12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500 |
- /*!
- * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
- * v1.0.0-beta.82
- */
- import { HTMLElement as HTMLElement$1, createEvent, h, Host, Build, forceUpdate, Fragment, getAssetPath, proxyCustomElement } from '@stencil/core/internal/client';
- export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client';
- const accordionCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([scale=s]){--calcite-accordion-item-spacing-unit:0.25rem;--calcite-accordion-icon-margin:0.5rem;--calcite-accordion-item-padding:var(--calcite-accordion-item-spacing-unit) 0.5rem;font-size:var(--calcite-font-size--2);line-height:1rem}:host([scale=m]){--calcite-accordion-item-spacing-unit:0.5rem;--calcite-accordion-icon-margin:0.75rem;--calcite-accordion-item-padding:var(--calcite-accordion-item-spacing-unit) 0.75rem;font-size:var(--calcite-font-size--1);line-height:1rem}:host([scale=l]){--calcite-accordion-item-spacing-unit:0.75rem;--calcite-accordion-icon-margin:1rem;--calcite-accordion-item-padding:var(--calcite-accordion-item-spacing-unit) 1rem;font-size:var(--calcite-font-size-0);line-height:1.25rem}:host{position:relative;display:block;max-width:100%;line-height:1.5rem;--calcite-accordion-item-border:var(--calcite-ui-border-2);--calcite-accordion-item-background:var(--calcite-ui-foreground-1)}.accordion--transparent{--calcite-accordion-item-border:transparent;--calcite-accordion-item-background:transparent}.accordion--minimal{--calcite-accordion-item-padding:var(--calcite-accordion-item-spacing-unit) 0}.accordion{border-width:1px;border-bottom-width:0px;border-style:solid;border-color:var(--calcite-ui-border-2)}";
- const Accordion = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteAccordionChange = createEvent(this, "calciteAccordionChange", 7);
- //--------------------------------------------------------------------------
- //
- // Public Properties
- //
- //--------------------------------------------------------------------------
- /** specify the appearance - default (containing border), or minimal (no containing border), defaults to default */
- this.appearance = "default";
- /** specify the placement of the icon in the header, defaults to end */
- this.iconPosition = "end";
- /** specify the type of the icon in the header, defaults to chevron */
- this.iconType = "chevron";
- /** specify the scale of accordion, defaults to m */
- this.scale = "m";
- /** specify the selection mode - multi (allow any number of open items), single (allow one open item),
- * or single-persist (allow and require one open item), defaults to multi */
- this.selectionMode = "multi";
- //--------------------------------------------------------------------------
- //
- // Private State/Props
- //
- //--------------------------------------------------------------------------
- /** created list of Accordion items */
- this.items = [];
- /** keep track of whether the items have been sorted so we don't re-sort */
- this.sorted = false;
- this.sortItems = (items) => items.sort((a, b) => a.position - b.position).map((a) => a.item);
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentDidLoad() {
- if (!this.sorted) {
- this.items = this.sortItems(this.items);
- this.sorted = true;
- }
- }
- render() {
- return (h("div", { class: {
- "accordion--transparent": this.appearance === "transparent",
- "accordion--minimal": this.appearance === "minimal",
- accordion: this.appearance === "default"
- } }, h("slot", null)));
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- calciteAccordionItemKeyEvent(e) {
- const item = e.detail.item;
- const parent = e.detail.parent;
- if (this.el === parent) {
- const key = item.key;
- const itemToFocus = e.target;
- const isFirstItem = this.itemIndex(itemToFocus) === 0;
- const isLastItem = this.itemIndex(itemToFocus) === this.items.length - 1;
- switch (key) {
- case "ArrowDown":
- if (isLastItem) {
- this.focusFirstItem();
- }
- else {
- this.focusNextItem(itemToFocus);
- }
- break;
- case "ArrowUp":
- if (isFirstItem) {
- this.focusLastItem();
- }
- else {
- this.focusPrevItem(itemToFocus);
- }
- break;
- case "Home":
- this.focusFirstItem();
- break;
- case "End":
- this.focusLastItem();
- break;
- }
- }
- }
- registerCalciteAccordionItem(e) {
- const item = {
- item: e.target,
- parent: e.detail.parent,
- position: e.detail.position
- };
- if (this.el === item.parent) {
- this.items.push(item);
- }
- }
- updateActiveItemOnChange(event) {
- this.requestedAccordionItem = event.detail.requestedAccordionItem;
- this.calciteAccordionChange.emit({
- requestedAccordionItem: this.requestedAccordionItem
- });
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- focusFirstItem() {
- const firstItem = this.items[0];
- this.focusElement(firstItem);
- }
- focusLastItem() {
- const lastItem = this.items[this.items.length - 1];
- this.focusElement(lastItem);
- }
- focusNextItem(e) {
- const index = this.itemIndex(e);
- const nextItem = this.items[index + 1] || this.items[0];
- this.focusElement(nextItem);
- }
- focusPrevItem(e) {
- const index = this.itemIndex(e);
- const prevItem = this.items[index - 1] || this.items[this.items.length - 1];
- this.focusElement(prevItem);
- }
- itemIndex(e) {
- return this.items.indexOf(e);
- }
- focusElement(item) {
- const target = item;
- target.focus();
- }
- get el() { return this; }
- static get style() { return accordionCss; }
- };
- const autoTheme = "calcite-theme-auto";
- const darkTheme = "calcite-theme-dark";
- const lightTheme = "calcite-theme-light";
- const CSS_UTILITY = {
- autoTheme,
- darkTheme,
- lightTheme,
- rtl: "calcite--rtl"
- };
- const TEXT$s = {
- loading: "Loading"
- };
- function gen(counts) {
- return counts
- .map((count) => {
- let out = "";
- for (let i = 0; i < count; i++) {
- out += (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
- }
- return out;
- })
- .join("-");
- }
- const guid = () => gen([2, 1, 1, 1, 3]);
- /**
- * This helper will guarantee an ID on the provided element.
- *
- * If it already has an ID, it will be preserved, otherwise a unique one will be generated and assigned.
- *
- * @returns {string} The element's ID.
- */
- function ensureId(el) {
- if (!el) {
- return "";
- }
- return (el.id = el.id || `${el.tagName.toLowerCase()}-${guid()}`);
- }
- function nodeListToArray(nodeList) {
- return Array.isArray(nodeList) ? nodeList : Array.from(nodeList);
- }
- function getThemeName(el) {
- const closestElWithTheme = closestElementCrossShadowBoundary(el, `.${CSS_UTILITY.darkTheme}, .${CSS_UTILITY.lightTheme}`);
- return (closestElWithTheme === null || closestElWithTheme === void 0 ? void 0 : closestElWithTheme.classList.contains("calcite-theme-dark")) ? "dark" : "light";
- }
- function getElementDir(el) {
- const prop = "dir";
- const selector = `[${prop}]`;
- const closest = closestElementCrossShadowBoundary(el, selector);
- return closest ? closest.getAttribute(prop) : "ltr";
- }
- function getElementProp(el, prop, fallbackValue) {
- const selector = `[${prop}]`;
- const closest = el.closest(selector);
- return closest ? closest.getAttribute(prop) : fallbackValue;
- }
- function getRootNode(el) {
- return el.getRootNode();
- }
- function getHost(root) {
- return root.host || null;
- }
- /**
- * This helper queries an element's rootNodes and any ancestor rootNodes.
- *
- * @returns {Element[]} The elements.
- */
- function queryElementsRoots(element, selector) {
- // Gets the rootNode and any ancestor rootNodes (shadowRoot or document) of an element and queries them for a selector.
- // Based on: https://stackoverflow.com/q/54520554/194216
- function queryFromAll(el, allResults) {
- if (!el) {
- return allResults;
- }
- if (el.assignedSlot) {
- el = el.assignedSlot;
- }
- const rootNode = getRootNode(el);
- const results = Array.from(rootNode.querySelectorAll(selector));
- const uniqueResults = results.filter((result) => !allResults.includes(result));
- allResults = [...allResults, ...uniqueResults];
- const host = getHost(rootNode);
- return host ? queryFromAll(host, allResults) : allResults;
- }
- return queryFromAll(element, []);
- }
- /**
- * This helper queries an element's rootNode and any ancestor rootNodes.
- *
- * If both an 'id' and 'selector' are supplied, 'id' will take precedence over 'selector'.
- *
- * @returns {Element} The element.
- */
- function queryElementRoots(element, { selector, id }) {
- // Gets the rootNode and any ancestor rootNodes (shadowRoot or document) of an element and queries them for a selector.
- // Based on: https://stackoverflow.com/q/54520554/194216
- function queryFrom(el) {
- if (!el) {
- return null;
- }
- if (el.assignedSlot) {
- el = el.assignedSlot;
- }
- const rootNode = getRootNode(el);
- const found = id
- ? "getElementById" in rootNode
- ? /*
- Check to make sure 'getElementById' exists in cases where element is no longer connected to the DOM and getRootNode() returns the element.
- https://github.com/Esri/calcite-components/pull/4280
- */
- rootNode.getElementById(id)
- : null
- : selector
- ? rootNode.querySelector(selector)
- : null;
- const host = getHost(rootNode);
- return found ? found : host ? queryFrom(host) : null;
- }
- return queryFrom(element);
- }
- function closestElementCrossShadowBoundary(element, selector) {
- // based on https://stackoverflow.com/q/54520554/194216
- function closestFrom(el) {
- return el ? el.closest(selector) || closestFrom(getHost(getRootNode(el))) : null;
- }
- return closestFrom(element);
- }
- function isCalciteFocusable(el) {
- return typeof (el === null || el === void 0 ? void 0 : el.setFocus) === "function";
- }
- async function focusElement(el) {
- if (!el) {
- return;
- }
- return isCalciteFocusable(el) ? el.setFocus() : el.focus();
- }
- const defaultSlotSelector = ":not([slot])";
- function getSlotted(element, slotName, options) {
- if (slotName && !Array.isArray(slotName) && typeof slotName !== "string") {
- options = slotName;
- slotName = null;
- }
- const slotSelector = slotName
- ? Array.isArray(slotName)
- ? slotName.map((name) => `[slot="${name}"]`).join(",")
- : `[slot="${slotName}"]`
- : defaultSlotSelector;
- if (options === null || options === void 0 ? void 0 : options.all) {
- return queryMultiple(element, slotSelector, options);
- }
- return querySingle(element, slotSelector, options);
- }
- function getDirectChildren(el, selector) {
- return el ? Array.from(el.children || []).filter((child) => child === null || child === void 0 ? void 0 : child.matches(selector)) : [];
- }
- function queryMultiple(element, slotSelector, options) {
- let matches = slotSelector === defaultSlotSelector
- ? getDirectChildren(element, defaultSlotSelector)
- : Array.from(element.querySelectorAll(slotSelector));
- matches = options && options.direct === false ? matches : matches.filter((el) => el.parentElement === element);
- matches = (options === null || options === void 0 ? void 0 : options.matches) ? matches.filter((el) => el === null || el === void 0 ? void 0 : el.matches(options.matches)) : matches;
- const selector = options === null || options === void 0 ? void 0 : options.selector;
- return selector
- ? matches
- .map((item) => Array.from(item.querySelectorAll(selector)))
- .reduce((previousValue, currentValue) => [...previousValue, ...currentValue], [])
- .filter((match) => !!match)
- : matches;
- }
- function querySingle(element, slotSelector, options) {
- let match = slotSelector === defaultSlotSelector
- ? getDirectChildren(element, defaultSlotSelector)[0] || null
- : element.querySelector(slotSelector);
- match = options && options.direct === false ? match : (match === null || match === void 0 ? void 0 : match.parentElement) === element ? match : null;
- match = (options === null || options === void 0 ? void 0 : options.matches) ? ((match === null || match === void 0 ? void 0 : match.matches(options.matches)) ? match : null) : match;
- const selector = options === null || options === void 0 ? void 0 : options.selector;
- return selector ? match === null || match === void 0 ? void 0 : match.querySelector(selector) : match;
- }
- function filterDirectChildren(el, selector) {
- return Array.from(el.children).filter((child) => child.matches(selector));
- }
- // set a default icon from a defined set or allow an override with an icon name string
- function setRequestedIcon(iconObject, iconValue, matchedValue) {
- if (typeof iconValue === "string" && iconValue !== "") {
- return iconValue;
- }
- else if (iconValue === "") {
- return iconObject[matchedValue];
- }
- }
- function intersects(rect1, rect2) {
- return !(rect2.left > rect1.right ||
- rect2.right < rect1.left ||
- rect2.top > rect1.bottom ||
- rect2.bottom < rect1.top);
- }
- /**
- * This helper makes sure that boolean aria attributes are properly converted to a string.
- *
- * It should only be used for aria attributes that require a string value of "true" or "false".
- *
- * @returns {string} The string conversion of a boolean value ("true" | "false").
- */
- function toAriaBoolean(value) {
- return (!!value).toString();
- }
- const accordionItemCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}.icon-position--end,.icon-position--start{--calcite-accordion-item-icon-rotation:calc(90deg * -1);--calcite-accordion-item-active-icon-rotation:0deg;--calcite-accordion-item-icon-rotation-rtl:90deg;--calcite-accordion-item-active-icon-rotation-rtl:0deg}.icon-position--start{--calcite-accordion-item-flex-direction:row-reverse;--calcite-accordion-item-icon-spacing-start:0;--calcite-accordion-item-icon-spacing-end:var(--calcite-accordion-icon-margin)}.icon-position--end{--calcite-accordion-item-flex-direction:row;--calcite-accordion-item-icon-spacing-start:var(--calcite-accordion-icon-margin);--calcite-accordion-item-icon-spacing-end:0}.icon-position--end:not(.icon-type--plus-minus){--calcite-accordion-item-icon-rotation:0deg;--calcite-accordion-item-active-icon-rotation:180deg;--calcite-accordion-item-icon-rotation-rtl:0deg;--calcite-accordion-item-active-icon-rotation-rtl:calc(180deg * -1)}:host{position:relative;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;color:var(--calcite-ui-text-3);-webkit-text-decoration-line:none;text-decoration-line:none;outline:2px solid transparent;outline-offset:2px;background-color:var(--calcite-accordion-item-background, var(--calcite-ui-foreground-1))}:host .accordion-item-header{outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out}:host(:focus) .accordion-item-header{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}:host([active]){color:var(--calcite-ui-text-1)}:host([active]) .accordion-item-content{display:block;color:var(--calcite-ui-text-1)}:host([active]) .accordion-item-header{border-bottom-color:transparent}:host .accordion-item-header{display:-ms-flexbox;display:flex;cursor:pointer;-ms-flex-align:center;align-items:center;-ms-flex-direction:var(--calcite-accordion-item-flex-direction);flex-direction:var(--calcite-accordion-item-flex-direction)}:host .accordion-item-icon{position:relative;margin:0px;display:-ms-inline-flexbox;display:inline-flex;color:var(--calcite-ui-text-3);-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);-webkit-margin-end:var(--calcite-accordion-item-icon-spacing-start);margin-inline-end:var(--calcite-accordion-item-icon-spacing-start);-webkit-margin-start:var(--calcite-accordion-item-icon-spacing-end);margin-inline-start:var(--calcite-accordion-item-icon-spacing-end)}:host .accordion-item-content,:host .accordion-item-header{padding:var(--calcite-accordion-item-padding);border-bottom:1px solid var(--calcite-accordion-item-border, var(--calcite-ui-border-2))}:host .accordion-item-header *{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}:host .accordion-item-content{display:none;padding-top:0px;color:var(--calcite-ui-text-3);text-align:initial}:host .accordion-item-expand-icon{color:var(--calcite-ui-text-3);-webkit-margin-start:var(--calcite-accordion-item-icon-spacing-start);margin-inline-start:var(--calcite-accordion-item-icon-spacing-start);-webkit-margin-end:var(--calcite-accordion-item-icon-spacing-end);margin-inline-end:var(--calcite-accordion-item-icon-spacing-end);-webkit-transform:rotate(var(--calcite-accordion-item-icon-rotation));transform:rotate(var(--calcite-accordion-item-icon-rotation))}.calcite--rtl .accordion-item-expand-icon{-webkit-transform:rotate(var(--calcite-accordion-item-icon-rotation-rtl));transform:rotate(var(--calcite-accordion-item-icon-rotation-rtl))}:host([active]) .accordion-item-expand-icon{color:var(--calcite-ui-text-1);-webkit-transform:rotate(var(--calcite-accordion-item-active-icon-rotation));transform:rotate(var(--calcite-accordion-item-active-icon-rotation))}:host([active]) .calcite--rtl .accordion-item-expand-icon{-webkit-transform:rotate(var(--calcite-accordion-item-active-icon-rotation-rtl));transform:rotate(var(--calcite-accordion-item-active-icon-rotation-rtl))}:host .accordion-item-header-text{margin-top:0px;margin-bottom:0px;-ms-flex-positive:1;flex-grow:1;-ms-flex-direction:column;flex-direction:column;padding-top:0px;padding-bottom:0px;text-align:initial;-webkit-margin-end:auto;margin-inline-end:auto}:host .accordion-item-title,:host .accordion-item-subtitle{display:-ms-flexbox;display:flex;width:100%}:host .accordion-item-title{font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-2)}:host .accordion-item-subtitle{margin-top:0.25rem;color:var(--calcite-ui-text-3)}:host(:focus) .accordion-item-title,:host(:hover) .accordion-item-title{color:var(--calcite-ui-text-1)}:host(:focus) .accordion-item-icon,:host(:hover) .accordion-item-icon{color:var(--calcite-ui-text-1)}:host(:focus) .accordion-item-expand-icon,:host(:hover) .accordion-item-expand-icon{color:var(--calcite-ui-text-1)}:host(:focus) .accordion-item-subtitle,:host(:hover) .accordion-item-subtitle{color:var(--calcite-ui-text-2)}:host(:focus) .accordion-item-title,:host(:active) .accordion-item-title,:host([active]) .accordion-item-title{color:var(--calcite-ui-text-1)}:host(:focus) .accordion-item-icon,:host(:active) .accordion-item-icon,:host([active]) .accordion-item-icon{color:var(--calcite-ui-text-1)}:host(:focus) .accordion-item-expand-icon,:host(:active) .accordion-item-expand-icon,:host([active]) .accordion-item-expand-icon{color:var(--calcite-ui-text-1)}:host(:focus) .accordion-item-subtitle,:host(:active) .accordion-item-subtitle,:host([active]) .accordion-item-subtitle{color:var(--calcite-ui-text-2)}";
- const AccordionItem = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteAccordionItemKeyEvent = createEvent(this, "calciteAccordionItemKeyEvent", 7);
- this.calciteAccordionItemSelect = createEvent(this, "calciteAccordionItemSelect", 7);
- this.calciteAccordionItemClose = createEvent(this, "calciteAccordionItemClose", 7);
- this.calciteAccordionItemRegister = createEvent(this, "calciteAccordionItemRegister", 7);
- //--------------------------------------------------------------------------
- //
- // Public Properties
- //
- //--------------------------------------------------------------------------
- /** Indicates whether the item is active. */
- this.active = false;
- //--------------------------------------------------------------------------
- //
- // Private State/Props
- //
- //--------------------------------------------------------------------------
- this.guid = guid();
- /** what icon position does the parent accordion specify */
- this.iconPosition = "end";
- /** handle clicks on item header */
- this.itemHeaderClickHandler = () => this.emitRequestedItem();
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- this.parent = this.el.parentElement;
- this.selectionMode = getElementProp(this.el, "selection-mode", "multi");
- this.iconType = getElementProp(this.el, "icon-type", "chevron");
- this.iconPosition = getElementProp(this.el, "icon-position", this.iconPosition);
- }
- componentDidLoad() {
- this.itemPosition = this.getItemPosition();
- this.calciteAccordionItemRegister.emit({
- parent: this.parent,
- position: this.itemPosition
- });
- }
- render() {
- const dir = getElementDir(this.el);
- const iconEl = h("calcite-icon", { class: "accordion-item-icon", icon: this.icon, scale: "s" });
- const { guid } = this;
- const regionId = `${guid}-region`;
- const buttonId = `${guid}-button`;
- return (h(Host, { tabindex: "0" }, h("div", { class: {
- [`icon-position--${this.iconPosition}`]: true,
- [`icon-type--${this.iconType}`]: true
- } }, h("div", { "aria-controls": regionId, class: { "accordion-item-header": true, [CSS_UTILITY.rtl]: dir === "rtl" }, id: buttonId, onClick: this.itemHeaderClickHandler, role: "button" }, this.icon ? iconEl : null, h("div", { class: "accordion-item-header-text" }, h("span", { class: "accordion-item-title" }, this.itemTitle), this.itemSubtitle ? (h("span", { class: "accordion-item-subtitle" }, this.itemSubtitle)) : null), h("calcite-icon", { class: "accordion-item-expand-icon", icon: this.iconType === "chevron"
- ? "chevronDown"
- : this.iconType === "caret"
- ? "caretDown"
- : this.active
- ? "minus"
- : "plus", scale: "s" })), h("div", { "aria-expanded": toAriaBoolean(this.active), "aria-labelledby": buttonId, class: "accordion-item-content", id: regionId, role: "region" }, h("slot", null)))));
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- keyDownHandler(e) {
- if (e.target === this.el) {
- switch (e.key) {
- case " ":
- case "Enter":
- this.emitRequestedItem();
- e.preventDefault();
- break;
- case "ArrowUp":
- case "ArrowDown":
- case "Home":
- case "End":
- this.calciteAccordionItemKeyEvent.emit({
- parent: this.parent,
- item: e
- });
- e.preventDefault();
- break;
- }
- }
- }
- updateActiveItemOnChange(event) {
- this.requestedAccordionItem = event.detail
- .requestedAccordionItem;
- if (this.el.parentNode !== this.requestedAccordionItem.parentNode) {
- return;
- }
- this.determineActiveItem();
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- determineActiveItem() {
- switch (this.selectionMode) {
- case "multi":
- if (this.el === this.requestedAccordionItem) {
- this.active = !this.active;
- }
- break;
- case "single":
- this.active = this.el === this.requestedAccordionItem ? !this.active : false;
- break;
- case "single-persist":
- this.active = this.el === this.requestedAccordionItem;
- break;
- }
- }
- emitRequestedItem() {
- this.calciteAccordionItemSelect.emit({
- requestedAccordionItem: this.el
- });
- }
- getItemPosition() {
- return Array.prototype.indexOf.call(this.parent.querySelectorAll("calcite-accordion-item"), this.el);
- }
- get el() { return this; }
- static get style() { return accordionItemCss; }
- };
- const CSS$P = {
- button: "button",
- buttonTextVisible: "button--text-visible",
- buttonCompact: "button--compact",
- iconContainer: "icon-container",
- slotContainer: "slot-container",
- slotContainerHidden: "slot-container--hidden",
- textContainer: "text-container",
- textContainerVisible: "text-container--visible"
- };
- const TEXT$r = {
- loading: "Loading"
- };
- /**
- * This utility ensures observers are created only for browser contexts.
- *
- * @param type - the type of observer to create
- * @param callback - the observer callback
- * @param options - the observer options
- */
- function createObserver(type, callback, options) {
- const Observer = getObserver(type);
- return Build.isBrowser ? new Observer(callback, options) : undefined;
- }
- function getObserver(type) {
- return (type === "intersection"
- ? window.IntersectionObserver
- : type === "mutation"
- ? window.MutationObserver
- : window.ResizeObserver);
- }
- function noopClick() {
- /** noop **/
- }
- /**
- * This helper updates the host element to prevent keyboard interaction on its subtree and sets the appropriate aria attribute for accessibility.
- *
- * This should be used in the `componentDidRender` lifecycle hook.
- *
- * **Notes**
- *
- * * this util is not needed for simple components whose root element or elements are an interactive component (custom element or native control). For those cases, set the `disabled` props on the root components instead.
- * * technically, users can override `tabindex` and restore keyboard navigation, but this will be considered user error
- */
- function updateHostInteraction(component, hostIsTabbable = false) {
- if (component.disabled) {
- component.el.setAttribute("tabindex", "-1");
- component.el.setAttribute("aria-disabled", "true");
- if (component.el.contains(document.activeElement)) {
- document.activeElement.blur();
- }
- component.el.click = noopClick;
- return;
- }
- component.el.click = HTMLElement.prototype.click;
- if (typeof hostIsTabbable === "function") {
- component.el.setAttribute("tabindex", hostIsTabbable.call(component) ? "0" : "-1");
- }
- else if (hostIsTabbable === true) {
- component.el.setAttribute("tabindex", "0");
- }
- else if (hostIsTabbable === false) {
- component.el.removeAttribute("tabindex");
- }
- else ;
- component.el.removeAttribute("aria-disabled");
- }
- const actionCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:host{-webkit-box-sizing:border-box;box-sizing:border-box;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-2);font-size:var(--calcite-font-size--1)}:host *{-webkit-box-sizing:border-box;box-sizing:border-box}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:-ms-flexbox;display:flex;background-color:transparent}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.button{position:relative;margin:0px;display:-ms-flexbox;display:flex;width:auto;cursor:pointer;-ms-flex-align:center;align-items:center;-ms-flex-pack:start;justify-content:flex-start;border-style:none;background-color:var(--calcite-ui-foreground-1);fill:var(--calcite-ui-text-3);font-family:var(--calcite-sans-family);font-size:var(--calcite-font-size--2);line-height:1rem;font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-3);outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;text-align:unset;-ms-flex:1 0 auto;flex:1 0 auto}.button:hover{background-color:var(--calcite-ui-foreground-2);fill:var(--calcite-ui-text-1);color:var(--calcite-ui-text-1)}.button:focus{background-color:var(--calcite-ui-foreground-2);fill:var(--calcite-ui-text-1);color:var(--calcite-ui-text-1);outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.button:active{background-color:var(--calcite-ui-foreground-3)}.button .icon-container{pointer-events:none;margin:0px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;min-width:1rem;min-height:1rem}.button .text-container{margin:0px;width:0px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1rem;opacity:0;-webkit-transition-property:opacity;transition-property:opacity;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);-webkit-transition-property:margin;transition-property:margin;-webkit-transition-property:width;transition-property:width}.button .text-container--visible{width:auto;-ms-flex:1 1 auto;flex:1 1 auto;opacity:1}:host([scale=s]) .button{padding:0.5rem;font-size:var(--calcite-font-size--2);line-height:1rem;font-weight:var(--calcite-font-weight-normal)}:host([scale=s]) .button--text-visible .icon-container{-webkit-margin-end:0.5rem;margin-inline-end:0.5rem}:host([scale=m]) .button{padding:1rem;font-size:var(--calcite-font-size--1);line-height:1rem;font-weight:var(--calcite-font-weight-normal)}:host([scale=m]) .button--text-visible .icon-container{-webkit-margin-end:0.75rem;margin-inline-end:0.75rem}:host([scale=l]) .button{padding:1.25rem;font-size:var(--calcite-font-size-0);line-height:1.25rem;font-weight:var(--calcite-font-weight-normal)}:host([scale=l]) .button--text-visible .icon-container{-webkit-margin-end:1rem;margin-inline-end:1rem}:host([alignment=center]) .button{-ms-flex-pack:center;justify-content:center}:host([alignment=end]) .button{-ms-flex-pack:end;justify-content:flex-end}:host([alignment=center]) .button .text-container--visible,:host([alignment=end]) .button .text-container--visible{-ms-flex:0 1 auto;flex:0 1 auto}:host([scale=s][compact]) .button,:host([scale=m][compact]) .button,:host([scale=l][compact]) .button{padding-left:0px;padding-right:0px}.slot-container{display:-ms-flexbox;display:flex}.slot-container--hidden{display:none}.button--text-visible{width:100%}:host([active]) .button,:host([active]) .button:hover,:host([active]) .button:focus,:host([active][loading]) .button{background-color:var(--calcite-ui-foreground-3);fill:var(--calcite-ui-text-1);color:var(--calcite-ui-text-1)}:host([active]) .button:active{background-color:var(--calcite-ui-foreground-1)}:host([appearance=clear]) .button{background-color:transparent;-webkit-transition-property:-webkit-box-shadow;transition-property:-webkit-box-shadow;transition-property:box-shadow;transition-property:box-shadow, -webkit-box-shadow;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}:host([appearance=clear]) .button:hover,:host([appearance=clear]) .button:focus{background-color:transparent;-webkit-box-shadow:0 0 0 2px var(--calcite-ui-border-1) inset;box-shadow:0 0 0 2px var(--calcite-ui-border-1) inset}:host([active][appearance=clear]) .button,:host([active][appearance=clear]) .button:hover,:host([active][appearance=clear]) .button:focus{background-color:var(--calcite-ui-foreground-3);fill:var(--calcite-ui-text-1);color:var(--calcite-ui-text-1)}:host([appearance=clear][loading]) .button,:host([appearance=clear][disabled]) .button{background-color:transparent}:host([loading]) .button,:host([loading]) .button:hover,:host([loading]) .button:focus{background-color:var(--calcite-ui-foreground-1)}:host([loading]) .button .text-container,:host([loading]) .button:hover .text-container,:host([loading]) .button:focus .text-container{opacity:var(--calcite-ui-opacity-disabled)}:host([loading]) calcite-loader[inline]{margin-right:0px;color:var(--calcite-ui-text-3)}:host([disabled]) .button,:host([disabled]) .button:hover,:host([disabled]) .button:focus{cursor:default;background-color:var(--calcite-ui-foreground-1);opacity:var(--calcite-ui-opacity-disabled)}:host([disabled][active]) .button,:host([disabled][active]) .button:hover,:host([disabled][active]) .button:focus{background-color:var(--calcite-ui-foreground-3);opacity:var(--calcite-ui-opacity-disabled)}:host([indicator]) .button::after{content:\"\";position:absolute;z-index:10;height:0.5rem;width:0.5rem;border-radius:9999px;border-width:2px;background-color:var(--calcite-ui-brand);border-color:var(--calcite-ui-foreground-1);inset-block-end:0.75rem;inset-inline-end:0.75rem}:host([indicator]) .button--text-visible::after{inset-block-end:auto}:host([indicator]) .button--text-visible .text-container--visible{-webkit-margin-end:1rem;margin-inline-end:1rem}:host([indicator]) .button:hover::after,:host([indicator]) .button:focus::after{border-color:var(--calcite-ui-foreground-1)}:host([indicator][scale=s]) .button::after{inset-block-end:0.25rem;inset-inline-end:0.25rem}:host([indicator][scale=s]) .button--text-visible::after{inset-block-end:auto;inset-inline-end:0.5rem}:host([indicator][active]) .button::after{border-color:var(--calcite-ui-foreground-3)}";
- const Action = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteActionClick = createEvent(this, "calciteActionClick", 7);
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * Indicates whether the action is highlighted.
- */
- this.active = false;
- /** Specify the appearance style of the action, defaults to solid. */
- this.appearance = "solid";
- /**
- * Compact mode is used internally by components to reduce side padding, e.g. calcite-block-section.
- */
- this.compact = false;
- /**
- * When true, disabled prevents interaction. This state shows items with lower opacity/grayed.
- */
- this.disabled = false;
- /**
- * Indicates unread changes.
- */
- this.indicator = false;
- /** string to override English loading text
- * @default "Loading"
- */
- this.intlLoading = TEXT$r.loading;
- /**
- * When true, content is waiting to be loaded. This state shows a busy indicator.
- */
- this.loading = false;
- /**
- * Specifies the size of the action.
- */
- this.scale = "m";
- /**
- * Indicates whether the text is displayed.
- */
- this.textEnabled = false;
- this.mutationObserver = createObserver("mutation", () => forceUpdate(this));
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- this.calciteActionClickHandler = () => {
- if (!this.disabled) {
- this.calciteActionClick.emit();
- }
- };
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- var _a;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
- }
- disconnectedCallback() {
- var _a;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- // --------------------------------------------------------------------------
- //
- // Methods
- //
- // --------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- this.buttonEl.focus();
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- renderTextContainer() {
- const { text, textEnabled } = this;
- const textContainerClasses = {
- [CSS$P.textContainer]: true,
- [CSS$P.textContainerVisible]: textEnabled
- };
- return text ? (h("div", { class: textContainerClasses, key: "text-container" }, text)) : null;
- }
- renderIconContainer() {
- var _a;
- const { loading, icon, scale, el, intlLoading } = this;
- const iconScale = scale === "l" ? "m" : "s";
- const loaderScale = scale === "l" ? "l" : "m";
- const calciteLoaderNode = loading ? (h("calcite-loader", { active: true, inline: true, label: intlLoading, scale: loaderScale })) : null;
- const calciteIconNode = icon ? h("calcite-icon", { icon: icon, scale: iconScale }) : null;
- const iconNode = calciteLoaderNode || calciteIconNode;
- const hasIconToDisplay = iconNode || ((_a = el.children) === null || _a === void 0 ? void 0 : _a.length);
- const slotContainerNode = (h("div", { class: {
- [CSS$P.slotContainer]: true,
- [CSS$P.slotContainerHidden]: loading
- } }, h("slot", null)));
- return hasIconToDisplay ? (h("div", { "aria-hidden": "true", class: CSS$P.iconContainer, key: "icon-container" }, iconNode, slotContainerNode)) : null;
- }
- render() {
- const { compact, disabled, loading, textEnabled, label, text } = this;
- const ariaLabel = label || text;
- const buttonClasses = {
- [CSS$P.button]: true,
- [CSS$P.buttonTextVisible]: textEnabled,
- [CSS$P.buttonCompact]: compact
- };
- return (h(Host, { onClick: this.calciteActionClickHandler }, h("button", { "aria-busy": toAriaBoolean(loading), "aria-disabled": toAriaBoolean(disabled), "aria-label": ariaLabel, class: buttonClasses, disabled: disabled, ref: (buttonEl) => (this.buttonEl = buttonEl) }, this.renderIconContainer(), this.renderTextContainer())));
- }
- get el() { return this; }
- static get style() { return actionCss; }
- };
- const CSS$O = {
- menu: "menu",
- defaultTrigger: "default-trigger"
- };
- const SLOTS$p = {
- tooltip: "tooltip",
- trigger: "trigger"
- };
- const ICONS$f = {
- menu: "ellipsis"
- };
- const SLOTS$o = {
- menuActions: "menu-actions",
- menuTooltip: "menu-tooltip"
- };
- const TEXT$q = {
- more: "More"
- };
- const ICONS$e = {
- menu: "ellipsis"
- };
- const overflowActionsDebounceInMs = 150;
- const groupBufferHeight = 2;
- const getMaxActionCount = ({ height, actionHeight, groupCount }) => {
- return Math.floor((height - groupCount * groupBufferHeight) / actionHeight);
- };
- const getOverflowCount = ({ actionCount, actionHeight, height, groupCount }) => {
- return Math.max(actionCount - getMaxActionCount({ height, actionHeight, groupCount }), 0);
- };
- const queryActions = (el) => {
- return Array.from(el.querySelectorAll("calcite-action")).filter((action) => action.closest("calcite-action-menu") ? action.slot === SLOTS$p.trigger : true);
- };
- const overflowActions = ({ actionGroups, expanded, overflowCount }) => {
- let needToSlotCount = overflowCount;
- actionGroups.reverse().forEach((group) => {
- let slottedWithinGroupCount = 0;
- const groupActions = queryActions(group).reverse();
- groupActions.forEach((groupAction) => {
- if (groupAction.slot === SLOTS$o.menuActions) {
- groupAction.removeAttribute("slot");
- groupAction.textEnabled = expanded;
- }
- });
- if (needToSlotCount > 0) {
- groupActions.some((groupAction) => {
- const unslottedActions = groupActions.filter((action) => !action.slot);
- if (unslottedActions.length > 1 && groupActions.length > 2 && !groupAction.closest("calcite-action-menu")) {
- groupAction.textEnabled = true;
- groupAction.setAttribute("slot", SLOTS$o.menuActions);
- slottedWithinGroupCount++;
- if (slottedWithinGroupCount > 1) {
- needToSlotCount--;
- }
- }
- return needToSlotCount < 1;
- });
- }
- forceUpdate(group);
- });
- };
- const ICONS$d = {
- chevronsLeft: "chevrons-left",
- chevronsRight: "chevrons-right"
- };
- function getCalcitePosition(position, el) {
- var _a;
- return position || ((_a = el.closest("calcite-shell-panel")) === null || _a === void 0 ? void 0 : _a.position) || "start";
- }
- function toggleChildActionText({ parent, expanded }) {
- queryActions(parent)
- .filter((el) => el.slot !== SLOTS$o.menuActions)
- .forEach((action) => (action.textEnabled = expanded));
- parent.querySelectorAll("calcite-action-group").forEach((group) => (group.expanded = expanded));
- }
- const setTooltipReference = ({ tooltip, referenceElement, expanded, ref }) => {
- if (tooltip) {
- tooltip.referenceElement = !expanded && referenceElement ? referenceElement : null;
- }
- if (ref) {
- ref(referenceElement);
- }
- return referenceElement;
- };
- const ExpandToggle = ({ expanded, intlExpand, intlCollapse, toggle, el, position, tooltip, ref, scale }) => {
- const rtl = getElementDir(el) === "rtl";
- const expandText = expanded ? intlCollapse : intlExpand;
- const icons = [ICONS$d.chevronsLeft, ICONS$d.chevronsRight];
- if (rtl) {
- icons.reverse();
- }
- const end = getCalcitePosition(position, el) === "end";
- const expandIcon = end ? icons[1] : icons[0];
- const collapseIcon = end ? icons[0] : icons[1];
- const actionNode = (h("calcite-action", { icon: expanded ? expandIcon : collapseIcon, onClick: toggle, ref: (referenceElement) => setTooltipReference({ tooltip, referenceElement, expanded, ref }), scale: scale, text: expandText, textEnabled: expanded }));
- return actionNode;
- };
- const CSS$N = {
- actionGroupBottom: "action-group--bottom"
- };
- const SLOTS$n = {
- bottomActions: "bottom-actions",
- expandTooltip: "expand-tooltip"
- };
- const TEXT$p = {
- expand: "Expand",
- collapse: "Collapse"
- };
- /** Detect free variable `global` from Node.js. */
- var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
- /** Detect free variable `self`. */
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
- /** Used as a reference to the global object. */
- var root = freeGlobal || freeSelf || Function('return this')();
- /** Built-in value references. */
- var Symbol$1 = root.Symbol;
- /** Used for built-in method references. */
- var objectProto$5 = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty$3 = objectProto$5.hasOwnProperty;
- /**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
- * of values.
- */
- var nativeObjectToString$1 = objectProto$5.toString;
- /** Built-in value references. */
- var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
- /**
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
- *
- * @private
- * @param {*} value The value to query.
- * @returns {string} Returns the raw `toStringTag`.
- */
- function getRawTag(value) {
- var isOwn = hasOwnProperty$3.call(value, symToStringTag$1),
- tag = value[symToStringTag$1];
- try {
- value[symToStringTag$1] = undefined;
- var unmasked = true;
- } catch (e) {}
- var result = nativeObjectToString$1.call(value);
- if (unmasked) {
- if (isOwn) {
- value[symToStringTag$1] = tag;
- } else {
- delete value[symToStringTag$1];
- }
- }
- return result;
- }
- /** Used for built-in method references. */
- var objectProto$4 = Object.prototype;
- /**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
- * of values.
- */
- var nativeObjectToString = objectProto$4.toString;
- /**
- * Converts `value` to a string using `Object.prototype.toString`.
- *
- * @private
- * @param {*} value The value to convert.
- * @returns {string} Returns the converted string.
- */
- function objectToString(value) {
- return nativeObjectToString.call(value);
- }
- /** `Object#toString` result references. */
- var nullTag = '[object Null]',
- undefinedTag = '[object Undefined]';
- /** Built-in value references. */
- var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
- /**
- * The base implementation of `getTag` without fallbacks for buggy environments.
- *
- * @private
- * @param {*} value The value to query.
- * @returns {string} Returns the `toStringTag`.
- */
- function baseGetTag(value) {
- if (value == null) {
- return value === undefined ? undefinedTag : nullTag;
- }
- return (symToStringTag && symToStringTag in Object(value))
- ? getRawTag(value)
- : objectToString(value);
- }
- /**
- * Checks if `value` is object-like. A value is object-like if it's not `null`
- * and has a `typeof` result of "object".
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
- * @example
- *
- * _.isObjectLike({});
- * // => true
- *
- * _.isObjectLike([1, 2, 3]);
- * // => true
- *
- * _.isObjectLike(_.noop);
- * // => false
- *
- * _.isObjectLike(null);
- * // => false
- */
- function isObjectLike(value) {
- return value != null && typeof value == 'object';
- }
- /** `Object#toString` result references. */
- var symbolTag = '[object Symbol]';
- /**
- * Checks if `value` is classified as a `Symbol` primitive or object.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
- * @example
- *
- * _.isSymbol(Symbol.iterator);
- * // => true
- *
- * _.isSymbol('abc');
- * // => false
- */
- function isSymbol(value) {
- return typeof value == 'symbol' ||
- (isObjectLike(value) && baseGetTag(value) == symbolTag);
- }
- /**
- * A specialized version of `_.map` for arrays without support for iteratee
- * shorthands.
- *
- * @private
- * @param {Array} [array] The array to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns the new mapped array.
- */
- function arrayMap(array, iteratee) {
- var index = -1,
- length = array == null ? 0 : array.length,
- result = Array(length);
- while (++index < length) {
- result[index] = iteratee(array[index], index, array);
- }
- return result;
- }
- /**
- * Checks if `value` is classified as an `Array` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
- * @example
- *
- * _.isArray([1, 2, 3]);
- * // => true
- *
- * _.isArray(document.body.children);
- * // => false
- *
- * _.isArray('abc');
- * // => false
- *
- * _.isArray(_.noop);
- * // => false
- */
- var isArray = Array.isArray;
- /** Used as references for various `Number` constants. */
- var INFINITY = 1 / 0;
- /** Used to convert symbols to primitives and strings. */
- var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
- symbolToString = symbolProto ? symbolProto.toString : undefined;
- /**
- * The base implementation of `_.toString` which doesn't convert nullish
- * values to empty strings.
- *
- * @private
- * @param {*} value The value to process.
- * @returns {string} Returns the string.
- */
- function baseToString(value) {
- // Exit early for strings to avoid a performance hit in some environments.
- if (typeof value == 'string') {
- return value;
- }
- if (isArray(value)) {
- // Recursively convert values (susceptible to call stack limits).
- return arrayMap(value, baseToString) + '';
- }
- if (isSymbol(value)) {
- return symbolToString ? symbolToString.call(value) : '';
- }
- var result = (value + '');
- return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
- }
- /** Used to match a single whitespace character. */
- var reWhitespace = /\s/;
- /**
- * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
- * character of `string`.
- *
- * @private
- * @param {string} string The string to inspect.
- * @returns {number} Returns the index of the last non-whitespace character.
- */
- function trimmedEndIndex(string) {
- var index = string.length;
- while (index-- && reWhitespace.test(string.charAt(index))) {}
- return index;
- }
- /** Used to match leading whitespace. */
- var reTrimStart = /^\s+/;
- /**
- * The base implementation of `_.trim`.
- *
- * @private
- * @param {string} string The string to trim.
- * @returns {string} Returns the trimmed string.
- */
- function baseTrim(string) {
- return string
- ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
- : string;
- }
- /**
- * Checks if `value` is the
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
- * @example
- *
- * _.isObject({});
- * // => true
- *
- * _.isObject([1, 2, 3]);
- * // => true
- *
- * _.isObject(_.noop);
- * // => true
- *
- * _.isObject(null);
- * // => false
- */
- function isObject(value) {
- var type = typeof value;
- return value != null && (type == 'object' || type == 'function');
- }
- /** Used as references for various `Number` constants. */
- var NAN = 0 / 0;
- /** Used to detect bad signed hexadecimal string values. */
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
- /** Used to detect binary string values. */
- var reIsBinary = /^0b[01]+$/i;
- /** Used to detect octal string values. */
- var reIsOctal = /^0o[0-7]+$/i;
- /** Built-in method references without a dependency on `root`. */
- var freeParseInt = parseInt;
- /**
- * Converts `value` to a number.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to process.
- * @returns {number} Returns the number.
- * @example
- *
- * _.toNumber(3.2);
- * // => 3.2
- *
- * _.toNumber(Number.MIN_VALUE);
- * // => 5e-324
- *
- * _.toNumber(Infinity);
- * // => Infinity
- *
- * _.toNumber('3.2');
- * // => 3.2
- */
- function toNumber(value) {
- if (typeof value == 'number') {
- return value;
- }
- if (isSymbol(value)) {
- return NAN;
- }
- if (isObject(value)) {
- var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
- value = isObject(other) ? (other + '') : other;
- }
- if (typeof value != 'string') {
- return value === 0 ? value : +value;
- }
- value = baseTrim(value);
- var isBinary = reIsBinary.test(value);
- return (isBinary || reIsOctal.test(value))
- ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
- : (reIsBadHex.test(value) ? NAN : +value);
- }
- /**
- * This method returns the first argument it receives.
- *
- * @static
- * @since 0.1.0
- * @memberOf _
- * @category Util
- * @param {*} value Any value.
- * @returns {*} Returns `value`.
- * @example
- *
- * var object = { 'a': 1 };
- *
- * console.log(_.identity(object) === object);
- * // => true
- */
- function identity(value) {
- return value;
- }
- /** `Object#toString` result references. */
- var asyncTag = '[object AsyncFunction]',
- funcTag$1 = '[object Function]',
- genTag = '[object GeneratorFunction]',
- proxyTag = '[object Proxy]';
- /**
- * Checks if `value` is classified as a `Function` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
- * @example
- *
- * _.isFunction(_);
- * // => true
- *
- * _.isFunction(/abc/);
- * // => false
- */
- function isFunction(value) {
- if (!isObject(value)) {
- return false;
- }
- // The use of `Object#toString` avoids issues with the `typeof` operator
- // in Safari 9 which returns 'object' for typed arrays and other constructors.
- var tag = baseGetTag(value);
- return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
- }
- /** Used as references for various `Number` constants. */
- var MAX_SAFE_INTEGER$1 = 9007199254740991;
- /** Used to detect unsigned integer values. */
- var reIsUint = /^(?:0|[1-9]\d*)$/;
- /**
- * Checks if `value` is a valid array-like index.
- *
- * @private
- * @param {*} value The value to check.
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
- */
- function isIndex(value, length) {
- var type = typeof value;
- length = length == null ? MAX_SAFE_INTEGER$1 : length;
- return !!length &&
- (type == 'number' ||
- (type != 'symbol' && reIsUint.test(value))) &&
- (value > -1 && value % 1 == 0 && value < length);
- }
- /** Used as references for various `Number` constants. */
- var MAX_SAFE_INTEGER = 9007199254740991;
- /**
- * Checks if `value` is a valid array-like length.
- *
- * **Note:** This method is loosely based on
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
- * @example
- *
- * _.isLength(3);
- * // => true
- *
- * _.isLength(Number.MIN_VALUE);
- * // => false
- *
- * _.isLength(Infinity);
- * // => false
- *
- * _.isLength('3');
- * // => false
- */
- function isLength(value) {
- return typeof value == 'number' &&
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
- }
- /**
- * Checks if `value` is array-like. A value is considered array-like if it's
- * not a function and has a `value.length` that's an integer greater than or
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
- * @example
- *
- * _.isArrayLike([1, 2, 3]);
- * // => true
- *
- * _.isArrayLike(document.body.children);
- * // => true
- *
- * _.isArrayLike('abc');
- * // => true
- *
- * _.isArrayLike(_.noop);
- * // => false
- */
- function isArrayLike(value) {
- return value != null && isLength(value.length) && !isFunction(value);
- }
- /** Used for built-in method references. */
- var objectProto$3 = Object.prototype;
- /**
- * Checks if `value` is likely a prototype object.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
- */
- function isPrototype(value) {
- var Ctor = value && value.constructor,
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$3;
- return value === proto;
- }
- /**
- * The base implementation of `_.times` without support for iteratee shorthands
- * or max array length checks.
- *
- * @private
- * @param {number} n The number of times to invoke `iteratee`.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns the array of results.
- */
- function baseTimes(n, iteratee) {
- var index = -1,
- result = Array(n);
- while (++index < n) {
- result[index] = iteratee(index);
- }
- return result;
- }
- /** `Object#toString` result references. */
- var argsTag$1 = '[object Arguments]';
- /**
- * The base implementation of `_.isArguments`.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
- */
- function baseIsArguments(value) {
- return isObjectLike(value) && baseGetTag(value) == argsTag$1;
- }
- /** Used for built-in method references. */
- var objectProto$2 = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
- /** Built-in value references. */
- var propertyIsEnumerable = objectProto$2.propertyIsEnumerable;
- /**
- * Checks if `value` is likely an `arguments` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
- * else `false`.
- * @example
- *
- * _.isArguments(function() { return arguments; }());
- * // => true
- *
- * _.isArguments([1, 2, 3]);
- * // => false
- */
- var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
- return isObjectLike(value) && hasOwnProperty$2.call(value, 'callee') &&
- !propertyIsEnumerable.call(value, 'callee');
- };
- /**
- * This method returns `false`.
- *
- * @static
- * @memberOf _
- * @since 4.13.0
- * @category Util
- * @returns {boolean} Returns `false`.
- * @example
- *
- * _.times(2, _.stubFalse);
- * // => [false, false]
- */
- function stubFalse() {
- return false;
- }
- /** Detect free variable `exports`. */
- var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
- /** Detect free variable `module`. */
- var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
- /** Detect the popular CommonJS extension `module.exports`. */
- var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
- /** Built-in value references. */
- var Buffer = moduleExports$1 ? root.Buffer : undefined;
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
- /**
- * Checks if `value` is a buffer.
- *
- * @static
- * @memberOf _
- * @since 4.3.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
- * @example
- *
- * _.isBuffer(new Buffer(2));
- * // => true
- *
- * _.isBuffer(new Uint8Array(2));
- * // => false
- */
- var isBuffer = nativeIsBuffer || stubFalse;
- /** `Object#toString` result references. */
- var argsTag = '[object Arguments]',
- arrayTag = '[object Array]',
- boolTag = '[object Boolean]',
- dateTag = '[object Date]',
- errorTag = '[object Error]',
- funcTag = '[object Function]',
- mapTag = '[object Map]',
- numberTag = '[object Number]',
- objectTag = '[object Object]',
- regexpTag = '[object RegExp]',
- setTag = '[object Set]',
- stringTag = '[object String]',
- weakMapTag = '[object WeakMap]';
- var arrayBufferTag = '[object ArrayBuffer]',
- dataViewTag = '[object DataView]',
- float32Tag = '[object Float32Array]',
- float64Tag = '[object Float64Array]',
- int8Tag = '[object Int8Array]',
- int16Tag = '[object Int16Array]',
- int32Tag = '[object Int32Array]',
- uint8Tag = '[object Uint8Array]',
- uint8ClampedTag = '[object Uint8ClampedArray]',
- uint16Tag = '[object Uint16Array]',
- uint32Tag = '[object Uint32Array]';
- /** Used to identify `toStringTag` values of typed arrays. */
- var typedArrayTags = {};
- typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
- typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
- typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
- typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
- typedArrayTags[uint32Tag] = true;
- typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
- typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
- typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
- typedArrayTags[errorTag] = typedArrayTags[funcTag] =
- typedArrayTags[mapTag] = typedArrayTags[numberTag] =
- typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
- typedArrayTags[setTag] = typedArrayTags[stringTag] =
- typedArrayTags[weakMapTag] = false;
- /**
- * The base implementation of `_.isTypedArray` without Node.js optimizations.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
- */
- function baseIsTypedArray(value) {
- return isObjectLike(value) &&
- isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
- }
- /**
- * The base implementation of `_.unary` without support for storing metadata.
- *
- * @private
- * @param {Function} func The function to cap arguments for.
- * @returns {Function} Returns the new capped function.
- */
- function baseUnary(func) {
- return function(value) {
- return func(value);
- };
- }
- /** Detect free variable `exports`. */
- var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
- /** Detect free variable `module`. */
- var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
- /** Detect the popular CommonJS extension `module.exports`. */
- var moduleExports = freeModule && freeModule.exports === freeExports;
- /** Detect free variable `process` from Node.js. */
- var freeProcess = moduleExports && freeGlobal.process;
- /** Used to access faster Node.js helpers. */
- var nodeUtil = (function() {
- try {
- // Use `util.types` for Node.js 10+.
- var types = freeModule && freeModule.require && freeModule.require('util').types;
- if (types) {
- return types;
- }
- // Legacy `process.binding('util')` for Node.js < 10.
- return freeProcess && freeProcess.binding && freeProcess.binding('util');
- } catch (e) {}
- }());
- /* Node.js helper references. */
- var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
- /**
- * Checks if `value` is classified as a typed array.
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
- * @example
- *
- * _.isTypedArray(new Uint8Array);
- * // => true
- *
- * _.isTypedArray([]);
- * // => false
- */
- var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
- /** Used for built-in method references. */
- var objectProto$1 = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
- /**
- * Creates an array of the enumerable property names of the array-like `value`.
- *
- * @private
- * @param {*} value The value to query.
- * @param {boolean} inherited Specify returning inherited property names.
- * @returns {Array} Returns the array of property names.
- */
- function arrayLikeKeys(value, inherited) {
- var isArr = isArray(value),
- isArg = !isArr && isArguments(value),
- isBuff = !isArr && !isArg && isBuffer(value),
- isType = !isArr && !isArg && !isBuff && isTypedArray(value),
- skipIndexes = isArr || isArg || isBuff || isType,
- result = skipIndexes ? baseTimes(value.length, String) : [],
- length = result.length;
- for (var key in value) {
- if ((inherited || hasOwnProperty$1.call(value, key)) &&
- !(skipIndexes && (
- // Safari 9 has enumerable `arguments.length` in strict mode.
- key == 'length' ||
- // Node.js 0.10 has enumerable non-index properties on buffers.
- (isBuff && (key == 'offset' || key == 'parent')) ||
- // PhantomJS 2 has enumerable non-index properties on typed arrays.
- (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
- // Skip index properties.
- isIndex(key, length)
- ))) {
- result.push(key);
- }
- }
- return result;
- }
- /**
- * This function is like
- * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
- * except that it includes inherited enumerable properties.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- */
- function nativeKeysIn(object) {
- var result = [];
- if (object != null) {
- for (var key in Object(object)) {
- result.push(key);
- }
- }
- return result;
- }
- /** Used for built-in method references. */
- var objectProto = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
- /**
- * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- */
- function baseKeysIn(object) {
- if (!isObject(object)) {
- return nativeKeysIn(object);
- }
- var isProto = isPrototype(object),
- result = [];
- for (var key in object) {
- if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
- result.push(key);
- }
- }
- return result;
- }
- /**
- * Creates an array of the own and inherited enumerable property names of `object`.
- *
- * **Note:** Non-object values are coerced to objects.
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category Object
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.keysIn(new Foo);
- * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
- */
- function keysIn(object) {
- return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
- }
- /**
- * Converts `value` to a string. An empty string is returned for `null`
- * and `undefined` values. The sign of `-0` is preserved.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to convert.
- * @returns {string} Returns the converted string.
- * @example
- *
- * _.toString(null);
- * // => ''
- *
- * _.toString(-0);
- * // => '-0'
- *
- * _.toString([1, 2, 3]);
- * // => '1,2,3'
- */
- function toString(value) {
- return value == null ? '' : baseToString(value);
- }
- /**
- * Creates a base function for methods like `_.forIn` and `_.forOwn`.
- *
- * @private
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {Function} Returns the new base function.
- */
- function createBaseFor(fromRight) {
- return function(object, iteratee, keysFunc) {
- var index = -1,
- iterable = Object(object),
- props = keysFunc(object),
- length = props.length;
- while (length--) {
- var key = props[fromRight ? length : ++index];
- if (iteratee(iterable[key], key, iterable) === false) {
- break;
- }
- }
- return object;
- };
- }
- /**
- * The base implementation of `baseForOwn` which iterates over `object`
- * properties returned by `keysFunc` and invokes `iteratee` for each property.
- * Iteratee functions may exit iteration early by explicitly returning `false`.
- *
- * @private
- * @param {Object} object The object to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @param {Function} keysFunc The function to get the keys of `object`.
- * @returns {Object} Returns `object`.
- */
- var baseFor = createBaseFor();
- /**
- * Gets the timestamp of the number of milliseconds that have elapsed since
- * the Unix epoch (1 January 1970 00:00:00 UTC).
- *
- * @static
- * @memberOf _
- * @since 2.4.0
- * @category Date
- * @returns {number} Returns the timestamp.
- * @example
- *
- * _.defer(function(stamp) {
- * console.log(_.now() - stamp);
- * }, _.now());
- * // => Logs the number of milliseconds it took for the deferred invocation.
- */
- var now = function() {
- return root.Date.now();
- };
- /** Error message constants. */
- var FUNC_ERROR_TEXT$1 = 'Expected a function';
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeMax = Math.max,
- nativeMin = Math.min;
- /**
- * Creates a debounced function that delays invoking `func` until after `wait`
- * milliseconds have elapsed since the last time the debounced function was
- * invoked. The debounced function comes with a `cancel` method to cancel
- * delayed `func` invocations and a `flush` method to immediately invoke them.
- * Provide `options` to indicate whether `func` should be invoked on the
- * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
- * with the last arguments provided to the debounced function. Subsequent
- * calls to the debounced function return the result of the last `func`
- * invocation.
- *
- * **Note:** If `leading` and `trailing` options are `true`, `func` is
- * invoked on the trailing edge of the timeout only if the debounced function
- * is invoked more than once during the `wait` timeout.
- *
- * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
- * until to the next tick, similar to `setTimeout` with a timeout of `0`.
- *
- * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
- * for details over the differences between `_.debounce` and `_.throttle`.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Function
- * @param {Function} func The function to debounce.
- * @param {number} [wait=0] The number of milliseconds to delay.
- * @param {Object} [options={}] The options object.
- * @param {boolean} [options.leading=false]
- * Specify invoking on the leading edge of the timeout.
- * @param {number} [options.maxWait]
- * The maximum time `func` is allowed to be delayed before it's invoked.
- * @param {boolean} [options.trailing=true]
- * Specify invoking on the trailing edge of the timeout.
- * @returns {Function} Returns the new debounced function.
- * @example
- *
- * // Avoid costly calculations while the window size is in flux.
- * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
- *
- * // Invoke `sendMail` when clicked, debouncing subsequent calls.
- * jQuery(element).on('click', _.debounce(sendMail, 300, {
- * 'leading': true,
- * 'trailing': false
- * }));
- *
- * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
- * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
- * var source = new EventSource('/stream');
- * jQuery(source).on('message', debounced);
- *
- * // Cancel the trailing debounced invocation.
- * jQuery(window).on('popstate', debounced.cancel);
- */
- function debounce$1(func, wait, options) {
- var lastArgs,
- lastThis,
- maxWait,
- result,
- timerId,
- lastCallTime,
- lastInvokeTime = 0,
- leading = false,
- maxing = false,
- trailing = true;
- if (typeof func != 'function') {
- throw new TypeError(FUNC_ERROR_TEXT$1);
- }
- wait = toNumber(wait) || 0;
- if (isObject(options)) {
- leading = !!options.leading;
- maxing = 'maxWait' in options;
- maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
- trailing = 'trailing' in options ? !!options.trailing : trailing;
- }
- function invokeFunc(time) {
- var args = lastArgs,
- thisArg = lastThis;
- lastArgs = lastThis = undefined;
- lastInvokeTime = time;
- result = func.apply(thisArg, args);
- return result;
- }
- function leadingEdge(time) {
- // Reset any `maxWait` timer.
- lastInvokeTime = time;
- // Start the timer for the trailing edge.
- timerId = setTimeout(timerExpired, wait);
- // Invoke the leading edge.
- return leading ? invokeFunc(time) : result;
- }
- function remainingWait(time) {
- var timeSinceLastCall = time - lastCallTime,
- timeSinceLastInvoke = time - lastInvokeTime,
- timeWaiting = wait - timeSinceLastCall;
- return maxing
- ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
- : timeWaiting;
- }
- function shouldInvoke(time) {
- var timeSinceLastCall = time - lastCallTime,
- timeSinceLastInvoke = time - lastInvokeTime;
- // Either this is the first call, activity has stopped and we're at the
- // trailing edge, the system time has gone backwards and we're treating
- // it as the trailing edge, or we've hit the `maxWait` limit.
- return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
- (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
- }
- function timerExpired() {
- var time = now();
- if (shouldInvoke(time)) {
- return trailingEdge(time);
- }
- // Restart the timer.
- timerId = setTimeout(timerExpired, remainingWait(time));
- }
- function trailingEdge(time) {
- timerId = undefined;
- // Only invoke if we have `lastArgs` which means `func` has been
- // debounced at least once.
- if (trailing && lastArgs) {
- return invokeFunc(time);
- }
- lastArgs = lastThis = undefined;
- return result;
- }
- function cancel() {
- if (timerId !== undefined) {
- clearTimeout(timerId);
- }
- lastInvokeTime = 0;
- lastArgs = lastCallTime = lastThis = timerId = undefined;
- }
- function flush() {
- return timerId === undefined ? result : trailingEdge(now());
- }
- function debounced() {
- var time = now(),
- isInvoking = shouldInvoke(time);
- lastArgs = arguments;
- lastThis = this;
- lastCallTime = time;
- if (isInvoking) {
- if (timerId === undefined) {
- return leadingEdge(lastCallTime);
- }
- if (maxing) {
- // Handle invocations in a tight loop.
- clearTimeout(timerId);
- timerId = setTimeout(timerExpired, wait);
- return invokeFunc(lastCallTime);
- }
- }
- if (timerId === undefined) {
- timerId = setTimeout(timerExpired, wait);
- }
- return result;
- }
- debounced.cancel = cancel;
- debounced.flush = flush;
- return debounced;
- }
- /**
- * Casts `value` to `identity` if it's not a function.
- *
- * @private
- * @param {*} value The value to inspect.
- * @returns {Function} Returns cast function.
- */
- function castFunction(value) {
- return typeof value == 'function' ? value : identity;
- }
- /**
- * Used to match `RegExp`
- * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
- */
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
- reHasRegExpChar = RegExp(reRegExpChar.source);
- /**
- * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
- * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category String
- * @param {string} [string=''] The string to escape.
- * @returns {string} Returns the escaped string.
- * @example
- *
- * _.escapeRegExp('[lodash](https://lodash.com/)');
- * // => '\[lodash\]\(https://lodash\.com/\)'
- */
- function escapeRegExp(string) {
- string = toString(string);
- return (string && reHasRegExpChar.test(string))
- ? string.replace(reRegExpChar, '\\$&')
- : string;
- }
- /**
- * Iterates over own and inherited enumerable string keyed properties of an
- * object and invokes `iteratee` for each property. The iteratee is invoked
- * with three arguments: (value, key, object). Iteratee functions may exit
- * iteration early by explicitly returning `false`.
- *
- * @static
- * @memberOf _
- * @since 0.3.0
- * @category Object
- * @param {Object} object The object to iterate over.
- * @param {Function} [iteratee=_.identity] The function invoked per iteration.
- * @returns {Object} Returns `object`.
- * @see _.forInRight
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.forIn(new Foo, function(value, key) {
- * console.log(key);
- * });
- * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
- */
- function forIn(object, iteratee) {
- return object == null
- ? object
- : baseFor(object, castFunction(iteratee), keysIn);
- }
- /** Error message constants. */
- var FUNC_ERROR_TEXT = 'Expected a function';
- /**
- * Creates a throttled function that only invokes `func` at most once per
- * every `wait` milliseconds. The throttled function comes with a `cancel`
- * method to cancel delayed `func` invocations and a `flush` method to
- * immediately invoke them. Provide `options` to indicate whether `func`
- * should be invoked on the leading and/or trailing edge of the `wait`
- * timeout. The `func` is invoked with the last arguments provided to the
- * throttled function. Subsequent calls to the throttled function return the
- * result of the last `func` invocation.
- *
- * **Note:** If `leading` and `trailing` options are `true`, `func` is
- * invoked on the trailing edge of the timeout only if the throttled function
- * is invoked more than once during the `wait` timeout.
- *
- * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
- * until to the next tick, similar to `setTimeout` with a timeout of `0`.
- *
- * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
- * for details over the differences between `_.throttle` and `_.debounce`.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Function
- * @param {Function} func The function to throttle.
- * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
- * @param {Object} [options={}] The options object.
- * @param {boolean} [options.leading=true]
- * Specify invoking on the leading edge of the timeout.
- * @param {boolean} [options.trailing=true]
- * Specify invoking on the trailing edge of the timeout.
- * @returns {Function} Returns the new throttled function.
- * @example
- *
- * // Avoid excessively updating the position while scrolling.
- * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
- *
- * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
- * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
- * jQuery(element).on('click', throttled);
- *
- * // Cancel the trailing throttled invocation.
- * jQuery(window).on('popstate', throttled.cancel);
- */
- function throttle$1(func, wait, options) {
- var leading = true,
- trailing = true;
- if (typeof func != 'function') {
- throw new TypeError(FUNC_ERROR_TEXT);
- }
- if (isObject(options)) {
- leading = 'leading' in options ? !!options.leading : leading;
- trailing = 'trailing' in options ? !!options.trailing : trailing;
- }
- return debounce$1(func, wait, {
- 'leading': leading,
- 'maxWait': wait,
- 'trailing': trailing
- });
- }
- const observed = new Set();
- let mutationObserver;
- const observerOptions = { childList: true };
- /**
- * Helper to set up a conditional slot component on connectedCallback.
- */
- function connectConditionalSlotComponent(component) {
- if (!mutationObserver) {
- mutationObserver = createObserver("mutation", processMutations);
- }
- mutationObserver.observe(component.el, observerOptions);
- }
- /**
- * Helper to tear down a conditional slot component on disconnectedCallback.
- */
- function disconnectConditionalSlotComponent(component) {
- observed.delete(component.el);
- // we explicitly process queued mutations and disconnect and reconnect
- // the observer until MutationObserver gets an `unobserve` method
- // see https://github.com/whatwg/dom/issues/126
- processMutations(mutationObserver.takeRecords());
- mutationObserver.disconnect();
- for (const [element] of observed.entries()) {
- mutationObserver.observe(element, observerOptions);
- }
- }
- function processMutations(mutations) {
- mutations.forEach(({ target }) => {
- forceUpdate(target);
- });
- }
- const actionBarCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:host{-webkit-box-sizing:border-box;box-sizing:border-box;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-2);font-size:var(--calcite-font-size--1)}:host *{-webkit-box-sizing:border-box;box-sizing:border-box}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{pointer-events:auto;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-item-align:stretch;align-self:stretch;max-width:15vw}:host([overflow-actions-disabled]){overflow-y:auto}:host([expanded]){max-width:20vw}::slotted(calcite-action-group){border-width:0px;border-bottom-width:1px;border-style:solid;border-color:var(--calcite-ui-border-3)}::slotted(calcite-action-group:last-child){border-bottom-width:0px}.action-group--bottom{-ms-flex-positive:1;flex-grow:1;-ms-flex-pack:end;justify-content:flex-end;padding-bottom:0px}";
- const ActionBar = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteActionBarToggle = createEvent(this, "calciteActionBarToggle", 7);
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * When set to true, the expand-toggling behavior will be disabled.
- */
- this.expandDisabled = false;
- /**
- * Indicates whether widget is expanded.
- */
- this.expanded = false;
- /**
- * Disables automatically overflowing actions that won't fit into menus.
- */
- this.overflowActionsDisabled = false;
- this.mutationObserver = createObserver("mutation", () => {
- const { el, expanded } = this;
- toggleChildActionText({ parent: el, expanded });
- this.conditionallyOverflowActions();
- });
- this.resizeObserver = createObserver("resize", (entries) => this.resizeHandlerEntries(entries));
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- this.actionMenuOpenChangeHandler = (event) => {
- if (event.detail) {
- const composedPath = event.composedPath();
- Array.from(this.el.querySelectorAll("calcite-action-group")).forEach((group) => {
- if (!composedPath.includes(group)) {
- group.menuOpen = false;
- }
- });
- }
- };
- this.resizeHandlerEntries = (entries) => {
- entries.forEach(this.resizeHandler);
- };
- this.resizeHandler = (entry) => {
- const { height } = entry.contentRect;
- this.resize(height);
- };
- this.resize = debounce$1((height) => {
- var _a;
- const { el, expanded, expandDisabled } = this;
- if (!height) {
- return;
- }
- const actions = queryActions(el);
- const actionCount = expandDisabled ? actions.length : actions.length + 1;
- const actionGroups = Array.from(el.querySelectorAll("calcite-action-group"));
- const groupCount = getSlotted(el, SLOTS$n.bottomActions) || !expandDisabled
- ? actionGroups.length + 1
- : actionGroups.length;
- const overflowCount = getOverflowCount({
- actionCount,
- actionHeight: (_a = actions[0]) === null || _a === void 0 ? void 0 : _a.clientHeight,
- height,
- groupCount
- });
- overflowActions({
- actionGroups,
- expanded,
- overflowCount
- });
- }, overflowActionsDebounceInMs);
- this.conditionallyOverflowActions = () => {
- if (!this.overflowActionsDisabled) {
- this.overflowActions();
- }
- };
- this.toggleExpand = () => {
- this.expanded = !this.expanded;
- this.calciteActionBarToggle.emit();
- };
- this.setExpandToggleRef = (el) => {
- this.expandToggleEl = el;
- };
- }
- expandHandler() {
- this.conditionallyOverflowActions();
- }
- expandedHandler(expanded) {
- toggleChildActionText({ parent: this.el, expanded });
- }
- overflowDisabledHandler(overflowActionsDisabled) {
- overflowActionsDisabled
- ? this.resizeObserver.disconnect()
- : this.resizeObserver.observe(this.el);
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- componentDidLoad() {
- this.conditionallyOverflowActions();
- }
- connectedCallback() {
- var _a, _b;
- const { el, expanded } = this;
- toggleChildActionText({ parent: el, expanded });
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(el, { childList: true, subtree: true });
- if (!this.overflowActionsDisabled) {
- (_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.observe(el);
- }
- this.conditionallyOverflowActions();
- connectConditionalSlotComponent(this);
- }
- disconnectedCallback() {
- var _a, _b;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- (_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
- disconnectConditionalSlotComponent(this);
- }
- // --------------------------------------------------------------------------
- //
- // Methods
- //
- // --------------------------------------------------------------------------
- /**
- * Overflows actions that won't fit into menus.
- * @internal
- */
- async overflowActions() {
- this.resize(this.el.clientHeight);
- }
- /** Sets focus on the component. */
- async setFocus(focusId) {
- if (focusId === "expand-toggle") {
- await focusElement(this.expandToggleEl);
- return;
- }
- this.el.focus();
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- renderBottomActionGroup() {
- const { expanded, expandDisabled, intlExpand, intlCollapse, el, position, toggleExpand, scale } = this;
- const tooltip = getSlotted(el, SLOTS$n.expandTooltip);
- const expandLabel = intlExpand || TEXT$p.expand;
- const collapseLabel = intlCollapse || TEXT$p.collapse;
- const expandToggleNode = !expandDisabled ? (h(ExpandToggle, { el: el, expanded: expanded, intlCollapse: collapseLabel, intlExpand: expandLabel, position: position, ref: this.setExpandToggleRef, scale: scale, toggle: toggleExpand, tooltip: tooltip })) : null;
- return getSlotted(el, SLOTS$n.bottomActions) || expandToggleNode ? (h("calcite-action-group", { class: CSS$N.actionGroupBottom, scale: scale }, h("slot", { name: SLOTS$n.bottomActions }), h("slot", { name: SLOTS$n.expandTooltip }), expandToggleNode)) : null;
- }
- render() {
- return (h(Host, { onCalciteActionMenuOpenChange: this.actionMenuOpenChangeHandler }, h("slot", null), this.renderBottomActionGroup()));
- }
- get el() { return this; }
- static get watchers() { return {
- "expandDisabled": ["expandHandler"],
- "expanded": ["expandedHandler"],
- "overflowActionsDisabled": ["overflowDisabledHandler"]
- }; }
- static get style() { return actionBarCss; }
- };
- const actionGroupCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:host{-webkit-box-sizing:border-box;box-sizing:border-box;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-2);font-size:var(--calcite-font-size--1)}:host *{-webkit-box-sizing:border-box;box-sizing:border-box}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;padding:0px;--calcite-action-group-columns:3}:host([columns=\"1\"]){--calcite-action-group-columns:1}:host([columns=\"2\"]){--calcite-action-group-columns:2}:host([columns=\"3\"]){--calcite-action-group-columns:3}:host([columns=\"4\"]){--calcite-action-group-columns:4}:host([columns=\"5\"]){--calcite-action-group-columns:5}:host([columns=\"6\"]){--calcite-action-group-columns:6}:host(:first-child){padding-top:0px}:host([layout=horizontal]){-ms-flex-direction:row;flex-direction:row}:host([layout=grid]){display:grid;place-content:stretch;gap:1px;background-color:var(--calcite-ui-background);padding:1px;grid-template-columns:repeat(var(--calcite-action-group-columns), auto)}";
- const ActionGroup = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * Indicates whether widget is expanded.
- */
- this.expanded = false;
- /**
- * Indicates the horizontal, vertical, or grid layout of the component.
- */
- this.layout = "vertical";
- /**
- * Opens the action menu.
- */
- this.menuOpen = false;
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- this.setMenuOpen = (event) => {
- this.menuOpen = !!event.detail;
- };
- }
- expandedHandler() {
- this.menuOpen = false;
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- connectConditionalSlotComponent(this);
- }
- disconnectedCallback() {
- disconnectConditionalSlotComponent(this);
- }
- // --------------------------------------------------------------------------
- //
- // Component Methods
- //
- // --------------------------------------------------------------------------
- renderTooltip() {
- const { el } = this;
- const hasTooltip = getSlotted(el, SLOTS$o.menuTooltip);
- return hasTooltip ? h("slot", { name: SLOTS$o.menuTooltip, slot: SLOTS$p.tooltip }) : null;
- }
- renderMenu() {
- const { el, expanded, intlMore, menuOpen, scale } = this;
- const hasMenuItems = getSlotted(el, SLOTS$o.menuActions);
- return hasMenuItems ? (h("calcite-action-menu", { expanded: expanded, flipPlacements: ["left", "right"], label: intlMore || TEXT$q.more, onCalciteActionMenuOpenChange: this.setMenuOpen, open: menuOpen, placement: "leading-start", scale: scale }, h("calcite-action", { icon: ICONS$e.menu, scale: scale, slot: SLOTS$p.trigger, text: intlMore || TEXT$q.more, textEnabled: expanded }), h("slot", { name: SLOTS$o.menuActions }), this.renderTooltip())) : null;
- }
- render() {
- return (h(Fragment, null, h("slot", null), this.renderMenu()));
- }
- get el() { return this; }
- static get watchers() { return {
- "expanded": ["expandedHandler"]
- }; }
- static get style() { return actionGroupCss; }
- };
- function getRoundRobinIndex(index, total) {
- return (index + total) % total;
- }
- const actionMenuCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;background-color:var(--calcite-ui-foreground-1);font-size:var(--calcite-font-size-1);color:var(--calcite-ui-text-2)}.menu ::slotted(calcite-action){margin:0.125rem;display:-ms-flexbox;display:flex;outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out}::slotted(calcite-action[active]){outline:2px solid var(--calcite-ui-brand);outline-offset:0px}.default-trigger{position:relative;height:100%;-ms-flex:0 1 auto;flex:0 1 auto;-ms-flex-item-align:stretch;align-self:stretch}slot[name=trigger]::slotted(calcite-action),calcite-action::slotted([slot=trigger]){position:relative;height:100%;-ms-flex:0 1 auto;flex:0 1 auto;-ms-flex-item-align:stretch;align-self:stretch}.menu{-ms-flex-direction:column;flex-direction:column;-ms-flex-wrap:nowrap;flex-wrap:nowrap;outline:2px solid transparent;outline-offset:2px}";
- const SUPPORTED_BUTTON_NAV_KEYS = ["ArrowUp", "ArrowDown"];
- const SUPPORTED_MENU_NAV_KEYS = ["ArrowUp", "ArrowDown", "End", "Home"];
- const ActionMenu = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteActionMenuOpenChange = createEvent(this, "calciteActionMenuOpenChange", 7);
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * Indicates whether widget is expanded.
- */
- this.expanded = false;
- /**
- * Opens the action menu.
- */
- this.open = false;
- /** Describes the type of positioning to use for the overlaid content. If your element is in a fixed container, use the 'fixed' value. */
- this.overlayPositioning = "absolute";
- /**
- * Determines where the component will be positioned relative to the referenceElement.
- * @see [PopperPlacement](https://github.com/Esri/calcite-components/blob/master/src/utils/popper.ts#L25)
- */
- this.placement = "auto";
- this.actionElements = [];
- this.mutationObserver = createObserver("mutation", () => this.getActions());
- this.guid = `calcite-action-menu-${guid()}`;
- this.menuId = `${this.guid}-menu`;
- this.menuButtonId = `${this.guid}-menu-button`;
- this.activeMenuItemIndex = -1;
- // --------------------------------------------------------------------------
- //
- // Component Methods
- //
- // --------------------------------------------------------------------------
- this.connectMenuButtonEl = () => {
- const { el, menuButtonId, menuId, open, label } = this;
- const menuButtonEl = getSlotted(el, SLOTS$p.trigger) || this.defaultMenuButtonEl;
- if (this.menuButtonEl === menuButtonEl) {
- return;
- }
- this.disconnectMenuButtonEl();
- this.menuButtonEl = menuButtonEl;
- this.setTooltipReferenceElement();
- if (!menuButtonEl) {
- return;
- }
- menuButtonEl.active = open;
- menuButtonEl.setAttribute("aria-controls", menuId);
- menuButtonEl.setAttribute("aria-expanded", toAriaBoolean(open));
- menuButtonEl.setAttribute("aria-haspopup", "true");
- if (!menuButtonEl.id) {
- menuButtonEl.id = menuButtonId;
- }
- if (!menuButtonEl.label) {
- menuButtonEl.label = label;
- }
- if (!menuButtonEl.text) {
- menuButtonEl.text = label;
- }
- menuButtonEl.addEventListener("click", this.menuButtonClick);
- menuButtonEl.addEventListener("keydown", this.menuButtonKeyDown);
- menuButtonEl.addEventListener("keyup", this.menuButtonKeyUp);
- };
- this.disconnectMenuButtonEl = () => {
- const { menuButtonEl } = this;
- if (!menuButtonEl) {
- return;
- }
- menuButtonEl.removeEventListener("click", this.menuButtonClick);
- menuButtonEl.removeEventListener("keydown", this.menuButtonKeyDown);
- menuButtonEl.removeEventListener("keyup", this.menuButtonKeyUp);
- };
- this.setDefaultMenuButtonEl = (el) => {
- this.defaultMenuButtonEl = el;
- this.connectMenuButtonEl();
- };
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- this.handleCalciteActionClick = () => {
- this.open = false;
- this.setFocus();
- };
- this.menuButtonClick = () => {
- this.toggleOpen();
- };
- this.updateTooltip = (event) => {
- const tooltips = event.target
- .assignedElements({
- flatten: true
- })
- .filter((el) => el === null || el === void 0 ? void 0 : el.matches("calcite-tooltip"));
- this.tooltipEl = tooltips[0];
- this.setTooltipReferenceElement();
- };
- this.setTooltipReferenceElement = () => {
- const { tooltipEl, expanded, menuButtonEl } = this;
- if (tooltipEl) {
- tooltipEl.referenceElement = !expanded ? menuButtonEl : null;
- }
- };
- this.updateAction = (action, index) => {
- const { guid, activeMenuItemIndex } = this;
- const id = `${guid}-action-${index}`;
- action.tabIndex = -1;
- action.setAttribute("role", "menuitem");
- if (!action.id) {
- action.id = id;
- }
- action.active = index === activeMenuItemIndex;
- };
- this.updateActions = (actions) => {
- actions === null || actions === void 0 ? void 0 : actions.forEach(this.updateAction);
- };
- this.getActions = () => {
- const { el } = this;
- const actionElements = getSlotted(el, { all: true, matches: "calcite-action" });
- this.updateActions(actionElements);
- this.actionElements = actionElements;
- this.connectMenuButtonEl();
- };
- this.menuButtonKeyUp = (event) => {
- const { key } = event;
- const { actionElements } = this;
- if (!this.isValidKey(key, SUPPORTED_BUTTON_NAV_KEYS)) {
- return;
- }
- event.preventDefault();
- if (!actionElements.length) {
- return;
- }
- this.toggleOpen(true);
- this.handleActionNavigation(key, actionElements);
- };
- this.menuButtonKeyDown = (event) => {
- const { key } = event;
- if (!this.isValidKey(key, SUPPORTED_BUTTON_NAV_KEYS)) {
- return;
- }
- event.preventDefault();
- };
- this.menuActionsContainerKeyDown = (event) => {
- const { key } = event;
- const { actionElements, activeMenuItemIndex } = this;
- if (key === "Tab") {
- this.open = false;
- return;
- }
- if (key === " " || key === "Enter") {
- event.preventDefault();
- const action = actionElements[activeMenuItemIndex];
- action ? action.click() : this.toggleOpen(false);
- return;
- }
- if (this.isValidKey(key, SUPPORTED_MENU_NAV_KEYS)) {
- event.preventDefault();
- }
- };
- this.menuActionsContainerKeyUp = (event) => {
- const { key } = event;
- const { actionElements } = this;
- if (key === "Escape") {
- this.toggleOpen(false);
- return;
- }
- if (!this.isValidKey(key, SUPPORTED_MENU_NAV_KEYS)) {
- return;
- }
- event.preventDefault();
- if (!actionElements.length) {
- return;
- }
- this.handleActionNavigation(key, actionElements);
- };
- this.handleActionNavigation = (key, actions) => {
- const currentIndex = this.activeMenuItemIndex;
- if (key === "Home") {
- this.activeMenuItemIndex = 0;
- }
- if (key === "End") {
- this.activeMenuItemIndex = actions.length - 1;
- }
- if (key === "ArrowUp") {
- this.activeMenuItemIndex = getRoundRobinIndex(Math.max(currentIndex - 1, -1), actions.length);
- }
- if (key === "ArrowDown") {
- this.activeMenuItemIndex = getRoundRobinIndex(currentIndex + 1, actions.length);
- }
- };
- this.toggleOpenEnd = () => {
- this.setFocus();
- this.el.removeEventListener("calcitePopoverOpen", this.toggleOpenEnd);
- };
- this.toggleOpen = (value = !this.open) => {
- this.el.addEventListener("calcitePopoverOpen", this.toggleOpenEnd);
- this.open = value;
- };
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- var _a;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
- this.getActions();
- connectConditionalSlotComponent(this);
- }
- disconnectedCallback() {
- var _a;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- this.disconnectMenuButtonEl();
- disconnectConditionalSlotComponent(this);
- }
- expandedHandler() {
- this.open = false;
- this.setTooltipReferenceElement();
- }
- openHandler(open) {
- this.activeMenuItemIndex = this.open ? 0 : -1;
- if (this.menuButtonEl) {
- this.menuButtonEl.active = open;
- }
- this.calciteActionMenuOpenChange.emit(open);
- }
- closeCalciteActionMenuOnClick(event) {
- const composedPath = event.composedPath();
- if (composedPath.includes(this.el)) {
- return;
- }
- this.open = false;
- }
- activeMenuItemIndexHandler() {
- this.updateActions(this.actionElements);
- }
- // --------------------------------------------------------------------------
- //
- // Methods
- //
- // --------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- focusElement(this.open ? this.menuEl : this.menuButtonEl);
- }
- renderMenuButton() {
- const { label, scale } = this;
- const menuButtonSlot = (h("slot", { name: SLOTS$p.trigger }, h("calcite-action", { class: CSS$O.defaultTrigger, icon: ICONS$f.menu, ref: this.setDefaultMenuButtonEl, scale: scale, text: label })));
- return menuButtonSlot;
- }
- renderMenuItems() {
- const { actionElements, activeMenuItemIndex, open, menuId, menuButtonEl, label, placement, overlayPositioning, flipPlacements } = this;
- const activeAction = actionElements[activeMenuItemIndex];
- const activeDescendantId = (activeAction === null || activeAction === void 0 ? void 0 : activeAction.id) || null;
- return (h("calcite-popover", { disablePointer: true, flipPlacements: flipPlacements, label: label, offsetDistance: 0, open: open, overlayPositioning: overlayPositioning, placement: placement, referenceElement: menuButtonEl }, h("div", { "aria-activedescendant": activeDescendantId, "aria-labelledby": menuButtonEl === null || menuButtonEl === void 0 ? void 0 : menuButtonEl.id, class: CSS$O.menu, id: menuId, onClick: this.handleCalciteActionClick, onKeyDown: this.menuActionsContainerKeyDown, onKeyUp: this.menuActionsContainerKeyUp, ref: (el) => (this.menuEl = el), role: "menu", tabIndex: -1 }, h("slot", null))));
- }
- render() {
- return (h(Fragment, null, this.renderMenuButton(), this.renderMenuItems(), h("slot", { name: SLOTS$p.tooltip, onSlotchange: this.updateTooltip })));
- }
- isValidKey(key, supportedKeys) {
- return !!supportedKeys.find((k) => k === key);
- }
- get el() { return this; }
- static get watchers() { return {
- "expanded": ["expandedHandler"],
- "open": ["openHandler"],
- "activeMenuItemIndex": ["activeMenuItemIndexHandler"]
- }; }
- static get style() { return actionMenuCss; }
- };
- const CSS$M = {
- actionGroupBottom: "action-group--bottom",
- container: "container"
- };
- const TEXT$o = {
- expand: "Expand",
- collapse: "Collapse"
- };
- const SLOTS$m = {
- expandTooltip: "expand-tooltip"
- };
- const actionPadCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:host{-webkit-box-sizing:border-box;box-sizing:border-box;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-2);font-size:var(--calcite-font-size--1)}:host *{-webkit-box-sizing:border-box;box-sizing:border-box}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:block}@keyframes in{0%{opacity:0}100%{opacity:1}}:host{-webkit-animation:in var(--calcite-internal-animation-timing-slow) ease-in-out;animation:in var(--calcite-internal-animation-timing-slow) ease-in-out;border-radius:0.125rem}:host([expanded]){max-width:20vw}::slotted(calcite-action-group){border-width:0px;border-bottom-width:1px;border-style:solid;border-color:var(--calcite-ui-border-3);padding-bottom:0px;padding-top:0px}.container{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-direction:column;flex-direction:column;overflow-y:auto;border-radius:0.25rem;background-color:var(--calcite-ui-background);--tw-shadow:0 6px 20px -4px rgba(0, 0, 0, 0.1), 0 4px 12px -2px rgba(0, 0, 0, 0.08);--tw-shadow-colored:0 6px 20px -4px var(--tw-shadow-color), 0 4px 12px -2px var(--tw-shadow-color);-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);max-width:15vw}.action-group--bottom{-ms-flex-positive:1;flex-grow:1;-ms-flex-pack:end;justify-content:flex-end;padding-bottom:0px}:host([layout=horizontal]) .container{-ms-flex-direction:row;flex-direction:row;max-width:unset}:host([layout=horizontal]) .container .action-group--bottom{padding:0px}:host([layout=horizontal]) .container ::slotted(calcite-action-group){border-width:0px;padding:0px;border-inline-end-width:1px}::slotted(calcite-action-group:last-child){border-bottom-width:0px}";
- const ActionPad = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteActionPadToggle = createEvent(this, "calciteActionPadToggle", 7);
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * When set to true, the expand-toggling behavior will be disabled.
- */
- this.expandDisabled = false;
- /**
- * Indicates whether widget is expanded.
- */
- this.expanded = false;
- /**
- * Indicates the horizontal or vertical layout of the component.
- */
- this.layout = "vertical";
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- this.actionMenuOpenChangeHandler = (event) => {
- if (event.detail) {
- const composedPath = event.composedPath();
- Array.from(this.el.querySelectorAll("calcite-action-group")).forEach((group) => {
- if (!composedPath.includes(group)) {
- group.menuOpen = false;
- }
- });
- }
- };
- this.toggleExpand = () => {
- this.expanded = !this.expanded;
- this.calciteActionPadToggle.emit();
- };
- this.setExpandToggleRef = (el) => {
- this.expandToggleEl = el;
- };
- }
- expandedHandler(expanded) {
- toggleChildActionText({ parent: this.el, expanded });
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- connectConditionalSlotComponent(this);
- }
- disconnectedCallback() {
- disconnectConditionalSlotComponent(this);
- }
- componentWillLoad() {
- const { el, expanded } = this;
- toggleChildActionText({ parent: el, expanded });
- }
- // --------------------------------------------------------------------------
- //
- // Methods
- //
- // --------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus(focusId) {
- if (focusId === "expand-toggle") {
- await focusElement(this.expandToggleEl);
- return;
- }
- this.el.focus();
- }
- // --------------------------------------------------------------------------
- //
- // Component Methods
- //
- // --------------------------------------------------------------------------
- renderBottomActionGroup() {
- const { expanded, expandDisabled, intlExpand, intlCollapse, el, position, toggleExpand, scale } = this;
- const tooltip = getSlotted(el, SLOTS$m.expandTooltip);
- const expandLabel = intlExpand || TEXT$o.expand;
- const collapseLabel = intlCollapse || TEXT$o.collapse;
- const expandToggleNode = !expandDisabled ? (h(ExpandToggle, { el: el, expanded: expanded, intlCollapse: collapseLabel, intlExpand: expandLabel, position: position, ref: this.setExpandToggleRef, scale: scale, toggle: toggleExpand, tooltip: tooltip })) : null;
- return expandToggleNode ? (h("calcite-action-group", { class: CSS$M.actionGroupBottom, scale: scale }, h("slot", { name: SLOTS$m.expandTooltip }), expandToggleNode)) : null;
- }
- render() {
- return (h(Host, { onCalciteActionMenuOpenChange: this.actionMenuOpenChangeHandler }, h("div", { class: CSS$M.container }, h("slot", null), this.renderBottomActionGroup())));
- }
- get el() { return this; }
- static get watchers() { return {
- "expanded": ["expandedHandler"]
- }; }
- static get style() { return actionPadCss; }
- };
- const TEXT$n = {
- intlClose: "Close"
- };
- const DURATIONS = {
- slow: 14000,
- medium: 10000,
- fast: 6000
- };
- const SLOTS$l = {
- title: "title",
- message: "message",
- link: "link"
- };
- var StatusIcons;
- (function (StatusIcons) {
- StatusIcons["green"] = "checkCircle";
- StatusIcons["yellow"] = "exclamationMarkTriangle";
- StatusIcons["red"] = "exclamationMarkTriangle";
- StatusIcons["blue"] = "lightbulb";
- })(StatusIcons || (StatusIcons = {}));
- const alertCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([scale=s]){--calcite-alert-width:40em;--calcite-alert-spacing-token-small:0.5rem;--calcite-alert-spacing-token-large:0.75rem}:host([scale=s]) slot[name=title]::slotted(*),:host([scale=s]) *::slotted([slot=title]){font-size:var(--calcite-font-size--1);line-height:1.375}:host([scale=s]) slot[name=message]::slotted(*),:host([scale=s]) *::slotted([slot=message]){font-size:var(--calcite-font-size--2);line-height:1.375}:host([scale=s]) slot[name=link]::slotted(*),:host([scale=s]) *::slotted([slot=link]){font-size:var(--calcite-font-size--2);line-height:1.375}:host([scale=s]) .alert-queue-count{margin-left:0.5rem;margin-right:0.5rem}:host([scale=s]) .container{--calcite-alert-min-height:3.5rem}:host([scale=s]) .alert-close{padding:0.5rem}:host([scale=m]){--calcite-alert-width:50em;--calcite-alert-spacing-token-small:0.75rem;--calcite-alert-spacing-token-large:1rem}:host([scale=m]) slot[name=title]::slotted(*),:host([scale=m]) *::slotted([slot=title]){font-size:var(--calcite-font-size-0);line-height:1.375}:host([scale=m]) slot[name=message]::slotted(*),:host([scale=m]) *::slotted([slot=message]){font-size:var(--calcite-font-size--1);line-height:1.375}:host([scale=m]) slot[name=link]::slotted(*),:host([scale=m]) *::slotted([slot=link]){font-size:var(--calcite-font-size--1);line-height:1.375}:host([scale=m]) .alert-queue-count{margin-left:0.75rem;margin-right:0.75rem}:host([scale=m]) .container{--calcite-alert-min-height:4.1875rem}:host([scale=l]){--calcite-alert-width:60em;--calcite-alert-spacing-token-small:1rem;--calcite-alert-spacing-token-large:1.25rem}:host([scale=l]) slot[name=title]::slotted(*),:host([scale=l]) *::slotted([slot=title]){margin-bottom:0.25rem;font-size:var(--calcite-font-size-1);line-height:1.375}:host([scale=l]) slot[name=message]::slotted(*),:host([scale=l]) *::slotted([slot=message]){font-size:var(--calcite-font-size-0);line-height:1.375}:host([scale=l]) slot[name=link]::slotted(*),:host([scale=l]) *::slotted([slot=link]){font-size:var(--calcite-font-size-0);line-height:1.375}:host([scale=l]) .alert-queue-count{margin-left:1rem;margin-right:1rem}:host([scale=l]) .container{--calcite-alert-min-height:5.625rem}:host{--calcite-alert-edge-distance:2rem;display:block}:host .container{pointer-events:none;position:fixed;margin-top:0px;margin-bottom:0px;margin-left:auto;margin-right:auto;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;background-color:var(--calcite-ui-foreground-1);opacity:0;--tw-shadow:0 6px 20px -4px rgba(0, 0, 0, 0.1), 0 4px 12px -2px rgba(0, 0, 0, 0.08);--tw-shadow-colored:0 6px 20px -4px var(--tw-shadow-color), 0 4px 12px -2px var(--tw-shadow-color);-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);border-radius:var(--calcite-border-radius);border-top:0px solid transparent;border-left:1px solid var(--calcite-ui-border-3);border-right:1px solid var(--calcite-ui-border-3);border-bottom:1px solid var(--calcite-ui-border-3);min-height:var(--calcite-alert-min-height);width:var(--calcite-alert-width);max-width:calc(100% - (var(--calcite-alert-edge-distance) * 2 + 2px));max-height:0;z-index:101;-webkit-transition:var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), opacity var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), all var(--calcite-animation-timing) ease-in-out;transition:var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), opacity var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), all var(--calcite-animation-timing) ease-in-out}:host .container.bottom,:host .container.top{inset-inline-end:0;inset-inline-start:0}:host .container[class*=bottom]{-webkit-transform:translate3d(0, var(--calcite-alert-edge-distance), 0);transform:translate3d(0, var(--calcite-alert-edge-distance), 0);inset-block-end:var(--calcite-alert-edge-distance)}:host .container[class*=top]{-webkit-transform:translate3d(0, calc(-1 * var(--calcite-alert-edge-distance)), 0);transform:translate3d(0, calc(-1 * var(--calcite-alert-edge-distance)), 0);inset-block-start:var(--calcite-alert-edge-distance)}:host .container[class*=-start]{inset-inline-start:var(--calcite-alert-edge-distance);inset-inline-end:auto}:host .container[class*=-end]{inset-inline-end:var(--calcite-alert-edge-distance);inset-inline-start:auto}.container{display:-ms-flexbox;display:flex;width:100%;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}.alert-close{outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out}.alert-close:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}:host([active]) .container:not(.queued){max-height:100%;border-top-width:2px;opacity:1;pointer-events:initial}:host([active]) .container:not(.queued)[class*=bottom]{-webkit-transform:translate3d(0, calc(-1 * var(--calcite-alert-edge-distance)), inherit);transform:translate3d(0, calc(-1 * var(--calcite-alert-edge-distance)), inherit)}:host([active]) .container:not(.queued)[class*=top]{-webkit-transform:translate3d(0, var(--calcite-alert-edge-distance), inherit);transform:translate3d(0, var(--calcite-alert-edge-distance), inherit)}slot[name=title]::slotted(*),*::slotted([slot=title]){font-size:var(--calcite-font-size-0);line-height:1.375;font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1)}slot[name=message]::slotted(*),*::slotted([slot=message]){margin:0px;display:inline;font-size:var(--calcite-font-size--1);line-height:1.375;font-weight:var(--calcite-font-weight-normal);color:var(--calcite-ui-text-2);-webkit-margin-end:0.5rem;margin-inline-end:0.5rem}slot[name=link]::slotted(*),*::slotted([slot=link]){display:-ms-inline-flexbox;display:inline-flex;color:var(--calcite-ui-text-link)}.alert-content{-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s;padding:var(--calcite-alert-spacing-token-small) var(--calcite-alert-spacing-token-large);-ms-flex:0 0 auto;flex:0 0 auto;overflow-wrap:break-word;background-color:var(--calcite-ui-foreground-1);-ms-flex:1 1 auto;flex:1 1 auto;min-width:0;padding-block:var(--calcite-alert-spacing-token-small);padding-inline:0 var(--calcite-alert-spacing-token-small);border-bottom-left-radius:var(--calcite-border-radius);border-bottom-right-radius:var(--calcite-border-radius)}.alert-content:first-of-type:not(:only-child){-webkit-padding-start:var(--calcite-alert-spacing-token-large);padding-inline-start:var(--calcite-alert-spacing-token-large)}.alert-content:only-child{padding:var(--calcite-alert-spacing-token-small)}.alert-icon{-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s;padding:var(--calcite-alert-spacing-token-small) var(--calcite-alert-spacing-token-large);-ms-flex:0 0 auto;flex:0 0 auto;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-item-align:stretch;align-self:stretch;background-color:var(--calcite-ui-foreground-1);padding-top:0px;padding-bottom:0px}.alert-close{-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s;padding:var(--calcite-alert-spacing-token-small) var(--calcite-alert-spacing-token-large);-ms-flex:0 0 auto;flex:0 0 auto;cursor:pointer;-ms-flex-item-align:stretch;align-self:stretch;overflow:hidden;border-style:none;background-color:var(--calcite-ui-foreground-1);padding-top:0px;padding-bottom:0px;color:var(--calcite-ui-text-3);outline:2px solid transparent;outline-offset:2px;border-end-end-radius:var(--calcite-border-radius)}.alert-close:hover,.alert-close:focus{background-color:var(--calcite-ui-foreground-2);color:var(--calcite-ui-text-1)}.alert-close:active{background-color:var(--calcite-ui-foreground-3)}.alert-queue-count{visibility:hidden;display:-ms-flexbox;display:flex;cursor:default;-ms-flex-align:center;align-items:center;-ms-flex-pack:distribute;justify-content:space-around;-ms-flex-item-align:stretch;align-self:stretch;overflow:hidden;background-color:var(--calcite-ui-foreground-1);text-align:center;font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-2);opacity:0;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s;border-left:0px solid transparent;border-right:0px solid transparent;border-top-right-radius:0}.alert-queue-count.active{visibility:visible;opacity:1}:host([auto-dismiss])>.alert-queue-count{-webkit-border-end:0px solid transparent;border-inline-end:0px solid transparent}.alert-dismiss-progress{position:absolute;left:0px;right:0px;display:block;width:100%;overflow:hidden;top:-2px;height:2px;z-index:103;border-radius:var(--calcite-border-radius) var(--calcite-border-radius) 0 0}.alert-dismiss-progress:after{position:absolute;top:0px;display:block;height:2px;content:\"\";background-color:var(--calcite-alert-dismiss-progress-background);z-index:104;inset-inline-end:0}:host([color=blue]) .container{border-top-color:var(--calcite-ui-info)}:host([color=blue]) .container .alert-icon{color:var(--calcite-ui-info)}:host([color=red]) .container{border-top-color:var(--calcite-ui-danger)}:host([color=red]) .container .alert-icon{color:var(--calcite-ui-danger)}:host([color=yellow]) .container{border-top-color:var(--calcite-ui-warning)}:host([color=yellow]) .container .alert-icon{color:var(--calcite-ui-warning)}:host([color=green]) .container{border-top-color:var(--calcite-ui-success)}:host([color=green]) .container .alert-icon{color:var(--calcite-ui-success)}:host([auto-dismiss-duration=fast]) .alert-dismiss-progress:after{-webkit-animation:dismissProgress 6000ms ease-out;animation:dismissProgress 6000ms ease-out}:host([auto-dismiss-duration=medium]) .alert-dismiss-progress:after{-webkit-animation:dismissProgress 10000ms ease-out;animation:dismissProgress 10000ms ease-out}:host([auto-dismiss-duration=slow]) .alert-dismiss-progress:after{-webkit-animation:dismissProgress 14000ms ease-out;animation:dismissProgress 14000ms ease-out}@-webkit-keyframes dismissProgress{0%{width:0px;opacity:0.75}100%{width:100%;opacity:1}}@keyframes dismissProgress{0%{width:0px;opacity:0.75}100%{width:100%;opacity:1}}";
- const Alert = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteAlertClose = createEvent(this, "calciteAlertClose", 7);
- this.calciteAlertOpen = createEvent(this, "calciteAlertOpen", 7);
- this.calciteAlertSync = createEvent(this, "calciteAlertSync", 7);
- this.calciteAlertRegister = createEvent(this, "calciteAlertRegister", 7);
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //---------------------------------------------------------------------------
- /** Is the alert currently active or not */
- this.active = false;
- /** Close the alert automatically (recommended for passive, non-blocking alerts) */
- this.autoDismiss = false;
- /** Duration of autoDismiss (only used with `autoDismiss`) */
- this.autoDismissDuration = this.autoDismiss ? "medium" : null;
- /** Color for the alert (will apply to top border and icon) */
- this.color = "blue";
- /** string to override English close text
- * @default "Close"
- */
- this.intlClose = TEXT$n.intlClose;
- /** specify the placement of the alert */
- this.placement = "bottom";
- /** specify the scale of the alert, defaults to m */
- this.scale = "m";
- //--------------------------------------------------------------------------
- //
- // Private State/Props
- //
- //--------------------------------------------------------------------------
- /** the list of queued alerts */
- this.queue = [];
- /** the count of queued alerts */
- this.queueLength = 0;
- /** is the alert queued */
- this.queued = false;
- this.autoDismissTimeoutId = null;
- this.trackTimer = Date.now();
- this.activeTransitionProp = "opacity";
- /** close and emit the closed alert and the queue */
- this.closeAlert = () => {
- this.autoDismissTimeoutId = null;
- this.queued = false;
- this.active = false;
- this.queue = this.queue.filter((e) => e !== this.el);
- this.determineActiveAlert();
- this.calciteAlertSync.emit({ queue: this.queue });
- };
- this.transitionEnd = (event) => {
- if (event.propertyName === this.activeTransitionProp) {
- this.active
- ? this.calciteAlertOpen.emit({
- el: this.el,
- queue: this.queue
- })
- : this.calciteAlertClose.emit({
- el: this.el,
- queue: this.queue
- });
- }
- };
- }
- watchActive() {
- if (this.active && !this.queued) {
- this.calciteAlertRegister.emit();
- }
- if (!this.active) {
- this.queue = this.queue.filter((e) => e !== this.el);
- this.calciteAlertSync.emit({ queue: this.queue });
- }
- }
- updateRequestedIcon() {
- this.requestedIcon = setRequestedIcon(StatusIcons, this.icon, this.color);
- }
- updateDuration() {
- if (this.autoDismiss && this.autoDismissTimeoutId) {
- window.clearTimeout(this.autoDismissTimeoutId);
- this.autoDismissTimeoutId = window.setTimeout(() => this.closeAlert(), DURATIONS[this.autoDismissDuration] - (Date.now() - this.trackTimer));
- }
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- if (this.active && !this.queued) {
- this.calciteAlertRegister.emit();
- }
- }
- componentWillLoad() {
- this.requestedIcon = setRequestedIcon(StatusIcons, this.icon, this.color);
- }
- disconnectedCallback() {
- window.clearTimeout(this.autoDismissTimeoutId);
- }
- render() {
- const closeButton = (h("button", { "aria-label": this.intlClose, class: "alert-close", onClick: this.closeAlert, ref: (el) => (this.closeButton = el), type: "button" }, h("calcite-icon", { icon: "x", scale: this.scale === "l" ? "m" : "s" })));
- const queueText = `+${this.queueLength > 2 ? this.queueLength - 1 : 1}`;
- const queueCount = (h("div", { class: `${this.queueLength > 1 ? "active " : ""}alert-queue-count` }, h("calcite-chip", { scale: this.scale, value: queueText }, queueText)));
- const { active, autoDismiss, label, placement, queued, requestedIcon } = this;
- const role = autoDismiss ? "alert" : "alertdialog";
- const hidden = !active;
- return (h(Host, { "aria-hidden": toAriaBoolean(hidden), "aria-label": label, "calcite-hydrated-hidden": hidden, role: role }, h("div", { class: {
- container: true,
- queued,
- [placement]: true
- }, onTransitionEnd: this.transitionEnd }, requestedIcon ? (h("div", { class: "alert-icon" }, h("calcite-icon", { icon: requestedIcon, scale: this.scale === "l" ? "m" : "s" }))) : null, h("div", { class: "alert-content" }, h("slot", { name: SLOTS$l.title }), h("slot", { name: SLOTS$l.message }), h("slot", { name: SLOTS$l.link })), queueCount, !autoDismiss ? closeButton : null, active && !queued && autoDismiss ? h("div", { class: "alert-dismiss-progress" }) : null)));
- }
- // when an alert is opened or closed, update queue and determine active alert
- alertSync(event) {
- if (this.queue !== event.detail.queue) {
- this.queue = event.detail.queue;
- }
- this.queueLength = this.queue.length;
- this.determineActiveAlert();
- }
- // when an alert is first registered, trigger a queue sync to get queue
- alertRegister() {
- if (this.active && !this.queue.includes(this.el)) {
- this.queued = true;
- this.queue.push(this.el);
- }
- this.calciteAlertSync.emit({ queue: this.queue });
- this.determineActiveAlert();
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- const alertLinkEl = getSlotted(this.el, { selector: "calcite-link" });
- if (!this.closeButton && !alertLinkEl) {
- return;
- }
- else if (alertLinkEl) {
- alertLinkEl.setFocus();
- }
- else if (this.closeButton) {
- this.closeButton.focus();
- }
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- /** determine which alert is active */
- determineActiveAlert() {
- var _a;
- if (((_a = this.queue) === null || _a === void 0 ? void 0 : _a[0]) === this.el) {
- this.openAlert();
- if (this.autoDismiss && !this.autoDismissTimeoutId) {
- this.trackTimer = Date.now();
- this.autoDismissTimeoutId = window.setTimeout(() => this.closeAlert(), DURATIONS[this.autoDismissDuration]);
- }
- }
- else {
- return;
- }
- }
- /** emit the opened alert and the queue */
- openAlert() {
- window.clearTimeout(this.queueTimeout);
- this.queueTimeout = window.setTimeout(() => (this.queued = false), 300);
- }
- get el() { return this; }
- static get watchers() { return {
- "active": ["watchActive"],
- "icon": ["updateRequestedIcon"],
- "color": ["updateRequestedIcon"],
- "autoDismissDuration": ["updateDuration"]
- }; }
- static get style() { return alertCss; }
- };
- function rgbToHex(color) {
- const { r, g, b } = color;
- return `#${r.toString(16).padStart(2, "0")}${g.toString(16).padStart(2, "0")}${b
- .toString(16)
- .padStart(2, "0")}`.toLowerCase();
- }
- const hexChar = /^[0-9A-F]$/i;
- const shortHandHex = /^#[0-9A-F]{3}$/i;
- const longhandHex = /^#[0-9A-F]{6}$/i;
- function isValidHex(hex) {
- return isShorthandHex(hex) || isLonghandHex(hex);
- }
- function isShorthandHex(hex) {
- return hex && hex.length === 4 && shortHandHex.test(hex);
- }
- function isLonghandHex(hex) {
- return hex && hex.length === 7 && longhandHex.test(hex);
- }
- function normalizeHex(hex) {
- hex = hex.toLowerCase();
- if (!hex.startsWith("#")) {
- hex = `#${hex}`;
- }
- if (isShorthandHex(hex)) {
- return rgbToHex(hexToRGB(hex));
- }
- return hex;
- }
- function hexToRGB(hex) {
- if (!isValidHex(hex)) {
- return null;
- }
- hex = hex.replace("#", "");
- if (hex.length === 3) {
- const [first, second, third] = hex.split("");
- const r = parseInt(`${first}${first}`, 16);
- const g = parseInt(`${second}${second}`, 16);
- const b = parseInt(`${third}${third}`, 16);
- return { r, g, b };
- }
- const r = parseInt(hex.slice(0, 2), 16);
- const g = parseInt(hex.slice(2, 4), 16);
- const b = parseInt(hex.slice(4, 6), 16);
- return { r, g, b };
- }
- // these utils allow users to pass enum values as strings without having to access the enum
- // based on the approach suggested by https://github.com/microsoft/TypeScript/issues/17690#issuecomment-321365759,
- const enumify = (x) => x;
- const CSSColorMode = enumify({
- HEX: "hex",
- HEXA: "hexa",
- RGB_CSS: "rgb-css",
- RGBA_CSS: "rgba-css",
- HSL_CSS: "hsl-css",
- HSLA_CSS: "hsla-css"
- });
- const ObjectColorMode = enumify({
- RGB: "rgb",
- RGBA: "rgba",
- HSL: "hsl",
- HSLA: "hsla",
- HSV: "hsv",
- HSVA: "hsva"
- });
- function parseMode(colorValue) {
- if (typeof colorValue === "string") {
- if (colorValue.startsWith("#")) {
- const { length } = colorValue;
- if (length === 4 || length === 7) {
- return CSSColorMode.HEX;
- }
- if (length === 5 || length === 9) {
- return CSSColorMode.HEXA;
- }
- }
- if (colorValue.startsWith("rgba(")) {
- return CSSColorMode.RGBA_CSS;
- }
- if (colorValue.startsWith("rgb(")) {
- return CSSColorMode.RGB_CSS;
- }
- if (colorValue.startsWith("hsl(")) {
- return CSSColorMode.HSL_CSS;
- }
- if (colorValue.startsWith("hsla(")) {
- return CSSColorMode.HSLA_CSS;
- }
- }
- if (typeof colorValue === "object") {
- if (hasChannels(colorValue, "r", "g", "b")) {
- return hasChannels(colorValue, "a") ? ObjectColorMode.RGBA : ObjectColorMode.RGB;
- }
- if (hasChannels(colorValue, "h", "s", "l")) {
- return hasChannels(colorValue, "a") ? ObjectColorMode.HSLA : ObjectColorMode.HSL;
- }
- if (hasChannels(colorValue, "h", "s", "v")) {
- return hasChannels(colorValue, "a") ? ObjectColorMode.HSVA : ObjectColorMode.HSV;
- }
- }
- return null;
- }
- function hasChannels(colorObject, ...channels) {
- return channels.every((channel) => channel && colorObject && `${channel}` in colorObject);
- }
- function colorEqual(value1, value2) {
- return (value1 === null || value1 === void 0 ? void 0 : value1.rgbNumber()) === (value2 === null || value2 === void 0 ? void 0 : value2.rgbNumber());
- }
- /**
- * Convert a string to a valid hex by hashing its contents
- * and using the hash as a seed for three distinct color values
- */
- function stringToHex(str) {
- let hash = 0;
- for (let i = 0; i < str.length; i++) {
- hash = str.charCodeAt(i) + ((hash << 5) - hash);
- }
- let hex = "#";
- for (let j = 0; j < 3; j++) {
- const value = (hash >> (j * 8)) & 0xff;
- hex += ("00" + value.toString(16)).substr(-2);
- }
- return hex;
- }
- /**
- * Find the hue of a color given the separate RGB color channels
- */
- function rgbToHue(rgb) {
- let { r, g, b } = rgb;
- r /= 255;
- g /= 255;
- b /= 255;
- const max = Math.max(r, g, b);
- const min = Math.min(r, g, b);
- const delta = max - min;
- if (max === min) {
- return 0;
- }
- let hue = (max + min) / 2;
- switch (max) {
- case r:
- hue = (g - b) / delta + (g < b ? 6 : 0);
- break;
- case g:
- hue = (b - r) / delta + 2;
- break;
- case b:
- hue = (r - g) / delta + 4;
- break;
- }
- return Math.round(hue * 60);
- }
- /**
- * For a hex color, find the hue
- * @param hex {string} - form of "#------"
- */
- function hexToHue(hex) {
- return rgbToHue(hexToRGB(hex));
- }
- const avatarCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:inline-block;overflow:hidden;border-radius:50%}:host([scale=s]){height:1.5rem;width:1.5rem;font-size:var(--calcite-font-size--3)}:host([scale=m]){height:2rem;width:2rem;font-size:var(--calcite-font-size--2)}:host([scale=l]){height:2.75rem;width:2.75rem;font-size:var(--calcite-font-size-0)}.icon{display:-ms-flexbox;display:flex}.background{display:-ms-flexbox;display:flex;height:100%;width:100%;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;border-radius:50%}.initials{font-weight:var(--calcite-font-weight-bold);text-transform:uppercase;color:var(--calcite-ui-text-3)}.thumbnail{height:100%;width:100%;border-radius:50%}";
- const Avatar = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** specify the scale of the avatar, defaults to m */
- this.scale = "m";
- //--------------------------------------------------------------------------
- //
- // Private State/Props
- //
- //--------------------------------------------------------------------------
- /** True if thumnail fails to load */
- this.error = false;
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- render() {
- return this.determineContent();
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- determineContent() {
- if (this.thumbnail && !this.error) {
- return (h("img", { alt: "", class: "thumbnail", onError: () => (this.error = true), src: this.thumbnail }));
- }
- const initials = this.generateInitials();
- const backgroundColor = this.generateFillColor();
- return (h("span", { class: "background", style: { backgroundColor } }, initials ? (h("span", { "aria-hidden": "true", class: "initials" }, initials)) : (h("calcite-icon", { class: "icon", icon: "user", scale: this.scale }))));
- }
- /**
- * Generate a valid background color that is consistent and unique to this user
- */
- generateFillColor() {
- const { userId, username, fullName, el } = this;
- const theme = getThemeName(el);
- const id = userId && `#${userId.substr(userId.length - 6)}`;
- const name = username || fullName || "";
- const hex = id && isValidHex(id) ? id : stringToHex(name);
- // if there is not unique information, or an invalid hex is produced, return a default
- if ((!userId && !name) || !isValidHex(hex)) {
- return `var(--calcite-ui-foreground-2)`;
- }
- const hue = hexToHue(hex);
- const l = theme === "dark" ? 20 : 90;
- return `hsl(${hue}, 60%, ${l}%)`;
- }
- /**
- * Use fullname or username to generate initials
- */
- generateInitials() {
- const { fullName, username } = this;
- if (fullName) {
- return fullName
- .trim()
- .split(" ")
- .map((name) => name.substring(0, 1))
- .join("");
- }
- else if (username) {
- return username.substring(0, 2);
- }
- return false;
- }
- get el() { return this; }
- static get style() { return avatarCss; }
- };
- const CSS$L = {
- article: "article",
- content: "content",
- headerContainer: "header-container",
- icon: "icon",
- statusIcon: "status-icon",
- toggle: "toggle",
- toggleIcon: "toggle-icon",
- title: "title",
- heading: "heading",
- header: "header",
- button: "button",
- summary: "summary",
- controlContainer: "control-container",
- valid: "valid",
- invalid: "invalid",
- loading: "loading"
- };
- const TEXT$m = {
- collapse: "Collapse",
- expand: "Expand",
- loading: "Loading",
- options: "Options"
- };
- const SLOTS$k = {
- icon: "icon",
- control: "control",
- headerMenuActions: "header-menu-actions"
- };
- const ICONS$c = {
- opened: "chevron-up",
- closed: "chevron-down",
- valid: "check-circle",
- invalid: "exclamation-mark-triangle",
- refresh: "refresh"
- };
- const HEADING_LEVEL$7 = 4;
- function constrainHeadingLevel(level) {
- return Math.min(Math.max(Math.ceil(level), 1), 6);
- }
- const Heading = (props, children) => {
- const HeadingTag = `h${props.level}`;
- delete props.level;
- return h(HeadingTag, Object.assign({}, props), children);
- };
- const blockCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:host{-webkit-box-sizing:border-box;box-sizing:border-box;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-2);font-size:var(--calcite-font-size--1)}:host *{-webkit-box-sizing:border-box;box-sizing:border-box}:host{--calcite-icon-size:1rem;--calcite-spacing-eighth:0.125rem;--calcite-spacing-quarter:0.25rem;--calcite-spacing-half:0.5rem;--calcite-spacing-three-quarters:0.75rem;--calcite-spacing:1rem;--calcite-spacing-plus-quarter:1.25rem;--calcite-spacing-plus-half:1.5rem;--calcite-spacing-double:2rem;--calcite-menu-min-width:10rem;--calcite-header-min-height:3rem;--calcite-footer-min-height:3rem}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:-ms-flexbox;display:flex;-ms-flex-negative:0;flex-shrink:0;-ms-flex-positive:0;flex-grow:0;-ms-flex-direction:column;flex-direction:column;border-width:0px;border-bottom-width:1px;border-style:solid;border-color:var(--calcite-ui-border-3);padding:0px;-webkit-transition-property:margin;transition-property:margin;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.215, 0.440, 0.420, 0.880);transition-timing-function:cubic-bezier(0.215, 0.440, 0.420, 0.880);-ms-flex-preferred-size:auto;flex-basis:auto}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.header{margin:0px;display:-ms-flexbox;display:flex;-ms-flex-line-pack:justify;align-content:space-between;-ms-flex-align:center;align-items:center;fill:var(--calcite-ui-text-2);color:var(--calcite-ui-text-2)}.heading{margin:0px;padding:0px;font-weight:var(--calcite-font-weight-medium)}.header .heading{-ms-flex:1 1 auto;flex:1 1 auto;padding:0.5rem}h1.heading{font-size:var(--calcite-font-size-2);line-height:1.5rem}h2.heading{font-size:var(--calcite-font-size-1);line-height:1.5rem}h3.heading{font-size:var(--calcite-font-size-0);line-height:1.25rem}h4.heading,h5.heading{font-size:var(--calcite-font-size--1);line-height:1rem}.header{-ms-flex-pack:start;justify-content:flex-start;padding:0px}.header,.toggle{grid-area:header}.header-container{display:grid;-ms-flex-align:stretch;align-items:stretch;grid-template:auto/auto 1fr auto auto;grid-template-areas:\"handle header control menu\";grid-column:header-start/menu-end;grid-row:1/2}.toggle{margin:0px;display:-ms-flexbox;display:flex;cursor:pointer;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-ms-flex-align:center;align-items:center;-ms-flex-pack:justify;justify-content:space-between;border-style:none;padding:0px;font-family:inherit;outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;text-align:initial;background-color:transparent}.toggle:hover{background-color:var(--calcite-ui-foreground-2)}.toggle:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}calcite-loader[inline]{grid-area:control;align-self:center}calcite-handle{grid-area:handle}.title{margin:0px;padding:0.75rem}.header .title .heading{padding:0px;font-size:var(--calcite-font-size--1);font-weight:var(--calcite-font-weight-medium);line-height:1.25;color:var(--calcite-ui-text-2);-webkit-transition-property:color;transition-property:color;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);word-wrap:break-word;word-break:break-word}.summary{margin-top:0.125rem;padding:0px;font-size:var(--calcite-font-size--2);color:var(--calcite-ui-text-3);word-wrap:break-word;word-break:break-word}.icon{-webkit-margin-start:0.75rem;margin-inline-start:0.75rem;-webkit-margin-end:0px;margin-inline-end:0px;margin-block:0.75rem}.status-icon.valid{color:var(--calcite-ui-success)}.status-icon.invalid{color:var(--calcite-ui-danger)}.status-icon.loading{-webkit-animation:spin 2s linear infinite;animation:spin 2s linear infinite}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}50%{-webkit-transform:rotate(180deg);transform:rotate(180deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}50%{-webkit-transform:rotate(180deg);transform:rotate(180deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}.toggle-icon{margin-top:0.75rem;margin-bottom:0.75rem;-ms-flex-item-align:center;align-self:center;justify-self:end;color:var(--calcite-ui-text-3);-webkit-transition-property:color;transition-property:color;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);-webkit-margin-end:1rem;margin-inline-end:1rem;-webkit-margin-start:auto;margin-inline-start:auto}.toggle:hover .toggle-icon{color:var(--calcite-ui-text-1)}.content{position:relative}@keyframes in{0%{opacity:0}100%{opacity:1}}.content{-webkit-animation:in var(--calcite-internal-animation-timing-slow) ease-in-out;animation:in var(--calcite-internal-animation-timing-slow) ease-in-out;padding-left:0.75rem;padding-right:0.75rem;padding-top:0.5rem;padding-bottom:0.5rem}.control-container{margin:0px;display:-ms-flexbox;display:flex;grid-area:control}calcite-action-menu{grid-area:menu}:host([open]){margin-top:0.5rem;margin-bottom:0.5rem}:host([open]) .header .title .heading{color:var(--calcite-ui-text-1)}";
- const Block = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteBlockToggle = createEvent(this, "calciteBlockToggle", 7);
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * When true, this block will be collapsible.
- */
- this.collapsible = false;
- /**
- * When true, disabled prevents interaction. This state shows items with lower opacity/grayed.
- */
- this.disabled = false;
- /**
- * When true, displays a drag handle in the header.
- */
- this.dragHandle = false;
- /**
- * Aria-label for collapsing the toggle and tooltip used for the toggle when expanded.
- */
- this.intlCollapse = TEXT$m.collapse;
- /**
- * Aria-label for expanding the toggle and tooltip used for the toggle when collapsed.
- */
- this.intlExpand = TEXT$m.expand;
- /** string to override English loading text
- * @default "Loading"
- */
- this.intlLoading = TEXT$m.loading;
- /** Text string used for the actions menu
- * @default "Options"
- */
- this.intlOptions = TEXT$m.options;
- /**
- * When true, content is waiting to be loaded. This state shows a busy indicator.
- */
- this.loading = false;
- /**
- * When true, the block's content will be displayed.
- */
- this.open = false;
- this.guid = guid();
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- this.onHeaderClick = () => {
- this.open = !this.open;
- this.calciteBlockToggle.emit();
- };
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentDidRender() {
- updateHostInteraction(this);
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- connectConditionalSlotComponent(this);
- }
- disconnectedCallback() {
- disconnectConditionalSlotComponent(this);
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- renderScrim() {
- const { loading } = this;
- const defaultSlot = h("slot", null);
- return [loading ? h("calcite-scrim", { loading: loading }) : null, defaultSlot];
- }
- renderIcon() {
- const { el, status } = this;
- const showingLoadingStatus = this.loading && !this.open;
- const statusIcon = showingLoadingStatus ? ICONS$c.refresh : ICONS$c[status];
- const hasIcon = getSlotted(el, SLOTS$k.icon) || statusIcon;
- const iconEl = !statusIcon ? (h("slot", { key: "icon-slot", name: SLOTS$k.icon })) : (h("calcite-icon", { class: {
- [CSS$L.statusIcon]: true,
- [CSS$L.valid]: status == "valid",
- [CSS$L.invalid]: status == "invalid",
- [CSS$L.loading]: showingLoadingStatus
- }, icon: statusIcon, scale: "m" }));
- return hasIcon ? h("div", { class: CSS$L.icon }, iconEl) : null;
- }
- renderTitle() {
- const { heading, headingLevel, summary } = this;
- return heading || summary ? (h("div", { class: CSS$L.title }, h(Heading, { class: CSS$L.heading, level: headingLevel || HEADING_LEVEL$7 }, heading), summary ? h("div", { class: CSS$L.summary }, summary) : null)) : null;
- }
- render() {
- const { collapsible, el, intlCollapse, intlExpand, loading, open, intlLoading } = this;
- const toggleLabel = open ? intlCollapse || TEXT$m.collapse : intlExpand || TEXT$m.expand;
- const headerContent = (h("header", { class: CSS$L.header }, this.renderIcon(), this.renderTitle()));
- const hasControl = !!getSlotted(el, SLOTS$k.control);
- const hasMenuActions = !!getSlotted(el, SLOTS$k.headerMenuActions);
- const collapseIcon = open ? ICONS$c.opened : ICONS$c.closed;
- const { guid } = this;
- const regionId = `${guid}-region`;
- const buttonId = `${guid}-button`;
- const headerNode = (h("div", { class: CSS$L.headerContainer }, this.dragHandle ? h("calcite-handle", null) : null, collapsible ? (h("button", { "aria-controls": regionId, "aria-expanded": collapsible ? toAriaBoolean(open) : null, "aria-label": toggleLabel, class: CSS$L.toggle, id: buttonId, onClick: this.onHeaderClick, title: toggleLabel }, headerContent, !hasControl && !hasMenuActions ? (h("calcite-icon", { "aria-hidden": "true", class: CSS$L.toggleIcon, icon: collapseIcon, scale: "s" })) : null)) : (headerContent), loading ? (h("calcite-loader", { inline: true, "is-active": true, label: intlLoading })) : hasControl ? (h("div", { class: CSS$L.controlContainer }, h("slot", { name: SLOTS$k.control }))) : null, hasMenuActions ? (h("calcite-action-menu", { label: this.intlOptions || TEXT$m.options }, h("slot", { name: SLOTS$k.headerMenuActions }))) : null));
- return (h(Host, null, h("article", { "aria-busy": toAriaBoolean(loading), class: {
- [CSS$L.article]: true
- } }, headerNode, h("section", { "aria-expanded": toAriaBoolean(open), "aria-labelledby": buttonId, class: CSS$L.content, hidden: !open, id: regionId }, this.renderScrim()))));
- }
- get el() { return this; }
- static get style() { return blockCss; }
- };
- const CSS$K = {
- content: "content",
- invalid: "invalid",
- toggle: "toggle",
- toggleSwitch: "toggle--switch",
- toggleSwitchContent: "toggle--switch__content",
- toggleSwitchText: "toggle--switch__text",
- sectionHeader: "section-header",
- sectionHeaderText: "section-header__text",
- statusIcon: "status-icon",
- valid: "valid"
- };
- const TEXT$l = {
- collapse: "Collapse",
- expand: "Expand"
- };
- const ICONS$b = {
- menuOpen: "chevron-down",
- menuClosedLeft: "chevron-left",
- menuClosedRight: "chevron-right",
- valid: "check-circle",
- invalid: "exclamation-mark-triangle"
- };
- const blockSectionCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{-webkit-box-sizing:border-box;box-sizing:border-box;display:block;background-color:var(--calcite-ui-foreground-1);font-size:var(--calcite-font-size--1);color:var(--calcite-ui-text-2)}:host([open]){border-width:0px;border-bottom-width:1px;border-style:solid;border-bottom-color:var(--calcite-ui-border-3)}:host(:last-child){border-bottom-width:0px}.toggle{width:100%;border-width:0px;background-color:transparent;font-family:var(--calcite-sans-family);font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-2)}.toggle--switch,.section-header{margin-left:0px;margin-right:0px;margin-top:0.25rem;margin-bottom:0.25rem;display:-ms-flexbox;display:flex;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-ms-flex-align:center;align-items:center;padding-left:0px;padding-right:0px;padding-top:0.5rem;padding-bottom:0.5rem;font-size:var(--calcite-font-size--1);outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out}.toggle--switch:focus,.section-header:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:2px}.toggle--switch:hover,.section-header:hover{color:var(--calcite-ui-text-1)}.section-header .status-icon{-ms-flex-item-align:end;align-self:flex-end}.section-header__text{margin-left:0.75rem;margin-right:0.75rem;margin-top:0px;margin-bottom:0px;-ms-flex:1 1 auto;flex:1 1 auto;text-align:initial;word-wrap:anywhere}.toggle--switch calcite-switch{pointer-events:none;-webkit-margin-start:0.25rem;margin-inline-start:0.25rem}.toggle--switch .status-icon{-webkit-margin-start:0.5rem;margin-inline-start:0.5rem}.toggle--switch__content{display:-ms-flexbox;display:flex;-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-align:center;align-items:center}.status-icon.valid{color:var(--calcite-ui-success)}.status-icon.invalid{color:var(--calcite-ui-danger)}";
- const BlockSection = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteBlockSectionToggle = createEvent(this, "calciteBlockSectionToggle", 7);
- /**
- * When true, the block's section content will be displayed.
- */
- this.open = false;
- /**
- * This property determines the look of the section toggle.
- * If the value is "switch", a toggle-switch will be displayed.
- * If the value is "button", a clickable header is displayed.
- */
- this.toggleDisplay = "button";
- this.guid = guid();
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- this.handleHeaderKeyDown = (event) => {
- if (event.key === " " || event.key === "Enter") {
- this.toggleSection();
- event.preventDefault();
- event.stopPropagation();
- }
- };
- this.toggleSection = () => {
- this.open = !this.open;
- this.calciteBlockSectionToggle.emit();
- };
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- renderStatusIcon() {
- var _a;
- const { status } = this;
- const statusIcon = (_a = ICONS$b[status]) !== null && _a !== void 0 ? _a : false;
- const statusIconClasses = {
- [CSS$K.statusIcon]: true,
- [CSS$K.valid]: status == "valid",
- [CSS$K.invalid]: status == "invalid"
- };
- return !!statusIcon ? (h("calcite-icon", { class: statusIconClasses, icon: statusIcon, scale: "s" })) : null;
- }
- render() {
- const { el, intlCollapse, intlExpand, open, text, toggleDisplay } = this;
- const dir = getElementDir(el);
- const arrowIcon = open
- ? ICONS$b.menuOpen
- : dir === "rtl"
- ? ICONS$b.menuClosedLeft
- : ICONS$b.menuClosedRight;
- const toggleLabel = open ? intlCollapse || TEXT$l.collapse : intlExpand || TEXT$l.expand;
- const { guid } = this;
- const regionId = `${guid}-region`;
- const buttonId = `${guid}-button`;
- const headerNode = toggleDisplay === "switch" ? (h("div", { "aria-controls": regionId, "aria-label": toggleLabel, class: {
- [CSS$K.toggle]: true,
- [CSS$K.toggleSwitch]: true
- }, id: buttonId, onClick: this.toggleSection, onKeyDown: this.handleHeaderKeyDown, tabIndex: 0, title: toggleLabel }, h("div", { class: CSS$K.toggleSwitchContent }, h("span", { class: CSS$K.toggleSwitchText }, text)), h("calcite-switch", { checked: open, label: toggleLabel, scale: "s", tabIndex: -1 }), this.renderStatusIcon())) : (h("button", { "aria-controls": regionId, "aria-label": toggleLabel, class: {
- [CSS$K.sectionHeader]: true,
- [CSS$K.toggle]: true
- }, id: buttonId, name: toggleLabel, onClick: this.toggleSection }, h("calcite-icon", { icon: arrowIcon, scale: "s" }), h("span", { class: CSS$K.sectionHeaderText }, text), this.renderStatusIcon()));
- return (h(Host, null, headerNode, h("section", { "aria-expanded": toAriaBoolean(open), "aria-labelledby": buttonId, class: CSS$K.content, hidden: !open, id: regionId }, h("slot", null))));
- }
- get el() { return this; }
- static get style() { return blockSectionCss; }
- };
- (function(prototype) {
- if (typeof prototype.requestSubmit == "function") return
- prototype.requestSubmit = function(submitter) {
- if (submitter) {
- validateSubmitter(submitter, this);
- submitter.click();
- } else {
- submitter = document.createElement("input");
- submitter.type = "submit";
- submitter.hidden = true;
- this.appendChild(submitter);
- submitter.click();
- this.removeChild(submitter);
- }
- };
- function validateSubmitter(submitter, form) {
- submitter instanceof HTMLElement || raise(TypeError, "parameter 1 is not of type 'HTMLElement'");
- submitter.type == "submit" || raise(TypeError, "The specified element is not a submit button");
- submitter.form == form || raise(DOMException, "The specified element is not owned by this form element", "NotFoundError");
- }
- function raise(errorConstructor, message, name) {
- throw new errorConstructor("Failed to execute 'requestSubmit' on 'HTMLFormElement': " + message + ".", name)
- }
- })(HTMLFormElement.prototype);
- const CSS$J = {
- buttonLoader: "calcite-button--loader",
- content: "content",
- contentSlotted: "content--slotted",
- icon: "icon",
- iconStart: "icon--start",
- iconEnd: "icon--end",
- loadingIn: "loading-in",
- loadingOut: "loading-out",
- iconStartEmpty: "icon-start-empty",
- iconEndEmpty: "icon-end-empty"
- };
- const TEXT$k = {
- loading: "Loading"
- };
- /**
- * Exported for testing purposes only
- * @internal
- */
- const labelClickEvent = "calciteInternalLabelClick";
- const labelConnectedEvent = "calciteInternalLabelConnected";
- const labelDisconnectedEvent = "calciteInternaLabelDisconnected";
- const labelTagName = "calcite-label";
- const onLabelClickMap = new WeakMap();
- const onLabelConnectedMap = new WeakMap();
- const onLabelDisconnectedMap = new WeakMap();
- const unlabeledComponents = new Set();
- const findLabelForComponent = (componentEl) => {
- const { id } = componentEl;
- const forLabel = id && queryElementRoots(componentEl, { selector: `${labelTagName}[for="${id}"]` });
- if (forLabel) {
- return forLabel;
- }
- const parentLabel = closestElementCrossShadowBoundary(componentEl, labelTagName);
- if (!parentLabel ||
- // labelable components within other custom elements are not considered labelable
- hasAncestorCustomElements(parentLabel, componentEl)) {
- return null;
- }
- return parentLabel;
- };
- function hasAncestorCustomElements(label, componentEl) {
- let traversedElements;
- const customElementAncestorCheckEventType = "custom-element-ancestor-check";
- const listener = (event) => {
- event.stopImmediatePropagation();
- const composedPath = event.composedPath();
- traversedElements = composedPath.slice(composedPath.indexOf(componentEl), composedPath.indexOf(label));
- };
- label.addEventListener(customElementAncestorCheckEventType, listener, { once: true });
- componentEl.dispatchEvent(new CustomEvent(customElementAncestorCheckEventType, { composed: true, bubbles: true }));
- label.removeEventListener(customElementAncestorCheckEventType, listener);
- const ancestorCustomElements = traversedElements
- .filter((el) => el !== componentEl && el !== label)
- .filter((el) => { var _a; return (_a = el.tagName) === null || _a === void 0 ? void 0 : _a.includes("-"); });
- return ancestorCustomElements.length > 0;
- }
- /**
- * Helper to set up label interactions on connectedCallback.
- */
- function connectLabel(component) {
- const labelEl = findLabelForComponent(component.el);
- if (onLabelClickMap.has(labelEl) || (!labelEl && unlabeledComponents.has(component))) {
- return;
- }
- const boundOnLabelDisconnected = onLabelDisconnected.bind(component);
- if (labelEl) {
- component.labelEl = labelEl;
- const boundOnLabelClick = onLabelClick.bind(component);
- onLabelClickMap.set(component.labelEl, boundOnLabelClick);
- component.labelEl.addEventListener(labelClickEvent, boundOnLabelClick);
- unlabeledComponents.delete(component);
- document.removeEventListener(labelConnectedEvent, onLabelConnectedMap.get(component));
- onLabelDisconnectedMap.set(component, boundOnLabelDisconnected);
- document.addEventListener(labelDisconnectedEvent, boundOnLabelDisconnected);
- }
- else if (!unlabeledComponents.has(component)) {
- boundOnLabelDisconnected();
- document.removeEventListener(labelDisconnectedEvent, onLabelDisconnectedMap.get(component));
- }
- }
- /**
- * Helper to tear down label interactions on disconnectedCallback on labelable components.
- */
- function disconnectLabel(component) {
- unlabeledComponents.delete(component);
- document.removeEventListener(labelConnectedEvent, onLabelConnectedMap.get(component));
- document.removeEventListener(labelDisconnectedEvent, onLabelDisconnectedMap.get(component));
- onLabelConnectedMap.delete(component);
- onLabelDisconnectedMap.delete(component);
- if (!component.labelEl) {
- return;
- }
- const boundOnLabelClick = onLabelClickMap.get(component.labelEl);
- component.labelEl.removeEventListener(labelClickEvent, boundOnLabelClick);
- onLabelClickMap.delete(component.labelEl);
- }
- /**
- * Helper to get the label text from a component.
- */
- function getLabelText(component) {
- var _a, _b;
- return component.label || ((_b = (_a = component.labelEl) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || "";
- }
- function onLabelClick(event) {
- if (this.disabled) {
- return;
- }
- const containedLabelableChildClicked = this.el.contains(event.detail.sourceEvent.target);
- if (containedLabelableChildClicked) {
- return;
- }
- this.onLabelClick(event);
- }
- function onLabelConnected() {
- if (unlabeledComponents.has(this)) {
- connectLabel(this);
- }
- }
- function onLabelDisconnected() {
- unlabeledComponents.add(this);
- const boundOnLabelConnected = onLabelConnectedMap.get(this) || onLabelConnected.bind(this);
- onLabelConnectedMap.set(this, boundOnLabelConnected);
- document.addEventListener(labelConnectedEvent, boundOnLabelConnected);
- }
- /**
- * Exported for testing purposes.
- */
- const hiddenFormInputSlotName = "hidden-form-input";
- function isCheckable(component) {
- return "checked" in component;
- }
- const onFormResetMap = new WeakMap();
- const formComponentSet = new WeakSet();
- function hasRegisteredFormComponentParent(form, formComponentEl) {
- // we use events as a way to test for nested form-associated components across shadow bounds
- const formComponentRegisterEventName = "calciteInternalFormComponentRegister";
- let hasRegisteredFormComponentParent = false;
- form.addEventListener(formComponentRegisterEventName, (event) => {
- hasRegisteredFormComponentParent = event
- .composedPath()
- .some((element) => formComponentSet.has(element));
- event.stopPropagation();
- }, { once: true });
- formComponentEl.dispatchEvent(new CustomEvent(formComponentRegisterEventName, {
- bubbles: true,
- composed: true
- }));
- return hasRegisteredFormComponentParent;
- }
- /**
- * Helper to submit a form.
- */
- function submitForm(component) {
- var _a;
- (_a = component.formEl) === null || _a === void 0 ? void 0 : _a.requestSubmit();
- }
- /**
- * Helper to reset a form.
- */
- function resetForm(component) {
- var _a;
- (_a = component.formEl) === null || _a === void 0 ? void 0 : _a.reset();
- }
- /**
- * Helper to set up form interactions on connectedCallback.
- */
- function connectForm(component) {
- const { el, value } = component;
- const form = closestElementCrossShadowBoundary(el, "form");
- if (!form || hasRegisteredFormComponentParent(form, el)) {
- return;
- }
- component.formEl = form;
- component.defaultValue = value;
- if (isCheckable(component)) {
- component.defaultChecked = component.checked;
- }
- const boundOnFormReset = (component.onFormReset || onFormReset).bind(component);
- form.addEventListener("reset", boundOnFormReset);
- onFormResetMap.set(component.el, boundOnFormReset);
- formComponentSet.add(el);
- }
- function onFormReset() {
- if (isCheckable(this)) {
- this.checked = this.defaultChecked;
- return;
- }
- this.value = this.defaultValue;
- }
- /**
- * Helper to tear down form interactions on disconnectedCallback.
- */
- function disconnectForm(component) {
- const { el, formEl } = component;
- if (!formEl) {
- return;
- }
- const boundOnFormReset = onFormResetMap.get(el);
- formEl.removeEventListener("reset", boundOnFormReset);
- onFormResetMap.delete(el);
- component.formEl = null;
- formComponentSet.delete(el);
- }
- /**
- * Helper for setting the default value on initialization after connectedCallback.
- *
- * Note that this is only needed if the default value cannot be determined on connectedCallback.
- */
- function afterConnectDefaultValueSet(component, value) {
- component.defaultValue = value;
- }
- /**
- * Helper for maintaining a form-associated's hidden input in sync with the component.
- *
- * Based on Ionic's approach: https://github.com/ionic-team/ionic-framework/blob/e4bf052794af9aac07f887013b9250d2a045eba3/core/src/utils/helpers.ts#L198
- */
- function syncHiddenFormInput(component) {
- const { el, formEl, name, value } = component;
- const { ownerDocument } = el;
- const inputs = el.querySelectorAll(`input[slot="${hiddenFormInputSlotName}"]`);
- if (!formEl || !name) {
- inputs.forEach((input) => input.remove());
- return;
- }
- const values = Array.isArray(value) ? value : [value];
- const extra = [];
- const seen = new Set();
- inputs.forEach((input) => {
- const valueMatch = values.find((val) =>
- /* intentional non-strict equality check */
- val == input.value);
- if (valueMatch != null) {
- seen.add(valueMatch);
- defaultSyncHiddenFormInput(component, input, valueMatch);
- }
- else {
- extra.push(input);
- }
- });
- let docFrag;
- values.forEach((value) => {
- if (seen.has(value)) {
- return;
- }
- let input = extra.pop();
- if (!input) {
- input = ownerDocument.createElement("input");
- input.slot = hiddenFormInputSlotName;
- }
- if (!docFrag) {
- docFrag = ownerDocument.createDocumentFragment();
- }
- docFrag.append(input);
- defaultSyncHiddenFormInput(component, input, value);
- });
- if (docFrag) {
- el.append(docFrag);
- }
- extra.forEach((input) => input.remove());
- }
- function defaultSyncHiddenFormInput(component, input, value) {
- var _a;
- const { defaultValue, disabled, name, required } = component;
- // keep in sync to prevent losing reset value
- input.defaultValue = defaultValue;
- input.disabled = disabled;
- input.name = name;
- input.required = required;
- input.tabIndex = -1;
- if (isCheckable(component)) {
- // keep in sync to prevent losing reset value
- input.defaultChecked = component.defaultChecked;
- // heuristic to support default/on mode from https://html.spec.whatwg.org/multipage/input.html#dom-input-value-default-on
- input.value = component.checked ? value || "on" : "";
- // we disable the component when not checked to avoid having its value submitted
- if (!disabled && !component.checked) {
- input.disabled = true;
- }
- }
- else {
- input.value = value || "";
- }
- (_a = component.syncHiddenFormInput) === null || _a === void 0 ? void 0 : _a.call(component, input);
- }
- /**
- * Helper to render the slot for form-associated component's hidden input.
- *
- * If the component has a default slot, this must be placed at the bottom of the component's root container to ensure it is the last child.
- *
- * render(): VNode {
- * <Host>
- * <div class={CSS.container}>
- * // ...
- * <HiddenFormInputSlot component={this} />
- * </div>
- * </Host>
- * }
- *
- * Note that the hidden-form-input Sass mixin must be added to the component's style to apply specific styles.
- */
- const HiddenFormInputSlot = ({ component }) => {
- syncHiddenFormInput(component);
- return h("slot", { name: hiddenFormInputSlotName });
- };
- const buttonCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:inline-block;width:auto;vertical-align:middle}:host([round]){border-radius:50px}:host([round]) a,:host([round]) button{border-radius:50px}:host button,:host a{outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out}:host button:focus,:host a:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:2px}:host button,:host a{--calcite-button-content-margin:0.5rem;--calcite-button-padding-x:7px;--calcite-button-padding-y:3px;padding:var(--calcite-button-padding-y) var(--calcite-button-padding-x) var(--calcite-button-padding-y) var(--calcite-button-padding-x);position:relative;-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;height:100%;width:100%;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-appearance:none;-moz-appearance:none;appearance:none;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;border-radius:0px;border-style:none;text-align:center;font-family:inherit;font-weight:var(--calcite-font-weight-normal);-webkit-text-decoration-line:none;text-decoration-line:none;-webkit-transition:color var(--calcite-animation-timing) ease-in-out, background-color var(--calcite-animation-timing) ease-in-out, outline-offset var(--calcite-internal-animation-timing-fast) ease-in-out, outline-color var(--calcite-internal-animation-timing-fast) ease-in-out, -webkit-box-shadow var(--calcite-animation-timing) ease-in-out;transition:color var(--calcite-animation-timing) ease-in-out, background-color var(--calcite-animation-timing) ease-in-out, outline-offset var(--calcite-internal-animation-timing-fast) ease-in-out, outline-color var(--calcite-internal-animation-timing-fast) ease-in-out, -webkit-box-shadow var(--calcite-animation-timing) ease-in-out;transition:color var(--calcite-animation-timing) ease-in-out, background-color var(--calcite-animation-timing) ease-in-out, box-shadow var(--calcite-animation-timing) ease-in-out, outline-offset var(--calcite-internal-animation-timing-fast) ease-in-out, outline-color var(--calcite-internal-animation-timing-fast) ease-in-out;transition:color var(--calcite-animation-timing) ease-in-out, background-color var(--calcite-animation-timing) ease-in-out, box-shadow var(--calcite-animation-timing) ease-in-out, outline-offset var(--calcite-internal-animation-timing-fast) ease-in-out, outline-color var(--calcite-internal-animation-timing-fast) ease-in-out, -webkit-box-shadow var(--calcite-animation-timing) ease-in-out}:host button:hover,:host a:hover{-webkit-text-decoration-line:none;text-decoration-line:none}.content{display:-ms-flexbox;display:flex;-ms-flex-preferred-size:auto;flex-basis:auto;-webkit-margin-start:var(--calcite-button-content-margin);margin-inline-start:var(--calcite-button-content-margin);-webkit-margin-end:var(--calcite-button-content-margin);margin-inline-end:var(--calcite-button-content-margin)}.icon-start-empty .content{-webkit-margin-start:unset;margin-inline-start:unset}.icon-end-empty .content{-webkit-margin-end:unset;margin-inline-end:unset}:host([scale=m]) button,:host([scale=m]) a{--calcite-button-content-margin:0.75rem}:host([scale=l]) button,:host([scale=l]) a{--calcite-button-content-margin:1rem}:host([width=auto]){width:auto}:host([width=half]){width:50%}:host([width=full]){width:100%}:host([alignment=center]:not([width=auto])) a,:host([alignment=center]:not([width=auto])) button{-ms-flex-pack:center;justify-content:center}:host([alignment=start]:not([width=auto])) a,:host([alignment=start]:not([width=auto])) button{-ms-flex-pack:start;justify-content:flex-start}:host([alignment=end]:not([width=auto])) a,:host([alignment=end]:not([width=auto])) button{-ms-flex-pack:end;justify-content:flex-end}:host([alignment*=space-between]:not([width=auto])) a,:host([alignment*=space-between]:not([width=auto])) button{-ms-flex-pack:justify;justify-content:space-between}:host([alignment=icon-start-space-between]:not([width=auto])) .icon--start{-webkit-margin-end:auto;margin-inline-end:auto}:host([alignment=icon-start-space-between]:not([width=auto])) a,:host([alignment=icon-start-space-between]:not([width=auto])) button{text-align:unset}:host([alignment=icon-end-space-between]:not([width=auto])) .icon--end{-webkit-margin-start:auto;margin-inline-start:auto}:host([alignment=icon-end-space-between]:not([width=auto])) a,:host([alignment=icon-end-space-between]:not([width=auto])) button{text-align:unset}:host([alignment=center]) a:not(.content--slotted) .icon--start+.icon--end,:host([alignment=center]) button:not(.content--slotted) .icon--start+.icon--end{-webkit-margin-start:var(--calcite-button-content-margin);margin-inline-start:var(--calcite-button-content-margin)}.icon{position:relative;margin:0px;display:-ms-inline-flexbox;display:inline-flex;font-weight:var(--calcite-font-weight-normal);line-height:inherit}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host([loading]){pointer-events:none}:host([loading]) button,:host([loading]) a{pointer-events:none;opacity:var(--calcite-ui-opacity-disabled)}@-webkit-keyframes loader-in{0%{width:0;opacity:0;-webkit-transform:scale(0.5);transform:scale(0.5)}100%{width:1em;opacity:1;-webkit-transform:scale(1);transform:scale(1)}}@keyframes loader-in{0%{width:0;opacity:0;-webkit-transform:scale(0.5);transform:scale(0.5)}100%{width:1em;opacity:1;-webkit-transform:scale(1);transform:scale(1)}}@-webkit-keyframes loader-out{0%{width:1em;opacity:1;-webkit-transform:scale(1);transform:scale(1)}100%{width:0;opacity:0;-webkit-transform:scale(0.5);transform:scale(0.5)}}@keyframes loader-out{0%{width:1em;opacity:1;-webkit-transform:scale(1);transform:scale(1)}100%{width:0;opacity:0;-webkit-transform:scale(0.5);transform:scale(0.5)}}.calcite-button--loader{display:-ms-flexbox;display:flex}.calcite-button--loader calcite-loader{margin:0px;-webkit-transition:width var(--calcite-internal-animation-timing-slow) ease-in-out, opacity var(--calcite-internal-animation-timing-slow) ease-in-out, -webkit-transform var(--calcite-internal-animation-timing-slow) ease-in-out;transition:width var(--calcite-internal-animation-timing-slow) ease-in-out, opacity var(--calcite-internal-animation-timing-slow) ease-in-out, -webkit-transform var(--calcite-internal-animation-timing-slow) ease-in-out;transition:width var(--calcite-internal-animation-timing-slow) ease-in-out, opacity var(--calcite-internal-animation-timing-slow) ease-in-out, transform var(--calcite-internal-animation-timing-slow) ease-in-out;transition:width var(--calcite-internal-animation-timing-slow) ease-in-out, opacity var(--calcite-internal-animation-timing-slow) ease-in-out, transform var(--calcite-internal-animation-timing-slow) ease-in-out, -webkit-transform var(--calcite-internal-animation-timing-slow) ease-in-out}.calcite-button--loader calcite-loader.loading-in{-webkit-animation-name:loader-in;animation-name:loader-in;-webkit-animation-duration:310ms;animation-duration:310ms}.calcite-button--loader calcite-loader.loading-out{-webkit-animation-name:loader-out;animation-name:loader-out;-webkit-animation-duration:310ms;animation-duration:310ms}:host([loading]) button.content--slotted .calcite-button--loader calcite-loader,:host([loading]) a.content--slotted .calcite-button--loader calcite-loader{-webkit-margin-end:var(--calcite-button-content-margin);margin-inline-end:var(--calcite-button-content-margin)}:host([loading]) button:not(.content--slotted) .icon--start,:host([loading]) button:not(.content--slotted) .icon--end,:host([loading]) a:not(.content--slotted) .icon--start,:host([loading]) a:not(.content--slotted) .icon--end{display:none}:host([appearance=solid]) button,:host([appearance=solid]) a{border-width:1px;border-style:solid;border-color:transparent}:host([appearance=solid][color=blue]) button,:host([appearance=solid][color=blue]) a{background-color:var(--calcite-ui-brand);color:var(--calcite-ui-text-inverse)}:host([appearance=solid][color=blue]) button:hover,:host([appearance=solid][color=blue]) button:focus,:host([appearance=solid][color=blue]) a:hover,:host([appearance=solid][color=blue]) a:focus{background-color:var(--calcite-ui-brand-hover)}:host([appearance=solid][color=blue]) button:active,:host([appearance=solid][color=blue]) a:active{background-color:var(--calcite-ui-brand-press)}:host([appearance=solid][color=blue]) button calcite-loader,:host([appearance=solid][color=blue]) a calcite-loader{color:var(--calcite-ui-text-inverse)}:host([appearance=solid][color=red]) button,:host([appearance=solid][color=red]) a{background-color:var(--calcite-ui-danger);color:var(--calcite-ui-text-inverse)}:host([appearance=solid][color=red]) button:hover,:host([appearance=solid][color=red]) button:focus,:host([appearance=solid][color=red]) a:hover,:host([appearance=solid][color=red]) a:focus{background-color:var(--calcite-ui-danger-hover)}:host([appearance=solid][color=red]) button:active,:host([appearance=solid][color=red]) a:active{background-color:var(--calcite-ui-danger-press)}:host([appearance=solid][color=red]) button calcite-loader,:host([appearance=solid][color=red]) a calcite-loader{color:var(--calcite-ui-text-inverse)}:host([appearance=solid][color=neutral]) button,:host([appearance=solid][color=neutral]) a{background-color:var(--calcite-ui-foreground-3);color:var(--calcite-ui-text-1)}:host([appearance=solid][color=neutral]) button:hover,:host([appearance=solid][color=neutral]) button:focus,:host([appearance=solid][color=neutral]) a:hover,:host([appearance=solid][color=neutral]) a:focus{background-color:var(--calcite-ui-foreground-2)}:host([appearance=solid][color=neutral]) button:active,:host([appearance=solid][color=neutral]) a:active{background-color:var(--calcite-ui-foreground-1)}:host([appearance=solid][color=neutral]) button calcite-loader,:host([appearance=solid][color=neutral]) a calcite-loader{color:var(--calcite-ui-text-1)}:host([appearance=solid][color=inverse]) button,:host([appearance=solid][color=inverse]) a{color:var(--calcite-ui-text-inverse);background-color:var(--calcite-ui-inverse)}:host([appearance=solid][color=inverse]) button:hover,:host([appearance=solid][color=inverse]) button:focus,:host([appearance=solid][color=inverse]) a:hover,:host([appearance=solid][color=inverse]) a:focus{background-color:var(--calcite-ui-inverse-hover)}:host([appearance=solid][color=inverse]) button:active,:host([appearance=solid][color=inverse]) a:active{background-color:var(--calcite-ui-inverse-press)}:host([appearance=solid][color=inverse]) button calcite-loader,:host([appearance=solid][color=inverse]) a calcite-loader{color:var(--calcite-ui-text-inverse)}:host([appearance=outline]) button,:host([appearance=outline]) a{border-width:1px;border-style:solid;background-color:var(--calcite-ui-foreground-1);-webkit-box-shadow:inset 0 0 0 1px transparent;box-shadow:inset 0 0 0 1px transparent}:host([appearance=outline][color=blue]) button,:host([appearance=outline][color=blue]) a{border-color:var(--calcite-ui-brand);color:var(--calcite-ui-brand)}:host([appearance=outline][color=blue]) button:hover,:host([appearance=outline][color=blue]) a:hover{border-color:var(--calcite-ui-brand-hover);color:var(--calcite-ui-brand-hover);-webkit-box-shadow:inset 0 0 0 1px var(--calcite-ui-brand-hover);box-shadow:inset 0 0 0 1px var(--calcite-ui-brand-hover)}:host([appearance=outline][color=blue]) button:focus,:host([appearance=outline][color=blue]) a:focus{border-color:var(--calcite-ui-brand);color:var(--calcite-ui-brand);-webkit-box-shadow:inset 0 0 0 2px var(--calcite-ui-brand);box-shadow:inset 0 0 0 2px var(--calcite-ui-brand)}:host([appearance=outline][color=blue]) button:active,:host([appearance=outline][color=blue]) a:active{border-color:var(--calcite-ui-brand-press);color:var(--calcite-ui-brand-press);-webkit-box-shadow:inset 0 0 0 2px var(--calcite-ui-brand-press);box-shadow:inset 0 0 0 2px var(--calcite-ui-brand-press)}:host([appearance=outline][color=blue]) button calcite-loader,:host([appearance=outline][color=blue]) a calcite-loader{color:var(--calcite-ui-brand)}:host([appearance=outline][color=red]) button,:host([appearance=outline][color=red]) a{border-color:var(--calcite-ui-danger);color:var(--calcite-ui-danger)}:host([appearance=outline][color=red]) button:hover,:host([appearance=outline][color=red]) a:hover{border-color:var(--calcite-ui-danger-hover);color:var(--calcite-ui-danger-hover);-webkit-box-shadow:inset 0 0 0 1px var(--calcite-ui-danger-hover);box-shadow:inset 0 0 0 1px var(--calcite-ui-danger-hover)}:host([appearance=outline][color=red]) button:focus,:host([appearance=outline][color=red]) a:focus{border-color:var(--calcite-ui-danger);color:var(--calcite-ui-danger);-webkit-box-shadow:inset 0 0 0 2px var(--calcite-ui-danger);box-shadow:inset 0 0 0 2px var(--calcite-ui-danger)}:host([appearance=outline][color=red]) button:active,:host([appearance=outline][color=red]) a:active{border-color:var(--calcite-ui-danger-press);color:var(--calcite-ui-danger-press);-webkit-box-shadow:inset 0 0 0 2px var(--calcite-ui-danger-press);box-shadow:inset 0 0 0 2px var(--calcite-ui-danger-press)}:host([appearance=outline][color=red]) button calcite-loader,:host([appearance=outline][color=red]) a calcite-loader{color:var(--calcite-ui-danger)}:host([appearance=outline][color=neutral]) button,:host([appearance=outline][color=neutral]) a{color:var(--calcite-ui-text-1);border-color:var(--calcite-ui-foreground-3)}:host([appearance=outline][color=neutral]) button:hover,:host([appearance=outline][color=neutral]) a:hover{-webkit-box-shadow:inset 0 0 0 1px var(--calcite-ui-foreground-3);box-shadow:inset 0 0 0 1px var(--calcite-ui-foreground-3)}:host([appearance=outline][color=neutral]) button:focus,:host([appearance=outline][color=neutral]) a:focus{-webkit-box-shadow:inset 0 0 0 2px var(--calcite-ui-foreground-3);box-shadow:inset 0 0 0 2px var(--calcite-ui-foreground-3)}:host([appearance=outline][color=neutral]) button:active,:host([appearance=outline][color=neutral]) a:active{-webkit-box-shadow:inset 0 0 0 2px var(--calcite-ui-foreground-3);box-shadow:inset 0 0 0 2px var(--calcite-ui-foreground-3)}:host([appearance=outline][color=neutral]) button calcite-loader,:host([appearance=outline][color=neutral]) a calcite-loader{color:var(--calcite-ui-text-1)}:host([appearance=outline][color=inverse]) button,:host([appearance=outline][color=inverse]) a{color:var(--calcite-ui-text-1);border-color:var(--calcite-ui-inverse)}:host([appearance=outline][color=inverse]) button:hover,:host([appearance=outline][color=inverse]) a:hover{border-color:var(--calcite-ui-inverse-hover);-webkit-box-shadow:inset 0 0 0 1px var(--calcite-ui-inverse-hover);box-shadow:inset 0 0 0 1px var(--calcite-ui-inverse-hover)}:host([appearance=outline][color=inverse]) button:focus,:host([appearance=outline][color=inverse]) a:focus{border-color:var(--calcite-ui-inverse);-webkit-box-shadow:inset 0 0 0 2px var(--calcite-ui-inverse);box-shadow:inset 0 0 0 2px var(--calcite-ui-inverse)}:host([appearance=outline][color=inverse]) button:active,:host([appearance=outline][color=inverse]) a:active{border-color:var(--calcite-ui-inverse-press);-webkit-box-shadow:inset 0 0 0 2px var(--calcite-ui-inverse-press);box-shadow:inset 0 0 0 2px var(--calcite-ui-inverse-press)}:host([appearance=outline][color=inverse]) button calcite-loader,:host([appearance=outline][color=inverse]) a calcite-loader{color:var(--calcite-ui-text-1)}:host([appearance=clear]) button,:host([appearance=clear]) a{border-width:1px;border-style:solid;background-color:transparent;-webkit-box-shadow:inset 0 0 0 1px transparent;box-shadow:inset 0 0 0 1px transparent}:host([appearance=clear][color=blue]) button,:host([appearance=clear][color=blue]) a{border-color:var(--calcite-ui-brand);color:var(--calcite-ui-brand)}:host([appearance=clear][color=blue]) button:hover,:host([appearance=clear][color=blue]) a:hover{border-color:var(--calcite-ui-brand-hover);color:var(--calcite-ui-brand-hover);-webkit-box-shadow:inset 0 0 0 1px var(--calcite-ui-brand-hover);box-shadow:inset 0 0 0 1px var(--calcite-ui-brand-hover)}:host([appearance=clear][color=blue]) button:focus,:host([appearance=clear][color=blue]) a:focus{border-color:var(--calcite-ui-brand);color:var(--calcite-ui-brand);-webkit-box-shadow:inset 0 0 0 2px var(--calcite-ui-brand);box-shadow:inset 0 0 0 2px var(--calcite-ui-brand)}:host([appearance=clear][color=blue]) button:active,:host([appearance=clear][color=blue]) a:active{border-color:var(--calcite-ui-brand-press);color:var(--calcite-ui-brand-press);-webkit-box-shadow:inset 0 0 0 2px var(--calcite-ui-brand-press);box-shadow:inset 0 0 0 2px var(--calcite-ui-brand-press)}:host([appearance=clear][color=blue]) button calcite-loader,:host([appearance=clear][color=blue]) a calcite-loader{color:var(--calcite-ui-brand)}:host([appearance=clear][color=red]) button,:host([appearance=clear][color=red]) a{border-color:var(--calcite-ui-danger);color:var(--calcite-ui-danger)}:host([appearance=clear][color=red]) button:hover,:host([appearance=clear][color=red]) a:hover{border-color:var(--calcite-ui-danger-hover);color:var(--calcite-ui-danger-hover);-webkit-box-shadow:inset 0 0 0 1px var(--calcite-ui-danger-hover);box-shadow:inset 0 0 0 1px var(--calcite-ui-danger-hover)}:host([appearance=clear][color=red]) button:focus,:host([appearance=clear][color=red]) a:focus{border-color:var(--calcite-ui-danger);color:var(--calcite-ui-danger);-webkit-box-shadow:inset 0 0 0 2px var(--calcite-ui-danger);box-shadow:inset 0 0 0 2px var(--calcite-ui-danger)}:host([appearance=clear][color=red]) button:active,:host([appearance=clear][color=red]) a:active{border-color:var(--calcite-ui-danger-press);color:var(--calcite-ui-danger-press);-webkit-box-shadow:inset 0 0 0 2px var(--calcite-ui-danger-press);box-shadow:inset 0 0 0 2px var(--calcite-ui-danger-press)}:host([appearance=clear][color=red]) button calcite-loader,:host([appearance=clear][color=red]) a calcite-loader{color:var(--calcite-ui-danger)}:host([appearance=clear][color=neutral]) button,:host([appearance=clear][color=neutral]) a{color:var(--calcite-ui-text-1);border-color:var(--calcite-ui-foreground-3)}:host([appearance=clear][color=neutral]) button:hover,:host([appearance=clear][color=neutral]) a:hover{-webkit-box-shadow:inset 0 0 0 1px var(--calcite-ui-foreground-3);box-shadow:inset 0 0 0 1px var(--calcite-ui-foreground-3)}:host([appearance=clear][color=neutral]) button:focus,:host([appearance=clear][color=neutral]) a:focus{-webkit-box-shadow:inset 0 0 0 2px var(--calcite-ui-foreground-3);box-shadow:inset 0 0 0 2px var(--calcite-ui-foreground-3)}:host([appearance=clear][color=neutral]) button:active,:host([appearance=clear][color=neutral]) a:active{-webkit-box-shadow:inset 0 0 0 2px var(--calcite-ui-foreground-3);box-shadow:inset 0 0 0 2px var(--calcite-ui-foreground-3)}:host([appearance=clear][color=neutral]) button calcite-loader,:host([appearance=clear][color=neutral]) a calcite-loader{color:var(--calcite-ui-text-1)}:host([appearance=clear][color=inverse]) button,:host([appearance=clear][color=inverse]) a{color:var(--calcite-ui-text-1);border-color:var(--calcite-ui-inverse)}:host([appearance=clear][color=inverse]) button:hover,:host([appearance=clear][color=inverse]) a:hover{border-color:var(--calcite-ui-inverse-hover);-webkit-box-shadow:inset 0 0 0 1px var(--calcite-ui-inverse-hover);box-shadow:inset 0 0 0 1px var(--calcite-ui-inverse-hover)}:host([appearance=clear][color=inverse]) button:focus,:host([appearance=clear][color=inverse]) a:focus{border-color:var(--calcite-ui-inverse);-webkit-box-shadow:inset 0 0 0 2px var(--calcite-ui-inverse);box-shadow:inset 0 0 0 2px var(--calcite-ui-inverse)}:host([appearance=clear][color=inverse]) button:active,:host([appearance=clear][color=inverse]) a:active{border-color:var(--calcite-ui-inverse-press);-webkit-box-shadow:inset 0 0 0 2px var(--calcite-ui-inverse-press);box-shadow:inset 0 0 0 2px var(--calcite-ui-inverse-press)}:host([appearance=clear][color=inverse]) button calcite-loader,:host([appearance=clear][color=inverse]) a calcite-loader{color:var(--calcite-ui-text-1)}:host([appearance=outline][split-child=primary]) button,:host([appearance=clear][split-child=primary]) button{border-inline-end-width:0;border-inline-start-width:1px}:host([appearance=outline][split-child=secondary]) button,:host([appearance=clear][split-child=secondary]) button{border-inline-start-width:0;border-inline-end-width:1px}:host([appearance=transparent]:not(.enable-editing-button)) button,:host([appearance=transparent]:not(.enable-editing-button)) a{background-color:transparent}:host([appearance=transparent]:not(.enable-editing-button)) button:hover,:host([appearance=transparent]:not(.enable-editing-button)) button:focus,:host([appearance=transparent]:not(.enable-editing-button)) a:hover,:host([appearance=transparent]:not(.enable-editing-button)) a:focus{background-color:var(--calcite-button-transparent-hover)}:host([appearance=transparent]:not(.enable-editing-button)) button:active,:host([appearance=transparent]:not(.enable-editing-button)) a:active{background-color:var(--calcite-button-transparent-press)}:host([appearance=transparent][color=blue]) button,:host([appearance=transparent][color=blue]) a{color:var(--calcite-ui-brand)}:host([appearance=transparent][color=blue]) button:hover,:host([appearance=transparent][color=blue]) a:hover{color:var(--calcite-ui-brand-hover)}:host([appearance=transparent][color=blue]) button:focus,:host([appearance=transparent][color=blue]) a:focus{color:var(--calcite-ui-brand)}:host([appearance=transparent][color=blue]) button:active,:host([appearance=transparent][color=blue]) a:active{color:var(--calcite-ui-brand-press)}:host([appearance=transparent][color=blue]) button calcite-loader,:host([appearance=transparent][color=blue]) a calcite-loader{color:var(--calcite-ui-brand)}:host([appearance=transparent][color=red]) button,:host([appearance=transparent][color=red]) a{color:var(--calcite-ui-danger)}:host([appearance=transparent][color=red]) button:hover,:host([appearance=transparent][color=red]) a:hover{color:var(--calcite-ui-danger-hover)}:host([appearance=transparent][color=red]) button:focus,:host([appearance=transparent][color=red]) a:focus{color:var(--calcite-ui-danger)}:host([appearance=transparent][color=red]) button:active,:host([appearance=transparent][color=red]) a:active{color:var(--calcite-ui-danger-press)}:host([appearance=transparent][color=red]) button calcite-loader,:host([appearance=transparent][color=red]) a calcite-loader{color:var(--calcite-ui-danger)}:host([appearance=transparent][color=neutral]:not(.cancel-editing-button)) button,:host([appearance=transparent][color=neutral]:not(.cancel-editing-button)) a,:host([appearance=transparent][color=neutral]:not(.cancel-editing-button)) calcite-loader{color:var(--calcite-ui-text-1)}:host([appearance=transparent][color=neutral].cancel-editing-button) button{border-top-width:1px;border-bottom-width:1px;color:var(--calcite-ui-text-3);border-top-color:var(--calcite-ui-border-input);border-bottom-color:var(--calcite-ui-border-input);border-bottom-style:solid;border-top-style:solid}:host([appearance=transparent][color=neutral].cancel-editing-button) button:not(.content--slotted){--calcite-button-padding-y:0}:host([appearance=transparent][color=neutral].cancel-editing-button) button:hover{color:var(--calcite-ui-text-1)}:host([appearance=transparent][color=neutral].enable-editing-button) button{background-color:transparent}:host(.confirm-changes-button) button:focus,:host(.cancel-editing-button) button:focus,:host(.enable-editing-button) button:focus{outline-offset:-2px}:host([appearance=transparent][color=inverse]) button,:host([appearance=transparent][color=inverse]) a,:host([appearance=transparent][color=inverse]) calcite-loader{color:var(--calcite-ui-text-inverse)}:host([scale=s]) button.content--slotted,:host([scale=s]) a.content--slotted{font-size:var(--calcite-font-size--2);line-height:1rem}:host([scale=s][appearance=transparent]) button.content--slotted,:host([scale=s][appearance=transparent]) a.content--slotted{--calcite-button-padding-x:0.5rem;--calcite-button-padding-y:0.25rem}:host([scale=m]) button.content--slotted,:host([scale=m]) a.content--slotted{--calcite-button-padding-x:11px;font-size:var(--calcite-font-size--1);line-height:1rem}:host([scale=m]:not([appearance=transparent])) button.content--slotted,:host([scale=m]:not([appearance=transparent])) a.content--slotted{--calcite-button-padding-y:7px}:host([scale=m][appearance=transparent]) button.content--slotted,:host([scale=m][appearance=transparent]) a.content--slotted{--calcite-button-padding-x:0.75rem;--calcite-button-padding-y:0.5rem}:host([scale=l]) button.content--slotted,:host([scale=l]) a.content--slotted{--calcite-button-padding-x:15px;font-size:var(--calcite-font-size-0);line-height:1.25rem}:host([scale=l]:not([appearance=transparent])) button.content--slotted,:host([scale=l]:not([appearance=transparent])) a.content--slotted{--calcite-button-padding-y:11px}:host([scale=l][appearance=transparent]) button.content--slotted,:host([scale=l][appearance=transparent]) a.content--slotted{--calcite-button-padding-x:1rem;--calcite-button-padding-y:0.75rem}:host([scale=s]) button:not(.content--slotted),:host([scale=s]) a:not(.content--slotted){--calcite-button-padding-x:0.125rem;--calcite-button-padding-y:3px;width:1.5rem;font-size:var(--calcite-font-size-0);line-height:1.25rem;min-height:1.5rem}:host([scale=s][appearance=transparent]) button:not(.content--slotted),:host([scale=s][appearance=transparent]) a:not(.content--slotted){--calcite-button-padding-y:0.25rem}:host([scale=m]) button:not(.content--slotted),:host([scale=m]) a:not(.content--slotted){--calcite-button-padding-x:0.125rem;--calcite-button-padding-y:7px;width:2rem;font-size:var(--calcite-font-size-0);line-height:1.25rem;min-height:2rem}:host([scale=m][appearance=transparent]) button:not(.content--slotted),:host([scale=m][appearance=transparent]) a:not(.content--slotted){--calcite-button-padding-y:0.5rem}:host([scale=l]) button:not(.content--slotted),:host([scale=l]) a:not(.content--slotted){--calcite-button-padding-x:0.125rem;--calcite-button-padding-y:9px;width:2.75rem;font-size:var(--calcite-font-size-0);line-height:1.25rem;min-height:2.75rem}:host([scale=l][appearance=transparent]) button:not(.content--slotted),:host([scale=l][appearance=transparent]) a:not(.content--slotted){--calcite-button-padding-y:0.625rem}:host([scale=s][icon-start][icon-end]) button:not(.content--slotted),:host([scale=s][icon-start][icon-end]) a:not(.content--slotted){--calcite-button-padding-x:23px;height:1.5rem;font-size:var(--calcite-font-size-0);line-height:1.25rem}:host([scale=s][icon-start][icon-end][appearance=transparent]) button:not(.content--slotted),:host([scale=s][icon-start][icon-end][appearance=transparent]) a:not(.content--slotted){--calcite-button-padding-x:1.5rem}:host([scale=m][icon-start][icon-end]) button:not(.content--slotted),:host([scale=m][icon-start][icon-end]) a:not(.content--slotted){--calcite-button-padding-x:2rem;height:2rem;font-size:var(--calcite-font-size-0);line-height:1.25rem}:host([scale=m][icon-start][icon-end][appearance=transparent]) button:not(.content--slotted),:host([scale=m][icon-start][icon-end][appearance=transparent]) a:not(.content--slotted){--calcite-button-padding-x:33px}:host([scale=l][icon-start][icon-end]) button:not(.content--slotted),:host([scale=l][icon-start][icon-end]) a:not(.content--slotted){--calcite-button-padding-x:43px;height:2.75rem;font-size:var(--calcite-font-size-0);line-height:1.25rem}:host([scale=l][icon-start][icon-end]) button:not(.content--slotted) .icon--start+.icon--end,:host([scale=l][icon-start][icon-end]) a:not(.content--slotted) .icon--start+.icon--end{-webkit-margin-start:1rem;margin-inline-start:1rem}:host([scale=l][icon-start][icon-end][appearance=transparent]) button:not(.content--slotted),:host([scale=l][icon-start][icon-end][appearance=transparent]) a:not(.content--slotted){--calcite-button-padding-x:2.75rem}";
- const Button = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** optionally specify alignment of button elements. */
- this.alignment = "center";
- /** specify the appearance style of the button, defaults to solid. */
- this.appearance = "solid";
- /** specify the color of the button, defaults to blue */
- this.color = "blue";
- /** is the button disabled */
- this.disabled = false;
- /** string to override English loading text
- * @default "Loading"
- */
- this.intlLoading = TEXT$k.loading;
- /** optionally add a calcite-loader component to the button, disabling interaction. */
- this.loading = false;
- /** optionally add a round style to the button */
- this.round = false;
- /** specify the scale of the button, defaults to m */
- this.scale = "m";
- /** is the button a child of a calcite-split-button */
- this.splitChild = false;
- /** The type attribute to apply to the button */
- this.type = "button";
- /** specify the width of the button, defaults to auto */
- this.width = "auto";
- /** watches for changing text content **/
- this.mutationObserver = createObserver("mutation", () => this.updateHasContent());
- /** determine if there is slotted content for styling purposes */
- this.hasContent = false;
- /** determine if loader present for styling purposes */
- this.hasLoader = false;
- // act on a requested or nearby form based on type
- this.handleClick = () => {
- const { type } = this;
- if (this.href) {
- return;
- }
- // this.type refers to type attribute, not child element type
- if (type === "submit") {
- submitForm(this);
- }
- else if (type === "reset") {
- resetForm(this);
- }
- };
- }
- loadingChanged(newValue, oldValue) {
- if (!!newValue && !oldValue) {
- this.hasLoader = true;
- }
- if (!newValue && !!oldValue) {
- window.setTimeout(() => {
- this.hasLoader = false;
- }, 300);
- }
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- this.hasLoader = this.loading;
- this.setupTextContentObserver();
- connectLabel(this);
- this.formEl = closestElementCrossShadowBoundary(this.el, this.form ? `#${this.form}` : "form");
- }
- disconnectedCallback() {
- var _a;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- disconnectLabel(this);
- this.formEl = null;
- }
- componentWillLoad() {
- if (Build.isBrowser) {
- this.updateHasContent();
- }
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- render() {
- const childElType = this.href ? "a" : "button";
- const Tag = childElType;
- const loaderNode = this.hasLoader ? (h("div", { class: CSS$J.buttonLoader }, h("calcite-loader", { active: true, class: this.loading ? CSS$J.loadingIn : CSS$J.loadingOut, inline: true, label: this.intlLoading, scale: "m" }))) : null;
- const iconStartEl = (h("calcite-icon", { class: { [CSS$J.icon]: true, [CSS$J.iconStart]: true }, flipRtl: this.iconFlipRtl === "start" || this.iconFlipRtl === "both", icon: this.iconStart, scale: "s" }));
- const iconEndEl = (h("calcite-icon", { class: { [CSS$J.icon]: true, [CSS$J.iconEnd]: true }, flipRtl: this.iconFlipRtl === "end" || this.iconFlipRtl === "both", icon: this.iconEnd, scale: "s" }));
- const contentEl = (h("span", { class: CSS$J.content }, h("slot", null)));
- return (h(Tag, { "aria-label": getLabelText(this), class: {
- [CSS$J.contentSlotted]: this.hasContent,
- [CSS$J.iconStartEmpty]: !this.iconStart,
- [CSS$J.iconEndEmpty]: !this.iconEnd
- }, disabled: this.disabled || this.loading, href: childElType === "a" && this.href, name: childElType === "button" && this.name, onClick: this.handleClick, ref: (el) => (this.childEl = el), rel: childElType === "a" && this.rel, tabIndex: this.disabled || this.loading ? -1 : null, target: childElType === "a" && this.target, type: childElType === "button" && this.type }, loaderNode, this.iconStart ? iconStartEl : null, this.hasContent ? contentEl : null, this.iconEnd ? iconEndEl : null));
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- this.childEl.focus();
- }
- updateHasContent() {
- var _a, _b;
- const slottedContent = this.el.textContent.trim().length > 0 || this.el.childNodes.length > 0;
- this.hasContent =
- this.el.childNodes.length === 1 && ((_a = this.el.childNodes[0]) === null || _a === void 0 ? void 0 : _a.nodeName) === "#text"
- ? ((_b = this.el.textContent) === null || _b === void 0 ? void 0 : _b.trim().length) > 0
- : slottedContent;
- }
- setupTextContentObserver() {
- var _a;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- onLabelClick() {
- this.handleClick();
- this.setFocus();
- }
- get el() { return this; }
- static get watchers() { return {
- "loading": ["loadingChanged"]
- }; }
- static get style() { return buttonCss; }
- };
- const CSS$I = {
- container: "container",
- header: "header",
- footer: "footer",
- title: "title",
- subtitle: "subtitle",
- thumbnailWrapper: "thumbnail-wrapper",
- checkboxWrapper: "checkbox-wrapper"
- };
- const SLOTS$j = {
- thumbnail: "thumbnail",
- title: "title",
- subtitle: "subtitle",
- footerLeading: "footer-leading",
- footerTrailing: "footer-trailing"
- };
- const TEXT$j = {
- select: "Select",
- deselect: "Deselect",
- loading: "Loading"
- };
- const cardCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:block;max-width:100%}:host .calcite-card-container{position:relative;display:-ms-flexbox;display:flex;height:100%;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:justify;justify-content:space-between;border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-2);background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-3);--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);border-radius:var(--calcite-border-radius-base)}:host .calcite-card-container:hover{--tw-shadow:0 4px 16px 0 rgba(0, 0, 0, 0.08), 0 2px 8px 0 rgba(0, 0, 0, 0.04);--tw-shadow-colored:0 4px 16px 0 var(--tw-shadow-color), 0 2px 8px 0 var(--tw-shadow-color);-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);z-index:1}:host .calcite-card-container:active{--tw-shadow:0 1px 6px -1px rgba(0, 0, 0, 0.16), 0 1px 2px -1px rgba(0, 0, 0, 0.08);--tw-shadow-colored:0 1px 6px -1px var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);-webkit-transition-duration:75ms;transition-duration:75ms;z-index:1}.container{display:-ms-flexbox;display:flex;-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-direction:column;flex-direction:column}:host([loading]) .calcite-card-container *:not(calcite-loader):not(.calcite-card-loader-container){pointer-events:none;opacity:0}:host([loading]) .calcite-card-loader-container{position:absolute;top:0px;right:0px;bottom:0px;left:0px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.header,.footer{display:-ms-flexbox;display:flex;padding-left:0.75rem;padding-right:0.75rem;padding-top:0.75rem;padding-bottom:0.25rem}.header{-ms-flex-direction:column;flex-direction:column}.footer{margin-top:auto;-ms-flex-direction:row;flex-direction:row;-ms-flex-line-pack:justify;align-content:space-between;-ms-flex-pack:justify;justify-content:space-between;padding-left:0.75rem;padding-right:0.75rem;padding-top:0.25rem;padding-bottom:0.75rem}.card-content{padding:0.75rem;font-size:var(--calcite-font-size--2);line-height:1.375;color:var(--calcite-ui-text-3)}:host([selectable]) .calcite-card-container:active{--tw-shadow:0 1px 6px -1px rgba(0, 0, 0, 0.16), 0 1px 2px -1px rgba(0, 0, 0, 0.08);--tw-shadow-colored:0 1px 6px -1px var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}:host([selected]) .calcite-card-container{border-color:var(--calcite-ui-brand)}slot[name=title]::slotted(*),*::slotted([slot=title]){margin:0px;font-size:var(--calcite-font-size--1);line-height:1.375;font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1)}slot[name=subtitle]::slotted(*),*::slotted([slot=subtitle]){margin:0px;margin-top:0.5rem;font-size:var(--calcite-font-size--2);line-height:1.375;font-weight:var(--calcite-font-weight-normal);color:var(--calcite-ui-text-2)}slot[name=thumbnail]::slotted(img),img::slotted([slot=thumbnail]){min-width:100%;max-width:100%}slot[name=footer-leading]::slotted(*),*::slotted([slot=footer-leading]){-ms-flex-item-align:center;align-self:center;font-size:var(--calcite-font-size--2);line-height:1.375;-webkit-margin-end:auto;margin-inline-end:auto}slot[name=footer-trailing]::slotted(*),*::slotted([slot=footer-trailing]){-ms-flex-item-align:center;align-self:center;font-size:var(--calcite-font-size--2);line-height:1.375}.thumbnail-wrapper{font-size:var(--calcite-font-size-0);line-height:1.375}.checkbox-wrapper{position:absolute;margin:0px;padding:0px;top:0.5rem;inset-inline-end:0.5rem}";
- const Card = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteCardSelect = createEvent(this, "calciteCardSelect", 7);
- //--------------------------------------------------------------------------
- //
- // Public Properties
- //
- //--------------------------------------------------------------------------
- /** When true, the cards content is waiting to be loaded. This state shows a busy indicator.*/
- this.loading = false;
- /** Indicates whether the card is selected. */
- this.selected = false;
- /** Indicates whether the card is selectable. */
- this.selectable = false;
- /** string to override English loading text
- * @default "Loading"
- */
- this.intlLoading = TEXT$j.loading;
- /** string to override English select text for checkbox when selectable is true
- * @default "Select"
- */
- this.intlSelect = TEXT$j.select;
- /** string to override English deselect text for checkbox when selectable is true
- * @default "Deselect"
- */
- this.intlDeselect = TEXT$j.deselect;
- //--------------------------------------------------------------------------
- //
- // Private State/Props
- //
- //--------------------------------------------------------------------------
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- this.cardSelectClick = () => {
- this.selectCard();
- };
- this.cardSelectKeyDown = (e) => {
- switch (e.key) {
- case " ":
- case "Enter":
- this.selectCard();
- e.preventDefault();
- break;
- }
- };
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- connectConditionalSlotComponent(this);
- }
- disonnectedCallback() {
- disconnectConditionalSlotComponent(this);
- }
- render() {
- return (h("div", { class: "calcite-card-container" }, this.loading ? (h("div", { class: "calcite-card-loader-container" }, h("calcite-loader", { active: true, label: this.intlLoading }))) : null, h("section", { "aria-busy": toAriaBoolean(this.loading), class: { [CSS$I.container]: true } }, this.selectable ? this.renderCheckbox() : null, this.renderThumbnail(), this.renderHeader(), h("div", { class: "card-content" }, h("slot", null)), this.renderFooter())));
- }
- selectCard() {
- this.selected = !this.selected;
- this.calciteCardSelect.emit();
- }
- renderThumbnail() {
- return getSlotted(this.el, SLOTS$j.thumbnail) ? (h("div", { class: CSS$I.thumbnailWrapper, key: "thumbnail-wrapper" }, h("slot", { name: SLOTS$j.thumbnail }))) : null;
- }
- renderCheckbox() {
- const checkboxLabel = this.selected ? this.intlDeselect : this.intlSelect;
- return (h("calcite-label", { class: CSS$I.checkboxWrapper, onClick: this.cardSelectClick, onKeyDown: this.cardSelectKeyDown }, h("calcite-checkbox", { checked: this.selected, label: checkboxLabel })));
- }
- renderHeader() {
- const { el } = this;
- const title = getSlotted(el, SLOTS$j.title);
- const subtitle = getSlotted(el, SLOTS$j.subtitle);
- const hasHeader = title || subtitle;
- return hasHeader ? (h("header", { class: CSS$I.header }, h("slot", { name: SLOTS$j.title }), h("slot", { name: SLOTS$j.subtitle }))) : null;
- }
- renderFooter() {
- const { el } = this;
- const leadingFooter = getSlotted(el, SLOTS$j.footerLeading);
- const trailingFooter = getSlotted(el, SLOTS$j.footerTrailing);
- const hasFooter = leadingFooter || trailingFooter;
- return hasFooter ? (h("footer", { class: CSS$I.footer }, h("slot", { name: SLOTS$j.footerLeading }), h("slot", { name: SLOTS$j.footerTrailing }))) : null;
- }
- get el() { return this; }
- static get style() { return cardCss; }
- };
- const checkboxCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([scale=s]){--calcite-checkbox-size:0.75rem}:host([scale=m]){--calcite-checkbox-size:var(--calcite-font-size--1)}:host([scale=l]){--calcite-checkbox-size:1rem}:host{position:relative;display:-ms-inline-flexbox;display:inline-flex;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}:host .check-svg{pointer-events:none;-webkit-box-sizing:border-box;box-sizing:border-box;display:block;overflow:hidden;background-color:var(--calcite-ui-foreground-1);fill:currentColor;stroke:currentColor;stroke-width:1;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);width:var(--calcite-checkbox-size);height:var(--calcite-checkbox-size);-webkit-box-shadow:inset 0 0 0 1px var(--calcite-ui-border-input);box-shadow:inset 0 0 0 1px var(--calcite-ui-border-input);color:var(--calcite-ui-background)}:host([checked]) .check-svg,:host([indeterminate]) .check-svg{background-color:var(--calcite-ui-brand);-webkit-box-shadow:inset 0 0 0 1px var(--calcite-ui-brand);box-shadow:inset 0 0 0 1px var(--calcite-ui-brand)}:host([hovered]) .toggle .check-svg,:host .toggle:hover .check-svg{-webkit-box-shadow:inset 0 0 0 2px var(--calcite-ui-brand);box-shadow:inset 0 0 0 2px var(--calcite-ui-brand)}:host .toggle:focus .check-svg,:host .toggle:active .check-svg{-webkit-box-shadow:inset 0 0 0 1px var(--calcite-ui-brand), 0 0 0 2px var(--calcite-ui-foreground-1), 0 0 0 4px var(--calcite-ui-brand);box-shadow:inset 0 0 0 1px var(--calcite-ui-brand), 0 0 0 2px var(--calcite-ui-foreground-1), 0 0 0 4px var(--calcite-ui-brand);-webkit-transition:var(--calcite-animation-timing);transition:var(--calcite-animation-timing)}.toggle:focus-visible{outline:none}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}::slotted(input[slot=hidden-form-input]){bottom:0 !important;left:0 !important;margin:0 !important;opacity:0 !important;outline:none !important;padding:0 !important;position:absolute !important;right:0 !important;top:0 !important;-webkit-transform:none !important;transform:none !important;-webkit-appearance:none !important;z-index:-1 !important}";
- const Checkbox = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteInternalCheckboxBlur = createEvent(this, "calciteInternalCheckboxBlur", 7);
- this.calciteCheckboxChange = createEvent(this, "calciteCheckboxChange", 7);
- this.calciteInternalCheckboxFocus = createEvent(this, "calciteInternalCheckboxFocus", 7);
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** The checked state of the checkbox. */
- this.checked = false;
- /** True if the checkbox is disabled */
- this.disabled = false;
- /**
- * The hovered state of the checkbox.
- * @internal
- */
- this.hovered = false;
- /**
- * True if the checkbox is initially indeterminate,
- * which is independent from its checked state
- * https://css-tricks.com/indeterminate-checkboxes/
- * */
- this.indeterminate = false;
- /**
- * When true, makes the component required for form-submission.
- *
- * @internal
- */
- this.required = false;
- /** specify the scale of the checkbox, defaults to m */
- this.scale = "m";
- //--------------------------------------------------------------------------
- //
- // Private Properties
- //
- //--------------------------------------------------------------------------
- this.checkedPath = "M5.5 12L2 8.689l.637-.636L5.5 10.727l8.022-7.87.637.637z";
- this.indeterminatePath = "M13 8v1H3V8z";
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- this.getPath = () => this.indeterminate ? this.indeterminatePath : this.checked ? this.checkedPath : "";
- this.toggle = () => {
- if (!this.disabled) {
- this.checked = !this.checked;
- this.setFocus();
- this.indeterminate = false;
- this.calciteCheckboxChange.emit();
- }
- };
- this.keyDownHandler = (event) => {
- if (event.key === " " || event.key === "Enter") {
- this.toggle();
- event.preventDefault();
- }
- };
- this.clickHandler = () => {
- this.toggle();
- };
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- this.onToggleBlur = () => {
- this.calciteInternalCheckboxBlur.emit(false);
- };
- this.onToggleFocus = () => {
- this.calciteInternalCheckboxFocus.emit(true);
- };
- this.onLabelClick = () => {
- this.toggle();
- };
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- var _a;
- (_a = this.toggleEl) === null || _a === void 0 ? void 0 : _a.focus();
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- this.guid = this.el.id || `calcite-checkbox-${guid()}`;
- connectLabel(this);
- connectForm(this);
- }
- disconnectedCallback() {
- disconnectLabel(this);
- disconnectForm(this);
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- render() {
- return (h(Host, { onClick: this.clickHandler, onKeyDown: this.keyDownHandler }, h("div", { "aria-checked": toAriaBoolean(this.checked), "aria-label": getLabelText(this), class: "toggle", onBlur: this.onToggleBlur, onFocus: this.onToggleFocus, ref: (toggleEl) => (this.toggleEl = toggleEl), role: "checkbox", tabIndex: this.disabled ? undefined : 0 }, h("svg", { class: "check-svg", viewBox: "0 0 16 16" }, h("path", { d: this.getPath() })), h("slot", null)), h(HiddenFormInputSlot, { component: this })));
- }
- get el() { return this; }
- static get style() { return checkboxCss; }
- };
- const CSS$H = {
- title: "title",
- close: "close",
- imageContainer: "image-container",
- chipIcon: "chip-icon",
- closeIcon: "close-icon"
- };
- const TEXT$i = {
- close: "Close"
- };
- const SLOTS$i = {
- image: "image"
- };
- const ICONS$a = {
- close: "x"
- };
- const chipCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([scale=s]){height:1.5rem;font-size:var(--calcite-font-size--2);--calcite-chip-spacing-unit-l:0.5rem;--calcite-chip-spacing-unit-s:0.25rem}:host([scale=s]) .image-container{height:1.25rem;width:1.25rem}:host([scale=m]){height:2rem;font-size:var(--calcite-font-size--1);--calcite-chip-spacing-unit-l:0.75rem;--calcite-chip-spacing-unit-s:6px}:host([scale=m]) .image-container{height:1.5rem;width:1.5rem;-webkit-padding-start:0.25rem;padding-inline-start:0.25rem}:host([scale=l]){height:2.75rem;font-size:var(--calcite-font-size-0);--calcite-chip-spacing-unit-l:1rem;--calcite-chip-spacing-unit-s:0.5rem}:host([scale=l]) .image-container{height:2rem;width:2rem;padding-left:0.25rem}:host{-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-inline-flexbox;display:inline-flex;cursor:default;-ms-flex-align:center;align-items:center;border-radius:9999px;border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-1);font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1)}.container{display:-ms-inline-flexbox;display:inline-flex;height:100%;max-width:100%;-ms-flex-align:center;align-items:center}.title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host span{padding:0 var(--calcite-chip-spacing-unit-l)}:host([dismissible]) span{padding-inline:var(--calcite-chip-spacing-unit-l) var(--calcite-chip-spacing-unit-s)}:host([icon]:not([dismissible])) span{padding:0 var(--calcite-chip-spacing-unit-l)}:host button{margin:0px;display:-ms-inline-flexbox;display:inline-flex;max-height:100%;min-height:100%;cursor:pointer;-ms-flex-align:center;align-items:center;-ms-flex-item-align:stretch;align-self:stretch;border-style:none;background-color:transparent;color:var(--calcite-ui-text-1);outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s;-webkit-appearance:none;border-start-start-radius:0;border-start-end-radius:50px;border-end-end-radius:50px;border-end-start-radius:0;padding:0 var(--calcite-chip-spacing-unit-s);color:inherit;--calcite-chip-transparent-hover:var(--calcite-button-transparent-hover);--calcite-chip-transparent-press:var(--calcite-button-transparent-press)}:host button:hover{background-color:var(--calcite-chip-transparent-hover)}:host button:focus{background-color:var(--calcite-chip-transparent-hover);outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}:host button:active{background-color:var(--calcite-chip-transparent-press)}.image-container{display:-ms-inline-flexbox;display:inline-flex;overflow:hidden;border-radius:50%}:host slot[name=image]::slotted(*){display:-ms-flexbox;display:flex;height:100%;width:100%;overflow:hidden;border-radius:50%}.chip-icon{position:relative;margin-top:0px;margin-bottom:0px;display:-ms-inline-flexbox;display:inline-flex;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);-webkit-margin-end:0;margin-inline-end:0;-webkit-margin-start:var(--calcite-chip-spacing-unit-l);margin-inline-start:var(--calcite-chip-spacing-unit-l);border-start-start-radius:0;border-start-end-radius:50px;border-end-end-radius:50px;border-end-start-radius:0}:host([color=blue][appearance=solid]){border-color:transparent;background-color:var(--calcite-ui-info);color:var(--calcite-ui-text-inverse)}:host([color=red][appearance=solid]){border-color:transparent;background-color:var(--calcite-ui-danger);color:var(--calcite-ui-text-inverse)}:host([color=yellow][appearance=solid]){border-color:transparent;background-color:var(--calcite-ui-warning);color:#151515}:host([color=green][appearance=solid]){border-color:transparent;background-color:var(--calcite-ui-success);color:#151515}:host([color=grey][appearance=solid]){border-color:transparent;background-color:var(--calcite-ui-foreground-2);color:var(--calcite-ui-text-1)}:host([color=grey][appearance=solid]) button,:host([color=grey][appearance=solid]) .close-icon{color:var(--calcite-ui-text-3)}:host([color=grey][appearance=solid]) .chip-icon{color:var(--calcite-ui-icon-color, var(--calcite-ui-text-3))}:host([color=blue][appearance=clear]){border-color:var(--calcite-ui-info)}:host([color=blue][appearance=clear]) .chip-icon{color:var(--calcite-ui-icon-color, var(--calcite-ui-info))}:host([color=red][appearance=clear]){border-color:var(--calcite-ui-danger)}:host([color=red][appearance=clear]) .chip-icon{color:var(--calcite-ui-icon-color, var(--calcite-ui-danger))}:host([color=yellow][appearance=clear]){border-color:var(--calcite-ui-warning)}:host([color=yellow][appearance=clear]) .chip-icon{color:var(--calcite-ui-icon-color, var(--calcite-ui-warning))}:host([color=green][appearance=clear]){border-color:var(--calcite-ui-success)}:host([color=green][appearance=clear]) .chip-icon{color:var(--calcite-ui-icon-color, var(--calcite-ui-success))}:host([color=grey][appearance=clear]){border-color:var(--calcite-ui-border-1)}:host([color=grey][appearance=clear]) .chip-icon{color:var(--calcite-ui-icon-color, var(--calcite-ui-text-3))}";
- const Chip = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteChipDismiss = createEvent(this, "calciteChipDismiss", 7);
- //--------------------------------------------------------------------------
- //
- // Public Properties
- //
- //--------------------------------------------------------------------------
- /** specify the appearance style of the button, defaults to solid. */
- this.appearance = "solid";
- /** specify the color of the button, defaults to blue */
- this.color = "grey";
- /** Optionally show a button the user can click to dismiss the chip */
- this.dismissible = false;
- /** Aria label for the "x" button
- * @default "Close"
- */
- this.dismissLabel = TEXT$i.close;
- /** flip the icon in rtl */
- this.iconFlipRtl = false;
- /** specify the scale of the chip, defaults to m */
- this.scale = "m";
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- this.closeClickHandler = (event) => {
- event.preventDefault();
- this.calciteChipDismiss.emit(this.el);
- };
- this.guid = guid();
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- connectConditionalSlotComponent(this);
- }
- disconnectedCallback() {
- disconnectConditionalSlotComponent(this);
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- var _a;
- (_a = this.closeButton) === null || _a === void 0 ? void 0 : _a.focus();
- }
- //--------------------------------------------------------------------------
- //
- // Render Methods
- //
- //--------------------------------------------------------------------------
- renderChipImage() {
- const { el } = this;
- const hasChipImage = getSlotted(el, SLOTS$i.image);
- return hasChipImage ? (h("div", { class: CSS$H.imageContainer, key: "image" }, h("slot", { name: SLOTS$i.image }))) : null;
- }
- render() {
- const iconEl = (h("calcite-icon", { class: CSS$H.chipIcon, flipRtl: this.iconFlipRtl, icon: this.icon, scale: "s" }));
- const closeButton = (h("button", { "aria-describedby": this.guid, "aria-label": this.dismissLabel, class: CSS$H.close, onClick: this.closeClickHandler, ref: (el) => (this.closeButton = el) }, h("calcite-icon", { class: CSS$H.closeIcon, icon: ICONS$a.close, scale: "s" })));
- return (h("div", { class: "container" }, this.renderChipImage(), this.icon ? iconEl : null, h("span", { class: CSS$H.title, id: this.guid }, h("slot", null)), this.dismissible ? closeButton : null));
- }
- get el() { return this; }
- static get style() { return chipCss; }
- };
- function createCommonjsModule(fn, basedir, module) {
- return module = {
- path: basedir,
- exports: {},
- require: function (path, base) {
- return commonjsRequire();
- }
- }, fn(module, module.exports), module.exports;
- }
- function commonjsRequire () {
- throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
- }
- var colorName$1 = {
- "aliceblue": [240, 248, 255],
- "antiquewhite": [250, 235, 215],
- "aqua": [0, 255, 255],
- "aquamarine": [127, 255, 212],
- "azure": [240, 255, 255],
- "beige": [245, 245, 220],
- "bisque": [255, 228, 196],
- "black": [0, 0, 0],
- "blanchedalmond": [255, 235, 205],
- "blue": [0, 0, 255],
- "blueviolet": [138, 43, 226],
- "brown": [165, 42, 42],
- "burlywood": [222, 184, 135],
- "cadetblue": [95, 158, 160],
- "chartreuse": [127, 255, 0],
- "chocolate": [210, 105, 30],
- "coral": [255, 127, 80],
- "cornflowerblue": [100, 149, 237],
- "cornsilk": [255, 248, 220],
- "crimson": [220, 20, 60],
- "cyan": [0, 255, 255],
- "darkblue": [0, 0, 139],
- "darkcyan": [0, 139, 139],
- "darkgoldenrod": [184, 134, 11],
- "darkgray": [169, 169, 169],
- "darkgreen": [0, 100, 0],
- "darkgrey": [169, 169, 169],
- "darkkhaki": [189, 183, 107],
- "darkmagenta": [139, 0, 139],
- "darkolivegreen": [85, 107, 47],
- "darkorange": [255, 140, 0],
- "darkorchid": [153, 50, 204],
- "darkred": [139, 0, 0],
- "darksalmon": [233, 150, 122],
- "darkseagreen": [143, 188, 143],
- "darkslateblue": [72, 61, 139],
- "darkslategray": [47, 79, 79],
- "darkslategrey": [47, 79, 79],
- "darkturquoise": [0, 206, 209],
- "darkviolet": [148, 0, 211],
- "deeppink": [255, 20, 147],
- "deepskyblue": [0, 191, 255],
- "dimgray": [105, 105, 105],
- "dimgrey": [105, 105, 105],
- "dodgerblue": [30, 144, 255],
- "firebrick": [178, 34, 34],
- "floralwhite": [255, 250, 240],
- "forestgreen": [34, 139, 34],
- "fuchsia": [255, 0, 255],
- "gainsboro": [220, 220, 220],
- "ghostwhite": [248, 248, 255],
- "gold": [255, 215, 0],
- "goldenrod": [218, 165, 32],
- "gray": [128, 128, 128],
- "green": [0, 128, 0],
- "greenyellow": [173, 255, 47],
- "grey": [128, 128, 128],
- "honeydew": [240, 255, 240],
- "hotpink": [255, 105, 180],
- "indianred": [205, 92, 92],
- "indigo": [75, 0, 130],
- "ivory": [255, 255, 240],
- "khaki": [240, 230, 140],
- "lavender": [230, 230, 250],
- "lavenderblush": [255, 240, 245],
- "lawngreen": [124, 252, 0],
- "lemonchiffon": [255, 250, 205],
- "lightblue": [173, 216, 230],
- "lightcoral": [240, 128, 128],
- "lightcyan": [224, 255, 255],
- "lightgoldenrodyellow": [250, 250, 210],
- "lightgray": [211, 211, 211],
- "lightgreen": [144, 238, 144],
- "lightgrey": [211, 211, 211],
- "lightpink": [255, 182, 193],
- "lightsalmon": [255, 160, 122],
- "lightseagreen": [32, 178, 170],
- "lightskyblue": [135, 206, 250],
- "lightslategray": [119, 136, 153],
- "lightslategrey": [119, 136, 153],
- "lightsteelblue": [176, 196, 222],
- "lightyellow": [255, 255, 224],
- "lime": [0, 255, 0],
- "limegreen": [50, 205, 50],
- "linen": [250, 240, 230],
- "magenta": [255, 0, 255],
- "maroon": [128, 0, 0],
- "mediumaquamarine": [102, 205, 170],
- "mediumblue": [0, 0, 205],
- "mediumorchid": [186, 85, 211],
- "mediumpurple": [147, 112, 219],
- "mediumseagreen": [60, 179, 113],
- "mediumslateblue": [123, 104, 238],
- "mediumspringgreen": [0, 250, 154],
- "mediumturquoise": [72, 209, 204],
- "mediumvioletred": [199, 21, 133],
- "midnightblue": [25, 25, 112],
- "mintcream": [245, 255, 250],
- "mistyrose": [255, 228, 225],
- "moccasin": [255, 228, 181],
- "navajowhite": [255, 222, 173],
- "navy": [0, 0, 128],
- "oldlace": [253, 245, 230],
- "olive": [128, 128, 0],
- "olivedrab": [107, 142, 35],
- "orange": [255, 165, 0],
- "orangered": [255, 69, 0],
- "orchid": [218, 112, 214],
- "palegoldenrod": [238, 232, 170],
- "palegreen": [152, 251, 152],
- "paleturquoise": [175, 238, 238],
- "palevioletred": [219, 112, 147],
- "papayawhip": [255, 239, 213],
- "peachpuff": [255, 218, 185],
- "peru": [205, 133, 63],
- "pink": [255, 192, 203],
- "plum": [221, 160, 221],
- "powderblue": [176, 224, 230],
- "purple": [128, 0, 128],
- "rebeccapurple": [102, 51, 153],
- "red": [255, 0, 0],
- "rosybrown": [188, 143, 143],
- "royalblue": [65, 105, 225],
- "saddlebrown": [139, 69, 19],
- "salmon": [250, 128, 114],
- "sandybrown": [244, 164, 96],
- "seagreen": [46, 139, 87],
- "seashell": [255, 245, 238],
- "sienna": [160, 82, 45],
- "silver": [192, 192, 192],
- "skyblue": [135, 206, 235],
- "slateblue": [106, 90, 205],
- "slategray": [112, 128, 144],
- "slategrey": [112, 128, 144],
- "snow": [255, 250, 250],
- "springgreen": [0, 255, 127],
- "steelblue": [70, 130, 180],
- "tan": [210, 180, 140],
- "teal": [0, 128, 128],
- "thistle": [216, 191, 216],
- "tomato": [255, 99, 71],
- "turquoise": [64, 224, 208],
- "violet": [238, 130, 238],
- "wheat": [245, 222, 179],
- "white": [255, 255, 255],
- "whitesmoke": [245, 245, 245],
- "yellow": [255, 255, 0],
- "yellowgreen": [154, 205, 50]
- };
- var isArrayish = function isArrayish(obj) {
- if (!obj || typeof obj === 'string') {
- return false;
- }
- return obj instanceof Array || Array.isArray(obj) ||
- (obj.length >= 0 && (obj.splice instanceof Function ||
- (Object.getOwnPropertyDescriptor(obj, (obj.length - 1)) && obj.constructor.name !== 'String')));
- };
- var simpleSwizzle = createCommonjsModule(function (module) {
- var concat = Array.prototype.concat;
- var slice = Array.prototype.slice;
- var swizzle = module.exports = function swizzle(args) {
- var results = [];
- for (var i = 0, len = args.length; i < len; i++) {
- var arg = args[i];
- if (isArrayish(arg)) {
- // http://jsperf.com/javascript-array-concat-vs-push/98
- results = concat.call(results, slice.call(arg));
- } else {
- results.push(arg);
- }
- }
- return results;
- };
- swizzle.wrap = function (fn) {
- return function () {
- return fn(swizzle(arguments));
- };
- };
- });
- var colorString = createCommonjsModule(function (module) {
- /* MIT license */
- var hasOwnProperty = Object.hasOwnProperty;
- var reverseNames = {};
- // create a list of reverse color names
- for (var name in colorName$1) {
- if (hasOwnProperty.call(colorName$1, name)) {
- reverseNames[colorName$1[name]] = name;
- }
- }
- var cs = module.exports = {
- to: {},
- get: {}
- };
- cs.get = function (string) {
- var prefix = string.substring(0, 3).toLowerCase();
- var val;
- var model;
- switch (prefix) {
- case 'hsl':
- val = cs.get.hsl(string);
- model = 'hsl';
- break;
- case 'hwb':
- val = cs.get.hwb(string);
- model = 'hwb';
- break;
- default:
- val = cs.get.rgb(string);
- model = 'rgb';
- break;
- }
- if (!val) {
- return null;
- }
- return {model: model, value: val};
- };
- cs.get.rgb = function (string) {
- if (!string) {
- return null;
- }
- var abbr = /^#([a-f0-9]{3,4})$/i;
- var hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;
- var rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
- var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
- var keyword = /^(\w+)$/;
- var rgb = [0, 0, 0, 1];
- var match;
- var i;
- var hexAlpha;
- if (match = string.match(hex)) {
- hexAlpha = match[2];
- match = match[1];
- for (i = 0; i < 3; i++) {
- // https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19
- var i2 = i * 2;
- rgb[i] = parseInt(match.slice(i2, i2 + 2), 16);
- }
- if (hexAlpha) {
- rgb[3] = parseInt(hexAlpha, 16) / 255;
- }
- } else if (match = string.match(abbr)) {
- match = match[1];
- hexAlpha = match[3];
- for (i = 0; i < 3; i++) {
- rgb[i] = parseInt(match[i] + match[i], 16);
- }
- if (hexAlpha) {
- rgb[3] = parseInt(hexAlpha + hexAlpha, 16) / 255;
- }
- } else if (match = string.match(rgba)) {
- for (i = 0; i < 3; i++) {
- rgb[i] = parseInt(match[i + 1], 0);
- }
- if (match[4]) {
- if (match[5]) {
- rgb[3] = parseFloat(match[4]) * 0.01;
- } else {
- rgb[3] = parseFloat(match[4]);
- }
- }
- } else if (match = string.match(per)) {
- for (i = 0; i < 3; i++) {
- rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
- }
- if (match[4]) {
- if (match[5]) {
- rgb[3] = parseFloat(match[4]) * 0.01;
- } else {
- rgb[3] = parseFloat(match[4]);
- }
- }
- } else if (match = string.match(keyword)) {
- if (match[1] === 'transparent') {
- return [0, 0, 0, 0];
- }
- if (!hasOwnProperty.call(colorName$1, match[1])) {
- return null;
- }
- rgb = colorName$1[match[1]];
- rgb[3] = 1;
- return rgb;
- } else {
- return null;
- }
- for (i = 0; i < 3; i++) {
- rgb[i] = clamp(rgb[i], 0, 255);
- }
- rgb[3] = clamp(rgb[3], 0, 1);
- return rgb;
- };
- cs.get.hsl = function (string) {
- if (!string) {
- return null;
- }
- var hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
- var match = string.match(hsl);
- if (match) {
- var alpha = parseFloat(match[4]);
- var h = ((parseFloat(match[1]) % 360) + 360) % 360;
- var s = clamp(parseFloat(match[2]), 0, 100);
- var l = clamp(parseFloat(match[3]), 0, 100);
- var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
- return [h, s, l, a];
- }
- return null;
- };
- cs.get.hwb = function (string) {
- if (!string) {
- return null;
- }
- var hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
- var match = string.match(hwb);
- if (match) {
- var alpha = parseFloat(match[4]);
- var h = ((parseFloat(match[1]) % 360) + 360) % 360;
- var w = clamp(parseFloat(match[2]), 0, 100);
- var b = clamp(parseFloat(match[3]), 0, 100);
- var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
- return [h, w, b, a];
- }
- return null;
- };
- cs.to.hex = function () {
- var rgba = simpleSwizzle(arguments);
- return (
- '#' +
- hexDouble(rgba[0]) +
- hexDouble(rgba[1]) +
- hexDouble(rgba[2]) +
- (rgba[3] < 1
- ? (hexDouble(Math.round(rgba[3] * 255)))
- : '')
- );
- };
- cs.to.rgb = function () {
- var rgba = simpleSwizzle(arguments);
- return rgba.length < 4 || rgba[3] === 1
- ? 'rgb(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ')'
- : 'rgba(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ', ' + rgba[3] + ')';
- };
- cs.to.rgb.percent = function () {
- var rgba = simpleSwizzle(arguments);
- var r = Math.round(rgba[0] / 255 * 100);
- var g = Math.round(rgba[1] / 255 * 100);
- var b = Math.round(rgba[2] / 255 * 100);
- return rgba.length < 4 || rgba[3] === 1
- ? 'rgb(' + r + '%, ' + g + '%, ' + b + '%)'
- : 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + rgba[3] + ')';
- };
- cs.to.hsl = function () {
- var hsla = simpleSwizzle(arguments);
- return hsla.length < 4 || hsla[3] === 1
- ? 'hsl(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%)'
- : 'hsla(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%, ' + hsla[3] + ')';
- };
- // hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax
- // (hwb have alpha optional & 1 is default value)
- cs.to.hwb = function () {
- var hwba = simpleSwizzle(arguments);
- var a = '';
- if (hwba.length >= 4 && hwba[3] !== 1) {
- a = ', ' + hwba[3];
- }
- return 'hwb(' + hwba[0] + ', ' + hwba[1] + '%, ' + hwba[2] + '%' + a + ')';
- };
- cs.to.keyword = function (rgb) {
- return reverseNames[rgb.slice(0, 3)];
- };
- // helpers
- function clamp(num, min, max) {
- return Math.min(Math.max(min, num), max);
- }
- function hexDouble(num) {
- var str = Math.round(num).toString(16).toUpperCase();
- return (str.length < 2) ? '0' + str : str;
- }
- });
- var colorName = {
- "aliceblue": [240, 248, 255],
- "antiquewhite": [250, 235, 215],
- "aqua": [0, 255, 255],
- "aquamarine": [127, 255, 212],
- "azure": [240, 255, 255],
- "beige": [245, 245, 220],
- "bisque": [255, 228, 196],
- "black": [0, 0, 0],
- "blanchedalmond": [255, 235, 205],
- "blue": [0, 0, 255],
- "blueviolet": [138, 43, 226],
- "brown": [165, 42, 42],
- "burlywood": [222, 184, 135],
- "cadetblue": [95, 158, 160],
- "chartreuse": [127, 255, 0],
- "chocolate": [210, 105, 30],
- "coral": [255, 127, 80],
- "cornflowerblue": [100, 149, 237],
- "cornsilk": [255, 248, 220],
- "crimson": [220, 20, 60],
- "cyan": [0, 255, 255],
- "darkblue": [0, 0, 139],
- "darkcyan": [0, 139, 139],
- "darkgoldenrod": [184, 134, 11],
- "darkgray": [169, 169, 169],
- "darkgreen": [0, 100, 0],
- "darkgrey": [169, 169, 169],
- "darkkhaki": [189, 183, 107],
- "darkmagenta": [139, 0, 139],
- "darkolivegreen": [85, 107, 47],
- "darkorange": [255, 140, 0],
- "darkorchid": [153, 50, 204],
- "darkred": [139, 0, 0],
- "darksalmon": [233, 150, 122],
- "darkseagreen": [143, 188, 143],
- "darkslateblue": [72, 61, 139],
- "darkslategray": [47, 79, 79],
- "darkslategrey": [47, 79, 79],
- "darkturquoise": [0, 206, 209],
- "darkviolet": [148, 0, 211],
- "deeppink": [255, 20, 147],
- "deepskyblue": [0, 191, 255],
- "dimgray": [105, 105, 105],
- "dimgrey": [105, 105, 105],
- "dodgerblue": [30, 144, 255],
- "firebrick": [178, 34, 34],
- "floralwhite": [255, 250, 240],
- "forestgreen": [34, 139, 34],
- "fuchsia": [255, 0, 255],
- "gainsboro": [220, 220, 220],
- "ghostwhite": [248, 248, 255],
- "gold": [255, 215, 0],
- "goldenrod": [218, 165, 32],
- "gray": [128, 128, 128],
- "green": [0, 128, 0],
- "greenyellow": [173, 255, 47],
- "grey": [128, 128, 128],
- "honeydew": [240, 255, 240],
- "hotpink": [255, 105, 180],
- "indianred": [205, 92, 92],
- "indigo": [75, 0, 130],
- "ivory": [255, 255, 240],
- "khaki": [240, 230, 140],
- "lavender": [230, 230, 250],
- "lavenderblush": [255, 240, 245],
- "lawngreen": [124, 252, 0],
- "lemonchiffon": [255, 250, 205],
- "lightblue": [173, 216, 230],
- "lightcoral": [240, 128, 128],
- "lightcyan": [224, 255, 255],
- "lightgoldenrodyellow": [250, 250, 210],
- "lightgray": [211, 211, 211],
- "lightgreen": [144, 238, 144],
- "lightgrey": [211, 211, 211],
- "lightpink": [255, 182, 193],
- "lightsalmon": [255, 160, 122],
- "lightseagreen": [32, 178, 170],
- "lightskyblue": [135, 206, 250],
- "lightslategray": [119, 136, 153],
- "lightslategrey": [119, 136, 153],
- "lightsteelblue": [176, 196, 222],
- "lightyellow": [255, 255, 224],
- "lime": [0, 255, 0],
- "limegreen": [50, 205, 50],
- "linen": [250, 240, 230],
- "magenta": [255, 0, 255],
- "maroon": [128, 0, 0],
- "mediumaquamarine": [102, 205, 170],
- "mediumblue": [0, 0, 205],
- "mediumorchid": [186, 85, 211],
- "mediumpurple": [147, 112, 219],
- "mediumseagreen": [60, 179, 113],
- "mediumslateblue": [123, 104, 238],
- "mediumspringgreen": [0, 250, 154],
- "mediumturquoise": [72, 209, 204],
- "mediumvioletred": [199, 21, 133],
- "midnightblue": [25, 25, 112],
- "mintcream": [245, 255, 250],
- "mistyrose": [255, 228, 225],
- "moccasin": [255, 228, 181],
- "navajowhite": [255, 222, 173],
- "navy": [0, 0, 128],
- "oldlace": [253, 245, 230],
- "olive": [128, 128, 0],
- "olivedrab": [107, 142, 35],
- "orange": [255, 165, 0],
- "orangered": [255, 69, 0],
- "orchid": [218, 112, 214],
- "palegoldenrod": [238, 232, 170],
- "palegreen": [152, 251, 152],
- "paleturquoise": [175, 238, 238],
- "palevioletred": [219, 112, 147],
- "papayawhip": [255, 239, 213],
- "peachpuff": [255, 218, 185],
- "peru": [205, 133, 63],
- "pink": [255, 192, 203],
- "plum": [221, 160, 221],
- "powderblue": [176, 224, 230],
- "purple": [128, 0, 128],
- "rebeccapurple": [102, 51, 153],
- "red": [255, 0, 0],
- "rosybrown": [188, 143, 143],
- "royalblue": [65, 105, 225],
- "saddlebrown": [139, 69, 19],
- "salmon": [250, 128, 114],
- "sandybrown": [244, 164, 96],
- "seagreen": [46, 139, 87],
- "seashell": [255, 245, 238],
- "sienna": [160, 82, 45],
- "silver": [192, 192, 192],
- "skyblue": [135, 206, 235],
- "slateblue": [106, 90, 205],
- "slategray": [112, 128, 144],
- "slategrey": [112, 128, 144],
- "snow": [255, 250, 250],
- "springgreen": [0, 255, 127],
- "steelblue": [70, 130, 180],
- "tan": [210, 180, 140],
- "teal": [0, 128, 128],
- "thistle": [216, 191, 216],
- "tomato": [255, 99, 71],
- "turquoise": [64, 224, 208],
- "violet": [238, 130, 238],
- "wheat": [245, 222, 179],
- "white": [255, 255, 255],
- "whitesmoke": [245, 245, 245],
- "yellow": [255, 255, 0],
- "yellowgreen": [154, 205, 50]
- };
- /* MIT license */
- /* eslint-disable no-mixed-operators */
- // NOTE: conversions should only return primitive values (i.e. arrays, or
- // values that give correct `typeof` results).
- // do not use box values types (i.e. Number(), String(), etc.)
- const reverseKeywords = {};
- for (const key of Object.keys(colorName)) {
- reverseKeywords[colorName[key]] = key;
- }
- const convert$1 = {
- rgb: {channels: 3, labels: 'rgb'},
- hsl: {channels: 3, labels: 'hsl'},
- hsv: {channels: 3, labels: 'hsv'},
- hwb: {channels: 3, labels: 'hwb'},
- cmyk: {channels: 4, labels: 'cmyk'},
- xyz: {channels: 3, labels: 'xyz'},
- lab: {channels: 3, labels: 'lab'},
- lch: {channels: 3, labels: 'lch'},
- hex: {channels: 1, labels: ['hex']},
- keyword: {channels: 1, labels: ['keyword']},
- ansi16: {channels: 1, labels: ['ansi16']},
- ansi256: {channels: 1, labels: ['ansi256']},
- hcg: {channels: 3, labels: ['h', 'c', 'g']},
- apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
- gray: {channels: 1, labels: ['gray']}
- };
- var conversions = convert$1;
- // Hide .channels and .labels properties
- for (const model of Object.keys(convert$1)) {
- if (!('channels' in convert$1[model])) {
- throw new Error('missing channels property: ' + model);
- }
- if (!('labels' in convert$1[model])) {
- throw new Error('missing channel labels property: ' + model);
- }
- if (convert$1[model].labels.length !== convert$1[model].channels) {
- throw new Error('channel and label counts mismatch: ' + model);
- }
- const {channels, labels} = convert$1[model];
- delete convert$1[model].channels;
- delete convert$1[model].labels;
- Object.defineProperty(convert$1[model], 'channels', {value: channels});
- Object.defineProperty(convert$1[model], 'labels', {value: labels});
- }
- convert$1.rgb.hsl = function (rgb) {
- const r = rgb[0] / 255;
- const g = rgb[1] / 255;
- const b = rgb[2] / 255;
- const min = Math.min(r, g, b);
- const max = Math.max(r, g, b);
- const delta = max - min;
- let h;
- let s;
- if (max === min) {
- h = 0;
- } else if (r === max) {
- h = (g - b) / delta;
- } else if (g === max) {
- h = 2 + (b - r) / delta;
- } else if (b === max) {
- h = 4 + (r - g) / delta;
- }
- h = Math.min(h * 60, 360);
- if (h < 0) {
- h += 360;
- }
- const l = (min + max) / 2;
- if (max === min) {
- s = 0;
- } else if (l <= 0.5) {
- s = delta / (max + min);
- } else {
- s = delta / (2 - max - min);
- }
- return [h, s * 100, l * 100];
- };
- convert$1.rgb.hsv = function (rgb) {
- let rdif;
- let gdif;
- let bdif;
- let h;
- let s;
- const r = rgb[0] / 255;
- const g = rgb[1] / 255;
- const b = rgb[2] / 255;
- const v = Math.max(r, g, b);
- const diff = v - Math.min(r, g, b);
- const diffc = function (c) {
- return (v - c) / 6 / diff + 1 / 2;
- };
- if (diff === 0) {
- h = 0;
- s = 0;
- } else {
- s = diff / v;
- rdif = diffc(r);
- gdif = diffc(g);
- bdif = diffc(b);
- if (r === v) {
- h = bdif - gdif;
- } else if (g === v) {
- h = (1 / 3) + rdif - bdif;
- } else if (b === v) {
- h = (2 / 3) + gdif - rdif;
- }
- if (h < 0) {
- h += 1;
- } else if (h > 1) {
- h -= 1;
- }
- }
- return [
- h * 360,
- s * 100,
- v * 100
- ];
- };
- convert$1.rgb.hwb = function (rgb) {
- const r = rgb[0];
- const g = rgb[1];
- let b = rgb[2];
- const h = convert$1.rgb.hsl(rgb)[0];
- const w = 1 / 255 * Math.min(r, Math.min(g, b));
- b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
- return [h, w * 100, b * 100];
- };
- convert$1.rgb.cmyk = function (rgb) {
- const r = rgb[0] / 255;
- const g = rgb[1] / 255;
- const b = rgb[2] / 255;
- const k = Math.min(1 - r, 1 - g, 1 - b);
- const c = (1 - r - k) / (1 - k) || 0;
- const m = (1 - g - k) / (1 - k) || 0;
- const y = (1 - b - k) / (1 - k) || 0;
- return [c * 100, m * 100, y * 100, k * 100];
- };
- function comparativeDistance(x, y) {
- /*
- See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
- */
- return (
- ((x[0] - y[0]) ** 2) +
- ((x[1] - y[1]) ** 2) +
- ((x[2] - y[2]) ** 2)
- );
- }
- convert$1.rgb.keyword = function (rgb) {
- const reversed = reverseKeywords[rgb];
- if (reversed) {
- return reversed;
- }
- let currentClosestDistance = Infinity;
- let currentClosestKeyword;
- for (const keyword of Object.keys(colorName)) {
- const value = colorName[keyword];
- // Compute comparative distance
- const distance = comparativeDistance(rgb, value);
- // Check if its less, if so set as closest
- if (distance < currentClosestDistance) {
- currentClosestDistance = distance;
- currentClosestKeyword = keyword;
- }
- }
- return currentClosestKeyword;
- };
- convert$1.keyword.rgb = function (keyword) {
- return colorName[keyword];
- };
- convert$1.rgb.xyz = function (rgb) {
- let r = rgb[0] / 255;
- let g = rgb[1] / 255;
- let b = rgb[2] / 255;
- // Assume sRGB
- r = r > 0.04045 ? (((r + 0.055) / 1.055) ** 2.4) : (r / 12.92);
- g = g > 0.04045 ? (((g + 0.055) / 1.055) ** 2.4) : (g / 12.92);
- b = b > 0.04045 ? (((b + 0.055) / 1.055) ** 2.4) : (b / 12.92);
- const x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
- const y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
- const z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
- return [x * 100, y * 100, z * 100];
- };
- convert$1.rgb.lab = function (rgb) {
- const xyz = convert$1.rgb.xyz(rgb);
- let x = xyz[0];
- let y = xyz[1];
- let z = xyz[2];
- x /= 95.047;
- y /= 100;
- z /= 108.883;
- x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
- y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
- z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
- const l = (116 * y) - 16;
- const a = 500 * (x - y);
- const b = 200 * (y - z);
- return [l, a, b];
- };
- convert$1.hsl.rgb = function (hsl) {
- const h = hsl[0] / 360;
- const s = hsl[1] / 100;
- const l = hsl[2] / 100;
- let t2;
- let t3;
- let val;
- if (s === 0) {
- val = l * 255;
- return [val, val, val];
- }
- if (l < 0.5) {
- t2 = l * (1 + s);
- } else {
- t2 = l + s - l * s;
- }
- const t1 = 2 * l - t2;
- const rgb = [0, 0, 0];
- for (let i = 0; i < 3; i++) {
- t3 = h + 1 / 3 * -(i - 1);
- if (t3 < 0) {
- t3++;
- }
- if (t3 > 1) {
- t3--;
- }
- if (6 * t3 < 1) {
- val = t1 + (t2 - t1) * 6 * t3;
- } else if (2 * t3 < 1) {
- val = t2;
- } else if (3 * t3 < 2) {
- val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
- } else {
- val = t1;
- }
- rgb[i] = val * 255;
- }
- return rgb;
- };
- convert$1.hsl.hsv = function (hsl) {
- const h = hsl[0];
- let s = hsl[1] / 100;
- let l = hsl[2] / 100;
- let smin = s;
- const lmin = Math.max(l, 0.01);
- l *= 2;
- s *= (l <= 1) ? l : 2 - l;
- smin *= lmin <= 1 ? lmin : 2 - lmin;
- const v = (l + s) / 2;
- const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
- return [h, sv * 100, v * 100];
- };
- convert$1.hsv.rgb = function (hsv) {
- const h = hsv[0] / 60;
- const s = hsv[1] / 100;
- let v = hsv[2] / 100;
- const hi = Math.floor(h) % 6;
- const f = h - Math.floor(h);
- const p = 255 * v * (1 - s);
- const q = 255 * v * (1 - (s * f));
- const t = 255 * v * (1 - (s * (1 - f)));
- v *= 255;
- switch (hi) {
- case 0:
- return [v, t, p];
- case 1:
- return [q, v, p];
- case 2:
- return [p, v, t];
- case 3:
- return [p, q, v];
- case 4:
- return [t, p, v];
- case 5:
- return [v, p, q];
- }
- };
- convert$1.hsv.hsl = function (hsv) {
- const h = hsv[0];
- const s = hsv[1] / 100;
- const v = hsv[2] / 100;
- const vmin = Math.max(v, 0.01);
- let sl;
- let l;
- l = (2 - s) * v;
- const lmin = (2 - s) * vmin;
- sl = s * vmin;
- sl /= (lmin <= 1) ? lmin : 2 - lmin;
- sl = sl || 0;
- l /= 2;
- return [h, sl * 100, l * 100];
- };
- // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
- convert$1.hwb.rgb = function (hwb) {
- const h = hwb[0] / 360;
- let wh = hwb[1] / 100;
- let bl = hwb[2] / 100;
- const ratio = wh + bl;
- let f;
- // Wh + bl cant be > 1
- if (ratio > 1) {
- wh /= ratio;
- bl /= ratio;
- }
- const i = Math.floor(6 * h);
- const v = 1 - bl;
- f = 6 * h - i;
- if ((i & 0x01) !== 0) {
- f = 1 - f;
- }
- const n = wh + f * (v - wh); // Linear interpolation
- let r;
- let g;
- let b;
- /* eslint-disable max-statements-per-line,no-multi-spaces */
- switch (i) {
- default:
- case 6:
- case 0: r = v; g = n; b = wh; break;
- case 1: r = n; g = v; b = wh; break;
- case 2: r = wh; g = v; b = n; break;
- case 3: r = wh; g = n; b = v; break;
- case 4: r = n; g = wh; b = v; break;
- case 5: r = v; g = wh; b = n; break;
- }
- /* eslint-enable max-statements-per-line,no-multi-spaces */
- return [r * 255, g * 255, b * 255];
- };
- convert$1.cmyk.rgb = function (cmyk) {
- const c = cmyk[0] / 100;
- const m = cmyk[1] / 100;
- const y = cmyk[2] / 100;
- const k = cmyk[3] / 100;
- const r = 1 - Math.min(1, c * (1 - k) + k);
- const g = 1 - Math.min(1, m * (1 - k) + k);
- const b = 1 - Math.min(1, y * (1 - k) + k);
- return [r * 255, g * 255, b * 255];
- };
- convert$1.xyz.rgb = function (xyz) {
- const x = xyz[0] / 100;
- const y = xyz[1] / 100;
- const z = xyz[2] / 100;
- let r;
- let g;
- let b;
- r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
- g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
- b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
- // Assume sRGB
- r = r > 0.0031308
- ? ((1.055 * (r ** (1.0 / 2.4))) - 0.055)
- : r * 12.92;
- g = g > 0.0031308
- ? ((1.055 * (g ** (1.0 / 2.4))) - 0.055)
- : g * 12.92;
- b = b > 0.0031308
- ? ((1.055 * (b ** (1.0 / 2.4))) - 0.055)
- : b * 12.92;
- r = Math.min(Math.max(0, r), 1);
- g = Math.min(Math.max(0, g), 1);
- b = Math.min(Math.max(0, b), 1);
- return [r * 255, g * 255, b * 255];
- };
- convert$1.xyz.lab = function (xyz) {
- let x = xyz[0];
- let y = xyz[1];
- let z = xyz[2];
- x /= 95.047;
- y /= 100;
- z /= 108.883;
- x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
- y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
- z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
- const l = (116 * y) - 16;
- const a = 500 * (x - y);
- const b = 200 * (y - z);
- return [l, a, b];
- };
- convert$1.lab.xyz = function (lab) {
- const l = lab[0];
- const a = lab[1];
- const b = lab[2];
- let x;
- let y;
- let z;
- y = (l + 16) / 116;
- x = a / 500 + y;
- z = y - b / 200;
- const y2 = y ** 3;
- const x2 = x ** 3;
- const z2 = z ** 3;
- y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
- x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
- z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
- x *= 95.047;
- y *= 100;
- z *= 108.883;
- return [x, y, z];
- };
- convert$1.lab.lch = function (lab) {
- const l = lab[0];
- const a = lab[1];
- const b = lab[2];
- let h;
- const hr = Math.atan2(b, a);
- h = hr * 360 / 2 / Math.PI;
- if (h < 0) {
- h += 360;
- }
- const c = Math.sqrt(a * a + b * b);
- return [l, c, h];
- };
- convert$1.lch.lab = function (lch) {
- const l = lch[0];
- const c = lch[1];
- const h = lch[2];
- const hr = h / 360 * 2 * Math.PI;
- const a = c * Math.cos(hr);
- const b = c * Math.sin(hr);
- return [l, a, b];
- };
- convert$1.rgb.ansi16 = function (args, saturation = null) {
- const [r, g, b] = args;
- let value = saturation === null ? convert$1.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization
- value = Math.round(value / 50);
- if (value === 0) {
- return 30;
- }
- let ansi = 30
- + ((Math.round(b / 255) << 2)
- | (Math.round(g / 255) << 1)
- | Math.round(r / 255));
- if (value === 2) {
- ansi += 60;
- }
- return ansi;
- };
- convert$1.hsv.ansi16 = function (args) {
- // Optimization here; we already know the value and don't need to get
- // it converted for us.
- return convert$1.rgb.ansi16(convert$1.hsv.rgb(args), args[2]);
- };
- convert$1.rgb.ansi256 = function (args) {
- const r = args[0];
- const g = args[1];
- const b = args[2];
- // We use the extended greyscale palette here, with the exception of
- // black and white. normal palette only has 4 greyscale shades.
- if (r === g && g === b) {
- if (r < 8) {
- return 16;
- }
- if (r > 248) {
- return 231;
- }
- return Math.round(((r - 8) / 247) * 24) + 232;
- }
- const ansi = 16
- + (36 * Math.round(r / 255 * 5))
- + (6 * Math.round(g / 255 * 5))
- + Math.round(b / 255 * 5);
- return ansi;
- };
- convert$1.ansi16.rgb = function (args) {
- let color = args % 10;
- // Handle greyscale
- if (color === 0 || color === 7) {
- if (args > 50) {
- color += 3.5;
- }
- color = color / 10.5 * 255;
- return [color, color, color];
- }
- const mult = (~~(args > 50) + 1) * 0.5;
- const r = ((color & 1) * mult) * 255;
- const g = (((color >> 1) & 1) * mult) * 255;
- const b = (((color >> 2) & 1) * mult) * 255;
- return [r, g, b];
- };
- convert$1.ansi256.rgb = function (args) {
- // Handle greyscale
- if (args >= 232) {
- const c = (args - 232) * 10 + 8;
- return [c, c, c];
- }
- args -= 16;
- let rem;
- const r = Math.floor(args / 36) / 5 * 255;
- const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
- const b = (rem % 6) / 5 * 255;
- return [r, g, b];
- };
- convert$1.rgb.hex = function (args) {
- const integer = ((Math.round(args[0]) & 0xFF) << 16)
- + ((Math.round(args[1]) & 0xFF) << 8)
- + (Math.round(args[2]) & 0xFF);
- const string = integer.toString(16).toUpperCase();
- return '000000'.substring(string.length) + string;
- };
- convert$1.hex.rgb = function (args) {
- const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
- if (!match) {
- return [0, 0, 0];
- }
- let colorString = match[0];
- if (match[0].length === 3) {
- colorString = colorString.split('').map(char => {
- return char + char;
- }).join('');
- }
- const integer = parseInt(colorString, 16);
- const r = (integer >> 16) & 0xFF;
- const g = (integer >> 8) & 0xFF;
- const b = integer & 0xFF;
- return [r, g, b];
- };
- convert$1.rgb.hcg = function (rgb) {
- const r = rgb[0] / 255;
- const g = rgb[1] / 255;
- const b = rgb[2] / 255;
- const max = Math.max(Math.max(r, g), b);
- const min = Math.min(Math.min(r, g), b);
- const chroma = (max - min);
- let grayscale;
- let hue;
- if (chroma < 1) {
- grayscale = min / (1 - chroma);
- } else {
- grayscale = 0;
- }
- if (chroma <= 0) {
- hue = 0;
- } else
- if (max === r) {
- hue = ((g - b) / chroma) % 6;
- } else
- if (max === g) {
- hue = 2 + (b - r) / chroma;
- } else {
- hue = 4 + (r - g) / chroma;
- }
- hue /= 6;
- hue %= 1;
- return [hue * 360, chroma * 100, grayscale * 100];
- };
- convert$1.hsl.hcg = function (hsl) {
- const s = hsl[1] / 100;
- const l = hsl[2] / 100;
- const c = l < 0.5 ? (2.0 * s * l) : (2.0 * s * (1.0 - l));
- let f = 0;
- if (c < 1.0) {
- f = (l - 0.5 * c) / (1.0 - c);
- }
- return [hsl[0], c * 100, f * 100];
- };
- convert$1.hsv.hcg = function (hsv) {
- const s = hsv[1] / 100;
- const v = hsv[2] / 100;
- const c = s * v;
- let f = 0;
- if (c < 1.0) {
- f = (v - c) / (1 - c);
- }
- return [hsv[0], c * 100, f * 100];
- };
- convert$1.hcg.rgb = function (hcg) {
- const h = hcg[0] / 360;
- const c = hcg[1] / 100;
- const g = hcg[2] / 100;
- if (c === 0.0) {
- return [g * 255, g * 255, g * 255];
- }
- const pure = [0, 0, 0];
- const hi = (h % 1) * 6;
- const v = hi % 1;
- const w = 1 - v;
- let mg = 0;
- /* eslint-disable max-statements-per-line */
- switch (Math.floor(hi)) {
- case 0:
- pure[0] = 1; pure[1] = v; pure[2] = 0; break;
- case 1:
- pure[0] = w; pure[1] = 1; pure[2] = 0; break;
- case 2:
- pure[0] = 0; pure[1] = 1; pure[2] = v; break;
- case 3:
- pure[0] = 0; pure[1] = w; pure[2] = 1; break;
- case 4:
- pure[0] = v; pure[1] = 0; pure[2] = 1; break;
- default:
- pure[0] = 1; pure[1] = 0; pure[2] = w;
- }
- /* eslint-enable max-statements-per-line */
- mg = (1.0 - c) * g;
- return [
- (c * pure[0] + mg) * 255,
- (c * pure[1] + mg) * 255,
- (c * pure[2] + mg) * 255
- ];
- };
- convert$1.hcg.hsv = function (hcg) {
- const c = hcg[1] / 100;
- const g = hcg[2] / 100;
- const v = c + g * (1.0 - c);
- let f = 0;
- if (v > 0.0) {
- f = c / v;
- }
- return [hcg[0], f * 100, v * 100];
- };
- convert$1.hcg.hsl = function (hcg) {
- const c = hcg[1] / 100;
- const g = hcg[2] / 100;
- const l = g * (1.0 - c) + 0.5 * c;
- let s = 0;
- if (l > 0.0 && l < 0.5) {
- s = c / (2 * l);
- } else
- if (l >= 0.5 && l < 1.0) {
- s = c / (2 * (1 - l));
- }
- return [hcg[0], s * 100, l * 100];
- };
- convert$1.hcg.hwb = function (hcg) {
- const c = hcg[1] / 100;
- const g = hcg[2] / 100;
- const v = c + g * (1.0 - c);
- return [hcg[0], (v - c) * 100, (1 - v) * 100];
- };
- convert$1.hwb.hcg = function (hwb) {
- const w = hwb[1] / 100;
- const b = hwb[2] / 100;
- const v = 1 - b;
- const c = v - w;
- let g = 0;
- if (c < 1) {
- g = (v - c) / (1 - c);
- }
- return [hwb[0], c * 100, g * 100];
- };
- convert$1.apple.rgb = function (apple) {
- return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
- };
- convert$1.rgb.apple = function (rgb) {
- return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
- };
- convert$1.gray.rgb = function (args) {
- return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
- };
- convert$1.gray.hsl = function (args) {
- return [0, 0, args[0]];
- };
- convert$1.gray.hsv = convert$1.gray.hsl;
- convert$1.gray.hwb = function (gray) {
- return [0, 100, gray[0]];
- };
- convert$1.gray.cmyk = function (gray) {
- return [0, 0, 0, gray[0]];
- };
- convert$1.gray.lab = function (gray) {
- return [gray[0], 0, 0];
- };
- convert$1.gray.hex = function (gray) {
- const val = Math.round(gray[0] / 100 * 255) & 0xFF;
- const integer = (val << 16) + (val << 8) + val;
- const string = integer.toString(16).toUpperCase();
- return '000000'.substring(string.length) + string;
- };
- convert$1.rgb.gray = function (rgb) {
- const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
- return [val / 255 * 100];
- };
- /*
- This function routes a model to all other models.
- all functions that are routed have a property `.conversion` attached
- to the returned synthetic function. This property is an array
- of strings, each with the steps in between the 'from' and 'to'
- color models (inclusive).
- conversions that are not possible simply are not included.
- */
- function buildGraph() {
- const graph = {};
- // https://jsperf.com/object-keys-vs-for-in-with-closure/3
- const models = Object.keys(conversions);
- for (let len = models.length, i = 0; i < len; i++) {
- graph[models[i]] = {
- // http://jsperf.com/1-vs-infinity
- // micro-opt, but this is simple.
- distance: -1,
- parent: null
- };
- }
- return graph;
- }
- // https://en.wikipedia.org/wiki/Breadth-first_search
- function deriveBFS(fromModel) {
- const graph = buildGraph();
- const queue = [fromModel]; // Unshift -> queue -> pop
- graph[fromModel].distance = 0;
- while (queue.length) {
- const current = queue.pop();
- const adjacents = Object.keys(conversions[current]);
- for (let len = adjacents.length, i = 0; i < len; i++) {
- const adjacent = adjacents[i];
- const node = graph[adjacent];
- if (node.distance === -1) {
- node.distance = graph[current].distance + 1;
- node.parent = current;
- queue.unshift(adjacent);
- }
- }
- }
- return graph;
- }
- function link(from, to) {
- return function (args) {
- return to(from(args));
- };
- }
- function wrapConversion(toModel, graph) {
- const path = [graph[toModel].parent, toModel];
- let fn = conversions[graph[toModel].parent][toModel];
- let cur = graph[toModel].parent;
- while (graph[cur].parent) {
- path.unshift(graph[cur].parent);
- fn = link(conversions[graph[cur].parent][cur], fn);
- cur = graph[cur].parent;
- }
- fn.conversion = path;
- return fn;
- }
- var route = function (fromModel) {
- const graph = deriveBFS(fromModel);
- const conversion = {};
- const models = Object.keys(graph);
- for (let len = models.length, i = 0; i < len; i++) {
- const toModel = models[i];
- const node = graph[toModel];
- if (node.parent === null) {
- // No possible conversion, or this node is the source model.
- continue;
- }
- conversion[toModel] = wrapConversion(toModel, graph);
- }
- return conversion;
- };
- const convert = {};
- const models = Object.keys(conversions);
- function wrapRaw(fn) {
- const wrappedFn = function (...args) {
- const arg0 = args[0];
- if (arg0 === undefined || arg0 === null) {
- return arg0;
- }
- if (arg0.length > 1) {
- args = arg0;
- }
- return fn(args);
- };
- // Preserve .conversion property if there is one
- if ('conversion' in fn) {
- wrappedFn.conversion = fn.conversion;
- }
- return wrappedFn;
- }
- function wrapRounded(fn) {
- const wrappedFn = function (...args) {
- const arg0 = args[0];
- if (arg0 === undefined || arg0 === null) {
- return arg0;
- }
- if (arg0.length > 1) {
- args = arg0;
- }
- const result = fn(args);
- // We're assuming the result is an array here.
- // see notice in conversions.js; don't use box types
- // in conversion functions.
- if (typeof result === 'object') {
- for (let len = result.length, i = 0; i < len; i++) {
- result[i] = Math.round(result[i]);
- }
- }
- return result;
- };
- // Preserve .conversion property if there is one
- if ('conversion' in fn) {
- wrappedFn.conversion = fn.conversion;
- }
- return wrappedFn;
- }
- models.forEach(fromModel => {
- convert[fromModel] = {};
- Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
- Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
- const routes = route(fromModel);
- const routeModels = Object.keys(routes);
- routeModels.forEach(toModel => {
- const fn = routes[toModel];
- convert[fromModel][toModel] = wrapRounded(fn);
- convert[fromModel][toModel].raw = wrapRaw(fn);
- });
- });
- var colorConvert = convert;
- const skippedModels = [
- // To be honest, I don't really feel like keyword belongs in color convert, but eh.
- 'keyword',
- // Gray conflicts with some method names, and has its own method defined.
- 'gray',
- // Shouldn't really be in color-convert either...
- 'hex',
- ];
- const hashedModelKeys = {};
- for (const model of Object.keys(colorConvert)) {
- hashedModelKeys[[...colorConvert[model].labels].sort().join('')] = model;
- }
- const limiters = {};
- function Color(object, model) {
- if (!(this instanceof Color)) {
- return new Color(object, model);
- }
- if (model && model in skippedModels) {
- model = null;
- }
- if (model && !(model in colorConvert)) {
- throw new Error('Unknown model: ' + model);
- }
- let i;
- let channels;
- if (object == null) { // eslint-disable-line no-eq-null,eqeqeq
- this.model = 'rgb';
- this.color = [0, 0, 0];
- this.valpha = 1;
- } else if (object instanceof Color) {
- this.model = object.model;
- this.color = [...object.color];
- this.valpha = object.valpha;
- } else if (typeof object === 'string') {
- const result = colorString.get(object);
- if (result === null) {
- throw new Error('Unable to parse color from string: ' + object);
- }
- this.model = result.model;
- channels = colorConvert[this.model].channels;
- this.color = result.value.slice(0, channels);
- this.valpha = typeof result.value[channels] === 'number' ? result.value[channels] : 1;
- } else if (object.length > 0) {
- this.model = model || 'rgb';
- channels = colorConvert[this.model].channels;
- const newArray = Array.prototype.slice.call(object, 0, channels);
- this.color = zeroArray(newArray, channels);
- this.valpha = typeof object[channels] === 'number' ? object[channels] : 1;
- } else if (typeof object === 'number') {
- // This is always RGB - can be converted later on.
- this.model = 'rgb';
- this.color = [
- (object >> 16) & 0xFF,
- (object >> 8) & 0xFF,
- object & 0xFF,
- ];
- this.valpha = 1;
- } else {
- this.valpha = 1;
- const keys = Object.keys(object);
- if ('alpha' in object) {
- keys.splice(keys.indexOf('alpha'), 1);
- this.valpha = typeof object.alpha === 'number' ? object.alpha : 0;
- }
- const hashedKeys = keys.sort().join('');
- if (!(hashedKeys in hashedModelKeys)) {
- throw new Error('Unable to parse color from object: ' + JSON.stringify(object));
- }
- this.model = hashedModelKeys[hashedKeys];
- const {labels} = colorConvert[this.model];
- const color = [];
- for (i = 0; i < labels.length; i++) {
- color.push(object[labels[i]]);
- }
- this.color = zeroArray(color);
- }
- // Perform limitations (clamping, etc.)
- if (limiters[this.model]) {
- channels = colorConvert[this.model].channels;
- for (i = 0; i < channels; i++) {
- const limit = limiters[this.model][i];
- if (limit) {
- this.color[i] = limit(this.color[i]);
- }
- }
- }
- this.valpha = Math.max(0, Math.min(1, this.valpha));
- if (Object.freeze) {
- Object.freeze(this);
- }
- }
- Color.prototype = {
- toString() {
- return this.string();
- },
- toJSON() {
- return this[this.model]();
- },
- string(places) {
- let self = this.model in colorString.to ? this : this.rgb();
- self = self.round(typeof places === 'number' ? places : 1);
- const args = self.valpha === 1 ? self.color : [...self.color, this.valpha];
- return colorString.to[self.model](args);
- },
- percentString(places) {
- const self = this.rgb().round(typeof places === 'number' ? places : 1);
- const args = self.valpha === 1 ? self.color : [...self.color, this.valpha];
- return colorString.to.rgb.percent(args);
- },
- array() {
- return this.valpha === 1 ? [...this.color] : [...this.color, this.valpha];
- },
- object() {
- const result = {};
- const {channels} = colorConvert[this.model];
- const {labels} = colorConvert[this.model];
- for (let i = 0; i < channels; i++) {
- result[labels[i]] = this.color[i];
- }
- if (this.valpha !== 1) {
- result.alpha = this.valpha;
- }
- return result;
- },
- unitArray() {
- const rgb = this.rgb().color;
- rgb[0] /= 255;
- rgb[1] /= 255;
- rgb[2] /= 255;
- if (this.valpha !== 1) {
- rgb.push(this.valpha);
- }
- return rgb;
- },
- unitObject() {
- const rgb = this.rgb().object();
- rgb.r /= 255;
- rgb.g /= 255;
- rgb.b /= 255;
- if (this.valpha !== 1) {
- rgb.alpha = this.valpha;
- }
- return rgb;
- },
- round(places) {
- places = Math.max(places || 0, 0);
- return new Color([...this.color.map(roundToPlace(places)), this.valpha], this.model);
- },
- alpha(value) {
- if (value !== undefined) {
- return new Color([...this.color, Math.max(0, Math.min(1, value))], this.model);
- }
- return this.valpha;
- },
- // Rgb
- red: getset('rgb', 0, maxfn(255)),
- green: getset('rgb', 1, maxfn(255)),
- blue: getset('rgb', 2, maxfn(255)),
- hue: getset(['hsl', 'hsv', 'hsl', 'hwb', 'hcg'], 0, value => ((value % 360) + 360) % 360),
- saturationl: getset('hsl', 1, maxfn(100)),
- lightness: getset('hsl', 2, maxfn(100)),
- saturationv: getset('hsv', 1, maxfn(100)),
- value: getset('hsv', 2, maxfn(100)),
- chroma: getset('hcg', 1, maxfn(100)),
- gray: getset('hcg', 2, maxfn(100)),
- white: getset('hwb', 1, maxfn(100)),
- wblack: getset('hwb', 2, maxfn(100)),
- cyan: getset('cmyk', 0, maxfn(100)),
- magenta: getset('cmyk', 1, maxfn(100)),
- yellow: getset('cmyk', 2, maxfn(100)),
- black: getset('cmyk', 3, maxfn(100)),
- x: getset('xyz', 0, maxfn(95.047)),
- y: getset('xyz', 1, maxfn(100)),
- z: getset('xyz', 2, maxfn(108.833)),
- l: getset('lab', 0, maxfn(100)),
- a: getset('lab', 1),
- b: getset('lab', 2),
- keyword(value) {
- if (value !== undefined) {
- return new Color(value);
- }
- return colorConvert[this.model].keyword(this.color);
- },
- hex(value) {
- if (value !== undefined) {
- return new Color(value);
- }
- return colorString.to.hex(this.rgb().round().color);
- },
- hexa(value) {
- if (value !== undefined) {
- return new Color(value);
- }
- const rgbArray = this.rgb().round().color;
- let alphaHex = Math.round(this.valpha * 255).toString(16).toUpperCase();
- if (alphaHex.length === 1) {
- alphaHex = '0' + alphaHex;
- }
- return colorString.to.hex(rgbArray) + alphaHex;
- },
- rgbNumber() {
- const rgb = this.rgb().color;
- return ((rgb[0] & 0xFF) << 16) | ((rgb[1] & 0xFF) << 8) | (rgb[2] & 0xFF);
- },
- luminosity() {
- // http://www.w3.org/TR/WCAG20/#relativeluminancedef
- const rgb = this.rgb().color;
- const lum = [];
- for (const [i, element] of rgb.entries()) {
- const chan = element / 255;
- lum[i] = (chan <= 0.04045) ? chan / 12.92 : ((chan + 0.055) / 1.055) ** 2.4;
- }
- return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
- },
- contrast(color2) {
- // http://www.w3.org/TR/WCAG20/#contrast-ratiodef
- const lum1 = this.luminosity();
- const lum2 = color2.luminosity();
- if (lum1 > lum2) {
- return (lum1 + 0.05) / (lum2 + 0.05);
- }
- return (lum2 + 0.05) / (lum1 + 0.05);
- },
- level(color2) {
- // https://www.w3.org/TR/WCAG/#contrast-enhanced
- const contrastRatio = this.contrast(color2);
- if (contrastRatio >= 7) {
- return 'AAA';
- }
- return (contrastRatio >= 4.5) ? 'AA' : '';
- },
- isDark() {
- // YIQ equation from http://24ways.org/2010/calculating-color-contrast
- const rgb = this.rgb().color;
- const yiq = (rgb[0] * 2126 + rgb[1] * 7152 + rgb[2] * 722) / 10000;
- return yiq < 128;
- },
- isLight() {
- return !this.isDark();
- },
- negate() {
- const rgb = this.rgb();
- for (let i = 0; i < 3; i++) {
- rgb.color[i] = 255 - rgb.color[i];
- }
- return rgb;
- },
- lighten(ratio) {
- const hsl = this.hsl();
- hsl.color[2] += hsl.color[2] * ratio;
- return hsl;
- },
- darken(ratio) {
- const hsl = this.hsl();
- hsl.color[2] -= hsl.color[2] * ratio;
- return hsl;
- },
- saturate(ratio) {
- const hsl = this.hsl();
- hsl.color[1] += hsl.color[1] * ratio;
- return hsl;
- },
- desaturate(ratio) {
- const hsl = this.hsl();
- hsl.color[1] -= hsl.color[1] * ratio;
- return hsl;
- },
- whiten(ratio) {
- const hwb = this.hwb();
- hwb.color[1] += hwb.color[1] * ratio;
- return hwb;
- },
- blacken(ratio) {
- const hwb = this.hwb();
- hwb.color[2] += hwb.color[2] * ratio;
- return hwb;
- },
- grayscale() {
- // http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale
- const rgb = this.rgb().color;
- const value = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
- return Color.rgb(value, value, value);
- },
- fade(ratio) {
- return this.alpha(this.valpha - (this.valpha * ratio));
- },
- opaquer(ratio) {
- return this.alpha(this.valpha + (this.valpha * ratio));
- },
- rotate(degrees) {
- const hsl = this.hsl();
- let hue = hsl.color[0];
- hue = (hue + degrees) % 360;
- hue = hue < 0 ? 360 + hue : hue;
- hsl.color[0] = hue;
- return hsl;
- },
- mix(mixinColor, weight) {
- // Ported from sass implementation in C
- // https://github.com/sass/libsass/blob/0e6b4a2850092356aa3ece07c6b249f0221caced/functions.cpp#L209
- if (!mixinColor || !mixinColor.rgb) {
- throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof mixinColor);
- }
- const color1 = mixinColor.rgb();
- const color2 = this.rgb();
- const p = weight === undefined ? 0.5 : weight;
- const w = 2 * p - 1;
- const a = color1.alpha() - color2.alpha();
- const w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2;
- const w2 = 1 - w1;
- return Color.rgb(
- w1 * color1.red() + w2 * color2.red(),
- w1 * color1.green() + w2 * color2.green(),
- w1 * color1.blue() + w2 * color2.blue(),
- color1.alpha() * p + color2.alpha() * (1 - p));
- },
- };
- // Model conversion methods and static constructors
- for (const model of Object.keys(colorConvert)) {
- if (skippedModels.includes(model)) {
- continue;
- }
- const {channels} = colorConvert[model];
- // Conversion methods
- Color.prototype[model] = function (...args) {
- if (this.model === model) {
- return new Color(this);
- }
- if (args.length > 0) {
- return new Color(args, model);
- }
- return new Color([...assertArray(colorConvert[this.model][model].raw(this.color)), this.valpha], model);
- };
- // 'static' construction methods
- Color[model] = function (...args) {
- let color = args[0];
- if (typeof color === 'number') {
- color = zeroArray(args, channels);
- }
- return new Color(color, model);
- };
- }
- function roundTo(number, places) {
- return Number(number.toFixed(places));
- }
- function roundToPlace(places) {
- return function (number) {
- return roundTo(number, places);
- };
- }
- function getset(model, channel, modifier) {
- model = Array.isArray(model) ? model : [model];
- for (const m of model) {
- (limiters[m] || (limiters[m] = []))[channel] = modifier;
- }
- model = model[0];
- return function (value) {
- let result;
- if (value !== undefined) {
- if (modifier) {
- value = modifier(value);
- }
- result = this[model]();
- result.color[channel] = value;
- return result;
- }
- result = this[model]().color[channel];
- if (modifier) {
- result = modifier(result);
- }
- return result;
- };
- }
- function maxfn(max) {
- return function (v) {
- return Math.max(0, Math.min(max, v));
- };
- }
- function assertArray(value) {
- return Array.isArray(value) ? value : [value];
- }
- function zeroArray(array, length) {
- for (let i = 0; i < length; i++) {
- if (typeof array[i] !== 'number') {
- array[i] = 0;
- }
- }
- return array;
- }
- var color = Color;
- const CSS$G = {
- container: "container",
- controlSection: "control-section",
- hexOptions: "color-hex-options",
- section: "section",
- header: "header",
- control: "control",
- splitSection: "section--split",
- colorModeContainer: "color-mode-container",
- colorMode: "color-mode",
- channels: "channels",
- channel: "channel",
- savedColors: "saved-colors",
- savedColorsSection: "saved-colors-section",
- saveColor: "save-color",
- deleteColor: "delete-color",
- savedColorsButtons: "saved-colors-buttons",
- headerHex: "header--hex",
- colorFieldAndSlider: "color-field-and-slider",
- colorFieldAndSliderInteractive: "color-field-and-slider--interactive",
- colorFieldAndSliderWrap: "color-field-and-slider-wrap",
- scope: "scope",
- hueScope: "scope--hue",
- colorFieldScope: "scope--color-field",
- savedColor: "saved-color"
- };
- const DEFAULT_COLOR$1 = color("#007AC2");
- const DEFAULT_STORAGE_KEY_PREFIX = "calcite-color-";
- const RGB_LIMITS = {
- r: 255,
- g: 255,
- b: 255
- };
- const HSV_LIMITS = {
- h: 360,
- s: 100,
- v: 100
- };
- const TEXT$h = {
- b: "B",
- blue: "Blue",
- deleteColor: "Delete color",
- g: "G",
- green: "Green",
- h: "H",
- hsv: "HSV",
- hex: "Hex",
- hue: "Hue",
- noColor: "No color",
- r: "R",
- red: "Red",
- rgb: "RGB",
- s: "S",
- saturation: "Saturation",
- saveColor: "Save color",
- saved: "Saved",
- v: "V",
- value: "Value"
- };
- const DIMENSIONS = {
- s: {
- slider: {
- height: 10,
- width: 160
- },
- colorField: {
- height: 80,
- width: 160
- },
- thumb: {
- radius: 8
- }
- },
- m: {
- slider: {
- height: 14,
- width: 272
- },
- colorField: {
- height: 150,
- width: 272
- },
- thumb: {
- radius: 10
- }
- },
- l: {
- slider: {
- height: 16,
- width: 464
- },
- colorField: {
- height: 200,
- width: 464
- },
- thumb: {
- radius: 12
- }
- }
- };
- const clamp = (value, min, max) => Math.max(min, Math.min(value, max));
- const decimalPlaces = (value) => {
- const match = ("" + value).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
- if (!match) {
- return 0;
- }
- return Math.max(0,
- // Number of digits right of decimal point.
- (match[1] ? match[1].length : 0) -
- // Adjust for scientific notation.
- (match[2] ? +match[2] : 0));
- };
- const colorPickerCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:inline-block;font-size:var(--calcite-font-size--2);line-height:1rem;font-weight:var(--calcite-font-weight-normal)}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host([scale=s]) .container{width:160px}:host([scale=s]) .saved-colors{grid-template-columns:repeat(auto-fill, minmax(20px, 1fr))}:host([scale=s]) .channels{-ms-flex-direction:column;flex-direction:column}:host([scale=s]) .channel{width:100%;margin-bottom:4px}:host([scale=s]) .channel:last-child{margin-bottom:0}:host([scale=m]) .container{width:272px}:host([scale=l]) .header{padding-bottom:0px}:host([scale=l]){font-size:var(--calcite-font-size--1);line-height:1rem}:host([scale=l]) .container{width:464px}:host([scale=l]) .color-field-and-slider{margin-bottom:-20px}:host([scale=l]) .section{padding:0 16px 16px}:host([scale=l]) .section:first-of-type{padding-top:16px}:host([scale=l]) .saved-colors{grid-template-columns:repeat(auto-fill, minmax(28px, 1fr));grid-gap:12px;padding-top:16px}:host([scale=l]) .control-section{-ms-flex-wrap:nowrap;flex-wrap:nowrap;-ms-flex-align:baseline;align-items:baseline}:host([scale=l]) .control-section>:nth-child(2){-webkit-margin-start:12px;margin-inline-start:12px}:host([scale=l]) .color-hex-options{display:-ms-flexbox;display:flex;-ms-flex-negative:1;flex-shrink:1;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:distribute;justify-content:space-around;min-height:98px;width:160px}:host([scale=l]) .color-mode-container{-ms-flex-negative:3;flex-shrink:3}:host([appearance=minimal]) .container{border:none}.container{background-color:var(--calcite-ui-foreground-1);display:inline-block;border:1px solid var(--calcite-ui-border-1)}.color-field-and-slider-wrap{position:relative}.scope{pointer-events:none;position:absolute;font-size:var(--calcite-font-size--1);outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;outline-offset:14px}.scope:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:16px}.color-field-and-slider{margin-bottom:-16px}.color-field-and-slider--interactive{cursor:pointer}.control-section{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:wrap;flex-wrap:wrap}.section{padding:0 12px 12px}.section:first-of-type{padding-top:12px}.color-hex-options,.section--split{-ms-flex-positive:1;flex-grow:1}.header{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:justify;justify-content:space-between;padding-bottom:0.25rem;color:var(--calcite-ui-text-1)}.header--hex,.color-mode-container{padding-top:12px}.channels{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between}.channel{width:31%}.saved-colors{padding-top:12px;display:grid;grid-template-columns:repeat(auto-fill, minmax(24px, 1fr));grid-gap:8px;width:100%}.saved-colors-buttons{display:-ms-flexbox;display:flex}.saved-color{outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;cursor:pointer}.saved-color:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:2px}.saved-color:hover{-webkit-transition:outline-color var(--calcite-internal-animation-timing-fast) ease-in-out;transition:outline-color var(--calcite-internal-animation-timing-fast) ease-in-out;outline:2px solid var(--calcite-ui-border-2);outline-offset:2px}";
- const throttleFor60FpsInMs = 16;
- const defaultValue = normalizeHex(DEFAULT_COLOR$1.hex());
- const defaultFormat = "auto";
- const ColorPicker = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteColorPickerChange = createEvent(this, "calciteColorPickerChange", 7);
- this.calciteColorPickerInput = createEvent(this, "calciteColorPickerInput", 7);
- //--------------------------------------------------------------------------
- //
- // Public properties
- //
- //--------------------------------------------------------------------------
- /**
- * When false, empty color (null) will be allowed as a value. Otherwise, a color value is always enforced by the component.
- *
- * When true, clearing the input and blurring will restore the last valid color set. When false, it will set it to empty.
- */
- this.allowEmpty = false;
- /** specify the appearance - default (containing border), or minimal (no containing border) */
- this.appearance = "default";
- /**
- * Internal prop for advanced use-cases.
- *
- * @internal
- */
- this.color = DEFAULT_COLOR$1;
- /**
- * When true, disabled prevents user interaction.
- */
- this.disabled = false;
- /**
- * The format of the value property.
- *
- * When "auto", the format will be inferred from `value` when set.
- * @default "auto"
- */
- this.format = defaultFormat;
- /** When true, hides the hex input */
- this.hideHex = false;
- /** When true, hides the RGB/HSV channel inputs */
- this.hideChannels = false;
- /** When true, hides the saved colors section */
- this.hideSaved = false;
- /** Label used for the blue channel
- * @default "B"
- */
- this.intlB = TEXT$h.b;
- /** Label used for the blue channel description
- * @default "Blue"
- */
- this.intlBlue = TEXT$h.blue;
- /** Label used for the delete color button.
- * @default "Delete color"
- */
- this.intlDeleteColor = TEXT$h.deleteColor;
- /** Label used for the green channel
- * @default "G"
- */
- this.intlG = TEXT$h.g;
- /** Label used for the green channel description
- * @default "Green"
- */
- this.intlGreen = TEXT$h.green;
- /** Label used for the hue channel
- * @default "H"
- */
- this.intlH = TEXT$h.h;
- /** Label used for the HSV mode
- * @default "HSV"
- */
- this.intlHsv = TEXT$h.hsv;
- /** Label used for the hex input
- * @default "Hex"
- */
- this.intlHex = TEXT$h.hex;
- /** Label used for the hue channel description
- * @default "Hue"
- */
- this.intlHue = TEXT$h.hue;
- /**
- * Label used for the hex input when there is no color selected.
- * @default "No color"
- */
- this.intlNoColor = TEXT$h.noColor;
- /** Label used for the red channel
- * @default "R"
- */
- this.intlR = TEXT$h.r;
- /** Label used for the red channel description
- * @default "Red"
- */
- this.intlRed = TEXT$h.red;
- /** Label used for the RGB mode
- * @default "RGB"
- */
- this.intlRgb = TEXT$h.rgb;
- /** Label used for the saturation channel
- * @default "S"
- */
- this.intlS = TEXT$h.s;
- /** Label used for the saturation channel description
- * @default "Saturation"
- */
- this.intlSaturation = TEXT$h.saturation;
- /** Label used for the save color button.
- * @default "Save color"
- */
- this.intlSaveColor = TEXT$h.saveColor;
- /** Label used for the saved colors section
- * @default "Saved"
- */
- this.intlSaved = TEXT$h.saved;
- /** Label used for the value channel
- * @default "V"
- */
- this.intlV = TEXT$h.v;
- /** Label used for the
- * @default "Value"
- */
- this.intlValue = TEXT$h.value;
- /**
- * The scale of the color picker.
- */
- this.scale = "m";
- /**
- * The color value.
- *
- * This value can be either a {@link https://developer.mozilla.org/en-US/docs/Web/CSS/color|CSS string}
- * a RGB, HSL or HSV object.
- *
- * The type will be preserved as the color is updated.
- * @default "#007ac2"
- * @see [ColorValue](https://github.com/Esri/calcite-components/blob/master/src/components/color-picker/interfaces.ts#L10)
- */
- this.value = defaultValue;
- this.colorFieldAndSliderHovered = false;
- this.hueThumbState = "idle";
- this.internalColorUpdateContext = null;
- this.mode = CSSColorMode.HEX;
- this.shiftKeyChannelAdjustment = 0;
- this.sliderThumbState = "idle";
- this.colorFieldAndSliderInteractive = false;
- this.channelMode = "rgb";
- this.channels = this.toChannels(DEFAULT_COLOR$1);
- this.dimensions = DIMENSIONS.m;
- this.savedColors = [];
- this.handleTabActivate = (event) => {
- this.channelMode = event.currentTarget.getAttribute("data-color-mode");
- this.updateChannelsFromColor(this.color);
- };
- this.handleColorFieldScopeKeyDown = (event) => {
- const key = event.key;
- const arrowKeyToXYOffset = {
- ArrowUp: { x: 0, y: -10 },
- ArrowRight: { x: 10, y: 0 },
- ArrowDown: { x: 0, y: 10 },
- ArrowLeft: { x: -10, y: 0 }
- };
- if (arrowKeyToXYOffset[key]) {
- event.preventDefault();
- this.scopeOrientation = key === "ArrowDown" || key === "ArrowUp" ? "vertical" : "horizontal";
- this.captureColorFieldColor(this.colorFieldScopeLeft + arrowKeyToXYOffset[key].x || 0, this.colorFieldScopeTop + arrowKeyToXYOffset[key].y || 0, false);
- }
- };
- this.handleHueScopeKeyDown = (event) => {
- const modifier = event.shiftKey ? 10 : 1;
- const key = event.key;
- const arrowKeyToXOffset = {
- ArrowUp: 1,
- ArrowRight: 1,
- ArrowDown: -1,
- ArrowLeft: -1
- };
- if (arrowKeyToXOffset[key]) {
- event.preventDefault();
- const delta = arrowKeyToXOffset[key] * modifier;
- const hue = this.baseColorFieldColor.hue();
- const color = this.baseColorFieldColor.hue(hue + delta);
- this.internalColorSet(color, false);
- }
- };
- this.handleHexInputChange = (event) => {
- event.stopPropagation();
- const { allowEmpty, color: color$1 } = this;
- const input = event.target;
- const hex = input.value;
- if (allowEmpty && !hex) {
- this.internalColorSet(null);
- return;
- }
- const normalizedHex = color$1 && normalizeHex(color$1.hex());
- if (hex !== normalizedHex) {
- this.internalColorSet(color(hex));
- }
- };
- this.handleSavedColorSelect = (event) => {
- const swatch = event.currentTarget;
- this.internalColorSet(color(swatch.color));
- };
- this.handleChannelInput = (event) => {
- const input = event.currentTarget;
- const internalInput = event.detail.nativeEvent.target;
- const channelIndex = Number(input.getAttribute("data-channel-index"));
- const limit = this.channelMode === "rgb"
- ? RGB_LIMITS[Object.keys(RGB_LIMITS)[channelIndex]]
- : HSV_LIMITS[Object.keys(HSV_LIMITS)[channelIndex]];
- let inputValue;
- if (this.allowEmpty && !input.value) {
- inputValue = "";
- }
- else {
- const value = Number(input.value) + this.shiftKeyChannelAdjustment;
- const clamped = clamp(value, 0, limit);
- inputValue = clamped.toString();
- }
- input.value = inputValue;
- internalInput.value = inputValue;
- };
- this.handleChannelChange = (event) => {
- const input = event.currentTarget;
- const channelIndex = Number(input.getAttribute("data-channel-index"));
- const channels = [...this.channels];
- const shouldClearChannels = this.allowEmpty && !input.value;
- if (shouldClearChannels) {
- this.channels = [null, null, null];
- this.internalColorSet(null);
- return;
- }
- channels[channelIndex] = Number(input.value);
- this.updateColorFromChannels(channels);
- };
- this.handleSavedColorKeyDown = (event) => {
- if (event.key === " " || event.key === "Enter") {
- event.preventDefault();
- event.stopPropagation();
- this.handleSavedColorSelect(event);
- }
- };
- this.handleColorFieldAndSliderMouseLeave = () => {
- this.colorFieldAndSliderInteractive = false;
- this.colorFieldAndSliderHovered = false;
- if (this.sliderThumbState !== "drag" && this.hueThumbState !== "drag") {
- this.hueThumbState = "idle";
- this.sliderThumbState = "idle";
- this.drawColorFieldAndSlider();
- }
- };
- this.handleColorFieldAndSliderMouseDown = (event) => {
- const { offsetX, offsetY } = event;
- const region = this.getCanvasRegion(offsetY);
- if (region === "color-field") {
- this.hueThumbState = "drag";
- this.captureColorFieldColor(offsetX, offsetY);
- this.colorFieldScopeNode.focus();
- }
- else if (region === "slider") {
- this.sliderThumbState = "drag";
- this.captureHueSliderColor(offsetX);
- this.hueScopeNode.focus();
- }
- // prevent text selection outside of color field & slider area
- event.preventDefault();
- document.addEventListener("mousemove", this.globalMouseMoveHandler);
- document.addEventListener("mouseup", this.globalMouseUpHandler, { once: true });
- this.activeColorFieldAndSliderRect =
- this.fieldAndSliderRenderingContext.canvas.getBoundingClientRect();
- };
- this.globalMouseUpHandler = () => {
- const previouslyDragging = this.sliderThumbState === "drag" || this.hueThumbState === "drag";
- this.hueThumbState = "idle";
- this.sliderThumbState = "idle";
- this.activeColorFieldAndSliderRect = null;
- this.drawColorFieldAndSlider();
- if (previouslyDragging) {
- this.calciteColorPickerChange.emit();
- }
- };
- this.globalMouseMoveHandler = (event) => {
- const { el, dimensions } = this;
- const sliderThumbDragging = this.sliderThumbState === "drag";
- const hueThumbDragging = this.hueThumbState === "drag";
- if (!el.isConnected || (!sliderThumbDragging && !hueThumbDragging)) {
- return;
- }
- let samplingX;
- let samplingY;
- const colorFieldAndSliderRect = this.activeColorFieldAndSliderRect;
- const { clientX, clientY } = event;
- if (this.colorFieldAndSliderHovered) {
- samplingX = clientX - colorFieldAndSliderRect.x;
- samplingY = clientY - colorFieldAndSliderRect.y;
- }
- else {
- const colorFieldWidth = dimensions.colorField.width;
- const colorFieldHeight = dimensions.colorField.height;
- const hueSliderHeight = dimensions.slider.height;
- if (clientX < colorFieldAndSliderRect.x + colorFieldWidth &&
- clientX > colorFieldAndSliderRect.x) {
- samplingX = clientX - colorFieldAndSliderRect.x;
- }
- else if (clientX < colorFieldAndSliderRect.x) {
- samplingX = 0;
- }
- else {
- samplingX = colorFieldWidth;
- }
- if (clientY < colorFieldAndSliderRect.y + colorFieldHeight + hueSliderHeight &&
- clientY > colorFieldAndSliderRect.y) {
- samplingY = clientY - colorFieldAndSliderRect.y;
- }
- else if (clientY < colorFieldAndSliderRect.y) {
- samplingY = 0;
- }
- else {
- samplingY = colorFieldHeight + hueSliderHeight;
- }
- }
- if (hueThumbDragging) {
- this.captureColorFieldColor(samplingX, samplingY, false);
- }
- else {
- this.captureHueSliderColor(samplingX);
- }
- };
- this.handleColorFieldAndSliderMouseEnterOrMove = ({ offsetX, offsetY }) => {
- const { dimensions: { colorField, slider, thumb } } = this;
- this.colorFieldAndSliderInteractive = offsetY <= colorField.height + slider.height;
- this.colorFieldAndSliderHovered = true;
- const region = this.getCanvasRegion(offsetY);
- if (region === "color-field") {
- const prevHueThumbState = this.hueThumbState;
- const color = this.baseColorFieldColor.hsv();
- const centerX = Math.round(color.saturationv() / (HSV_LIMITS.s / colorField.width));
- const centerY = Math.round(colorField.height - color.value() / (HSV_LIMITS.v / colorField.height));
- const hoveringThumb = this.containsPoint(offsetX, offsetY, centerX, centerY, thumb.radius);
- let transitionedBetweenHoverAndIdle = false;
- if (prevHueThumbState === "idle" && hoveringThumb) {
- this.hueThumbState = "hover";
- transitionedBetweenHoverAndIdle = true;
- }
- else if (prevHueThumbState === "hover" && !hoveringThumb) {
- this.hueThumbState = "idle";
- transitionedBetweenHoverAndIdle = true;
- }
- if (this.hueThumbState !== "drag") {
- if (transitionedBetweenHoverAndIdle) {
- // refresh since we won't update color and thus no redraw
- this.drawColorFieldAndSlider();
- }
- }
- }
- else if (region === "slider") {
- const sliderThumbColor = this.baseColorFieldColor.hsv().saturationv(100).value(100);
- const prevSliderThumbState = this.sliderThumbState;
- const sliderThumbCenterX = Math.round(sliderThumbColor.hue() / (360 / slider.width));
- const sliderThumbCenterY = Math.round((slider.height + this.getSliderCapSpacing()) / 2) + colorField.height;
- const hoveringSliderThumb = this.containsPoint(offsetX, offsetY, sliderThumbCenterX, sliderThumbCenterY, thumb.radius);
- let sliderThumbTransitionedBetweenHoverAndIdle = false;
- if (prevSliderThumbState === "idle" && hoveringSliderThumb) {
- this.sliderThumbState = "hover";
- sliderThumbTransitionedBetweenHoverAndIdle = true;
- }
- else if (prevSliderThumbState === "hover" && !hoveringSliderThumb) {
- this.sliderThumbState = "idle";
- sliderThumbTransitionedBetweenHoverAndIdle = true;
- }
- if (this.sliderThumbState !== "drag") {
- if (sliderThumbTransitionedBetweenHoverAndIdle) {
- // refresh since we won't update color and thus no redraw
- this.drawColorFieldAndSlider();
- }
- }
- }
- };
- this.storeColorFieldScope = (node) => {
- this.colorFieldScopeNode = node;
- };
- this.storeHueScope = (node) => {
- this.hueScopeNode = node;
- };
- this.renderChannelsTabTitle = (channelMode) => {
- const { channelMode: activeChannelMode, intlRgb, intlHsv } = this;
- const active = channelMode === activeChannelMode;
- const label = channelMode === "rgb" ? intlRgb : intlHsv;
- return (h("calcite-tab-title", { active: active, class: CSS$G.colorMode, "data-color-mode": channelMode, key: channelMode, onCalciteTabsActivate: this.handleTabActivate }, label));
- };
- this.renderChannelsTab = (channelMode) => {
- const { channelMode: activeChannelMode, channels, intlB, intlBlue, intlG, intlGreen, intlH, intlHue, intlR, intlRed, intlS, intlSaturation, intlV, intlValue } = this;
- const active = channelMode === activeChannelMode;
- const isRgb = channelMode === "rgb";
- const channelLabels = isRgb ? [intlR, intlG, intlB] : [intlH, intlS, intlV];
- const channelAriaLabels = isRgb
- ? [intlRed, intlGreen, intlBlue]
- : [intlHue, intlSaturation, intlValue];
- const direction = getElementDir(this.el);
- return (h("calcite-tab", { active: active, class: CSS$G.control, key: channelMode }, h("div", { class: CSS$G.channels, dir: "ltr" }, channels.map((channel, index) =>
- /* the channel container is ltr, so we apply the host's direction */
- this.renderChannel(channel, index, channelLabels[index], channelAriaLabels[index], direction)))));
- };
- this.renderChannel = (value, index, label, ariaLabel, direction) => (h("calcite-input", { class: CSS$G.channel, "data-channel-index": index, dir: direction, label: ariaLabel, numberButtonType: "none", onCalciteInputChange: this.handleChannelChange, onCalciteInputInput: this.handleChannelInput, onKeyDown: this.handleKeyDown, prefixText: label, scale: this.scale === "l" ? "m" : "s", type: "number", value: value === null || value === void 0 ? void 0 : value.toString() }));
- this.deleteColor = () => {
- const colorToDelete = this.color.hex();
- const inStorage = this.savedColors.indexOf(colorToDelete) > -1;
- if (!inStorage) {
- return;
- }
- const savedColors = this.savedColors.filter((color) => color !== colorToDelete);
- this.savedColors = savedColors;
- const storageKey = `${DEFAULT_STORAGE_KEY_PREFIX}${this.storageId}`;
- if (this.storageId) {
- localStorage.setItem(storageKey, JSON.stringify(savedColors));
- }
- };
- this.saveColor = () => {
- const colorToSave = this.color.hex();
- const alreadySaved = this.savedColors.indexOf(colorToSave) > -1;
- if (alreadySaved) {
- return;
- }
- const savedColors = [...this.savedColors, colorToSave];
- this.savedColors = savedColors;
- const storageKey = `${DEFAULT_STORAGE_KEY_PREFIX}${this.storageId}`;
- if (this.storageId) {
- localStorage.setItem(storageKey, JSON.stringify(savedColors));
- }
- };
- this.drawColorFieldAndSlider = throttle$1(() => {
- if (!this.fieldAndSliderRenderingContext) {
- return;
- }
- this.drawColorField();
- this.drawHueSlider();
- }, throttleFor60FpsInMs);
- this.captureColorFieldColor = (x, y, skipEqual = true) => {
- const { dimensions: { colorField: { height, width } } } = this;
- const saturation = Math.round((HSV_LIMITS.s / width) * x);
- const value = Math.round((HSV_LIMITS.v / height) * (height - y));
- this.internalColorSet(this.baseColorFieldColor.hsv().saturationv(saturation).value(value), skipEqual);
- };
- this.initColorFieldAndSlider = (canvas) => {
- this.fieldAndSliderRenderingContext = canvas.getContext("2d");
- this.setCanvasContextSize(canvas, {
- width: this.dimensions.colorField.width,
- height: this.dimensions.colorField.height +
- this.dimensions.slider.height +
- this.getSliderCapSpacing() * 2
- });
- this.drawColorFieldAndSlider();
- };
- }
- handleColorChange(color, oldColor) {
- this.drawColorFieldAndSlider();
- this.updateChannelsFromColor(color);
- this.previousColor = oldColor;
- }
- handleFormatChange(format) {
- this.setMode(format);
- this.internalColorSet(this.color, false, "internal");
- }
- handleScaleChange(scale = "m") {
- this.updateDimensions(scale);
- }
- handleValueChange(value, oldValue) {
- const { allowEmpty, format } = this;
- const checkMode = !allowEmpty || value;
- let modeChanged = false;
- if (checkMode) {
- const nextMode = parseMode(value);
- if (!nextMode || (format !== "auto" && nextMode !== format)) {
- this.showIncompatibleColorWarning(value, format);
- this.value = oldValue;
- return;
- }
- modeChanged = this.mode !== nextMode;
- this.setMode(nextMode);
- }
- const dragging = this.sliderThumbState === "drag" || this.hueThumbState === "drag";
- if (this.internalColorUpdateContext === "initial") {
- return;
- }
- if (this.internalColorUpdateContext === "user-interaction") {
- this.calciteColorPickerInput.emit();
- if (!dragging) {
- this.calciteColorPickerChange.emit();
- }
- return;
- }
- const color$1 = allowEmpty && !value ? null : color(value);
- const colorChanged = !colorEqual(color$1, this.color);
- if (modeChanged || colorChanged) {
- this.internalColorSet(color$1, true, "internal");
- }
- }
- //--------------------------------------------------------------------------
- //
- // Internal State/Props
- //
- //--------------------------------------------------------------------------
- get baseColorFieldColor() {
- return this.color || this.previousColor || DEFAULT_COLOR$1;
- }
- // using @Listen as a workaround for VDOM listener not firing
- handleChannelKeyUpOrDown(event) {
- this.shiftKeyChannelAdjustment = 0;
- const key = event.key;
- if ((key !== "ArrowUp" && key !== "ArrowDown") ||
- !event.composedPath().some((node) => { var _a; return (_a = node.classList) === null || _a === void 0 ? void 0 : _a.contains(CSS$G.channel); })) {
- return;
- }
- const { shiftKey } = event;
- event.preventDefault();
- if (!this.color) {
- this.internalColorSet(this.previousColor);
- event.stopPropagation();
- return;
- }
- // this gets applied to the input's up/down arrow increment/decrement
- const complementaryBump = 9;
- this.shiftKeyChannelAdjustment =
- key === "ArrowUp" && shiftKey
- ? complementaryBump
- : key === "ArrowDown" && shiftKey
- ? -complementaryBump
- : 0;
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- return focusElement(this.colorFieldScopeNode);
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentWillLoad() {
- const { allowEmpty, color: color$1, format, value } = this;
- const willSetNoColor = allowEmpty && !value;
- const parsedMode = parseMode(value);
- const valueIsCompatible = willSetNoColor || (format === "auto" && parsedMode) || format === parsedMode;
- const initialColor = willSetNoColor ? null : valueIsCompatible ? color(value) : color$1;
- if (!valueIsCompatible) {
- this.showIncompatibleColorWarning(value, format);
- }
- this.setMode(format);
- this.internalColorSet(initialColor, false, "initial");
- this.updateDimensions(this.scale);
- const storageKey = `${DEFAULT_STORAGE_KEY_PREFIX}${this.storageId}`;
- if (this.storageId && localStorage.getItem(storageKey)) {
- this.savedColors = JSON.parse(localStorage.getItem(storageKey));
- }
- }
- disconnectedCallback() {
- document.removeEventListener("mousemove", this.globalMouseMoveHandler);
- document.removeEventListener("mouseup", this.globalMouseUpHandler);
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- //--------------------------------------------------------------------------
- //
- // Render Methods
- //
- //--------------------------------------------------------------------------
- render() {
- const { allowEmpty, color, intlDeleteColor, hideHex, hideChannels, hideSaved, intlHex, intlSaved, intlSaveColor, savedColors, scale } = this;
- const selectedColorInHex = color ? color.hex() : null;
- const hexInputScale = scale === "l" ? "m" : "s";
- const { colorFieldAndSliderInteractive, colorFieldScopeTop, colorFieldScopeLeft, hueScopeLeft, hueScopeTop, scopeOrientation, dimensions: { colorField: { height: colorFieldHeight, width: colorFieldWidth }, slider: { height: sliderHeight } } } = this;
- const hueTop = hueScopeTop !== null && hueScopeTop !== void 0 ? hueScopeTop : sliderHeight / 2 + colorFieldHeight;
- const hueLeft = hueScopeLeft !== null && hueScopeLeft !== void 0 ? hueScopeLeft : (colorFieldWidth * DEFAULT_COLOR$1.hue()) / HSV_LIMITS.h;
- const noColor = color === null;
- const vertical = scopeOrientation === "vertical";
- return (h("div", { class: CSS$G.container }, h("div", { class: CSS$G.colorFieldAndSliderWrap }, h("canvas", { class: {
- [CSS$G.colorFieldAndSlider]: true,
- [CSS$G.colorFieldAndSliderInteractive]: colorFieldAndSliderInteractive
- }, onMouseDown: this.handleColorFieldAndSliderMouseDown, onMouseEnter: this.handleColorFieldAndSliderMouseEnterOrMove, onMouseLeave: this.handleColorFieldAndSliderMouseLeave, onMouseMove: this.handleColorFieldAndSliderMouseEnterOrMove, ref: this.initColorFieldAndSlider }), h("div", { "aria-label": vertical ? this.intlValue : this.intlSaturation, "aria-valuemax": vertical ? HSV_LIMITS.v : HSV_LIMITS.s, "aria-valuemin": "0", "aria-valuenow": (vertical ? color === null || color === void 0 ? void 0 : color.saturationv() : color === null || color === void 0 ? void 0 : color.value()) || "0", class: { [CSS$G.scope]: true, [CSS$G.colorFieldScope]: true }, onKeyDown: this.handleColorFieldScopeKeyDown, ref: this.storeColorFieldScope, role: "slider", style: { top: `${colorFieldScopeTop || 0}px`, left: `${colorFieldScopeLeft || 0}px` }, tabindex: "0" }), h("div", { "aria-label": this.intlHue, "aria-valuemax": HSV_LIMITS.h, "aria-valuemin": "0", "aria-valuenow": (color === null || color === void 0 ? void 0 : color.round().hue()) || DEFAULT_COLOR$1.round().hue(), class: { [CSS$G.scope]: true, [CSS$G.hueScope]: true }, onKeyDown: this.handleHueScopeKeyDown, ref: this.storeHueScope, role: "slider", style: { top: `${hueTop}px`, left: `${hueLeft}px` }, tabindex: "0" })), hideHex && hideChannels ? null : (h("div", { class: {
- [CSS$G.controlSection]: true,
- [CSS$G.section]: true
- } }, hideHex ? null : (h("div", { class: CSS$G.hexOptions }, h("span", { class: {
- [CSS$G.header]: true,
- [CSS$G.headerHex]: true
- } }, intlHex), h("calcite-color-picker-hex-input", { allowEmpty: allowEmpty, class: CSS$G.control, onCalciteColorPickerHexInputChange: this.handleHexInputChange, scale: hexInputScale, value: selectedColorInHex }))), hideChannels ? null : (h("calcite-tabs", { class: {
- [CSS$G.colorModeContainer]: true,
- [CSS$G.splitSection]: true
- }, scale: hexInputScale }, h("calcite-tab-nav", { slot: "tab-nav" }, this.renderChannelsTabTitle("rgb"), this.renderChannelsTabTitle("hsv")), this.renderChannelsTab("rgb"), this.renderChannelsTab("hsv"))))), hideSaved ? null : (h("div", { class: { [CSS$G.savedColorsSection]: true, [CSS$G.section]: true } }, h("div", { class: CSS$G.header }, h("label", null, intlSaved), h("div", { class: CSS$G.savedColorsButtons }, h("calcite-button", { appearance: "transparent", class: CSS$G.deleteColor, color: "neutral", disabled: noColor, iconStart: "minus", label: intlDeleteColor, onClick: this.deleteColor, scale: hexInputScale, type: "button" }), h("calcite-button", { appearance: "transparent", class: CSS$G.saveColor, color: "neutral", disabled: noColor, iconStart: "plus", label: intlSaveColor, onClick: this.saveColor, scale: hexInputScale, type: "button" }))), savedColors.length > 0 ? (h("div", { class: CSS$G.savedColors }, [
- ...savedColors.map((color) => (h("calcite-color-picker-swatch", { active: selectedColorInHex === color, class: CSS$G.savedColor, color: color, key: color, onClick: this.handleSavedColorSelect, onKeyDown: this.handleSavedColorKeyDown, scale: scale, tabIndex: 0 })))
- ])) : null))));
- }
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- handleKeyDown(event) {
- if (event.key === "Enter") {
- event.preventDefault();
- }
- }
- showIncompatibleColorWarning(value, format) {
- console.warn(`ignoring color value (${value}) as it is not compatible with the current format (${format})`);
- }
- setMode(format) {
- this.mode = format === "auto" ? this.mode : format;
- }
- captureHueSliderColor(x) {
- const { dimensions: { slider: { width } } } = this;
- const hue = (360 / width) * x;
- this.internalColorSet(this.baseColorFieldColor.hue(hue), false);
- }
- getCanvasRegion(y) {
- const { dimensions: { colorField: { height: colorFieldHeight }, slider: { height: sliderHeight } } } = this;
- if (y <= colorFieldHeight) {
- return "color-field";
- }
- if (y <= colorFieldHeight + sliderHeight) {
- return "slider";
- }
- return "none";
- }
- internalColorSet(color, skipEqual = true, context = "user-interaction") {
- if (skipEqual && colorEqual(color, this.color)) {
- return;
- }
- this.internalColorUpdateContext = context;
- this.color = color;
- this.value = this.toValue(color);
- this.internalColorUpdateContext = null;
- }
- toValue(color, format = this.mode) {
- if (!color) {
- return null;
- }
- const hexMode = "hex";
- if (format.includes(hexMode)) {
- return normalizeHex(color.round()[hexMode]());
- }
- if (format.includes("-css")) {
- return color[format.replace("-css", "").replace("a", "")]().round().string();
- }
- const colorObject = color[format]().round().object();
- if (format.endsWith("a")) {
- // normalize alpha prop
- colorObject.a = colorObject.alpha;
- delete colorObject.alpha;
- }
- return colorObject;
- }
- getSliderCapSpacing() {
- const { dimensions: { slider: { height }, thumb: { radius } } } = this;
- return radius * 2 - height;
- }
- updateDimensions(scale = "m") {
- this.dimensions = DIMENSIONS[scale];
- }
- drawColorField() {
- const context = this.fieldAndSliderRenderingContext;
- const { dimensions: { colorField: { height, width } } } = this;
- context.fillStyle = this.baseColorFieldColor.hsv().saturationv(100).value(100).string();
- context.fillRect(0, 0, width, height);
- const whiteGradient = context.createLinearGradient(0, 0, width, 0);
- whiteGradient.addColorStop(0, "rgba(255,255,255,1)");
- whiteGradient.addColorStop(1, "rgba(255,255,255,0)");
- context.fillStyle = whiteGradient;
- context.fillRect(0, 0, width, height);
- const blackGradient = context.createLinearGradient(0, 0, 0, height);
- blackGradient.addColorStop(0, "rgba(0,0,0,0)");
- blackGradient.addColorStop(1, "rgba(0,0,0,1)");
- context.fillStyle = blackGradient;
- context.fillRect(0, 0, width, height);
- this.drawActiveColorFieldColor();
- }
- setCanvasContextSize(canvas, { height, width }) {
- const devicePixelRatio = window.devicePixelRatio || 1;
- canvas.width = width * devicePixelRatio;
- canvas.height = height * devicePixelRatio;
- canvas.style.height = `${height}px`;
- canvas.style.width = `${width}px`;
- const context = canvas.getContext("2d");
- context.scale(devicePixelRatio, devicePixelRatio);
- }
- containsPoint(testPointX, testPointY, boundsX, boundsY, boundsRadius) {
- return (Math.pow(testPointX - boundsX, 2) + Math.pow(testPointY - boundsY, 2) <=
- Math.pow(boundsRadius, 2));
- }
- drawActiveColorFieldColor() {
- const { color } = this;
- if (!color) {
- return;
- }
- const hsvColor = color.hsv();
- const { dimensions: { colorField: { height, width }, thumb: { radius } } } = this;
- const x = hsvColor.saturationv() / (HSV_LIMITS.s / width);
- const y = height - hsvColor.value() / (HSV_LIMITS.v / height);
- requestAnimationFrame(() => {
- this.colorFieldScopeLeft = x;
- this.colorFieldScopeTop = y;
- });
- this.drawThumb(this.fieldAndSliderRenderingContext, radius, x, y, hsvColor, this.hueThumbState);
- }
- drawThumb(context, radius, x, y, color, state) {
- const startAngle = 0;
- const endAngle = 2 * Math.PI;
- context.beginPath();
- context.arc(x, y, radius, startAngle, endAngle);
- context.shadowBlur = state === "hover" ? 32 : 16;
- context.shadowColor = `rgba(0, 0, 0, ${state === "drag" ? 0.32 : 0.16})`;
- context.fillStyle = "#fff";
- context.fill();
- context.beginPath();
- context.arc(x, y, radius - 3, startAngle, endAngle);
- context.shadowBlur = 0;
- context.shadowColor = "transparent";
- context.fillStyle = color.rgb().string();
- context.fill();
- }
- drawActiveHueSliderColor() {
- const { color } = this;
- if (!color) {
- return;
- }
- const hsvColor = color.hsv().saturationv(100).value(100);
- const { dimensions: { colorField: { height: colorFieldHeight }, slider: { height, width }, thumb: { radius } } } = this;
- const x = hsvColor.hue() / (360 / width);
- const y = height / 2 + colorFieldHeight;
- requestAnimationFrame(() => {
- this.hueScopeLeft = x;
- this.hueScopeTop = y;
- });
- this.drawThumb(this.fieldAndSliderRenderingContext, radius, x, y, hsvColor, this.sliderThumbState);
- }
- drawHueSlider() {
- const context = this.fieldAndSliderRenderingContext;
- const { dimensions: { colorField: { height: colorFieldHeight }, slider: { height, width } } } = this;
- const gradient = context.createLinearGradient(0, 0, width, 0);
- const hueSliderColorStopKeywords = ["red", "yellow", "lime", "cyan", "blue", "magenta", "red"];
- const offset = 1 / (hueSliderColorStopKeywords.length - 1);
- let currentOffset = 0;
- hueSliderColorStopKeywords.forEach((keyword) => {
- gradient.addColorStop(currentOffset, color(keyword).string());
- currentOffset += offset;
- });
- context.fillStyle = gradient;
- context.clearRect(0, colorFieldHeight, width, height + this.getSliderCapSpacing() * 2);
- context.fillRect(0, colorFieldHeight, width, height);
- this.drawActiveHueSliderColor();
- }
- updateColorFromChannels(channels) {
- this.internalColorSet(color(channels, this.channelMode));
- }
- updateChannelsFromColor(color) {
- this.channels = color ? this.toChannels(color) : [null, null, null];
- }
- toChannels(color) {
- const { channelMode } = this;
- return color[channelMode]()
- .array()
- .map((value) => Math.floor(value));
- }
- get el() { return this; }
- static get watchers() { return {
- "color": ["handleColorChange"],
- "format": ["handleFormatChange"],
- "scale": ["handleScaleChange"],
- "value": ["handleValueChange"]
- }; }
- static get style() { return colorPickerCss; }
- };
- const CSS$F = {
- container: "container",
- preview: "preview",
- input: "input"
- };
- const colorPickerHexInputCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:block}.container{display:inline-grid;width:100%;-ms-flex-align:center;align-items:center;grid-template-columns:1fr auto}.preview{grid-column:2/3;pointer-events:none;margin-top:0px;margin-bottom:0px;margin-left:0.25rem;margin-right:0.25rem;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;z-index:1}.preview,.input{grid-row:1}.input{grid-column:1/3;width:100%;text-transform:uppercase}";
- const DEFAULT_COLOR = color();
- const ColorPickerHexInput = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteColorPickerHexInputChange = createEvent(this, "calciteColorPickerHexInputChange", 7);
- //--------------------------------------------------------------------------
- //
- // Public Properties
- //
- //--------------------------------------------------------------------------
- /**
- * When false, empty color (null) will be allowed as a value. Otherwise, a color value is always enforced by the component.
- *
- * When true, clearing the input and blurring will restore the last valid color set. When false, it will set it to empty.
- */
- this.allowEmpty = false;
- /**
- * Label used for the hex input.
- * @default "Hex"
- */
- this.intlHex = TEXT$h.hex;
- /**
- * Label used for the hex input when there is no color selected.
- * @default "No color"
- */
- this.intlNoColor = TEXT$h.noColor;
- /**
- * The component's scale.
- */
- this.scale = "m";
- /**
- * The hex value.
- */
- this.value = normalizeHex(DEFAULT_COLOR.hex());
- this.onCalciteInputBlur = () => {
- const node = this.inputNode;
- const inputValue = node.value;
- const hex = `#${inputValue}`;
- const willClearValue = this.allowEmpty && !inputValue;
- if (willClearValue || (isValidHex(hex) && isLonghandHex(hex))) {
- return;
- }
- // manipulating DOM directly since rerender doesn't update input value
- node.value =
- this.allowEmpty && !this.internalColor
- ? ""
- : this.formatForInternalInput(rgbToHex(this.internalColor.object()));
- };
- this.onInputChange = () => {
- this.internalSetValue(this.inputNode.value, this.value);
- };
- /**
- * The last valid/selected color. Used as a fallback if an invalid hex code is entered.
- */
- this.internalColor = DEFAULT_COLOR;
- this.previousNonNullValue = this.value;
- this.storeInputRef = (node) => {
- this.inputNode = node;
- };
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- const { allowEmpty, value } = this;
- if (value) {
- const normalized = normalizeHex(value);
- if (isValidHex(normalized)) {
- this.internalSetValue(normalized, normalized, false);
- }
- return;
- }
- if (allowEmpty) {
- this.internalSetValue(null, null, false);
- }
- }
- handleValueChange(value, oldValue) {
- this.internalSetValue(value, oldValue, false);
- }
- // using @Listen as a workaround for VDOM listener not firing
- onInputKeyDown(event) {
- const { altKey, ctrlKey, metaKey, shiftKey } = event;
- const { internalColor, value } = this;
- const key = event.key;
- if (key === "Tab" || key === "Enter") {
- this.onInputChange();
- return;
- }
- const isNudgeKey = key === "ArrowDown" || key === "ArrowUp";
- const oldValue = this.value;
- if (isNudgeKey) {
- if (!value) {
- this.internalSetValue(this.previousNonNullValue, oldValue);
- event.preventDefault();
- return;
- }
- const direction = key === "ArrowUp" ? 1 : -1;
- const bump = shiftKey ? 10 : 1;
- this.internalSetValue(normalizeHex(this.nudgeRGBChannels(internalColor, bump * direction).hex()), oldValue);
- event.preventDefault();
- return;
- }
- const withModifiers = altKey || ctrlKey || metaKey;
- const singleChar = key.length === 1;
- const validHexChar = hexChar.test(key);
- if (singleChar && !withModifiers && !validHexChar) {
- event.preventDefault();
- }
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- render() {
- const { intlHex, value } = this;
- const hexInputValue = this.formatForInternalInput(value);
- return (h("div", { class: CSS$F.container }, h("calcite-input", { class: CSS$F.input, label: intlHex, maxLength: 6, onCalciteInputBlur: this.onCalciteInputBlur, onCalciteInputChange: this.onInputChange, onKeyDown: this.handleKeyDown, prefixText: "#", ref: this.storeInputRef, scale: this.scale, value: hexInputValue }), hexInputValue ? (h("calcite-color-picker-swatch", { active: true, class: CSS$F.preview, color: `#${hexInputValue}`, scale: this.scale })) : null));
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- focusElement(this.inputNode);
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- internalSetValue(value, oldValue, emit = true) {
- if (value) {
- const normalized = normalizeHex(value);
- if (isValidHex(normalized)) {
- const { internalColor } = this;
- const changed = !internalColor || normalized !== normalizeHex(internalColor.hex());
- this.internalColor = color(normalized);
- this.previousNonNullValue = normalized;
- this.value = normalized;
- if (changed && emit) {
- this.calciteColorPickerHexInputChange.emit();
- }
- return;
- }
- }
- else if (this.allowEmpty) {
- this.internalColor = null;
- this.value = null;
- if (emit) {
- this.calciteColorPickerHexInputChange.emit();
- }
- return;
- }
- this.value = oldValue;
- }
- formatForInternalInput(hex) {
- return hex ? hex.replace("#", "") : "";
- }
- nudgeRGBChannels(color$1, amount) {
- return color.rgb(color$1.array().map((channel) => channel + amount));
- }
- handleKeyDown(event) {
- if (event.key === "Enter") {
- event.preventDefault();
- }
- }
- get el() { return this; }
- static get watchers() { return {
- "value": ["handleValueChange"]
- }; }
- static get style() { return colorPickerHexInputCss; }
- };
- const CSS$E = {
- swatch: "swatch",
- noColorIcon: "no-color-icon"
- };
- const COLORS = {
- borderLight: "rgba(0, 0, 0, 0.3)",
- borderDark: "rgba(255, 255, 255, 0.15)"
- };
- const colorPickerSwatchCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;display:-ms-inline-flexbox;display:inline-flex}:host([scale=s]){height:1.25rem;width:1.25rem}:host([scale=m]){height:1.5rem;width:1.5rem}:host([scale=l]){height:2rem;width:2rem}.swatch{overflow:visible;height:inherit;width:inherit}.swatch rect{-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}.no-color-icon{position:absolute;top:0px;right:0px;bottom:0px;left:0px;height:100%;width:100%}";
- const ColorPickerSwatch = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /**
- * Used to display whether the swatch is active or not.
- */
- this.active = false;
- /**
- * The component scale.
- */
- this.scale = "m";
- }
- handleColorChange(color$1) {
- this.internalColor = color(color$1);
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentWillLoad() {
- this.handleColorChange(this.color);
- }
- render() {
- const { active, el, internalColor } = this;
- const borderRadius = active ? "100%" : "0";
- const hex = internalColor.hex();
- const theme = getThemeName(el);
- const borderColor = theme === "light" ? COLORS.borderLight : COLORS.borderDark;
- return (h("svg", { class: CSS$E.swatch, xmlns: "http://www.w3.org/2000/svg" }, h("title", null, hex), h("rect", { fill: hex, height: "100%", id: "swatch", rx: borderRadius, stroke: borderColor, "stroke-width": "2", style: { "clip-path": `inset(0 round ${borderRadius})` }, width: "100%" })));
- }
- get el() { return this; }
- static get watchers() { return {
- "color": ["handleColorChange"]
- }; }
- static get style() { return colorPickerSwatchCss; }
- };
- const filter = (data, value) => {
- const escapedValue = escapeRegExp(value);
- const regex = new RegExp(escapedValue, "i");
- if (data.length === 0) {
- console.warn(`No data was passed to the filter function.
- The data argument should be an array of objects`);
- }
- const find = (input, RE) => {
- var _a;
- if ((_a = input) === null || _a === void 0 ? void 0 : _a.constant) {
- return true;
- }
- let found = false;
- forIn(input, (val) => {
- if (typeof val === "function" || val == null /* intentional == to catch undefined */) {
- return;
- }
- if (Array.isArray(val) || (typeof val === "object" && val !== null)) {
- if (find(val, RE)) {
- found = true;
- }
- }
- else if (RE.test(val)) {
- found = true;
- }
- });
- return found;
- };
- const result = data.filter((item) => {
- return find(item, regex);
- });
- return result;
- };
- var top = 'top';
- var bottom = 'bottom';
- var right = 'right';
- var left = 'left';
- var auto = 'auto';
- var basePlacements = [top, bottom, right, left];
- var start = 'start';
- var end = 'end';
- var clippingParents = 'clippingParents';
- var viewport = 'viewport';
- var popper = 'popper';
- var reference = 'reference';
- var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
- return acc.concat([placement + "-" + start, placement + "-" + end]);
- }, []);
- var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
- return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
- }, []); // modifiers that need to read the DOM
- var beforeRead = 'beforeRead';
- var read = 'read';
- var afterRead = 'afterRead'; // pure-logic modifiers
- var beforeMain = 'beforeMain';
- var main = 'main';
- var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
- var beforeWrite = 'beforeWrite';
- var write = 'write';
- var afterWrite = 'afterWrite';
- var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
- function getNodeName(element) {
- return element ? (element.nodeName || '').toLowerCase() : null;
- }
- function getWindow(node) {
- if (node == null) {
- return window;
- }
- if (node.toString() !== '[object Window]') {
- var ownerDocument = node.ownerDocument;
- return ownerDocument ? ownerDocument.defaultView || window : window;
- }
- return node;
- }
- function isElement(node) {
- var OwnElement = getWindow(node).Element;
- return node instanceof OwnElement || node instanceof Element;
- }
- function isHTMLElement(node) {
- var OwnElement = getWindow(node).HTMLElement;
- return node instanceof OwnElement || node instanceof HTMLElement;
- }
- function isShadowRoot(node) {
- // IE 11 has no ShadowRoot
- if (typeof ShadowRoot === 'undefined') {
- return false;
- }
- var OwnElement = getWindow(node).ShadowRoot;
- return node instanceof OwnElement || node instanceof ShadowRoot;
- }
- // and applies them to the HTMLElements such as popper and arrow
- function applyStyles(_ref) {
- var state = _ref.state;
- Object.keys(state.elements).forEach(function (name) {
- var style = state.styles[name] || {};
- var attributes = state.attributes[name] || {};
- var element = state.elements[name]; // arrow is optional + virtual elements
- if (!isHTMLElement(element) || !getNodeName(element)) {
- return;
- } // Flow doesn't support to extend this property, but it's the most
- // effective way to apply styles to an HTMLElement
- // $FlowFixMe[cannot-write]
- Object.assign(element.style, style);
- Object.keys(attributes).forEach(function (name) {
- var value = attributes[name];
- if (value === false) {
- element.removeAttribute(name);
- } else {
- element.setAttribute(name, value === true ? '' : value);
- }
- });
- });
- }
- function effect$2(_ref2) {
- var state = _ref2.state;
- var initialStyles = {
- popper: {
- position: state.options.strategy,
- left: '0',
- top: '0',
- margin: '0'
- },
- arrow: {
- position: 'absolute'
- },
- reference: {}
- };
- Object.assign(state.elements.popper.style, initialStyles.popper);
- state.styles = initialStyles;
- if (state.elements.arrow) {
- Object.assign(state.elements.arrow.style, initialStyles.arrow);
- }
- return function () {
- Object.keys(state.elements).forEach(function (name) {
- var element = state.elements[name];
- var attributes = state.attributes[name] || {};
- var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
- var style = styleProperties.reduce(function (style, property) {
- style[property] = '';
- return style;
- }, {}); // arrow is optional + virtual elements
- if (!isHTMLElement(element) || !getNodeName(element)) {
- return;
- }
- Object.assign(element.style, style);
- Object.keys(attributes).forEach(function (attribute) {
- element.removeAttribute(attribute);
- });
- });
- };
- } // eslint-disable-next-line import/no-unused-modules
- const applyStyles$1 = {
- name: 'applyStyles',
- enabled: true,
- phase: 'write',
- fn: applyStyles,
- effect: effect$2,
- requires: ['computeStyles']
- };
- function getBasePlacement(placement) {
- return placement.split('-')[0];
- }
- var max = Math.max;
- var min = Math.min;
- var round = Math.round;
- function getBoundingClientRect(element, includeScale) {
- if (includeScale === void 0) {
- includeScale = false;
- }
- var rect = element.getBoundingClientRect();
- var scaleX = 1;
- var scaleY = 1;
- if (isHTMLElement(element) && includeScale) {
- var offsetHeight = element.offsetHeight;
- var offsetWidth = element.offsetWidth; // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
- // Fallback to 1 in case both values are `0`
- if (offsetWidth > 0) {
- scaleX = round(rect.width) / offsetWidth || 1;
- }
- if (offsetHeight > 0) {
- scaleY = round(rect.height) / offsetHeight || 1;
- }
- }
- return {
- width: rect.width / scaleX,
- height: rect.height / scaleY,
- top: rect.top / scaleY,
- right: rect.right / scaleX,
- bottom: rect.bottom / scaleY,
- left: rect.left / scaleX,
- x: rect.left / scaleX,
- y: rect.top / scaleY
- };
- }
- // means it doesn't take into account transforms.
- function getLayoutRect(element) {
- var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
- // Fixes https://github.com/popperjs/popper-core/issues/1223
- var width = element.offsetWidth;
- var height = element.offsetHeight;
- if (Math.abs(clientRect.width - width) <= 1) {
- width = clientRect.width;
- }
- if (Math.abs(clientRect.height - height) <= 1) {
- height = clientRect.height;
- }
- return {
- x: element.offsetLeft,
- y: element.offsetTop,
- width: width,
- height: height
- };
- }
- function contains(parent, child) {
- var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
- if (parent.contains(child)) {
- return true;
- } // then fallback to custom implementation with Shadow DOM support
- else if (rootNode && isShadowRoot(rootNode)) {
- var next = child;
- do {
- if (next && parent.isSameNode(next)) {
- return true;
- } // $FlowFixMe[prop-missing]: need a better way to handle this...
- next = next.parentNode || next.host;
- } while (next);
- } // Give up, the result is false
- return false;
- }
- function getComputedStyle$1(element) {
- return getWindow(element).getComputedStyle(element);
- }
- function isTableElement(element) {
- return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
- }
- function getDocumentElement(element) {
- // $FlowFixMe[incompatible-return]: assume body is always available
- return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
- element.document) || window.document).documentElement;
- }
- function getParentNode(element) {
- if (getNodeName(element) === 'html') {
- return element;
- }
- return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
- // $FlowFixMe[incompatible-return]
- // $FlowFixMe[prop-missing]
- element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
- element.parentNode || ( // DOM Element detected
- isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
- // $FlowFixMe[incompatible-call]: HTMLElement is a Node
- getDocumentElement(element) // fallback
- );
- }
- function getTrueOffsetParent(element) {
- if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
- getComputedStyle$1(element).position === 'fixed') {
- return null;
- }
- return element.offsetParent;
- } // `.offsetParent` reports `null` for fixed elements, while absolute elements
- // return the containing block
- function getContainingBlock(element) {
- var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') !== -1;
- var isIE = navigator.userAgent.indexOf('Trident') !== -1;
- if (isIE && isHTMLElement(element)) {
- // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
- var elementCss = getComputedStyle$1(element);
- if (elementCss.position === 'fixed') {
- return null;
- }
- }
- var currentNode = getParentNode(element);
- if (isShadowRoot(currentNode)) {
- currentNode = currentNode.host;
- }
- while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
- var css = getComputedStyle$1(currentNode); // This is non-exhaustive but covers the most common CSS properties that
- // create a containing block.
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
- if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
- return currentNode;
- } else {
- currentNode = currentNode.parentNode;
- }
- }
- return null;
- } // Gets the closest ancestor positioned element. Handles some edge cases,
- // such as table ancestors and cross browser bugs.
- function getOffsetParent(element) {
- var window = getWindow(element);
- var offsetParent = getTrueOffsetParent(element);
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
- offsetParent = getTrueOffsetParent(offsetParent);
- }
- if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static')) {
- return window;
- }
- return offsetParent || getContainingBlock(element) || window;
- }
- function getMainAxisFromPlacement(placement) {
- return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
- }
- function within(min$1, value, max$1) {
- return max(min$1, min(value, max$1));
- }
- function withinMaxClamp(min, value, max) {
- var v = within(min, value, max);
- return v > max ? max : v;
- }
- function getFreshSideObject() {
- return {
- top: 0,
- right: 0,
- bottom: 0,
- left: 0
- };
- }
- function mergePaddingObject(paddingObject) {
- return Object.assign({}, getFreshSideObject(), paddingObject);
- }
- function expandToHashMap(value, keys) {
- return keys.reduce(function (hashMap, key) {
- hashMap[key] = value;
- return hashMap;
- }, {});
- }
- var toPaddingObject = function toPaddingObject(padding, state) {
- padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
- placement: state.placement
- })) : padding;
- return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
- };
- function arrow(_ref) {
- var _state$modifiersData$;
- var state = _ref.state,
- name = _ref.name,
- options = _ref.options;
- var arrowElement = state.elements.arrow;
- var popperOffsets = state.modifiersData.popperOffsets;
- var basePlacement = getBasePlacement(state.placement);
- var axis = getMainAxisFromPlacement(basePlacement);
- var isVertical = [left, right].indexOf(basePlacement) >= 0;
- var len = isVertical ? 'height' : 'width';
- if (!arrowElement || !popperOffsets) {
- return;
- }
- var paddingObject = toPaddingObject(options.padding, state);
- var arrowRect = getLayoutRect(arrowElement);
- var minProp = axis === 'y' ? top : left;
- var maxProp = axis === 'y' ? bottom : right;
- var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
- var startDiff = popperOffsets[axis] - state.rects.reference[axis];
- var arrowOffsetParent = getOffsetParent(arrowElement);
- var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
- var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
- // outside of the popper bounds
- var min = paddingObject[minProp];
- var max = clientSize - arrowRect[len] - paddingObject[maxProp];
- var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
- var offset = within(min, center, max); // Prevents breaking syntax highlighting...
- var axisProp = axis;
- state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
- }
- function effect$1(_ref2) {
- var state = _ref2.state,
- options = _ref2.options;
- var _options$element = options.element,
- arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
- if (arrowElement == null) {
- return;
- } // CSS selector
- if (typeof arrowElement === 'string') {
- arrowElement = state.elements.popper.querySelector(arrowElement);
- if (!arrowElement) {
- return;
- }
- }
- if (!contains(state.elements.popper, arrowElement)) {
- return;
- }
- state.elements.arrow = arrowElement;
- } // eslint-disable-next-line import/no-unused-modules
- const arrow$1 = {
- name: 'arrow',
- enabled: true,
- phase: 'main',
- fn: arrow,
- effect: effect$1,
- requires: ['popperOffsets'],
- requiresIfExists: ['preventOverflow']
- };
- function getVariation(placement) {
- return placement.split('-')[1];
- }
- var unsetSides = {
- top: 'auto',
- right: 'auto',
- bottom: 'auto',
- left: 'auto'
- }; // Round the offsets to the nearest suitable subpixel based on the DPR.
- // Zooming can change the DPR, but it seems to report a value that will
- // cleanly divide the values into the appropriate subpixels.
- function roundOffsetsByDPR(_ref) {
- var x = _ref.x,
- y = _ref.y;
- var win = window;
- var dpr = win.devicePixelRatio || 1;
- return {
- x: round(x * dpr) / dpr || 0,
- y: round(y * dpr) / dpr || 0
- };
- }
- function mapToStyles(_ref2) {
- var _Object$assign2;
- var popper = _ref2.popper,
- popperRect = _ref2.popperRect,
- placement = _ref2.placement,
- variation = _ref2.variation,
- offsets = _ref2.offsets,
- position = _ref2.position,
- gpuAcceleration = _ref2.gpuAcceleration,
- adaptive = _ref2.adaptive,
- roundOffsets = _ref2.roundOffsets,
- isFixed = _ref2.isFixed;
- var _offsets$x = offsets.x,
- x = _offsets$x === void 0 ? 0 : _offsets$x,
- _offsets$y = offsets.y,
- y = _offsets$y === void 0 ? 0 : _offsets$y;
- var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
- x: x,
- y: y
- }) : {
- x: x,
- y: y
- };
- x = _ref3.x;
- y = _ref3.y;
- var hasX = offsets.hasOwnProperty('x');
- var hasY = offsets.hasOwnProperty('y');
- var sideX = left;
- var sideY = top;
- var win = window;
- if (adaptive) {
- var offsetParent = getOffsetParent(popper);
- var heightProp = 'clientHeight';
- var widthProp = 'clientWidth';
- if (offsetParent === getWindow(popper)) {
- offsetParent = getDocumentElement(popper);
- if (getComputedStyle$1(offsetParent).position !== 'static' && position === 'absolute') {
- heightProp = 'scrollHeight';
- widthProp = 'scrollWidth';
- }
- } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
- offsetParent = offsetParent;
- if (placement === top || (placement === left || placement === right) && variation === end) {
- sideY = bottom;
- var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
- offsetParent[heightProp];
- y -= offsetY - popperRect.height;
- y *= gpuAcceleration ? 1 : -1;
- }
- if (placement === left || (placement === top || placement === bottom) && variation === end) {
- sideX = right;
- var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
- offsetParent[widthProp];
- x -= offsetX - popperRect.width;
- x *= gpuAcceleration ? 1 : -1;
- }
- }
- var commonStyles = Object.assign({
- position: position
- }, adaptive && unsetSides);
- var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
- x: x,
- y: y
- }) : {
- x: x,
- y: y
- };
- x = _ref4.x;
- y = _ref4.y;
- if (gpuAcceleration) {
- var _Object$assign;
- return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
- }
- return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
- }
- function computeStyles(_ref5) {
- var state = _ref5.state,
- options = _ref5.options;
- var _options$gpuAccelerat = options.gpuAcceleration,
- gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
- _options$adaptive = options.adaptive,
- adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
- _options$roundOffsets = options.roundOffsets,
- roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
- var commonStyles = {
- placement: getBasePlacement(state.placement),
- variation: getVariation(state.placement),
- popper: state.elements.popper,
- popperRect: state.rects.popper,
- gpuAcceleration: gpuAcceleration,
- isFixed: state.options.strategy === 'fixed'
- };
- if (state.modifiersData.popperOffsets != null) {
- state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
- offsets: state.modifiersData.popperOffsets,
- position: state.options.strategy,
- adaptive: adaptive,
- roundOffsets: roundOffsets
- })));
- }
- if (state.modifiersData.arrow != null) {
- state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
- offsets: state.modifiersData.arrow,
- position: 'absolute',
- adaptive: false,
- roundOffsets: roundOffsets
- })));
- }
- state.attributes.popper = Object.assign({}, state.attributes.popper, {
- 'data-popper-placement': state.placement
- });
- } // eslint-disable-next-line import/no-unused-modules
- const computeStyles$1 = {
- name: 'computeStyles',
- enabled: true,
- phase: 'beforeWrite',
- fn: computeStyles,
- data: {}
- };
- var passive = {
- passive: true
- };
- function effect(_ref) {
- var state = _ref.state,
- instance = _ref.instance,
- options = _ref.options;
- var _options$scroll = options.scroll,
- scroll = _options$scroll === void 0 ? true : _options$scroll,
- _options$resize = options.resize,
- resize = _options$resize === void 0 ? true : _options$resize;
- var window = getWindow(state.elements.popper);
- var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
- if (scroll) {
- scrollParents.forEach(function (scrollParent) {
- scrollParent.addEventListener('scroll', instance.update, passive);
- });
- }
- if (resize) {
- window.addEventListener('resize', instance.update, passive);
- }
- return function () {
- if (scroll) {
- scrollParents.forEach(function (scrollParent) {
- scrollParent.removeEventListener('scroll', instance.update, passive);
- });
- }
- if (resize) {
- window.removeEventListener('resize', instance.update, passive);
- }
- };
- } // eslint-disable-next-line import/no-unused-modules
- const eventListeners = {
- name: 'eventListeners',
- enabled: true,
- phase: 'write',
- fn: function fn() {},
- effect: effect,
- data: {}
- };
- var hash$1 = {
- left: 'right',
- right: 'left',
- bottom: 'top',
- top: 'bottom'
- };
- function getOppositePlacement(placement) {
- return placement.replace(/left|right|bottom|top/g, function (matched) {
- return hash$1[matched];
- });
- }
- var hash = {
- start: 'end',
- end: 'start'
- };
- function getOppositeVariationPlacement(placement) {
- return placement.replace(/start|end/g, function (matched) {
- return hash[matched];
- });
- }
- function getWindowScroll(node) {
- var win = getWindow(node);
- var scrollLeft = win.pageXOffset;
- var scrollTop = win.pageYOffset;
- return {
- scrollLeft: scrollLeft,
- scrollTop: scrollTop
- };
- }
- function getWindowScrollBarX(element) {
- // If <html> has a CSS width greater than the viewport, then this will be
- // incorrect for RTL.
- // Popper 1 is broken in this case and never had a bug report so let's assume
- // it's not an issue. I don't think anyone ever specifies width on <html>
- // anyway.
- // Browsers where the left scrollbar doesn't cause an issue report `0` for
- // this (e.g. Edge 2019, IE11, Safari)
- return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
- }
- function getViewportRect(element) {
- var win = getWindow(element);
- var html = getDocumentElement(element);
- var visualViewport = win.visualViewport;
- var width = html.clientWidth;
- var height = html.clientHeight;
- var x = 0;
- var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
- // can be obscured underneath it.
- // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
- // if it isn't open, so if this isn't available, the popper will be detected
- // to overflow the bottom of the screen too early.
- if (visualViewport) {
- width = visualViewport.width;
- height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
- // In Chrome, it returns a value very close to 0 (+/-) but contains rounding
- // errors due to floating point numbers, so we need to check precision.
- // Safari returns a number <= 0, usually < -1 when pinch-zoomed
- // Feature detection fails in mobile emulation mode in Chrome.
- // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
- // 0.001
- // Fallback here: "Not Safari" userAgent
- if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
- x = visualViewport.offsetLeft;
- y = visualViewport.offsetTop;
- }
- }
- return {
- width: width,
- height: height,
- x: x + getWindowScrollBarX(element),
- y: y
- };
- }
- // of the `<html>` and `<body>` rect bounds if horizontally scrollable
- function getDocumentRect(element) {
- var _element$ownerDocumen;
- var html = getDocumentElement(element);
- var winScroll = getWindowScroll(element);
- var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
- var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
- var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
- var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
- var y = -winScroll.scrollTop;
- if (getComputedStyle$1(body || html).direction === 'rtl') {
- x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
- }
- return {
- width: width,
- height: height,
- x: x,
- y: y
- };
- }
- function isScrollParent(element) {
- // Firefox wants us to check `-x` and `-y` variations as well
- var _getComputedStyle = getComputedStyle$1(element),
- overflow = _getComputedStyle.overflow,
- overflowX = _getComputedStyle.overflowX,
- overflowY = _getComputedStyle.overflowY;
- return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
- }
- function getScrollParent(node) {
- if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
- // $FlowFixMe[incompatible-return]: assume body is always available
- return node.ownerDocument.body;
- }
- if (isHTMLElement(node) && isScrollParent(node)) {
- return node;
- }
- return getScrollParent(getParentNode(node));
- }
- /*
- given a DOM element, return the list of all scroll parents, up the list of ancesors
- until we get to the top window object. This list is what we attach scroll listeners
- to, because if any of these parent elements scroll, we'll need to re-calculate the
- reference element's position.
- */
- function listScrollParents(element, list) {
- var _element$ownerDocumen;
- if (list === void 0) {
- list = [];
- }
- var scrollParent = getScrollParent(element);
- var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
- var win = getWindow(scrollParent);
- var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
- var updatedList = list.concat(target);
- return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
- updatedList.concat(listScrollParents(getParentNode(target)));
- }
- function rectToClientRect(rect) {
- return Object.assign({}, rect, {
- left: rect.x,
- top: rect.y,
- right: rect.x + rect.width,
- bottom: rect.y + rect.height
- });
- }
- function getInnerBoundingClientRect(element) {
- var rect = getBoundingClientRect(element);
- rect.top = rect.top + element.clientTop;
- rect.left = rect.left + element.clientLeft;
- rect.bottom = rect.top + element.clientHeight;
- rect.right = rect.left + element.clientWidth;
- rect.width = element.clientWidth;
- rect.height = element.clientHeight;
- rect.x = rect.left;
- rect.y = rect.top;
- return rect;
- }
- function getClientRectFromMixedType(element, clippingParent) {
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
- } // A "clipping parent" is an overflowable container with the characteristic of
- // clipping (or hiding) overflowing elements with a position different from
- // `initial`
- function getClippingParents(element) {
- var clippingParents = listScrollParents(getParentNode(element));
- var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle$1(element).position) >= 0;
- var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
- if (!isElement(clipperElement)) {
- return [];
- } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
- return clippingParents.filter(function (clippingParent) {
- return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
- });
- } // Gets the maximum area that the element is visible in due to any number of
- // clipping parents
- function getClippingRect(element, boundary, rootBoundary) {
- var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
- var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
- var firstClippingParent = clippingParents[0];
- var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
- var rect = getClientRectFromMixedType(element, clippingParent);
- accRect.top = max(rect.top, accRect.top);
- accRect.right = min(rect.right, accRect.right);
- accRect.bottom = min(rect.bottom, accRect.bottom);
- accRect.left = max(rect.left, accRect.left);
- return accRect;
- }, getClientRectFromMixedType(element, firstClippingParent));
- clippingRect.width = clippingRect.right - clippingRect.left;
- clippingRect.height = clippingRect.bottom - clippingRect.top;
- clippingRect.x = clippingRect.left;
- clippingRect.y = clippingRect.top;
- return clippingRect;
- }
- function computeOffsets(_ref) {
- var reference = _ref.reference,
- element = _ref.element,
- placement = _ref.placement;
- var basePlacement = placement ? getBasePlacement(placement) : null;
- var variation = placement ? getVariation(placement) : null;
- var commonX = reference.x + reference.width / 2 - element.width / 2;
- var commonY = reference.y + reference.height / 2 - element.height / 2;
- var offsets;
- switch (basePlacement) {
- case top:
- offsets = {
- x: commonX,
- y: reference.y - element.height
- };
- break;
- case bottom:
- offsets = {
- x: commonX,
- y: reference.y + reference.height
- };
- break;
- case right:
- offsets = {
- x: reference.x + reference.width,
- y: commonY
- };
- break;
- case left:
- offsets = {
- x: reference.x - element.width,
- y: commonY
- };
- break;
- default:
- offsets = {
- x: reference.x,
- y: reference.y
- };
- }
- var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
- if (mainAxis != null) {
- var len = mainAxis === 'y' ? 'height' : 'width';
- switch (variation) {
- case start:
- offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
- break;
- case end:
- offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
- break;
- }
- }
- return offsets;
- }
- function detectOverflow(state, options) {
- if (options === void 0) {
- options = {};
- }
- var _options = options,
- _options$placement = _options.placement,
- placement = _options$placement === void 0 ? state.placement : _options$placement,
- _options$boundary = _options.boundary,
- boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
- _options$rootBoundary = _options.rootBoundary,
- rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
- _options$elementConte = _options.elementContext,
- elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
- _options$altBoundary = _options.altBoundary,
- altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
- _options$padding = _options.padding,
- padding = _options$padding === void 0 ? 0 : _options$padding;
- var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
- var altContext = elementContext === popper ? reference : popper;
- var popperRect = state.rects.popper;
- var element = state.elements[altBoundary ? altContext : elementContext];
- var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
- var referenceClientRect = getBoundingClientRect(state.elements.reference);
- var popperOffsets = computeOffsets({
- reference: referenceClientRect,
- element: popperRect,
- strategy: 'absolute',
- placement: placement
- });
- var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
- var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
- // 0 or negative = within the clipping rect
- var overflowOffsets = {
- top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
- bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
- left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
- right: elementClientRect.right - clippingClientRect.right + paddingObject.right
- };
- var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
- if (elementContext === popper && offsetData) {
- var offset = offsetData[placement];
- Object.keys(overflowOffsets).forEach(function (key) {
- var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
- var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
- overflowOffsets[key] += offset[axis] * multiply;
- });
- }
- return overflowOffsets;
- }
- function computeAutoPlacement(state, options) {
- if (options === void 0) {
- options = {};
- }
- var _options = options,
- placement = _options.placement,
- boundary = _options.boundary,
- rootBoundary = _options.rootBoundary,
- padding = _options.padding,
- flipVariations = _options.flipVariations,
- _options$allowedAutoP = _options.allowedAutoPlacements,
- allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
- var variation = getVariation(placement);
- var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
- return getVariation(placement) === variation;
- }) : basePlacements;
- var allowedPlacements = placements$1.filter(function (placement) {
- return allowedAutoPlacements.indexOf(placement) >= 0;
- });
- if (allowedPlacements.length === 0) {
- allowedPlacements = placements$1;
- } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
- var overflows = allowedPlacements.reduce(function (acc, placement) {
- acc[placement] = detectOverflow(state, {
- placement: placement,
- boundary: boundary,
- rootBoundary: rootBoundary,
- padding: padding
- })[getBasePlacement(placement)];
- return acc;
- }, {});
- return Object.keys(overflows).sort(function (a, b) {
- return overflows[a] - overflows[b];
- });
- }
- function getExpandedFallbackPlacements(placement) {
- if (getBasePlacement(placement) === auto) {
- return [];
- }
- var oppositePlacement = getOppositePlacement(placement);
- return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
- }
- function flip(_ref) {
- var state = _ref.state,
- options = _ref.options,
- name = _ref.name;
- if (state.modifiersData[name]._skip) {
- return;
- }
- var _options$mainAxis = options.mainAxis,
- checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
- _options$altAxis = options.altAxis,
- checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
- specifiedFallbackPlacements = options.fallbackPlacements,
- padding = options.padding,
- boundary = options.boundary,
- rootBoundary = options.rootBoundary,
- altBoundary = options.altBoundary,
- _options$flipVariatio = options.flipVariations,
- flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
- allowedAutoPlacements = options.allowedAutoPlacements;
- var preferredPlacement = state.options.placement;
- var basePlacement = getBasePlacement(preferredPlacement);
- var isBasePlacement = basePlacement === preferredPlacement;
- var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
- var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
- return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
- placement: placement,
- boundary: boundary,
- rootBoundary: rootBoundary,
- padding: padding,
- flipVariations: flipVariations,
- allowedAutoPlacements: allowedAutoPlacements
- }) : placement);
- }, []);
- var referenceRect = state.rects.reference;
- var popperRect = state.rects.popper;
- var checksMap = new Map();
- var makeFallbackChecks = true;
- var firstFittingPlacement = placements[0];
- for (var i = 0; i < placements.length; i++) {
- var placement = placements[i];
- var _basePlacement = getBasePlacement(placement);
- var isStartVariation = getVariation(placement) === start;
- var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
- var len = isVertical ? 'width' : 'height';
- var overflow = detectOverflow(state, {
- placement: placement,
- boundary: boundary,
- rootBoundary: rootBoundary,
- altBoundary: altBoundary,
- padding: padding
- });
- var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
- if (referenceRect[len] > popperRect[len]) {
- mainVariationSide = getOppositePlacement(mainVariationSide);
- }
- var altVariationSide = getOppositePlacement(mainVariationSide);
- var checks = [];
- if (checkMainAxis) {
- checks.push(overflow[_basePlacement] <= 0);
- }
- if (checkAltAxis) {
- checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
- }
- if (checks.every(function (check) {
- return check;
- })) {
- firstFittingPlacement = placement;
- makeFallbackChecks = false;
- break;
- }
- checksMap.set(placement, checks);
- }
- if (makeFallbackChecks) {
- // `2` may be desired in some cases – research later
- var numberOfChecks = flipVariations ? 3 : 1;
- var _loop = function _loop(_i) {
- var fittingPlacement = placements.find(function (placement) {
- var checks = checksMap.get(placement);
- if (checks) {
- return checks.slice(0, _i).every(function (check) {
- return check;
- });
- }
- });
- if (fittingPlacement) {
- firstFittingPlacement = fittingPlacement;
- return "break";
- }
- };
- for (var _i = numberOfChecks; _i > 0; _i--) {
- var _ret = _loop(_i);
- if (_ret === "break") break;
- }
- }
- if (state.placement !== firstFittingPlacement) {
- state.modifiersData[name]._skip = true;
- state.placement = firstFittingPlacement;
- state.reset = true;
- }
- } // eslint-disable-next-line import/no-unused-modules
- const flip$1 = {
- name: 'flip',
- enabled: true,
- phase: 'main',
- fn: flip,
- requiresIfExists: ['offset'],
- data: {
- _skip: false
- }
- };
- function getSideOffsets(overflow, rect, preventedOffsets) {
- if (preventedOffsets === void 0) {
- preventedOffsets = {
- x: 0,
- y: 0
- };
- }
- return {
- top: overflow.top - rect.height - preventedOffsets.y,
- right: overflow.right - rect.width + preventedOffsets.x,
- bottom: overflow.bottom - rect.height + preventedOffsets.y,
- left: overflow.left - rect.width - preventedOffsets.x
- };
- }
- function isAnySideFullyClipped(overflow) {
- return [top, right, bottom, left].some(function (side) {
- return overflow[side] >= 0;
- });
- }
- function hide(_ref) {
- var state = _ref.state,
- name = _ref.name;
- var referenceRect = state.rects.reference;
- var popperRect = state.rects.popper;
- var preventedOffsets = state.modifiersData.preventOverflow;
- var referenceOverflow = detectOverflow(state, {
- elementContext: 'reference'
- });
- var popperAltOverflow = detectOverflow(state, {
- altBoundary: true
- });
- var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
- var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
- var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
- var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
- state.modifiersData[name] = {
- referenceClippingOffsets: referenceClippingOffsets,
- popperEscapeOffsets: popperEscapeOffsets,
- isReferenceHidden: isReferenceHidden,
- hasPopperEscaped: hasPopperEscaped
- };
- state.attributes.popper = Object.assign({}, state.attributes.popper, {
- 'data-popper-reference-hidden': isReferenceHidden,
- 'data-popper-escaped': hasPopperEscaped
- });
- } // eslint-disable-next-line import/no-unused-modules
- const hide$1 = {
- name: 'hide',
- enabled: true,
- phase: 'main',
- requiresIfExists: ['preventOverflow'],
- fn: hide
- };
- function distanceAndSkiddingToXY(placement, rects, offset) {
- var basePlacement = getBasePlacement(placement);
- var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
- var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
- placement: placement
- })) : offset,
- skidding = _ref[0],
- distance = _ref[1];
- skidding = skidding || 0;
- distance = (distance || 0) * invertDistance;
- return [left, right].indexOf(basePlacement) >= 0 ? {
- x: distance,
- y: skidding
- } : {
- x: skidding,
- y: distance
- };
- }
- function offset(_ref2) {
- var state = _ref2.state,
- options = _ref2.options,
- name = _ref2.name;
- var _options$offset = options.offset,
- offset = _options$offset === void 0 ? [0, 0] : _options$offset;
- var data = placements.reduce(function (acc, placement) {
- acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
- return acc;
- }, {});
- var _data$state$placement = data[state.placement],
- x = _data$state$placement.x,
- y = _data$state$placement.y;
- if (state.modifiersData.popperOffsets != null) {
- state.modifiersData.popperOffsets.x += x;
- state.modifiersData.popperOffsets.y += y;
- }
- state.modifiersData[name] = data;
- } // eslint-disable-next-line import/no-unused-modules
- const offset$1 = {
- name: 'offset',
- enabled: true,
- phase: 'main',
- requires: ['popperOffsets'],
- fn: offset
- };
- function popperOffsets(_ref) {
- var state = _ref.state,
- name = _ref.name;
- // Offsets are the actual position the popper needs to have to be
- // properly positioned near its reference element
- // This is the most basic placement, and will be adjusted by
- // the modifiers in the next step
- state.modifiersData[name] = computeOffsets({
- reference: state.rects.reference,
- element: state.rects.popper,
- strategy: 'absolute',
- placement: state.placement
- });
- } // eslint-disable-next-line import/no-unused-modules
- const popperOffsets$1 = {
- name: 'popperOffsets',
- enabled: true,
- phase: 'read',
- fn: popperOffsets,
- data: {}
- };
- function getAltAxis(axis) {
- return axis === 'x' ? 'y' : 'x';
- }
- function preventOverflow(_ref) {
- var state = _ref.state,
- options = _ref.options,
- name = _ref.name;
- var _options$mainAxis = options.mainAxis,
- checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
- _options$altAxis = options.altAxis,
- checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
- boundary = options.boundary,
- rootBoundary = options.rootBoundary,
- altBoundary = options.altBoundary,
- padding = options.padding,
- _options$tether = options.tether,
- tether = _options$tether === void 0 ? true : _options$tether,
- _options$tetherOffset = options.tetherOffset,
- tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
- var overflow = detectOverflow(state, {
- boundary: boundary,
- rootBoundary: rootBoundary,
- padding: padding,
- altBoundary: altBoundary
- });
- var basePlacement = getBasePlacement(state.placement);
- var variation = getVariation(state.placement);
- var isBasePlacement = !variation;
- var mainAxis = getMainAxisFromPlacement(basePlacement);
- var altAxis = getAltAxis(mainAxis);
- var popperOffsets = state.modifiersData.popperOffsets;
- var referenceRect = state.rects.reference;
- var popperRect = state.rects.popper;
- var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
- placement: state.placement
- })) : tetherOffset;
- var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
- mainAxis: tetherOffsetValue,
- altAxis: tetherOffsetValue
- } : Object.assign({
- mainAxis: 0,
- altAxis: 0
- }, tetherOffsetValue);
- var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
- var data = {
- x: 0,
- y: 0
- };
- if (!popperOffsets) {
- return;
- }
- if (checkMainAxis) {
- var _offsetModifierState$;
- var mainSide = mainAxis === 'y' ? top : left;
- var altSide = mainAxis === 'y' ? bottom : right;
- var len = mainAxis === 'y' ? 'height' : 'width';
- var offset = popperOffsets[mainAxis];
- var min$1 = offset + overflow[mainSide];
- var max$1 = offset - overflow[altSide];
- var additive = tether ? -popperRect[len] / 2 : 0;
- var minLen = variation === start ? referenceRect[len] : popperRect[len];
- var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
- // outside the reference bounds
- var arrowElement = state.elements.arrow;
- var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
- width: 0,
- height: 0
- };
- var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
- var arrowPaddingMin = arrowPaddingObject[mainSide];
- var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
- // to include its full size in the calculation. If the reference is small
- // and near the edge of a boundary, the popper can overflow even if the
- // reference is not overflowing as well (e.g. virtual elements with no
- // width or height)
- var arrowLen = within(0, referenceRect[len], arrowRect[len]);
- var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
- var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
- var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
- var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
- var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
- var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
- var tetherMax = offset + maxOffset - offsetModifierValue;
- var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
- popperOffsets[mainAxis] = preventedOffset;
- data[mainAxis] = preventedOffset - offset;
- }
- if (checkAltAxis) {
- var _offsetModifierState$2;
- var _mainSide = mainAxis === 'x' ? top : left;
- var _altSide = mainAxis === 'x' ? bottom : right;
- var _offset = popperOffsets[altAxis];
- var _len = altAxis === 'y' ? 'height' : 'width';
- var _min = _offset + overflow[_mainSide];
- var _max = _offset - overflow[_altSide];
- var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
- var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
- var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
- var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
- var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
- popperOffsets[altAxis] = _preventedOffset;
- data[altAxis] = _preventedOffset - _offset;
- }
- state.modifiersData[name] = data;
- } // eslint-disable-next-line import/no-unused-modules
- const preventOverflow$1 = {
- name: 'preventOverflow',
- enabled: true,
- phase: 'main',
- fn: preventOverflow,
- requiresIfExists: ['offset']
- };
- function getHTMLElementScroll(element) {
- return {
- scrollLeft: element.scrollLeft,
- scrollTop: element.scrollTop
- };
- }
- function getNodeScroll(node) {
- if (node === getWindow(node) || !isHTMLElement(node)) {
- return getWindowScroll(node);
- } else {
- return getHTMLElementScroll(node);
- }
- }
- function isElementScaled(element) {
- var rect = element.getBoundingClientRect();
- var scaleX = round(rect.width) / element.offsetWidth || 1;
- var scaleY = round(rect.height) / element.offsetHeight || 1;
- return scaleX !== 1 || scaleY !== 1;
- } // Returns the composite rect of an element relative to its offsetParent.
- // Composite means it takes into account transforms as well as layout.
- function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
- if (isFixed === void 0) {
- isFixed = false;
- }
- var isOffsetParentAnElement = isHTMLElement(offsetParent);
- var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
- var documentElement = getDocumentElement(offsetParent);
- var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
- var scroll = {
- scrollLeft: 0,
- scrollTop: 0
- };
- var offsets = {
- x: 0,
- y: 0
- };
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
- if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
- isScrollParent(documentElement)) {
- scroll = getNodeScroll(offsetParent);
- }
- if (isHTMLElement(offsetParent)) {
- offsets = getBoundingClientRect(offsetParent, true);
- offsets.x += offsetParent.clientLeft;
- offsets.y += offsetParent.clientTop;
- } else if (documentElement) {
- offsets.x = getWindowScrollBarX(documentElement);
- }
- }
- return {
- x: rect.left + scroll.scrollLeft - offsets.x,
- y: rect.top + scroll.scrollTop - offsets.y,
- width: rect.width,
- height: rect.height
- };
- }
- function order(modifiers) {
- var map = new Map();
- var visited = new Set();
- var result = [];
- modifiers.forEach(function (modifier) {
- map.set(modifier.name, modifier);
- }); // On visiting object, check for its dependencies and visit them recursively
- function sort(modifier) {
- visited.add(modifier.name);
- var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
- requires.forEach(function (dep) {
- if (!visited.has(dep)) {
- var depModifier = map.get(dep);
- if (depModifier) {
- sort(depModifier);
- }
- }
- });
- result.push(modifier);
- }
- modifiers.forEach(function (modifier) {
- if (!visited.has(modifier.name)) {
- // check for visited object
- sort(modifier);
- }
- });
- return result;
- }
- function orderModifiers(modifiers) {
- // order based on dependencies
- var orderedModifiers = order(modifiers); // order based on phase
- return modifierPhases.reduce(function (acc, phase) {
- return acc.concat(orderedModifiers.filter(function (modifier) {
- return modifier.phase === phase;
- }));
- }, []);
- }
- function debounce(fn) {
- var pending;
- return function () {
- if (!pending) {
- pending = new Promise(function (resolve) {
- Promise.resolve().then(function () {
- pending = undefined;
- resolve(fn());
- });
- });
- }
- return pending;
- };
- }
- function mergeByName(modifiers) {
- var merged = modifiers.reduce(function (merged, current) {
- var existing = merged[current.name];
- merged[current.name] = existing ? Object.assign({}, existing, current, {
- options: Object.assign({}, existing.options, current.options),
- data: Object.assign({}, existing.data, current.data)
- }) : current;
- return merged;
- }, {}); // IE11 does not support Object.values
- return Object.keys(merged).map(function (key) {
- return merged[key];
- });
- }
- var DEFAULT_OPTIONS = {
- placement: 'bottom',
- modifiers: [],
- strategy: 'absolute'
- };
- function areValidElements() {
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
- return !args.some(function (element) {
- return !(element && typeof element.getBoundingClientRect === 'function');
- });
- }
- function popperGenerator(generatorOptions) {
- if (generatorOptions === void 0) {
- generatorOptions = {};
- }
- var _generatorOptions = generatorOptions,
- _generatorOptions$def = _generatorOptions.defaultModifiers,
- defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
- _generatorOptions$def2 = _generatorOptions.defaultOptions,
- defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
- return function createPopper(reference, popper, options) {
- if (options === void 0) {
- options = defaultOptions;
- }
- var state = {
- placement: 'bottom',
- orderedModifiers: [],
- options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
- modifiersData: {},
- elements: {
- reference: reference,
- popper: popper
- },
- attributes: {},
- styles: {}
- };
- var effectCleanupFns = [];
- var isDestroyed = false;
- var instance = {
- state: state,
- setOptions: function setOptions(setOptionsAction) {
- var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
- cleanupModifierEffects();
- state.options = Object.assign({}, defaultOptions, state.options, options);
- state.scrollParents = {
- reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
- popper: listScrollParents(popper)
- }; // Orders the modifiers based on their dependencies and `phase`
- // properties
- var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
- state.orderedModifiers = orderedModifiers.filter(function (m) {
- return m.enabled;
- }); // Validate the provided modifiers so that the consumer will get warned
- runModifierEffects();
- return instance.update();
- },
- // Sync update – it will always be executed, even if not necessary. This
- // is useful for low frequency updates where sync behavior simplifies the
- // logic.
- // For high frequency updates (e.g. `resize` and `scroll` events), always
- // prefer the async Popper#update method
- forceUpdate: function forceUpdate() {
- if (isDestroyed) {
- return;
- }
- var _state$elements = state.elements,
- reference = _state$elements.reference,
- popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
- // anymore
- if (!areValidElements(reference, popper)) {
- return;
- } // Store the reference and popper rects to be read by modifiers
- state.rects = {
- reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
- popper: getLayoutRect(popper)
- }; // Modifiers have the ability to reset the current update cycle. The
- // most common use case for this is the `flip` modifier changing the
- // placement, which then needs to re-run all the modifiers, because the
- // logic was previously ran for the previous placement and is therefore
- // stale/incorrect
- state.reset = false;
- state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
- // is filled with the initial data specified by the modifier. This means
- // it doesn't persist and is fresh on each update.
- // To ensure persistent data, use `${name}#persistent`
- state.orderedModifiers.forEach(function (modifier) {
- return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
- });
- for (var index = 0; index < state.orderedModifiers.length; index++) {
- if (state.reset === true) {
- state.reset = false;
- index = -1;
- continue;
- }
- var _state$orderedModifie = state.orderedModifiers[index],
- fn = _state$orderedModifie.fn,
- _state$orderedModifie2 = _state$orderedModifie.options,
- _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
- name = _state$orderedModifie.name;
- if (typeof fn === 'function') {
- state = fn({
- state: state,
- options: _options,
- name: name,
- instance: instance
- }) || state;
- }
- }
- },
- // Async and optimistically optimized update – it will not be executed if
- // not necessary (debounced to run at most once-per-tick)
- update: debounce(function () {
- return new Promise(function (resolve) {
- instance.forceUpdate();
- resolve(state);
- });
- }),
- destroy: function destroy() {
- cleanupModifierEffects();
- isDestroyed = true;
- }
- };
- if (!areValidElements(reference, popper)) {
- return instance;
- }
- instance.setOptions(options).then(function (state) {
- if (!isDestroyed && options.onFirstUpdate) {
- options.onFirstUpdate(state);
- }
- }); // Modifiers have the ability to execute arbitrary code before the first
- // update cycle runs. They will be executed in the same order as the update
- // cycle. This is useful when a modifier adds some persistent data that
- // other modifiers need to use, but the modifier is run after the dependent
- // one.
- function runModifierEffects() {
- state.orderedModifiers.forEach(function (_ref3) {
- var name = _ref3.name,
- _ref3$options = _ref3.options,
- options = _ref3$options === void 0 ? {} : _ref3$options,
- effect = _ref3.effect;
- if (typeof effect === 'function') {
- var cleanupFn = effect({
- state: state,
- name: name,
- instance: instance,
- options: options
- });
- var noopFn = function noopFn() {};
- effectCleanupFns.push(cleanupFn || noopFn);
- }
- });
- }
- function cleanupModifierEffects() {
- effectCleanupFns.forEach(function (fn) {
- return fn();
- });
- effectCleanupFns = [];
- }
- return instance;
- };
- }
- var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
- var createPopper$1 = /*#__PURE__*/popperGenerator({
- defaultModifiers: defaultModifiers
- }); // eslint-disable-next-line import/no-unused-modules
- const popperComputedPlacements = [
- "top",
- "bottom",
- "right",
- "left",
- "top-start",
- "top-end",
- "bottom-start",
- "bottom-end",
- "right-start",
- "right-end",
- "left-start",
- "left-end"
- ];
- const defaultMenuPlacement = "bottom-leading";
- const popperMenuComputedPlacements = [
- "top-start",
- "top",
- "top-end",
- "bottom-start",
- "bottom",
- "bottom-end"
- ];
- const CSS$D = {
- animation: "calcite-popper-anim",
- animationActive: "calcite-popper-anim--active"
- };
- function filterComputedPlacements(placements, el) {
- const filteredPlacements = placements.filter((placement) => popperComputedPlacements.includes(placement));
- if (filteredPlacements.length !== placements.length) {
- console.warn(`${el.tagName}: Invalid value found in: flipPlacements. Try any of these: ${popperComputedPlacements
- .map((placement) => `"${placement}"`)
- .join(", ")
- .trim()}`, { el });
- }
- return filteredPlacements;
- }
- function getPlacement(el, placement) {
- const placements = ["left", "right"];
- const variations = ["start", "end"];
- if (getElementDir(el) === "rtl") {
- placements.reverse();
- variations.reverse();
- }
- return placement
- .replace(/-leading/gi, `-${variations[0]}`)
- .replace(/-trailing/gi, `-${variations[1]}`)
- .replace(/leading/gi, placements[0])
- .replace(/trailing/gi, placements[1]);
- }
- function createPopper({ referenceEl, el, placement, overlayPositioning = "absolute", modifiers }) {
- if (!referenceEl) {
- return null;
- }
- return createPopper$1(referenceEl, el, {
- strategy: overlayPositioning,
- placement: getPlacement(el, placement),
- modifiers
- });
- }
- async function updatePopper({ el, modifiers, placement: PopperPlacement, popper }) {
- const placement = getPlacement(el, PopperPlacement);
- await popper.setOptions({
- modifiers,
- placement
- });
- }
- function hypotenuse(sideA, sideB) {
- return Math.sqrt(Math.pow(sideA, 2) + Math.pow(sideB, 2));
- }
- const visiblePointerSize = 4;
- const defaultOffsetDistance = Math.ceil(hypotenuse(visiblePointerSize, visiblePointerSize));
- const ComboboxItem$1 = "CALCITE-COMBOBOX-ITEM";
- const ComboboxItemGroup$1 = "CALCITE-COMBOBOX-ITEM-GROUP";
- const ComboboxChildSelector = `${ComboboxItem$1}, ${ComboboxItemGroup$1}`;
- const TEXT$g = {
- removeTag: "Remove tag"
- };
- function getAncestors(element) {
- var _a, _b;
- const parent = (_a = element.parentElement) === null || _a === void 0 ? void 0 : _a.closest(ComboboxChildSelector);
- const grandparent = (_b = parent === null || parent === void 0 ? void 0 : parent.parentElement) === null || _b === void 0 ? void 0 : _b.closest(ComboboxChildSelector);
- return [parent, grandparent].filter((el) => el);
- }
- function getItemAncestors(item) {
- var _a;
- return (((_a = item.ancestors) === null || _a === void 0 ? void 0 : _a.filter((el) => el.nodeName === "CALCITE-COMBOBOX-ITEM")) || []);
- }
- function getItemChildren(item) {
- return nodeListToArray(item.querySelectorAll("calcite-combobox-item"));
- }
- function hasActiveChildren(node) {
- const items = nodeListToArray(node.querySelectorAll("calcite-combobox-item"));
- return items.filter((item) => item.selected).length > 0;
- }
- function getDepth(element) {
- if (!Build.isBrowser) {
- return 0;
- }
- const result = document.evaluate("ancestor::calcite-combobox-item | ancestor::calcite-combobox-item-group", element, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
- return result.snapshotLength;
- }
- const comboboxCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;display:block}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host([scale=s]){font-size:var(--calcite-font-size--2);--calcite-combobox-item-spacing-unit-l:0.5rem;--calcite-combobox-item-spacing-unit-s:0.25rem;--calcite-combobox-input-height:1.5rem}:host([scale=m]){font-size:var(--calcite-font-size--1);--calcite-combobox-item-spacing-unit-l:0.75rem;--calcite-combobox-item-spacing-unit-s:0.5rem;--calcite-combobox-input-height:2rem}:host([scale=l]){font-size:var(--calcite-font-size-0);--calcite-combobox-item-spacing-unit-l:1rem;--calcite-combobox-item-spacing-unit-s:0.75rem;--calcite-combobox-input-height:2.75rem}.wrapper{display:-ms-flexbox;display:flex;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-1);outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;-webkit-box-shadow:inset 0 0 0 1px var(--calcite-ui-border-input);box-shadow:inset 0 0 0 1px var(--calcite-ui-border-input);padding:calc(var(--calcite-combobox-item-spacing-unit-s) / 4) var(--calcite-combobox-item-spacing-unit-l)}:host(:focus-within) .wrapper,.wrapper--active{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.wrapper--single{padding:0 var(--calcite-combobox-item-spacing-unit-l);cursor:pointer;-ms-flex-wrap:nowrap;flex-wrap:nowrap}.grid-input{display:-ms-flexbox;display:flex;-ms-flex-positive:1;flex-grow:1;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-align:center;align-items:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0px}.input{-ms-flex-positive:1;flex-grow:1;-webkit-appearance:none;-moz-appearance:none;appearance:none;border-style:none;background-color:transparent;padding:0px;font-family:inherit;color:var(--calcite-ui-text-1);font-size:inherit;height:var(--calcite-combobox-input-height);line-height:var(--calcite-combobox-input-height);min-width:120px;margin-bottom:var(--calcite-combobox-item-spacing-unit-s)}.input:focus{outline:2px solid transparent;outline-offset:2px}.input--transparent{opacity:0}.input--single{margin-bottom:0px;margin-top:0px;padding:0px}.wrapper--active .input-single{cursor:text}.input--hidden{pointer-events:none;width:0px;min-width:0px;opacity:0}.input--icon{padding:0 var(--calcite-combobox-item-spacing-unit-l)}.input-wrap{display:-ms-flexbox;display:flex;-ms-flex-positive:1;flex-grow:1}.input-wrap--single{-ms-flex:1 1 0%;flex:1 1 0%;overflow:hidden}.label{pointer-events:none;display:-ms-flexbox;display:flex;max-width:100%;-ms-flex:1 1 auto;flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0px;font-weight:var(--calcite-font-weight-normal);height:var(--calcite-combobox-input-height);line-height:var(--calcite-combobox-input-height)}.label--spaced{padding-top:0px;padding-bottom:0px;padding-left:var(--calcite-combobox-item-spacing-unit-l);padding-right:var(--calcite-combobox-item-spacing-unit-l)}.icon-end,.icon-start{display:-ms-flexbox;display:flex;width:1rem;cursor:pointer;-ms-flex-align:center;align-items:center}.icon-end{-ms-flex:none;flex:none}.popper-container{width:100%;display:block;position:absolute;z-index:900;-webkit-transform:scale(0);transform:scale(0);visibility:hidden;pointer-events:none}.popper-container .calcite-popper-anim{position:relative;z-index:1;-webkit-transition:var(--calcite-popper-transition);transition:var(--calcite-popper-transition);visibility:hidden;-webkit-transition-property:visibility, opacity, -webkit-transform;transition-property:visibility, opacity, -webkit-transform;transition-property:transform, visibility, opacity;transition-property:transform, visibility, opacity, -webkit-transform;opacity:0;-webkit-box-shadow:0 0 16px 0 rgba(0, 0, 0, 0.16);box-shadow:0 0 16px 0 rgba(0, 0, 0, 0.16);border-radius:0.25rem}.popper-container[data-popper-placement^=bottom] .calcite-popper-anim{-webkit-transform:translateY(-5px);transform:translateY(-5px)}.popper-container[data-popper-placement^=top] .calcite-popper-anim{-webkit-transform:translateY(5px);transform:translateY(5px)}.popper-container[data-popper-placement^=left] .calcite-popper-anim{-webkit-transform:translateX(5px);transform:translateX(5px)}.popper-container[data-popper-placement^=right] .calcite-popper-anim{-webkit-transform:translateX(-5px);transform:translateX(-5px)}.popper-container[data-popper-placement] .calcite-popper-anim--active{opacity:1;visibility:visible;-webkit-transform:translate(0);transform:translate(0)}.popper-container--active{pointer-events:initial;visibility:visible}.screen-readers-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}.list-container{max-height:100vh;overflow-y:auto;background-color:var(--calcite-ui-foreground-1);width:var(--calcite-dropdown-width)}.list{margin:0px;display:block;padding:0px}.list--hide{height:0px;overflow:hidden}.chip{margin-block:calc(var(--calcite-combobox-item-spacing-unit-s) / 4);margin-inline:0 var(--calcite-combobox-item-spacing-unit-s);max-width:100%}.chip--active{background-color:var(--calcite-ui-foreground-3)}.item{display:block}::slotted(input[slot=hidden-form-input]){bottom:0 !important;left:0 !important;margin:0 !important;opacity:0 !important;outline:none !important;padding:0 !important;position:absolute !important;right:0 !important;top:0 !important;-webkit-transform:none !important;transform:none !important;-webkit-appearance:none !important;z-index:-1 !important}";
- const isGroup = (el) => el.tagName === ComboboxItemGroup$1;
- const itemUidPrefix = "combobox-item-";
- const chipUidPrefix = "combobox-chip-";
- const labelUidPrefix = "combobox-label-";
- const listboxUidPrefix = "combobox-listbox-";
- const inputUidPrefix = "combobox-input-";
- const Combobox = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteLookupChange = createEvent(this, "calciteLookupChange", 7);
- this.calciteComboboxChange = createEvent(this, "calciteComboboxChange", 7);
- this.calciteComboboxFilterChange = createEvent(this, "calciteComboboxFilterChange", 7);
- this.calciteComboboxChipDismiss = createEvent(this, "calciteComboboxChipDismiss", 7);
- this.calciteComboboxOpen = createEvent(this, "calciteComboboxOpen", 7);
- this.calciteComboboxClose = createEvent(this, "calciteComboboxClose", 7);
- //--------------------------------------------------------------------------
- //
- // Public Properties
- //
- //--------------------------------------------------------------------------
- /** Opens or closes the combobox */
- this.active = false;
- /** Disable combobox input */
- this.disabled = false;
- /** Specify the maximum number of combobox items (including nested children) to display before showing the scroller */
- this.maxItems = 0;
- /** Describes the type of positioning to use for the overlaid content. If your element is in a fixed container, use the 'fixed' value. */
- this.overlayPositioning = "absolute";
- /**
- * When true, makes the component required for form-submission.
- *
- * @internal
- */
- this.required = false;
- /** specify the selection mode
- * - multi: allow any number of selected items (default)
- * - single: only one selection)
- * - ancestors: like multi, but show ancestors of selected items as selected, only deepest children shown in chips
- */
- this.selectionMode = "multi";
- /** Specify the scale of the combobox, defaults to m */
- this.scale = "m";
- /** The value(s) of the selectedItem(s) */
- this.value = null;
- /** string to override the English "Remove tag" text for when an item is selected.
- * @default "Remove tag"
- */
- this.intlRemoveTag = TEXT$g.removeTag;
- this.internalValueChangeFlag = false;
- this.items = [];
- this.groupItems = [];
- this.selectedItems = [];
- this.visibleItems = [];
- this.activeItemIndex = -1;
- this.activeChipIndex = -1;
- this.activeDescendant = "";
- this.text = "";
- this.textInput = null;
- this.mutationObserver = createObserver("mutation", () => this.updateItems());
- this.resizeObserver = createObserver("resize", () => this.setMaxScrollerHeight());
- this.guid = guid();
- this.inputHeight = 0;
- this.ignoreSelectedEventsFlag = false;
- this.activeTransitionProp = "opacity";
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- this.setFilteredPlacements = () => {
- const { el, flipPlacements } = this;
- this.filteredFlipPlacements = flipPlacements
- ? filterComputedPlacements(flipPlacements, el)
- : null;
- };
- this.getValue = () => {
- const items = this.selectedItems.map((item) => { var _a; return (_a = item === null || item === void 0 ? void 0 : item.value) === null || _a === void 0 ? void 0 : _a.toString(); });
- return (items === null || items === void 0 ? void 0 : items.length) ? (items.length > 1 ? items : items[0]) : "";
- };
- this.onLabelClick = () => {
- this.setFocus();
- };
- this.keydownHandler = (event) => {
- const { key } = event;
- switch (key) {
- case "Tab":
- this.activeChipIndex = -1;
- this.activeItemIndex = -1;
- if (this.allowCustomValues && this.text) {
- this.addCustomChip(this.text, true);
- event.preventDefault();
- }
- else if (this.active) {
- this.active = false;
- event.preventDefault();
- }
- break;
- case "ArrowLeft":
- this.previousChip();
- break;
- case "ArrowRight":
- this.nextChip();
- break;
- case "ArrowUp":
- this.shiftActiveItemIndex(-1);
- if (!this.comboboxInViewport()) {
- this.el.scrollIntoView();
- }
- break;
- case "ArrowDown":
- if (!this.active) {
- event.preventDefault();
- this.active = true;
- }
- this.shiftActiveItemIndex(1);
- if (!this.comboboxInViewport()) {
- this.el.scrollIntoView();
- }
- break;
- case " ":
- if (!this.textInput.value) {
- event.preventDefault();
- this.active = true;
- this.shiftActiveItemIndex(1);
- }
- break;
- case "Home":
- if (this.active) {
- event.preventDefault();
- }
- this.updateActiveItemIndex(0);
- this.scrollToActiveItem();
- if (!this.comboboxInViewport()) {
- this.el.scrollIntoView();
- }
- break;
- case "End":
- if (this.active) {
- event.preventDefault();
- }
- this.updateActiveItemIndex(this.visibleItems.length - 1);
- this.scrollToActiveItem();
- if (!this.comboboxInViewport()) {
- this.el.scrollIntoView();
- }
- break;
- case "Escape":
- this.active = false;
- break;
- case "Enter":
- if (this.activeItemIndex > -1) {
- this.toggleSelection(this.visibleItems[this.activeItemIndex]);
- }
- else if (this.activeChipIndex > -1) {
- this.removeActiveChip();
- }
- else if (this.allowCustomValues && this.text) {
- this.addCustomChip(this.text, true);
- }
- else if (!event.defaultPrevented) {
- submitForm(this);
- }
- break;
- case "Delete":
- case "Backspace":
- if (this.activeChipIndex > -1) {
- this.removeActiveChip();
- }
- else if (!this.text && this.isMulti()) {
- this.removeLastChip();
- }
- break;
- }
- };
- this.toggleCloseEnd = () => {
- this.active = false;
- this.el.removeEventListener("calciteComboboxClose", this.toggleCloseEnd);
- };
- this.toggleOpenEnd = () => {
- this.active = true;
- this.el.removeEventListener("calciteComboboxOpen", this.toggleOpenEnd);
- };
- this.transitionEnd = (event) => {
- if (event.propertyName === this.activeTransitionProp) {
- this.active ? this.calciteComboboxOpen.emit() : this.calciteComboboxClose.emit();
- }
- };
- this.setMaxScrollerHeight = () => {
- const { active, listContainerEl } = this;
- if (!listContainerEl || !active) {
- return;
- }
- this.reposition();
- const maxScrollerHeight = this.getMaxScrollerHeight();
- listContainerEl.style.maxHeight = maxScrollerHeight > 0 ? `${maxScrollerHeight}px` : "";
- this.reposition();
- };
- this.calciteChipDismissHandler = (event, comboboxItem) => {
- this.active = false;
- const selection = this.items.find((item) => item === comboboxItem);
- if (selection) {
- this.toggleSelection(selection, false);
- }
- this.calciteComboboxChipDismiss.emit(event.detail);
- };
- this.clickHandler = (event) => {
- if (event.composedPath().some((node) => node.tagName === "CALCITE-CHIP")) {
- return;
- }
- this.active = !this.active;
- this.updateActiveItemIndex(0);
- this.setFocus();
- };
- this.setInactiveIfNotContained = (event) => {
- const composedPath = event.composedPath();
- if (!this.active || composedPath.includes(this.el) || composedPath.includes(this.referenceEl)) {
- return;
- }
- if (this.allowCustomValues && this.text.trim().length) {
- this.addCustomChip(this.text);
- }
- if (this.selectionMode === "single") {
- if (this.textInput) {
- this.textInput.value = "";
- }
- this.text = "";
- this.filterItems("");
- this.updateActiveItemIndex(-1);
- }
- this.active = false;
- };
- this.setMenuEl = (el) => {
- this.menuEl = el;
- };
- this.setListContainerEl = (el) => {
- this.resizeObserver.observe(el);
- this.listContainerEl = el;
- };
- this.setReferenceEl = (el) => {
- this.referenceEl = el;
- };
- this.inputHandler = (event) => {
- const value = event.target.value;
- this.text = value;
- this.filterItems(value);
- if (value) {
- this.activeChipIndex = -1;
- }
- };
- this.filterItems = (() => {
- const find = (item, filteredData) => item &&
- filteredData.some(({ label, value }) => {
- if (isGroup(item)) {
- return value === item.label;
- }
- return (value === item.textLabel ||
- value === item.value ||
- label === item.textLabel ||
- label === item.value);
- });
- return debounce$1((text) => {
- const filteredData = filter(this.data, text);
- const items = this.getCombinedItems();
- items.forEach((item) => {
- const hidden = !find(item, filteredData);
- item.hidden = hidden;
- const [parent, grandparent] = item.ancestors;
- if (find(parent, filteredData) || find(grandparent, filteredData)) {
- item.hidden = false;
- }
- if (!hidden) {
- item.ancestors.forEach((ancestor) => (ancestor.hidden = false));
- }
- });
- this.visibleItems = this.getVisibleItems();
- this.calciteComboboxFilterChange.emit({ visibleItems: [...this.visibleItems], text: text });
- }, 100);
- })();
- this.internalCalciteLookupChangeEvent = () => {
- this.calciteLookupChange.emit(this.selectedItems);
- };
- this.emitCalciteLookupChange = debounce$1(this.internalCalciteLookupChangeEvent, 0);
- this.internalComboboxChangeEvent = () => {
- const { selectedItems } = this;
- this.calciteComboboxChange.emit({ selectedItems });
- };
- this.emitComboboxChange = debounce$1(this.internalComboboxChangeEvent, 0);
- this.updateItems = () => {
- this.items = this.getItems();
- this.groupItems = this.getGroupItems();
- this.data = this.getData();
- this.selectedItems = this.getSelectedItems();
- this.visibleItems = this.getVisibleItems();
- this.needsIcon = this.getNeedsIcon();
- if (!this.allowCustomValues) {
- this.setMaxScrollerHeight();
- }
- };
- this.scrollToActiveItem = () => {
- const activeItem = this.visibleItems[this.activeItemIndex];
- const height = this.calculateSingleItemHeight(activeItem);
- const { offsetHeight, scrollTop } = this.listContainerEl;
- if (offsetHeight + scrollTop < activeItem.offsetTop + height) {
- this.listContainerEl.scrollTop = activeItem.offsetTop - offsetHeight + height;
- }
- else if (activeItem.offsetTop < scrollTop) {
- this.listContainerEl.scrollTop = activeItem.offsetTop;
- }
- };
- this.comboboxFocusHandler = () => {
- var _a;
- (_a = this.textInput) === null || _a === void 0 ? void 0 : _a.focus();
- };
- this.comboboxBlurHandler = (event) => {
- this.setInactiveIfNotContained(event);
- };
- }
- activeHandler() {
- if (this.disabled) {
- this.active = false;
- return;
- }
- this.reposition();
- }
- handleDisabledChange(value) {
- if (!value) {
- this.active = false;
- }
- }
- maxItemsHandler() {
- this.setMaxScrollerHeight();
- }
- valueHandler(value) {
- if (!this.internalValueChangeFlag) {
- const items = this.getItems();
- if (Array.isArray(value)) {
- items.forEach((item) => (item.selected = value.includes(item.value)));
- }
- else if (value) {
- items.forEach((item) => (item.selected = value === item.value));
- }
- else {
- items.forEach((item) => (item.selected = false));
- }
- this.updateItems();
- }
- }
- flipPlacementsHandler() {
- this.setFilteredPlacements();
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- documentClickHandler(event) {
- this.setInactiveIfNotContained(event);
- }
- calciteComboboxItemChangeHandler(event) {
- if (this.ignoreSelectedEventsFlag) {
- return;
- }
- const target = event.target;
- const newIndex = this.visibleItems.indexOf(target);
- this.updateActiveItemIndex(newIndex);
- this.toggleSelection(target, target.selected);
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /** Updates the position of the component. */
- async reposition() {
- const { popper, menuEl } = this;
- const modifiers = this.getModifiers();
- popper
- ? await updatePopper({
- el: menuEl,
- modifiers,
- placement: defaultMenuPlacement,
- popper
- })
- : this.createPopper();
- }
- /** Sets focus on the component. */
- async setFocus() {
- var _a;
- (_a = this.textInput) === null || _a === void 0 ? void 0 : _a.focus();
- this.activeChipIndex = -1;
- this.activeItemIndex = -1;
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- var _a;
- this.internalValueChangeFlag = true;
- this.value = this.getValue();
- this.internalValueChangeFlag = false;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
- this.createPopper();
- connectLabel(this);
- connectForm(this);
- this.setFilteredPlacements();
- }
- componentWillLoad() {
- this.updateItems();
- }
- componentDidLoad() {
- afterConnectDefaultValueSet(this, this.getValue());
- }
- componentDidRender() {
- if (this.el.offsetHeight !== this.inputHeight) {
- this.reposition();
- this.inputHeight = this.el.offsetHeight;
- }
- updateHostInteraction(this);
- }
- disconnectedCallback() {
- var _a, _b;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- (_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
- this.destroyPopper();
- disconnectLabel(this);
- disconnectForm(this);
- }
- selectedItemsHandler() {
- this.internalValueChangeFlag = true;
- this.value = this.getValue();
- this.internalValueChangeFlag = false;
- }
- /** when search text is cleared, reset active to */
- textHandler() {
- this.updateActiveItemIndex(-1);
- }
- comboboxInViewport() {
- const bounding = this.el.getBoundingClientRect();
- return (bounding.top >= 0 &&
- bounding.left >= 0 &&
- bounding.right <= (window.innerWidth || document.documentElement.clientWidth) &&
- bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight));
- }
- getModifiers() {
- const flipModifier = {
- name: "flip",
- enabled: true
- };
- flipModifier.options = {
- fallbackPlacements: this.filteredFlipPlacements || popperMenuComputedPlacements
- };
- const eventListenerModifier = {
- name: "eventListeners",
- enabled: this.active
- };
- return [flipModifier, eventListenerModifier];
- }
- createPopper() {
- this.destroyPopper();
- const { menuEl, referenceEl, overlayPositioning } = this;
- const modifiers = this.getModifiers();
- this.popper = createPopper({
- el: menuEl,
- modifiers,
- overlayPositioning,
- placement: defaultMenuPlacement,
- referenceEl
- });
- }
- destroyPopper() {
- const { popper } = this;
- if (popper) {
- popper.destroy();
- }
- this.popper = null;
- }
- getMaxScrollerHeight() {
- const items = this.getCombinedItems().filter((item) => !item.hidden);
- const { maxItems } = this;
- let itemsToProcess = 0;
- let maxScrollerHeight = 0;
- if (items.length > maxItems) {
- items.forEach((item) => {
- if (itemsToProcess < maxItems && maxItems > 0) {
- const height = this.calculateSingleItemHeight(item);
- if (height > 0) {
- maxScrollerHeight += height;
- itemsToProcess++;
- }
- }
- });
- }
- return maxScrollerHeight;
- }
- calculateSingleItemHeight(item) {
- let height = item.offsetHeight;
- // if item has children items, don't count their height twice
- const children = Array.from(item.querySelectorAll(ComboboxChildSelector));
- children
- .map((child) => child === null || child === void 0 ? void 0 : child.offsetHeight)
- .forEach((offsetHeight) => {
- height -= offsetHeight;
- });
- return height;
- }
- getCombinedItems() {
- return [...this.groupItems, ...this.items];
- }
- toggleSelection(item, value = !item.selected) {
- if (!item) {
- return;
- }
- if (this.isMulti()) {
- item.selected = value;
- this.updateAncestors(item);
- this.selectedItems = this.getSelectedItems();
- this.emitCalciteLookupChange();
- this.emitComboboxChange();
- this.resetText();
- this.filterItems("");
- }
- else {
- this.ignoreSelectedEventsFlag = true;
- this.items.forEach((el) => (el.selected = el === item ? value : false));
- this.ignoreSelectedEventsFlag = false;
- this.selectedItems = this.getSelectedItems();
- this.emitComboboxChange();
- if (this.textInput) {
- this.textInput.value = item.textLabel;
- }
- this.active = false;
- this.updateActiveItemIndex(-1);
- this.resetText();
- this.filterItems("");
- }
- }
- updateAncestors(item) {
- if (this.selectionMode !== "ancestors") {
- return;
- }
- const ancestors = getItemAncestors(item);
- const children = getItemChildren(item);
- if (item.selected) {
- ancestors.forEach((el) => {
- el.selected = true;
- });
- }
- else {
- children.forEach((el) => (el.selected = false));
- [...ancestors].forEach((el) => {
- if (!hasActiveChildren(el)) {
- el.selected = false;
- }
- });
- }
- }
- getVisibleItems() {
- return this.items.filter((item) => !item.hidden);
- }
- getSelectedItems() {
- if (!this.isMulti()) {
- const match = this.items.find(({ selected }) => selected);
- return match ? [match] : [];
- }
- return (this.items
- .filter((item) => item.selected && (this.selectionMode !== "ancestors" || !hasActiveChildren(item)))
- /** Preserve order of entered tags */
- .sort((a, b) => {
- const aIdx = this.selectedItems.indexOf(a);
- const bIdx = this.selectedItems.indexOf(b);
- if (aIdx > -1 && bIdx > -1) {
- return aIdx - bIdx;
- }
- return bIdx - aIdx;
- }));
- }
- getData() {
- return this.items.map((item) => ({
- constant: item.constant,
- value: item.value,
- label: item.textLabel
- }));
- }
- getNeedsIcon() {
- return this.selectionMode === "single" && this.items.some((item) => item.icon);
- }
- resetText() {
- if (this.textInput) {
- this.textInput.value = "";
- }
- this.text = "";
- }
- getItems() {
- const items = Array.from(this.el.querySelectorAll(ComboboxItem$1));
- return items.filter((item) => !item.disabled);
- }
- getGroupItems() {
- return Array.from(this.el.querySelectorAll(ComboboxItemGroup$1));
- }
- addCustomChip(value, focus) {
- const existingItem = this.items.find((el) => el.textLabel === value);
- if (existingItem) {
- this.toggleSelection(existingItem, true);
- }
- else {
- if (!this.isMulti()) {
- this.toggleSelection(this.selectedItems[this.selectedItems.length - 1], false);
- }
- const item = document.createElement(ComboboxItem$1);
- item.value = value;
- item.textLabel = value;
- item.selected = true;
- this.el.appendChild(item);
- this.resetText();
- if (focus) {
- this.setFocus();
- }
- this.updateItems();
- this.filterItems("");
- this.emitCalciteLookupChange();
- this.emitComboboxChange();
- }
- }
- removeActiveChip() {
- this.toggleSelection(this.selectedItems[this.activeChipIndex], false);
- this.setFocus();
- }
- removeLastChip() {
- this.toggleSelection(this.selectedItems[this.selectedItems.length - 1], false);
- this.setFocus();
- }
- previousChip() {
- if (this.text) {
- return;
- }
- const length = this.selectedItems.length - 1;
- const active = this.activeChipIndex;
- this.activeChipIndex = active === -1 ? length : Math.max(active - 1, 0);
- this.updateActiveItemIndex(-1);
- this.focusChip();
- }
- nextChip() {
- if (this.text || this.activeChipIndex === -1) {
- return;
- }
- const last = this.selectedItems.length - 1;
- const newIndex = this.activeChipIndex + 1;
- if (newIndex > last) {
- this.activeChipIndex = -1;
- this.setFocus();
- }
- else {
- this.activeChipIndex = newIndex;
- this.focusChip();
- }
- this.updateActiveItemIndex(-1);
- }
- focusChip() {
- var _a;
- const guid = (_a = this.selectedItems[this.activeChipIndex]) === null || _a === void 0 ? void 0 : _a.guid;
- const chip = guid
- ? this.referenceEl.querySelector(`#${chipUidPrefix}${guid}`)
- : null;
- chip === null || chip === void 0 ? void 0 : chip.setFocus();
- }
- shiftActiveItemIndex(delta) {
- const { length } = this.visibleItems;
- const newIndex = (this.activeItemIndex + length + delta) % length;
- this.updateActiveItemIndex(newIndex);
- this.scrollToActiveItem();
- }
- updateActiveItemIndex(index) {
- var _a;
- this.activeItemIndex = index;
- let activeDescendant = null;
- this.visibleItems.forEach((el, i) => {
- if (i === index) {
- el.active = true;
- activeDescendant = el.guid;
- }
- else {
- el.active = false;
- }
- });
- this.activeDescendant = activeDescendant;
- if (this.activeItemIndex > -1) {
- this.activeChipIndex = -1;
- (_a = this.textInput) === null || _a === void 0 ? void 0 : _a.focus();
- }
- }
- isMulti() {
- return this.selectionMode !== "single";
- }
- //--------------------------------------------------------------------------
- //
- // Render Methods
- //
- //--------------------------------------------------------------------------
- renderChips() {
- const { activeChipIndex, scale, selectionMode, intlRemoveTag } = this;
- return this.selectedItems.map((item, i) => {
- const chipClasses = {
- chip: true,
- "chip--active": activeChipIndex === i
- };
- const ancestors = [...getItemAncestors(item)].reverse();
- const pathLabel = [...ancestors, item].map((el) => el.textLabel);
- const label = selectionMode !== "ancestors" ? item.textLabel : pathLabel.join(" / ");
- return (h("calcite-chip", { class: chipClasses, dismissLabel: intlRemoveTag, dismissible: true, icon: item.icon, id: item.guid ? `${chipUidPrefix}${item.guid}` : null, key: item.textLabel, onCalciteChipDismiss: (event) => this.calciteChipDismissHandler(event, item), scale: scale, title: label, value: item.value }, label));
- });
- }
- renderInput() {
- const { guid, active, disabled, placeholder, selectionMode, needsIcon, selectedItems } = this;
- const single = selectionMode === "single";
- const selectedItem = selectedItems[0];
- const showLabel = !active && single && !!selectedItem;
- return (h("span", { class: {
- "input-wrap": true,
- "input-wrap--single": single
- } }, showLabel && (h("span", { class: {
- label: true,
- "label--spaced": needsIcon
- }, key: "label" }, selectedItem.textLabel)), h("input", { "aria-activedescendant": this.activeDescendant, "aria-autocomplete": "list", "aria-controls": `${listboxUidPrefix}${guid}`, "aria-label": getLabelText(this), class: {
- input: true,
- "input--single": true,
- "input--transparent": this.activeChipIndex > -1,
- "input--hidden": showLabel,
- "input--icon": single && needsIcon
- }, disabled: disabled, id: `${inputUidPrefix}${guid}`, key: "input", onBlur: this.comboboxBlurHandler, onFocus: this.comboboxFocusHandler, onInput: this.inputHandler, placeholder: placeholder, ref: (el) => (this.textInput = el), type: "text" })));
- }
- renderListBoxOptions() {
- return this.visibleItems.map((item) => (h("li", { "aria-selected": toAriaBoolean(item.selected), id: item.guid ? `${itemUidPrefix}${item.guid}` : null, role: "option", tabindex: "-1" }, item.textLabel)));
- }
- renderPopperContainer() {
- const { active, setMenuEl, setListContainerEl } = this;
- const classes = {
- "list-container": true,
- [CSS$D.animation]: true,
- [CSS$D.animationActive]: active
- };
- return (h("div", { "aria-hidden": "true", class: { "popper-container": true, "popper-container--active": active }, ref: setMenuEl }, h("div", { class: classes, onTransitionEnd: this.transitionEnd, ref: setListContainerEl }, h("ul", { class: { list: true, "list--hide": !active } }, h("slot", null)))));
- }
- renderIconStart() {
- const { selectionMode, needsIcon, selectedItems } = this;
- const selectedItem = selectedItems[0];
- return (selectionMode === "single" &&
- needsIcon && (h("span", { class: "icon-start" }, (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.icon) && (h("calcite-icon", { class: "selected-icon", icon: selectedItem.icon, scale: "s" })))));
- }
- renderIconEnd() {
- const { active } = this;
- return (h("span", { class: "icon-end" }, h("calcite-icon", { icon: active ? "chevron-up" : "chevron-down", scale: "s" })));
- }
- render() {
- const { active, guid, label } = this;
- const single = this.selectionMode === "single";
- return (h(Host, { onKeyDown: this.keydownHandler }, h("div", { "aria-autocomplete": "list", "aria-expanded": toAriaBoolean(active), "aria-haspopup": "listbox", "aria-labelledby": `${labelUidPrefix}${guid}`, "aria-owns": `${listboxUidPrefix}${guid}`, class: {
- wrapper: true,
- "wrapper--single": single || !this.selectedItems.length,
- "wrapper--active": active
- }, onClick: this.clickHandler, ref: this.setReferenceEl, role: "combobox" }, h("div", { class: "grid-input" }, this.renderIconStart(), !single && this.renderChips(), h("label", { class: "screen-readers-only", htmlFor: `${inputUidPrefix}${guid}`, id: `${labelUidPrefix}${guid}` }, label), this.renderInput()), this.renderIconEnd()), h("ul", { "aria-labelledby": `${labelUidPrefix}${guid}`, "aria-multiselectable": "true", class: "screen-readers-only", id: `${listboxUidPrefix}${guid}`, role: "listbox", tabIndex: -1 }, this.renderListBoxOptions()), this.renderPopperContainer(), h(HiddenFormInputSlot, { component: this })));
- }
- get el() { return this; }
- static get watchers() { return {
- "active": ["activeHandler"],
- "disabled": ["handleDisabledChange"],
- "maxItems": ["maxItemsHandler"],
- "value": ["valueHandler"],
- "flipPlacements": ["flipPlacementsHandler"],
- "selectedItems": ["selectedItemsHandler"],
- "text": ["textHandler"]
- }; }
- static get style() { return comboboxCss; }
- };
- const CSS$C = {
- icon: "icon",
- iconActive: "icon--active",
- custom: "icon--custom",
- dot: "icon--dot",
- single: "label--single",
- label: "label",
- active: "label--active",
- selected: "label--selected",
- title: "title",
- textContainer: "text-container"
- };
- const comboboxItemCss = "@charset \"UTF-8\";@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}.scale--s{font-size:var(--calcite-font-size--2);line-height:1rem;--calcite-combobox-item-spacing-unit-l:0.5rem;--calcite-combobox-item-spacing-unit-s:0.25rem;--calcite-combobox-item-spacing-indent:0.5rem}.scale--m{font-size:var(--calcite-font-size--1);line-height:1rem;--calcite-combobox-item-spacing-unit-l:0.75rem;--calcite-combobox-item-spacing-unit-s:0.5rem;--calcite-combobox-item-spacing-indent:0.75rem}.scale--l{font-size:var(--calcite-font-size-0);line-height:1.25rem;--calcite-combobox-item-spacing-unit-l:1rem;--calcite-combobox-item-spacing-unit-s:0.75rem;--calcite-combobox-item-spacing-indent:1rem}.container{--calcite-combobox-item-indent-value:calc(\n var(--calcite-combobox-item-spacing-indent) * var(--calcite-combobox-item-spacing-indent-multiplier)\n )}:host(:focus){--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host,ul{margin:0px;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;padding:0px;outline:2px solid transparent;outline-offset:2px}.label{position:relative;-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;width:100%;min-width:100%;cursor:pointer;-ms-flex-align:center;align-items:center;color:var(--calcite-ui-text-3);-webkit-text-decoration-line:none;text-decoration-line:none;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;padding:var(--calcite-combobox-item-spacing-unit-s) var(--calcite-combobox-item-spacing-unit-l)}:host([disabled]) .label{cursor:default}.label--selected{font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1)}.label--active{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.label:hover,.label:active{background-color:var(--calcite-ui-foreground-2);color:var(--calcite-ui-text-1);-webkit-text-decoration-line:none;text-decoration-line:none;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.title{padding:0 var(--calcite-combobox-item-spacing-unit-l)}.icon{display:-ms-inline-flexbox;display:inline-flex;opacity:0;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);color:var(--calcite-ui-border-1)}.icon--indent{-webkit-padding-start:var(--calcite-combobox-item-indent-value);padding-inline-start:var(--calcite-combobox-item-indent-value)}.icon--custom{margin-top:-1px;color:var(--calcite-ui-text-3)}.icon--active{color:var(--calcite-ui-text-1)}.icon--dot{display:-ms-flexbox;display:flex;-ms-flex-pack:end;justify-content:flex-end;min-width:var(--calcite-combobox-item-spacing-unit-l)}.icon--dot:before{text-align:start;content:\"•\"}.label--active .icon{opacity:1}.label--selected .icon{opacity:1;color:var(--calcite-ui-brand)}:host(:hover[disabled]) .icon{opacity:1}";
- const ComboboxItem = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteComboboxItemChange = createEvent(this, "calciteComboboxItemChange", 7);
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /** When true, the item cannot be clicked and is visually muted. */
- this.disabled = false;
- /** Set this to true to pre-select an item. Toggles when an item is checked/unchecked. */
- this.selected = false;
- /** True when item is highlighted either from keyboard or mouse hover */
- this.active = false;
- /** Unique identifier, used for accessibility */
- this.guid = guid();
- this.scale = "m";
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- this.itemClickHandler = (event) => {
- event.preventDefault();
- if (this.disabled) {
- return;
- }
- this.selected = !this.selected;
- };
- }
- selectedWatchHandler() {
- this.calciteComboboxItemChange.emit(this.el);
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- this.ancestors = getAncestors(this.el);
- this.scale = getElementProp(this.el, "scale", this.scale);
- connectConditionalSlotComponent(this);
- }
- disconnectedCallback() {
- disconnectConditionalSlotComponent(this);
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- // --------------------------------------------------------------------------
- //
- // Public Methods
- //
- // --------------------------------------------------------------------------
- /**
- * Used to toggle the selection state. By default this won't trigger an event.
- * The first argument allows the value to be coerced, rather than swapping values.
- */
- async toggleSelected(coerce) {
- if (this.disabled) {
- return;
- }
- this.selected = typeof coerce === "boolean" ? coerce : !this.selected;
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- renderIcon(isSingle) {
- const { icon, disabled, selected } = this;
- const level = `${CSS$C.icon}--indent`;
- const defaultIcon = isSingle ? "dot" : "check";
- const iconPath = disabled ? "circle-disallowed" : defaultIcon;
- const showDot = isSingle && !icon && !disabled;
- return showDot ? (h("span", { class: {
- [CSS$C.icon]: true,
- [CSS$C.dot]: true,
- [level]: true
- } })) : (h("calcite-icon", { class: {
- [CSS$C.icon]: !icon,
- [CSS$C.custom]: !!icon,
- [CSS$C.iconActive]: icon && selected,
- [level]: true
- }, icon: icon || iconPath, scale: "s" }));
- }
- renderChildren() {
- if (getSlotted(this.el)) {
- return (h("ul", { key: "default-slot-container" }, h("slot", null)));
- }
- return null;
- }
- render() {
- const isSingleSelect = getElementProp(this.el, "selection-mode", "multi") === "single";
- const classes = {
- [CSS$C.label]: true,
- [CSS$C.selected]: this.selected,
- [CSS$C.active]: this.active,
- [CSS$C.single]: isSingleSelect
- };
- const depth = getDepth(this.el);
- return (h(Host, { "aria-hidden": "true" }, h("div", { class: `container scale--${this.scale}`, style: { "--calcite-combobox-item-spacing-indent-multiplier": `${depth}` } }, h("li", { class: classes, id: this.guid, onClick: this.itemClickHandler }, this.renderIcon(isSingleSelect), h("span", { class: CSS$C.title }, this.textLabel)), this.renderChildren())));
- }
- get el() { return this; }
- static get watchers() { return {
- "selected": ["selectedWatchHandler"]
- }; }
- static get style() { return comboboxItemCss; }
- };
- const CSS$B = {
- list: "list",
- label: "label",
- title: "title"
- };
- const comboboxItemGroupCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}.scale--s{font-size:var(--calcite-font-size--2);line-height:1rem;--calcite-combobox-item-spacing-unit-l:0.5rem;--calcite-combobox-item-spacing-unit-s:0.25rem;--calcite-combobox-item-spacing-indent-1:0.5rem;--calcite-combobox-item-spacing-indent-2:1rem}.scale--m{font-size:var(--calcite-font-size--1);line-height:1rem;--calcite-combobox-item-spacing-unit-l:0.75rem;--calcite-combobox-item-spacing-unit-s:0.5rem;--calcite-combobox-item-spacing-indent-1:0.75rem;--calcite-combobox-item-spacing-indent-2:1.5rem}.scale--l{font-size:var(--calcite-font-size-0);line-height:1.25rem;--calcite-combobox-item-spacing-unit-l:1rem;--calcite-combobox-item-spacing-unit-s:0.75rem;--calcite-combobox-item-spacing-indent-1:1rem;--calcite-combobox-item-spacing-indent-2:2rem}:host,.list{margin:0px;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;padding:0px;outline:2px solid transparent;outline-offset:2px}.label{-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;width:100%;min-width:0px;max-width:100%;color:var(--calcite-ui-text-3)}.label--indent-1{-webkit-padding-start:var(--calcite-combobox-item-spacing-indent-1);padding-inline-start:var(--calcite-combobox-item-spacing-indent-1)}.label--indent-2{-webkit-padding-start:var(--calcite-combobox-item-spacing-indent-2);padding-inline-start:var(--calcite-combobox-item-spacing-indent-2)}.title{border:0 solid;display:block;-ms-flex:1 1 0%;flex:1 1 0%;border-bottom-width:1px;font-weight:var(--calcite-font-weight-bold);color:var(--calcite-ui-text-2);word-wrap:break-word;word-break:break-word;border-bottom-color:var(--calcite-ui-border-3);padding:var(--calcite-combobox-item-spacing-unit-l) 0;margin-left:var(--calcite-combobox-item-spacing-unit-s);margin-right:var(--calcite-combobox-item-spacing-unit-s)}";
- const ComboboxItemGroup = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.guid = guid();
- this.scale = "m";
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- this.ancestors = getAncestors(this.el);
- this.scale = getElementProp(this.el, "scale", this.scale);
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- render() {
- const { el, scale } = this;
- const indent = `${CSS$B.label}--indent-${getDepth(el)}`;
- return (h("ul", { "aria-labelledby": this.guid, class: { [CSS$B.list]: true, [`scale--${scale}`]: true }, role: "group" }, h("li", { class: { [CSS$B.label]: true, [indent]: true }, id: this.guid, role: "presentation" }, h("span", { class: CSS$B.title }, this.label)), h("slot", null)));
- }
- get el() { return this; }
- static get style() { return comboboxItemGroupCss; }
- };
- function isActivationKey(key) {
- return key === "Enter" || key === " ";
- }
- const numberKeys = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
- function isValidNumber(numberString) {
- return !(!numberString || isNaN(Number(numberString)));
- }
- function parseNumberString(numberString) {
- if (!numberString || !stringContainsNumbers(numberString)) {
- return "";
- }
- return sanitizeExponentialNumberString(numberString, (nonExpoNumString) => {
- let containsDecimal = false;
- const result = nonExpoNumString
- .split("")
- .filter((value, i) => {
- if (value.match(/\./g) && !containsDecimal) {
- containsDecimal = true;
- return true;
- }
- if (value.match(/\-/g) && i === 0) {
- return true;
- }
- return numberKeys.includes(value);
- })
- .reduce((string, part) => string + part);
- return isValidNumber(result) ? Number(result).toString() : "";
- });
- }
- function sanitizeDecimalString(decimalString) {
- const decimalAtEndOfStringButNotStart = /(?!^\.)\.$/;
- return decimalString.replace(decimalAtEndOfStringButNotStart, "");
- }
- function sanitizeNegativeString(negativeString) {
- const allHyphensExceptTheStart = /(?!^-)-/g;
- return negativeString.replace(allHyphensExceptTheStart, "");
- }
- function sanitizeLeadingZeroString(zeroString) {
- const allLeadingZerosOptionallyNegative = /^([-0])0+(?=\d)/;
- return zeroString.replace(allLeadingZerosOptionallyNegative, "$1");
- }
- function sanitizeNumberString(numberString) {
- return sanitizeExponentialNumberString(numberString, (nonExpoNumString) => {
- const sanitizedValue = sanitizeNegativeString(sanitizeDecimalString(sanitizeLeadingZeroString(nonExpoNumString)));
- const isNegativeDecimalOnlyZeros = /^-\b0\b\.?0*$/;
- return isValidNumber(sanitizedValue)
- ? isNegativeDecimalOnlyZeros.test(sanitizedValue)
- ? sanitizedValue
- : Number(sanitizedValue).toString()
- : nonExpoNumString;
- });
- }
- function sanitizeExponentialNumberString(numberString, func) {
- if (!numberString) {
- return numberString;
- }
- const firstE = numberString.toLowerCase().indexOf("e") + 1;
- return numberString
- .replace(/[eE]*$/g, "")
- .substring(0, firstE)
- .concat(numberString.slice(firstE).replace(/[eE]/g, ""))
- .split(/[eE]/)
- .map((section, i) => (i === 1 ? func(section.replace(/\./g, "")) : func(section)))
- .join("e")
- .replace(/^e/, "1e");
- }
- function stringContainsNumbers(string) {
- return numberKeys.some((number) => string.includes(number));
- }
- const locales = [
- "ar",
- "bg",
- "bs",
- "ca",
- "cs",
- "da",
- "de",
- "de-CH",
- "el",
- "en",
- "en-AU",
- "en-CA",
- "en-GB",
- "es",
- "es-MX",
- "et",
- "fi",
- "fr",
- "fr-CH",
- "he",
- "hi",
- "hr",
- "hu",
- "id",
- "it",
- "it-CH",
- "ja",
- "ko",
- "lt",
- "lv",
- "mk",
- "nb",
- "nl",
- "pl",
- "pt",
- "pt-PT",
- "ro",
- "ru",
- "sk",
- "sl",
- "sr",
- "sv",
- "th",
- "tr",
- "uk",
- "vi",
- "zh-CN",
- "zh-HK",
- "zh-TW"
- ];
- const allDecimalsExceptLast = new RegExp(`[.](?=.*[.])`, "g");
- const everythingExceptNumbersDecimalsAndMinusSigns = new RegExp("[^0-9-.]", "g");
- const defaultGroupSeparator = new RegExp(",", "g");
- function createLocaleNumberFormatter(locale) {
- return new Intl.NumberFormat(locale, {
- minimumFractionDigits: 0,
- maximumFractionDigits: 20
- });
- }
- function delocalizeNumberString(numberString, locale) {
- return sanitizeExponentialNumberString(numberString, (nonExpoNumString) => {
- const delocalizedNumberString = nonExpoNumString
- .replace(getMinusSign(locale), "-")
- .replace(getGroupSeparator(locale), "")
- .replace(getDecimalSeparator(locale), ".")
- .replace(allDecimalsExceptLast, "")
- .replace(everythingExceptNumbersDecimalsAndMinusSigns, "");
- return isValidNumber(delocalizedNumberString) ? delocalizedNumberString : nonExpoNumString;
- });
- }
- function getGroupSeparator(locale) {
- const formatter = createLocaleNumberFormatter(locale);
- const parts = formatter.formatToParts(1234567);
- const value = parts.find((part) => part.type === "group").value;
- // change whitespace group characters that don't render correctly
- return value.trim().length === 0 ? " " : value;
- }
- function getDecimalSeparator(locale) {
- const formatter = createLocaleNumberFormatter(locale);
- const parts = formatter.formatToParts(1.1);
- return parts.find((part) => part.type === "decimal").value;
- }
- function getMinusSign(locale) {
- const formatter = createLocaleNumberFormatter(locale);
- const parts = formatter.formatToParts(-9);
- return parts.find((part) => part.type === "minusSign").value;
- }
- function localizeNumberString(numberString, locale, displayGroupSeparator = false) {
- return sanitizeExponentialNumberString(numberString, (nonExpoNumString) => {
- if (nonExpoNumString) {
- const number = Number(sanitizeDecimalString(nonExpoNumString.replace(defaultGroupSeparator, "")));
- if (!isNaN(number)) {
- const formatter = createLocaleNumberFormatter(locale);
- const parts = formatter.formatToParts(number);
- const localizedNumberString = parts
- .map(({ type, value }) => {
- switch (type) {
- case "group":
- return displayGroupSeparator ? getGroupSeparator(locale) : "";
- case "decimal":
- return getDecimalSeparator(locale);
- case "minusSign":
- return getMinusSign(locale);
- default:
- return value;
- }
- })
- .reduce((string, part) => string + part);
- return localizedNumberString;
- }
- }
- return nonExpoNumString;
- });
- }
- /**
- * Get supported locale code from raw user input
- * Exported for testing purposes.
- * @private
- */
- function getSupportedLocale(lang = "") {
- if (locales.indexOf(lang) > -1) {
- return lang;
- }
- lang = lang.toLowerCase();
- if (lang.includes("-")) {
- lang = lang.replace(/(\w+)-(\w+)/, (_match, language, region) => `${language}-${region.toUpperCase()}`);
- if (!locales.includes(lang)) {
- lang = lang.split("-")[0];
- }
- }
- return locales.includes(lang) ? lang : "en";
- }
- /**
- * CLDR cache.
- * Exported for testing purposes.
- * @private
- */
- const translationCache = {};
- /**
- * CLDR request cache.
- * Exported for testing purposes.
- * @private
- */
- const requestCache$1 = {};
- /**
- * Fetch calendar data for a given locale from list of supported languages
- * @public
- */
- async function getLocaleData(lang) {
- const locale = getSupportedLocale(lang);
- if (translationCache[locale]) {
- return translationCache[locale];
- }
- if (!requestCache$1[locale]) {
- requestCache$1[locale] = fetch(getAssetPath(`./assets/date-picker/nls/${locale}.json`))
- .then((resp) => resp.json())
- .catch(() => {
- console.error(`Translations for "${locale}" not found or invalid, falling back to english`);
- return getLocaleData("en");
- });
- }
- const data = await requestCache$1[locale];
- translationCache[locale] = data;
- return data;
- }
- /**
- * Check if date is within a min and max
- */
- function inRange(date, min, max) {
- const time = date.getTime();
- const afterMin = !(min instanceof Date) || time >= min.getTime();
- const beforeMax = !(max instanceof Date) || time <= max.getTime();
- return afterMin && beforeMax;
- }
- /**
- * Ensures date is within range,
- * returns min or max if out of bounds
- */
- function dateFromRange(date, min, max) {
- if (!(date instanceof Date)) {
- return null;
- }
- const time = date.getTime();
- const beforeMin = min instanceof Date && time < min.getTime();
- const afterMax = max instanceof Date && time > max.getTime();
- if (beforeMin) {
- return min;
- }
- if (afterMax) {
- return max;
- }
- return date;
- }
- /**
- * Parse an iso8601 string (YYYY-mm-dd) into a valid date.
- * TODO: handle time when time of day UI is added
- */
- function dateFromISO(iso8601) {
- if (iso8601 instanceof Date) {
- return iso8601;
- }
- if (!iso8601 || typeof iso8601 !== "string") {
- return null;
- }
- const d = iso8601.split(/[: T-]/).map(parseFloat);
- const date = new Date(d[0], (d[1] || 1) - 1, d[2] || 1);
- date.setFullYear(d[0]);
- if (isNaN(date.getTime())) {
- throw new Error(`Invalid ISO 8601 date: "${iso8601}"`);
- }
- return date;
- }
- /**
- * Return first portion of ISO string (YYYY-mm-dd)
- */
- function dateToISO(date) {
- if (typeof date === "string") {
- return date;
- }
- if (date instanceof Date) {
- return new Date(date.getTime() - date.getTimezoneOffset() * 60000).toISOString().split("T")[0];
- }
- return "";
- }
- /**
- * Check if two dates are the same day, month, year
- */
- function sameDate(d1, d2) {
- return (d1 instanceof Date &&
- d2 instanceof Date &&
- d1.getDate() === d2.getDate() &&
- d1.getMonth() === d2.getMonth() &&
- d1.getFullYear() === d2.getFullYear());
- }
- /**
- * Get a date one month in the past
- */
- function prevMonth(date) {
- const month = date.getMonth();
- const nextDate = new Date(date);
- nextDate.setMonth(month - 1);
- // date doesn't exist in new month, use last day
- if (month === nextDate.getMonth()) {
- return new Date(date.getFullYear(), month, 0);
- }
- return nextDate;
- }
- /**
- * Get a date one month in the future
- */
- function nextMonth(date) {
- const month = date.getMonth();
- const nextDate = new Date(date);
- nextDate.setMonth(month + 1);
- // date doesn't exist in new month, use last day
- if ((month + 2) % 7 === nextDate.getMonth() % 7) {
- return new Date(date.getFullYear(), month + 2, 0);
- }
- return nextDate;
- }
- /**
- * Translate a number into a given locals numeral system
- */
- function localizeNumber(num, localeData) {
- return String(num)
- .split("")
- .map((i) => localeData.numerals[i])
- .join("");
- }
- /**
- * Calculate actual number from localized string
- */
- function parseNumber(str, localeData) {
- const numerals = "0123456789";
- return parseInt(str
- .split("")
- .map((i) => numerals[localeData.numerals.indexOf(i)])
- .filter((num) => num)
- .join(""));
- }
- /**
- * Parse numeric units for day, month, and year from a localized string
- * month starts at 0 (can pass to date constructor)
- */
- function parseDateString(str, localeData) {
- const { separator, unitOrder } = localeData;
- const order = getOrder(unitOrder);
- const values = replaceArabicNumerals(str).split(separator);
- return {
- day: parseInt(values[order.indexOf("d")]),
- month: parseInt(values[order.indexOf("m")]) - 1,
- year: parseInt(values[order.indexOf("y")])
- };
- }
- /**
- * Convert eastern arbic numerals
- */
- function replaceArabicNumerals(str = "") {
- return str
- .replace(/[\u0660-\u0669]/g, (c) => (c.charCodeAt(0) - 0x0660))
- .replace(/[\u06f0-\u06f9]/g, (c) => (c.charCodeAt(0) - 0x06f0));
- }
- /**
- * Based on the unitOrder string, find order of month, day, and year for locale
- */
- function getOrder(unitOrder) {
- const signifiers = ["d", "m", "y"];
- const order = unitOrder.toLowerCase();
- return signifiers.sort((a, b) => order.indexOf(a) - order.indexOf(b));
- }
- /**
- * Get number of days between two dates
- */
- function getDaysDiff(date1, date2) {
- const ts1 = date1.getTime();
- const ts2 = date2.getTime();
- return (ts1 - ts2) / (1000 * 3600 * 24);
- }
- const HEADING_LEVEL$6 = 2;
- const TEXT$f = {
- nextMonth: "Next month",
- prevMonth: "Previous month",
- year: "Year"
- };
- const datePickerCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;display:inline-block;width:100%;overflow:visible;border-radius:0px;border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-2);background-color:var(--calcite-ui-foreground-1);vertical-align:top}:host([scale=s]){max-width:216px}:host([scale=m]){max-width:286px}:host([scale=l]){max-width:398px}";
- const DatePicker = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteDatePickerChange = createEvent(this, "calciteDatePickerChange", 7);
- this.calciteDatePickerRangeChange = createEvent(this, "calciteDatePickerRangeChange", 7);
- /** Localized string for "previous month" (used for aria label)
- * @default "Previous month"
- */
- this.intlPrevMonth = TEXT$f.prevMonth;
- /** Localized string for "next month" (used for aria label)
- * @default "Next month"
- */
- this.intlNextMonth = TEXT$f.nextMonth;
- /** Localized string for "year" (used for aria label)
- * @default "Year"
- */
- this.intlYear = TEXT$f.year;
- /** BCP 47 language tag for desired language and country format */
- this.locale = document.documentElement.lang || "en";
- /** specify the scale of the date picker */
- this.scale = "m";
- /** Range mode activation */
- this.range = false;
- /** Disables the default behaviour on the third click of narrowing or extending the range and instead starts a new range. */
- this.proximitySelectionDisabled = false;
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- this.keyUpHandler = (e) => {
- if (e.key === "Escape") {
- this.reset();
- }
- };
- this.monthHeaderSelectChange = (e) => {
- const date = new Date(e.detail);
- if (!this.range) {
- this.activeDate = date;
- }
- else {
- if (this.activeRange === "end") {
- this.activeEndDate = date;
- }
- else {
- this.activeStartDate = date;
- }
- this.mostRecentRangeValue = date;
- }
- };
- this.monthActiveDateChange = (e) => {
- const date = new Date(e.detail);
- if (!this.range) {
- this.activeDate = date;
- }
- else {
- if (this.activeRange === "end") {
- this.activeEndDate = date;
- }
- else {
- this.activeStartDate = date;
- }
- this.mostRecentRangeValue = date;
- }
- };
- this.monthHoverChange = (e) => {
- if (!this.startAsDate) {
- this.hoverRange = undefined;
- return;
- }
- const date = new Date(e.detail);
- this.hoverRange = {
- focused: this.activeRange || "start",
- start: this.startAsDate,
- end: this.endAsDate
- };
- if (!this.proximitySelectionDisabled) {
- if (this.endAsDate) {
- const startDiff = getDaysDiff(date, this.startAsDate);
- const endDiff = getDaysDiff(date, this.endAsDate);
- if (endDiff > 0) {
- this.hoverRange.end = date;
- this.hoverRange.focused = "end";
- }
- else if (startDiff < 0) {
- this.hoverRange.start = date;
- this.hoverRange.focused = "start";
- }
- else if (startDiff > endDiff) {
- this.hoverRange.start = date;
- this.hoverRange.focused = "start";
- }
- else {
- this.hoverRange.end = date;
- this.hoverRange.focused = "end";
- }
- }
- else {
- if (date < this.startAsDate) {
- this.hoverRange = {
- focused: "start",
- start: date,
- end: this.startAsDate
- };
- }
- else {
- this.hoverRange.end = date;
- this.hoverRange.focused = "end";
- }
- }
- }
- else {
- if (!this.endAsDate) {
- if (date < this.startAsDate) {
- this.hoverRange = {
- focused: "start",
- start: date,
- end: this.startAsDate
- };
- }
- else {
- this.hoverRange.end = date;
- this.hoverRange.focused = "end";
- }
- }
- else {
- this.hoverRange = undefined;
- }
- }
- };
- this.monthMouseOutChange = () => {
- if (this.hoverRange) {
- this.hoverRange = undefined;
- }
- };
- /**
- * Reset active date and close
- */
- this.reset = () => {
- var _a, _b, _c, _d, _e, _f;
- if (!Array.isArray(this.valueAsDate) &&
- this.valueAsDate &&
- ((_a = this.valueAsDate) === null || _a === void 0 ? void 0 : _a.getTime()) !== ((_b = this.activeDate) === null || _b === void 0 ? void 0 : _b.getTime())) {
- this.activeDate = new Date(this.valueAsDate);
- }
- if (this.startAsDate && ((_c = this.startAsDate) === null || _c === void 0 ? void 0 : _c.getTime()) !== ((_d = this.activeStartDate) === null || _d === void 0 ? void 0 : _d.getTime())) {
- this.activeStartDate = new Date(this.startAsDate);
- }
- if (this.endAsDate && ((_e = this.endAsDate) === null || _e === void 0 ? void 0 : _e.getTime()) !== ((_f = this.activeEndDate) === null || _f === void 0 ? void 0 : _f.getTime())) {
- this.activeEndDate = new Date(this.endAsDate);
- }
- };
- /**
- * Event handler for when the selected date changes
- */
- this.monthDateChange = (e) => {
- const date = new Date(e.detail);
- if (!this.range) {
- this.value = date ? dateToISO(date) : "";
- this.valueAsDate = date || null;
- this.activeDate = date || null;
- this.calciteDatePickerChange.emit(date);
- return;
- }
- if (!this.startAsDate || (!this.endAsDate && date < this.startAsDate)) {
- if (this.startAsDate) {
- this.setEndDate(new Date(this.startAsDate));
- }
- if (this.activeRange == "end") {
- this.setEndDate(date);
- }
- else {
- this.setStartDate(date);
- }
- }
- else if (!this.endAsDate) {
- this.setEndDate(date);
- }
- else {
- if (!this.proximitySelectionDisabled) {
- if (this.activeRange) {
- if (this.activeRange == "end") {
- this.setEndDate(date);
- }
- else {
- this.setStartDate(date);
- }
- }
- else {
- const startDiff = getDaysDiff(date, this.startAsDate);
- const endDiff = getDaysDiff(date, this.endAsDate);
- if (endDiff === 0 || startDiff < 0) {
- this.setStartDate(date);
- }
- else if (startDiff === 0 || endDiff < 0) {
- this.setEndDate(date);
- }
- else if (startDiff < endDiff) {
- this.setStartDate(date);
- }
- else {
- this.setEndDate(date);
- }
- }
- }
- else {
- this.setStartDate(date);
- this.endAsDate = this.activeEndDate = this.end = undefined;
- }
- }
- this.calciteDatePickerChange.emit(date);
- };
- }
- handleValueAsDate(date) {
- if (!Array.isArray(date) && date && date !== this.activeDate) {
- this.activeDate = date;
- }
- }
- handleRangeChange() {
- const { startAsDate: startDate, endAsDate: endDate } = this;
- this.activeEndDate = endDate;
- this.activeStartDate = startDate;
- }
- onMinChanged(min) {
- if (min) {
- this.minAsDate = dateFromISO(min);
- }
- }
- onMaxChanged(max) {
- if (max) {
- this.maxAsDate = dateFromISO(max);
- }
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- if (Array.isArray(this.value)) {
- this.valueAsDate = this.value.map((v) => dateFromISO(v));
- this.start = this.value[0];
- this.end = this.value[1];
- }
- else if (this.value) {
- this.valueAsDate = dateFromISO(this.value);
- }
- if (this.start) {
- this.setStartAsDate(dateFromISO(this.start));
- }
- if (this.end) {
- this.setEndAsDate(dateFromISO(this.end));
- }
- if (this.min) {
- this.minAsDate = dateFromISO(this.min);
- }
- if (this.max) {
- this.maxAsDate = dateFromISO(this.max);
- }
- }
- async componentWillLoad() {
- await this.loadLocaleData();
- this.onMinChanged(this.min);
- this.onMaxChanged(this.max);
- }
- render() {
- var _a;
- const date = dateFromRange(this.range ? this.startAsDate : this.valueAsDate, this.minAsDate, this.maxAsDate);
- const activeStartDate = this.range
- ? this.getActiveStartDate(date, this.minAsDate, this.maxAsDate)
- : this.getActiveDate(date, this.minAsDate, this.maxAsDate);
- let activeDate = activeStartDate;
- const endDate = this.range
- ? dateFromRange(this.endAsDate, this.minAsDate, this.maxAsDate)
- : null;
- const activeEndDate = this.getActiveEndDate(endDate, this.minAsDate, this.maxAsDate);
- if ((this.activeRange === "end" ||
- (((_a = this.hoverRange) === null || _a === void 0 ? void 0 : _a.focused) === "end" && (!this.proximitySelectionDisabled || endDate))) &&
- activeEndDate) {
- activeDate = activeEndDate;
- }
- if (this.range && this.mostRecentRangeValue) {
- activeDate = this.mostRecentRangeValue;
- }
- const minDate = this.range && this.activeRange
- ? this.activeRange === "start"
- ? this.minAsDate
- : date || this.minAsDate
- : this.minAsDate;
- const maxDate = this.range && this.activeRange
- ? this.activeRange === "start"
- ? endDate || this.maxAsDate
- : this.maxAsDate
- : this.maxAsDate;
- return (h(Host, { onBlur: this.reset, onKeyUp: this.keyUpHandler, role: "application" }, this.renderCalendar(activeDate, maxDate, minDate, date, endDate)));
- }
- valueHandler(value) {
- if (Array.isArray(value)) {
- this.valueAsDate = value.map((v) => dateFromISO(v));
- this.start = value[0];
- this.end = value[1];
- }
- else if (value) {
- this.valueAsDate = dateFromISO(value);
- this.start = "";
- this.end = "";
- }
- }
- startWatcher(start) {
- this.setStartAsDate(dateFromISO(start));
- }
- endWatcher(end) {
- this.setEndAsDate(dateFromISO(end));
- }
- async loadLocaleData() {
- if (!Build.isBrowser) {
- return;
- }
- const { locale } = this;
- this.localeData = await getLocaleData(locale);
- }
- /**
- * Render calcite-date-picker-month-header and calcite-date-picker-month
- */
- renderCalendar(activeDate, maxDate, minDate, date, endDate) {
- return (this.localeData && [
- h("calcite-date-picker-month-header", { activeDate: activeDate, headingLevel: this.headingLevel || HEADING_LEVEL$6, intlNextMonth: this.intlNextMonth, intlPrevMonth: this.intlPrevMonth, intlYear: this.intlYear, localeData: this.localeData, max: maxDate, min: minDate, onCalciteDatePickerSelect: this.monthHeaderSelectChange, scale: this.scale, selectedDate: this.activeRange === "end" ? endDate : date || new Date() }),
- h("calcite-date-picker-month", { activeDate: activeDate, endDate: this.range ? endDate : undefined, hoverRange: this.hoverRange, localeData: this.localeData, max: maxDate, min: minDate, onCalciteDatePickerActiveDateChange: this.monthActiveDateChange, onCalciteDatePickerHover: this.monthHoverChange, onCalciteDatePickerMouseOut: this.monthMouseOutChange, onCalciteDatePickerSelect: this.monthDateChange, scale: this.scale, selectedDate: this.activeRange === "end" ? endDate : date, startDate: this.range ? date : undefined })
- ]);
- }
- /**
- * Update date instance of start if valid
- */
- setStartAsDate(startDate, emit) {
- this.startAsDate = startDate;
- this.mostRecentRangeValue = this.startAsDate;
- if (emit) {
- this.calciteDatePickerRangeChange.emit({
- startDate,
- endDate: this.endAsDate
- });
- }
- }
- /**
- * Update date instance of end if valid
- */
- setEndAsDate(endDate, emit) {
- this.endAsDate = endDate;
- this.mostRecentRangeValue = this.endAsDate;
- if (emit) {
- this.calciteDatePickerRangeChange.emit({
- startDate: this.startAsDate,
- endDate
- });
- }
- }
- setEndDate(date) {
- this.end = date ? dateToISO(date) : "";
- this.setEndAsDate(date, true);
- this.activeEndDate = date || null;
- }
- setStartDate(date) {
- this.start = date ? dateToISO(date) : "";
- this.setStartAsDate(date, true);
- this.activeStartDate = date || null;
- }
- /**
- * Get an active date using the value, or current date as default
- */
- getActiveDate(value, min, max) {
- return dateFromRange(this.activeDate, min, max) || value || dateFromRange(new Date(), min, max);
- }
- getActiveStartDate(value, min, max) {
- return (dateFromRange(this.activeStartDate, min, max) || value || dateFromRange(new Date(), min, max));
- }
- getActiveEndDate(value, min, max) {
- return (dateFromRange(this.activeEndDate, min, max) || value || dateFromRange(new Date(), min, max));
- }
- static get assetsDirs() { return ["assets"]; }
- get el() { return this; }
- static get watchers() { return {
- "valueAsDate": ["handleValueAsDate"],
- "startAsDate": ["handleRangeChange"],
- "endAsDate": ["handleRangeChange"],
- "min": ["onMinChanged"],
- "max": ["onMaxChanged"],
- "value": ["valueHandler"],
- "start": ["startWatcher"],
- "end": ["endWatcher"],
- "locale": ["loadLocaleData"]
- }; }
- static get style() { return datePickerCss; }
- };
- const datePickerDayCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:-ms-flexbox;display:flex;min-width:0px;cursor:pointer;-ms-flex-pack:center;justify-content:center;color:var(--calcite-ui-text-3);width:14.2857142857%}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.day-v-wrapper{-ms-flex:1 1 auto;flex:1 1 auto}.day-wrapper{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:center;align-items:center}.day{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;border-radius:9999px;font-size:var(--calcite-font-size--2);line-height:1rem;line-height:1;color:var(--calcite-ui-text-3);opacity:var(--calcite-ui-opacity-disabled);-webkit-transition-property:all;transition-property:all;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);-webkit-transition-duration:150ms;transition-duration:150ms;background:none;-webkit-box-shadow:0 0 0 2px transparent, 0 0 0 0px transparent;box-shadow:0 0 0 2px transparent, 0 0 0 0px transparent}.text{margin-top:1px;margin-right:0px;margin-bottom:0px;margin-left:1px}:host([scale=s]) .day-v-wrapper{padding-top:0.125rem;padding-bottom:0.125rem}:host([scale=s]) .day-wrapper{padding:0px}:host([scale=s]) .day{height:27px;width:27px;font-size:var(--calcite-font-size--2)}:host([scale=m]) .day-v-wrapper{padding-top:0.25rem;padding-bottom:0.25rem}:host([scale=m]) .day-wrapper{padding-left:0.25rem;padding-right:0.25rem}:host([scale=m]) .day{height:33px;width:33px;font-size:var(--calcite-font-size--1)}:host([scale=l]) .day-v-wrapper{padding-top:0.25rem;padding-bottom:0.25rem}:host([scale=l]) .day-wrapper{padding-left:0.25rem;padding-right:0.25rem}:host([scale=l]) .day{height:43px;width:43px;font-size:var(--calcite-font-size-0)}:host([current-month]) .day{opacity:1}:host(:hover:not([disabled])) .day,:host([active]:not([range])) .day{background-color:var(--calcite-ui-foreground-2);color:var(--calcite-ui-text-1)}:host(:focus),:host([active]){outline:2px solid transparent;outline-offset:2px;z-index:1}:host(:focus:not([disabled])) .day{-webkit-box-shadow:0 0 0 2px var(--calcite-ui-foreground-1), 0 0 0 4px var(--calcite-ui-brand);box-shadow:0 0 0 2px var(--calcite-ui-foreground-1), 0 0 0 4px var(--calcite-ui-brand)}:host([selected]) .day{font-weight:var(--calcite-font-weight-medium);background-color:var(--calcite-ui-brand) !important;color:var(--calcite-ui-foreground-1) !important;z-index:1}:host([range][selected]) .day-wrapper{background-color:var(--calcite-ui-foreground-current)}:host([start-of-range]) .day-wrapper{border-start-start-radius:40%;border-end-start-radius:40%}:host([end-of-range]) .day-wrapper{border-start-end-radius:40%;border-end-end-radius:40%}:host([start-of-range]) :not(.calcite--rtl) .day-wrapper,:host([end-of-range]) .calcite--rtl .day-wrapper{-webkit-box-shadow:inset 4px 0 var(--calcite-ui-foreground-1);box-shadow:inset 4px 0 var(--calcite-ui-foreground-1)}:host([start-of-range]) :not(.calcite--rtl) .day,:host([end-of-range]) .calcite--rtl .day{opacity:1}:host([start-of-range]:not(:focus)) :not(.calcite--rtl) .day,:host([end-of-range]:not(:focus)) .calcite--rtl .day{-webkit-box-shadow:0 0 0 2px var(--calcite-ui-foreground-1);box-shadow:0 0 0 2px var(--calcite-ui-foreground-1)}:host([end-of-range]) :not(.calcite--rtl) .day-wrapper,:host([start-of-range]) .calcite--rtl .day-wrapper{-webkit-box-shadow:inset -4px 0 var(--calcite-ui-foreground-1);box-shadow:inset -4px 0 var(--calcite-ui-foreground-1)}:host([end-of-range]) :not(.calcite--rtl) .day,:host([start-of-range]) .calcite--rtl .day{opacity:1}:host([end-of-range]:not(:focus)) :not(.calcite--rtl) .day,:host([start-of-range]:not(:focus)) .calcite--rtl .day{-webkit-box-shadow:0 0 0 2px var(--calcite-ui-foreground-1);box-shadow:0 0 0 2px var(--calcite-ui-foreground-1)}:host([end-of-range][scale=l]) :not(.calcite--rtl) .day-wrapper,:host([start-of-range][scale=l]) .calcite--rtl .day-wrapper{-webkit-box-shadow:inset -8px 0 var(--calcite-ui-foreground-1);box-shadow:inset -8px 0 var(--calcite-ui-foreground-1)}:host([start-of-range][scale=l]) :not(.calcite--rtl) .day-wrapper,:host([end-of-range][scale=l]) .calcite--rtl .day-wrapper{-webkit-box-shadow:inset 8px 0 var(--calcite-ui-foreground-1);box-shadow:inset 8px 0 var(--calcite-ui-foreground-1)}:host([highlighted]) .day-wrapper{background-color:var(--calcite-ui-foreground-current)}:host([highlighted]) .day-wrapper .day{color:var(--calcite-ui-text-1)}:host([highlighted]:not([active]:focus)) .day{border-radius:0px;color:var(--calcite-ui-text-1)}:host([range-hover]:not([selected])) .day-wrapper{background-color:var(--calcite-ui-foreground-2)}:host([range-hover]:not([selected])) .day{border-radius:0px}:host([end-of-range][range-hover]) :not(.calcite--rtl) .day-wrapper,:host([start-of-range][range-hover]) .calcite--rtl .day-wrapper{background-image:-webkit-gradient(linear, left top, right top, from(var(--calcite-ui-foreground-current)), color-stop(var(--calcite-ui-foreground-current)), color-stop(var(--calcite-ui-foreground-2)), to(var(--calcite-ui-foreground-2)));background-image:linear-gradient(to right, var(--calcite-ui-foreground-current), var(--calcite-ui-foreground-current), var(--calcite-ui-foreground-2), var(--calcite-ui-foreground-2));border-radius:0px;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}:host([start-of-range][range-hover]) :not(.calcite--rtl) .day-wrapper,:host([end-of-range][range-hover]) .calcite--rtl .day-wrapper{background-image:-webkit-gradient(linear, right top, left top, from(var(--calcite-ui-foreground-current)), color-stop(var(--calcite-ui-foreground-current)), color-stop(var(--calcite-ui-foreground-2)), to(var(--calcite-ui-foreground-2)));background-image:linear-gradient(to left, var(--calcite-ui-foreground-current), var(--calcite-ui-foreground-current), var(--calcite-ui-foreground-2), var(--calcite-ui-foreground-2));border-radius:0px;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}:host(:hover[end-of-range][range-hover]) :not(.calcite--rtl) .day-wrapper,:host(:hover[start-of-range][range-hover]) .calcite--rtl .day-wrapper{background-image:-webkit-gradient(linear, left top, right top, from(var(--calcite-ui-foreground-current)), color-stop(var(--calcite-ui-foreground-current)), color-stop(var(--calcite-ui-foreground-1)), to(var(--calcite-ui-foreground-1)));background-image:linear-gradient(to right, var(--calcite-ui-foreground-current), var(--calcite-ui-foreground-current), var(--calcite-ui-foreground-1), var(--calcite-ui-foreground-1));border-radius:0px;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}:host(:hover[start-of-range][range-hover]) :not(.calcite--rtl) .day-wrapper,:host(:hover[end-of-range][range-hover]) .calcite--rtl .day-wrapper{background-image:-webkit-gradient(linear, right top, left top, from(var(--calcite-ui-foreground-current)), color-stop(var(--calcite-ui-foreground-current)), color-stop(var(--calcite-ui-foreground-1)), to(var(--calcite-ui-foreground-1)));background-image:linear-gradient(to left, var(--calcite-ui-foreground-current), var(--calcite-ui-foreground-current), var(--calcite-ui-foreground-1), var(--calcite-ui-foreground-1));border-radius:0px;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}:host(:hover[range-hover]:not([selected]).focused--end) :not(.calcite--rtl) .day-wrapper,:host(:hover[range-hover]:not([selected]).focused--start) .calcite--rtl .day-wrapper{background-image:-webkit-gradient(linear, left top, right top, from(var(--calcite-ui-foreground-2)), color-stop(var(--calcite-ui-foreground-2)), color-stop(var(--calcite-ui-foreground-current)), to(var(--calcite-ui-foreground-current)));background-image:linear-gradient(to right, var(--calcite-ui-foreground-2), var(--calcite-ui-foreground-2), var(--calcite-ui-foreground-current), var(--calcite-ui-foreground-current))}:host(:hover[range-hover]:not([selected]).focused--end) :not(.calcite--rtl) .day,:host(:hover[range-hover]:not([selected]).focused--start) .calcite--rtl .day{border-radius:9999px;opacity:1;-webkit-box-shadow:0 0 0 2px var(--calcite-ui-foreground-1);box-shadow:0 0 0 2px var(--calcite-ui-foreground-1)}:host(:hover[range-hover]:not([selected]).focused--start) :not(.calcite--rtl) .day-wrapper,:host(:hover[range-hover]:not([selected]).focused--end) .calcite--rtl .day-wrapper{background-image:-webkit-gradient(linear, left top, right top, from(var(--calcite-ui-foreground-current)), color-stop(var(--calcite-ui-foreground-current)), color-stop(var(--calcite-ui-foreground-2)), to(var(--calcite-ui-foreground-2)));background-image:linear-gradient(to right, var(--calcite-ui-foreground-current), var(--calcite-ui-foreground-current), var(--calcite-ui-foreground-2), var(--calcite-ui-foreground-2))}:host(:hover[range-hover]:not([selected]).focused--start) :not(.calcite--rtl) .day,:host(:hover[range-hover]:not([selected]).focused--end) .calcite--rtl .day{border-radius:9999px;opacity:1;-webkit-box-shadow:0 0 0 2px var(--calcite-ui-foreground-1);box-shadow:0 0 0 2px var(--calcite-ui-foreground-1)}:host(:hover[range-hover]:not([selected]).focused--start.hover--outside-range) :not(.calcite--rtl) .day-wrapper,:host(:hover[range-hover]:not([selected]).focused--end.hover--outside-range) .calcite--rtl .day-wrapper{background-image:-webkit-gradient(linear, left top, right top, from(var(--calcite-ui-foreground-1)), color-stop(var(--calcite-ui-foreground-1)), color-stop(var(--calcite-ui-foreground-2)), to(var(--calcite-ui-foreground-2)));background-image:linear-gradient(to right, var(--calcite-ui-foreground-1), var(--calcite-ui-foreground-1), var(--calcite-ui-foreground-2), var(--calcite-ui-foreground-2))}:host(:hover[range-hover]:not([selected]).focused--start.hover--outside-range) :not(.calcite--rtl) .day,:host(:hover[range-hover]:not([selected]).focused--end.hover--outside-range) .calcite--rtl .day{border-radius:9999px;opacity:1;-webkit-box-shadow:0 0 0 2px var(--calcite-ui-foreground-1);box-shadow:0 0 0 2px var(--calcite-ui-foreground-1)}:host(:hover[range-hover]:not([selected]).focused--end.hover--outside-range) :not(.calcite--rtl) .day-wrapper,:host(:hover[range-hover]:not([selected]).focused--start.hover--outside-range) .calcite--rtl .day-wrapper{background-image:-webkit-gradient(linear, left top, right top, from(var(--calcite-ui-foreground-2)), color-stop(var(--calcite-ui-foreground-2)), color-stop(var(--calcite-ui-foreground-1)), to(var(--calcite-ui-foreground-1)));background-image:linear-gradient(to right, var(--calcite-ui-foreground-2), var(--calcite-ui-foreground-2), var(--calcite-ui-foreground-1), var(--calcite-ui-foreground-1))}:host(:hover[range-hover]:not([selected]).focused--end.hover--outside-range) :not(.calcite--rtl) .day,:host(:hover[range-hover]:not([selected]).focused--start.hover--outside-range) .calcite--rtl .day{border-radius:9999px;opacity:1;-webkit-box-shadow:0 0 0 2px var(--calcite-ui-foreground-1);box-shadow:0 0 0 2px var(--calcite-ui-foreground-1)}:host(:hover[start-of-range].hover--inside-range.focused--end) .day-wrapper,:host(:hover[end-of-range].hover--inside-range.focused--start) .day-wrapper{background-image:none}:host([start-of-range].hover--inside-range.focused--end) .day-wrapper,:host([end-of-range].hover--inside-range.focused--start) .day-wrapper{background-color:var(--calcite-ui-foreground-2)}:host([highlighted]:last-child) :not(.calcite--rtl) .day-wrapper,:host([range-hover]:last-child) :not(.calcite--rtl) .day-wrapper,:host([highlighted]:first-child) .calcite--rtl .day-wrapper,:host([range-hover]:first-child) .calcite--rtl .day-wrapper{-webkit-box-shadow:inset -4px 0px 0px 0px var(--calcite-ui-foreground-1);box-shadow:inset -4px 0px 0px 0px var(--calcite-ui-foreground-1)}:host([highlighted]:first-child) :not(.calcite--rtl) .day-wrapper,:host([range-hover]:first-child) :not(.calcite--rtl) .day-wrapper,:host([highlighted]:last-child) .calcite--rtl .day-wrapper,:host([range-hover]:last-child) .calcite--rtl .day-wrapper{-webkit-box-shadow:inset 4px 0px 0px 0px var(--calcite-ui-foreground-1);box-shadow:inset 4px 0px 0px 0px var(--calcite-ui-foreground-1)}:host([scale=s][highlighted]:last-child) :not(.calcite--rtl) .day-wrapper,:host([scale=s][range-hover]:last-child) :not(.calcite--rtl) .day-wrapper,:host([scale=s][highlighted]:first-child) .calcite--rtl .day-wrapper,:host([scale=s][range-hover]:first-child) .calcite--rtl .day-wrapper{-webkit-box-shadow:inset -1px 0px 0px 0px var(--calcite-ui-foreground-1);box-shadow:inset -1px 0px 0px 0px var(--calcite-ui-foreground-1)}:host([scale=s][highlighted]:first-child) :not(.calcite--rtl) .day-wrapper,:host([scale=s][range-hover]:first-child) :not(.calcite--rtl) .day-wrapper,:host([scale=s][highlighted]:last-child) .calcite--rtl .day-wrapper,:host([scale=s][range-hover]:last-child) .calcite--rtl .day-wrapper{-webkit-box-shadow:inset 1px 0px 0px 0px var(--calcite-ui-foreground-1);box-shadow:inset 1px 0px 0px 0px var(--calcite-ui-foreground-1)}:host([scale=l][highlighted]:first-child) :not(.calcite--rtl) .day-wrapper,:host([scale=l][range-hover]:first-child) :not(.calcite--rtl) .day-wrapper,:host([scale=l][highlighted]:last-child) .calcite--rtl .day-wrapper,:host([scale=l][range-hover]:last-child) .calcite--rtl .day-wrapper{-webkit-box-shadow:inset 6px 0px 0px 0px var(--calcite-ui-foreground-1);box-shadow:inset 6px 0px 0px 0px var(--calcite-ui-foreground-1)}:host([highlighted]:first-child) .day-wrapper,:host([range-hover]:first-child) .day-wrapper{border-start-start-radius:45%;border-end-start-radius:45%}:host([highlighted]:last-child) .day-wrapper,:host([range-hover]:last-child) .day-wrapper{border-start-end-radius:45%;border-end-end-radius:45%}:host([scale=l][highlighted]:last-child) :not(.calcite--rtl) .day-wrapper,:host([scale=l][range-hover]:last-child) :not(.calcite--rtl) .day-wrapper,:host([scale=l][highlighted]:first-child) .calcite--rtl .day-wrapper,:host([scale=l][range-hover]:first-child) .calcite--rtl .day-wrapper{-webkit-box-shadow:inset -6px 0px 0px 0px var(--calcite-ui-foreground-1);box-shadow:inset -6px 0px 0px 0px var(--calcite-ui-foreground-1)}@media (forced-colors: active){:host(:hover:not([disabled])) .day,:host([active]:not([range])) .day{border-radius:0px}:host([selected]){outline:2px solid canvasText;z-index:1}:host([selected]) .day{border-radius:0px;background-color:highlight}:host([range][selected]) .day-wrapper,:host([highlighted]) .day-wrapper,:host([range-hover]:not([selected])) .day-wrapper{background-color:highlight}:host([range][selected][start-of-range]) .day-wrapper,:host([range][selected][end-of-range]) .day-wrapper{background-color:canvas}}";
- const DatePickerDay = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteDaySelect = createEvent(this, "calciteDaySelect", 7);
- this.calciteDayHover = createEvent(this, "calciteDayHover", 7);
- /** Date is outside of range and can't be selected */
- this.disabled = false;
- /** Date is in the current month. */
- this.currentMonth = false;
- /** Date is the current selected date of the picker */
- this.selected = false;
- /** Date is currently highlighted as part of the range */
- this.highlighted = false;
- /** Showing date range */
- this.range = false;
- /** Date is the start of date range */
- this.startOfRange = false;
- /** Date is the end of date range */
- this.endOfRange = false;
- /** Date is being hovered and within the set range */
- this.rangeHover = false;
- /** Date is actively in focus for keyboard navigation */
- this.active = false;
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- this.onClick = () => {
- !this.disabled && this.calciteDaySelect.emit();
- };
- this.keyDownHandler = (e) => {
- const key = e.key;
- if (key === " " || key === "Enter") {
- !this.disabled && this.calciteDaySelect.emit();
- }
- };
- }
- mouseoverHandler() {
- this.calciteDayHover.emit({
- disabled: this.disabled
- });
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- render() {
- const formattedDay = String(this.day)
- .split("")
- .map((i) => this.localeData.numerals[i])
- .join("");
- const dir = getElementDir(this.el);
- return (h(Host, { onClick: this.onClick, onKeyDown: this.keyDownHandler, role: "gridcell" }, h("div", { class: { "day-v-wrapper": true, [CSS_UTILITY.rtl]: dir === "rtl" } }, h("div", { class: "day-wrapper" }, h("span", { class: "day" }, h("span", { class: "text" }, formattedDay))))));
- }
- componentDidRender() {
- updateHostInteraction(this, this.isTabbable);
- }
- isTabbable() {
- return this.active;
- }
- get el() { return this; }
- static get style() { return datePickerDayCss; }
- };
- const datePickerMonthCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}.calender{margin-bottom:0.25rem}.week-headers{display:-ms-flexbox;display:flex;border-width:0px;border-top-width:1px;border-style:solid;border-color:var(--calcite-ui-border-3);padding-top:0px;padding-bottom:0px;padding-left:0.25rem;padding-right:0.25rem}.week-header{text-align:center;font-weight:var(--calcite-font-weight-bold);color:var(--calcite-ui-text-3);width:14.2857142857%}:host([scale=s]) .week-header{padding-left:0px;padding-right:0px;padding-top:0.5rem;padding-bottom:0.75rem;font-size:var(--calcite-font-size--2);line-height:1rem}:host([scale=m]) .week-header{padding-left:0px;padding-right:0px;padding-top:0.75rem;padding-bottom:1rem;font-size:var(--calcite-font-size--2);line-height:1rem}:host([scale=l]) .week-header{padding-left:0px;padding-right:0px;padding-top:1rem;padding-bottom:1.25rem;font-size:var(--calcite-font-size--1);line-height:1rem}.week-days{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;padding-top:0px;padding-bottom:0px;padding-left:6px;padding-right:6px}.week-days:focus{outline:2px solid transparent;outline-offset:2px}";
- const DatePickerMonth = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteDatePickerSelect = createEvent(this, "calciteDatePickerSelect", 7);
- this.calciteDatePickerHover = createEvent(this, "calciteDatePickerHover", 7);
- this.calciteDatePickerActiveDateChange = createEvent(this, "calciteDatePickerActiveDateChange", 7);
- this.calciteDatePickerMouseOut = createEvent(this, "calciteDatePickerMouseOut", 7);
- /** Date currently active.*/
- this.activeDate = new Date();
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- this.keyDownHandler = (e) => {
- const isRTL = this.el.dir === "rtl";
- switch (e.key) {
- case "ArrowUp":
- e.preventDefault();
- this.addDays(-7);
- break;
- case "ArrowRight":
- e.preventDefault();
- this.addDays(isRTL ? -1 : 1);
- break;
- case "ArrowDown":
- e.preventDefault();
- this.addDays(7);
- break;
- case "ArrowLeft":
- e.preventDefault();
- this.addDays(isRTL ? 1 : -1);
- break;
- case "PageUp":
- e.preventDefault();
- this.addMonths(-1);
- break;
- case "PageDown":
- e.preventDefault();
- this.addMonths(1);
- break;
- case "Home":
- e.preventDefault();
- this.activeDate.setDate(1);
- this.addDays();
- break;
- case "End":
- e.preventDefault();
- this.activeDate.setDate(new Date(this.activeDate.getFullYear(), this.activeDate.getMonth() + 1, 0).getDate());
- this.addDays();
- break;
- case "Enter":
- case " ":
- e.preventDefault();
- break;
- case "Tab":
- this.activeFocus = false;
- }
- };
- /**
- * Once user is not interacting via keyboard,
- * disable auto focusing of active date
- */
- this.disableActiveFocus = () => {
- this.activeFocus = false;
- };
- this.dayHover = (e) => {
- const target = e.target;
- if (e.detail.disabled) {
- this.calciteDatePickerMouseOut.emit();
- }
- else {
- this.calciteDatePickerHover.emit(target.value);
- }
- };
- this.daySelect = (e) => {
- const target = e.target;
- this.calciteDatePickerSelect.emit(target.value);
- };
- }
- mouseoutHandler() {
- this.calciteDatePickerMouseOut.emit();
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- render() {
- const month = this.activeDate.getMonth();
- const year = this.activeDate.getFullYear();
- const startOfWeek = this.localeData.weekStart % 7;
- const { abbreviated, short, narrow } = this.localeData.days;
- const weekDays = this.scale === "s" ? narrow || short || abbreviated : short || abbreviated || narrow;
- const adjustedWeekDays = [...weekDays.slice(startOfWeek, 7), ...weekDays.slice(0, startOfWeek)];
- const curMonDays = this.getCurrentMonthDays(month, year);
- const prevMonDays = this.getPrevMonthdays(month, year, startOfWeek);
- const nextMonDays = this.getNextMonthDays(month, year, startOfWeek);
- const days = [
- ...prevMonDays.map((day) => {
- const date = new Date(year, month - 1, day);
- return this.renderDateDay(false, day, date);
- }),
- ...curMonDays.map((day) => {
- const date = new Date(year, month, day);
- const active = sameDate(date, this.activeDate);
- return this.renderDateDay(active, day, date, true, true);
- }),
- ...nextMonDays.map((day) => {
- const date = new Date(year, month + 1, day);
- return this.renderDateDay(false, day, date);
- })
- ];
- const weeks = [];
- for (let i = 0; i < days.length; i += 7) {
- weeks.push(days.slice(i, i + 7));
- }
- return (h(Host, { onFocusOut: this.disableActiveFocus, onKeyDown: this.keyDownHandler }, h("div", { class: "calender", role: "grid" }, h("div", { class: "week-headers", role: "row" }, adjustedWeekDays.map((weekday) => (h("span", { class: "week-header", role: "columnheader" }, weekday)))), weeks.map((days) => (h("div", { class: "week-days", role: "row" }, days))))));
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- /**
- * Add n months to the current month
- */
- addMonths(step) {
- const nextDate = new Date(this.activeDate);
- nextDate.setMonth(this.activeDate.getMonth() + step);
- this.calciteDatePickerActiveDateChange.emit(dateFromRange(nextDate, this.min, this.max));
- this.activeFocus = true;
- }
- /**
- * Add n days to the current date
- */
- addDays(step = 0) {
- const nextDate = new Date(this.activeDate);
- nextDate.setDate(this.activeDate.getDate() + step);
- this.calciteDatePickerActiveDateChange.emit(dateFromRange(nextDate, this.min, this.max));
- this.activeFocus = true;
- }
- /**
- * Get dates for last days of the previous month
- */
- getPrevMonthdays(month, year, startOfWeek) {
- const lastDate = new Date(year, month, 0);
- const date = lastDate.getDate();
- const day = lastDate.getDay();
- const days = [];
- if (day - 6 === startOfWeek) {
- return days;
- }
- for (let i = Math.abs(lastDate.getDay() - startOfWeek); i >= 0; i--) {
- days.push(date - i);
- }
- return days;
- }
- /**
- * Get dates for the current month
- */
- getCurrentMonthDays(month, year) {
- const num = new Date(year, month + 1, 0).getDate();
- const days = [];
- for (let i = 0; i < num; i++) {
- days.push(i + 1);
- }
- return days;
- }
- /**
- * Get dates for first days of the next month
- */
- getNextMonthDays(month, year, startOfWeek) {
- const endDay = new Date(year, month + 1, 0).getDay();
- const days = [];
- if (endDay === (startOfWeek + 6) % 7) {
- return days;
- }
- for (let i = 0; i < (6 - (endDay - startOfWeek)) % 7; i++) {
- days.push(i + 1);
- }
- return days;
- }
- /**
- * Determine if the date is in between the start and end dates
- */
- betweenSelectedRange(date) {
- return !!(this.startDate &&
- this.endDate &&
- date > this.startDate &&
- date < this.endDate &&
- !this.isRangeHover(date));
- }
- /**
- * Determine if the date should be in selected state
- */
- isSelected(date) {
- return !!(sameDate(date, this.selectedDate) ||
- (this.startDate && sameDate(date, this.startDate)) ||
- (this.endDate && sameDate(date, this.endDate)));
- }
- /**
- * Determine if the date is the start of the date range
- */
- isStartOfRange(date) {
- return !!(this.startDate &&
- !sameDate(this.startDate, this.endDate) &&
- sameDate(this.startDate, date) &&
- !this.isEndOfRange(date));
- }
- isEndOfRange(date) {
- return !!((this.endDate && !sameDate(this.startDate, this.endDate) && sameDate(this.endDate, date)) ||
- (!this.endDate &&
- this.hoverRange &&
- sameDate(this.startDate, this.hoverRange.end) &&
- sameDate(date, this.hoverRange.end)));
- }
- /**
- * Render calcite-date-picker-day
- */
- renderDateDay(active, day, date, currentMonth, ref) {
- var _a;
- const isFocusedOnStart = this.isFocusedOnStart();
- const isHoverInRange = this.isHoverInRange() ||
- (!this.endDate && this.hoverRange && sameDate((_a = this.hoverRange) === null || _a === void 0 ? void 0 : _a.end, this.startDate));
- return (h("calcite-date-picker-day", { active: active, class: {
- "hover--inside-range": this.startDate && isHoverInRange,
- "hover--outside-range": this.startDate && !isHoverInRange,
- "focused--start": isFocusedOnStart,
- "focused--end": !isFocusedOnStart
- }, currentMonth: currentMonth, day: day, disabled: !inRange(date, this.min, this.max), endOfRange: this.isEndOfRange(date), highlighted: this.betweenSelectedRange(date), key: date.toDateString(), localeData: this.localeData, onCalciteDayHover: this.dayHover, onCalciteDaySelect: this.daySelect, range: !!this.startDate && !!this.endDate && !sameDate(this.startDate, this.endDate), rangeHover: this.isRangeHover(date), ref: (el) => {
- // when moving via keyboard, focus must be updated on active date
- if (ref && active && this.activeFocus) {
- el === null || el === void 0 ? void 0 : el.focus();
- }
- }, scale: this.scale, selected: this.isSelected(date), startOfRange: this.isStartOfRange(date), value: date }));
- }
- isFocusedOnStart() {
- var _a;
- return ((_a = this.hoverRange) === null || _a === void 0 ? void 0 : _a.focused) === "start";
- }
- isHoverInRange() {
- if (!this.hoverRange) {
- return false;
- }
- const { start, end } = this.hoverRange;
- return !!((!this.isFocusedOnStart() && this.startDate && (!this.endDate || end < this.endDate)) ||
- (this.isFocusedOnStart() && this.startDate && start > this.startDate));
- }
- isRangeHover(date) {
- if (!this.hoverRange) {
- return false;
- }
- const { start, end } = this.hoverRange;
- const isStart = this.isFocusedOnStart();
- const insideRange = this.isHoverInRange();
- const cond1 = insideRange &&
- ((!isStart && date > this.startDate && (date < end || sameDate(date, end))) ||
- (isStart && date < this.endDate && (date > start || sameDate(date, start))));
- const cond2 = !insideRange &&
- ((!isStart && date >= this.endDate && (date < end || sameDate(date, end))) ||
- (isStart &&
- (date < this.startDate || (this.endDate && sameDate(date, this.startDate))) &&
- (date > start || sameDate(date, start))));
- return cond1 || cond2;
- }
- get el() { return this; }
- static get style() { return datePickerMonthCss; }
- };
- const datePickerMonthHeaderCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:block}.header{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;padding-top:0px;padding-bottom:0px;padding-left:0.25rem;padding-right:0.25rem}:host([scale=s]) .text{margin-top:0.5rem;margin-bottom:0.5rem;font-size:var(--calcite-font-size--1);line-height:1rem}:host([scale=s]) .chevron{height:2.25rem}:host([scale=m]) .text{margin-top:0.75rem;margin-bottom:0.75rem;font-size:var(--calcite-font-size-0);line-height:1.25rem}:host([scale=m]) .chevron{height:3rem}:host([scale=l]) .text{margin-top:1rem;margin-bottom:1rem;font-size:var(--calcite-font-size-1);line-height:1.5rem}:host([scale=l]) .chevron{height:3.5rem}.chevron{margin-left:-0.25rem;margin-right:-0.25rem;-webkit-box-sizing:content-box;box-sizing:content-box;display:-ms-flexbox;display:flex;-ms-flex-positive:0;flex-grow:0;cursor:pointer;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;border-style:none;background-color:var(--calcite-ui-foreground-1);padding-left:0.25rem;padding-right:0.25rem;color:var(--calcite-ui-text-3);outline:2px solid transparent;outline-offset:2px;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;width:14.2857142857%}.chevron:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.chevron:hover,.chevron:focus{background-color:var(--calcite-ui-foreground-2);fill:var(--calcite-ui-text-1);color:var(--calcite-ui-text-1)}.chevron:active{background-color:var(--calcite-ui-foreground-3)}.chevron[aria-disabled=true]{pointer-events:none;opacity:0}.text{margin-top:auto;margin-bottom:auto;width:100%;-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;text-align:center;line-height:1}.text-nreverse{-ms-flex-direction:row-reverse;flex-direction:row-reverse}.month,.year,.suffix{margin-left:0.25rem;margin-right:0.25rem;margin-top:auto;margin-bottom:auto;display:inline-block;background-color:var(--calcite-ui-foreground-1);font-weight:var(--calcite-font-weight-medium);line-height:1.25;color:var(--calcite-ui-text-1);font-size:inherit}.year{position:relative;width:3rem;border-style:none;background-color:transparent;text-align:center;font-family:inherit;outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;z-index:2}.year:hover{-webkit-transition-duration:100ms;transition-duration:100ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);-webkit-transition-property:outline-color;transition-property:outline-color;outline:2px solid var(--calcite-ui-border-2);outline-offset:2px}.year:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:2px}.year--suffix{width:4rem;text-align:left}.year-wrap{position:relative}.suffix{position:absolute;top:0px;left:0px;width:4rem;white-space:nowrap;text-align:left}.suffix__invisible{visibility:hidden}";
- const DatePickerMonthHeader = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteDatePickerSelect = createEvent(this, "calciteDatePickerSelect", 7);
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- /**
- * Increment year on UP/DOWN keys
- */
- this.onYearKey = (e) => {
- const localizedYear = e.target.value;
- switch (e.key) {
- case "ArrowDown":
- e.preventDefault();
- this.setYear({ localizedYear, offset: -1 });
- break;
- case "ArrowUp":
- e.preventDefault();
- this.setYear({ localizedYear, offset: 1 });
- break;
- }
- };
- this.onYearChange = (event) => {
- this.setYear({ localizedYear: event.target.value });
- };
- this.onYearInput = (event) => {
- this.setYear({ localizedYear: event.target.value, commit: false });
- };
- this.prevMonthClick = (e) => {
- this.handleArrowClick(e, this.prevMonthDate);
- };
- this.prevMonthKeydown = (e) => {
- const key = e.key;
- if (key === " " || key === "Enter") {
- this.prevMonthClick(e);
- }
- };
- this.nextMonthClick = (e) => {
- this.handleArrowClick(e, this.nextMonthDate);
- };
- this.nextMonthKeydown = (e) => {
- const key = e.key;
- if (key === " " || key === "Enter") {
- this.nextMonthClick(e);
- }
- };
- /*
- * Update active month on clicks of left/right arrows
- */
- this.handleArrowClick = (e, date) => {
- e === null || e === void 0 ? void 0 : e.preventDefault();
- e.stopPropagation();
- this.calciteDatePickerSelect.emit(date);
- };
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- this.setNextPrevMonthDates();
- }
- render() {
- return h("div", { class: "header" }, this.renderContent());
- }
- renderContent() {
- var _a;
- if (!this.activeDate || !this.localeData) {
- return null;
- }
- const activeMonth = this.activeDate.getMonth();
- const { months, unitOrder } = this.localeData;
- const localizedMonth = (months.wide || months.narrow || months.abbreviated)[activeMonth];
- const localizedYear = localizeNumber(this.activeDate.getFullYear(), this.localeData);
- const iconScale = this.scale === "l" ? "m" : "s";
- const order = getOrder(unitOrder);
- const reverse = order.indexOf("y") < order.indexOf("m");
- const suffix = (_a = this.localeData.year) === null || _a === void 0 ? void 0 : _a.suffix;
- return (h(Fragment, null, h("a", { "aria-disabled": (this.prevMonthDate.getMonth() === activeMonth).toString(), "aria-label": this.intlPrevMonth, class: "chevron", href: "#", onClick: this.prevMonthClick, onKeyDown: this.prevMonthKeydown, role: "button", tabindex: this.prevMonthDate.getMonth() === activeMonth ? -1 : 0 }, h("calcite-icon", { "flip-rtl": true, icon: "chevron-left", scale: iconScale })), h("div", { class: { text: true, "text--reverse": reverse } }, h(Heading, { class: "month", level: this.headingLevel }, localizedMonth), h("span", { class: "year-wrap" }, h("input", { "aria-label": this.intlYear, class: {
- year: true,
- "year--suffix": !!suffix
- }, inputmode: "numeric", maxlength: "4", minlength: "1", onChange: this.onYearChange, onInput: this.onYearInput, onKeyDown: this.onYearKey, pattern: "\\d*", ref: (el) => (this.yearInput = el), type: "text", value: localizedYear }), suffix && (h("span", { class: "suffix" }, h("span", { "aria-hidden": "true", class: "suffix__invisible" }, localizedYear), " " + suffix)))), h("a", { "aria-disabled": (this.nextMonthDate.getMonth() === activeMonth).toString(), "aria-label": this.intlNextMonth, class: "chevron", href: "#", onClick: this.nextMonthClick, onKeyDown: this.nextMonthKeydown, role: "button", tabindex: this.nextMonthDate.getMonth() === activeMonth ? -1 : 0 }, h("calcite-icon", { "flip-rtl": true, icon: "chevron-right", scale: iconScale }))));
- }
- setNextPrevMonthDates() {
- if (!this.activeDate) {
- return;
- }
- this.nextMonthDate = dateFromRange(nextMonth(this.activeDate), this.min, this.max);
- this.prevMonthDate = dateFromRange(prevMonth(this.activeDate), this.min, this.max);
- }
- getInRangeDate({ localizedYear, offset = 0 }) {
- const { min, max, activeDate, localeData } = this;
- const parsedYear = parseNumber(localizedYear, localeData);
- const length = parsedYear.toString().length;
- const year = isNaN(parsedYear) ? false : parsedYear + offset;
- const inRange = year && (!min || min.getFullYear() <= year) && (!max || max.getFullYear() >= year);
- // if you've supplied a year and it's in range
- if (year && inRange && length === localizedYear.length) {
- const nextDate = new Date(activeDate);
- nextDate.setFullYear(year);
- return dateFromRange(nextDate, min, max);
- }
- }
- /**
- * Parse localized year string from input,
- * set to active if in range
- */
- setYear({ localizedYear, commit = true, offset = 0 }) {
- const { yearInput, activeDate, localeData } = this;
- const inRangeDate = this.getInRangeDate({ localizedYear, offset });
- // if you've supplied a year and it's in range, update active date
- if (inRangeDate) {
- this.calciteDatePickerSelect.emit(inRangeDate);
- }
- if (commit) {
- yearInput.value = localizeNumber((inRangeDate || activeDate).getFullYear(), localeData);
- }
- }
- get el() { return this; }
- static get watchers() { return {
- "min": ["setNextPrevMonthDates"],
- "max": ["setNextPrevMonthDates"],
- "activeDate": ["setNextPrevMonthDates"]
- }; }
- static get style() { return datePickerMonthHeaderCss; }
- };
- const SLOTS$h = {
- dropdownTrigger: "dropdown-trigger"
- };
- const dropdownCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:-ms-inline-flexbox;display:inline-flex;-ms-flex:0 1 auto;flex:0 1 auto}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host .calcite-dropdown-wrapper{display:block;position:absolute;z-index:900;-webkit-transform:scale(0);transform:scale(0);visibility:hidden;pointer-events:none}.calcite-dropdown-wrapper .calcite-popper-anim{position:relative;z-index:1;-webkit-transition:var(--calcite-popper-transition);transition:var(--calcite-popper-transition);visibility:hidden;-webkit-transition-property:visibility, opacity, -webkit-transform;transition-property:visibility, opacity, -webkit-transform;transition-property:transform, visibility, opacity;transition-property:transform, visibility, opacity, -webkit-transform;opacity:0;-webkit-box-shadow:0 0 16px 0 rgba(0, 0, 0, 0.16);box-shadow:0 0 16px 0 rgba(0, 0, 0, 0.16);border-radius:0.25rem}.calcite-dropdown-wrapper[data-popper-placement^=bottom] .calcite-popper-anim{-webkit-transform:translateY(-5px);transform:translateY(-5px)}.calcite-dropdown-wrapper[data-popper-placement^=top] .calcite-popper-anim{-webkit-transform:translateY(5px);transform:translateY(5px)}.calcite-dropdown-wrapper[data-popper-placement^=left] .calcite-popper-anim{-webkit-transform:translateX(5px);transform:translateX(5px)}.calcite-dropdown-wrapper[data-popper-placement^=right] .calcite-popper-anim{-webkit-transform:translateX(-5px);transform:translateX(-5px)}.calcite-dropdown-wrapper[data-popper-placement] .calcite-popper-anim--active{opacity:1;visibility:visible;-webkit-transform:translate(0);transform:translate(0)}:host([active]) .calcite-dropdown-wrapper{pointer-events:initial;visibility:visible}:host .calcite-dropdown-content{width:auto;overflow-y:auto;overflow-x:hidden;background-color:var(--calcite-ui-foreground-1);max-height:90vh;width:var(--calcite-dropdown-width)}.calcite-dropdown-trigger-container{position:relative;display:-ms-flexbox;display:flex;-ms-flex:1 1 auto;flex:1 1 auto}:host([width=s]){--calcite-dropdown-width:12rem}:host([width=m]){--calcite-dropdown-width:14rem}:host([width=l]){--calcite-dropdown-width:16rem}";
- const Dropdown = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteDropdownSelect = createEvent(this, "calciteDropdownSelect", 7);
- this.calciteDropdownOpen = createEvent(this, "calciteDropdownOpen", 7);
- this.calciteDropdownClose = createEvent(this, "calciteDropdownClose", 7);
- //--------------------------------------------------------------------------
- //
- // Public Properties
- //
- //--------------------------------------------------------------------------
- /** Opens or closes the dropdown */
- this.active = false;
- /**
- allow the dropdown to remain open after a selection is made
- if the selection-mode of the selected item's containing group is "none", the dropdown will always close
- */
- this.disableCloseOnSelect = false;
- /** is the dropdown disabled */
- this.disabled = false;
- /**
- specify the maximum number of calcite-dropdown-items to display before showing the scroller, must be greater than 0 -
- this value does not include groupTitles passed to calcite-dropdown-group
- */
- this.maxItems = 0;
- /** Describes the type of positioning to use for the overlaid content. If your element is in a fixed container, use the 'fixed' value. */
- this.overlayPositioning = "absolute";
- /**
- * Determines where the dropdown will be positioned relative to the button.
- * @default "bottom-leading"
- */
- this.placement = defaultMenuPlacement;
- /** specify the scale of dropdown, defaults to m */
- this.scale = "m";
- /**
- * **read-only** The currently selected items
- *
- * @readonly
- */
- this.selectedItems = [];
- /** specify whether the dropdown is opened by hover or click of a trigger element */
- this.type = "click";
- /** specify the width of dropdown, defaults to m */
- this.width = "m";
- this.items = [];
- this.groups = [];
- this.activeTransitionProp = "visibility";
- this.mutationObserver = createObserver("mutation", () => this.updateItems());
- this.resizeObserver = createObserver("resize", () => this.setMaxScrollerHeight());
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- this.setFilteredPlacements = () => {
- const { el, flipPlacements } = this;
- this.filteredFlipPlacements = flipPlacements
- ? filterComputedPlacements(flipPlacements, el)
- : null;
- };
- this.updateTriggers = (event) => {
- this.triggers = event.target.assignedElements({
- flatten: true
- });
- this.reposition();
- };
- this.updateItems = () => {
- this.items = this.groups
- .map((group) => Array.from(group === null || group === void 0 ? void 0 : group.querySelectorAll("calcite-dropdown-item")))
- .reduce((previousValue, currentValue) => [...previousValue, ...currentValue], []);
- this.updateSelectedItems();
- this.reposition();
- };
- this.updateGroups = (event) => {
- const groups = event.target
- .assignedElements({ flatten: true })
- .filter((el) => el === null || el === void 0 ? void 0 : el.matches("calcite-dropdown-group"));
- this.groups = groups;
- this.updateItems();
- };
- this.setMaxScrollerHeight = () => {
- const { active, scrollerEl } = this;
- if (!scrollerEl || !active) {
- return;
- }
- this.reposition();
- const maxScrollerHeight = this.getMaxScrollerHeight();
- scrollerEl.style.maxHeight = maxScrollerHeight > 0 ? `${maxScrollerHeight}px` : "";
- this.reposition();
- };
- this.setScrollerEl = (scrollerEl) => {
- this.resizeObserver.observe(scrollerEl);
- this.scrollerEl = scrollerEl;
- };
- this.transitionEnd = (event) => {
- if (event.propertyName === this.activeTransitionProp) {
- this.active ? this.calciteDropdownOpen.emit() : this.calciteDropdownClose.emit();
- }
- };
- this.setReferenceEl = (el) => {
- this.referenceEl = el;
- };
- this.setMenuEl = (el) => {
- this.menuEl = el;
- };
- this.keyDownHandler = (e) => {
- const target = e.target;
- if (target !== this.referenceEl) {
- return;
- }
- const key = e.key;
- if (this.active && (key === "Escape" || (e.shiftKey && key === "Tab"))) {
- this.closeCalciteDropdown();
- return;
- }
- switch (key) {
- case " ":
- case "Enter":
- this.openCalciteDropdown();
- break;
- case "Escape":
- this.closeCalciteDropdown();
- break;
- }
- };
- this.focusOnFirstActiveOrFirstItem = () => {
- this.getFocusableElement(this.items.find((item) => item.active) || this.items[0]);
- };
- this.toggleOpenEnd = () => {
- this.focusOnFirstActiveOrFirstItem();
- this.el.removeEventListener("calciteDropdownOpen", this.toggleOpenEnd);
- };
- this.openCalciteDropdown = () => {
- this.active = !this.active;
- if (this.active) {
- this.el.addEventListener("calciteDropdownOpen", this.toggleOpenEnd);
- }
- };
- }
- activeHandler() {
- if (!this.disabled) {
- this.reposition();
- return;
- }
- this.active = false;
- }
- handleDisabledChange(value) {
- if (!value) {
- this.active = false;
- }
- }
- flipPlacementsHandler() {
- this.setFilteredPlacements();
- }
- maxItemsHandler() {
- this.setMaxScrollerHeight();
- }
- placementHandler() {
- this.reposition();
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- var _a;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
- this.createPopper();
- this.setFilteredPlacements();
- }
- componentDidLoad() {
- this.reposition();
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- disconnectedCallback() {
- var _a, _b;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- (_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
- this.destroyPopper();
- }
- render() {
- const { active } = this;
- return (h(Host, null, h("div", { class: "calcite-dropdown-trigger-container", onClick: this.openCalciteDropdown, onKeyDown: this.keyDownHandler, ref: this.setReferenceEl }, h("slot", { "aria-expanded": toAriaBoolean(active), "aria-haspopup": "true", name: SLOTS$h.dropdownTrigger, onSlotchange: this.updateTriggers })), h("div", { "aria-hidden": toAriaBoolean(!active), class: "calcite-dropdown-wrapper", ref: this.setMenuEl }, h("div", { class: {
- ["calcite-dropdown-content"]: true,
- [CSS$D.animation]: true,
- [CSS$D.animationActive]: active
- }, onTransitionEnd: this.transitionEnd, ref: this.setScrollerEl }, h("div", { hidden: !this.active }, h("slot", { onSlotchange: this.updateGroups }))))));
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /** Updates the position of the component. */
- async reposition() {
- const { popper, menuEl, placement } = this;
- const modifiers = this.getModifiers();
- popper
- ? await updatePopper({
- el: menuEl,
- modifiers,
- placement,
- popper
- })
- : this.createPopper();
- }
- closeCalciteDropdownOnClick(e) {
- if (!this.active || e.composedPath().includes(this.el)) {
- return;
- }
- this.closeCalciteDropdown(false);
- }
- closeCalciteDropdownOnEvent() {
- this.closeCalciteDropdown();
- }
- closeCalciteDropdownOnOpenEvent(e) {
- if (e.composedPath().includes(this.el)) {
- return;
- }
- this.active = false;
- }
- mouseEnterHandler() {
- if (this.type === "hover") {
- this.openCalciteDropdown();
- }
- }
- mouseLeaveHandler() {
- if (this.type === "hover") {
- this.closeCalciteDropdown();
- }
- }
- calciteDropdownItemKeyEvent(e) {
- const { keyboardEvent } = e.detail;
- // handle edge
- const target = keyboardEvent.target;
- const itemToFocus = target.nodeName !== "A" ? target : target.parentNode;
- const isFirstItem = this.itemIndex(itemToFocus) === 0;
- const isLastItem = this.itemIndex(itemToFocus) === this.items.length - 1;
- switch (keyboardEvent.key) {
- case "Tab":
- if (isLastItem && !keyboardEvent.shiftKey) {
- this.closeCalciteDropdown();
- }
- else if (isFirstItem && keyboardEvent.shiftKey) {
- this.closeCalciteDropdown();
- }
- else if (keyboardEvent.shiftKey) {
- this.focusPrevItem(itemToFocus);
- }
- else {
- this.focusNextItem(itemToFocus);
- }
- break;
- case "ArrowDown":
- this.focusNextItem(itemToFocus);
- break;
- case "ArrowUp":
- this.focusPrevItem(itemToFocus);
- break;
- case "Home":
- this.focusFirstItem();
- break;
- case "End":
- this.focusLastItem();
- break;
- }
- e.stopPropagation();
- }
- handleItemSelect(event) {
- this.updateSelectedItems();
- event.stopPropagation();
- this.calciteDropdownSelect.emit();
- if (!this.disableCloseOnSelect ||
- event.detail.requestedDropdownGroup.selectionMode === "none") {
- this.closeCalciteDropdown();
- }
- }
- getModifiers() {
- const flipModifier = {
- name: "flip",
- enabled: true
- };
- flipModifier.options = {
- fallbackPlacements: this.filteredFlipPlacements || popperMenuComputedPlacements
- };
- const eventListenerModifier = {
- name: "eventListeners",
- enabled: this.active
- };
- return [flipModifier, eventListenerModifier];
- }
- createPopper() {
- this.destroyPopper();
- const { menuEl, referenceEl, placement, overlayPositioning } = this;
- const modifiers = this.getModifiers();
- this.popper = createPopper({
- el: menuEl,
- modifiers,
- overlayPositioning,
- placement,
- referenceEl
- });
- }
- destroyPopper() {
- const { popper } = this;
- if (popper) {
- popper.destroy();
- }
- this.popper = null;
- }
- updateSelectedItems() {
- this.selectedItems = this.items.filter((item) => item.active);
- }
- getMaxScrollerHeight() {
- const { maxItems } = this;
- let itemsToProcess = 0;
- let maxScrollerHeight = 0;
- let groupHeaderHeight;
- this.groups.forEach((group) => {
- if (maxItems > 0 && itemsToProcess < maxItems) {
- Array.from(group.children).forEach((item, index) => {
- if (index === 0) {
- if (isNaN(groupHeaderHeight)) {
- groupHeaderHeight = item.offsetTop;
- }
- maxScrollerHeight += groupHeaderHeight;
- }
- if (itemsToProcess < maxItems) {
- maxScrollerHeight += item.offsetHeight;
- itemsToProcess += 1;
- }
- });
- }
- });
- return maxScrollerHeight;
- }
- closeCalciteDropdown(focusTrigger = true) {
- this.active = false;
- if (focusTrigger) {
- focusElement(this.triggers[0]);
- }
- }
- focusFirstItem() {
- const firstItem = this.items[0];
- this.getFocusableElement(firstItem);
- }
- focusLastItem() {
- const lastItem = this.items[this.items.length - 1];
- this.getFocusableElement(lastItem);
- }
- focusNextItem(e) {
- const index = this.itemIndex(e);
- const nextItem = this.items[index + 1] || this.items[0];
- this.getFocusableElement(nextItem);
- }
- focusPrevItem(e) {
- const index = this.itemIndex(e);
- const prevItem = this.items[index - 1] || this.items[this.items.length - 1];
- this.getFocusableElement(prevItem);
- }
- itemIndex(e) {
- return this.items.indexOf(e);
- }
- getFocusableElement(item) {
- if (!item) {
- return;
- }
- const target = item.attributes.isLink
- ? item.shadowRoot.querySelector("a")
- : item;
- focusElement(target);
- }
- get el() { return this; }
- static get watchers() { return {
- "active": ["activeHandler"],
- "disabled": ["handleDisabledChange"],
- "flipPlacements": ["flipPlacementsHandler"],
- "maxItems": ["maxItemsHandler"],
- "placement": ["placementHandler"]
- }; }
- static get style() { return dropdownCss; }
- };
- const CSS$A = {
- containerSmall: "container--s",
- containerMedium: "container--m",
- containerLarge: "container--l"
- };
- const dropdownGroupCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:block}.container--s{font-size:var(--calcite-font-size--2);line-height:1rem}.container--s .dropdown-title{padding:0.5rem}.container--m{font-size:var(--calcite-font-size--1);line-height:1rem}.container--m .dropdown-title{padding:0.75rem}.container--l{font-size:var(--calcite-font-size-0);line-height:1.25rem}.container--l .dropdown-title{padding:1rem}.dropdown-title{margin-bottom:-1px;display:block;cursor:default;overflow-wrap:break-word;border-width:0px;border-bottom-width:1px;border-style:solid;border-color:var(--calcite-ui-border-3);font-weight:var(--calcite-font-weight-bold);color:var(--calcite-ui-text-2)}.dropdown-separator{display:block;height:1px;background-color:var(--calcite-ui-border-3)}";
- const DropdownGroup = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteDropdownItemChange = createEvent(this, "calciteDropdownItemChange", 7);
- /** specify the selection mode - multi (allow any number of (or no) active items), single (allow and require one active item),
- none (no active items), defaults to single */
- this.selectionMode = "single";
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentWillLoad() {
- this.groupPosition = this.getGroupPosition();
- }
- render() {
- const scale = this.scale || getElementProp(this.el, "scale", "m");
- const groupTitle = this.groupTitle ? (h("span", { "aria-hidden": "true", class: "dropdown-title" }, this.groupTitle)) : null;
- const dropdownSeparator = this.groupPosition > 0 ? h("div", { class: "dropdown-separator", role: "separator" }) : null;
- return (h(Host, { role: "menu" }, h("div", { class: {
- container: true,
- [CSS$A.containerSmall]: scale === "s",
- [CSS$A.containerMedium]: scale === "m",
- [CSS$A.containerLarge]: scale === "l"
- }, title: this.groupTitle }, dropdownSeparator, groupTitle, h("slot", null))));
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- updateActiveItemOnChange(event) {
- this.requestedDropdownGroup = event.detail.requestedDropdownGroup;
- this.requestedDropdownItem = event.detail.requestedDropdownItem;
- this.calciteDropdownItemChange.emit({
- requestedDropdownGroup: this.requestedDropdownGroup,
- requestedDropdownItem: this.requestedDropdownItem
- });
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- getGroupPosition() {
- return Array.prototype.indexOf.call(this.el.parentElement.querySelectorAll("calcite-dropdown-group"), this.el);
- }
- get el() { return this; }
- static get style() { return dropdownGroupCss; }
- };
- const CSS$z = {
- containerLink: "container--link",
- containerSmall: "container--s",
- containerMedium: "container--m",
- containerLarge: "container--l",
- containerMulti: "container--multi-selection",
- containerSingle: "container--single-selection",
- containerNone: "container--none-selection"
- };
- const dropdownItemCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}.container--s{padding-top:0.25rem;padding-bottom:0.25rem;font-size:var(--calcite-font-size--2);line-height:1rem;-webkit-padding-end:0.5rem;padding-inline-end:0.5rem;-webkit-padding-start:1.5rem;padding-inline-start:1.5rem}.container--m{padding-top:0.5rem;padding-bottom:0.5rem;font-size:var(--calcite-font-size--1);line-height:1rem;-webkit-padding-end:0.75rem;padding-inline-end:0.75rem;-webkit-padding-start:2rem;padding-inline-start:2rem}.container--l{padding-top:0.75rem;padding-bottom:0.75rem;font-size:var(--calcite-font-size-0);line-height:1.25rem;-webkit-padding-end:1rem;padding-inline-end:1rem;-webkit-padding-start:2.5rem;padding-inline-start:2.5rem}.container--s.container--none-selection{-webkit-padding-start:0.25rem;padding-inline-start:0.25rem}.container--s.container--none-selection .dropdown-link{-webkit-padding-start:0px;padding-inline-start:0px}.container--m.container--none-selection{-webkit-padding-start:0.5rem;padding-inline-start:0.5rem}.container--m.container--none-selection .dropdown-link{-webkit-padding-start:0px;padding-inline-start:0px}.container--l.container--none-selection{-webkit-padding-start:0.75rem;padding-inline-start:0.75rem}.container--l.container--none-selection .dropdown-link{-webkit-padding-start:0px;padding-inline-start:0px}:host{position:relative;display:-ms-flexbox;display:flex;-ms-flex-positive:1;flex-grow:1;-ms-flex-align:center;align-items:center}.container{position:relative;display:-ms-flexbox;display:flex;-ms-flex-positive:1;flex-grow:1;cursor:pointer;-ms-flex-align:center;align-items:center;color:var(--calcite-ui-text-3);-webkit-text-decoration-line:none;text-decoration-line:none;outline:2px solid transparent;outline-offset:2px;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}.dropdown-item-content{-ms-flex:1 1 auto;flex:1 1 auto;-webkit-padding-end:auto;padding-inline-end:auto;-webkit-padding-start:0.25rem;padding-inline-start:0.25rem}:host,.container--link a{outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out}:host(:focus){outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.container--link{padding:0px}.container--link a{position:relative;display:-ms-flexbox;display:flex;-ms-flex-positive:1;flex-grow:1;cursor:pointer;-ms-flex-align:center;align-items:center;color:var(--calcite-ui-text-3);-webkit-text-decoration-line:none;text-decoration-line:none;outline:2px solid transparent;outline-offset:2px;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}.container--s .dropdown-link{padding-top:0.25rem;padding-bottom:0.25rem;font-size:var(--calcite-font-size--2);line-height:1rem;-webkit-padding-end:0.5rem;padding-inline-end:0.5rem;-webkit-padding-start:1.5rem;padding-inline-start:1.5rem}.container--m .dropdown-link{padding-top:0.5rem;padding-bottom:0.5rem;font-size:var(--calcite-font-size--1);line-height:1rem;-webkit-padding-end:0.75rem;padding-inline-end:0.75rem;-webkit-padding-start:2rem;padding-inline-start:2rem}.container--l .dropdown-link{padding-top:0.75rem;padding-bottom:0.75rem;font-size:var(--calcite-font-size-0);line-height:1.25rem;-webkit-padding-end:1rem;padding-inline-end:1rem;-webkit-padding-start:2.5rem;padding-inline-start:2.5rem}:host(:hover) .container,:host(:active) .container{background-color:var(--calcite-ui-foreground-2);color:var(--calcite-ui-text-1);-webkit-text-decoration-line:none;text-decoration-line:none}:host(:hover) .container--link .dropdown-link,:host(:active) .container--link .dropdown-link{color:var(--calcite-ui-text-1)}:host(:focus) .container{color:var(--calcite-ui-text-1);-webkit-text-decoration-line:none;text-decoration-line:none}:host(:active) .container{background-color:var(--calcite-ui-foreground-3)}:host(:hover) .container:before,:host(:active) .container:before,:host(:focus) .container:before{opacity:1}:host([active]) .container:not(.container--none-selection),:host([active]) .container--link .dropdown-link{font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1)}:host([active]) .container:not(.container--none-selection):before,:host([active]) .container--link .dropdown-link:before{opacity:1;color:var(--calcite-ui-brand)}:host([active]) .container:not(.container--none-selection) calcite-icon,:host([active]) .container--link .dropdown-link calcite-icon{color:var(--calcite-ui-brand)}.container--multi-selection:before,.container--none-selection:before{display:none}.container--s:before{inset-inline-start:0.5rem}.container--m:before{inset-inline-start:0.75rem}.container--l:before{inset-inline-start:1rem}.dropdown-item-icon{position:absolute;opacity:0;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);-webkit-transform:scale(0.9);transform:scale(0.9)}.container--s .dropdown-item-icon{inset-inline-start:0.25rem}.container--m .dropdown-item-icon{inset-inline-start:0.5rem}.container--l .dropdown-item-icon{inset-inline-start:0.75rem}:host(:hover) .dropdown-item-icon{color:var(--calcite-ui-border-1);opacity:1}:host([active]) .dropdown-item-icon{color:var(--calcite-ui-brand);opacity:1}.container--s .dropdown-item-icon-start{-webkit-margin-end:0.5rem;margin-inline-end:0.5rem;-webkit-margin-start:0.25rem;margin-inline-start:0.25rem}.container--s .dropdown-item-icon-end{-webkit-margin-start:0.5rem;margin-inline-start:0.5rem}.container--m .dropdown-item-icon-start{-webkit-margin-end:0.75rem;margin-inline-end:0.75rem;-webkit-margin-start:0.25rem;margin-inline-start:0.25rem}.container--m .dropdown-item-icon-end{-webkit-margin-start:0.75rem;margin-inline-start:0.75rem}.container--l .dropdown-item-icon-start{-webkit-margin-end:1rem;margin-inline-end:1rem;-webkit-margin-start:0.25rem;margin-inline-start:0.25rem}.container--l .dropdown-item-icon-end{-webkit-margin-start:1rem;margin-inline-start:1rem}";
- const DropdownItem = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteDropdownItemSelect = createEvent(this, "calciteDropdownItemSelect", 7);
- this.calciteDropdownItemKeyEvent = createEvent(this, "calciteDropdownItemKeyEvent", 7);
- this.calciteDropdownCloseRequest = createEvent(this, "calciteDropdownCloseRequest", 7);
- //--------------------------------------------------------------------------
- //
- // Public Properties
- //
- //--------------------------------------------------------------------------
- /** Indicates whether the item is active. */
- this.active = false;
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- this.el.focus();
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentWillLoad() {
- this.initialize();
- }
- connectedCallback() {
- this.initialize();
- }
- render() {
- const scale = getElementProp(this.el, "scale", "m");
- const iconStartEl = (h("calcite-icon", { class: "dropdown-item-icon-start", flipRtl: this.iconFlipRtl === "start" || this.iconFlipRtl === "both", icon: this.iconStart, scale: "s" }));
- const contentNode = (h("span", { class: "dropdown-item-content" }, h("slot", null)));
- const iconEndEl = (h("calcite-icon", { class: "dropdown-item-icon-end", flipRtl: this.iconFlipRtl === "end" || this.iconFlipRtl === "both", icon: this.iconEnd, scale: "s" }));
- const slottedContent = this.iconStart && this.iconEnd
- ? [iconStartEl, contentNode, iconEndEl]
- : this.iconStart
- ? [iconStartEl, h("slot", null)]
- : this.iconEnd
- ? [contentNode, iconEndEl]
- : contentNode;
- const contentEl = !this.href ? (slottedContent) : (h("a", { "aria-label": this.label, class: "dropdown-link", href: this.href, ref: (el) => (this.childLink = el), rel: this.rel, target: this.target }, slottedContent));
- const itemRole = this.href
- ? null
- : this.selectionMode === "single"
- ? "menuitemradio"
- : this.selectionMode === "multi"
- ? "menuitemcheckbox"
- : "menuitem";
- const itemAria = this.selectionMode !== "none" ? toAriaBoolean(this.active) : null;
- return (h(Host, { "aria-checked": itemAria, role: itemRole, tabindex: "0" }, h("div", { class: {
- container: true,
- [CSS$z.containerLink]: !!this.href,
- [CSS$z.containerSmall]: scale === "s",
- [CSS$z.containerMedium]: scale === "m",
- [CSS$z.containerLarge]: scale === "l",
- [CSS$z.containerMulti]: this.selectionMode === "multi",
- [CSS$z.containerSingle]: this.selectionMode === "single",
- [CSS$z.containerNone]: this.selectionMode === "none"
- } }, this.selectionMode !== "none" ? (h("calcite-icon", { class: "dropdown-item-icon", icon: this.selectionMode === "multi" ? "check" : "bullet-point", scale: "s" })) : null, contentEl)));
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- onClick() {
- this.emitRequestedItem();
- }
- keyDownHandler(e) {
- switch (e.key) {
- case " ":
- this.emitRequestedItem();
- if (this.href) {
- e.preventDefault();
- this.childLink.click();
- }
- break;
- case "Enter":
- this.emitRequestedItem();
- if (this.href) {
- this.childLink.click();
- }
- break;
- case "Escape":
- this.calciteDropdownCloseRequest.emit();
- break;
- case "Tab":
- case "ArrowUp":
- case "ArrowDown":
- case "Home":
- case "End":
- this.calciteDropdownItemKeyEvent.emit({ keyboardEvent: e });
- break;
- }
- e.preventDefault();
- }
- updateActiveItemOnChange(event) {
- const parentEmittedChange = event.composedPath().includes(this.parentDropdownGroupEl);
- if (parentEmittedChange) {
- this.requestedDropdownGroup = event.detail.requestedDropdownGroup;
- this.requestedDropdownItem = event.detail.requestedDropdownItem;
- this.determineActiveItem();
- }
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- initialize() {
- this.selectionMode = getElementProp(this.el, "selection-mode", "single");
- this.parentDropdownGroupEl = this.el.closest("calcite-dropdown-group");
- if (this.selectionMode === "none") {
- this.active = false;
- }
- }
- determineActiveItem() {
- switch (this.selectionMode) {
- case "multi":
- if (this.el === this.requestedDropdownItem) {
- this.active = !this.active;
- }
- break;
- case "single":
- if (this.el === this.requestedDropdownItem) {
- this.active = true;
- }
- else if (this.requestedDropdownGroup === this.parentDropdownGroupEl) {
- this.active = false;
- }
- break;
- case "none":
- this.active = false;
- break;
- }
- }
- emitRequestedItem() {
- this.calciteDropdownItemSelect.emit({
- requestedDropdownItem: this.el,
- requestedDropdownGroup: this.parentDropdownGroupEl
- });
- }
- get el() { return this; }
- static get style() { return dropdownItemCss; }
- };
- const CSS$y = {
- button: "button"
- };
- const ICONS$9 = {
- plus: "plus"
- };
- const fabCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:-ms-flexbox;display:flex;background-color:transparent}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}calcite-button{--tw-shadow:0 6px 20px -4px rgba(0, 0, 0, 0.1), 0 4px 12px -2px rgba(0, 0, 0, 0.08);--tw-shadow-colored:0 6px 20px -4px var(--tw-shadow-color), 0 4px 12px -2px var(--tw-shadow-color);-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}calcite-button:hover{--tw-shadow:0 12px 32px -2px rgba(0, 0, 0, 0.1), 0 4px 20px 0 rgba(0, 0, 0, 0.08);--tw-shadow-colored:0 12px 32px -2px var(--tw-shadow-color), 0 4px 20px 0 var(--tw-shadow-color);-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}calcite-button:active{--tw-shadow:0 2px 12px -4px rgba(0, 0, 0, 0.2), 0 2px 4px -2px rgba(0, 0, 0, 0.16);--tw-shadow-colored:0 2px 12px -4px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}";
- const Fab = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * Used to set the button's appearance. Default is outline.
- */
- this.appearance = "outline";
- /**
- * Used to set the button's color. Default is light.
- */
- this.color = "neutral";
- /**
- * When true, disabled prevents interaction. This state shows items with lower opacity/grayed.
- */
- this.disabled = false;
- /**
- * The name of the icon to display. The value of this property must match the icon name from https://esri.github.io/calcite-ui-icons/.
- * @default "plus"
- */
- this.icon = ICONS$9.plus;
- /**
- * When true, content is waiting to be loaded. This state shows a busy indicator.
- */
- this.loading = false;
- /**
- * Specifies the size of the fab.
- */
- this.scale = "m";
- /**
- * Indicates whether the text is displayed.
- */
- this.textEnabled = false;
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentDidRender() {
- updateHostInteraction(this);
- }
- // --------------------------------------------------------------------------
- //
- // Methods
- //
- // --------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- focusElement(this.buttonEl);
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- render() {
- const { appearance, color, disabled, loading, scale, textEnabled, icon, label, text } = this;
- const title = !textEnabled ? label || text || null : null;
- return (h("calcite-button", { appearance: appearance === "solid" ? "solid" : "outline", class: CSS$y.button, color: color, disabled: disabled, iconStart: icon, label: label, loading: loading, ref: (buttonEl) => {
- this.buttonEl = buttonEl;
- }, round: true, scale: scale, title: title, type: "button", width: "auto" }, this.textEnabled ? this.text : null));
- }
- get el() { return this; }
- static get style() { return fabCss; }
- };
- const CSS$x = {
- container: "container",
- searchIcon: "search-icon"
- };
- const TEXT$e = {
- filterLabel: "Filter",
- clear: "Clear filter"
- };
- const ICONS$8 = {
- search: "search",
- close: "x"
- };
- const DEBOUNCE_TIMEOUT = 250;
- const filterCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:host{-webkit-box-sizing:border-box;box-sizing:border-box;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-2);font-size:var(--calcite-font-size--1)}:host *{-webkit-box-sizing:border-box;box-sizing:border-box}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:-ms-flexbox;display:flex;width:100%}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.container{display:-ms-flexbox;display:flex;width:100%;padding:0.5rem}label{position:relative;margin-left:0.25rem;margin-right:0.25rem;margin-top:0px;margin-bottom:0px;display:-ms-flexbox;display:flex;width:100%;-ms-flex-align:center;align-items:center;overflow:hidden}input[type=text]{margin-bottom:0.25rem;width:100%;border-style:none;background-color:transparent;padding-top:0.25rem;padding-bottom:0.25rem;padding-right:0.25rem;padding-left:1.5rem;font-family:inherit;font-size:var(--calcite-font-size--2);line-height:1rem;color:var(--calcite-ui-text-1);-webkit-transition:padding var(--calcite-animation-timing), -webkit-box-shadow var(--calcite-animation-timing);transition:padding var(--calcite-animation-timing), -webkit-box-shadow var(--calcite-animation-timing);transition:padding var(--calcite-animation-timing), box-shadow var(--calcite-animation-timing);transition:padding var(--calcite-animation-timing), box-shadow var(--calcite-animation-timing), -webkit-box-shadow var(--calcite-animation-timing)}input[type=text]::-ms-clear{display:none}calcite-input{width:100%}.search-icon{position:absolute;display:-ms-flexbox;display:flex;color:var(--calcite-ui-text-2);inset-inline-start:0;-webkit-transition:left var(--calcite-animation-timing), right var(--calcite-animation-timing), opacity var(--calcite-animation-timing);transition:left var(--calcite-animation-timing), right var(--calcite-animation-timing), opacity var(--calcite-animation-timing)}input[type=text]:focus{border-color:var(--calcite-ui-brand);outline:2px solid transparent;outline-offset:2px;padding-inline:0.25rem}input[type=text]:focus~.search-icon{inset-inline-start:calc(1rem * -1);opacity:0}.clear-button{display:-ms-flexbox;display:flex;cursor:pointer;-ms-flex-align:center;align-items:center;border-width:0px;background-color:transparent;color:var(--calcite-ui-text-2)}.clear-button:hover,.clear-button:focus{color:var(--calcite-ui-text-1)}";
- const Filter = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteFilterChange = createEvent(this, "calciteFilterChange", 7);
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * The items to filter through. The filter uses this as the starting point, and returns items
- * that contain the string entered in the input, using a partial match and recursive search.
- *
- * This property is required.
- */
- this.items = [];
- /**
- * When true, disabled prevents interaction. This state shows items with lower opacity/grayed.
- */
- this.disabled = false;
- /**
- * The resulting items after filtering.
- *
- * @readonly
- */
- this.filteredItems = [];
- /** specify the scale of filter, defaults to m */
- this.scale = "m";
- /**
- * Filter value.
- */
- this.value = "";
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- this.filter = debounce$1((value, emit = false) => {
- const regex = new RegExp(value, "i");
- if (this.items.length === 0) {
- this.updateFiltered([], emit);
- return;
- }
- const find = (input, RE) => {
- let found = false;
- forIn(input, (val) => {
- if (typeof val === "function" || val == null /* intentional == to catch undefined */) {
- return;
- }
- if (Array.isArray(val) || (typeof val === "object" && val !== null)) {
- if (find(val, RE)) {
- found = true;
- }
- }
- else if (RE.test(val)) {
- found = true;
- }
- });
- return found;
- };
- const result = this.items.filter((item) => {
- return find(item, regex);
- });
- this.updateFiltered(result, emit);
- }, DEBOUNCE_TIMEOUT);
- this.inputHandler = (event) => {
- const target = event.target;
- this.value = target.value;
- this.filter(target.value, true);
- };
- this.keyDownHandler = (event) => {
- if (event.key === "Escape") {
- this.clear();
- }
- if (event.key === "Enter") {
- event.preventDefault();
- }
- };
- this.clear = () => {
- this.value = "";
- this.filter("", true);
- this.setFocus();
- };
- }
- watchItemsHandler() {
- this.filter(this.value);
- }
- valueHandler(value) {
- this.filter(value);
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentDidRender() {
- updateHostInteraction(this);
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentWillLoad() {
- this.filter(this.value);
- }
- // --------------------------------------------------------------------------
- //
- // Public Methods
- //
- // --------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- focusElement(this.textInput);
- }
- updateFiltered(filtered, emit = false) {
- this.filteredItems.length = 0;
- this.filteredItems = this.filteredItems.concat(filtered);
- if (emit) {
- this.calciteFilterChange.emit();
- }
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- render() {
- const { disabled, scale } = this;
- return (h(Fragment, null, h("div", { class: CSS$x.container }, h("label", null, h("calcite-input", { "aria-label": this.intlLabel || TEXT$e.filterLabel, clearable: true, disabled: disabled, icon: ICONS$8.search, intlClear: this.intlClear || TEXT$e.clear, onCalciteInputInput: this.inputHandler, onKeyDown: this.keyDownHandler, placeholder: this.placeholder, ref: (el) => {
- this.textInput = el;
- }, scale: scale, type: "text", value: this.value })))));
- }
- get el() { return this; }
- static get watchers() { return {
- "items": ["watchItemsHandler"],
- "value": ["valueHandler"]
- }; }
- static get style() { return filterCss; }
- };
- const CSS$w = {
- frame: "frame",
- frameAdvancing: "frame--advancing",
- frameRetreating: "frame--retreating"
- };
- const flowCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:host{-webkit-box-sizing:border-box;box-sizing:border-box;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-2);font-size:var(--calcite-font-size--1)}:host *{-webkit-box-sizing:border-box;box-sizing:border-box}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;display:-ms-flexbox;display:flex;width:100%;-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-align:stretch;align-items:stretch;overflow:hidden;background-color:transparent}:host .frame{position:relative;margin:0px;display:-ms-flexbox;display:flex;width:100%;-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:stretch;align-items:stretch;padding:0px}:host ::slotted(calcite-panel){height:100%}:host ::slotted(.calcite-match-height:last-child){display:-ms-flexbox;display:flex;-ms-flex:1 1 auto;flex:1 1 auto;overflow:hidden}:host .frame--advancing{-webkit-animation:calcite-frame-advance var(--calcite-animation-timing);animation:calcite-frame-advance var(--calcite-animation-timing)}:host .frame--retreating{-webkit-animation:calcite-frame-retreat var(--calcite-animation-timing);animation:calcite-frame-retreat var(--calcite-animation-timing)}@-webkit-keyframes calcite-frame-advance{0%{--tw-bg-opacity:0.5;-webkit-transform:translate3d(50px, 0, 0);transform:translate3d(50px, 0, 0)}100%{--tw-bg-opacity:1;-webkit-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0)}}@keyframes calcite-frame-advance{0%{--tw-bg-opacity:0.5;-webkit-transform:translate3d(50px, 0, 0);transform:translate3d(50px, 0, 0)}100%{--tw-bg-opacity:1;-webkit-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0)}}@-webkit-keyframes calcite-frame-retreat{0%{--tw-bg-opacity:0.5;-webkit-transform:translate3d(-50px, 0, 0);transform:translate3d(-50px, 0, 0)}100%{--tw-bg-opacity:1;-webkit-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0)}}@keyframes calcite-frame-retreat{0%{--tw-bg-opacity:0.5;-webkit-transform:translate3d(-50px, 0, 0);transform:translate3d(-50px, 0, 0)}100%{--tw-bg-opacity:1;-webkit-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0)}}";
- const Flow = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.panelCount = 0;
- this.flowDirection = null;
- this.panels = [];
- this.getFlowDirection = (oldPanelCount, newPanelCount) => {
- const allowRetreatingDirection = oldPanelCount > 1;
- const allowAdvancingDirection = oldPanelCount && newPanelCount > 1;
- if (!allowAdvancingDirection && !allowRetreatingDirection) {
- return null;
- }
- return newPanelCount < oldPanelCount ? "retreating" : "advancing";
- };
- this.updateFlowProps = () => {
- const { panels } = this;
- const newPanels = Array.from(this.el.querySelectorAll("calcite-panel"));
- const oldPanelCount = panels.length;
- const newPanelCount = newPanels.length;
- const activePanel = newPanels[newPanelCount - 1];
- const previousPanel = newPanels[newPanelCount - 2];
- if (newPanelCount && activePanel) {
- newPanels.forEach((panelNode) => {
- panelNode.showBackButton = newPanelCount > 1;
- panelNode.hidden = panelNode !== activePanel;
- });
- }
- if (previousPanel) {
- previousPanel.menuOpen = false;
- }
- this.panels = newPanels;
- if (oldPanelCount !== newPanelCount) {
- const flowDirection = this.getFlowDirection(oldPanelCount, newPanelCount);
- this.panelCount = newPanelCount;
- this.flowDirection = flowDirection;
- }
- };
- this.panelItemMutationObserver = createObserver("mutation", this.updateFlowProps);
- }
- // --------------------------------------------------------------------------
- //
- // Public Methods
- //
- // --------------------------------------------------------------------------
- /**
- * Removes the currently active `calcite-panel`.
- */
- async back() {
- const lastItem = this.el.querySelector("calcite-panel:last-child");
- if (!lastItem) {
- return;
- }
- const beforeBack = lastItem.beforeBack
- ? lastItem.beforeBack
- : () => Promise.resolve();
- return beforeBack.call(lastItem).then(() => {
- lastItem.remove();
- return lastItem;
- });
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- var _a;
- (_a = this.panelItemMutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
- this.updateFlowProps();
- }
- disconnectedCallback() {
- var _a;
- (_a = this.panelItemMutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- }
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- handleCalcitePanelBackClick() {
- this.back();
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- render() {
- const { flowDirection, panelCount } = this;
- const frameDirectionClasses = {
- [CSS$w.frame]: true,
- [CSS$w.frameAdvancing]: flowDirection === "advancing",
- [CSS$w.frameRetreating]: flowDirection === "retreating"
- };
- return (h("div", { class: frameDirectionClasses, key: panelCount }, h("slot", null)));
- }
- get el() { return this; }
- static get style() { return flowCss; }
- };
- /**
- * Calculate slope of the tangents
- * uses Steffen interpolation as it's monotonic
- * http://jrwalsh1.github.io/posts/interpolations/
- */
- function slope(p0, p1, p2) {
- const dx = p1[0] - p0[0];
- const dx1 = p2[0] - p1[0];
- const dy = p1[1] - p0[1];
- const dy1 = p2[1] - p1[1];
- const m = dy / (dx || (dx1 < 0 && 0));
- const m1 = dy1 / (dx1 || (dx < 0 && 0));
- const p = (m * dx1 + m1 * dx) / (dx + dx1);
- return (Math.sign(m) + Math.sign(m1)) * Math.min(Math.abs(m), Math.abs(m1), 0.5 * Math.abs(p)) || 0;
- }
- /**
- * Calculate slope for just one tangent (single-sided)
- */
- function slopeSingle(p0, p1, m) {
- const dx = p1[0] - p0[0];
- const dy = p1[1] - p0[1];
- return dx ? ((3 * dy) / dx - m) / 2 : m;
- }
- /**
- * Given two points and their tangent slopes,
- * calculate the bezier handle coordinates and return draw command.
- *
- * Translates Hermite Spline to Beziér curve:
- * stackoverflow.com/questions/42574940/
- */
- function bezier(p0, p1, m0, m1, t) {
- const [x0, y0] = p0;
- const [x1, y1] = p1;
- const dx = (x1 - x0) / 3;
- const h1 = t([x0 + dx, y0 + dx * m0]).join(",");
- const h2 = t([x1 - dx, y1 - dx * m1]).join(",");
- const p = t([x1, y1]).join(",");
- return `C ${h1} ${h2} ${p}`;
- }
- /**
- * Generate a function which will translate a point
- * from the data coordinate space to svg viewbox oriented pixels
- */
- function translate({ width, height, min, max }) {
- const rangeX = max[0] - min[0];
- const rangeY = max[1] - min[1];
- return (point) => {
- const x = ((point[0] - min[0]) / rangeX) * width;
- const y = height - (point[1] / rangeY) * height;
- return [x, y];
- };
- }
- /**
- * Get the min and max values from the dataset
- */
- function range(data) {
- const [startX, startY] = data[0];
- const min = [startX, startY];
- const max = [startX, startY];
- return data.reduce(({ min, max }, [x, y]) => ({
- min: [Math.min(min[0], x), Math.min(min[1], y)],
- max: [Math.max(max[0], x), Math.max(max[1], y)]
- }), { min, max });
- }
- /**
- * Generate drawing commands for an area graph
- * returns a string can can be passed directly to a path element's `d` attribute
- */
- function area({ data, min, max, t }) {
- if (data.length === 0) {
- return "";
- }
- // important points for beginning and ending the path
- const [startX, startY] = t(data[0]);
- const [minX, minY] = t(min);
- const [maxX] = t(max);
- // keep track of previous slope/points
- let m;
- let p0;
- let p1;
- // iterate over data points, calculating command for each
- const commands = data.reduce((acc, point, i) => {
- p0 = data[i - 2];
- p1 = data[i - 1];
- if (i > 1) {
- const m1 = slope(p0, p1, point);
- const m0 = m === undefined ? slopeSingle(p0, p1, m1) : m;
- const command = bezier(p0, p1, m0, m1, t);
- m = m1;
- return `${acc} ${command}`;
- }
- return acc;
- }, `M ${minX},${minY} L ${minX},${startY} L ${startX},${startY}`);
- // close the path
- const last = data[data.length - 1];
- const end = bezier(p1, last, m, slopeSingle(p1, last, m), t);
- return `${commands} ${end} L ${maxX},${minY} Z`;
- }
- const graphCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:block}.svg{fill:currentColor;stroke:transparent;margin:0px;display:block;height:100%;width:100%;padding:0px}.svg .graph-path--highlight{fill:var(--calcite-ui-brand);opacity:0.5}";
- const Graph = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /**
- * Array of tuples describing a single data point ([x, y])
- * These data points should be sorted by x-axis value
- */
- this.data = [];
- //--------------------------------------------------------------------------
- //
- // Private State/Props
- //
- //--------------------------------------------------------------------------
- this.graphId = `calcite-graph-${guid()}`;
- this.resizeObserver = createObserver("resize", () => forceUpdate(this));
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- var _a;
- (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el);
- }
- disconnectedCallback() {
- var _a;
- (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- }
- render() {
- const { data, colorStops, el, highlightMax, highlightMin, min, max } = this;
- const id = this.graphId;
- const { clientHeight: height, clientWidth: width } = el;
- // if we have no data, return empty svg
- if (!data || data.length === 0) {
- return (h("svg", { class: "svg", height: height, preserveAspectRatio: "none", viewBox: `0 0 ${width} ${height}`, width: width }));
- }
- const { min: rangeMin, max: rangeMax } = range(data);
- let currentMin = rangeMin;
- let currentMax = rangeMax;
- if (min < rangeMin[0] || min > rangeMin[0]) {
- currentMin = [min, 0];
- }
- if (max > rangeMax[0] || max < rangeMax[0]) {
- currentMax = [max, rangeMax[1]];
- }
- const t = translate({ min: currentMin, max: currentMax, width, height });
- const [hMinX] = t([highlightMin, currentMax[1]]);
- const [hMaxX] = t([highlightMax, currentMax[1]]);
- const areaPath = area({ data, min: rangeMin, max: rangeMax, t });
- const fill = colorStops ? `url(#linear-gradient-${id})` : undefined;
- return (h("svg", { class: "svg", height: height, preserveAspectRatio: "none", viewBox: `0 0 ${width} ${height}`, width: width }, colorStops ? (h("defs", null, h("linearGradient", { id: `linear-gradient-${id}`, x1: "0", x2: "1", y1: "0", y2: "0" }, colorStops.map(({ offset, color, opacity }) => (h("stop", { offset: `${offset * 100}%`, "stop-color": color, "stop-opacity": opacity })))))) : null, highlightMin !== undefined ? ([
- h("mask", { height: "100%", id: `${id}1`, width: "100%", x: "0%", y: "0%" }, h("path", { d: `
- M 0,0
- L ${hMinX - 1},0
- L ${hMinX - 1},${height}
- L 0,${height}
- Z
- `, fill: "white" })),
- h("mask", { height: "100%", id: `${id}2`, width: "100%", x: "0%", y: "0%" }, h("path", { d: `
- M ${hMinX + 1},0
- L ${hMaxX - 1},0
- L ${hMaxX - 1},${height}
- L ${hMinX + 1}, ${height}
- Z
- `, fill: "white" })),
- h("mask", { height: "100%", id: `${id}3`, width: "100%", x: "0%", y: "0%" }, h("path", { d: `
- M ${hMaxX + 1},0
- L ${width},0
- L ${width},${height}
- L ${hMaxX + 1}, ${height}
- Z
- `, fill: "white" })),
- h("path", { class: "graph-path", d: areaPath, fill: fill, mask: `url(#${id}1)` }),
- h("path", { class: "graph-path--highlight", d: areaPath, fill: fill, mask: `url(#${id}2)` }),
- h("path", { class: "graph-path", d: areaPath, fill: fill, mask: `url(#${id}3)` })
- ]) : (h("path", { class: "graph-path", d: areaPath, fill: fill }))));
- }
- get el() { return this; }
- static get style() { return graphCss; }
- };
- const CSS$v = {
- handle: "handle",
- handleActivated: "handle--activated"
- };
- const ICONS$7 = {
- drag: "drag"
- };
- const handleCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:-ms-flexbox;display:flex}.handle{display:-ms-flexbox;display:flex;cursor:move;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;-ms-flex-item-align:stretch;align-self:stretch;border-style:none;background-color:transparent;outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;color:var(--calcite-ui-border-3);padding:0.75rem 0.25rem;line-height:0}.handle:hover{background-color:var(--calcite-ui-foreground-2);color:var(--calcite-ui-text-1)}.handle:focus{color:var(--calcite-ui-text-1);outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.handle--activated{background-color:var(--calcite-ui-foreground-3);color:var(--calcite-ui-text-1)}.handle calcite-icon{color:inherit}";
- const Handle = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteHandleNudge = createEvent(this, "calciteHandleNudge", 7);
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * @internal - stores the activated state of the drag handle.
- */
- this.activated = false;
- /**
- * Value for the button title attribute
- */
- this.textTitle = "handle";
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- this.handleKeyDown = (event) => {
- switch (event.key) {
- case " ":
- this.activated = !this.activated;
- break;
- case "ArrowUp":
- case "ArrowDown":
- if (!this.activated) {
- return;
- }
- const direction = event.key.toLowerCase().replace("arrow", "");
- this.calciteHandleNudge.emit({ handle: this.el, direction });
- break;
- }
- };
- this.handleBlur = () => {
- this.activated = false;
- };
- }
- // --------------------------------------------------------------------------
- //
- // Methods
- //
- // --------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- this.handleButton.focus();
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- render() {
- return (
- // Needs to be a span because of https://github.com/SortableJS/Sortable/issues/1486
- h("span", { "aria-pressed": toAriaBoolean(this.activated), class: { [CSS$v.handle]: true, [CSS$v.handleActivated]: this.activated }, onBlur: this.handleBlur, onKeyDown: this.handleKeyDown, ref: (el) => {
- this.handleButton = el;
- }, role: "button", tabindex: "0", title: this.textTitle }, h("calcite-icon", { icon: ICONS$7.drag, scale: "s" })));
- }
- get el() { return this; }
- static get style() { return handleCss; }
- };
- const CSS$u = {
- icon: "icon",
- flipRtl: "flip-rtl"
- };
- /**
- * Icon data cache.
- * Exported for testing purposes.
- * @private
- */
- const iconCache = {};
- /**
- * Icon request cache.
- * Exported for testing purposes.
- * @private
- */
- const requestCache = {};
- const scaleToPx = {
- s: 16,
- m: 24,
- l: 32
- };
- async function fetchIcon({ icon, scale }) {
- const size = scaleToPx[scale];
- const name = normalizeIconName(icon);
- const filled = name.charAt(name.length - 1) === "F";
- const iconName = filled ? name.substring(0, name.length - 1) : name;
- const id = `${iconName}${size}${filled ? "F" : ""}`;
- if (iconCache[id]) {
- return iconCache[id];
- }
- if (!requestCache[id]) {
- requestCache[id] = fetch(getAssetPath(`./assets/icon/${id}.json`))
- .then((resp) => resp.json())
- .catch(() => {
- console.error(`"${id}" is not a valid calcite-ui-icon name`);
- return "";
- });
- }
- const path = await requestCache[id];
- iconCache[id] = path;
- return path;
- }
- /**
- * Normalize the icon name to match the path data module exports.
- * Exported for testing purposes.
- * @private
- */
- function normalizeIconName(name) {
- const numberLeadingName = !isNaN(Number(name.charAt(0)));
- const parts = name.split("-");
- if (parts.length === 1) {
- return numberLeadingName ? `i${name}` : name;
- }
- return parts
- .map((part, index) => {
- if (index === 0) {
- return numberLeadingName ? `i${part.toUpperCase()}` : part;
- }
- return part.charAt(0).toUpperCase() + part.slice(1);
- })
- .join("");
- }
- const iconCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:-ms-inline-flexbox;display:inline-flex;color:var(--calcite-ui-icon-color)}:host([scale=s]){height:1rem;width:1rem;min-width:1rem;min-height:1rem}:host([scale=m]){height:1.5rem;width:1.5rem;min-width:1.5rem;min-height:1.5rem}:host([scale=l]){height:2rem;width:2rem;min-width:2rem;min-height:2rem}.flip-rtl{-webkit-transform:scaleX(-1);transform:scaleX(-1)}.svg{display:block}";
- const Icon = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /**
- * The name of the icon to display. The value of this property must match the icon name from https://esri.github.io/calcite-ui-icons/.
- */
- this.icon = null;
- /**
- * When true, the icon will be flipped when the element direction is 'rtl'.
- */
- this.flipRtl = false;
- /**
- * Icon scale.
- */
- this.scale = "m";
- this.visible = false;
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- this.waitUntilVisible(() => {
- this.visible = true;
- this.loadIconPathData();
- });
- }
- disconnectedCallback() {
- var _a;
- (_a = this.intersectionObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- this.intersectionObserver = null;
- }
- async componentWillLoad() {
- this.loadIconPathData();
- }
- render() {
- const { el, flipRtl, pathData, scale, textLabel } = this;
- const dir = getElementDir(el);
- const size = scaleToPx[scale];
- const semantic = !!textLabel;
- const paths = [].concat(pathData || "");
- return (h(Host, { "aria-hidden": toAriaBoolean(!semantic), "aria-label": semantic ? textLabel : null, role: semantic ? "img" : null }, h("svg", { class: {
- [CSS$u.flipRtl]: dir === "rtl" && flipRtl,
- svg: true
- }, fill: "currentColor", height: "100%", viewBox: `0 0 ${size} ${size}`, width: "100%", xmlns: "http://www.w3.org/2000/svg" }, paths.map((path) => typeof path === "string" ? (h("path", { d: path })) : (h("path", { d: path.d, opacity: "opacity" in path ? path.opacity : 1 }))))));
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- async loadIconPathData() {
- const { icon, scale, visible } = this;
- if (!Build.isBrowser || !icon || !visible) {
- return;
- }
- this.pathData = await fetchIcon({ icon, scale });
- }
- waitUntilVisible(callback) {
- this.intersectionObserver = createObserver("intersection", (entries) => {
- entries.forEach((entry) => {
- if (entry.isIntersecting) {
- this.intersectionObserver.disconnect();
- this.intersectionObserver = null;
- callback();
- }
- });
- }, { rootMargin: "50px" });
- if (!this.intersectionObserver) {
- callback();
- return;
- }
- this.intersectionObserver.observe(this.el);
- }
- static get assetsDirs() { return ["assets"]; }
- get el() { return this; }
- static get watchers() { return {
- "icon": ["loadIconPathData"],
- "scale": ["loadIconPathData"]
- }; }
- static get style() { return iconCss; }
- };
- const CSS$t = {
- wrapper: "wrapper",
- confirmChangesButton: "confirm-changes-button",
- cancelEditingButton: "cancel-editing-button",
- inputWrapper: "input-wrapper",
- cancelEditingButtonWrapper: "cancel-editing-button-wrapper",
- enableEditingButton: "enable-editing-button",
- controlsWrapper: "controls-wrapper"
- };
- const TEXT$d = {
- intlEnablingEditing: "Click to edit",
- intlCancelEditing: "Cancel",
- intlConfirmChanges: "Save"
- };
- const inlineEditableCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:block}:host([scale=s]) .controls-wrapper{height:1.5rem}:host([scale=m]) .controls-wrapper{height:2rem}:host([scale=l]) .controls-wrapper{height:2.75rem}:host(:not([editing-enabled]):not([disabled])) .wrapper:hover{background-color:var(--calcite-ui-foreground-2)}.wrapper{-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;background-color:var(--calcite-ui-foreground-1);-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s}.wrapper .input-wrapper{-ms-flex:1 1 0%;flex:1 1 0%}.controls-wrapper{display:-ms-flexbox;display:flex}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) .cancel-editing-button-wrapper{border-color:var(--calcite-ui-border-2)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}";
- const InlineEditable = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteInlineEditableEditCancel = createEvent(this, "calciteInlineEditableEditCancel", 7);
- this.calciteInlineEditableEditConfirm = createEvent(this, "calciteInlineEditableEditConfirm", 7);
- this.calciteInlineEditableEnableEditingChange = createEvent(this, "calciteInlineEditableEnableEditingChange", 7);
- //--------------------------------------------------------------------------
- //
- // Props
- //
- //--------------------------------------------------------------------------
- /** specify whether editing can be enabled */
- this.disabled = false;
- /** specify whether the wrapped input element is editable, defaults to false */
- this.editingEnabled = false;
- /** specify whether the confirm button should display a loading state, defaults to false */
- this.loading = false;
- /** specify whether save/cancel controls should be displayed when editingEnabled is true, defaults to false */
- this.controls = false;
- /** specify text to be user for the enable editing button's aria-label, defaults to `Click to edit`
- * @default "Click to edit"
- */
- this.intlEnableEditing = TEXT$d.intlEnablingEditing;
- /** specify text to be user for the cancel editing button's aria-label, defaults to `Cancel`
- * @default "Cancel"
- */
- this.intlCancelEditing = TEXT$d.intlCancelEditing;
- /** specify text to be user for the confirm changes button's aria-label, defaults to `Save`
- * @default "Save"
- */
- this.intlConfirmChanges = TEXT$d.intlConfirmChanges;
- this.mutationObserver = createObserver("mutation", () => this.mutationObserverCallback());
- this.enableEditing = () => {
- var _a, _b;
- this.valuePriorToEditing = (_a = this.inputElement) === null || _a === void 0 ? void 0 : _a.value;
- this.editingEnabled = true;
- (_b = this.inputElement) === null || _b === void 0 ? void 0 : _b.setFocus();
- this.calciteInlineEditableEnableEditingChange.emit();
- };
- this.disableEditing = () => {
- this.editingEnabled = false;
- };
- this.cancelEditing = () => {
- if (this.inputElement) {
- this.inputElement.value = this.valuePriorToEditing;
- }
- this.disableEditing();
- this.enableEditingButton.setFocus();
- if (!this.editingEnabled && !!this.shouldEmitCancel) {
- this.calciteInlineEditableEditCancel.emit();
- }
- };
- this.escapeKeyHandler = async (e) => {
- var _a;
- if (e.key !== "Escape") {
- if (e.key === "Tab" && this.shouldShowControls) {
- if (!e.shiftKey && e.target === this.inputElement) {
- e.preventDefault();
- this.cancelEditingButton.setFocus();
- }
- if (!!e.shiftKey && e.target === this.cancelEditingButton) {
- e.preventDefault();
- (_a = this.inputElement) === null || _a === void 0 ? void 0 : _a.setFocus();
- }
- }
- return;
- }
- this.cancelEditing();
- };
- this.cancelEditingHandler = async (e) => {
- e.preventDefault();
- this.cancelEditing();
- };
- this.enableEditingHandler = async (e) => {
- if (this.disabled ||
- e.target === this.cancelEditingButton ||
- e.target === this.confirmEditingButton) {
- return;
- }
- e.preventDefault();
- if (!this.editingEnabled) {
- this.enableEditing();
- }
- };
- this.confirmChangesHandler = async (e) => {
- e.preventDefault();
- this.calciteInlineEditableEditConfirm.emit();
- try {
- if (this.afterConfirm) {
- this.loading = true;
- await this.afterConfirm();
- this.disableEditing();
- this.enableEditingButton.setFocus();
- }
- }
- catch (e) {
- }
- finally {
- this.loading = false;
- }
- };
- }
- disabledWatcher(disabled) {
- if (this.inputElement) {
- this.inputElement.disabled = disabled;
- }
- }
- editingEnabledWatcher(newValue, oldValue) {
- if (this.inputElement) {
- this.inputElement.editingEnabled = newValue;
- }
- if (!newValue && !!oldValue) {
- this.shouldEmitCancel = true;
- }
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- var _a;
- connectLabel(this);
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true });
- this.mutationObserverCallback();
- }
- disconnectedCallback() {
- var _a;
- disconnectLabel(this);
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- render() {
- return (h("div", { class: CSS$t.wrapper, onClick: this.enableEditingHandler, onKeyDown: this.escapeKeyHandler }, h("div", { class: CSS$t.inputWrapper }, h("slot", null)), h("div", { class: CSS$t.controlsWrapper }, h("calcite-button", { appearance: "transparent", class: CSS$t.enableEditingButton, color: "neutral", disabled: this.disabled, iconStart: "pencil", label: this.intlEnableEditing, onClick: this.enableEditingHandler, ref: (el) => (this.enableEditingButton = el), scale: this.scale, style: {
- opacity: this.editingEnabled ? "0" : "1",
- width: this.editingEnabled ? "0" : "inherit"
- }, type: "button" }), this.shouldShowControls && [
- h("div", { class: CSS$t.cancelEditingButtonWrapper }, h("calcite-button", { appearance: "transparent", class: CSS$t.cancelEditingButton, color: "neutral", disabled: this.disabled, iconStart: "x", label: this.intlCancelEditing, onClick: this.cancelEditingHandler, ref: (el) => (this.cancelEditingButton = el), scale: this.scale, type: "button" })),
- h("calcite-button", { appearance: "solid", class: CSS$t.confirmChangesButton, color: "blue", disabled: this.disabled, iconStart: "check", label: this.intlConfirmChanges, loading: this.loading, onClick: this.confirmChangesHandler, ref: (el) => (this.confirmEditingButton = el), scale: this.scale, type: "button" })
- ])));
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- blurHandler() {
- if (!this.controls) {
- this.disableEditing();
- }
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- async setFocus() {
- var _a, _b;
- if (this.editingEnabled) {
- (_a = this.inputElement) === null || _a === void 0 ? void 0 : _a.setFocus();
- }
- else {
- (_b = this.enableEditingButton) === null || _b === void 0 ? void 0 : _b.setFocus();
- }
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- mutationObserverCallback() {
- var _a;
- this.updateSlottedInput();
- this.scale =
- this.scale || ((_a = this.inputElement) === null || _a === void 0 ? void 0 : _a.scale) || getElementProp(this.el, "scale", undefined);
- }
- onLabelClick() {
- this.setFocus();
- }
- updateSlottedInput() {
- const inputElement = getSlotted(this.el, {
- matches: "calcite-input"
- });
- this.inputElement = inputElement;
- if (!inputElement) {
- return;
- }
- this.inputElement.disabled = this.disabled;
- this.inputElement.label = this.inputElement.label || getLabelText(this);
- }
- get shouldShowControls() {
- return this.editingEnabled && this.controls;
- }
- get el() { return this; }
- static get watchers() { return {
- "disabled": ["disabledWatcher"],
- "editingEnabled": ["editingEnabledWatcher"]
- }; }
- static get style() { return inlineEditableCss; }
- };
- const CSS$s = {
- loader: "loader",
- clearButton: "clear-button",
- editingEnabled: "editing-enabled",
- inlineChild: "inline-child",
- inputIcon: "icon",
- prefix: "prefix",
- suffix: "suffix",
- numberButtonWrapper: "number-button-wrapper",
- buttonItemHorizontal: "number-button-item--horizontal",
- wrapper: "element-wrapper",
- inputWrapper: "wrapper",
- actionWrapper: "action-wrapper",
- resizeIconWrapper: "resize-icon-wrapper",
- numberButtonItem: "number-button-item"
- };
- const INPUT_TYPE_ICONS = {
- tel: "phone",
- password: "lock",
- email: "email-address",
- date: "calendar",
- time: "clock",
- search: "search"
- };
- const SLOTS$g = {
- action: "action"
- };
- const TEXT$c = {
- clear: "Clear value"
- };
- const inputCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:block}:host([scale=s]) input,:host([scale=s]) .prefix,:host([scale=s]) .suffix{height:1.5rem;padding:0.5rem;font-size:var(--calcite-font-size--2);line-height:1rem}:host([scale=s]) textarea{height:1.5rem;min-height:1.5rem}:host([scale=s]) .number-button-wrapper,:host([scale=s]) .action-wrapper calcite-button,:host([scale=s]) .action-wrapper calcite-button button{height:1.5rem}:host([scale=s]) input[type=file]{height:1.5rem}:host([scale=s]) .clear-button{min-height:1.5rem;min-width:1.5rem}:host([scale=s]) textarea{height:auto;padding-top:0.25rem;padding-bottom:0.25rem;padding-left:0.5rem;padding-right:0.5rem;font-size:var(--calcite-font-size--2);line-height:1rem}:host([scale=m]) input,:host([scale=m]) .prefix,:host([scale=m]) .suffix{height:2rem;padding:0.75rem;font-size:var(--calcite-font-size--1);line-height:1rem}:host([scale=m]) textarea{min-height:2rem}:host([scale=m]) .number-button-wrapper,:host([scale=m]) .action-wrapper calcite-button,:host([scale=m]) .action-wrapper calcite-button button{height:2rem}:host([scale=m]) input[type=file]{height:2rem}:host([scale=m]) .clear-button{min-height:2rem;min-width:2rem}:host([scale=m]) textarea{height:auto;padding-top:0.5rem;padding-bottom:0.5rem;padding-left:0.75rem;padding-right:0.75rem;font-size:var(--calcite-font-size--1);line-height:1rem}:host([scale=l]) input,:host([scale=l]) .prefix,:host([scale=l]) .suffix{height:2.75rem;padding:1rem;font-size:var(--calcite-font-size-0);line-height:1.25rem}:host([scale=l]) textarea{min-height:2.75rem}:host([scale=l]) .number-button-wrapper,:host([scale=l]) .action-wrapper calcite-button,:host([scale=l]) .action-wrapper calcite-button button{height:2.75rem}:host([scale=l]) input[type=file]{height:2.75rem}:host([scale=l]) .clear-button{min-height:2.75rem;min-width:2.75rem}:host([scale=l]) textarea{height:auto;padding-top:0.75rem;padding-bottom:0.75rem;padding-left:1rem;padding-right:1rem;font-size:var(--calcite-font-size-0);line-height:1.25rem}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) textarea{resize:none}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host textarea,:host input{-webkit-transition:var(--calcite-animation-timing), height 0s;transition:var(--calcite-animation-timing), height 0s;-webkit-appearance:none;position:relative;margin:0px;-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;max-height:100%;width:100%;max-width:100%;-ms-flex:1 1 0%;flex:1 1 0%;border-radius:0px;background-color:var(--calcite-ui-foreground-1);font-family:inherit;font-weight:var(--calcite-font-weight-normal);color:var(--calcite-ui-text-1)}:host input[type=search]::-webkit-search-decoration{-webkit-appearance:none}:host input,:host textarea{border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-input);color:var(--calcite-ui-text-1)}:host input:-ms-input-placeholder,:host textarea:-ms-input-placeholder{font-weight:var(--calcite-font-weight-normal);color:var(--calcite-ui-text-3)}:host input::-ms-input-placeholder,:host textarea::-ms-input-placeholder{font-weight:var(--calcite-font-weight-normal);color:var(--calcite-ui-text-3)}:host input::placeholder,:host input:-ms-input-placeholder,:host input::-ms-input-placeholder,:host textarea::placeholder,:host textarea:-ms-input-placeholder,:host textarea::-ms-input-placeholder{font-weight:var(--calcite-font-weight-normal);color:var(--calcite-ui-text-3)}:host input:focus,:host textarea:focus{border-color:var(--calcite-ui-brand);color:var(--calcite-ui-text-1)}:host input[readonly],:host textarea[readonly]{background-color:var(--calcite-ui-background);font-weight:var(--calcite-font-weight-medium)}:host input[readonly]:focus,:host textarea[readonly]:focus{color:var(--calcite-ui-text-1)}:host calcite-icon{color:var(--calcite-ui-text-3)}:host textarea,:host input{outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out}:host textarea:focus,:host input:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}:host([status=invalid]) input,:host([status=invalid]) textarea{border-color:var(--calcite-ui-danger)}:host([status=invalid]) input:focus,:host([status=invalid]) textarea:focus{outline:2px solid var(--calcite-ui-danger);outline-offset:-2px}:host([scale=s]) .icon{inset-inline-start:0.5rem}:host([scale=m]) .icon{inset-inline-start:0.75rem}:host([scale=l]) .icon{inset-inline-start:1rem}:host([icon][scale=s]) input{-webkit-padding-start:2rem;padding-inline-start:2rem}:host([icon][scale=m]) input{-webkit-padding-start:2.5rem;padding-inline-start:2.5rem}:host([icon][scale=l]) input{-webkit-padding-start:3rem;padding-inline-start:3rem}.element-wrapper{position:relative;-ms-flex-order:3;order:3;display:-ms-inline-flexbox;display:inline-flex;-ms-flex:1 1 0%;flex:1 1 0%;-ms-flex-align:center;align-items:center}.icon{pointer-events:none;position:absolute;z-index:10;display:block;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s}input[type=text]::-ms-clear,input[type=text]::-ms-reveal{display:none;height:0px;width:0px}input[type=search]::-webkit-search-decoration,input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-results-button,input[type=search]::-webkit-search-results-decoration,input[type=date]::-webkit-clear-button,input[type=time]::-webkit-clear-button{display:none}.clear-button{pointer-events:initial;-ms-flex-order:4;order:4;margin:0px;-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;min-height:100%;cursor:pointer;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;-ms-flex-item-align:stretch;align-self:stretch;border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-input);background-color:var(--calcite-ui-foreground-1);outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;border-inline-start-width:0px}.clear-button:hover{background-color:var(--calcite-ui-foreground-2);-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s}.clear-button:hover calcite-icon{color:var(--calcite-ui-text-1);-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s}.clear-button:active{background-color:var(--calcite-ui-foreground-3)}.clear-button:active calcite-icon{color:var(--calcite-ui-text-1)}.clear-button:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.clear-button:disabled{opacity:var(--calcite-ui-opacity-disabled)}.loader{top:1px;left:1px;right:1px;pointer-events:none;position:absolute;display:block}.action-wrapper{-ms-flex-order:7;order:7;display:-ms-flexbox;display:flex}.prefix,.suffix{-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;height:auto;min-height:100%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-ms-flex-line-pack:center;align-content:center;-ms-flex-align:center;align-items:center;overflow-wrap:break-word;border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-input);background-color:var(--calcite-ui-background);font-weight:var(--calcite-font-weight-medium);line-height:1;color:var(--calcite-ui-text-2)}.prefix{-ms-flex-order:2;order:2;border-inline-end-width:0px}.suffix{-ms-flex-order:5;order:5;border-inline-start-width:0px}:host([alignment=start]) textarea,:host([alignment=start]) input{text-align:start}:host([alignment=end]) textarea,:host([alignment=end]) input{text-align:end}:host input[type=number]{-moz-appearance:textfield}:host input[type=number]::-webkit-inner-spin-button,:host input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;-moz-appearance:textfield;margin:0px}.number-button-wrapper{pointer-events:none;-ms-flex-order:6;order:6;-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s}:host([number-button-type=vertical]) .wrapper{-ms-flex-direction:row;flex-direction:row;display:-ms-flexbox;display:flex}:host([number-button-type=vertical]) input,:host([number-button-type=vertical]) textarea{-ms-flex-order:2;order:2}:host([number-button-type=horizontal]) .calcite--rtl .number-button-item[data-adjustment=down] calcite-icon{-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}:host([number-button-type=horizontal]) .calcite--rtl .number-button-item[data-adjustment=up] calcite-icon{-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}.number-button-item.number-button-item--horizontal[data-adjustment=down],.number-button-item.number-button-item--horizontal[data-adjustment=up]{-ms-flex-order:1;order:1;max-height:100%;min-height:100%;-ms-flex-item-align:stretch;align-self:stretch}.number-button-item.number-button-item--horizontal[data-adjustment=down] calcite-icon,.number-button-item.number-button-item--horizontal[data-adjustment=up] calcite-icon{-webkit-transform:rotate(90deg);transform:rotate(90deg)}.number-button-item.number-button-item--horizontal[data-adjustment=down]{border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-input);border-inline-end-width:0px}.number-button-item.number-button-item--horizontal[data-adjustment=down]:hover{background-color:var(--calcite-ui-foreground-2)}.number-button-item.number-button-item--horizontal[data-adjustment=down]:hover calcite-icon{color:var(--calcite-ui-text-1)}.number-button-item.number-button-item--horizontal[data-adjustment=up]{-ms-flex-order:5;order:5}.number-button-item.number-button-item--horizontal[data-adjustment=up]:hover{background-color:var(--calcite-ui-foreground-2)}.number-button-item.number-button-item--horizontal[data-adjustment=up]:hover calcite-icon{color:var(--calcite-ui-text-1)}:host([number-button-type=vertical]) .number-button-item[data-adjustment=down]:hover{background-color:var(--calcite-ui-foreground-2)}:host([number-button-type=vertical]) .number-button-item[data-adjustment=down]:hover calcite-icon{color:var(--calcite-ui-text-1)}:host([number-button-type=vertical]) .number-button-item[data-adjustment=up]:hover{background-color:var(--calcite-ui-foreground-2)}:host([number-button-type=vertical]) .number-button-item[data-adjustment=up]:hover calcite-icon{color:var(--calcite-ui-text-1)}:host([number-button-type=vertical]) .number-button-item[data-adjustment=down]{border-top-width:0px}.number-button-item{max-height:50%;min-height:50%;pointer-events:initial;margin:0px;-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;cursor:pointer;-ms-flex-align:center;align-items:center;-ms-flex-item-align:center;align-self:center;border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-input);background-color:var(--calcite-ui-foreground-1);padding-top:0px;padding-bottom:0px;padding-left:0.5rem;padding-right:0.5rem;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s;border-inline-start-width:0px}.number-button-item calcite-icon{pointer-events:none;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s}.number-button-item:focus{background-color:var(--calcite-ui-foreground-2)}.number-button-item:focus calcite-icon{color:var(--calcite-ui-text-1)}.number-button-item:active{background-color:var(--calcite-ui-foreground-3)}.wrapper{position:relative;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-align:center;align-items:center}:host input::-webkit-calendar-picker-indicator{display:none}:host input[type=date]::-webkit-input-placeholder{visibility:hidden !important}:host textarea::-webkit-resizer{position:absolute;bottom:0px;-webkit-box-sizing:border-box;box-sizing:border-box;padding-top:0px;padding-bottom:0px;padding-left:0.25rem;padding-right:0.25rem;inset-inline-end:0}.resize-icon-wrapper{bottom:2px;inset-inline-end:2px;pointer-events:none;position:absolute;z-index:10;height:0.75rem;width:0.75rem;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-3)}.resize-icon-wrapper calcite-icon{bottom:0.25rem;inset-inline-end:0.25rem;-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}.calcite--rtl .resize-icon-wrapper calcite-icon{-webkit-transform:rotate(45deg);transform:rotate(45deg)}:host([type=color]) input{padding:0.25rem}:host([type=file]) input{cursor:pointer;border-width:1px;border-style:dashed;border-color:var(--calcite-ui-border-input);background-color:var(--calcite-ui-foreground-1);text-align:center}:host([type=file][scale=s]) input{padding-top:1px;padding-bottom:1px;padding-left:0.5rem;padding-right:0.5rem}:host([type=file][scale=m]) input{padding-top:0.25rem;padding-bottom:0.25rem;padding-left:0.75rem;padding-right:0.75rem}:host([type=file][scale=l]) input{padding-top:0.5rem;padding-bottom:0.5rem;padding-left:1rem;padding-right:1rem}:host(.no-bottom-border) input{border-bottom-width:0px}:host(.border-top-color-one) input{border-top-color:var(--calcite-ui-border-1)}:host .inline-child{background-color:transparent;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s}:host .inline-child .editing-enabled{background-color:inherit}:host .inline-child:not(.editing-enabled){display:-ms-flexbox;display:flex;cursor:pointer;border-color:transparent;-webkit-padding-start:0;padding-inline-start:0}::slotted(input[slot=hidden-form-input]){bottom:0 !important;left:0 !important;margin:0 !important;opacity:0 !important;outline:none !important;padding:0 !important;position:absolute !important;right:0 !important;top:0 !important;-webkit-transform:none !important;transform:none !important;-webkit-appearance:none !important;z-index:-1 !important}";
- const Input = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteInputFocus = createEvent(this, "calciteInputFocus", 7);
- this.calciteInputBlur = createEvent(this, "calciteInputBlur", 7);
- this.calciteInputInput = createEvent(this, "calciteInputInput", 7);
- this.calciteInputChange = createEvent(this, "calciteInputChange", 7);
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** specify the alignment of the value of the input */
- this.alignment = "start";
- /** should the input autofocus */
- this.autofocus = false;
- /** optionally display a clear button that displays when field has a value
- * shows by default for search, time, date
- * will not display for type="textarea" */
- this.clearable = false;
- /** is the input disabled */
- this.disabled = false;
- /** for number values, displays the locale's group separator */
- this.groupSeparator = false;
- /** when true, the component will not be visible */
- this.hidden = false;
- /**
- * string to override English loading text
- * @default "Loading"
- */
- this.intlLoading = TEXT$s.loading;
- /** flip the icon in rtl */
- this.iconFlipRtl = false;
- /** specify if the input is in loading state */
- this.loading = false;
- /** BCP 47 language tag for desired language and country format */
- this.locale = document.documentElement.lang || "en";
- /**
- * Toggles locale formatting for numbers.
- * @internal
- */
- this.localeFormat = false;
- /** specify the placement of the number buttons */
- this.numberButtonType = "vertical";
- /** When true, a field cannot be modified. */
- this.readOnly = false;
- /** is the input required */
- this.required = false;
- /** specify the scale of the input, defaults to m */
- this.scale = "m";
- /** specify the status of the input field, determines message and icons */
- this.status = "idle";
- /** @internal adds inline styles for text input when slotted in calcite-inline-editable */
- this.editingEnabled = false;
- /**
- * specify the input type
- *
- * Note that the following types add type-specific icons by default: `date`, `email`, `password`, `search`, `tel`, `time`
- */
- this.type = "text";
- /** input value */
- this.value = "";
- /** keep track of the rendered child type */
- this.childElType = "input";
- this.previousValueOrigin = "initial";
- this.mutationObserver = createObserver("mutation", () => this.setDisabledAction());
- this.userChangedValue = false;
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- this.keyDownHandler = (event) => {
- if (this.readOnly || this.disabled) {
- return;
- }
- if (this.isClearable && event.key === "Escape") {
- this.clearInputValue(event);
- event.preventDefault();
- }
- if (event.key === "Enter" && !event.defaultPrevented) {
- submitForm(this);
- }
- };
- this.clearInputValue = (nativeEvent) => {
- this.setValue({
- committing: true,
- nativeEvent,
- origin: "user",
- value: ""
- });
- };
- this.emitChangeIfUserModified = () => {
- if (this.previousValueOrigin === "user" && this.value !== this.previousEmittedValue) {
- this.calciteInputChange.emit();
- }
- this.previousEmittedValue = this.value;
- };
- this.inputBlurHandler = () => {
- this.calciteInputBlur.emit({
- element: this.childEl,
- value: this.value
- });
- this.emitChangeIfUserModified();
- };
- this.inputFocusHandler = (event) => {
- const slottedActionEl = getSlotted(this.el, "action");
- if (event.target !== slottedActionEl) {
- this.setFocus();
- }
- this.calciteInputFocus.emit({
- element: this.childEl,
- value: this.value
- });
- };
- this.inputInputHandler = (nativeEvent) => {
- if (this.disabled || this.readOnly) {
- return;
- }
- this.setValue({
- nativeEvent,
- origin: "user",
- value: nativeEvent.target.value
- });
- };
- this.inputKeyDownHandler = (event) => {
- if (this.disabled || this.readOnly) {
- return;
- }
- if (event.key === "Enter") {
- this.emitChangeIfUserModified();
- }
- };
- this.inputNumberInputHandler = (nativeEvent) => {
- if (this.disabled || this.readOnly) {
- return;
- }
- const value = nativeEvent.target.value;
- const delocalizedValue = delocalizeNumberString(value, this.locale);
- if (nativeEvent.inputType === "insertFromPaste") {
- if (!isValidNumber(delocalizedValue)) {
- nativeEvent.preventDefault();
- }
- this.setValue({
- nativeEvent,
- origin: "user",
- value: parseNumberString(delocalizedValue)
- });
- this.childNumberEl.value = this.localizedValue;
- }
- else {
- this.setValue({
- nativeEvent,
- origin: "user",
- value: delocalizedValue
- });
- }
- };
- this.inputNumberKeyDownHandler = (event) => {
- if (this.type !== "number" || this.disabled || this.readOnly) {
- return;
- }
- if (event.key === "ArrowUp") {
- /* prevent default behavior of moving cursor to the beginning of the input when holding down ArrowUp */
- event.preventDefault();
- this.nudgeNumberValue("up", event);
- return;
- }
- if (event.key === "ArrowDown") {
- this.nudgeNumberValue("down", event);
- return;
- }
- const supportedKeys = [
- ...numberKeys,
- "ArrowLeft",
- "ArrowRight",
- "Backspace",
- "Delete",
- "Enter",
- "Escape",
- "Tab"
- ];
- if (event.altKey || event.ctrlKey || event.metaKey) {
- return;
- }
- const isShiftTabEvent = event.shiftKey && event.key === "Tab";
- if (supportedKeys.includes(event.key) && (!event.shiftKey || isShiftTabEvent)) {
- if (event.key === "Enter") {
- this.emitChangeIfUserModified();
- }
- return;
- }
- const decimalSeparator = getDecimalSeparator(this.locale);
- if (event.key === decimalSeparator) {
- if (!this.value && !this.childNumberEl.value) {
- return;
- }
- if (this.value && this.childNumberEl.value.indexOf(decimalSeparator) === -1) {
- return;
- }
- }
- if (/[eE]/.test(event.key)) {
- if (!this.value && !this.childNumberEl.value) {
- return;
- }
- if (this.value && !/[eE]/.test(this.childNumberEl.value)) {
- return;
- }
- }
- if (event.key === "-") {
- if (!this.value && !this.childNumberEl.value) {
- return;
- }
- if (this.value && this.childNumberEl.value.split("-").length <= 2) {
- return;
- }
- }
- event.preventDefault();
- };
- this.nudgeNumberValue = (direction, nativeEvent) => {
- if ((nativeEvent instanceof KeyboardEvent && nativeEvent.repeat) || this.type !== "number") {
- return;
- }
- const inputMax = this.maxString ? parseFloat(this.maxString) : null;
- const inputMin = this.minString ? parseFloat(this.minString) : null;
- const valueNudgeDelayInMs = 100;
- this.incrementOrDecrementNumberValue(direction, inputMax, inputMin, nativeEvent);
- if (this.nudgeNumberValueIntervalId) {
- window.clearInterval(this.nudgeNumberValueIntervalId);
- }
- let firstValueNudge = true;
- this.nudgeNumberValueIntervalId = window.setInterval(() => {
- if (firstValueNudge) {
- firstValueNudge = false;
- return;
- }
- this.incrementOrDecrementNumberValue(direction, inputMax, inputMin, nativeEvent);
- }, valueNudgeDelayInMs);
- };
- this.numberButtonMouseUpAndMouseOutHandler = () => {
- window.clearInterval(this.nudgeNumberValueIntervalId);
- };
- this.numberButtonMouseDownHandler = (event) => {
- event.preventDefault();
- const direction = event.target.dataset.adjustment;
- this.nudgeNumberValue(direction, event);
- };
- this.setChildElRef = (el) => {
- this.childEl = el;
- };
- this.setChildNumberElRef = (el) => {
- this.childNumberEl = el;
- };
- this.setInputValue = (newInputValue) => {
- if (this.type === "text" && !this.childEl) {
- return;
- }
- if (this.type === "number" && !this.childNumberEl) {
- return;
- }
- this[`child${this.type === "number" ? "Number" : ""}El`].value = newInputValue;
- };
- this.setPreviousEmittedValue = (newPreviousEmittedValue) => {
- this.previousEmittedValue =
- this.type === "number"
- ? isValidNumber(newPreviousEmittedValue)
- ? newPreviousEmittedValue
- : ""
- : newPreviousEmittedValue;
- };
- this.setPreviousValue = (newPreviousValue) => {
- this.previousValue =
- this.type === "number"
- ? isValidNumber(newPreviousValue)
- ? newPreviousValue
- : ""
- : newPreviousValue;
- };
- this.setValue = ({ committing = false, nativeEvent, origin, previousValue, value }) => {
- const previousLocalizedValue = this.type === "number"
- ? localizeNumberString(this.previousValue, this.locale, this.groupSeparator)
- : "";
- const sanitizedValue = this.type === "number" ? sanitizeNumberString(value) : value;
- const newValue = this.type === "number" && value && !sanitizedValue
- ? isValidNumber(this.previousValue)
- ? this.previousValue
- : ""
- : sanitizedValue;
- const newLocalizedValue = this.type === "number"
- ? localizeNumberString(newValue, this.locale, this.groupSeparator)
- : "";
- this.setPreviousValue(previousValue || this.value);
- this.previousValueOrigin = origin;
- this.userChangedValue = origin === "user" && this.value !== newValue;
- this.value = newValue;
- if (this.type === "number") {
- this.localizedValue = newLocalizedValue;
- }
- if (origin === "direct") {
- this.setInputValue(this.type === "number" ? newLocalizedValue : newValue);
- }
- if (nativeEvent) {
- const calciteInputInputEvent = this.calciteInputInput.emit({
- element: this.childEl,
- nativeEvent,
- value: this.value
- });
- if (calciteInputInputEvent.defaultPrevented) {
- this.value = this.previousValue;
- this.localizedValue = previousLocalizedValue;
- }
- else if (committing) {
- this.emitChangeIfUserModified();
- }
- }
- };
- this.inputKeyUpHandler = () => {
- window.clearInterval(this.nudgeNumberValueIntervalId);
- };
- }
- disabledWatcher() {
- this.setDisabledAction();
- }
- /** watcher to update number-to-string for max */
- maxWatcher() {
- var _a;
- this.maxString = ((_a = this.max) === null || _a === void 0 ? void 0 : _a.toString()) || null;
- }
- /** watcher to update number-to-string for min */
- minWatcher() {
- var _a;
- this.minString = ((_a = this.min) === null || _a === void 0 ? void 0 : _a.toString()) || null;
- }
- valueWatcher(newValue, previousValue) {
- if (!this.userChangedValue) {
- this.setValue({
- origin: "direct",
- previousValue,
- value: newValue == null || newValue == ""
- ? ""
- : this.type === "number"
- ? isValidNumber(newValue)
- ? newValue
- : this.previousValue || ""
- : newValue
- });
- this.warnAboutInvalidNumberValue(newValue);
- }
- this.userChangedValue = false;
- }
- updateRequestedIcon() {
- this.requestedIcon = setRequestedIcon(INPUT_TYPE_ICONS, this.icon, this.type);
- }
- get isClearable() {
- return !this.isTextarea && (this.clearable || this.type === "search") && this.value.length > 0;
- }
- get isTextarea() {
- return this.childElType === "textarea";
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- var _a;
- this.scale = getElementProp(this.el, "scale", this.scale);
- this.status = getElementProp(this.el, "status", this.status);
- this.inlineEditableEl = this.el.closest("calcite-inline-editable");
- if (this.inlineEditableEl) {
- this.editingEnabled = this.inlineEditableEl.editingEnabled || false;
- }
- this.setPreviousEmittedValue(this.value);
- this.setPreviousValue(this.value);
- if (this.type === "number") {
- this.warnAboutInvalidNumberValue(this.value);
- this.setValue({
- origin: "connected",
- value: isValidNumber(this.value) ? this.value : ""
- });
- }
- connectLabel(this);
- connectForm(this);
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true });
- this.setDisabledAction();
- }
- disconnectedCallback() {
- var _a;
- disconnectLabel(this);
- disconnectForm(this);
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- }
- componentWillLoad() {
- var _a, _b;
- this.childElType = this.type === "textarea" ? "textarea" : "input";
- this.maxString = (_a = this.max) === null || _a === void 0 ? void 0 : _a.toString();
- this.minString = (_b = this.min) === null || _b === void 0 ? void 0 : _b.toString();
- this.requestedIcon = setRequestedIcon(INPUT_TYPE_ICONS, this.icon, this.type);
- }
- componentShouldUpdate(newValue, oldValue, property) {
- if (this.type === "number" && property === "value" && newValue && !isValidNumber(newValue)) {
- this.setValue({
- origin: "reset",
- value: oldValue
- });
- return false;
- }
- return true;
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- var _a, _b;
- if (this.type === "number") {
- (_a = this.childNumberEl) === null || _a === void 0 ? void 0 : _a.focus();
- }
- else {
- (_b = this.childEl) === null || _b === void 0 ? void 0 : _b.focus();
- }
- }
- onLabelClick() {
- this.setFocus();
- }
- incrementOrDecrementNumberValue(direction, inputMax, inputMin, nativeEvent) {
- const { value } = this;
- const inputStep = this.step === "any" ? 1 : Math.abs(this.step || 1);
- const inputVal = value && value !== "" ? parseFloat(value) : 0;
- const adjustment = direction === "up" ? 1 : -1;
- const nudgedValue = inputVal + inputStep * adjustment;
- const finalValue = (typeof inputMin === "number" && !isNaN(inputMin) && nudgedValue < inputMin) ||
- (typeof inputMax === "number" && !isNaN(inputMax) && nudgedValue > inputMax)
- ? inputVal
- : nudgedValue;
- const inputValPlaces = decimalPlaces(inputVal);
- const inputStepPlaces = decimalPlaces(inputStep);
- this.setValue({
- committing: true,
- nativeEvent,
- origin: "user",
- value: finalValue.toFixed(Math.max(inputValPlaces, inputStepPlaces))
- });
- }
- onFormReset() {
- this.setValue({
- origin: "reset",
- value: this.defaultValue
- });
- }
- syncHiddenFormInput(input) {
- var _a, _b, _c, _d;
- if (this.type === "number") {
- input.type = "number";
- input.min = (_b = (_a = this.min) === null || _a === void 0 ? void 0 : _a.toString(10)) !== null && _b !== void 0 ? _b : "";
- input.max = (_d = (_c = this.max) === null || _c === void 0 ? void 0 : _c.toString(10)) !== null && _d !== void 0 ? _d : "";
- }
- else if (this.type === "text") {
- input.type = "text";
- if (this.minLength != null) {
- input.minLength = this.minLength;
- }
- if (this.maxLength != null) {
- input.maxLength = this.maxLength;
- }
- }
- else if (this.type === "password") {
- input.type = "password";
- }
- }
- setDisabledAction() {
- const slottedActionEl = getSlotted(this.el, "action");
- if (!slottedActionEl) {
- return;
- }
- this.disabled
- ? slottedActionEl.setAttribute("disabled", "")
- : slottedActionEl.removeAttribute("disabled");
- }
- warnAboutInvalidNumberValue(value) {
- if (this.type === "number" && value && !isValidNumber(value)) {
- console.warn(`The specified value "${value}" cannot be parsed, or is out of range.`);
- }
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- render() {
- const dir = getElementDir(this.el);
- const loader = (h("div", { class: CSS$s.loader }, h("calcite-progress", { label: this.intlLoading, type: "indeterminate" })));
- const inputClearButton = (h("button", { "aria-label": this.intlClear || TEXT$c.clear, class: CSS$s.clearButton, disabled: this.disabled || this.readOnly, onClick: this.clearInputValue, tabIndex: this.disabled ? -1 : 0, type: "button" }, h("calcite-icon", { icon: "x", scale: "s" })));
- const iconEl = (h("calcite-icon", { class: CSS$s.inputIcon, flipRtl: this.iconFlipRtl, icon: this.requestedIcon, scale: "s" }));
- const isHorizontalNumberButton = this.numberButtonType === "horizontal";
- const numberButtonsHorizontalUp = (h("button", { class: {
- [CSS$s.numberButtonItem]: true,
- [CSS$s.buttonItemHorizontal]: isHorizontalNumberButton
- }, "data-adjustment": "up", disabled: this.disabled || this.readOnly, onMouseDown: this.numberButtonMouseDownHandler, onMouseOut: this.numberButtonMouseUpAndMouseOutHandler, onMouseUp: this.numberButtonMouseUpAndMouseOutHandler, tabIndex: -1, type: "button" }, h("calcite-icon", { icon: "chevron-up", scale: "s" })));
- const numberButtonsHorizontalDown = (h("button", { class: {
- [CSS$s.numberButtonItem]: true,
- [CSS$s.buttonItemHorizontal]: isHorizontalNumberButton
- }, "data-adjustment": "down", disabled: this.disabled || this.readOnly, onMouseDown: this.numberButtonMouseDownHandler, onMouseOut: this.numberButtonMouseUpAndMouseOutHandler, onMouseUp: this.numberButtonMouseUpAndMouseOutHandler, tabIndex: -1, type: "button" }, h("calcite-icon", { icon: "chevron-down", scale: "s" })));
- const numberButtonsVertical = (h("div", { class: CSS$s.numberButtonWrapper }, numberButtonsHorizontalUp, numberButtonsHorizontalDown));
- const prefixText = h("div", { class: CSS$s.prefix }, this.prefixText);
- const suffixText = h("div", { class: CSS$s.suffix }, this.suffixText);
- const localeNumberInput = this.type === "number" ? (h("input", { "aria-label": getLabelText(this), autofocus: this.autofocus ? true : null, defaultValue: this.defaultValue, disabled: this.disabled ? true : null, enterKeyHint: this.el.enterKeyHint, inputMode: this.el.inputMode, key: "localized-input", maxLength: this.maxLength, minLength: this.minLength, name: undefined, onBlur: this.inputBlurHandler, onFocus: this.inputFocusHandler, onInput: this.inputNumberInputHandler, onKeyDown: this.inputNumberKeyDownHandler, onKeyUp: this.inputKeyUpHandler, placeholder: this.placeholder || "", readOnly: this.readOnly, ref: this.setChildNumberElRef, type: "text", value: this.localizedValue })) : null;
- const childEl = this.type !== "number"
- ? [
- h(this.childElType, { "aria-label": getLabelText(this), autofocus: this.autofocus ? true : null, class: {
- [CSS$s.editingEnabled]: this.editingEnabled,
- [CSS$s.inlineChild]: !!this.inlineEditableEl
- }, defaultValue: this.defaultValue, disabled: this.disabled ? true : null, enterKeyHint: this.el.enterKeyHint, inputMode: this.el.inputMode, max: this.maxString, maxLength: this.maxLength, min: this.minString, minLength: this.minLength, name: this.name, onBlur: this.inputBlurHandler, onFocus: this.inputFocusHandler, onInput: this.inputInputHandler, onKeyDown: this.inputKeyDownHandler, onKeyUp: this.inputKeyUpHandler, placeholder: this.placeholder || "", readOnly: this.readOnly, ref: this.setChildElRef, required: this.required ? true : null, step: this.step, tabIndex: this.disabled || (this.inlineEditableEl && !this.editingEnabled) ? -1 : null, type: this.type, value: this.value }),
- this.isTextarea ? (h("div", { class: CSS$s.resizeIconWrapper }, h("calcite-icon", { icon: "chevron-down", scale: "s" }))) : null
- ]
- : null;
- return (h(Host, { onClick: this.inputFocusHandler, onKeyDown: this.keyDownHandler }, h("div", { class: { [CSS$s.inputWrapper]: true, [CSS_UTILITY.rtl]: dir === "rtl" } }, this.type === "number" && this.numberButtonType === "horizontal" && !this.readOnly
- ? numberButtonsHorizontalDown
- : null, this.prefixText ? prefixText : null, h("div", { class: CSS$s.wrapper }, localeNumberInput, childEl, this.isClearable ? inputClearButton : null, this.requestedIcon ? iconEl : null, this.loading ? loader : null), h("div", { class: CSS$s.actionWrapper }, h("slot", { name: SLOTS$g.action })), this.type === "number" && this.numberButtonType === "vertical" && !this.readOnly
- ? numberButtonsVertical
- : null, this.suffixText ? suffixText : null, this.type === "number" && this.numberButtonType === "horizontal" && !this.readOnly
- ? numberButtonsHorizontalUp
- : null, h(HiddenFormInputSlot, { component: this }))));
- }
- get el() { return this; }
- static get watchers() { return {
- "disabled": ["disabledWatcher"],
- "max": ["maxWatcher"],
- "min": ["minWatcher"],
- "value": ["valueWatcher"],
- "icon": ["updateRequestedIcon"],
- "type": ["updateRequestedIcon"]
- }; }
- static get style() { return inputCss; }
- };
- const inputDatePickerCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:host{--calcite-icon-size:1rem;--calcite-spacing-eighth:0.125rem;--calcite-spacing-quarter:0.25rem;--calcite-spacing-half:0.5rem;--calcite-spacing-three-quarters:0.75rem;--calcite-spacing:1rem;--calcite-spacing-plus-quarter:1.25rem;--calcite-spacing-plus-half:1.5rem;--calcite-spacing-double:2rem;--calcite-menu-min-width:10rem;--calcite-header-min-height:3rem;--calcite-footer-min-height:3rem}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;display:inline-block;width:100%;overflow:visible;vertical-align:top;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.calendar-picker-wrapper{position:static;width:100%;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);-webkit-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0)}.input-wrapper{position:relative}:host([range]) .input-container{display:-ms-flexbox;display:flex}:host([range]) .input-wrapper{-ms-flex:1 1 auto;flex:1 1 auto}:host([range]) .horizontal-arrow-container{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-width:1px;border-left-width:0px;border-right-width:0px;border-style:solid;border-color:var(--calcite-ui-border-input);background-color:var(--calcite-ui-background);padding-top:0px;padding-bottom:0px;padding-left:0.25rem;padding-right:0.25rem}:host([range][layout=vertical]) .input-wrapper{width:100%}:host([range][layout=vertical]) .input-container{-ms-flex-direction:column;flex-direction:column;-ms-flex-align:start;align-items:flex-start}:host([range][layout=vertical]) .calendar-picker-wrapper--end{-webkit-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0)}:host([range][layout=vertical]) .vertical-arrow-container{top:1.5rem;position:absolute;left:0px;z-index:10;margin-left:1px;margin-right:1px;background-color:var(--calcite-ui-foreground-1);padding-left:0.625rem;padding-right:0.625rem}:host([scale=s][range]:not([layout=vertical])) .calendar-picker-wrapper{width:216px}:host([scale=m][range]:not([layout=vertical])) .calendar-picker-wrapper{width:286px}:host([scale=l][range]:not([layout=vertical])) .calendar-picker-wrapper{width:398px}.menu-container{display:block;position:absolute;z-index:900;-webkit-transform:scale(0);transform:scale(0);visibility:hidden;pointer-events:none}.menu-container .calcite-popper-anim{position:relative;z-index:1;-webkit-transition:var(--calcite-popper-transition);transition:var(--calcite-popper-transition);visibility:hidden;-webkit-transition-property:visibility, opacity, -webkit-transform;transition-property:visibility, opacity, -webkit-transform;transition-property:transform, visibility, opacity;transition-property:transform, visibility, opacity, -webkit-transform;opacity:0;-webkit-box-shadow:0 0 16px 0 rgba(0, 0, 0, 0.16);box-shadow:0 0 16px 0 rgba(0, 0, 0, 0.16);border-radius:0.25rem}.menu-container[data-popper-placement^=bottom] .calcite-popper-anim{-webkit-transform:translateY(-5px);transform:translateY(-5px)}.menu-container[data-popper-placement^=top] .calcite-popper-anim{-webkit-transform:translateY(5px);transform:translateY(5px)}.menu-container[data-popper-placement^=left] .calcite-popper-anim{-webkit-transform:translateX(5px);transform:translateX(5px)}.menu-container[data-popper-placement^=right] .calcite-popper-anim{-webkit-transform:translateX(-5px);transform:translateX(-5px)}.menu-container[data-popper-placement] .calcite-popper-anim--active{opacity:1;visibility:visible;-webkit-transform:translate(0);transform:translate(0)}:host([active]) .menu-container{pointer-events:initial;visibility:visible}.menu-container--active .menu-container .calcite-popper-anim{position:relative;z-index:1;-webkit-transition:var(--calcite-popper-transition);transition:var(--calcite-popper-transition);visibility:hidden;-webkit-transition-property:visibility, opacity, -webkit-transform;transition-property:visibility, opacity, -webkit-transform;transition-property:transform, visibility, opacity;transition-property:transform, visibility, opacity, -webkit-transform;opacity:0;-webkit-box-shadow:0 0 16px 0 rgba(0, 0, 0, 0.16);box-shadow:0 0 16px 0 rgba(0, 0, 0, 0.16);border-radius:0.25rem}.menu-container--active .menu-container[data-popper-placement^=bottom] .calcite-popper-anim{-webkit-transform:translateY(-5px);transform:translateY(-5px)}.menu-container--active .menu-container[data-popper-placement^=top] .calcite-popper-anim{-webkit-transform:translateY(5px);transform:translateY(5px)}.menu-container--active .menu-container[data-popper-placement^=left] .calcite-popper-anim{-webkit-transform:translateX(5px);transform:translateX(5px)}.menu-container--active .menu-container[data-popper-placement^=right] .calcite-popper-anim{-webkit-transform:translateX(-5px);transform:translateX(-5px)}.menu-container--active .menu-container[data-popper-placement] .calcite-popper-anim--active{opacity:1;visibility:visible;-webkit-transform:translate(0);transform:translate(0)}.input .calcite-input__wrapper{margin-top:0px}:host([range][layout=vertical][scale=m]) .vertical-arrow-container{top:1.5rem;padding-left:0.75rem}:host([range][layout=vertical][scale=m]) .vertical-arrow-container calcite-icon{height:0.75rem;width:0.75rem;min-width:0px}:host([range][layout=vertical][scale=l]) .vertical-arrow-container{top:2.25rem;padding-left:0.875rem;padding-right:0.875rem}:host([range][layout=vertical][active]) .vertical-arrow-container{display:none}::slotted(input[slot=hidden-form-input]){bottom:0 !important;left:0 !important;margin:0 !important;opacity:0 !important;outline:none !important;padding:0 !important;position:absolute !important;right:0 !important;top:0 !important;-webkit-transform:none !important;transform:none !important;-webkit-appearance:none !important;z-index:-1 !important}";
- const InputDatePicker = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteDatePickerChange = createEvent(this, "calciteDatePickerChange", 7);
- this.calciteDatePickerRangeChange = createEvent(this, "calciteDatePickerRangeChange", 7);
- this.calciteInputDatePickerChange = createEvent(this, "calciteInputDatePickerChange", 7);
- this.calciteInputDatePickerOpen = createEvent(this, "calciteInputDatePickerOpen", 7);
- this.calciteInputDatePickerClose = createEvent(this, "calciteInputDatePickerClose", 7);
- //--------------------------------------------------------------------------
- //
- // Public Properties
- //
- //--------------------------------------------------------------------------
- /**
- * When false, the component won't be interactive.
- */
- this.disabled = false;
- /** Expand or collapse when calendar does not have input */
- this.active = false;
- /** Localized string for "previous month" (used for aria label)
- * @default "Previous month"
- */
- this.intlPrevMonth = TEXT$f.prevMonth;
- /** Localized string for "next month" (used for aria label)
- * @default "Next month"
- */
- this.intlNextMonth = TEXT$f.nextMonth;
- /** Localized string for "year" (used for aria label)
- * @default "Year"
- */
- this.intlYear = TEXT$f.year;
- /** BCP 47 language tag for desired language and country format */
- this.locale = document.documentElement.lang || "en";
- /** specify the scale of the date picker */
- this.scale = "m";
- /**
- * Determines where the date-picker component will be positioned relative to the input.
- * @default "bottom-leading"
- */
- this.placement = defaultMenuPlacement;
- /** Range mode activation */
- this.range = false;
- /**
- * When true, makes the component required for form-submission.
- *
- * @internal
- */
- this.required = false;
- /** Describes the type of positioning to use for the overlaid content. If your element is in a fixed container, use the 'fixed' value. */
- this.overlayPositioning = "absolute";
- /** Disables the default behaviour on the third click of narrowing or extending the range and instead starts a new range. */
- this.proximitySelectionDisabled = false;
- /** Layout */
- this.layout = "horizontal";
- this.focusedInput = "start";
- this.activeTransitionProp = "opacity";
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- this.setFilteredPlacements = () => {
- const { el, flipPlacements } = this;
- this.filteredFlipPlacements = flipPlacements
- ? filterComputedPlacements(flipPlacements, el)
- : null;
- };
- this.transitionEnd = (event) => {
- if (event.propertyName === this.activeTransitionProp) {
- this.active
- ? this.calciteInputDatePickerOpen.emit()
- : this.calciteInputDatePickerClose.emit();
- }
- };
- this.setStartInput = (el) => {
- this.startInput = el;
- };
- this.setEndInput = (el) => {
- this.endInput = el;
- };
- this.deactivate = () => {
- this.active = false;
- };
- this.keyDownHandler = (event) => {
- if (event.key === "Enter" && !event.defaultPrevented) {
- submitForm(this);
- }
- };
- this.keyUpHandler = (e) => {
- if (e.key === "Escape") {
- this.active = false;
- }
- };
- this.inputBlur = (e) => {
- this.blur(e.detail);
- };
- this.startInputFocus = () => {
- this.active = true;
- this.focusedInput = "start";
- };
- this.endInputFocus = () => {
- this.active = true;
- this.focusedInput = "end";
- };
- this.inputInput = (e) => {
- this.input(e.detail.value);
- };
- this.setMenuEl = (el) => {
- if (el) {
- this.menuEl = el;
- this.createPopper();
- }
- };
- this.setStartWrapper = (el) => {
- this.startWrapper = el;
- this.setReferenceEl();
- };
- this.setEndWrapper = (el) => {
- this.endWrapper = el;
- this.setReferenceEl();
- };
- /**
- * Event handler for when the selected date changes
- */
- this.handleDateChange = (event) => {
- if (this.range) {
- return;
- }
- this.value = dateToISO(event.detail);
- };
- this.handleDateRangeChange = (event) => {
- var _a, _b;
- if (!this.range || !event.detail) {
- return;
- }
- const { startDate, endDate } = event.detail;
- this.start = dateToISO(startDate);
- this.end = dateToISO(endDate);
- this.value = [this.start, this.end];
- if (this.shouldFocusRangeEnd()) {
- (_a = this.endInput) === null || _a === void 0 ? void 0 : _a.setFocus();
- }
- else if (this.shouldFocusRangeStart()) {
- (_b = this.startInput) === null || _b === void 0 ? void 0 : _b.setFocus();
- }
- };
- }
- handleDisabledChange(value) {
- if (!value) {
- this.active = false;
- }
- }
- valueHandler(value) {
- if (Array.isArray(value)) {
- this.valueAsDate = value.map((v) => dateFromISO(v));
- this.start = value[0];
- this.end = value[1];
- }
- else if (value) {
- this.valueAsDate = dateFromISO(value);
- this.start = "";
- this.end = "";
- }
- else {
- this.valueAsDate = undefined;
- this.start = undefined;
- this.end = undefined;
- }
- }
- flipPlacementsHandler() {
- this.setFilteredPlacements();
- }
- onMinChanged(min) {
- if (min) {
- this.minAsDate = dateFromISO(min);
- }
- }
- onMaxChanged(max) {
- if (max) {
- this.maxAsDate = dateFromISO(max);
- }
- }
- activeHandler() {
- if (!this.disabled) {
- this.reposition();
- return;
- }
- this.active = false;
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- handleDateOrRangeChange() {
- this.calciteInputDatePickerChange.emit();
- }
- calciteDaySelectHandler() {
- if (this.shouldFocusRangeStart() || this.shouldFocusRangeEnd()) {
- return;
- }
- this.active = false;
- }
- // --------------------------------------------------------------------------
- //
- // Public Methods
- //
- // --------------------------------------------------------------------------
- /** Updates the position of the component. */
- async setFocus() {
- var _a;
- (_a = this.startInput) === null || _a === void 0 ? void 0 : _a.setFocus();
- }
- /** Updates the position of the component. */
- async reposition() {
- const { placement, popper, menuEl } = this;
- const modifiers = this.getModifiers();
- popper
- ? await updatePopper({
- el: menuEl,
- modifiers,
- placement,
- popper
- })
- : this.createPopper();
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- if (Array.isArray(this.value)) {
- this.valueAsDate = this.value.map((v) => dateFromISO(v));
- this.start = this.value[0];
- this.end = this.value[1];
- }
- else if (this.value) {
- this.valueAsDate = dateFromISO(this.value);
- this.start = "";
- this.end = "";
- }
- if (this.start) {
- this.startAsDate = dateFromISO(this.start);
- }
- if (this.end) {
- this.endAsDate = dateFromISO(this.end);
- }
- if (this.min) {
- this.minAsDate = dateFromISO(this.min);
- }
- if (this.max) {
- this.maxAsDate = dateFromISO(this.max);
- }
- this.createPopper();
- connectLabel(this);
- connectForm(this);
- this.setFilteredPlacements();
- }
- async componentWillLoad() {
- await this.loadLocaleData();
- this.onMinChanged(this.min);
- this.onMaxChanged(this.max);
- }
- disconnectedCallback() {
- this.destroyPopper();
- disconnectLabel(this);
- disconnectForm(this);
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- render() {
- var _a, _b;
- const { disabled } = this;
- const date = dateFromRange(this.range ? this.startAsDate : this.valueAsDate, this.minAsDate, this.maxAsDate);
- const endDate = this.range
- ? dateFromRange(this.endAsDate, this.minAsDate, this.maxAsDate)
- : null;
- const formattedEndDate = endDate ? endDate.toLocaleDateString(this.locale) : "";
- const formattedDate = date ? date.toLocaleDateString(this.locale) : "";
- return (h(Host, { onBlur: this.deactivate, onKeyDown: this.keyDownHandler, onKeyUp: this.keyUpHandler, role: "application" }, this.localeData && (h("div", { "aria-expanded": toAriaBoolean(this.active), class: "input-container", role: "application" }, h("div", { class: "input-wrapper", ref: this.setStartWrapper }, h("calcite-input", { class: `input ${this.layout === "vertical" && this.range ? `no-bottom-border` : ``}`, disabled: disabled, icon: "calendar", label: getLabelText(this), "number-button-type": "none", onCalciteInputBlur: this.inputBlur, onCalciteInputFocus: this.startInputFocus, onCalciteInputInput: this.inputInput, placeholder: (_a = this.localeData) === null || _a === void 0 ? void 0 : _a.placeholder, ref: this.setStartInput, scale: this.scale, type: "text", value: formattedDate })), h("div", { "aria-hidden": toAriaBoolean(!this.active), class: {
- "menu-container": true,
- "menu-container--active": this.active
- }, ref: this.setMenuEl }, h("div", { class: {
- ["calendar-picker-wrapper"]: true,
- ["calendar-picker-wrapper--end"]: this.focusedInput === "end",
- [CSS$D.animation]: true,
- [CSS$D.animationActive]: this.active
- }, onTransitionEnd: this.transitionEnd }, h("calcite-date-picker", { activeRange: this.focusedInput, endAsDate: this.endAsDate, headingLevel: this.headingLevel, intlNextMonth: this.intlNextMonth, intlPrevMonth: this.intlPrevMonth, intlYear: this.intlYear, locale: this.locale, max: this.max, maxAsDate: this.maxAsDate, min: this.min, minAsDate: this.minAsDate, onCalciteDatePickerChange: this.handleDateChange, onCalciteDatePickerRangeChange: this.handleDateRangeChange, proximitySelectionDisabled: this.proximitySelectionDisabled, range: this.range, scale: this.scale, startAsDate: this.startAsDate, tabIndex: 0, valueAsDate: this.valueAsDate }))), this.range && this.layout === "horizontal" && (h("div", { class: "horizontal-arrow-container" }, h("calcite-icon", { flipRtl: true, icon: "arrow-right", scale: "s" }))), this.range && this.layout === "vertical" && this.scale !== "s" && (h("div", { class: "vertical-arrow-container" }, h("calcite-icon", { icon: "arrow-down", scale: "s" }))), this.range && (h("div", { class: "input-wrapper", ref: this.setEndWrapper }, h("calcite-input", { class: {
- input: true,
- "border-top-color-one": this.layout === "vertical" && this.range
- }, disabled: disabled, icon: "calendar", "number-button-type": "none", onCalciteInputBlur: this.inputBlur, onCalciteInputFocus: this.endInputFocus, onCalciteInputInput: this.inputInput, placeholder: (_b = this.localeData) === null || _b === void 0 ? void 0 : _b.placeholder, ref: this.setEndInput, scale: this.scale, type: "text", value: formattedEndDate }))))), h(HiddenFormInputSlot, { component: this })));
- }
- setReferenceEl() {
- const { focusedInput, layout, endWrapper, startWrapper } = this;
- this.referenceEl =
- focusedInput === "end" || layout === "vertical"
- ? endWrapper || startWrapper
- : startWrapper || endWrapper;
- this.createPopper();
- }
- onLabelClick() {
- this.setFocus();
- }
- getModifiers() {
- const flipModifier = {
- name: "flip",
- enabled: true
- };
- flipModifier.options = {
- fallbackPlacements: this.filteredFlipPlacements || popperMenuComputedPlacements
- };
- const eventListenerModifier = {
- name: "eventListeners",
- enabled: this.active
- };
- return [flipModifier, eventListenerModifier];
- }
- createPopper() {
- this.destroyPopper();
- const { menuEl, placement, referenceEl, overlayPositioning } = this;
- if (!menuEl || !referenceEl) {
- return;
- }
- const modifiers = this.getModifiers();
- this.popper = createPopper({
- el: menuEl,
- modifiers,
- overlayPositioning,
- placement,
- referenceEl
- });
- }
- destroyPopper() {
- const { popper } = this;
- if (popper) {
- popper.destroy();
- }
- this.popper = null;
- }
- startWatcher(start) {
- this.startAsDate = dateFromISO(start);
- }
- endWatcher(end) {
- this.endAsDate = dateFromISO(end);
- }
- async loadLocaleData() {
- if (!Build.isBrowser) {
- return;
- }
- const { locale } = this;
- this.localeData = await getLocaleData(locale);
- }
- clearCurrentValue() {
- if (!this.range) {
- if (typeof this.value === "string" && this.value) {
- this.calciteDatePickerChange.emit();
- }
- this.value = "";
- return;
- }
- const { focusedInput } = this;
- if (focusedInput === "start") {
- if (this.start) {
- this.calciteDatePickerRangeChange.emit();
- }
- this.value = Array.isArray(this.value) ? ["", this.value[1] || ""] : [""];
- this.start = undefined;
- }
- else if (focusedInput === "end") {
- if (this.end) {
- this.calciteDatePickerRangeChange.emit();
- }
- this.value = Array.isArray(this.value) ? [this.value[0] || "", ""] : ["", ""];
- this.end = undefined;
- }
- }
- /**
- * If inputted string is a valid date, update value/active
- */
- input(value) {
- const date = this.getDateFromInput(value);
- if (!date) {
- this.clearCurrentValue();
- return;
- }
- if (!this.range) {
- this.value = dateToISO(date);
- this.calciteDatePickerChange.emit(date);
- return;
- }
- const { focusedInput } = this;
- if (focusedInput === "start") {
- if (!this.startAsDate || !sameDate(date, this.startAsDate)) {
- const startDateISO = dateToISO(date);
- this.value = Array.isArray(this.value)
- ? [startDateISO, this.value[1] || ""]
- : [startDateISO];
- this.start = startDateISO;
- this.calciteDatePickerRangeChange.emit({
- startDate: date,
- endDate: this.endAsDate
- });
- }
- }
- else if (focusedInput === "end") {
- if (!this.endAsDate || !sameDate(date, this.endAsDate)) {
- const endDateISO = dateToISO(date);
- this.value = Array.isArray(this.value)
- ? [this.value[0] || "", endDateISO]
- : ["", endDateISO];
- this.end = endDateISO;
- this.calciteDatePickerRangeChange.emit({
- startDate: this.startAsDate,
- endDate: date
- });
- }
- }
- }
- /**
- * Clean up invalid date from input on blur
- */
- blur(target) {
- const { locale, focusedInput, endAsDate, range, startAsDate, valueAsDate } = this;
- const date = this.getDateFromInput(target.value);
- if (!date) {
- if (!range && valueAsDate) {
- target.value = Array.isArray(valueAsDate)
- ? valueAsDate[focusedInput === "end" ? 1 : 0].toLocaleDateString(locale)
- : valueAsDate.toLocaleDateString(locale);
- }
- else if (focusedInput === "start" && startAsDate) {
- target.value = startAsDate.toLocaleDateString(locale);
- }
- else if (focusedInput === "end" && endAsDate) {
- target.value = endAsDate.toLocaleDateString(locale);
- }
- }
- }
- shouldFocusRangeStart() {
- return !!(this.endAsDate &&
- !this.startAsDate &&
- this.focusedInput === "end" &&
- this.startInput);
- }
- shouldFocusRangeEnd() {
- return !!(this.startAsDate &&
- !this.endAsDate &&
- this.focusedInput === "start" &&
- this.endInput);
- }
- /**
- * Find a date from input string
- * return false if date is invalid, or out of range
- */
- getDateFromInput(value) {
- if (!this.localeData) {
- return false;
- }
- const { separator } = this.localeData;
- const { day, month, year } = parseDateString(value, this.localeData);
- const validDay = day > 0;
- const validMonth = month > -1;
- const date = new Date(year, month, day);
- date.setFullYear(year);
- const validDate = !isNaN(date.getTime());
- const validLength = value.split(separator).filter((c) => c).length > 2;
- const validYear = year.toString().length > 0;
- if (validDay &&
- validMonth &&
- validDate &&
- validLength &&
- validYear &&
- inRange(date, this.min, this.max)) {
- return date;
- }
- return false;
- }
- get el() { return this; }
- static get watchers() { return {
- "disabled": ["handleDisabledChange"],
- "value": ["valueHandler"],
- "flipPlacements": ["flipPlacementsHandler"],
- "min": ["onMinChanged"],
- "max": ["onMaxChanged"],
- "active": ["activeHandler"],
- "layout": ["setReferenceEl"],
- "focusedInput": ["setReferenceEl"],
- "start": ["startWatcher"],
- "end": ["endWatcher"],
- "locale": ["loadLocaleData"]
- }; }
- static get style() { return inputDatePickerCss; }
- };
- var StatusIconDefaults;
- (function (StatusIconDefaults) {
- StatusIconDefaults["valid"] = "check-circle";
- StatusIconDefaults["invalid"] = "exclamation-mark-triangle";
- StatusIconDefaults["idle"] = "information";
- })(StatusIconDefaults || (StatusIconDefaults = {}));
- const inputMessageCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([active][scale=m]),:host([active][scale=l]){--calcite-input-message-spacing-value:0.25rem}:host{visibility:hidden;-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;height:0px;width:100%;-ms-flex-align:center;align-items:center;font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1);opacity:0;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s}:host([active]){visibility:visible;height:auto;opacity:1;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s}:host([active][scale=m]),:host([active][scale=l]){margin-top:var(--calcite-input-message-spacing-value)}.calcite-input-message-icon{pointer-events:none;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-negative:0;flex-shrink:0;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s;-webkit-margin-end:0.5rem;margin-inline-end:0.5rem}:host([status=invalid]) .calcite-input-message-icon{color:var(--calcite-ui-danger)}:host([status=warning]) .calcite-input-message-icon{color:var(--calcite-ui-warning)}:host([status=valid]) .calcite-input-message-icon{color:var(--calcite-ui-success)}:host([status=idle]) .calcite-input-message-icon{color:var(--calcite-ui-brand)}:host([status][active]){font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1)}:host([status][active][scale=s]){font-size:var(--calcite-font-size--3);line-height:0.75rem}:host([status][active][scale=m]){margin-top:0.25rem;font-size:var(--calcite-font-size--2);line-height:1rem}:host([status][active][scale=l]){margin-top:0.25rem;font-size:var(--calcite-font-size--1);line-height:1rem}";
- const InputMessage = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** Indicates whether the message is displayed. */
- this.active = false;
- /** specify the scale of the input, defaults to m */
- this.scale = "m";
- /** specify the status of the input field, determines message and icons */
- this.status = "idle";
- }
- handleIconEl() {
- this.requestedIcon = setRequestedIcon(StatusIconDefaults, this.icon, this.status);
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- this.status = getElementProp(this.el, "status", this.status);
- this.scale = getElementProp(this.el, "scale", this.scale);
- this.requestedIcon = setRequestedIcon(StatusIconDefaults, this.icon, this.status);
- }
- render() {
- const hidden = !this.active;
- return (h(Host, { "calcite-hydrated-hidden": hidden }, this.renderIcon(this.requestedIcon), h("slot", null)));
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- renderIcon(iconName) {
- if (iconName) {
- return h("calcite-icon", { class: "calcite-input-message-icon", icon: iconName, scale: "s" });
- }
- }
- get el() { return this; }
- static get watchers() { return {
- "status": ["handleIconEl"],
- "icon": ["handleIconEl"]
- }; }
- static get style() { return inputMessageCss; }
- };
- const maxTenthForMinuteAndSecond = 5;
- function createLocaleDateTimeFormatter(locale, includeSeconds = true) {
- try {
- const options = {
- hour: "2-digit",
- minute: "2-digit",
- timeZone: "UTC"
- };
- if (includeSeconds) {
- options.second = "2-digit";
- }
- return new Intl.DateTimeFormat(locale, options);
- }
- catch (e) {
- throw new Error(`Invalid locale supplied while attempting to create a DateTime formatter: ${locale}`);
- }
- }
- function formatTimePart(number) {
- const numberAsString = number.toString();
- return number >= 0 && number <= 9 ? numberAsString.padStart(2, "0") : numberAsString;
- }
- function formatTimeString(value) {
- if (!isValidTime(value)) {
- return null;
- }
- const [hourString, minuteString, secondString] = value.split(":");
- const hour = formatTimePart(parseInt(hourString));
- const minute = formatTimePart(parseInt(minuteString));
- if (secondString) {
- const second = formatTimePart(parseInt(secondString));
- return `${hour}:${minute}:${second}`;
- }
- return `${hour}:${minute}`;
- }
- function getLocaleHourCycle(locale) {
- const formatter = createLocaleDateTimeFormatter(locale);
- const parts = formatter.formatToParts(new Date(Date.UTC(0, 0, 0, 0, 0, 0)));
- return getLocalizedTimePart("meridiem", parts) ? "12" : "24";
- }
- function getLocalizedTimePart(part, parts) {
- var _a, _b, _c, _d;
- if (!part || !parts) {
- return null;
- }
- if (part === "hourSuffix") {
- const hourIndex = parts.indexOf(parts.find(({ type }) => type === "hour"));
- const minuteIndex = parts.indexOf(parts.find(({ type }) => type === "minute"));
- const hourSuffix = parts[hourIndex + 1];
- return hourSuffix && hourSuffix.type === "literal" && minuteIndex - hourIndex === 2
- ? ((_a = hourSuffix.value) === null || _a === void 0 ? void 0 : _a.trim()) || null
- : null;
- }
- if (part === "minuteSuffix") {
- const minuteIndex = parts.indexOf(parts.find(({ type }) => type === "minute"));
- const secondIndex = parts.indexOf(parts.find(({ type }) => type === "second"));
- const minuteSuffix = parts[minuteIndex + 1];
- return minuteSuffix && minuteSuffix.type === "literal" && secondIndex - minuteIndex === 2
- ? ((_b = minuteSuffix.value) === null || _b === void 0 ? void 0 : _b.trim()) || null
- : null;
- }
- if (part === "secondSuffix") {
- const secondIndex = parts.indexOf(parts.find(({ type }) => type === "second"));
- const secondSuffix = parts[secondIndex + 1];
- return secondSuffix && secondSuffix.type === "literal" ? ((_c = secondSuffix.value) === null || _c === void 0 ? void 0 : _c.trim()) || null : null;
- }
- return ((_d = parts.find(({ type }) => (part == "meridiem" ? type === "dayPeriod" : type === part))) === null || _d === void 0 ? void 0 : _d.value) || null;
- }
- function getMeridiem(hour) {
- if (!isValidNumber(hour)) {
- return null;
- }
- const hourAsNumber = parseInt(hour);
- return hourAsNumber >= 0 && hourAsNumber <= 11 ? "AM" : "PM";
- }
- function isValidTime(value) {
- if (!value || value.startsWith(":") || value.endsWith(":")) {
- return false;
- }
- const splitValue = value.split(":");
- const validLength = splitValue.length > 1 && splitValue.length < 4;
- if (!validLength) {
- return false;
- }
- const [hour, minute, second] = splitValue;
- const hourAsNumber = parseInt(splitValue[0]);
- const minuteAsNumber = parseInt(splitValue[1]);
- const secondAsNumber = parseInt(splitValue[2]);
- const hourValid = isValidNumber(hour) && hourAsNumber >= 0 && hourAsNumber < 24;
- const minuteValid = isValidNumber(minute) && minuteAsNumber >= 0 && minuteAsNumber < 60;
- const secondValid = isValidNumber(second) && secondAsNumber >= 0 && secondAsNumber < 60;
- if ((hourValid && minuteValid && !second) || (hourValid && minuteValid && secondValid)) {
- return true;
- }
- }
- function isValidTimePart(value, part) {
- if (part === "meridiem") {
- return value === "AM" || value === "PM";
- }
- if (!isValidNumber(value)) {
- return false;
- }
- const valueAsNumber = Number(value);
- return part === "hour" ? valueAsNumber >= 0 && valueAsNumber < 24 : valueAsNumber >= 0 && valueAsNumber < 60;
- }
- function localizeTimePart(value, part, locale) {
- if (!isValidTimePart(value, part)) {
- return;
- }
- const valueAsNumber = parseInt(value);
- const date = new Date(Date.UTC(0, 0, 0, part === "hour" ? valueAsNumber : part === "meridiem" ? (value === "AM" ? 0 : 12) : 0, part === "minute" ? valueAsNumber : 0, part === "second" ? valueAsNumber : 0));
- if (!date) {
- return;
- }
- const formatter = createLocaleDateTimeFormatter(locale);
- const parts = formatter.formatToParts(date);
- return getLocalizedTimePart(part, parts);
- }
- function localizeTimeString(value, locale = "en", includeSeconds = true) {
- if (!isValidTime(value)) {
- return null;
- }
- const { hour, minute, second = "0" } = parseTimeString(value);
- const dateFromTimeString = new Date(Date.UTC(0, 0, 0, parseInt(hour), parseInt(minute), parseInt(second)));
- const formatter = createLocaleDateTimeFormatter(locale, includeSeconds);
- return (formatter === null || formatter === void 0 ? void 0 : formatter.format(dateFromTimeString)) || null;
- }
- function localizeTimeStringToParts(value, locale = "en") {
- if (!isValidTime(value)) {
- return null;
- }
- const { hour, minute, second = "0" } = parseTimeString(value);
- const dateFromTimeString = new Date(Date.UTC(0, 0, 0, parseInt(hour), parseInt(minute), parseInt(second)));
- if (dateFromTimeString) {
- const formatter = createLocaleDateTimeFormatter(locale);
- const parts = formatter.formatToParts(dateFromTimeString);
- return {
- localizedHour: getLocalizedTimePart("hour", parts),
- localizedHourSuffix: getLocalizedTimePart("hourSuffix", parts),
- localizedMinute: getLocalizedTimePart("minute", parts),
- localizedMinuteSuffix: getLocalizedTimePart("minuteSuffix", parts),
- localizedSecond: getLocalizedTimePart("second", parts),
- localizedSecondSuffix: getLocalizedTimePart("secondSuffix", parts),
- localizedMeridiem: getLocalizedTimePart("meridiem", parts)
- };
- }
- return null;
- }
- function getTimeParts(value, locale = "en") {
- if (!isValidTime(value)) {
- return null;
- }
- const { hour, minute, second = "0" } = parseTimeString(value);
- const dateFromTimeString = new Date(Date.UTC(0, 0, 0, parseInt(hour), parseInt(minute), parseInt(second)));
- if (dateFromTimeString) {
- const formatter = createLocaleDateTimeFormatter(locale);
- const parts = formatter.formatToParts(dateFromTimeString);
- return parts;
- }
- return null;
- }
- function parseTimeString(value) {
- if (isValidTime(value)) {
- const [hour, minute, second] = value.split(":");
- return {
- hour,
- minute,
- second
- };
- }
- return {
- hour: null,
- minute: null,
- second: null
- };
- }
- const inputTimePickerCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:inline-block;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}::slotted(input[slot=hidden-form-input]){bottom:0 !important;left:0 !important;margin:0 !important;opacity:0 !important;outline:none !important;padding:0 !important;position:absolute !important;right:0 !important;top:0 !important;-webkit-transform:none !important;transform:none !important;-webkit-appearance:none !important;z-index:-1 !important}";
- const InputTimePicker = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteInputTimePickerChange = createEvent(this, "calciteInputTimePickerChange", 7);
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** The active state of the time input */
- this.active = false;
- /** The disabled state of the time input */
- this.disabled = false;
- /**
- * BCP 47 language tag for desired language and country format
- * @internal
- */
- this.locale = document.documentElement.lang || navigator.language || "en";
- /**
- * When true, makes the component required for form-submission.
- *
- * @internal
- */
- this.required = false;
- /** The scale (size) of the time input */
- this.scale = "m";
- /**
- * Determines where the popover will be positioned relative to the input.
- * @see [PopperPlacement](https://github.com/Esri/calcite-components/blob/master/src/utils/popper.ts#L25)
- */
- this.placement = "auto";
- /** number (seconds) that specifies the granularity that the value must adhere to */
- this.step = 60;
- /** The selected time in UTC (always 24-hour format) */
- this.value = null;
- /** whether the value of the input was changed as a result of user typing or not */
- this.internalValueChange = false;
- this.previousValidValue = null;
- this.referenceElementId = `input-time-picker-${guid()}`;
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- this.calciteInputBlurHandler = () => {
- this.active = false;
- const shouldIncludeSeconds = this.shouldIncludeSeconds();
- const localizedInputValue = localizeTimeString(this.calciteInputEl.value, this.locale, shouldIncludeSeconds);
- this.setInputValue(localizedInputValue || localizeTimeString(this.value, this.locale, shouldIncludeSeconds));
- };
- this.calciteInputFocusHandler = () => {
- this.active = true;
- };
- this.calciteInputInputHandler = (event) => {
- const target = event.target;
- this.setValue({ value: target.value });
- };
- this.timePickerChangeHandler = (event) => {
- event.stopPropagation();
- const target = event.target;
- const value = target.value;
- this.setValue({ value, origin: "time-picker" });
- };
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- this.keyDownHandler = (event) => {
- if (event.key === "Enter" && !event.defaultPrevented) {
- submitForm(this);
- }
- };
- this.setCalcitePopoverEl = (el) => {
- this.popoverEl = el;
- };
- this.setCalciteInputEl = (el) => {
- this.calciteInputEl = el;
- };
- this.setCalciteTimePickerEl = (el) => {
- this.calciteTimePickerEl = el;
- };
- this.setInputValue = (newInputValue) => {
- if (!this.calciteInputEl) {
- return;
- }
- this.calciteInputEl.value = newInputValue;
- };
- this.setValue = ({ value, origin = "input" }) => {
- const previousValue = this.value;
- const newValue = formatTimeString(value);
- const newLocalizedValue = localizeTimeString(newValue, this.locale, this.shouldIncludeSeconds());
- this.internalValueChange = origin !== "external" && origin !== "loading";
- const shouldEmit = origin !== "loading" &&
- origin !== "external" &&
- ((value !== this.previousValidValue && !value) ||
- !!(!this.previousValidValue && newValue) ||
- (newValue !== this.previousValidValue && newValue));
- if (value) {
- if (shouldEmit) {
- this.previousValidValue = newValue;
- }
- if (newValue && newValue !== this.value) {
- this.value = newValue;
- }
- this.localizedValue = newLocalizedValue;
- }
- else {
- this.value = value;
- this.localizedValue = null;
- }
- if (origin === "time-picker" || origin === "external") {
- this.setInputValue(newLocalizedValue);
- }
- if (shouldEmit) {
- const changeEvent = this.calciteInputTimePickerChange.emit();
- if (changeEvent.defaultPrevented) {
- this.internalValueChange = false;
- this.value = previousValue;
- this.setInputValue(previousValue);
- this.previousValidValue = previousValue;
- }
- else {
- this.previousValidValue = newValue;
- }
- }
- };
- }
- activeHandler() {
- if (this.disabled) {
- this.active = false;
- return;
- }
- this.reposition();
- }
- handleDisabledChange(value) {
- if (!value) {
- this.active = false;
- }
- }
- localeWatcher(newLocale) {
- this.setInputValue(localizeTimeString(this.value, newLocale, this.shouldIncludeSeconds()));
- }
- valueWatcher(newValue) {
- if (!this.internalValueChange) {
- this.setValue({ value: newValue, origin: "external" });
- }
- this.internalValueChange = false;
- }
- clickHandler(event) {
- if (event.composedPath().includes(this.calciteTimePickerEl)) {
- return;
- }
- this.setFocus();
- }
- keyUpHandler(event) {
- if (event.key === "Escape" && this.active) {
- this.active = false;
- }
- }
- timePickerBlurHandler(event) {
- event.preventDefault();
- event.stopPropagation();
- this.active = false;
- }
- timePickerFocusHandler(event) {
- event.preventDefault();
- event.stopPropagation();
- this.active = true;
- }
- // --------------------------------------------------------------------------
- //
- // Public Methods
- //
- // --------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- this.calciteInputEl.setFocus();
- }
- /** Updates the position of the component. */
- async reposition() {
- var _a;
- (_a = this.popoverEl) === null || _a === void 0 ? void 0 : _a.reposition();
- }
- onLabelClick() {
- this.setFocus();
- }
- shouldIncludeSeconds() {
- return this.step < 60;
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- if (this.value) {
- this.setValue({ value: isValidTime(this.value) ? this.value : undefined, origin: "loading" });
- }
- connectLabel(this);
- connectForm(this);
- }
- componentDidLoad() {
- this.setInputValue(this.localizedValue);
- }
- disconnectedCallback() {
- disconnectLabel(this);
- disconnectForm(this);
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- render() {
- const popoverId = `${this.referenceElementId}-popover`;
- return (h(Host, { onKeyDown: this.keyDownHandler }, h("div", { "aria-controls": popoverId, "aria-haspopup": "dialog", "aria-label": this.name, "aria-owns": popoverId, id: this.referenceElementId, role: "combobox" }, h("calcite-input", { disabled: this.disabled, icon: "clock", label: getLabelText(this), onCalciteInputBlur: this.calciteInputBlurHandler, onCalciteInputFocus: this.calciteInputFocusHandler, onCalciteInputInput: this.calciteInputInputHandler, ref: this.setCalciteInputEl, scale: this.scale, step: this.step })), h("calcite-popover", { id: popoverId, label: "Time Picker", open: this.active, placement: this.placement, ref: this.setCalcitePopoverEl, referenceElement: this.referenceElementId }, h("calcite-time-picker", { intlHour: this.intlHour, intlHourDown: this.intlHourDown, intlHourUp: this.intlHourUp, intlMeridiem: this.intlMeridiem, intlMeridiemDown: this.intlMeridiemDown, intlMeridiemUp: this.intlMeridiemUp, intlMinute: this.intlMinute, intlMinuteDown: this.intlMinuteDown, intlMinuteUp: this.intlMinuteUp, intlSecond: this.intlSecond, intlSecondDown: this.intlSecondDown, intlSecondUp: this.intlSecondUp, lang: this.locale, onCalciteTimePickerChange: this.timePickerChangeHandler, ref: this.setCalciteTimePickerEl, scale: this.scale, step: this.step, value: this.value })), h(HiddenFormInputSlot, { component: this })));
- }
- get el() { return this; }
- static get watchers() { return {
- "active": ["activeHandler"],
- "disabled": ["handleDisabledChange"],
- "locale": ["localeWatcher"],
- "value": ["valueWatcher"]
- }; }
- static get style() { return inputTimePickerCss; }
- };
- const CSS$r = {
- container: "container"
- };
- const labelCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:inline}:host([alignment=start]){text-align:start}:host([alignment=end]){text-align:end}:host([alignment=center]){text-align:center}:host([scale=s]) .container{margin-bottom:0.5rem;font-size:var(--calcite-font-size--2);line-height:1rem}:host([scale=m]) .container{margin-bottom:0.75rem;font-size:var(--calcite-font-size--1);line-height:1rem}:host([scale=l]) .container{margin-bottom:1rem;font-size:var(--calcite-font-size-0);line-height:1.25rem}:host .container{margin-top:0px;margin-right:0px;margin-left:0px;width:100%;line-height:1.375;color:var(--calcite-ui-text-1)}:host([layout=default]) .container{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:0.25rem}:host([layout=inline]) .container,:host([layout=inline-space-between]) .container{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-align:center;align-items:center;gap:0.5rem}:host([layout=inline][scale=l]) .container{gap:0.75rem}:host([layout=inline-space-between]) .container{-ms-flex-pack:justify;justify-content:space-between}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled])>.container{pointer-events:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted(*){pointer-events:none}:host([disabled]) ::slotted(*[disabled]),:host([disabled]) ::slotted(*[disabled] *){--tw-bg-opacity:1}:host([disabled]) ::slotted(calcite-input-message:not([active])){--tw-bg-opacity:0}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host([disable-spacing]) .container{margin:0px;gap:0px}";
- const Label = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteInternalLabelClick = createEvent(this, "calciteInternalLabelClick", 3);
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** specify the text alignment of the label */
- this.alignment = "start";
- /**
- * specify the status of the label and any child input / input messages
- * @deprecated set directly on child element instead
- */
- this.status = "idle";
- /** specify the scale of the label, defaults to m */
- this.scale = "m";
- /** is the wrapped element positioned inline with the label slotted text */
- this.layout = "default";
- /** eliminates any space around the label */
- this.disableSpacing = false;
- /**
- * is the label disabled
- *
- * @deprecated use the `disabled` property on the interactive components instead
- */
- this.disabled = false;
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- this.labelClickHandler = (event) => {
- this.calciteInternalLabelClick.emit({
- sourceEvent: event
- });
- };
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- document.dispatchEvent(new CustomEvent(labelConnectedEvent));
- }
- disconnectedCallback() {
- document.dispatchEvent(new CustomEvent(labelDisconnectedEvent));
- }
- render() {
- return (h(Host, { onClick: this.labelClickHandler }, h("div", { class: CSS$r.container }, h("slot", null))));
- }
- get el() { return this; }
- static get style() { return labelCss; }
- };
- const linkCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:inline}:host a,:host span{position:relative;display:-ms-flexbox;display:flex;cursor:pointer;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;border-radius:0px;border-style:none;font-family:inherit;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s;text-decoration:none;line-height:inherit;font-size:inherit;-webkit-appearance:none}:host a:hover,:host span:hover{text-decoration:none}:host a,:host span{outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out}:host a:focus,:host span:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}calcite-icon{width:1em;height:1em;min-width:unset;min-height:unset}.calcite-link--icon{vertical-align:text-top;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s;margin-top:0.125rem}:host .calcite-link--icon.icon-start{-webkit-margin-end:0.5rem;margin-inline-end:0.5rem}:host .calcite-link--icon.icon-end{-webkit-margin-start:0.5rem;margin-inline-start:0.5rem}:host span,:host a{position:relative;display:inline;border-style:none;background-color:transparent;padding:0px;color:var(--calcite-ui-text-link);-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s;line-height:inherit;white-space:initial;background-image:-webkit-gradient(linear, left top, left bottom, from(currentColor), to(currentColor)), -webkit-gradient(linear, left top, left bottom, from(var(--calcite-link-blue-underline)), to(var(--calcite-link-blue-underline)));background-image:linear-gradient(currentColor, currentColor), linear-gradient(var(--calcite-link-blue-underline), var(--calcite-link-blue-underline));background-position:0% 100%, 100% 100%;background-repeat:no-repeat, no-repeat;background-size:0% 1px, 100% 1px}:host span:hover,:host span:focus,:host a:hover,:host a:focus{background-size:100% 1px, 100% 1px}:host span:active,:host a:active{background-size:100% 2px, 100% 2px}:host span.calcite--rtl,:host a.calcite--rtl{background-position:100% 100%, 100% 100%}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}";
- const Link = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** is the link disabled */
- this.disabled = false;
- /** Prompts the user to save the linked URL instead of navigating to it. Can be used with or without a value:
- * Without a value, the browser will suggest a filename/extension
- * See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download
- */
- this.download = false;
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- this.storeTagRef = (el) => {
- this.childEl = el;
- };
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentDidRender() {
- updateHostInteraction(this);
- }
- render() {
- const { download, el } = this;
- const dir = getElementDir(el);
- const childElType = this.href ? "a" : "span";
- const iconStartEl = (h("calcite-icon", { class: "calcite-link--icon icon-start", flipRtl: this.iconFlipRtl === "start" || this.iconFlipRtl === "both", icon: this.iconStart, scale: "s" }));
- const iconEndEl = (h("calcite-icon", { class: "calcite-link--icon icon-end", flipRtl: this.iconFlipRtl === "end" || this.iconFlipRtl === "both", icon: this.iconEnd, scale: "s" }));
- const Tag = childElType;
- const role = childElType === "span" ? "link" : null;
- const tabIndex = childElType === "span" ? 0 : null;
- return (h(Host, { role: "presentation" }, h(Tag, { class: { [CSS_UTILITY.rtl]: dir === "rtl" },
- /*
- When the 'download' property of type 'boolean | string' is set to true, the value is "".
- This works around that issue for now.
- */
- download: Tag === "a" && (download === "" || download) ? download : null, href: Tag === "a" && this.href, ref: this.storeTagRef, rel: Tag === "a" && this.rel, role: role, tabIndex: tabIndex, target: Tag === "a" && this.target }, this.iconStart ? iconStartEl : null, h("slot", null), this.iconEnd ? iconEndEl : null)));
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- focusElement(this.childEl);
- }
- get el() { return this; }
- static get style() { return linkCss; }
- };
- const CSS$q = {
- container: "container"
- };
- const listCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:block}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.container{-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;width:100%;-ms-flex-direction:column;flex-direction:column;background-color:transparent}.container *{-webkit-box-sizing:border-box;box-sizing:border-box}::slotted(calcite-list-item){margin-bottom:1px;--tw-shadow:0 1px 0 var(--calcite-ui-border-3);--tw-shadow-colored:0 1px 0 var(--tw-shadow-color);-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}::slotted(calcite-list-item:last-child){--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}";
- const List$1 = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * When true, disabled prevents user interaction.
- */
- this.disabled = false;
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentDidRender() {
- updateHostInteraction(this);
- }
- // --------------------------------------------------------------------------
- //
- // Public Methods
- //
- // --------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- const firstListItem = this.el.querySelector(`calcite-list-item:not([non-interactive])`);
- firstListItem === null || firstListItem === void 0 ? void 0 : firstListItem.setFocus();
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- render() {
- return (h(Host, { role: "list" }, h("div", { class: CSS$q.container }, h("slot", null))));
- }
- get el() { return this; }
- static get style() { return listCss; }
- };
- const CSS$p = {
- container: "container",
- contentContainer: "content-container",
- nestedContainer: "nested-container",
- contentContainerButton: "content-container--button",
- content: "content",
- actionsStart: "actions-start",
- contentStart: "content-start",
- label: "label",
- description: "description",
- contentEnd: "content-end",
- actionsEnd: "actions-end",
- hasCenterContent: "has-center-content"
- };
- const SLOTS$f = {
- actionsStart: "actions-start",
- contentStart: "content-start",
- contentEnd: "content-end",
- actionsEnd: "actions-end"
- };
- const listItemCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.container{-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;-ms-flex:1 1 0%;flex:1 1 0%;background-color:var(--calcite-ui-foreground-1);font-family:var(--calcite-sans-family)}.container *{-webkit-box-sizing:border-box;box-sizing:border-box}.nested-container{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;background-color:var(--calcite-ui-foreground-1)}.content-container{display:-ms-flexbox;display:flex;-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-align:stretch;align-items:stretch;padding:0px;font-family:var(--calcite-sans-family);font-weight:var(--calcite-font-weight-normal);color:var(--calcite-ui-text-2);outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out}.content-container--button{cursor:pointer;border-style:none;background-color:var(--calcite-ui-foreground-1);outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;text-align:initial}.content-container--button:hover{background-color:var(--calcite-ui-foreground-2)}.content-container--button:hover .label,.content-container--button:hover .description{color:var(--calcite-ui-text-1)}.content-container--button:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.content-container--button .content-start,.content-container--button .content-end{pointer-events:none}.content{display:-ms-flexbox;display:flex;-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:center;justify-content:center;padding-left:0.75rem;padding-right:0.75rem;padding-top:0.5rem;padding-bottom:0.5rem;font-size:var(--calcite-font-size--2);line-height:1.375}.label,.description{font-family:var(--calcite-sans-family);font-size:var(--calcite-font-size--2);font-weight:var(--calcite-font-weight-normal);word-wrap:break-word;word-break:break-word}.label:only-child,.description:only-child{margin:0px;padding-top:0.25rem;padding-bottom:0.25rem}.label{color:var(--calcite-ui-text-1)}.description{margin-top:0.125rem;color:var(--calcite-ui-text-3)}.content-start{-ms-flex-pack:start;justify-content:flex-start}.content-end{-ms-flex-pack:end;justify-content:flex-end}.content-start,.content-end{-ms-flex:1 1 auto;flex:1 1 auto}.has-center-content .content-start,.has-center-content .content-end{-ms-flex:0 1 auto;flex:0 1 auto}.actions-start,.actions-end,.content-start,.content-end{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.content-start ::slotted(calcite-icon),.content-end ::slotted(calcite-icon){-ms-flex-item-align:center;align-self:center;padding-left:0.75rem;padding-right:0.75rem}.actions-start ::slotted(calcite-action),.actions-end ::slotted(calcite-action){-ms-flex-item-align:stretch;align-self:stretch;color:inherit}::slotted(calcite-list-item-group),::slotted(calcite-list-item){padding-left:0.5rem}";
- const ListItem = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * When true, prevents the content of the list item from user interaction.
- */
- this.nonInteractive = false;
- /**
- * When true, disabled prevents interaction.
- */
- this.disabled = false;
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentDidRender() {
- updateHostInteraction(this);
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- connectConditionalSlotComponent(this);
- }
- disconnectedCallback() {
- disconnectConditionalSlotComponent(this);
- }
- // --------------------------------------------------------------------------
- //
- // Public Methods
- //
- // --------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- var _a;
- (_a = this.focusEl) === null || _a === void 0 ? void 0 : _a.focus();
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- renderActionsStart() {
- const { el } = this;
- return getSlotted(el, SLOTS$f.actionsStart) ? (h("div", { class: CSS$p.actionsStart }, h("slot", { name: SLOTS$f.actionsStart }))) : null;
- }
- renderActionsEnd() {
- const { el } = this;
- return getSlotted(el, SLOTS$f.actionsEnd) ? (h("div", { class: CSS$p.actionsEnd }, h("slot", { name: SLOTS$f.actionsEnd }))) : null;
- }
- renderContentStart() {
- const { el } = this;
- return getSlotted(el, SLOTS$f.contentStart) ? (h("div", { class: CSS$p.contentStart }, h("slot", { name: SLOTS$f.contentStart }))) : null;
- }
- renderContentEnd() {
- const { el } = this;
- return getSlotted(el, SLOTS$f.contentEnd) ? (h("div", { class: CSS$p.contentEnd }, h("slot", { name: SLOTS$f.contentEnd }))) : null;
- }
- renderContent() {
- const { label, description } = this;
- return !!label || !!description ? (h("div", { class: CSS$p.content }, label ? h("div", { class: CSS$p.label }, label) : null, description ? h("div", { class: CSS$p.description }, description) : null)) : null;
- }
- renderContentContainer() {
- const { description, disabled, label, nonInteractive } = this;
- const hasCenterContent = !!label || !!description;
- const content = [this.renderContentStart(), this.renderContent(), this.renderContentEnd()];
- return !nonInteractive ? (h("button", { class: {
- [CSS$p.contentContainer]: true,
- [CSS$p.contentContainerButton]: true,
- [CSS$p.hasCenterContent]: hasCenterContent
- }, disabled: disabled, ref: (focusEl) => (this.focusEl = focusEl) }, content)) : (h("div", { class: { [CSS$p.contentContainer]: true, [CSS$p.hasCenterContent]: hasCenterContent }, ref: () => (this.focusEl = null) }, content));
- }
- render() {
- return (h(Host, { role: "listitem" }, h("div", { class: CSS$p.container }, this.renderActionsStart(), this.renderContentContainer(), this.renderActionsEnd()), h("div", { class: CSS$p.nestedContainer }, h("slot", null))));
- }
- get el() { return this; }
- static get style() { return listItemCss; }
- };
- const CSS$o = {
- heading: "heading",
- container: "container"
- };
- const HEADING_LEVEL$5 = 3;
- const listItemGroupCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}.heading{margin:0px;display:-ms-flexbox;display:flex;-ms-flex:1 1 0%;flex:1 1 0%;background-color:var(--calcite-ui-foreground-2);padding:0.75rem;font-family:var(--calcite-sans-family);font-size:var(--calcite-font-size--1);font-weight:var(--calcite-font-weight-bold);color:var(--calcite-ui-text-2)}.container{display:-ms-flexbox;display:flex;width:100%;-ms-flex-direction:column;flex-direction:column;background-color:var(--calcite-ui-foreground-1)}::slotted(calcite-list-item-group){padding-left:0.5rem}";
- const ListItemGroup = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- render() {
- var _a;
- const { el, heading, headingLevel } = this;
- const parentLevel = (_a = el.closest("calcite-list, calcite-list-item-group")) === null || _a === void 0 ? void 0 : _a.headingLevel;
- const relativeLevel = parentLevel ? constrainHeadingLevel(parentLevel + 1) : null;
- const level = headingLevel || relativeLevel || HEADING_LEVEL$5;
- return (h(Host, null, heading ? (h(Heading, { class: CSS$o.heading, level: level }, heading)) : null, h("div", { class: CSS$o.container, role: "group" }, h("slot", null))));
- }
- get el() { return this; }
- static get style() { return listItemGroupCss; }
- };
- const loaderCss = "@charset \"UTF-8\";@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;margin-left:auto;margin-right:auto;display:none;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding-top:4rem;padding-bottom:4rem;opacity:1;min-height:var(--calcite-loader-size);font-size:var(--calcite-loader-font-size);stroke:var(--calcite-ui-brand);stroke-width:3;fill:none;-webkit-transform:scale(1, 1);transform:scale(1, 1);animation:loader-color-shift 6s alternate-reverse infinite linear}:host([scale=s]){--calcite-loader-font-size:var(--calcite-font-size--2);--calcite-loader-size:2rem;--calcite-loader-size-inline:0.75rem}:host([scale=m]){--calcite-loader-font-size:var(--calcite-font-size-0);--calcite-loader-size:4rem;--calcite-loader-size-inline:1rem}:host([scale=l]){--calcite-loader-font-size:var(--calcite-font-size-2);--calcite-loader-size:6rem;--calcite-loader-size-inline:1.5rem}:host([no-padding]){padding-top:0px;padding-bottom:0px}:host{display:none}:host([active]){display:-ms-flexbox;display:flex}.loader__text{display:block;text-align:center;font-size:var(--calcite-font-size--2);line-height:1rem;color:var(--calcite-ui-text-1);margin-top:calc(var(--calcite-loader-size) + 1.5rem)}.loader__percentage{position:absolute;display:block;text-align:center;color:var(--calcite-ui-text-1);font-size:var(--calcite-loader-font-size);width:var(--calcite-loader-size);left:50%;margin-left:calc(var(--calcite-loader-size) / 2 * -1);line-height:0.25;-webkit-transform:scale(1, 1);transform:scale(1, 1)}.loader__svgs{position:absolute;overflow:visible;opacity:1;width:var(--calcite-loader-size);height:var(--calcite-loader-size);left:50%;margin-left:calc(var(--calcite-loader-size) / 2 * -1);-webkit-transform:scale(1, 1);transform:scale(1, 1)}.loader__svg{position:absolute;top:0px;left:0px;-webkit-transform-origin:center;transform-origin:center;overflow:visible;width:var(--calcite-loader-size);height:var(--calcite-loader-size);-webkit-animation-iteration-count:infinite;animation-iteration-count:infinite;-webkit-animation-timing-function:linear;animation-timing-function:linear;-webkit-animation-name:loader-clockwise;animation-name:loader-clockwise}@supports (display: grid){.loader__svg--1{-webkit-animation-name:loader-offset-1;animation-name:loader-offset-1}.loader__svg--2{-webkit-animation-name:loader-offset-2;animation-name:loader-offset-2}.loader__svg--3{-webkit-animation-name:loader-offset-3;animation-name:loader-offset-3}}:host([type=determinate]){-webkit-animation:none;animation:none;stroke:var(--calcite-ui-border-3)}:host([type=determinate]) .loader__svg--3{-webkit-animation:none;animation:none;stroke:var(--calcite-ui-brand);stroke-dasharray:150.79632;-webkit-transform:rotate(-90deg);transform:rotate(-90deg);-webkit-transition:all var(--calcite-internal-animation-timing-fast) linear;transition:all var(--calcite-internal-animation-timing-fast) linear}:host([inline]){position:relative;margin:0px;-webkit-animation:none;animation:none;stroke:currentColor;stroke-width:2;padding-top:0px;padding-bottom:0px;height:var(--calcite-loader-size-inline);min-height:var(--calcite-loader-size-inline);width:var(--calcite-loader-size-inline);-webkit-margin-end:calc(var(--calcite-loader-size-inline) * 0.5);margin-inline-end:calc(var(--calcite-loader-size-inline) * 0.5);vertical-align:calc(var(--calcite-loader-size-inline) * -1 * 0.2)}:host([active][inline]){display:inline-block}:host([inline]) .loader__svgs{top:0px;left:0px;margin:0px;width:var(--calcite-loader-size-inline);height:var(--calcite-loader-size-inline)}:host([inline]) .loader__svg{width:var(--calcite-loader-size-inline);height:var(--calcite-loader-size-inline)}:host([complete]){opacity:0;-webkit-transform:scale(0.75, 0.75);transform:scale(0.75, 0.75);-webkit-transform-origin:center;transform-origin:center;-webkit-transition:opacity var(--calcite-internal-animation-timing-medium) linear 1000ms, -webkit-transform var(--calcite-internal-animation-timing-medium) linear 1000ms;transition:opacity var(--calcite-internal-animation-timing-medium) linear 1000ms, -webkit-transform var(--calcite-internal-animation-timing-medium) linear 1000ms;transition:opacity var(--calcite-internal-animation-timing-medium) linear 1000ms, transform var(--calcite-internal-animation-timing-medium) linear 1000ms;transition:opacity var(--calcite-internal-animation-timing-medium) linear 1000ms, transform var(--calcite-internal-animation-timing-medium) linear 1000ms, -webkit-transform var(--calcite-internal-animation-timing-medium) linear 1000ms}:host([complete]) .loader__svgs{opacity:0;-webkit-transform:scale(0.75, 0.75);transform:scale(0.75, 0.75);-webkit-transform-origin:center;transform-origin:center;-webkit-transition:opacity calc(180ms * var(--calcite-internal-duration-factor)) linear 800ms, -webkit-transform calc(180ms * var(--calcite-internal-duration-factor)) linear 800ms;transition:opacity calc(180ms * var(--calcite-internal-duration-factor)) linear 800ms, -webkit-transform calc(180ms * var(--calcite-internal-duration-factor)) linear 800ms;transition:opacity calc(180ms * var(--calcite-internal-duration-factor)) linear 800ms, transform calc(180ms * var(--calcite-internal-duration-factor)) linear 800ms;transition:opacity calc(180ms * var(--calcite-internal-duration-factor)) linear 800ms, transform calc(180ms * var(--calcite-internal-duration-factor)) linear 800ms, -webkit-transform calc(180ms * var(--calcite-internal-duration-factor)) linear 800ms}:host([complete]) .loader__percentage{color:var(--calcite-ui-brand);-webkit-transform:scale(1.05, 1.05);transform:scale(1.05, 1.05);-webkit-transform-origin:center;transform-origin:center;-webkit-transition:color var(--calcite-internal-animation-timing-medium) linear, -webkit-transform var(--calcite-internal-animation-timing-medium) linear;transition:color var(--calcite-internal-animation-timing-medium) linear, -webkit-transform var(--calcite-internal-animation-timing-medium) linear;transition:color var(--calcite-internal-animation-timing-medium) linear, transform var(--calcite-internal-animation-timing-medium) linear;transition:color var(--calcite-internal-animation-timing-medium) linear, transform var(--calcite-internal-animation-timing-medium) linear, -webkit-transform var(--calcite-internal-animation-timing-medium) linear}.loader__svg--1{stroke-dasharray:27.9252444444% 139.6262222222%;-webkit-animation-duration:0.72s;animation-duration:0.72s}@-webkit-keyframes loader-offset-1{0%{stroke-dasharray:27.9252444444% 251.3272%;stroke-dashoffset:0}50%{stroke-dasharray:139.6262222222% 139.6262222222%;stroke-dashoffset:-83.7757333333%}100%{stroke-dasharray:27.9252444444% 251.3272%;stroke-dashoffset:-279.2524444444%}}@keyframes loader-offset-1{0%{stroke-dasharray:27.9252444444% 251.3272%;stroke-dashoffset:0}50%{stroke-dasharray:139.6262222222% 139.6262222222%;stroke-dashoffset:-83.7757333333%}100%{stroke-dasharray:27.9252444444% 251.3272%;stroke-dashoffset:-279.2524444444%}}.loader__svg--2{stroke-dasharray:55.8504888889% 139.6262222222%;-webkit-animation-duration:0.96s;animation-duration:0.96s}@-webkit-keyframes loader-offset-2{0%{stroke-dasharray:55.8504888889% 223.4019555556%;stroke-dashoffset:0}50%{stroke-dasharray:139.6262222222% 139.6262222222%;stroke-dashoffset:-97.7383555556%}100%{stroke-dasharray:55.8504888889% 223.4019555556%;stroke-dashoffset:-279.2524444444%}}@keyframes loader-offset-2{0%{stroke-dasharray:55.8504888889% 223.4019555556%;stroke-dashoffset:0}50%{stroke-dasharray:139.6262222222% 139.6262222222%;stroke-dashoffset:-97.7383555556%}100%{stroke-dasharray:55.8504888889% 223.4019555556%;stroke-dashoffset:-279.2524444444%}}.loader__svg--3{stroke-dasharray:13.9626222222% 139.6262222222%;-webkit-animation-duration:1.16s;animation-duration:1.16s}@-webkit-keyframes loader-offset-3{0%{stroke-dasharray:13.9626222222% 265.2898222222%;stroke-dashoffset:0}50%{stroke-dasharray:139.6262222222% 139.6262222222%;stroke-dashoffset:-76.7944222222%}100%{stroke-dasharray:13.9626222222% 265.2898222222%;stroke-dashoffset:-279.2524444444%}}@keyframes loader-offset-3{0%{stroke-dasharray:13.9626222222% 265.2898222222%;stroke-dashoffset:0}50%{stroke-dasharray:139.6262222222% 139.6262222222%;stroke-dashoffset:-76.7944222222%}100%{stroke-dasharray:13.9626222222% 265.2898222222%;stroke-dashoffset:-279.2524444444%}}@-webkit-keyframes loader-color-shift{0%{stroke:var(--calcite-ui-brand)}33%{stroke:var(--calcite-ui-brand-press)}66%{stroke:var(--calcite-ui-brand-hover)}100%{stroke:var(--calcite-ui-brand)}}@keyframes loader-color-shift{0%{stroke:var(--calcite-ui-brand)}33%{stroke:var(--calcite-ui-brand-press)}66%{stroke:var(--calcite-ui-brand-hover)}100%{stroke:var(--calcite-ui-brand)}}@-webkit-keyframes loader-clockwise{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes loader-clockwise{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}";
- const Loader = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** Show the loader */
- this.active = false;
- /** Inline loaders are smaller and will appear to the left of the text */
- this.inline = false;
- /** Speficy the scale of the loader. Defaults to "m" */
- this.scale = "m";
- /** Percent complete of 100, only valid for determinate indicators */
- this.value = 0;
- /** Text which should appear under the loading indicator (optional) */
- this.text = "";
- /** Turn off spacing around the loader */
- this.noPadding = false;
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- render() {
- const { el, inline, label, scale, text, type, value } = this;
- const id = el.id || guid();
- const radiusRatio = 0.45;
- const size = inline ? this.getInlineSize(scale) : this.getSize(scale);
- const radius = size * radiusRatio;
- const viewbox = `0 0 ${size} ${size}`;
- const isDeterminate = type === "determinate";
- const circumference = 2 * radius * Math.PI;
- const progress = (value / 100) * circumference;
- const remaining = circumference - progress;
- const valueNow = Math.floor(value);
- const hostAttributes = {
- "aria-valuenow": valueNow,
- "aria-valuemin": 0,
- "aria-valuemax": 100,
- complete: valueNow === 100
- };
- const svgAttributes = { r: radius, cx: size / 2, cy: size / 2 };
- const determinateStyle = { "stroke-dasharray": `${progress} ${remaining}` };
- return (h(Host, Object.assign({ "aria-label": label, id: id, role: "progressbar" }, (isDeterminate ? hostAttributes : {})), h("div", { class: "loader__svgs" }, h("svg", { class: "loader__svg loader__svg--1", viewBox: viewbox }, h("circle", Object.assign({}, svgAttributes))), h("svg", { class: "loader__svg loader__svg--2", viewBox: viewbox }, h("circle", Object.assign({}, svgAttributes))), h("svg", Object.assign({ class: "loader__svg loader__svg--3", viewBox: viewbox }, (isDeterminate ? { style: determinateStyle } : {})), h("circle", Object.assign({}, svgAttributes)))), text && h("div", { class: "loader__text" }, text), isDeterminate && h("div", { class: "loader__percentage" }, value)));
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- /**
- * Return the proper sizes based on the scale property
- */
- getSize(scale) {
- return {
- s: 32,
- m: 56,
- l: 80
- }[scale];
- }
- getInlineSize(scale) {
- return {
- s: 12,
- m: 16,
- l: 20
- }[scale];
- }
- get el() { return this; }
- static get style() { return loaderCss; }
- };
- /**
- * Traverses the slots of the open shadowroots and returns all children matching the query.
- * @param {ShadowRoot | HTMLElement} root
- * @param skipNode
- * @param isMatch
- * @param {number} maxDepth
- * @param {number} depth
- * @returns {HTMLElement[]}
- */
- function queryShadowRoot(root, skipNode, isMatch, maxDepth = 20, depth = 0) {
- let matches = [];
- // If the depth is above the max depth, abort the searching here.
- if (depth >= maxDepth) {
- return matches;
- }
- // Traverses a slot element
- const traverseSlot = ($slot) => {
- // Only check nodes that are of the type Node.ELEMENT_NODE
- // Read more here https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
- const assignedNodes = $slot.assignedNodes().filter(node => node.nodeType === 1);
- if (assignedNodes.length > 0) {
- return queryShadowRoot(assignedNodes[0].parentElement, skipNode, isMatch, maxDepth, depth + 1);
- }
- return [];
- };
- // Go through each child and continue the traversing if necessary
- // Even though the typing says that children can't be undefined, Edge 15 sometimes gives an undefined value.
- // Therefore we fallback to an empty array if it is undefined.
- const children = Array.from(root.children || []);
- for (const $child of children) {
- // Check if the node and its descendants should be skipped
- if (skipNode($child)) {
- continue;
- }
- // If the child matches we always add it
- if (isMatch($child)) {
- matches.push($child);
- }
- if ($child.shadowRoot != null) {
- matches.push(...queryShadowRoot($child.shadowRoot, skipNode, isMatch, maxDepth, depth + 1));
- }
- else if ($child.tagName === "SLOT") {
- matches.push(...traverseSlot($child));
- }
- else {
- matches.push(...queryShadowRoot($child, skipNode, isMatch, maxDepth, depth + 1));
- }
- }
- return matches;
- }
- /**
- * Returns whether the element is hidden.
- * @param $elem
- */
- function isHidden($elem) {
- return $elem.hasAttribute("hidden")
- || ($elem.hasAttribute("aria-hidden") && $elem.getAttribute("aria-hidden") !== "false")
- // A quick and dirty way to check whether the element is hidden.
- // For a more fine-grained check we could use "window.getComputedStyle" but we don't because of bad performance.
- // If the element has visibility set to "hidden" or "collapse", display set to "none" or opacity set to "0" through CSS
- // we won't be able to catch it here. We accept it due to the huge performance benefits.
- || $elem.style.display === `none`
- || $elem.style.opacity === `0`
- || $elem.style.visibility === `hidden`
- || $elem.style.visibility === `collapse`;
- // If offsetParent is null we can assume that the element is hidden
- // https://stackoverflow.com/questions/306305/what-would-make-offsetparent-null
- //|| $elem.offsetParent == null;
- }
- /**
- * Returns whether the element is disabled.
- * @param $elem
- */
- function isDisabled($elem) {
- return $elem.hasAttribute("disabled")
- || ($elem.hasAttribute("aria-disabled") && $elem.getAttribute("aria-disabled") !== "false");
- }
- /**
- * Determines whether an element is focusable.
- * Read more here: https://stackoverflow.com/questions/1599660/which-html-elements-can-receive-focus/1600194#1600194
- * Or here: https://stackoverflow.com/questions/18261595/how-to-check-if-a-dom-element-is-focusable
- * @param $elem
- */
- function isFocusable($elem) {
- // Discard elements that are removed from the tab order.
- if ($elem.getAttribute("tabindex") === "-1" || isHidden($elem) || isDisabled($elem)) {
- return false;
- }
- return (
- // At this point we know that the element can have focus (eg. won't be -1) if the tabindex attribute exists
- $elem.hasAttribute("tabindex")
- // Anchor tags or area tags with a href set
- || ($elem instanceof HTMLAnchorElement || $elem instanceof HTMLAreaElement) && $elem.hasAttribute("href")
- // Form elements which are not disabled
- || ($elem instanceof HTMLButtonElement
- || $elem instanceof HTMLInputElement
- || $elem instanceof HTMLTextAreaElement
- || $elem instanceof HTMLSelectElement)
- // IFrames
- || $elem instanceof HTMLIFrameElement);
- }
- const CSS$n = {
- title: "title",
- header: "header",
- footer: "footer",
- scrim: "scrim",
- back: "back",
- close: "close",
- secondary: "secondary",
- primary: "primary",
- overflowHidden: "overflow-hidden"
- };
- const ICONS$6 = {
- close: "x"
- };
- const SLOTS$e = {
- content: "content",
- header: "header",
- back: "back",
- secondary: "secondary",
- primary: "primary"
- };
- const TEXT$b = {
- close: "Close"
- };
- const modalCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:fixed;top:0px;right:0px;bottom:0px;left:0px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;overflow-y:hidden;color:var(--calcite-ui-text-2);opacity:0;visibility:hidden !important;-webkit-transition:visibility 0ms linear 300ms, opacity var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88);transition:visibility 0ms linear 300ms, opacity var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88);z-index:101}:host([scale=s]){--calcite-modal-padding:0.75rem;--calcite-modal-padding-large:1rem;--calcite-modal-title-text:var(--calcite-font-size-1);--calcite-modal-content-text:var(--calcite-font-size--1)}:host([scale=m]){--calcite-modal-padding:1rem;--calcite-modal-padding-large:1.25rem;--calcite-modal-title-text:var(--calcite-font-size-2);--calcite-modal-content-text:var(--calcite-font-size-0)}:host([scale=l]){--calcite-modal-padding:1.25rem;--calcite-modal-padding-large:1.5rem;--calcite-modal-title-text:var(--calcite-font-size-3);--calcite-modal-content-text:var(--calcite-font-size-1)}.scrim{--calcite-scrim-background:rgba(0, 0, 0, 0.75);position:fixed;top:0px;right:0px;bottom:0px;left:0px;display:-ms-flexbox;display:flex;overflow-y:hidden}.modal{pointer-events:none;float:none;margin:1.5rem;-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;width:100%;-ms-flex-direction:column;flex-direction:column;overflow:hidden;border-radius:0.25rem;background-color:var(--calcite-ui-foreground-1);opacity:0;--tw-shadow:0 2px 12px -4px rgba(0, 0, 0, 0.2), 0 2px 4px -2px rgba(0, 0, 0, 0.16);--tw-shadow-colored:0 2px 12px -4px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);z-index:102;-webkit-overflow-scrolling:touch;visibility:hidden;-webkit-transition:visibility 0ms linear 300ms, opacity var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), -webkit-transform var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88);transition:visibility 0ms linear 300ms, opacity var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), -webkit-transform var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88);transition:transform var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), visibility 0ms linear 300ms, opacity var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88);transition:transform var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), visibility 0ms linear 300ms, opacity var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), -webkit-transform var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88);-webkit-transform:translate3d(0, 20px, 0);transform:translate3d(0, 20px, 0)}:host([active]){opacity:1;visibility:visible !important;-webkit-transition-delay:0ms;transition-delay:0ms}:host([active]) .modal{pointer-events:auto;visibility:visible;opacity:1;-webkit-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0);-webkit-transition:visibility 0ms linear, opacity var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), max-width var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), max-height var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), -webkit-transform var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88);transition:visibility 0ms linear, opacity var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), max-width var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), max-height var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), -webkit-transform var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88);transition:transform var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), visibility 0ms linear, opacity var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), max-width var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), max-height var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88);transition:transform var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), visibility 0ms linear, opacity var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), max-width var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), max-height var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88), -webkit-transform var(--calcite-internal-animation-timing-slow) cubic-bezier(0.215, 0.44, 0.42, 0.88);-webkit-transition-delay:0ms;transition-delay:0ms}.header{display:-ms-flexbox;display:flex;min-width:0px;max-width:100%;border-top-left-radius:0.25rem;border-top-right-radius:0.25rem;border-width:0px;border-bottom-width:1px;border-style:solid;border-color:var(--calcite-ui-border-3);background-color:var(--calcite-ui-foreground-1);-ms-flex:0 0 auto;flex:0 0 auto;z-index:2}.close{-ms-flex-order:2;order:2;margin:0px;cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none;border-style:none;background-color:transparent;color:var(--calcite-ui-text-3);outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s;border-start-end-radius:0.25rem;padding:var(--calcite-modal-padding);-ms-flex:0 0 auto;flex:0 0 auto}.close calcite-icon{pointer-events:none;vertical-align:-2px}.close:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.close:hover,.close:focus,.close:active{background-color:var(--calcite-ui-foreground-2);color:var(--calcite-ui-text-1)}.title{-ms-flex-order:1;order:1;display:-ms-flexbox;display:flex;min-width:0px;-ms-flex-align:center;align-items:center;-ms-flex:1 1 auto;flex:1 1 auto;padding:var(--calcite-modal-padding) var(--calcite-modal-padding-large)}slot[name=header]::slotted(*),*::slotted([slot=header]){margin:0px;font-weight:var(--calcite-font-weight-normal);color:var(--calcite-ui-text-1);font-size:var(--calcite-modal-title-text)}.content{position:relative;-webkit-box-sizing:border-box;box-sizing:border-box;display:block;height:100%;overflow:auto;background-color:var(--calcite-ui-foreground-1);padding:0px;max-height:calc(100vh - 12rem);z-index:1}.content--spaced{padding:var(--calcite-modal-padding) var(--calcite-modal-padding-large)}.content--no-footer{border-bottom-right-radius:0.25rem;border-bottom-left-radius:0.25rem}slot[name=content]::slotted(*),*::slotted([slot=content]){font-size:var(--calcite-modal-content-text)}:host([background-color=grey]) .content{background-color:var(--calcite-ui-background)}.footer{margin-top:auto;-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;width:100%;-ms-flex-pack:justify;justify-content:space-between;border-bottom-right-radius:0.25rem;border-bottom-left-radius:0.25rem;border-width:0px;border-top-width:1px;border-style:solid;border-color:var(--calcite-ui-border-3);background-color:var(--calcite-ui-foreground-1);-ms-flex:0 0 auto;flex:0 0 auto;padding:var(--calcite-modal-padding) var(--calcite-modal-padding-large);z-index:2}.footer--hide-back .back,.footer--hide-secondary .secondary{display:none}.back{display:block;-webkit-margin-end:auto;margin-inline-end:auto}.secondary{margin-left:0.25rem;margin-right:0.25rem;display:block}slot[name=primary]{display:block}:host([width=small]) .modal{width:auto}:host([width=s]) .modal{max-width:32rem}@media screen and (max-width: 35rem){:host([width=s]) .modal{margin:0px;height:100%;max-height:100%;width:100%;max-width:100%;border-radius:0px}:host([width=s]) .content{-ms-flex:1 1 auto;flex:1 1 auto;max-height:unset}:host([width=s][docked]){-ms-flex-align:end;align-items:flex-end}}:host([width=m]) .modal{max-width:48rem}@media screen and (max-width: 51rem){:host([width=m]) .modal{margin:0px;height:100%;max-height:100%;width:100%;max-width:100%;border-radius:0px}:host([width=m]) .content{-ms-flex:1 1 auto;flex:1 1 auto;max-height:unset}:host([width=m][docked]){-ms-flex-align:end;align-items:flex-end}}:host([width=l]) .modal{max-width:94rem}@media screen and (max-width: 97rem){:host([width=l]) .modal{margin:0px;height:100%;max-height:100%;width:100%;max-width:100%;border-radius:0px}:host([width=l]) .content{-ms-flex:1 1 auto;flex:1 1 auto;max-height:unset}:host([width=l][docked]){-ms-flex-align:end;align-items:flex-end}}:host([fullscreen]){background-color:transparent}:host([fullscreen]) .modal{margin:0px;height:100%;max-height:100%;width:100%;max-width:100%;-webkit-transform:translate3D(0, 20px, 0) scale(0.95);transform:translate3D(0, 20px, 0) scale(0.95)}:host([fullscreen]) .content{max-height:100%;-ms-flex:1 1 auto;flex:1 1 auto}:host([active][fullscreen]) .modal{-webkit-transform:translate3D(0, 0, 0) scale(1);transform:translate3D(0, 0, 0) scale(1)}:host([active][fullscreen]) .header{border-radius:0}:host([active][fullscreen]) .footer{border-radius:0}:host([docked]) .modal{height:auto}:host([docked]) .content{height:auto;-ms-flex:1 1 auto;flex:1 1 auto}@media screen and (max-width: 860px){:host([docked]) .modal{border-radius:var(--calcite-border-radius) var(--calcite-border-radius) 0 0}:host([docked]) .close{border-start-end-radius:var(--calcite-border-radius)}}:host([color=red]) .modal{border-color:var(--calcite-ui-danger)}:host([color=blue]) .modal{border-color:var(--calcite-ui-info)}:host([color=red]) .modal,:host([color=blue]) .modal{border-width:0px;border-top-width:4px;border-style:solid}:host([color=red]) .header,:host([color=blue]) .header{border-radius:0.25rem;border-bottom-right-radius:0px;border-bottom-left-radius:0px}@media screen and (max-width: 860px){slot[name=header]::slotted(*),*::slotted([slot=header]){font-size:var(--calcite-font-size-1)}.footer{position:-webkit-sticky;position:sticky;bottom:0px}}@media screen and (max-width: 480px){.footer{-ms-flex-direction:column;flex-direction:column}.back,.secondary{margin:0px;margin-bottom:0.25rem}}";
- const isFocusableExtended = (el) => {
- return isCalciteFocusable(el) || isFocusable(el);
- };
- const getFocusableElements = (el) => {
- return queryShadowRoot(el, isHidden, isFocusableExtended);
- };
- const Modal = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteModalOpen = createEvent(this, "calciteModalOpen", 7);
- this.calciteModalClose = createEvent(this, "calciteModalClose", 7);
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** Add the active attribute to open the modal */
- this.active = false;
- /** Optionally pass a function to run before close */
- this.beforeClose = () => Promise.resolve();
- /** Disables the display a close button within the Modal */
- this.disableCloseButton = false;
- /** Disables the closing of the Modal when clicked outside. */
- this.disableOutsideClose = false;
- /** Aria label for the close button */
- this.intlClose = TEXT$b.close;
- /** Flag to disable the default close on escape behavior */
- this.disableEscape = false;
- /** specify the scale of modal, defaults to m */
- this.scale = "m";
- /** Set the width of the modal. Can use stock sizes or pass a number (in pixels) */
- this.width = "m";
- /** Background color of modal content */
- this.backgroundColor = "white";
- /** Turn off spacing around the content area slot */
- this.noPadding = false;
- //--------------------------------------------------------------------------
- //
- // Variables
- //
- //--------------------------------------------------------------------------
- this.hasFooter = true;
- this.mutationObserver = createObserver("mutation", () => this.updateFooterVisibility());
- this.activeTransitionProp = "opacity";
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- this.transitionEnd = (event) => {
- if (event.propertyName === this.activeTransitionProp) {
- this.active ? this.calciteModalOpen.emit() : this.calciteModalClose.emit();
- }
- };
- this.openEnd = () => {
- this.setFocus();
- this.el.removeEventListener("calciteModalOpen", this.openEnd);
- };
- this.handleOutsideClose = () => {
- if (this.disableOutsideClose) {
- return;
- }
- this.close();
- };
- /** Close the modal, first running the `beforeClose` method */
- this.close = () => {
- return this.beforeClose(this.el).then(() => {
- this.active = false;
- focusElement(this.previousActiveElement);
- this.removeOverflowHiddenClass();
- });
- };
- this.focusFirstElement = () => {
- focusElement(this.disableCloseButton ? getFocusableElements(this.el)[0] : this.closeButtonEl);
- };
- this.focusLastElement = () => {
- const focusableElements = getFocusableElements(this.el).filter((el) => !el.getAttribute("data-focus-fence"));
- if (focusableElements.length > 0) {
- focusElement(focusableElements[focusableElements.length - 1]);
- }
- else {
- focusElement(this.closeButtonEl);
- }
- };
- this.updateFooterVisibility = () => {
- this.hasFooter = !!getSlotted(this.el, [SLOTS$e.back, SLOTS$e.primary, SLOTS$e.secondary]);
- };
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentWillLoad() {
- // when modal initially renders, if active was set we need to open as watcher doesn't fire
- if (this.active) {
- this.open();
- }
- }
- connectedCallback() {
- var _a;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
- this.updateFooterVisibility();
- connectConditionalSlotComponent(this);
- }
- disconnectedCallback() {
- var _a;
- this.removeOverflowHiddenClass();
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- disconnectConditionalSlotComponent(this);
- }
- render() {
- return (h(Host, { "aria-describedby": this.contentId, "aria-labelledby": this.titleId, "aria-modal": "true", role: "dialog" }, h("calcite-scrim", { class: CSS$n.scrim, onClick: this.handleOutsideClose }), this.renderStyle(), h("div", { class: "modal", onTransitionEnd: this.transitionEnd }, h("div", { "data-focus-fence": true, onFocus: this.focusLastElement, tabindex: "0" }), h("div", { class: CSS$n.header }, this.renderCloseButton(), h("header", { class: CSS$n.title }, h("slot", { name: CSS$n.header }))), h("div", { class: {
- content: true,
- "content--spaced": !this.noPadding,
- "content--no-footer": !this.hasFooter
- }, ref: (el) => (this.modalContent = el) }, h("slot", { name: SLOTS$e.content })), this.renderFooter(), h("div", { "data-focus-fence": true, onFocus: this.focusFirstElement, tabindex: "0" }))));
- }
- renderFooter() {
- return this.hasFooter ? (h("div", { class: CSS$n.footer, key: "footer" }, h("span", { class: CSS$n.back }, h("slot", { name: SLOTS$e.back })), h("span", { class: CSS$n.secondary }, h("slot", { name: SLOTS$e.secondary })), h("span", { class: CSS$n.primary }, h("slot", { name: SLOTS$e.primary })))) : null;
- }
- renderCloseButton() {
- return !this.disableCloseButton ? (h("button", { "aria-label": this.intlClose, class: CSS$n.close, key: "button", onClick: this.close, ref: (el) => (this.closeButtonEl = el), title: this.intlClose }, h("calcite-icon", { icon: ICONS$6.close, scale: this.scale === "s" ? "s" : this.scale === "m" ? "m" : this.scale === "l" ? "l" : null }))) : null;
- }
- renderStyle() {
- const hasCustomWidth = !isNaN(parseInt(`${this.width}`));
- return hasCustomWidth ? (h("style", null, `
- .modal {
- max-width: ${this.width}px !important;
- }
- @media screen and (max-width: ${this.width}px) {
- .modal {
- height: 100% !important;
- max-height: 100% !important;
- width: 100% !important;
- max-width: 100% !important;
- margin: 0 !important;
- border-radius: 0 !important;
- }
- .content {
- flex: 1 1 auto !important;
- max-height: unset !important;
- }
- }
- `)) : null;
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- handleEscape(e) {
- if (this.active && !this.disableEscape && e.key === "Escape") {
- this.close();
- }
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /**
- * Focus first interactive element
- * @deprecated use `setFocus` instead.
- */
- async focusElement(el) {
- if (el) {
- el.focus();
- }
- return this.setFocus();
- }
- /**
- * Sets focus on the component.
- *
- * By default, will try to focus on any focusable content. If there is none, it will focus on the close button.
- * If you want to focus on the close button, you can use the `close-button` focus ID.
- */
- async setFocus(focusId) {
- const closeButton = this.closeButtonEl;
- return focusElement(focusId === "close-button" ? closeButton : getFocusableElements(this.el)[0] || closeButton);
- }
- /** Set the scroll top of the modal content */
- async scrollContent(top = 0, left = 0) {
- if (this.modalContent) {
- if (this.modalContent.scrollTo) {
- this.modalContent.scrollTo({ top, left, behavior: "smooth" });
- }
- else {
- this.modalContent.scrollTop = top;
- this.modalContent.scrollLeft = left;
- }
- }
- }
- async toggleModal(value, oldValue) {
- if (value !== oldValue) {
- if (value) {
- this.open();
- }
- else if (!value) {
- this.close();
- }
- }
- }
- /** Open the modal */
- open() {
- this.previousActiveElement = document.activeElement;
- this.el.addEventListener("calciteModalOpen", this.openEnd);
- this.active = true;
- const titleEl = getSlotted(this.el, SLOTS$e.header);
- const contentEl = getSlotted(this.el, SLOTS$e.content);
- this.titleId = ensureId(titleEl);
- this.contentId = ensureId(contentEl);
- document.documentElement.classList.add(CSS$n.overflowHidden);
- }
- removeOverflowHiddenClass() {
- document.documentElement.classList.remove(CSS$n.overflowHidden);
- }
- get el() { return this; }
- static get watchers() { return {
- "active": ["toggleModal"]
- }; }
- static get style() { return modalCss; }
- };
- const TEXT$a = {
- close: "Close"
- };
- const SLOTS$d = {
- title: "title",
- message: "message",
- link: "link",
- actionsEnd: "actions-end"
- };
- const CSS$m = {
- actionsEnd: "actions-end",
- close: "notice-close",
- container: "container",
- content: "notice-content",
- icon: "notice-icon"
- };
- const noticeCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([scale=s]){--calcite-notice-spacing-token-small:0.5rem;--calcite-notice-spacing-token-large:0.75rem}:host([scale=s]) .container slot[name=title]::slotted(*),:host([scale=s]) .container *::slotted([slot=title]){margin-top:0.125rem;margin-bottom:0.125rem;font-size:var(--calcite-font-size--1);line-height:1.375}:host([scale=s]) .container slot[name=message]::slotted(*),:host([scale=s]) .container *::slotted([slot=message]){margin-top:0.125rem;margin-bottom:0.125rem;font-size:var(--calcite-font-size--2);line-height:1.375}:host([scale=s]) ::slotted(calcite-link){margin-top:0.125rem;margin-bottom:0.125rem;font-size:var(--calcite-font-size--2);line-height:1.375}:host([scale=s]) .notice-close{padding:0.5rem}:host([scale=m]){--calcite-notice-spacing-token-small:0.75rem;--calcite-notice-spacing-token-large:1rem}:host([scale=m]) .container slot[name=title]::slotted(*),:host([scale=m]) .container *::slotted([slot=title]){margin-top:0.125rem;margin-bottom:0.125rem;font-size:var(--calcite-font-size-0);line-height:1.375}:host([scale=m]) .container slot[name=message]::slotted(*),:host([scale=m]) .container *::slotted([slot=message]){margin-top:0.125rem;margin-bottom:0.125rem;font-size:var(--calcite-font-size--1);line-height:1.375}:host([scale=m]) ::slotted(calcite-link){margin-top:0.125rem;margin-bottom:0.125rem;font-size:var(--calcite-font-size--1);line-height:1.375}:host([scale=l]){--calcite-notice-spacing-token-small:1rem;--calcite-notice-spacing-token-large:1.25rem}:host([scale=l]) .container slot[name=title]::slotted(*),:host([scale=l]) .container *::slotted([slot=title]){margin-top:0.125rem;margin-bottom:0.125rem;font-size:var(--calcite-font-size-1);line-height:1.375}:host([scale=l]) .container slot[name=message]::slotted(*),:host([scale=l]) .container *::slotted([slot=message]){margin-top:0.125rem;margin-bottom:0.125rem;font-size:var(--calcite-font-size-0);line-height:1.375}:host([scale=l]) ::slotted(calcite-link){margin-top:0.125rem;margin-bottom:0.125rem;font-size:var(--calcite-font-size-0);line-height:1.375}:host([width=auto]){--calcite-notice-width:auto}:host([width=half]){--calcite-notice-width:50%}:host([width=full]){--calcite-notice-width:100%}:host{margin-left:auto;margin-right:auto;display:none;max-width:100%;-ms-flex-align:center;align-items:center;width:var(--calcite-notice-width)}.container{pointer-events:none;margin-top:0px;margin-bottom:0px;-webkit-box-sizing:border-box;box-sizing:border-box;display:none;width:100%;background-color:var(--calcite-ui-foreground-1);opacity:0;max-height:0;text-align:start;-webkit-transition:var(--calcite-animation-timing);transition:var(--calcite-animation-timing);-webkit-border-start:0px solid;border-inline-start:0px solid;-webkit-box-shadow:0 0 0 0 transparent;box-shadow:0 0 0 0 transparent}.notice-close{outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out}.notice-close:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}:host{display:-ms-flexbox;display:flex}:host([active]) .container{pointer-events:auto;display:-ms-flexbox;display:flex;max-height:100%;-ms-flex-align:center;align-items:center;border-width:2px;opacity:1;--tw-shadow:0 4px 8px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);--tw-shadow-colored:0 4px 8px -1px var(--tw-shadow-color), 0 2px 4px -1px var(--tw-shadow-color);-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.container slot[name=title]::slotted(*),.container *::slotted([slot=title]){margin:0px;font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1)}.container slot[name=message]::slotted(*),.container *::slotted([slot=message]){margin:0px;display:inline;font-weight:var(--calcite-font-weight-normal);color:var(--calcite-ui-text-2);-webkit-margin-end:var(--calcite-notice-spacing-token-small);margin-inline-end:var(--calcite-notice-spacing-token-small)}.notice-content{-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s;padding:var(--calcite-notice-spacing-token-small) var(--calcite-notice-spacing-token-large);-ms-flex:0 0 auto;flex:0 0 auto;display:-ms-flexbox;display:flex;min-width:0px;-ms-flex-direction:column;flex-direction:column;overflow-wrap:break-word;-ms-flex:1 1 0px;flex:1 1 0;padding-block:var(--calcite-notice-spacing-token-small);padding-inline:0 var(--calcite-notice-spacing-token-small)}.notice-content:first-of-type:not(:only-child){-webkit-padding-start:var(--calcite-notice-spacing-token-large);padding-inline-start:var(--calcite-notice-spacing-token-large)}.notice-content:only-of-type{padding:var(--calcite-notice-spacing-token-small) var(--calcite-notice-spacing-token-large)}.notice-icon{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s;padding:var(--calcite-notice-spacing-token-small) var(--calcite-notice-spacing-token-large);-ms-flex:0 0 auto;flex:0 0 auto}.notice-close{display:-ms-flexbox;display:flex;cursor:pointer;-ms-flex-align:center;align-items:center;-ms-flex-item-align:stretch;align-self:stretch;border-style:none;background-color:transparent;color:var(--calcite-ui-text-3);outline:2px solid transparent;outline-offset:2px;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s;padding:var(--calcite-notice-spacing-token-small) var(--calcite-notice-spacing-token-large);-ms-flex:0 0 auto;flex:0 0 auto;-webkit-appearance:none}.notice-close:hover,.notice-close:focus{background-color:var(--calcite-ui-foreground-2);color:var(--calcite-ui-text-1)}.notice-close:active{background-color:var(--calcite-ui-foreground-3)}.actions-end{display:-ms-flexbox;display:flex;-ms-flex-item-align:stretch;align-self:stretch}:host([color=blue]) .container{border-color:var(--calcite-ui-brand)}:host([color=blue]) .container .notice-icon{color:var(--calcite-ui-brand)}:host([color=red]) .container{border-color:var(--calcite-ui-danger)}:host([color=red]) .container .notice-icon{color:var(--calcite-ui-danger)}:host([color=yellow]) .container{border-color:var(--calcite-ui-warning)}:host([color=yellow]) .container .notice-icon{color:var(--calcite-ui-warning)}:host([color=green]) .container{border-color:var(--calcite-ui-success)}:host([color=green]) .container .notice-icon{color:var(--calcite-ui-success)}";
- const Notice = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteNoticeClose = createEvent(this, "calciteNoticeClose", 7);
- this.calciteNoticeOpen = createEvent(this, "calciteNoticeOpen", 7);
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //---------------------------------------------------------------------------
- /** Is the notice currently active or not */
- this.active = false;
- /** Color for the notice (will apply to top border and icon) */
- this.color = "blue";
- /** Optionally show a button the user can click to dismiss the notice */
- this.dismissible = false;
- /** String for the close button.
- * @default "Close"
- */
- this.intlClose = TEXT$a.close;
- /** specify the scale of the notice, defaults to m */
- this.scale = "m";
- /** specify the width of the notice, defaults to auto */
- this.width = "auto";
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- this.close = () => {
- this.active = false;
- this.calciteNoticeClose.emit();
- };
- }
- updateRequestedIcon() {
- this.requestedIcon = setRequestedIcon(StatusIcons, this.icon, this.color);
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- connectConditionalSlotComponent(this);
- }
- disconnectedCallback() {
- disconnectConditionalSlotComponent(this);
- }
- componentWillLoad() {
- this.requestedIcon = setRequestedIcon(StatusIcons, this.icon, this.color);
- }
- render() {
- const { el } = this;
- const closeButton = (h("button", { "aria-label": this.intlClose, class: CSS$m.close, onClick: this.close, ref: (el) => (this.closeButton = el) }, h("calcite-icon", { icon: "x", scale: this.scale === "l" ? "m" : "s" })));
- const hasActionEnd = getSlotted(el, SLOTS$d.actionsEnd);
- return (h("div", { class: CSS$m.container }, this.requestedIcon ? (h("div", { class: CSS$m.icon }, h("calcite-icon", { icon: this.requestedIcon, scale: this.scale === "l" ? "m" : "s" }))) : null, h("div", { class: CSS$m.content }, h("slot", { name: SLOTS$d.title }), h("slot", { name: SLOTS$d.message }), h("slot", { name: SLOTS$d.link })), hasActionEnd ? (h("div", { class: CSS$m.actionsEnd }, h("slot", { name: SLOTS$d.actionsEnd }))) : null, this.dismissible ? closeButton : null));
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- const noticeLinkEl = this.el.querySelector("calcite-link");
- if (!this.closeButton && !noticeLinkEl) {
- return;
- }
- if (noticeLinkEl) {
- noticeLinkEl.setFocus();
- }
- else if (this.closeButton) {
- this.closeButton.focus();
- }
- }
- get el() { return this; }
- static get watchers() { return {
- "icon": ["updateRequestedIcon"],
- "color": ["updateRequestedIcon"]
- }; }
- static get style() { return noticeCss; }
- };
- const optionCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:block}";
- const Option = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteOptionChange = createEvent(this, "calciteOptionChange", 7);
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /**
- * When true, it prevents the option from being selected.
- */
- this.disabled = false;
- this.mutationObserver = createObserver("mutation", () => {
- this.ensureTextContentDependentProps();
- this.calciteOptionChange.emit();
- });
- }
- handlePropChange(_newValue, _oldValue, propName) {
- if (propName === "label" || propName === "value") {
- this.ensureTextContentDependentProps();
- }
- this.calciteOptionChange.emit();
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- ensureTextContentDependentProps() {
- const { el: { textContent } } = this;
- if (!this.label || this.label === this.internallySetLabel) {
- this.label = textContent;
- this.internallySetLabel = textContent;
- }
- if (!this.value || this.value === this.internallySetValue) {
- this.value = textContent;
- this.internallySetValue = textContent;
- }
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- var _a;
- this.ensureTextContentDependentProps();
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, {
- attributeFilter: ["label", "value"],
- characterData: true,
- childList: true,
- subtree: true
- });
- }
- disconnectedCallback() {
- var _a;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- }
- //--------------------------------------------------------------------------
- //
- // Render Methods
- //
- //--------------------------------------------------------------------------
- render() {
- return h("slot", null, this.label);
- }
- get el() { return this; }
- static get watchers() { return {
- "disabled": ["handlePropChange"],
- "label": ["handlePropChange"],
- "selected": ["handlePropChange"],
- "value": ["handlePropChange"]
- }; }
- static get style() { return optionCss; }
- };
- const optionGroupCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:block}";
- const OptionGroup = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteOptionGroupChange = createEvent(this, "calciteOptionGroupChange", 7);
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /**
- * When true, it prevents selection from any of its associated options.
- */
- this.disabled = false;
- }
- handlePropChange() {
- this.calciteOptionGroupChange.emit();
- }
- //--------------------------------------------------------------------------
- //
- // Render Methods
- //
- //--------------------------------------------------------------------------
- render() {
- return (h(Fragment, null, h("div", null, this.label), h("slot", null)));
- }
- static get watchers() { return {
- "disabled": ["handlePropChange"],
- "label": ["handlePropChange"]
- }; }
- static get style() { return optionGroupCss; }
- };
- const CSS$l = {
- page: "page",
- selected: "is-selected",
- previous: "previous",
- next: "next",
- disabled: "is-disabled",
- ellipsis: "ellipsis",
- ellipsisStart: "ellipsis--start",
- ellipsisEnd: "ellipsis--end"
- };
- const TEXT$9 = {
- nextLabel: "Next",
- previousLabel: "Previous"
- };
- const paginationCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([scale=s]){--calcite-pagination-spacing:0.25rem 0.5rem}:host([scale=s]) .previous,:host([scale=s]) .next,:host([scale=s]) .page{height:1.5rem;font-size:var(--calcite-font-size--2);line-height:1rem}:host([scale=s]) .previous,:host([scale=s]) .next{padding-left:0.25rem;padding-right:0.25rem}:host([scale=m]){--calcite-pagination-spacing:0.5rem 0.75rem}:host([scale=m]) .previous,:host([scale=m]) .next,:host([scale=m]) .page{height:2rem;font-size:var(--calcite-font-size--1);line-height:1rem}:host([scale=m]) .previous,:host([scale=m]) .next{padding-left:0.5rem;padding-right:0.5rem}:host([scale=l]){--calcite-pagination-spacing:0.75rem 1rem}:host([scale=l]) .previous,:host([scale=l]) .next,:host([scale=l]) .page{height:2.75rem;font-size:var(--calcite-font-size-0);line-height:1.25rem}:host([scale=l]) .previous,:host([scale=l]) .next{padding-left:1rem;padding-right:1rem}:host{display:-ms-flexbox;display:flex;-webkit-writing-mode:horizontal-tb;-ms-writing-mode:lr-tb;writing-mode:horizontal-tb}:host button{outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out}:host button:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.previous,.next,.page{-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;cursor:pointer;-ms-flex-align:center;align-items:center;border-style:none;--tw-border-opacity:0;background-color:transparent;font-family:inherit;font-size:var(--calcite-font-size-0);line-height:1.25rem;color:var(--calcite-ui-text-3);border-top:2px solid transparent;border-bottom:2px solid transparent}.previous:hover,.next:hover,.page:hover{color:var(--calcite-ui-text-1);-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s}.page:hover{border-bottom-color:var(--calcite-ui-border-2)}.page.is-selected{font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1);border-bottom-color:var(--calcite-ui-brand)}.previous:hover,.next:hover{background-color:var(--calcite-ui-foreground-2);color:var(--calcite-ui-brand)}.previous:active,.next:active{background-color:var(--calcite-ui-foreground-3)}.previous.is-disabled,.next.is-disabled{pointer-events:none;background-color:transparent}.previous.is-disabled>calcite-icon,.next.is-disabled>calcite-icon{opacity:var(--calcite-ui-opacity-disabled)}.next{margin-right:0px}.page,.ellipsis{padding:var(--calcite-pagination-spacing)}.ellipsis{display:-ms-flexbox;display:flex;-ms-flex-align:end;align-items:flex-end;color:var(--calcite-ui-text-3)}";
- const maxPagesDisplayed = 5;
- const Pagination = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calcitePaginationUpdate = createEvent(this, "calcitePaginationUpdate", 7);
- this.calcitePaginationChange = createEvent(this, "calcitePaginationChange", 7);
- //--------------------------------------------------------------------------
- //
- // Public Properties
- //
- //--------------------------------------------------------------------------
- /** number of items per page */
- this.num = 20;
- /** index of item that should begin the page */
- this.start = 1;
- /** total number of items */
- this.total = 0;
- /** Used as an accessible label (aria-label) for the next button
- * @default "Next"
- */
- this.textLabelNext = TEXT$9.nextLabel;
- /** Used as an accessible label (aria-label) of the previous button
- * @default "Previous"
- */
- this.textLabelPrevious = TEXT$9.previousLabel;
- /** The scale of the pagination */
- this.scale = "m";
- this.previousClicked = () => {
- this.previousPage().then();
- this.emitUpdate();
- };
- this.nextClicked = () => {
- this.nextPage();
- this.emitUpdate();
- };
- }
- // --------------------------------------------------------------------------
- //
- // Public Methods
- //
- // --------------------------------------------------------------------------
- /** Go to the next page of results */
- async nextPage() {
- this.start = Math.min(this.getLastStart(), this.start + this.num);
- }
- /** Go to the previous page of results */
- async previousPage() {
- this.start = Math.max(1, this.start - this.num);
- }
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- getLastStart() {
- const { total, num } = this;
- const lastStart = total % num === 0 ? total - num : Math.floor(total / num) * num;
- return lastStart + 1;
- }
- showLeftEllipsis() {
- return Math.floor(this.start / this.num) > 3;
- }
- showRightEllipsis() {
- return (this.total - this.start) / this.num > 3;
- }
- emitUpdate() {
- const changePayload = {
- start: this.start,
- total: this.total,
- num: this.num
- };
- this.calcitePaginationChange.emit(changePayload);
- this.calcitePaginationUpdate.emit(changePayload);
- }
- //--------------------------------------------------------------------------
- //
- // Render Methods
- //
- //--------------------------------------------------------------------------
- renderPages() {
- const lastStart = this.getLastStart();
- let end;
- let nextStart;
- // if we don't need ellipses render the whole set
- if (this.total / this.num <= maxPagesDisplayed) {
- nextStart = 1 + this.num;
- end = lastStart - this.num;
- }
- else {
- // if we're within max pages of page 1
- if (this.start / this.num < maxPagesDisplayed - 1) {
- nextStart = 1 + this.num;
- end = 1 + 4 * this.num;
- }
- else {
- // if we're within max pages of last page
- if (this.start + 3 * this.num >= this.total) {
- nextStart = lastStart - 4 * this.num;
- end = lastStart - this.num;
- }
- else {
- nextStart = this.start - this.num;
- end = this.start + this.num;
- }
- }
- }
- const pages = [];
- while (nextStart <= end) {
- pages.push(nextStart);
- nextStart = nextStart + this.num;
- }
- return pages.map((page) => this.renderPage(page));
- }
- renderPage(start) {
- const page = Math.floor(start / this.num) + (this.num === 1 ? 0 : 1);
- return (h("button", { class: {
- [CSS$l.page]: true,
- [CSS$l.selected]: start === this.start
- }, onClick: () => {
- this.start = start;
- this.emitUpdate();
- } }, page));
- }
- renderLeftEllipsis() {
- if (this.total / this.num > maxPagesDisplayed && this.showLeftEllipsis()) {
- return h("span", { class: `${CSS$l.ellipsis} ${CSS$l.ellipsisStart}` }, "\u2026");
- }
- }
- renderRightEllipsis() {
- if (this.total / this.num > maxPagesDisplayed && this.showRightEllipsis()) {
- return h("span", { class: `${CSS$l.ellipsis} ${CSS$l.ellipsisEnd}` }, "\u2026");
- }
- }
- render() {
- const { total, num, start } = this;
- const prevDisabled = num === 1 ? start <= num : start < num;
- const nextDisabled = num === 1 ? start + num > total : start + num > total;
- return (h(Fragment, null, h("button", { "aria-label": this.textLabelPrevious, class: {
- [CSS$l.previous]: true,
- [CSS$l.disabled]: prevDisabled
- }, disabled: prevDisabled, onClick: this.previousClicked }, h("calcite-icon", { flipRtl: true, icon: "chevronLeft", scale: "s" })), total > num ? this.renderPage(1) : null, this.renderLeftEllipsis(), this.renderPages(), this.renderRightEllipsis(), this.renderPage(this.getLastStart()), h("button", { "aria-label": this.textLabelNext, class: {
- [CSS$l.next]: true,
- [CSS$l.disabled]: nextDisabled
- }, disabled: nextDisabled, onClick: this.nextClicked }, h("calcite-icon", { flipRtl: true, icon: "chevronRight", scale: "s" }))));
- }
- get el() { return this; }
- static get style() { return paginationCss; }
- };
- const CSS$k = {
- backButton: "back-button",
- container: "container",
- header: "header",
- heading: "heading",
- summary: "summary",
- headerContent: "header-content",
- headerActions: "header-actions",
- headerActionsEnd: "header-actions--end",
- headerActionsStart: "header-actions--start",
- contentWrapper: "content-wrapper",
- contentContainer: "content-container",
- contentHeight: "content-height",
- fabContainer: "fab-container",
- footer: "footer",
- menuContainer: "menu-container",
- menuButton: "menu-button",
- menu: "menu",
- menuOpen: "menu--open"
- };
- const ICONS$5 = {
- close: "x",
- menu: "ellipsis",
- backLeft: "chevron-left",
- backRight: "chevron-right"
- };
- const SLOTS$c = {
- headerActionsStart: "header-actions-start",
- headerActionsEnd: "header-actions-end",
- headerMenuActions: "header-menu-actions",
- headerContent: "header-content",
- fab: "fab",
- footer: "footer",
- footerActions: "footer-actions"
- };
- const TEXT$8 = {
- back: "Back",
- close: "Close",
- open: "Open",
- options: "Options"
- };
- const HEADING_LEVEL$4 = 3;
- const panelCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:host{-webkit-box-sizing:border-box;box-sizing:border-box;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-2);font-size:var(--calcite-font-size--1)}:host *{-webkit-box-sizing:border-box;box-sizing:border-box}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;display:-ms-flexbox;display:flex;width:100%;-ms-flex:1 1 auto;flex:1 1 auto;overflow:hidden;--calcite-min-header-height:calc(var(--calcite-icon-size) * 3);--calcite-panel-max-height:unset;--calcite-panel-width:100%;--calcite-panel-min-width:unset;--calcite-panel-max-width:unset}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.header{margin:0px;display:-ms-flexbox;display:flex;-ms-flex-line-pack:justify;align-content:space-between;-ms-flex-align:center;align-items:center;fill:var(--calcite-ui-text-2);color:var(--calcite-ui-text-2)}.heading{margin:0px;padding:0px;font-weight:var(--calcite-font-weight-medium)}.header .heading{-ms-flex:1 1 auto;flex:1 1 auto;padding:0.5rem}h1.heading{font-size:var(--calcite-font-size-2);line-height:1.5rem}h2.heading{font-size:var(--calcite-font-size-1);line-height:1.5rem}h3.heading{font-size:var(--calcite-font-size-0);line-height:1.25rem}h4.heading,h5.heading{font-size:var(--calcite-font-size--1);line-height:1rem}.container{margin:0px;display:-ms-flexbox;display:flex;width:100%;-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:stretch;align-items:stretch;background-color:var(--calcite-ui-background);padding:0px;max-height:var(--calcite-panel-max-height);width:var(--calcite-panel-width);max-width:var(--calcite-panel-max-width);min-width:var(--calcite-panel-min-width);-webkit-transition:max-height var(--calcite-animation-timing), width var(--calcite-animation-timing);transition:max-height var(--calcite-animation-timing), width var(--calcite-animation-timing)}:host([height-scale=s]){--calcite-panel-max-height:40vh}:host([height-scale=m]){--calcite-panel-max-height:60vh}:host([height-scale=l]){--calcite-panel-max-height:80vh}:host([width-scale=s]){--calcite-panel-width:calc(var(--calcite-panel-width-multiplier) * 12vw);--calcite-panel-max-width:calc(var(--calcite-panel-width-multiplier) * 300px);--calcite-panel-min-width:calc(var(--calcite-panel-width-multiplier) * 150px)}:host([width-scale=m]){--calcite-panel-width:calc(var(--calcite-panel-width-multiplier) * 20vw);--calcite-panel-max-width:calc(var(--calcite-panel-width-multiplier) * 420px);--calcite-panel-min-width:calc(var(--calcite-panel-width-multiplier) * 240px)}:host([width-scale=l]){--calcite-panel-width:calc(var(--calcite-panel-width-multiplier) * 45vw);--calcite-panel-max-width:calc(var(--calcite-panel-width-multiplier) * 680px);--calcite-panel-min-width:calc(var(--calcite-panel-width-multiplier) * 340px)}.container[hidden]{display:none}:host([loading]) .container,:host([disabled]) .container{position:relative}.header{border-bottom:1px solid;position:-webkit-sticky;position:sticky;top:0px;width:100%;-ms-flex-align:stretch;align-items:stretch;-ms-flex-pack:start;justify-content:flex-start;background-color:var(--calcite-ui-foreground-1);border-bottom-color:var(--calcite-ui-border-3);-ms-flex:0 0 auto;flex:0 0 auto}.header-content{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;overflow:hidden;padding-left:0.75rem;padding-right:0.75rem;padding-top:0.875rem;padding-bottom:0.875rem;-webkit-margin-end:auto;margin-inline-end:auto}.header-content .heading,.header-content .summary{display:block;overflow-wrap:break-word;padding:0px}.header-content .heading{margin-left:0px;margin-right:0px;margin-top:0px;margin-bottom:0.25rem;font-size:var(--calcite-font-size-0);line-height:1.25rem;font-weight:var(--calcite-font-weight-medium)}.header-content .heading:only-child{margin-bottom:0px}.header-content .summary{font-size:var(--calcite-font-size--1);line-height:1rem;color:var(--calcite-ui-text-2)}.back-button{border-width:0px;border-style:solid;border-color:var(--calcite-ui-border-3);border-inline-end-width:1px}.header-actions{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-ms-flex-align:stretch;align-items:stretch}.header-actions--end,.menu-container:only-child{-webkit-margin-start:auto;margin-inline-start:auto}.menu-button{position:relative;height:100%;-ms-flex:0 1 auto;flex:0 1 auto;-ms-flex-item-align:stretch;align-self:stretch}.menu{min-width:10rem;-ms-flex-flow:column nowrap;flex-flow:column nowrap}.content-wrapper{overflow:auto}.content-height{height:100%}.content-container{display:-ms-flexbox;display:flex;-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-direction:column;flex-direction:column;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-ms-flex-align:stretch;align-items:stretch;background-color:var(--calcite-ui-background)}.footer{border-top:1px solid;position:-webkit-sticky;position:sticky;bottom:0px;display:-ms-flexbox;display:flex;width:100%;-ms-flex-pack:space-evenly;justify-content:space-evenly;background-color:var(--calcite-ui-foreground-1);border-top-color:var(--calcite-ui-border-3);-ms-flex:0 0 auto;flex:0 0 auto;min-height:3rem;padding:0.5rem}.fab-container{position:-webkit-sticky;position:sticky;bottom:0px;left:0px;right:0px;margin-top:0px;margin-bottom:0px;margin-left:auto;margin-right:auto;display:block;padding:0.5rem;width:-moz-fit-content;width:-webkit-fit-content;width:fit-content}";
- const Panel = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calcitePanelDismiss = createEvent(this, "calcitePanelDismiss", 7);
- this.calcitePanelDismissedChange = createEvent(this, "calcitePanelDismissedChange", 7);
- this.calcitePanelScroll = createEvent(this, "calcitePanelScroll", 7);
- this.calcitePanelBackClick = createEvent(this, "calcitePanelBackClick", 7);
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * Hides the panel.
- */
- this.dismissed = false;
- /**
- * When true, disabled prevents interaction. This state shows items with lower opacity/grayed.
- */
- this.disabled = false;
- /**
- * Displays a close button in the trailing side of the header.
- */
- this.dismissible = false;
- /**
- * Shows a back button in the header.
- */
- this.showBackButton = false;
- /**
- * When true, content is waiting to be loaded. This state shows a busy indicator.
- */
- this.loading = false;
- /**
- * Opens the action menu.
- */
- this.menuOpen = false;
- this.resizeObserver = createObserver("resize", () => this.resizeHandler());
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- this.resizeHandler = () => {
- const { panelScrollEl } = this;
- if (!panelScrollEl ||
- typeof panelScrollEl.scrollHeight !== "number" ||
- typeof panelScrollEl.offsetHeight !== "number") {
- return;
- }
- panelScrollEl.tabIndex = panelScrollEl.scrollHeight > panelScrollEl.offsetHeight ? 0 : -1;
- };
- this.setContainerRef = (node) => {
- this.containerEl = node;
- };
- this.setDismissRef = (node) => {
- this.dismissButtonEl = node;
- };
- this.setBackRef = (node) => {
- this.backButtonEl = node;
- };
- this.panelKeyDownHandler = (event) => {
- if (event.key === "Escape") {
- this.dismiss();
- }
- };
- this.dismiss = () => {
- this.dismissed = true;
- this.calcitePanelDismiss.emit();
- };
- this.panelScrollHandler = () => {
- this.calcitePanelScroll.emit();
- };
- this.backButtonClick = () => {
- this.calcitePanelBackClick.emit();
- };
- this.setPanelScrollEl = (el) => {
- var _a, _b;
- this.panelScrollEl = el;
- (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- if (el) {
- (_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.observe(el);
- this.resizeHandler();
- }
- };
- }
- dismissedHandler() {
- this.calcitePanelDismissedChange.emit();
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentDidRender() {
- updateHostInteraction(this);
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- connectConditionalSlotComponent(this);
- }
- disconnectedCallback() {
- var _a;
- disconnectConditionalSlotComponent(this);
- (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- }
- // --------------------------------------------------------------------------
- //
- // Methods
- //
- // --------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus(focusId) {
- var _a, _b, _c;
- if (focusId === "dismiss-button") {
- (_a = this.dismissButtonEl) === null || _a === void 0 ? void 0 : _a.setFocus();
- return;
- }
- if (focusId === "back-button") {
- (_b = this.backButtonEl) === null || _b === void 0 ? void 0 : _b.setFocus();
- return;
- }
- (_c = this.containerEl) === null || _c === void 0 ? void 0 : _c.focus();
- }
- /** Scrolls panel content to a particular set of coordinates.
- *
- * ```
- * myCalcitePanel.scrollContentTo({
- * left: 0, // Specifies the number of pixels along the X axis to scroll the window or element.
- * top: 0, // Specifies the number of pixels along the Y axis to scroll the window or element
- * behavior: "auto" // Specifies whether the scrolling should animate smoothly (smooth), or happen instantly in a single jump (auto, the default value).
- * });
- * ```
- */
- async scrollContentTo(options) {
- var _a;
- (_a = this.panelScrollEl) === null || _a === void 0 ? void 0 : _a.scrollTo(options);
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- renderBackButton() {
- const { el } = this;
- const rtl = getElementDir(el) === "rtl";
- const { showBackButton, intlBack, backButtonClick } = this;
- const label = intlBack || TEXT$8.back;
- const icon = rtl ? ICONS$5.backRight : ICONS$5.backLeft;
- return showBackButton ? (h("calcite-action", { "aria-label": label, class: CSS$k.backButton, icon: icon, key: "back-button", onClick: backButtonClick, ref: this.setBackRef, scale: "s", slot: SLOTS$c.headerActionsStart, text: label })) : null;
- }
- renderHeaderContent() {
- const { heading, headingLevel, summary } = this;
- const headingNode = heading ? (h(Heading, { class: CSS$k.heading, level: headingLevel || HEADING_LEVEL$4 }, heading)) : null;
- const summaryNode = summary ? h("span", { class: CSS$k.summary }, summary) : null;
- return headingNode || summaryNode ? (h("div", { class: CSS$k.headerContent, key: "header-content" }, headingNode, summaryNode)) : null;
- }
- /**
- * Allows user to override the entire header-content node.
- */
- renderHeaderSlottedContent() {
- return (h("div", { class: CSS$k.headerContent, key: "slotted-header-content" }, h("slot", { name: SLOTS$c.headerContent })));
- }
- renderHeaderStartActions() {
- const { el } = this;
- const hasStartActions = getSlotted(el, SLOTS$c.headerActionsStart);
- return hasStartActions ? (h("div", { class: { [CSS$k.headerActionsStart]: true, [CSS$k.headerActions]: true }, key: "header-actions-start" }, h("slot", { name: SLOTS$c.headerActionsStart }))) : null;
- }
- renderHeaderActionsEnd() {
- const { dismiss, dismissible, el, intlClose } = this;
- const text = intlClose || TEXT$8.close;
- const dismissibleNode = dismissible ? (h("calcite-action", { "aria-label": text, icon: ICONS$5.close, onClick: dismiss, ref: this.setDismissRef, text: text })) : null;
- const slotNode = h("slot", { name: SLOTS$c.headerActionsEnd });
- const hasEndActions = getSlotted(el, SLOTS$c.headerActionsEnd);
- return hasEndActions || dismissibleNode ? (h("div", { class: { [CSS$k.headerActionsEnd]: true, [CSS$k.headerActions]: true }, key: "header-actions-end" }, slotNode, dismissibleNode)) : null;
- }
- renderMenu() {
- const { el, intlOptions, menuOpen } = this;
- const hasMenuItems = getSlotted(el, SLOTS$c.headerMenuActions);
- return hasMenuItems ? (h("calcite-action-menu", { flipPlacements: ["top", "bottom"], key: "menu", label: intlOptions || TEXT$8.options, open: menuOpen, placement: "bottom-end" }, h("calcite-action", { icon: ICONS$5.menu, slot: SLOTS$p.trigger, text: intlOptions || TEXT$8.options }), h("slot", { name: SLOTS$c.headerMenuActions }))) : null;
- }
- renderHeaderNode() {
- const { el, showBackButton } = this;
- const backButtonNode = this.renderBackButton();
- const hasHeaderSlottedContent = getSlotted(el, SLOTS$c.headerContent);
- const headerContentNode = hasHeaderSlottedContent
- ? this.renderHeaderSlottedContent()
- : this.renderHeaderContent();
- const actionsNodeStart = this.renderHeaderStartActions();
- const actionsNodeEnd = this.renderHeaderActionsEnd();
- const headerMenuNode = this.renderMenu();
- return actionsNodeStart ||
- headerContentNode ||
- actionsNodeEnd ||
- headerMenuNode ||
- showBackButton ? (h("header", { class: CSS$k.header }, backButtonNode, actionsNodeStart, headerContentNode, actionsNodeEnd, headerMenuNode)) : null;
- }
- renderFooterNode() {
- const { el } = this;
- const hasFooterSlottedContent = getSlotted(el, SLOTS$c.footer);
- const hasFooterActions = getSlotted(el, SLOTS$c.footerActions);
- return hasFooterSlottedContent || hasFooterActions ? (h("footer", { class: CSS$k.footer, key: "footer" }, hasFooterSlottedContent ? h("slot", { key: "footer-slot", name: SLOTS$c.footer }) : null, hasFooterActions ? h("slot", { key: "footer-actions-slot", name: SLOTS$c.footerActions }) : null)) : null;
- }
- renderContent() {
- const { el } = this;
- const hasFab = getSlotted(el, SLOTS$c.fab);
- const defaultSlotNode = h("slot", { key: "default-slot" });
- const contentWrapperKey = "content-wrapper";
- return hasFab ? (h("div", { class: { [CSS$k.contentWrapper]: true, [CSS$k.contentHeight]: true }, key: contentWrapperKey, onScroll: this.panelScrollHandler, ref: this.setPanelScrollEl }, h("section", { class: CSS$k.contentContainer }, defaultSlotNode), this.renderFab())) : (h("section", { class: { [CSS$k.contentWrapper]: true, [CSS$k.contentContainer]: true }, key: contentWrapperKey, onScroll: this.panelScrollHandler, ref: this.setPanelScrollEl }, defaultSlotNode));
- }
- renderFab() {
- return (h("div", { class: CSS$k.fabContainer }, h("slot", { name: SLOTS$c.fab })));
- }
- render() {
- const { dismissed, dismissible, loading, panelKeyDownHandler } = this;
- const panelNode = (h("article", { "aria-busy": toAriaBoolean(loading), class: CSS$k.container, hidden: dismissible && dismissed, onKeyDown: panelKeyDownHandler, ref: this.setContainerRef, tabIndex: dismissible ? 0 : -1 }, this.renderHeaderNode(), this.renderContent(), this.renderFooterNode()));
- return (h(Fragment, null, loading ? h("calcite-scrim", { loading: loading }) : null, panelNode));
- }
- get el() { return this; }
- static get watchers() { return {
- "dismissed": ["dismissedHandler"]
- }; }
- static get style() { return panelCss; }
- };
- const CSS$j = {
- sticky: "sticky-pos"
- };
- var ICON_TYPES$1;
- (function (ICON_TYPES) {
- ICON_TYPES["circle"] = "circle";
- ICON_TYPES["square"] = "square";
- ICON_TYPES["grip"] = "grip";
- })(ICON_TYPES$1 || (ICON_TYPES$1 = {}));
- const SLOTS$b = {
- menuActions: "menu-actions"
- };
- const CSS$i = {
- heading: "heading",
- container: "container",
- indented: "container--indented"
- };
- const SLOTS$a = {
- parentItem: "parent-item"
- };
- const HEADING_LEVEL$3 = 3;
- function mutationObserverCallback() {
- this.setUpItems();
- this.setUpFilter();
- this.deselectRemovedItems();
- }
- const SUPPORTED_ARROW_KEYS = ["ArrowUp", "ArrowDown"];
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- function initialize() {
- this.setUpItems();
- this.setUpFilter();
- this.emitCalciteListChange = debounce$1(internalCalciteListChangeEvent.bind(this), 0);
- }
- function initializeObserver() {
- var _a;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
- }
- function cleanUpObserver() {
- var _a;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- }
- // --------------------------------------------------------------------------
- //
- // Listeners
- //
- // --------------------------------------------------------------------------
- function calciteListItemChangeHandler(event) {
- const { selectedValues } = this;
- const { item, value, selected, shiftPressed } = event.detail;
- if (selected) {
- if (this.multiple && shiftPressed) {
- this.selectSiblings(item);
- }
- if (!this.multiple) {
- this.deselectSiblingItems(item);
- }
- selectedValues.set(value, item);
- }
- else {
- selectedValues.delete(value);
- if (this.multiple && shiftPressed) {
- this.selectSiblings(item, true);
- }
- }
- if (!this.multiple) {
- toggleSingleSelectItemTabbing(item, selected);
- if (selected) {
- focusElement(item);
- }
- }
- this.lastSelectedItem = item;
- this.emitCalciteListChange();
- }
- function calciteListItemValueChangeHandler(event) {
- event.stopPropagation();
- const oldValue = event.detail.oldValue;
- const selectedValues = this.selectedValues;
- if (selectedValues.has(oldValue)) {
- const item = selectedValues.get(oldValue);
- selectedValues.delete(oldValue);
- selectedValues.set(event.detail.newValue, item);
- }
- }
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- function isValidNavigationKey(key) {
- return !!SUPPORTED_ARROW_KEYS.find((k) => k === key);
- }
- function calciteListFocusOutHandler(event) {
- const { el, items, multiple, selectedValues } = this;
- if (multiple) {
- return;
- }
- const focusedInside = el.contains(event.relatedTarget);
- if (focusedInside) {
- return;
- }
- filterOutDisabled(items).forEach((item) => {
- toggleSingleSelectItemTabbing(item, selectedValues.size === 0 ? item.contains(event.target) || event.target === item : item.selected);
- });
- }
- function keyDownHandler(event) {
- const { key, target } = event;
- if (!isValidNavigationKey(key)) {
- return;
- }
- const { items, multiple, selectionFollowsFocus } = this;
- const { length: totalItems } = items;
- const currentIndex = items.indexOf(target);
- if (!totalItems || currentIndex === -1) {
- return;
- }
- event.preventDefault();
- const index = moveItemIndex(this, target, key === "ArrowUp" ? "up" : "down");
- const item = items[index];
- items.forEach((i) => toggleSingleSelectItemTabbing(i, i === item));
- if (!multiple && selectionFollowsFocus) {
- item.selected = true;
- }
- focusElement(item);
- }
- function moveItemIndex(list, item, direction) {
- const { items } = list;
- const { length: totalItems } = items;
- const currentIndex = items.indexOf(item);
- const directionFactor = direction === "up" ? -1 : 1;
- let moveOffset = 1;
- let index = getRoundRobinIndex(currentIndex + directionFactor * moveOffset++, totalItems);
- const firstMovedIndex = index;
- while (items[index].disabled) {
- index = getRoundRobinIndex(currentIndex + directionFactor * moveOffset++, totalItems);
- if (index === firstMovedIndex) {
- break;
- }
- }
- return index;
- }
- function filterOutDisabled(items) {
- return items.filter((item) => !item.disabled);
- }
- function internalCalciteListChangeEvent() {
- this.calciteListChange.emit(this.selectedValues);
- }
- function removeItem(event) {
- if (event.defaultPrevented) {
- return;
- }
- const item = event.target;
- const selectedValues = this.selectedValues;
- if (item.parentElement.tagName === "CALCITE-PICK-LIST-GROUP" && item.slot === SLOTS$a.parentItem) {
- item.parentElement.remove();
- Array.from(item.parentElement.children).forEach((item) => selectedValues.delete(item.value));
- }
- else {
- item.remove();
- selectedValues.delete(item.value);
- }
- this.emitCalciteListChange();
- }
- function toggleSingleSelectItemTabbing(item, selectable) {
- if (item.disabled) {
- return;
- }
- // using attribute intentionally
- if (selectable) {
- item.removeAttribute("tabindex");
- }
- else {
- item.setAttribute("tabindex", "-1");
- }
- }
- async function setFocus(focusId) {
- var _a;
- if (this.filterEnabled && focusId === "filter") {
- await focusElement(this.filterEl);
- return;
- }
- const { items, multiple, selectionFollowsFocus } = this;
- if (items.length === 0) {
- return;
- }
- if (multiple) {
- return (_a = filterOutDisabled(items)[0]) === null || _a === void 0 ? void 0 : _a.setFocus();
- }
- const filtered = filterOutDisabled(items);
- const focusTarget = filtered.find((item) => item.selected) || filtered[0];
- if (selectionFollowsFocus && focusTarget) {
- focusTarget.selected = true;
- }
- return focusTarget.setFocus();
- }
- function setUpItems(tagName) {
- this.items = Array.from(this.el.querySelectorAll(tagName));
- let hasSelected = false;
- const { items } = this;
- items.forEach((item) => {
- item.icon = this.getIconType();
- if (!this.multiple) {
- item.disableDeselect = true;
- toggleSingleSelectItemTabbing(item, false);
- }
- if (item.selected) {
- hasSelected = true;
- toggleSingleSelectItemTabbing(item, true);
- this.selectedValues.set(item.value, item);
- }
- });
- const [first] = items;
- if (!hasSelected && first && !first.disabled) {
- toggleSingleSelectItemTabbing(first, true);
- }
- }
- function deselectRemovedItems() {
- const selectedValues = this.selectedValues;
- const itemValues = this.items.map(({ value }) => value);
- selectedValues.forEach((selectedItem) => {
- if (!itemValues.includes(selectedItem.value)) {
- this.selectedValues.delete(selectedItem.value);
- }
- });
- }
- function deselectSiblingItems(item) {
- this.items.forEach((currentItem) => {
- if (currentItem.value !== item.value) {
- currentItem.toggleSelected(false);
- if (this.selectedValues.has(currentItem.value)) {
- this.selectedValues.delete(currentItem.value);
- }
- }
- });
- }
- function selectSiblings(item, deselect = false) {
- if (!this.lastSelectedItem) {
- return;
- }
- const { items } = this;
- const start = items.findIndex((currentItem) => {
- return currentItem.value === this.lastSelectedItem.value;
- });
- const end = items.findIndex((currentItem) => {
- return currentItem.value === item.value;
- });
- items.slice(Math.min(start, end), Math.max(start, end)).forEach((currentItem) => {
- currentItem.toggleSelected(!deselect);
- if (!deselect) {
- this.selectedValues.set(currentItem.value, currentItem);
- }
- else {
- this.selectedValues.delete(currentItem.value);
- }
- });
- }
- let groups;
- function handleFilter(event) {
- const { filteredItems } = event.currentTarget;
- const values = filteredItems.map((item) => item.value);
- let hasSelectedMatch = false;
- if (!groups) {
- groups = new Set();
- }
- const matchedItems = this.items.filter((item) => {
- const parent = item.parentElement;
- const grouped = parent.matches("calcite-pick-list-group");
- if (grouped) {
- groups.add(parent);
- }
- const matches = values.includes(item.value);
- item.hidden = !matches;
- if (!hasSelectedMatch) {
- hasSelectedMatch = matches && item.selected;
- }
- return matches;
- });
- groups.forEach((group) => {
- const hasAtLeastOneMatch = matchedItems.some((item) => group.contains(item));
- group.hidden = !hasAtLeastOneMatch;
- if (!hasAtLeastOneMatch) {
- return;
- }
- const parentItem = getSlotted(group, "parent-item");
- if (parentItem) {
- parentItem.hidden = false;
- if (matchedItems.includes(parentItem)) {
- Array.from(group.children).forEach((child) => (child.hidden = false));
- }
- }
- });
- groups.clear();
- if (matchedItems.length > 0 && !hasSelectedMatch && !this.multiple) {
- toggleSingleSelectItemTabbing(matchedItems[0], true);
- }
- }
- function getItemData() {
- return this.items.map((item) => ({
- label: item.label,
- description: item.description,
- metadata: item.metadata,
- value: item.value
- }));
- }
- var __rest = (undefined && undefined.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
- };
- const List = (_a) => {
- var { props: { disabled, loading, filterEnabled, dataForFilter, handleFilter, filterPlaceholder, setFilterEl } } = _a, rest = __rest(_a, ["props"]);
- const defaultSlot = h("slot", null);
- return (h(Host, Object.assign({ "aria-busy": toAriaBoolean(loading), role: "menu" }, rest),
- h("section", null,
- h("header", { class: { [CSS$j.sticky]: true } },
- filterEnabled ? (h("calcite-filter", { "aria-label": filterPlaceholder, disabled: loading || disabled, items: dataForFilter, onCalciteFilterChange: handleFilter, placeholder: filterPlaceholder, ref: setFilterEl })) : null,
- h("slot", { name: SLOTS$b.menuActions })),
- loading ? h("calcite-scrim", { loading: loading }) : null,
- defaultSlot)));
- };
- const pickListCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;-ms-flex-negative:0;flex-shrink:0;-ms-flex-positive:1;flex-grow:1;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:stretch;align-items:stretch;background-color:transparent;font-size:var(--calcite-font-size--1);line-height:1rem;color:var(--calcite-ui-text-2)}:host *{-webkit-box-sizing:border-box;box-sizing:border-box}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host([filter-enabled]) header{margin-bottom:0.25rem;display:-ms-flexbox;display:flex;-ms-flex-align:stretch;align-items:stretch;-ms-flex-pack:end;justify-content:flex-end;background-color:var(--calcite-ui-foreground-1);--tw-shadow:0 1px 0 var(--calcite-ui-border-3);--tw-shadow-colored:0 1px 0 var(--tw-shadow-color);-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}:host([filter-enabled]) header.sticky-pos{position:-webkit-sticky;position:sticky;top:0px;z-index:1}calcite-filter{margin-bottom:0px}:host([loading][disabled]){min-height:2rem}";
- const PickList = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteListChange = createEvent(this, "calciteListChange", 7);
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * When true, disabled prevents interaction. This state shows items with lower opacity/grayed.
- */
- this.disabled = false;
- /**
- * When true, an input appears at the top of the list that can be used by end users to filter items in the list.
- */
- this.filterEnabled = false;
- /**
- * When true, content is waiting to be loaded. This state shows a busy indicator.
- */
- this.loading = false;
- /**
- * Multiple works similar to standard radio buttons and checkboxes.
- * When true, a user can select multiple items at a time.
- * When false, only a single item can be selected at a time
- * and selecting a new item will deselect any other selected items.
- */
- this.multiple = false;
- /**
- * When true and single-selection is enabled, the selection will change when navigating items via the keyboard.
- */
- this.selectionFollowsFocus = false;
- // --------------------------------------------------------------------------
- //
- // Private Properties
- //
- // --------------------------------------------------------------------------
- this.selectedValues = new Map();
- this.dataForFilter = [];
- this.lastSelectedItem = null;
- this.mutationObserver = createObserver("mutation", mutationObserverCallback.bind(this));
- this.setFilterEl = (el) => {
- this.filterEl = el;
- };
- this.deselectRemovedItems = deselectRemovedItems.bind(this);
- this.deselectSiblingItems = deselectSiblingItems.bind(this);
- this.selectSiblings = selectSiblings.bind(this);
- this.handleFilter = handleFilter.bind(this);
- this.getItemData = getItemData.bind(this);
- this.keyDownHandler = keyDownHandler.bind(this);
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- initialize.call(this);
- initializeObserver.call(this);
- }
- disconnectedCallback() {
- cleanUpObserver.call(this);
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- calciteListItemRemoveHandler(event) {
- removeItem.call(this, event);
- }
- calciteListItemChangeHandler(event) {
- calciteListItemChangeHandler.call(this, event);
- }
- calciteListItemPropsChangeHandler(event) {
- event.stopPropagation();
- this.setUpFilter();
- }
- calciteListItemValueChangeHandler(event) {
- calciteListItemValueChangeHandler.call(this, event);
- }
- calciteListFocusOutHandler(event) {
- calciteListFocusOutHandler.call(this, event);
- }
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- setUpItems() {
- setUpItems.call(this, "calcite-pick-list-item");
- }
- setUpFilter() {
- if (this.filterEnabled) {
- this.dataForFilter = this.getItemData();
- }
- }
- // --------------------------------------------------------------------------
- //
- // Public Methods
- //
- // --------------------------------------------------------------------------
- /** Returns the currently selected items */
- async getSelectedItems() {
- return this.selectedValues;
- }
- /** Sets focus on the component. */
- async setFocus(focusId) {
- return setFocus.call(this, focusId);
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- getIconType() {
- return this.multiple ? ICON_TYPES$1.square : ICON_TYPES$1.circle;
- }
- render() {
- return h(List, { onKeyDown: this.keyDownHandler, props: this });
- }
- get el() { return this; }
- static get style() { return pickListCss; }
- };
- const pickListGroupCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{margin-bottom:0.25rem;-webkit-box-sizing:border-box;box-sizing:border-box;display:block;background-color:transparent;font-size:var(--calcite-font-size--1);color:var(--calcite-ui-text-2)}:host *{-webkit-box-sizing:border-box;box-sizing:border-box}:host(:last-child){margin-bottom:0px}.header{margin:0px;display:-ms-flexbox;display:flex;-ms-flex-line-pack:justify;align-content:space-between;-ms-flex-align:center;align-items:center;fill:var(--calcite-ui-text-2);color:var(--calcite-ui-text-2)}.heading{margin:0px;padding:0px;font-weight:var(--calcite-font-weight-medium)}.header .heading{-ms-flex:1 1 auto;flex:1 1 auto;padding:0.5rem}h1.heading{font-size:var(--calcite-font-size-2);line-height:1.5rem}h2.heading{font-size:var(--calcite-font-size-1);line-height:1.5rem}h3.heading{font-size:var(--calcite-font-size-0);line-height:1.25rem}h4.heading,h5.heading{font-size:var(--calcite-font-size--1);line-height:1rem}h3.heading{margin-top:0.5rem;margin-bottom:0.5rem;margin-left:1rem;margin-right:1rem;font-size:var(--calcite-font-size--1);line-height:1.375;color:var(--calcite-ui-text-3)}.container--indented{-webkit-margin-start:1.5rem;margin-inline-start:1.5rem}";
- const PickListGroup = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- connectConditionalSlotComponent(this);
- }
- disconnectedCallback() {
- disconnectConditionalSlotComponent(this);
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- render() {
- var _a;
- const { el, groupTitle, headingLevel } = this;
- const hasParentItem = getSlotted(el, SLOTS$a.parentItem) !== null;
- const sectionClasses = {
- [CSS$i.container]: true,
- [CSS$i.indented]: hasParentItem
- };
- const title = groupTitle;
- const parentLevel = (_a = el.closest("calcite-pick-list")) === null || _a === void 0 ? void 0 : _a.headingLevel;
- const relativeLevel = parentLevel ? constrainHeadingLevel(parentLevel + 1) : null;
- const level = headingLevel || relativeLevel || HEADING_LEVEL$3;
- return (h(Fragment, null, title ? (h(Heading, { class: CSS$i.heading, level: level }, title)) : null, h("slot", { name: SLOTS$a.parentItem }), h("section", { class: sectionClasses }, h("slot", null))));
- }
- get el() { return this; }
- static get style() { return pickListGroupCss; }
- };
- const CSS$h = {
- actions: "actions",
- actionsEnd: "actions--end",
- actionsStart: "actions--start",
- description: "description",
- handle: "handle",
- handleActivated: "handle--activated",
- highlight: "highlight",
- icon: "icon",
- iconDot: "icon-dot",
- label: "label",
- remove: "remove",
- title: "title",
- textContainer: "text-container"
- };
- const ICONS$4 = {
- checked: "check",
- remove: "x"
- };
- const SLOTS$9 = {
- actionsEnd: "actions-end",
- actionsStart: "actions-start"
- };
- const TEXT$7 = {
- remove: "Remove"
- };
- const pickListItemCss = "@charset \"UTF-8\";@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{margin:0px;margin-bottom:1px;-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;-ms-flex-align:stretch;align-items:stretch;background-color:var(--calcite-ui-foreground-1);font-size:var(--calcite-font-size--1);line-height:1rem;color:var(--calcite-ui-text-1);--tw-shadow:0 1px 0 var(--calcite-ui-border-3);--tw-shadow-colored:0 1px 0 var(--tw-shadow-color);-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);-webkit-transition:background-color var(--calcite-animation-timing);transition:background-color var(--calcite-animation-timing);-webkit-animation:calcite-fade-in var(--calcite-animation-timing);animation:calcite-fade-in var(--calcite-animation-timing)}:host *{-webkit-box-sizing:border-box;box-sizing:border-box}.label{display:-ms-flexbox;display:flex;-ms-flex:1 1 auto;flex:1 1 auto;cursor:pointer;-ms-flex-align:center;align-items:center;background-color:transparent;outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out}.label:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.label:hover{background-color:var(--calcite-ui-foreground-2)}:host([non-interactive]:hover){background-color:var(--calcite-ui-foreground-1)}:host([non-interactive]) .label,:host([non-interactive]) .icon{pointer-events:none}.icon{margin-top:0px;margin-bottom:0px;display:-ms-flexbox;display:flex;cursor:pointer;-ms-flex-align:center;align-items:center;padding:0.25rem;color:var(--calcite-ui-brand);-ms-flex:0 0 auto;flex:0 0 auto;line-height:0}.icon:hover{background-color:var(--calcite-ui-foreground-2)}.icon-dot{display:-ms-flexbox;display:flex;width:1.5rem;-ms-flex-align:center;align-items:center;padding:0.5rem}.icon-dot:before{opacity:0;content:\"•\"}.icon calcite-icon{opacity:0}:host([selected]) .icon-dot:before,:host([selected]) .icon calcite-icon{-webkit-transition:opacity var(--calcite-animation-timing);transition:opacity var(--calcite-animation-timing);opacity:1}.text-container{pointer-events:none;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-wrap:nowrap;flex-wrap:nowrap;overflow:hidden;padding-top:0.5rem;padding-bottom:0.5rem;padding-left:0.75rem;padding-right:0.75rem;font-size:var(--calcite-font-size--2);line-height:1.375;word-wrap:break-word;word-break:break-word}.title{font-weight:var(--calcite-font-weight-normal);color:var(--calcite-ui-text-1)}.description{margin-top:0.125rem;font-weight:var(--calcite-font-weight-normal);color:var(--calcite-ui-text-3)}.actions{margin:0px;display:-ms-flexbox;display:flex;-ms-flex:0 1 auto;flex:0 1 auto;-ms-flex-align:stretch;align-items:stretch;-ms-flex-pack:end;justify-content:flex-end}.actions--start~.label{-webkit-padding-start:0.25rem;padding-inline-start:0.25rem}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}";
- const PickListItem = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteListItemChange = createEvent(this, "calciteListItemChange", 7);
- this.calciteListItemRemove = createEvent(this, "calciteListItemRemove", 7);
- this.calciteListItemPropsChange = createEvent(this, "calciteListItemPropsChange", 7);
- this.calciteListItemValueChange = createEvent(this, "calciteListItemValueChange", 7);
- /**
- * When true, the item cannot be clicked and is visually muted.
- */
- this.disabled = false;
- /**
- * When false, the item cannot be deselected by user interaction.
- */
- this.disableDeselect = false;
- /**
- * @internal When true, the item cannot be selected by user interaction.
- */
- this.nonInteractive = false;
- /**
- * Determines the icon SVG symbol that will be shown. Options are circle, square, grip or null.
- * @see [ICON_TYPES](https://github.com/Esri/calcite-components/blob/master/src/components/pick-list/resources.ts#L5)
- */
- this.icon = null;
- /**
- * Set this to true to display a remove action that removes the item from the list.
- */
- this.removable = false;
- /**
- * Set this to true to pre-select an item. Toggles when an item is checked/unchecked.
- */
- this.selected = false;
- /**
- * Used as an accessible label (aria-label) for the "remove item" action. Only applicable if removable is true.
- * @default "Remove"
- */
- this.intlRemove = TEXT$7.remove;
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- this.pickListClickHandler = (event) => {
- if (this.disabled || (this.disableDeselect && this.selected) || this.nonInteractive) {
- return;
- }
- this.shiftPressed = event.shiftKey;
- this.selected = !this.selected;
- };
- this.pickListKeyDownHandler = (event) => {
- if (event.key === " ") {
- event.preventDefault();
- if ((this.disableDeselect && this.selected) || this.nonInteractive) {
- return;
- }
- this.selected = !this.selected;
- }
- };
- this.removeClickHandler = () => {
- this.calciteListItemRemove.emit();
- };
- }
- descriptionWatchHandler() {
- this.calciteListItemPropsChange.emit();
- }
- labelWatchHandler() {
- this.calciteListItemPropsChange.emit();
- }
- metadataWatchHandler() {
- this.calciteListItemPropsChange.emit();
- }
- selectedWatchHandler() {
- this.calciteListItemChange.emit({
- item: this.el,
- value: this.value,
- selected: this.selected,
- shiftPressed: this.shiftPressed
- });
- this.shiftPressed = false;
- }
- valueWatchHandler(newValue, oldValue) {
- this.calciteListItemValueChange.emit({ oldValue, newValue });
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- connectConditionalSlotComponent(this);
- }
- disconnectedCallback() {
- disconnectConditionalSlotComponent(this);
- }
- componentDidRender() {
- updateHostInteraction(this, this.el.closest("calcite-pick-list") ? "managed" : false);
- }
- // --------------------------------------------------------------------------
- //
- // Public Methods
- //
- // --------------------------------------------------------------------------
- /**
- * Used to toggle the selection state. By default this won't trigger an event.
- * The first argument allows the value to be coerced, rather than swapping values.
- */
- async toggleSelected(coerce) {
- this.selected = typeof coerce === "boolean" ? coerce : !this.selected;
- }
- /** Sets focus on the component. */
- async setFocus() {
- var _a;
- (_a = this.focusEl) === null || _a === void 0 ? void 0 : _a.focus();
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- renderIcon() {
- const { icon } = this;
- if (!icon) {
- return null;
- }
- return (h("span", { class: {
- [CSS$h.icon]: true,
- [CSS$h.iconDot]: icon === ICON_TYPES$1.circle
- }, onClick: this.pickListClickHandler }, icon === ICON_TYPES$1.square ? h("calcite-icon", { icon: ICONS$4.checked, scale: "s" }) : null));
- }
- renderRemoveAction() {
- return this.removable ? (h("calcite-action", { class: CSS$h.remove, icon: ICONS$4.remove, onCalciteActionClick: this.removeClickHandler, slot: SLOTS$9.actionsEnd, text: this.intlRemove })) : null;
- }
- renderActionsStart() {
- const { el } = this;
- const hasActionsStart = getSlotted(el, SLOTS$9.actionsStart);
- return hasActionsStart ? (h("div", { class: { [CSS$h.actions]: true, [CSS$h.actionsStart]: true } }, h("slot", { name: SLOTS$9.actionsStart }))) : null;
- }
- renderActionsEnd() {
- const { el, removable } = this;
- const hasActionsEnd = getSlotted(el, SLOTS$9.actionsEnd);
- return hasActionsEnd || removable ? (h("div", { class: { [CSS$h.actions]: true, [CSS$h.actionsEnd]: true } }, h("slot", { name: SLOTS$9.actionsEnd }), this.renderRemoveAction())) : null;
- }
- render() {
- const { description, label } = this;
- return (h(Fragment, null, this.renderIcon(), this.renderActionsStart(), h("label", { "aria-label": label, class: CSS$h.label, onClick: this.pickListClickHandler, onKeyDown: this.pickListKeyDownHandler, ref: (focusEl) => (this.focusEl = focusEl), tabIndex: 0 }, h("div", { "aria-checked": toAriaBoolean(this.selected), class: CSS$h.textContainer, role: "menuitemcheckbox" }, h("span", { class: CSS$h.title }, label), description ? h("span", { class: CSS$h.description }, description) : null)), this.renderActionsEnd()));
- }
- get el() { return this; }
- static get watchers() { return {
- "description": ["descriptionWatchHandler"],
- "label": ["labelWatchHandler"],
- "metadata": ["metadataWatchHandler"],
- "selected": ["selectedWatchHandler"],
- "value": ["valueWatchHandler"]
- }; }
- static get style() { return pickListItemCss; }
- };
- const CSS$g = {
- container: "container",
- arrow: "arrow",
- imageContainer: "image-container",
- closeButtonContainer: "close-button-container",
- closeButton: "close-button",
- content: "content",
- hasHeader: "has-header",
- header: "header",
- headerContent: "header-content",
- heading: "heading"
- };
- const TEXT$6 = {
- close: "Close"
- };
- const defaultPopoverPlacement = "auto";
- const ARIA_CONTROLS = "aria-controls";
- const ARIA_EXPANDED = "aria-expanded";
- const HEADING_LEVEL$2 = 2;
- class PopoverManager$1 {
- constructor() {
- // --------------------------------------------------------------------------
- //
- // Private Properties
- //
- // --------------------------------------------------------------------------
- this.registeredElements = new WeakMap();
- this.registeredElementCount = 0;
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- this.queryPopover = (composedPath) => {
- const { registeredElements } = this;
- const registeredElement = composedPath.find((pathEl) => registeredElements.has(pathEl));
- return registeredElements.get(registeredElement);
- };
- this.clickHandler = (event) => {
- const composedPath = event.composedPath();
- const popover = this.queryPopover(composedPath);
- if (popover) {
- popover.toggle();
- return;
- }
- queryElementsRoots(event.target, "calcite-popover")
- .filter((popover) => popover.autoClose && popover.open && !composedPath.includes(popover))
- .forEach((popover) => popover.toggle(false));
- };
- }
- // --------------------------------------------------------------------------
- //
- // Public Methods
- //
- // --------------------------------------------------------------------------
- registerElement(referenceEl, popover) {
- this.registeredElementCount++;
- this.registeredElements.set(referenceEl, popover);
- if (this.registeredElementCount === 1) {
- this.addListeners();
- }
- }
- unregisterElement(referenceEl) {
- if (this.registeredElements.delete(referenceEl)) {
- this.registeredElementCount--;
- }
- if (this.registeredElementCount === 0) {
- this.removeListeners();
- }
- }
- addListeners() {
- document.addEventListener("pointerdown", this.clickHandler, { capture: true });
- }
- removeListeners() {
- document.removeEventListener("pointerdown", this.clickHandler, { capture: true });
- }
- }
- const popoverCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:block;position:absolute;z-index:900;-webkit-transform:scale(0);transform:scale(0)}.calcite-popper-anim{position:relative;z-index:1;-webkit-transition:var(--calcite-popper-transition);transition:var(--calcite-popper-transition);visibility:hidden;-webkit-transition-property:visibility, opacity, -webkit-transform;transition-property:visibility, opacity, -webkit-transform;transition-property:transform, visibility, opacity;transition-property:transform, visibility, opacity, -webkit-transform;opacity:0;-webkit-box-shadow:0 0 16px 0 rgba(0, 0, 0, 0.16);box-shadow:0 0 16px 0 rgba(0, 0, 0, 0.16);border-radius:0.25rem}:host([data-popper-placement^=bottom]) .calcite-popper-anim{-webkit-transform:translateY(-5px);transform:translateY(-5px)}:host([data-popper-placement^=top]) .calcite-popper-anim{-webkit-transform:translateY(5px);transform:translateY(5px)}:host([data-popper-placement^=left]) .calcite-popper-anim{-webkit-transform:translateX(5px);transform:translateX(5px)}:host([data-popper-placement^=right]) .calcite-popper-anim{-webkit-transform:translateX(-5px);transform:translateX(-5px)}:host([data-popper-placement]) .calcite-popper-anim--active{opacity:1;visibility:visible;-webkit-transform:translate(0);transform:translate(0)}:host([data-popper-placement][data-popper-reference-hidden]){pointer-events:none;opacity:0}.arrow,.arrow::before{position:absolute;width:8px;height:8px;z-index:-1}.arrow::before{content:\"\";--tw-shadow:0 4px 8px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);--tw-shadow-colored:0 4px 8px -1px var(--tw-shadow-color), 0 2px 4px -1px var(--tw-shadow-color);-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);-webkit-transform:rotate(45deg);transform:rotate(45deg);background:var(--calcite-ui-foreground-1)}:host([data-popper-placement^=top]) .arrow{bottom:-4px}:host([data-popper-placement^=bottom]) .arrow{top:-4px}:host([data-popper-placement^=left]) .arrow{right:-4px}:host([data-popper-placement^=right]) .arrow{left:-4px}:host{pointer-events:none}:host([open]){pointer-events:initial}.calcite-popper-anim{border-radius:0.25rem;border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-3);background-color:var(--calcite-ui-foreground-1)}.arrow::before{outline:1px solid var(--calcite-ui-border-3)}.header{display:-ms-flexbox;display:flex;-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-align:stretch;align-items:stretch;-ms-flex-pack:start;justify-content:flex-start;border-width:0px;border-bottom-width:1px;border-style:solid;background-color:var(--calcite-ui-foreground-1);border-bottom-color:var(--calcite-ui-border-3)}.heading{margin:0px;display:block;-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-item-align:center;align-self:center;white-space:normal;padding-left:1rem;padding-right:1rem;padding-top:0.75rem;padding-bottom:0.75rem;font-size:var(--calcite-font-size-0);line-height:1.375;font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1);word-wrap:break-word;word-break:break-word}.container{position:relative;display:-ms-flexbox;display:flex;height:100%;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:nowrap;flex-wrap:nowrap;border-radius:0.25rem;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-1)}.container.has-header{-ms-flex-direction:column;flex-direction:column}.content{display:-ms-flexbox;display:flex;height:100%;width:100%;-ms-flex-direction:column;flex-direction:column;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-ms-flex-item-align:center;align-self:center;word-wrap:break-word;word-break:break-word}.close-button-container{display:-ms-flexbox;display:flex;overflow:hidden;-ms-flex:0 0 auto;flex:0 0 auto;border-start-end-radius:0.25rem;border-end-end-radius:0.25rem}::slotted(calcite-panel),::slotted(calcite-flow){height:100%}";
- const manager$1 = new PopoverManager$1();
- const Popover = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calcitePopoverClose = createEvent(this, "calcitePopoverClose", 7);
- this.calcitePopoverOpen = createEvent(this, "calcitePopoverOpen", 7);
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * Automatically closes any currently open popovers when clicking outside of a popover.
- */
- this.autoClose = false;
- /**
- * Display a close button within the Popover.
- * @deprecated use dismissible instead.
- */
- this.closeButton = false;
- /**
- * Display a close button within the Popover.
- */
- this.dismissible = false;
- /**
- * Prevents flipping the popover's placement when it starts to overlap its reference element.
- */
- this.disableFlip = false;
- /**
- * Removes the caret pointer.
- */
- this.disablePointer = false;
- /**
- * Offset the position of the popover away from the reference element.
- * @default 6
- */
- this.offsetDistance = defaultOffsetDistance;
- /**
- * Offset the position of the popover along the reference element.
- */
- this.offsetSkidding = 0;
- /**
- * Display and position the component.
- */
- this.open = false;
- /** Describes the type of positioning to use for the overlaid content. If your element is in a fixed container, use the 'fixed' value. */
- this.overlayPositioning = "absolute";
- /**
- * Determines where the component will be positioned relative to the referenceElement.
- * @see [PopperPlacement](https://github.com/Esri/calcite-components/blob/master/src/utils/popper.ts#L25)
- */
- this.placement = defaultPopoverPlacement;
- /** Text for close button.
- * @default "Close"
- */
- this.intlClose = TEXT$6.close;
- this.guid = `calcite-popover-${guid()}`;
- this.activeTransitionProp = "opacity";
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- this.setFilteredPlacements = () => {
- const { el, flipPlacements } = this;
- this.filteredFlipPlacements = flipPlacements
- ? filterComputedPlacements(flipPlacements, el)
- : null;
- };
- this.setUpReferenceElement = () => {
- this.removeReferences();
- this.effectiveReferenceElement = this.getReferenceElement();
- const { el, referenceElement, effectiveReferenceElement } = this;
- if (referenceElement && !effectiveReferenceElement) {
- console.warn(`${el.tagName}: reference-element id "${referenceElement}" was not found.`, {
- el
- });
- }
- this.addReferences();
- this.createPopper();
- };
- this.getId = () => {
- return this.el.id || this.guid;
- };
- this.setExpandedAttr = () => {
- const { effectiveReferenceElement, open } = this;
- if (!effectiveReferenceElement) {
- return;
- }
- effectiveReferenceElement.setAttribute(ARIA_EXPANDED, toAriaBoolean(open));
- };
- this.addReferences = () => {
- const { effectiveReferenceElement } = this;
- if (!effectiveReferenceElement) {
- return;
- }
- const id = this.getId();
- effectiveReferenceElement.setAttribute(ARIA_CONTROLS, id);
- manager$1.registerElement(effectiveReferenceElement, this.el);
- this.setExpandedAttr();
- };
- this.removeReferences = () => {
- const { effectiveReferenceElement } = this;
- if (!effectiveReferenceElement) {
- return;
- }
- effectiveReferenceElement.removeAttribute(ARIA_CONTROLS);
- effectiveReferenceElement.removeAttribute(ARIA_EXPANDED);
- manager$1.unregisterElement(effectiveReferenceElement);
- };
- this.hide = () => {
- this.open = false;
- };
- this.transitionEnd = (event) => {
- if (event.propertyName === this.activeTransitionProp) {
- this.open ? this.calcitePopoverOpen.emit() : this.calcitePopoverClose.emit();
- }
- };
- }
- flipPlacementsHandler() {
- this.setFilteredPlacements();
- }
- offsetDistanceOffsetHandler() {
- this.reposition();
- }
- offsetSkiddingHandler() {
- this.reposition();
- }
- openHandler() {
- this.reposition();
- this.setExpandedAttr();
- }
- placementHandler() {
- this.reposition();
- }
- referenceElementHandler() {
- this.setUpReferenceElement();
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- this.setFilteredPlacements();
- }
- componentWillLoad() {
- this.setUpReferenceElement();
- }
- componentDidLoad() {
- this.reposition();
- }
- disconnectedCallback() {
- this.removeReferences();
- this.destroyPopper();
- }
- // --------------------------------------------------------------------------
- //
- // Public Methods
- //
- // --------------------------------------------------------------------------
- /** Updates the position of the component. */
- async reposition() {
- const { popper, el, placement } = this;
- const modifiers = this.getModifiers();
- popper
- ? await updatePopper({
- el,
- modifiers,
- placement,
- popper
- })
- : this.createPopper();
- }
- /** Sets focus on the component. */
- async setFocus(focusId) {
- var _a;
- const { closeButtonEl } = this;
- if (focusId === "close-button" && closeButtonEl) {
- forceUpdate(closeButtonEl);
- closeButtonEl.setFocus();
- return;
- }
- (_a = this.el) === null || _a === void 0 ? void 0 : _a.focus();
- }
- /** Toggles the popover's open property. */
- async toggle(value = !this.open) {
- this.open = value;
- }
- getReferenceElement() {
- const { referenceElement, el } = this;
- return ((typeof referenceElement === "string"
- ? queryElementRoots(el, { id: referenceElement })
- : referenceElement) || null);
- }
- getModifiers() {
- const { arrowEl, disableFlip, disablePointer, offsetDistance, offsetSkidding, filteredFlipPlacements } = this;
- const flipModifier = {
- name: "flip",
- enabled: !disableFlip
- };
- if (filteredFlipPlacements) {
- flipModifier.options = {
- fallbackPlacements: filteredFlipPlacements
- };
- }
- const arrowModifier = {
- name: "arrow",
- enabled: !disablePointer
- };
- if (arrowEl) {
- arrowModifier.options = {
- element: arrowEl
- };
- }
- const offsetModifier = {
- name: "offset",
- enabled: true,
- options: {
- offset: [offsetSkidding, offsetDistance]
- }
- };
- const eventListenerModifier = {
- name: "eventListeners",
- enabled: this.open
- };
- return [arrowModifier, flipModifier, offsetModifier, eventListenerModifier];
- }
- createPopper() {
- this.destroyPopper();
- const { el, placement, effectiveReferenceElement: referenceEl, overlayPositioning } = this;
- const modifiers = this.getModifiers();
- this.popper = createPopper({
- el,
- modifiers,
- overlayPositioning,
- placement,
- referenceEl
- });
- }
- destroyPopper() {
- const { popper } = this;
- if (popper) {
- popper.destroy();
- }
- this.popper = null;
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- renderCloseButton() {
- const { dismissible, closeButton, intlClose } = this;
- return dismissible || closeButton ? (h("div", { class: CSS$g.closeButtonContainer }, h("calcite-action", { class: CSS$g.closeButton, onClick: this.hide, ref: (closeButtonEl) => (this.closeButtonEl = closeButtonEl), text: intlClose }, h("calcite-icon", { icon: "x", scale: "m" })))) : null;
- }
- renderHeader() {
- const { heading, headingLevel } = this;
- const headingNode = heading ? (h(Heading, { class: CSS$g.heading, level: headingLevel || HEADING_LEVEL$2 }, heading)) : null;
- return headingNode ? (h("div", { class: CSS$g.header }, headingNode, this.renderCloseButton())) : null;
- }
- render() {
- const { effectiveReferenceElement, heading, label, open, disablePointer } = this;
- const displayed = effectiveReferenceElement && open;
- const hidden = !displayed;
- const arrowNode = !disablePointer ? (h("div", { class: CSS$g.arrow, ref: (arrowEl) => (this.arrowEl = arrowEl) })) : null;
- return (h(Host, { "aria-hidden": toAriaBoolean(hidden), "aria-label": label, "calcite-hydrated-hidden": hidden, id: this.getId(), role: "dialog" }, h("div", { class: {
- [CSS$D.animation]: true,
- [CSS$D.animationActive]: displayed
- }, onTransitionEnd: this.transitionEnd }, arrowNode, h("div", { class: {
- [CSS$g.hasHeader]: !!heading,
- [CSS$g.container]: true
- } }, this.renderHeader(), h("div", { class: CSS$g.content }, h("slot", null)), !heading ? this.renderCloseButton() : null))));
- }
- get el() { return this; }
- static get watchers() { return {
- "flipPlacements": ["flipPlacementsHandler"],
- "offsetDistance": ["offsetDistanceOffsetHandler"],
- "offsetSkidding": ["offsetSkiddingHandler"],
- "open": ["openHandler"],
- "placement": ["placementHandler"],
- "referenceElement": ["referenceElementHandler"]
- }; }
- static get style() { return popoverCss; }
- };
- const popoverManagerCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;display:block}";
- const PopoverManager = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.mutationObserver = createObserver("mutation", () => this.setAutoClose());
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * CSS Selector to match reference elements for popovers. Reference elements will be identified by this selector in order to open their associated popover.
- * @default `[data-calcite-popover-reference]`
- */
- this.selector = "[data-calcite-popover-reference]";
- /**
- * Automatically closes any currently open popovers when clicking outside of a popover.
- */
- this.autoClose = false;
- }
- autoCloseHandler() {
- this.setAutoClose();
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- var _a;
- this.setAutoClose();
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
- }
- disconnectedCallback() {
- var _a;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- render() {
- return h("slot", null);
- }
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- setAutoClose() {
- const { autoClose, el } = this;
- el.querySelectorAll("calcite-popover").forEach((popover) => (popover.autoClose = autoClose));
- }
- get el() { return this; }
- static get watchers() { return {
- "autoClose": ["autoCloseHandler"]
- }; }
- static get style() { return popoverManagerCss; }
- };
- const progressCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;display:block;width:100%}.track,.bar{position:absolute;top:0px;height:2px}.track{z-index:0;width:100%;overflow:hidden;background:var(--calcite-ui-border-3)}.bar{z-index:0;background-color:var(--calcite-ui-brand)}@media (forced-colors: active){.track{background-color:highlightText}.bar{background-color:linkText}}.indeterminate{width:20%;-webkit-animation:looping-progress-bar-ani 2200ms linear infinite;animation:looping-progress-bar-ani 2200ms linear infinite}.reversed{animation-direction:reverse}.text{padding-left:0px;padding-right:0px;padding-top:1rem;padding-bottom:0px;text-align:center;font-size:var(--calcite-font-size--2);line-height:1rem;font-weight:var(--calcite-font-weight-medium)}@-webkit-keyframes looping-progress-bar-ani{0%{-webkit-transform:translate3d(-100%, 0, 0);transform:translate3d(-100%, 0, 0)}50%{width:40%}100%{-webkit-transform:translate3d(600%, 0, 0);transform:translate3d(600%, 0, 0)}}@keyframes looping-progress-bar-ani{0%{-webkit-transform:translate3d(-100%, 0, 0);transform:translate3d(-100%, 0, 0)}50%{width:40%}100%{-webkit-transform:translate3d(600%, 0, 0);transform:translate3d(600%, 0, 0)}}";
- const Progress = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- /** Use indeterminate if finding actual progress value is impossible */
- this.type = "determinate";
- /** Fraction completed, in the range of 0 - 1.0 */
- this.value = 0;
- /** For indeterminate progress bars, reverse the animation direction */
- this.reversed = false;
- }
- render() {
- const isDeterminate = this.type === "determinate";
- const barStyles = isDeterminate ? { width: `${this.value * 100}%` } : {};
- return (h("div", { "aria-label": this.label || this.text, "aria-valuemax": 1, "aria-valuemin": 0, "aria-valuenow": this.value, role: "progressbar" }, h("div", { class: "track" }, h("div", { class: {
- bar: true,
- indeterminate: this.type === "indeterminate",
- reversed: this.reversed
- }, style: barStyles })), this.text ? h("div", { class: "text" }, this.text) : null));
- }
- get el() { return this; }
- static get style() { return progressCss; }
- };
- const CSS$f = {
- container: "container"
- };
- const radioButtonCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:block;cursor:pointer}:host .container{position:relative;outline:2px solid transparent;outline-offset:2px}:host .radio{cursor:pointer;border-radius:9999px;background-color:var(--calcite-ui-foreground-1);-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);-webkit-box-shadow:inset 0 0 0 1px var(--calcite-ui-border-input);box-shadow:inset 0 0 0 1px var(--calcite-ui-border-input)}:host([hovered]) .radio,:host(:not([checked])[focused]:not([disabled])) .radio{-webkit-box-shadow:inset 0 0 0 2px var(--calcite-ui-brand);box-shadow:inset 0 0 0 2px var(--calcite-ui-brand)}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) .radio{cursor:default;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host([hovered][disabled]) .radio{-webkit-box-shadow:inset 0 0 0 1px var(--calcite-ui-border-input);box-shadow:inset 0 0 0 1px var(--calcite-ui-border-input)}:host([scale=s]){--calcite-radio-size:var(--calcite-font-size--2)}:host([scale=m]){--calcite-radio-size:var(--calcite-font-size--1)}:host([scale=l]){--calcite-radio-size:var(--calcite-font-size-0)}.radio{height:var(--calcite-radio-size);max-width:var(--calcite-radio-size);min-width:var(--calcite-radio-size)}:host([scale=s][checked]) .radio,:host([hovered][scale=s][checked][disabled]) .radio{-webkit-box-shadow:inset 0 0 0 4px var(--calcite-ui-brand);box-shadow:inset 0 0 0 4px var(--calcite-ui-brand)}:host([scale=s][focused][checked]:not([disabled])) .radio{-webkit-box-shadow:inset 0 0 0 4px var(--calcite-ui-brand), 0 0 0 2px var(--calcite-ui-foreground-1), 0 0 0 4px var(--calcite-ui-brand);box-shadow:inset 0 0 0 4px var(--calcite-ui-brand), 0 0 0 2px var(--calcite-ui-foreground-1), 0 0 0 4px var(--calcite-ui-brand)}:host([scale=m][checked]) .radio,:host([hovered][scale=m][checked][disabled]) .radio{-webkit-box-shadow:inset 0 0 0 5px var(--calcite-ui-brand);box-shadow:inset 0 0 0 5px var(--calcite-ui-brand)}:host([scale=m][focused][checked]:not([disabled])) .radio{-webkit-box-shadow:inset 0 0 0 5px var(--calcite-ui-brand), 0 0 0 2px var(--calcite-ui-foreground-1), 0 0 0 4px var(--calcite-ui-brand);box-shadow:inset 0 0 0 5px var(--calcite-ui-brand), 0 0 0 2px var(--calcite-ui-foreground-1), 0 0 0 4px var(--calcite-ui-brand)}:host([scale=l][checked]) .radio,:host([hovered][scale=l][checked][disabled]) .radio{-webkit-box-shadow:inset 0 0 0 6px var(--calcite-ui-brand);box-shadow:inset 0 0 0 6px var(--calcite-ui-brand)}:host([scale=l][focused][checked]:not([disabled])) .radio{-webkit-box-shadow:inset 0 0 0 6px var(--calcite-ui-brand), 0 0 0 2px var(--calcite-ui-foreground-1), 0 0 0 4px var(--calcite-ui-brand);box-shadow:inset 0 0 0 6px var(--calcite-ui-brand), 0 0 0 2px var(--calcite-ui-foreground-1), 0 0 0 4px var(--calcite-ui-brand)}@media (forced-colors: active){:host([checked]) .radio::after,:host([checked][disabled]) .radio::after{content:\"\";width:var(--calcite-radio-size);height:var(--calcite-radio-size);background-color:windowText;display:block}}::slotted(input[slot=hidden-form-input]){bottom:0 !important;left:0 !important;margin:0 !important;opacity:0 !important;outline:none !important;padding:0 !important;position:absolute !important;right:0 !important;top:0 !important;-webkit-transform:none !important;transform:none !important;-webkit-appearance:none !important;z-index:-1 !important}";
- const RadioButton = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteInternalRadioButtonBlur = createEvent(this, "calciteInternalRadioButtonBlur", 7);
- this.calciteRadioButtonChange = createEvent(this, "calciteRadioButtonChange", 7);
- this.calciteInternalRadioButtonCheckedChange = createEvent(this, "calciteInternalRadioButtonCheckedChange", 7);
- this.calciteInternalRadioButtonFocus = createEvent(this, "calciteInternalRadioButtonFocus", 7);
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** The checked state of the radio button. */
- this.checked = false;
- /** The disabled state of the radio button. */
- this.disabled = false;
- /**
- * The focused state of the radio button.
- * @internal
- */
- this.focused = false;
- /** The radio button's hidden status. When a radio button is hidden it is not focusable or checkable. */
- this.hidden = false;
- /**
- * The hovered state of the radio button.
- * @internal
- */
- this.hovered = false;
- /** Requires that a value is selected for the radio button group before the parent form will submit. */
- this.required = false;
- /** The scale (size) of the radio button. `scale` is passed as a property automatically from `calcite-radio-button-group`. */
- this.scale = "m";
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- this.selectItem = (items, selectedIndex) => {
- items[selectedIndex].click();
- };
- this.queryButtons = () => {
- return Array.from(this.rootNode.querySelectorAll("calcite-radio-button:not([hidden])")).filter((radioButton) => radioButton.name === this.name);
- };
- this.isDefaultSelectable = () => {
- const radioButtons = this.queryButtons();
- return !radioButtons.some((radioButton) => radioButton.checked) && radioButtons[0] === this.el;
- };
- this.check = () => {
- if (this.disabled) {
- return;
- }
- this.uncheckAllRadioButtonsInGroup();
- this.checked = true;
- this.calciteRadioButtonChange.emit();
- this.setFocus();
- };
- this.clickHandler = () => {
- this.check();
- };
- this.setContainerEl = (el) => {
- this.containerEl = el;
- };
- this.handleKeyDown = (event) => {
- const keys = ["ArrowLeft", "ArrowUp", "ArrowRight", "ArrowDown", " "];
- const key = event.key;
- const { el } = this;
- if (keys.indexOf(key) === -1) {
- return;
- }
- if (key === " ") {
- this.check();
- return;
- }
- let adjustedKey = key;
- if (getElementDir(el) === "rtl") {
- if (key === "ArrowRight") {
- adjustedKey = "ArrowLeft";
- }
- if (key === "ArrowLeft") {
- adjustedKey = "ArrowRight";
- }
- }
- const radioButtons = Array.from(this.rootNode.querySelectorAll("calcite-radio-button:not([hidden]")).filter((radioButton) => radioButton.name === this.name);
- let currentIndex = 0;
- const radioButtonsLength = radioButtons.length;
- radioButtons.some((item, index) => {
- if (item.checked) {
- currentIndex = index;
- return true;
- }
- });
- switch (adjustedKey) {
- case "ArrowLeft":
- case "ArrowUp":
- event.preventDefault();
- this.selectItem(radioButtons, getRoundRobinIndex(Math.max(currentIndex - 1, -1), radioButtonsLength));
- return;
- case "ArrowRight":
- case "ArrowDown":
- event.preventDefault();
- this.selectItem(radioButtons, getRoundRobinIndex(currentIndex + 1, radioButtonsLength));
- return;
- default:
- return;
- }
- };
- this.onContainerBlur = () => {
- this.focused = false;
- this.calciteInternalRadioButtonBlur.emit();
- };
- this.onContainerFocus = () => {
- if (!this.disabled) {
- this.focused = true;
- this.calciteInternalRadioButtonFocus.emit();
- }
- };
- }
- checkedChanged(newChecked) {
- if (newChecked) {
- this.uncheckOtherRadioButtonsInGroup();
- }
- this.calciteInternalRadioButtonCheckedChange.emit(newChecked);
- }
- nameChanged() {
- this.checkLastRadioButton();
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- if (!this.disabled) {
- focusElement(this.containerEl);
- }
- }
- onLabelClick(event) {
- if (!this.disabled && !this.hidden) {
- this.uncheckOtherRadioButtonsInGroup();
- const label = event.currentTarget;
- const radioButton = label.for
- ? this.rootNode.querySelector(`calcite-radio-button[id="${label.for}"]`)
- : label.querySelector(`calcite-radio-button[name="${this.name}"]`);
- if (radioButton) {
- radioButton.checked = true;
- radioButton.focused = true;
- }
- this.calciteRadioButtonChange.emit();
- this.setFocus();
- }
- }
- checkLastRadioButton() {
- const radioButtons = this.queryButtons();
- const checkedRadioButtons = radioButtons.filter((radioButton) => radioButton.checked);
- if ((checkedRadioButtons === null || checkedRadioButtons === void 0 ? void 0 : checkedRadioButtons.length) > 1) {
- const lastCheckedRadioButton = checkedRadioButtons[checkedRadioButtons.length - 1];
- checkedRadioButtons
- .filter((checkedRadioButton) => checkedRadioButton !== lastCheckedRadioButton)
- .forEach((checkedRadioButton) => {
- checkedRadioButton.checked = false;
- checkedRadioButton.emitCheckedChange();
- });
- }
- }
- /** @internal */
- async emitCheckedChange() {
- this.calciteInternalRadioButtonCheckedChange.emit();
- }
- uncheckAllRadioButtonsInGroup() {
- const radioButtons = this.queryButtons();
- radioButtons.forEach((radioButton) => {
- if (radioButton.checked) {
- radioButton.checked = false;
- radioButton.focused = false;
- }
- });
- }
- uncheckOtherRadioButtonsInGroup() {
- const radioButtons = this.queryButtons();
- const otherRadioButtons = radioButtons.filter((radioButton) => radioButton.guid !== this.guid);
- otherRadioButtons.forEach((otherRadioButton) => {
- if (otherRadioButton.checked) {
- otherRadioButton.checked = false;
- otherRadioButton.focused = false;
- }
- });
- }
- getTabIndex() {
- if (this.disabled) {
- return undefined;
- }
- return this.checked || this.isDefaultSelectable() ? 0 : -1;
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- mouseenter() {
- this.hovered = true;
- }
- mouseleave() {
- this.hovered = false;
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- this.rootNode = this.el.getRootNode();
- this.guid = this.el.id || `calcite-radio-button-${guid()}`;
- if (this.name) {
- this.checkLastRadioButton();
- }
- connectLabel(this);
- connectForm(this);
- }
- componentDidLoad() {
- if (this.focused && !this.disabled) {
- this.setFocus();
- }
- }
- disconnectedCallback() {
- disconnectLabel(this);
- disconnectForm(this);
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- render() {
- const tabIndex = this.getTabIndex();
- return (h(Host, { onClick: this.clickHandler, onKeyDown: this.handleKeyDown }, h("div", { "aria-checked": toAriaBoolean(this.checked), "aria-label": getLabelText(this), class: CSS$f.container, onBlur: this.onContainerBlur, onFocus: this.onContainerFocus, ref: this.setContainerEl, role: "radio", tabIndex: tabIndex }, h("div", { class: "radio" })), h(HiddenFormInputSlot, { component: this })));
- }
- get el() { return this; }
- static get watchers() { return {
- "checked": ["checkedChanged"],
- "name": ["nameChanged"]
- }; }
- static get style() { return radioButtonCss; }
- };
- const radioButtonGroupCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:-ms-flexbox;display:flex;max-width:100vw}:host([layout=horizontal]){-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:wrap;flex-wrap:wrap}:host([layout=horizontal][scale=s]){gap:1rem}:host([layout=horizontal][scale=m]){gap:1.25rem}:host([layout=horizontal][scale=l]){gap:1.5rem}:host([layout=vertical]){-ms-flex-direction:column;flex-direction:column}";
- const RadioButtonGroup = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteRadioButtonGroupChange = createEvent(this, "calciteRadioButtonGroupChange", 7);
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** The disabled state of the radio button group. */
- this.disabled = false;
- /** The radio button group's hidden status. When a radio button group is hidden none of its options are focusable or checkable. */
- this.hidden = false;
- /** The layout direction of the radio buttons in a group. */
- this.layout = "horizontal";
- /** Requires that a value is selected for the radio button group before the parent form will submit. */
- this.required = false;
- /** The scale (size) of the radio button group. */
- this.scale = "m";
- // --------------------------------------------------------------------------
- //
- // Private Properties
- //
- // --------------------------------------------------------------------------
- this.mutationObserver = createObserver("mutation", () => this.passPropsToRadioButtons());
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- this.passPropsToRadioButtons = () => {
- const radioButtons = this.el.querySelectorAll("calcite-radio-button");
- if (radioButtons.length > 0) {
- radioButtons.forEach((radioButton) => {
- radioButton.disabled = this.disabled || radioButton.disabled;
- radioButton.hidden = this.hidden;
- radioButton.name = this.name;
- radioButton.required = this.required;
- radioButton.scale = this.scale;
- });
- }
- };
- }
- onDisabledChange() {
- this.passPropsToRadioButtons();
- }
- onHiddenChange() {
- this.passPropsToRadioButtons();
- }
- onLayoutChange() {
- this.passPropsToRadioButtons();
- }
- onScaleChange() {
- this.passPropsToRadioButtons();
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- var _a;
- this.passPropsToRadioButtons();
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
- }
- disconnectedCallback() {
- var _a;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- radioButtonChangeHandler(event) {
- this.calciteRadioButtonGroupChange.emit(event.target.value);
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- render() {
- return (h(Host, { role: "radiogroup" }, h("slot", null)));
- }
- get el() { return this; }
- static get watchers() { return {
- "disabled": ["onDisabledChange"],
- "hidden": ["onHiddenChange"],
- "layout": ["onLayoutChange"],
- "scale": ["onScaleChange"]
- }; }
- static get style() { return radioButtonGroupCss; }
- };
- const radioGroupCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:-ms-flexbox;display:flex;background-color:var(--calcite-ui-foreground-1);width:-moz-fit-content;width:-webkit-fit-content;width:fit-content;outline:1px solid var(--calcite-ui-border-input);outline-offset:-1px}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host([layout=vertical]){-ms-flex-direction:column;flex-direction:column;-ms-flex-align:start;align-items:flex-start;-ms-flex-item-align:start;align-self:flex-start}:host([width=full]){width:100%;min-width:-moz-fit-content;min-width:-webkit-fit-content;min-width:fit-content}:host([width=full]) ::slotted(calcite-radio-group-item){-ms-flex:1 1 auto;flex:1 1 auto}:host([width=full][layout=vertical]) ::slotted(calcite-radio-group-item){-ms-flex-pack:start;justify-content:flex-start}::slotted(calcite-radio-group-item[checked]),::slotted(calcite-radio-group-item:focus){z-index:0}::slotted(input[slot=hidden-form-input]){bottom:0 !important;left:0 !important;margin:0 !important;opacity:0 !important;outline:none !important;padding:0 !important;position:absolute !important;right:0 !important;top:0 !important;-webkit-transform:none !important;transform:none !important;-webkit-appearance:none !important;z-index:-1 !important}";
- const RadioGroup = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteRadioGroupChange = createEvent(this, "calciteRadioGroupChange", 7);
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** specify the appearance style of the radio group, defaults to solid. */
- this.appearance = "solid";
- /** is the radio group disabled */
- this.disabled = false;
- /**
- * When true, makes the component required for form-submission.
- *
- * @internal
- */
- this.required = false;
- /** specify the layout of the radio group, defaults to horizontal */
- this.layout = "horizontal";
- /** The scale of the radio group */
- this.scale = "m";
- /** The value of the selectedItem */
- this.value = null;
- /** specify the width of the group, defaults to auto */
- this.width = "auto";
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- this.handleClick = (event) => {
- if (event.target.localName === "calcite-radio-group-item") {
- this.selectItem(event.target, true);
- }
- };
- }
- valueHandler(value) {
- const items = this.getItems();
- items.forEach((item) => (item.checked = item.value === value));
- }
- handleSelectedItemChange(newItem, oldItem) {
- this.value = newItem === null || newItem === void 0 ? void 0 : newItem.value;
- if (newItem === oldItem) {
- return;
- }
- const items = this.getItems();
- const match = Array.from(items)
- .filter((item) => item === newItem)
- .pop();
- if (match) {
- this.selectItem(match);
- }
- else if (items[0]) {
- items[0].tabIndex = 0;
- }
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentWillLoad() {
- const items = this.getItems();
- const lastChecked = Array.from(items)
- .filter((item) => item.checked)
- .pop();
- if (lastChecked) {
- this.selectItem(lastChecked);
- }
- else if (items[0]) {
- items[0].tabIndex = 0;
- }
- }
- connectedCallback() {
- connectLabel(this);
- connectForm(this);
- }
- disconnectedCallback() {
- disconnectLabel(this);
- disconnectForm(this);
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- render() {
- return (h(Host, { onClick: this.handleClick, role: "radiogroup" }, h("slot", null), h(HiddenFormInputSlot, { component: this })));
- }
- handleSelected(event) {
- event.stopPropagation();
- event.preventDefault();
- this.selectItem(event.target);
- }
- handleKeyDown(event) {
- const keys = ["ArrowLeft", "ArrowUp", "ArrowRight", "ArrowDown", " "];
- const key = event.key;
- const { el, selectedItem } = this;
- if (keys.indexOf(key) === -1) {
- return;
- }
- let adjustedKey = key;
- if (getElementDir(el) === "rtl") {
- if (key === "ArrowRight") {
- adjustedKey = "ArrowLeft";
- }
- if (key === "ArrowLeft") {
- adjustedKey = "ArrowRight";
- }
- }
- const items = this.getItems();
- let selectedIndex = -1;
- items.forEach((item, index) => {
- if (item === selectedItem) {
- selectedIndex = index;
- }
- });
- switch (adjustedKey) {
- case "ArrowLeft":
- case "ArrowUp":
- event.preventDefault();
- const previous = selectedIndex < 1 ? items.item(items.length - 1) : items.item(selectedIndex - 1);
- this.selectItem(previous, true);
- return;
- case "ArrowRight":
- case "ArrowDown":
- event.preventDefault();
- const next = selectedIndex === -1 ? items.item(1) : items.item(selectedIndex + 1) || items.item(0);
- this.selectItem(next, true);
- return;
- case " ":
- event.preventDefault();
- this.selectItem(event.target, true);
- return;
- default:
- return;
- }
- }
- // --------------------------------------------------------------------------
- //
- // Methods
- //
- // --------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- var _a;
- (_a = (this.selectedItem || this.getItems()[0])) === null || _a === void 0 ? void 0 : _a.focus();
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- onLabelClick() {
- this.setFocus();
- }
- getItems() {
- return this.el.querySelectorAll("calcite-radio-group-item");
- }
- selectItem(selected, emit = false) {
- if (selected === this.selectedItem) {
- return;
- }
- const items = this.getItems();
- let match = null;
- items.forEach((item) => {
- const matches = item.value === selected.value;
- if ((matches && !item.checked) || (!matches && item.checked)) {
- item.checked = matches;
- }
- item.tabIndex = matches ? 0 : -1;
- if (matches) {
- match = item;
- if (emit) {
- this.calciteRadioGroupChange.emit(match.value);
- }
- }
- });
- this.selectedItem = match;
- if (Build.isBrowser && match) {
- match.focus();
- }
- }
- get el() { return this; }
- static get watchers() { return {
- "value": ["valueHandler"],
- "selectedItem": ["handleSelectedItemChange"]
- }; }
- static get style() { return radioGroupCss; }
- };
- const SLOTS$8 = {
- input: "input"
- };
- const CSS$e = {
- radioGroupItemIcon: "radio-group-item-icon"
- };
- const radioGroupItemCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:-ms-flexbox;display:flex;cursor:pointer;-ms-flex-item-align:stretch;align-self:stretch;font-weight:var(--calcite-font-weight-normal);-webkit-transition:background-color var(--calcite-internal-animation-timing-fast) ease-in-out, border-color var(--calcite-animation-timing) ease-in-out;transition:background-color var(--calcite-internal-animation-timing-fast) ease-in-out, border-color var(--calcite-animation-timing) ease-in-out}:host label{pointer-events:none;margin:0.125rem;-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;-ms-flex:1 1 0%;flex:1 1 0%;-ms-flex-align:center;align-items:center;color:var(--calcite-ui-text-3);-webkit-transition:background-color var(--calcite-internal-animation-timing-fast) ease-in-out, border-color var(--calcite-internal-animation-timing-fast) ease-in-out, color var(--calcite-internal-animation-timing-fast) ease-in-out;transition:background-color var(--calcite-internal-animation-timing-fast) ease-in-out, border-color var(--calcite-internal-animation-timing-fast) ease-in-out, color var(--calcite-internal-animation-timing-fast) ease-in-out}.label--horizontal{-ms-flex-pack:center;justify-content:center}:host{outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out}:host(:focus){outline:2px solid var(--calcite-ui-brand);outline-offset:-1px}.label--scale-s{padding-left:0.5rem;padding-right:0.5rem;font-size:var(--calcite-font-size--2);line-height:1rem;padding-top:0.125rem;padding-bottom:0.125rem}.label--scale-m{padding-left:0.75rem;padding-right:0.75rem;font-size:var(--calcite-font-size--1);line-height:1rem;padding-top:0.375rem;padding-bottom:0.375rem}.label--scale-l{padding-left:1rem;padding-right:1rem;padding-top:0.625rem;padding-bottom:0.625rem;font-size:var(--calcite-font-size-0);line-height:1.25rem}:host(:hover) label{background-color:var(--calcite-ui-foreground-2);color:var(--calcite-ui-text-1)}:host(:active) label{background-color:var(--calcite-ui-foreground-3)}:host([checked]) label{cursor:default;border-color:var(--calcite-ui-brand);background-color:var(--calcite-ui-brand);color:var(--calcite-ui-background)}:host([checked]) .label--outline{border-color:var(--calcite-ui-brand);background-color:var(--calcite-ui-foreground-1);-webkit-box-shadow:inset 0 0 0 1px var(--calcite-ui-brand);box-shadow:inset 0 0 0 1px var(--calcite-ui-brand);color:var(--calcite-ui-brand)}::slotted(input){display:none}.radio-group-item-icon{position:relative;margin:0px;display:-ms-inline-flexbox;display:inline-flex;line-height:inherit}:host([icon-position=start]) .label--scale-s .radio-group-item-icon{-webkit-margin-end:0.5rem;margin-inline-end:0.5rem}:host([icon-position=end]) .label--scale-s .radio-group-item-icon{-webkit-margin-end:unset;margin-inline-end:unset;-webkit-margin-start:0.5rem;margin-inline-start:0.5rem}:host([icon-position=start]) .label--scale-m .radio-group-item-icon{-webkit-margin-end:0.75rem;margin-inline-end:0.75rem}:host([icon-position=end]) .label--scale-m .radio-group-item-icon{-webkit-margin-end:unset;margin-inline-end:unset;-webkit-margin-start:0.75rem;margin-inline-start:0.75rem}:host([icon-position=start]) .label--scale-l .radio-group-item-icon{-webkit-margin-end:1rem;margin-inline-end:1rem}:host([icon-position=end]) .label--scale-l .radio-group-item-icon{-webkit-margin-end:unset;margin-inline-end:unset;-webkit-margin-start:1rem;margin-inline-start:1rem}";
- const RadioGroupItem = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteRadioGroupItemChange = createEvent(this, "calciteRadioGroupItemChange", 7);
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** Indicates whether the control is checked. */
- this.checked = false;
- /** flip the icon in rtl */
- this.iconFlipRtl = false;
- /** optionally used with icon, select where to position the icon */
- this.iconPosition = "start";
- }
- handleCheckedChange() {
- this.calciteRadioGroupItemChange.emit();
- }
- render() {
- const { checked, value } = this;
- const scale = getElementProp(this.el, "scale", "m");
- const appearance = getElementProp(this.el, "appearance", "solid");
- const layout = getElementProp(this.el, "layout", "horizontal");
- const iconEl = (h("calcite-icon", { class: CSS$e.radioGroupItemIcon, flipRtl: this.iconFlipRtl, icon: this.icon, scale: "s" }));
- return (h(Host, { "aria-checked": toAriaBoolean(checked), role: "radio" }, h("label", { class: {
- "label--scale-s": scale === "s",
- "label--scale-m": scale === "m",
- "label--scale-l": scale === "l",
- "label--horizontal": layout === "horizontal",
- "label--outline": appearance === "outline"
- } }, this.icon && this.iconPosition === "start" ? iconEl : null, h("slot", null, value), h("slot", { name: SLOTS$8.input }), this.icon && this.iconPosition === "end" ? iconEl : null)));
- }
- get el() { return this; }
- static get watchers() { return {
- "checked": ["handleCheckedChange"]
- }; }
- static get style() { return radioGroupItemCss; }
- };
- const TEXT$5 = {
- rating: "Rating",
- stars: "Stars: ${num}"
- };
- const ratingCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;width:-moz-fit-content;width:-webkit-fit-content;width:fit-content}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host([scale=s]){height:1.5rem;--calcite-rating-spacing-unit:0.25rem}:host([scale=m]){height:2rem;--calcite-rating-spacing-unit:0.5rem}:host([scale=l]){height:2.75rem;--calcite-rating-spacing-unit:0.75rem}:host([read-only]){pointer-events:none}.fieldset{margin:0px;display:-ms-flexbox;display:flex;border-width:0px;padding:0px}.wrapper{display:inline-block;-webkit-margin-end:var(--calcite-rating-spacing-unit);margin-inline-end:var(--calcite-rating-spacing-unit)}.star{position:relative;display:-ms-flexbox;display:flex;cursor:pointer;outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;color:var(--calcite-ui-border-input);-webkit-transition:var(--calcite-animation-timing);transition:var(--calcite-animation-timing);-webkit-transform:scale(1);transform:scale(1)}.star:active{-webkit-transform:scale(1.1);transform:scale(1.1)}.focused{outline:2px solid var(--calcite-ui-brand);outline-offset:2px}.average,.fraction{color:var(--calcite-ui-warning)}.hovered,.selected,:host([read-only]) .average,:host([read-only]) .fraction{color:var(--calcite-ui-brand)}.hovered:not(.selected){-webkit-transform:scale(0.9);transform:scale(0.9)}:host .fraction{pointer-events:none;position:absolute;top:0px;overflow:hidden;-webkit-transition:var(--calcite-animation-timing);transition:var(--calcite-animation-timing);inset-inline-start:0}calcite-chip{pointer-events:none;cursor:default}.number--average{font-weight:var(--calcite-font-weight-bold)}.number--count{color:var(--calcite-ui-text-2);font-style:italic}.number--count:not(:first-child){-webkit-margin-start:var(--calcite-rating-spacing-unit);margin-inline-start:var(--calcite-rating-spacing-unit)}.visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}::slotted(input[slot=hidden-form-input]){bottom:0 !important;left:0 !important;margin:0 !important;opacity:0 !important;outline:none !important;padding:0 !important;position:absolute !important;right:0 !important;top:0 !important;-webkit-transform:none !important;transform:none !important;-webkit-appearance:none !important;z-index:-1 !important}";
- const Rating = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteRatingChange = createEvent(this, "calciteRatingChange", 7);
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /** specify the scale of the component, defaults to m */
- this.scale = "m";
- /** the value of the rating component */
- this.value = 0;
- /** is the rating component in a selectable mode */
- this.readOnly = false;
- /** is the rating component in a selectable mode */
- this.disabled = false;
- /** Show average and count data summary chip (if available) */
- this.showChip = false;
- /** Localized string for "Rating" (used for aria label)
- * @default "Rating"
- */
- this.intlRating = TEXT$5.rating;
- /** Localized string for labelling each star, `${num}` in the string will be replaced by the number
- * @default "Stars: ${num}"
- */
- this.intlStars = TEXT$5.stars;
- /**
- * When true, makes the component required for form-submission.
- *
- * @internal
- */
- this.required = false;
- this.guid = `calcite-ratings-${guid()}`;
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- connectLabel(this);
- connectForm(this);
- }
- disconnectedCallback() {
- disconnectLabel(this);
- disconnectForm(this);
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- blurHandler() {
- this.hasFocus = false;
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- renderStars() {
- return [1, 2, 3, 4, 5].map((i) => {
- const selected = this.value >= i;
- const average = this.average && !this.value && i <= this.average;
- const hovered = i <= this.hoverValue;
- const fraction = this.average && this.average + 1 - i;
- const partial = !this.value && !hovered && fraction > 0 && fraction < 1;
- const focused = this.hasFocus && this.focusValue === i;
- return (h("span", { class: { wrapper: true } }, h("label", { class: { star: true, focused, selected, average, hovered, partial }, htmlFor: `${this.guid}-${i}`, onMouseOver: () => {
- this.hoverValue = i;
- } }, h("calcite-icon", { "aria-hidden": "true", class: "icon", icon: selected || average || this.readOnly ? "star-f" : "star", scale: this.scale }), partial && (h("div", { class: "fraction", style: { width: `${fraction * 100}%` } }, h("calcite-icon", { icon: "star-f", scale: this.scale }))), h("span", { class: "visually-hidden" }, this.intlStars.replace("${num}", `${i}`))), h("input", { checked: i === this.value, class: "visually-hidden", disabled: this.disabled || this.readOnly, id: `${this.guid}-${i}`, name: this.guid, onChange: () => this.updateValue(i), onClick: (event) =>
- // click is fired from the the component's label, so we treat this as an internal event
- event.stopPropagation(), onFocus: () => {
- this.hasFocus = true;
- this.focusValue = i;
- }, ref: (el) => (i === 1 || i === this.value) && (this.inputFocusRef = el), type: "radio", value: i })));
- });
- }
- render() {
- const { disabled, intlRating, showChip, scale, count, average } = this;
- return (h(Fragment, null, h("fieldset", { class: "fieldset", disabled: disabled, onBlur: () => (this.hoverValue = null), onMouseLeave: () => (this.hoverValue = null), onTouchEnd: () => (this.hoverValue = null) }, h("legend", { class: "visually-hidden" }, intlRating), this.renderStars()), (count || average) && showChip ? (h("calcite-chip", { scale: scale, value: count === null || count === void 0 ? void 0 : count.toString() }, !!average && h("span", { class: "number--average" }, average.toString()), !!count && h("span", { class: "number--count" }, "(", count === null || count === void 0 ? void 0 :
- count.toString(), ")"))) : null, h(HiddenFormInputSlot, { component: this })));
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- onLabelClick() {
- this.setFocus();
- }
- updateValue(value) {
- this.value = value;
- this.calciteRatingChange.emit({ value });
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- this.inputFocusRef.focus();
- }
- get el() { return this; }
- static get style() { return ratingCss; }
- };
- const CSS$d = {
- scrim: "scrim",
- content: "content"
- };
- const TEXT$4 = {
- loading: "Loading"
- };
- const scrimCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:absolute;top:0px;right:0px;bottom:0px;left:0px;z-index:50;display:-ms-flexbox;display:flex;height:100%;width:100%;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:stretch;align-items:stretch}@-webkit-keyframes calcite-scrim-fade-in{0%{--tw-bg-opacity:0}100%{--tw-text-opacity:1}}@keyframes calcite-scrim-fade-in{0%{--tw-bg-opacity:0}100%{--tw-text-opacity:1}}.scrim{position:absolute;top:0px;right:0px;bottom:0px;left:0px;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-line-pack:center;align-content:center;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;overflow:hidden;-webkit-animation:calcite-scrim-fade-in var(--calcite-internal-animation-timing-medium) ease-in-out;animation:calcite-scrim-fade-in var(--calcite-internal-animation-timing-medium) ease-in-out;background-color:var(--calcite-scrim-background)}.content{padding:1rem}";
- const Scrim = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /** string to override English loading text
- * @default "Loading"
- */
- this.intlLoading = TEXT$4.loading;
- /**
- * Determines if the component will have the loader overlay.
- * Otherwise, will render opaque disabled state.
- */
- this.loading = false;
- }
- // --------------------------------------------------------------------------
- //
- // Render Method
- //
- // --------------------------------------------------------------------------
- render() {
- const { el, loading, intlLoading } = this;
- const hasContent = el.innerHTML.trim().length > 0;
- const loaderNode = loading ? h("calcite-loader", { active: true, label: intlLoading }) : null;
- const contentNode = hasContent ? (h("div", { class: CSS$d.content }, h("slot", null))) : null;
- return (h("div", { class: CSS$d.scrim }, loaderNode, contentNode));
- }
- get el() { return this; }
- static get style() { return scrimCss; }
- };
- const CSS$c = {
- icon: "icon",
- iconContainer: "icon-container",
- select: "select"
- };
- const selectCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:host{--calcite-icon-size:1rem;--calcite-spacing-eighth:0.125rem;--calcite-spacing-quarter:0.25rem;--calcite-spacing-half:0.5rem;--calcite-spacing-three-quarters:0.75rem;--calcite-spacing:1rem;--calcite-spacing-plus-quarter:1.25rem;--calcite-spacing-plus-half:1.5rem;--calcite-spacing-double:2rem;--calcite-menu-min-width:10rem;--calcite-header-min-height:3rem;--calcite-footer-min-height:3rem}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:stretch;align-items:stretch;width:var(--select-width)}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host([scale=s]){height:1.5rem;--calcite-select-font-size:var(--calcite-font-size--2);--calcite-select-spacing-inline:0.5rem 2rem}:host([scale=s]) .icon-container{padding-left:0.5rem;padding-right:0.5rem}:host([scale=m]){height:2rem;--calcite-select-font-size:var(--calcite-font-size--1);--calcite-select-spacing-inline:0.75rem 2.5rem}:host([scale=m]) .icon-container{padding-left:0.75rem;padding-right:0.75rem}:host([scale=l]){height:44px;--calcite-select-font-size:var(--calcite-font-size-0);--calcite-select-spacing-inline:1rem 3rem}:host([scale=l]) .icon-container{padding-left:1rem;padding-right:1rem}:host([width=auto]){width:auto}:host([width=half]){width:50%}:host([width=full]){width:100%}.select{margin:0px;-webkit-box-sizing:border-box;box-sizing:border-box;width:100%;cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border-radius:0px;border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-input);background-color:var(--calcite-ui-foreground-1);font-family:inherit;color:var(--calcite-ui-text-2);outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;font-size:var(--calcite-select-font-size);padding-inline:var(--calcite-select-spacing-inline);border-inline-end-width:0px}.select:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.select:hover{background-color:var(--calcite-ui-foreground-2)}select:disabled{border-color:var(--calcite-ui-border-input);--tw-bg-opacity:1}.icon-container{pointer-events:none;position:absolute;top:0px;bottom:0px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-width:0px;border-style:solid;border-color:var(--calcite-ui-border-input);background-color:transparent;color:var(--calcite-ui-text-2);inset-inline-end:0px;border-inline-width:0px 1px}.select:focus~.icon-container{border-color:transparent}::slotted(input[slot=hidden-form-input]){bottom:0 !important;left:0 !important;margin:0 !important;opacity:0 !important;outline:none !important;padding:0 !important;position:absolute !important;right:0 !important;top:0 !important;-webkit-transform:none !important;transform:none !important;-webkit-appearance:none !important;z-index:-1 !important}";
- function isOption(optionOrGroup) {
- return optionOrGroup.tagName === "CALCITE-OPTION";
- }
- function isOptionGroup(optionOrGroup) {
- return optionOrGroup.tagName === "CALCITE-OPTION-GROUP";
- }
- const Select = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteSelectChange = createEvent(this, "calciteSelectChange", 7);
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /**
- * When true, it prevents the option from being selected.
- */
- this.disabled = false;
- /**
- * When true, makes the component required for form-submission.
- *
- * @internal
- */
- this.required = false;
- /**
- * The component scale.
- */
- this.scale = "m";
- /** The value of the selectedOption */
- this.value = null;
- /**
- * The component width.
- */
- this.width = "auto";
- this.componentToNativeEl = new Map();
- this.mutationObserver = createObserver("mutation", () => this.populateInternalSelect());
- this.handleInternalSelectChange = () => {
- const selected = this.selectEl.selectedOptions[0];
- this.selectFromNativeOption(selected);
- requestAnimationFrame(() => this.emitChangeEvent());
- };
- this.populateInternalSelect = () => {
- const optionsAndGroups = Array.from(this.el.children).filter((child) => child.tagName === "CALCITE-OPTION" || child.tagName === "CALCITE-OPTION-GROUP");
- this.clearInternalSelect();
- optionsAndGroups.forEach((optionOrGroup) => { var _a; return (_a = this.selectEl) === null || _a === void 0 ? void 0 : _a.append(this.toNativeElement(optionOrGroup)); });
- };
- this.storeSelectRef = (node) => {
- this.selectEl = node;
- this.populateInternalSelect();
- const selected = this.selectEl.selectedOptions[0];
- this.selectFromNativeOption(selected);
- };
- this.emitChangeEvent = () => {
- this.calciteSelectChange.emit();
- };
- }
- valueHandler(value) {
- const items = this.el.querySelectorAll("calcite-option");
- items.forEach((item) => (item.selected = item.value === value));
- }
- selectedOptionHandler(selectedOption) {
- this.value = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value;
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- var _a;
- const { el } = this;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(el, {
- subtree: true,
- childList: true
- });
- connectLabel(this);
- connectForm(this);
- }
- disconnectedCallback() {
- var _a;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- disconnectLabel(this);
- disconnectForm(this);
- }
- componentDidLoad() {
- var _a, _b;
- afterConnectDefaultValueSet(this, (_b = (_a = this.selectedOption) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : "");
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- focusElement(this.selectEl);
- }
- handleOptionOrGroupChange(event) {
- event.stopPropagation();
- const optionOrGroup = event.target;
- const nativeEl = this.componentToNativeEl.get(optionOrGroup);
- if (!nativeEl) {
- return;
- }
- this.updateNativeElement(optionOrGroup, nativeEl);
- if (isOption(optionOrGroup) && optionOrGroup.selected) {
- this.deselectAllExcept(optionOrGroup);
- this.selectedOption = optionOrGroup;
- }
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- onLabelClick() {
- this.setFocus();
- }
- updateNativeElement(optionOrGroup, nativeOptionOrGroup) {
- nativeOptionOrGroup.disabled = optionOrGroup.disabled;
- nativeOptionOrGroup.label = optionOrGroup.label;
- if (isOption(optionOrGroup)) {
- const option = nativeOptionOrGroup;
- option.selected = optionOrGroup.selected;
- option.value = optionOrGroup.value;
- // need to set innerText for mobile
- // see https://stackoverflow.com/questions/35021620/ios-safari-not-showing-all-options-for-select-menu/41749701
- option.innerText = optionOrGroup.label;
- }
- }
- clearInternalSelect() {
- this.componentToNativeEl.forEach((value) => value.remove());
- this.componentToNativeEl.clear();
- }
- selectFromNativeOption(nativeOption) {
- if (!nativeOption) {
- return;
- }
- let futureSelected;
- this.componentToNativeEl.forEach((nativeOptionOrGroup, optionOrGroup) => {
- if (isOption(optionOrGroup) && nativeOptionOrGroup === nativeOption) {
- optionOrGroup.selected = true;
- futureSelected = optionOrGroup;
- this.deselectAllExcept(optionOrGroup);
- }
- });
- if (futureSelected) {
- this.selectedOption = futureSelected;
- }
- }
- toNativeElement(optionOrGroup) {
- if (isOption(optionOrGroup)) {
- const option = document.createElement("option");
- this.updateNativeElement(optionOrGroup, option);
- this.componentToNativeEl.set(optionOrGroup, option);
- return option;
- }
- if (isOptionGroup(optionOrGroup)) {
- const group = document.createElement("optgroup");
- this.updateNativeElement(optionOrGroup, group);
- Array.from(optionOrGroup.children).forEach((option) => {
- const nativeOption = this.toNativeElement(option);
- group.append(nativeOption);
- this.componentToNativeEl.set(optionOrGroup, nativeOption);
- });
- this.componentToNativeEl.set(optionOrGroup, group);
- return group;
- }
- throw new Error("unsupported element child provided");
- }
- deselectAllExcept(except) {
- this.el.querySelectorAll("calcite-option").forEach((option) => {
- if (option === except) {
- return;
- }
- option.selected = false;
- });
- }
- //--------------------------------------------------------------------------
- //
- // Render Methods
- //
- //--------------------------------------------------------------------------
- renderChevron() {
- return (h("div", { class: CSS$c.iconContainer }, h("calcite-icon", { class: CSS$c.icon, icon: "chevron-down", scale: "s" })));
- }
- render() {
- return (h(Fragment, null, h("select", { "aria-label": this.label, class: CSS$c.select, disabled: this.disabled, onChange: this.handleInternalSelectChange, ref: this.storeSelectRef }, h("slot", null)), this.renderChevron(), h(HiddenFormInputSlot, { component: this })));
- }
- get el() { return this; }
- static get watchers() { return {
- "value": ["valueHandler"],
- "selectedOption": ["selectedOptionHandler"]
- }; }
- static get style() { return selectCss; }
- };
- const CSS$b = {
- main: "main",
- mainReversed: "main--reversed",
- content: "content",
- contentBehind: "content--behind",
- footer: "footer"
- };
- const SLOTS$7 = {
- centerRow: "center-row",
- primaryPanel: "primary-panel",
- contextualPanel: "contextual-panel",
- header: "header",
- footer: "footer"
- };
- const shellCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:host{-webkit-box-sizing:border-box;box-sizing:border-box;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-2);font-size:var(--calcite-font-size--1)}:host *{-webkit-box-sizing:border-box;box-sizing:border-box}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:absolute;top:0px;right:0px;bottom:0px;left:0px;display:-ms-flexbox;display:flex;height:100%;width:100%;-ms-flex-direction:column;flex-direction:column;overflow:hidden;--calcite-shell-tip-spacing:26vw}.main{position:relative;display:-ms-flexbox;display:flex;height:100%;width:100%;-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:justify;justify-content:space-between;overflow:hidden}.main--reversed{-ms-flex-direction:row-reverse;flex-direction:row-reverse}.content{display:-ms-flexbox;display:flex;height:100%;width:100%;-ms-flex-direction:column;flex-direction:column;-ms-flex-wrap:nowrap;flex-wrap:nowrap;overflow:auto}.content ::slotted(calcite-shell-center-row),.content ::slotted(calcite-panel),.content ::slotted(calcite-flow){-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-item-align:stretch;align-self:stretch;max-height:unset}.content--behind{position:absolute;top:0px;right:0px;bottom:0px;left:0px;z-index:0;border-width:0px;display:initial}::slotted(calcite-shell-center-row){width:unset}::slotted(.header .heading){font-size:var(--calcite-font-size--2);line-height:1.375;font-weight:var(--calcite-font-weight-normal)}::slotted(calcite-shell-panel),::slotted(calcite-shell-center-row){position:relative;z-index:1}::slotted(calcite-panel),::slotted(calcite-flow){border-width:1px;border-left-width:0px;border-right-width:0px;border-style:solid;border-color:var(--calcite-ui-border-3)}slot[name=center-row]::slotted(calcite-shell-center-row:not([detached])){border-left-width:1px;border-right-width:1px;border-color:var(--calcite-ui-border-3)}::slotted(calcite-tip-manager){position:absolute;-webkit-box-sizing:border-box;box-sizing:border-box}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}::slotted(calcite-tip-manager){-webkit-animation:in-up var(--calcite-internal-animation-timing-slow) ease-in-out;animation:in-up var(--calcite-internal-animation-timing-slow) ease-in-out;border-radius:0.25rem;--tw-shadow:0 6px 20px -4px rgba(0, 0, 0, 0.1), 0 4px 12px -2px rgba(0, 0, 0, 0.08);--tw-shadow-colored:0 6px 20px -4px var(--tw-shadow-color), 0 4px 12px -2px var(--tw-shadow-color);-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);bottom:0.5rem;left:var(--calcite-shell-tip-spacing);right:var(--calcite-shell-tip-spacing);z-index:2}";
- const Shell = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * Positions the center content behind any calcite-shell-panels.
- */
- this.contentBehind = false;
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- connectConditionalSlotComponent(this);
- }
- disconnectedCallback() {
- disconnectConditionalSlotComponent(this);
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- renderHeader() {
- const hasHeader = !!getSlotted(this.el, SLOTS$7.header);
- return hasHeader ? h("slot", { key: "header", name: SLOTS$7.header }) : null;
- }
- renderContent() {
- const defaultSlotNode = h("slot", { key: "default-slot" });
- const centerRowSlotNode = h("slot", { key: "center-row-slot", name: SLOTS$7.centerRow });
- const contentContainerKey = "content-container";
- const content = !!this.contentBehind
- ? [
- h("div", { class: {
- [CSS$b.content]: true,
- [CSS$b.contentBehind]: true
- }, key: contentContainerKey }, defaultSlotNode),
- centerRowSlotNode
- ]
- : [
- h("div", { class: CSS$b.content, key: contentContainerKey }, defaultSlotNode, centerRowSlotNode)
- ];
- return content;
- }
- renderFooter() {
- const hasFooter = !!getSlotted(this.el, SLOTS$7.footer);
- return hasFooter ? (h("div", { class: CSS$b.footer, key: "footer" }, h("slot", { name: SLOTS$7.footer }))) : null;
- }
- renderMain() {
- const primaryPanel = getSlotted(this.el, SLOTS$7.primaryPanel);
- const mainClasses = {
- [CSS$b.main]: true,
- [CSS$b.mainReversed]: (primaryPanel === null || primaryPanel === void 0 ? void 0 : primaryPanel.position) === "end"
- };
- return (h("div", { class: mainClasses }, h("slot", { name: SLOTS$7.primaryPanel }), this.renderContent(), h("slot", { name: SLOTS$7.contextualPanel })));
- }
- render() {
- return (h(Fragment, null, this.renderHeader(), this.renderMain(), this.renderFooter()));
- }
- get el() { return this; }
- static get style() { return shellCss; }
- };
- const CSS$a = {
- actionBarContainer: "action-bar-container",
- content: "content"
- };
- const SLOTS$6 = {
- actionBar: "action-bar"
- };
- const shellCenterRowCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:host{-webkit-box-sizing:border-box;box-sizing:border-box;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-2);font-size:var(--calcite-font-size--1)}:host *{-webkit-box-sizing:border-box;box-sizing:border-box}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:-ms-flexbox;display:flex;-ms-flex:1 1 auto;flex:1 1 auto;overflow:hidden;background-color:transparent}.content{margin:0px;display:-ms-flexbox;display:flex;height:100%;width:100%;overflow:hidden;-ms-flex:1 0 0px;flex:1 0 0}.action-bar-container{display:-ms-flexbox;display:flex}:host([detached]){margin-left:0.5rem;margin-right:0.5rem;margin-top:0.5rem;margin-bottom:1.5rem}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}:host([detached]){-webkit-animation:in-up var(--calcite-internal-animation-timing-slow) ease-in-out;animation:in-up var(--calcite-internal-animation-timing-slow) ease-in-out;border-radius:0.25rem;border-width:0px;--tw-shadow:0 4px 8px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);--tw-shadow-colored:0 4px 8px -1px var(--tw-shadow-color), 0 2px 4px -1px var(--tw-shadow-color);-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}:host([position=end]){-ms-flex-item-align:end;align-self:flex-end}:host([position=start]){-ms-flex-item-align:start;align-self:flex-start}:host([height-scale=s]){height:33.333333%}:host([height-scale=m]){height:70%}:host([height-scale=l]){height:100%}:host([height-scale=l][detached]){height:calc(100% - 2rem)}::slotted(calcite-panel){height:100%;width:100%}::slotted(calcite-action-bar),::slotted(calcite-action-bar[position=end]){-webkit-border-end:1px solid;border-inline-end:1px solid;border-color:var(--calcite-ui-border-3)}";
- const ShellCenterRow = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * This property makes the content area appear like a "floating" panel.
- */
- this.detached = false;
- /**
- * Specifies the maximum height of the row.
- */
- this.heightScale = "s";
- /**
- * Arranges the component depending on the elements 'dir' property.
- */
- this.position = "end";
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- connectConditionalSlotComponent(this);
- }
- disconnectedCallback() {
- disconnectConditionalSlotComponent(this);
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- render() {
- const { el } = this;
- const contentNode = (h("div", { class: CSS$a.content }, h("slot", null)));
- const actionBar = getSlotted(el, SLOTS$6.actionBar);
- const actionBarNode = actionBar ? (h("div", { class: CSS$a.actionBarContainer, key: "action-bar" }, h("slot", { name: SLOTS$6.actionBar }))) : null;
- const children = [actionBarNode, contentNode];
- if ((actionBar === null || actionBar === void 0 ? void 0 : actionBar.position) === "end") {
- children.reverse();
- }
- return h(Fragment, null, children);
- }
- get el() { return this; }
- static get style() { return shellCenterRowCss; }
- };
- const CSS$9 = {
- container: "container",
- content: "content",
- contentHeader: "content__header",
- contentBody: "content__body",
- contentDetached: "content--detached",
- separator: "separator"
- };
- const SLOTS$5 = {
- actionBar: "action-bar",
- header: "header"
- };
- const TEXT$3 = {
- resize: "Resize"
- };
- const shellPanelCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{pointer-events:none;display:-ms-flexbox;display:flex;-ms-flex:0 1 auto;flex:0 1 auto;-ms-flex-align:stretch;align-items:stretch;--calcite-shell-panel-detached-max-height:unset}.container{pointer-events:none;-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-align:stretch;align-items:stretch;background-color:transparent;font-size:var(--calcite-font-size--1);color:var(--calcite-ui-text-2)}.container *{-webkit-box-sizing:border-box;box-sizing:border-box}:host(:hover) .separator:not(:hover):not(:focus),:host(:focus-within) .separator:not(:hover):not(:focus){opacity:1;background-color:var(--calcite-ui-border-3)}.separator{pointer-events:auto;position:absolute;bottom:0px;top:0px;z-index:10;display:-ms-flexbox;display:flex;height:100%;width:0.125rem;background-color:transparent;opacity:0;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s;cursor:col-resize;outline:none}.separator:hover{opacity:1;background-color:var(--calcite-ui-border-2)}.separator:focus{background-color:var(--calcite-ui-brand);opacity:1}:host([position=start]) .separator{inset-inline-end:-2px}:host([position=end]) .separator{inset-inline-start:-2px}::slotted(calcite-panel),::slotted(calcite-flow){height:100%;width:100%;-ms-flex:1 1 auto;flex:1 1 auto;max-height:unset;max-width:unset}::slotted(.calcite-match-height){display:-ms-flexbox;display:flex;-ms-flex:1 1 auto;flex:1 1 auto;overflow:hidden}.content{pointer-events:auto;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-ms-flex-align:stretch;align-items:stretch;-ms-flex-item-align:stretch;align-self:stretch;background-color:var(--calcite-ui-background);padding:0px;width:var(--calcite-shell-panel-width);max-width:var(--calcite-shell-panel-max-width);min-width:var(--calcite-shell-panel-min-width);-webkit-transition:max-height var(--calcite-animation-timing), max-width var(--calcite-animation-timing);transition:max-height var(--calcite-animation-timing), max-width var(--calcite-animation-timing)}.content__header{display:-ms-flexbox;display:flex;-ms-flex:0 1 auto;flex:0 1 auto;-ms-flex-direction:column;flex-direction:column;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-ms-flex-align:stretch;align-items:stretch}.content__body{display:-ms-flexbox;display:flex;-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-direction:column;flex-direction:column;overflow:hidden}:host([width-scale=s]) .content{--calcite-shell-panel-width:calc(var(--calcite-panel-width-multiplier) * 12vw);--calcite-shell-panel-max-width:calc(var(--calcite-panel-width-multiplier) * 300px);--calcite-shell-panel-min-width:calc(var(--calcite-panel-width-multiplier) * 150px)}:host([width-scale=m]) .content{--calcite-shell-panel-width:calc(var(--calcite-panel-width-multiplier) * 20vw);--calcite-shell-panel-max-width:calc(var(--calcite-panel-width-multiplier) * 420px);--calcite-shell-panel-min-width:calc(var(--calcite-panel-width-multiplier) * 240px)}:host([width-scale=l]) .content{--calcite-shell-panel-width:calc(var(--calcite-panel-width-multiplier) * 45vw);--calcite-shell-panel-max-width:calc(var(--calcite-panel-width-multiplier) * 680px);--calcite-shell-panel-min-width:calc(var(--calcite-panel-width-multiplier) * 340px)}:host([detached-height-scale=s]) .content--detached{--calcite-shell-panel-detached-max-height:40vh}:host([detached-height-scale=m]) .content--detached{--calcite-shell-panel-detached-max-height:60vh}:host([detached-height-scale=l]) .content--detached{--calcite-shell-panel-detached-max-height:80vh}.content--detached{margin-left:0.5rem;margin-right:0.5rem;margin-top:0.5rem;margin-bottom:auto;height:auto;overflow:hidden;border-radius:0.25rem;--tw-shadow:0 4px 8px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);--tw-shadow-colored:0 4px 8px -1px var(--tw-shadow-color), 0 2px 4px -1px var(--tw-shadow-color);-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);max-height:var(--calcite-shell-panel-detached-max-height)}.content--detached ::slotted(calcite-panel),.content--detached ::slotted(calcite-flow){max-height:unset}:host([position=start]) .content--detached ::slotted(calcite-panel),:host([position=start]) .content--detached ::slotted(calcite-flow),:host([position=end]) .content--detached ::slotted(calcite-panel),:host([position=end]) .content--detached ::slotted(calcite-flow){border-style:none}.content[hidden]{display:none}slot[name=action-bar]::slotted(calcite-action-bar),.content ::slotted(calcite-flow),.content ::slotted(calcite-panel:not([dismissed])){border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-3)}:host([position=start]) slot[name=action-bar]::slotted(calcite-action-bar),:host([position=start]) .content ::slotted(calcite-flow),:host([position=start]) .content ::slotted(calcite-panel){-webkit-border-start:none;border-inline-start:none}:host([position=end]) slot[name=action-bar]::slotted(calcite-action-bar),:host([position=end]) .content ::slotted(calcite-flow),:host([position=end]) .content ::slotted(calcite-panel){-webkit-border-end:none;border-inline-end:none}";
- const ShellPanel = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteShellPanelToggle = createEvent(this, "calciteShellPanelToggle", 7);
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * Hide the content panel.
- */
- this.collapsed = false;
- /**
- * This property makes the content area appear like a "floating" panel.
- */
- this.detached = false;
- /**
- * Specifies the maximum height of the contents when detached.
- */
- this.detachedHeightScale = "l";
- /**
- * This sets width of the content area.
- */
- this.widthScale = "m";
- /**
- * Accessible label for resize separator.
- * @default "Resize"
- */
- this.intlResize = TEXT$3.resize;
- /**
- * This property makes the content area resizable if the calcite-shell-panel is not 'detached'.
- */
- this.resizable = false;
- this.contentWidth = null;
- this.initialContentWidth = null;
- this.initialClientX = null;
- this.contentWidthMax = null;
- this.contentWidthMin = null;
- this.step = 1;
- this.stepMultiplier = 10;
- this.storeContentEl = (contentEl) => {
- this.contentEl = contentEl;
- };
- this.getKeyAdjustedWidth = (event) => {
- const { key } = event;
- const { el, step, stepMultiplier, contentWidthMin, contentWidthMax, initialContentWidth, position } = this;
- const multipliedStep = step * stepMultiplier;
- const MOVEMENT_KEYS = [
- "ArrowUp",
- "ArrowDown",
- "ArrowLeft",
- "ArrowRight",
- "Home",
- "End",
- "PageUp",
- "PageDown"
- ];
- if (MOVEMENT_KEYS.indexOf(key) > -1) {
- event.preventDefault();
- }
- const dir = getElementDir(el);
- const directionKeys = ["ArrowLeft", "ArrowRight"];
- const directionFactor = dir === "rtl" && directionKeys.includes(key) ? -1 : 1;
- const increaseKeys = key === "ArrowUp" ||
- (position === "end" ? key === directionKeys[0] : key === directionKeys[1]);
- if (increaseKeys) {
- const stepValue = event.shiftKey ? multipliedStep : step;
- return initialContentWidth + directionFactor * stepValue;
- }
- const decreaseKeys = key === "ArrowDown" ||
- (position === "end" ? key === directionKeys[1] : key === directionKeys[0]);
- if (decreaseKeys) {
- const stepValue = event.shiftKey ? multipliedStep : step;
- return initialContentWidth - directionFactor * stepValue;
- }
- if (typeof contentWidthMin === "number" && key === "Home") {
- return contentWidthMin;
- }
- if (typeof contentWidthMax === "number" && key === "End") {
- return contentWidthMax;
- }
- if (key === "PageDown") {
- return initialContentWidth - multipliedStep;
- }
- if (key === "PageUp") {
- return initialContentWidth + multipliedStep;
- }
- return null;
- };
- this.separatorKeyDown = (event) => {
- this.setInitialContentWidth();
- const width = this.getKeyAdjustedWidth(event);
- if (typeof width === "number") {
- this.setContentWidth(width);
- }
- };
- this.separatorPointerMove = (event) => {
- event.preventDefault();
- const { el, initialContentWidth, position, initialClientX } = this;
- const offset = event.clientX - initialClientX;
- const dir = getElementDir(el);
- const adjustmentDirection = dir === "rtl" ? -1 : 1;
- const adjustedOffset = position === "end" ? -adjustmentDirection * offset : adjustmentDirection * offset;
- const width = initialContentWidth + adjustedOffset;
- this.setContentWidth(width);
- };
- this.separatorPointerUp = (event) => {
- event.preventDefault();
- document.removeEventListener("pointerup", this.separatorPointerUp);
- document.removeEventListener("pointermove", this.separatorPointerMove);
- };
- this.setInitialContentWidth = () => {
- var _a;
- this.initialContentWidth = (_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width;
- };
- this.separatorPointerDown = (event) => {
- event.preventDefault();
- const { separatorEl } = this;
- separatorEl && document.activeElement !== separatorEl && separatorEl.focus();
- this.setInitialContentWidth();
- this.initialClientX = event.clientX;
- document.addEventListener("pointerup", this.separatorPointerUp);
- document.addEventListener("pointermove", this.separatorPointerMove);
- };
- this.connectSeparator = (separatorEl) => {
- this.disconnectSeparator();
- this.separatorEl = separatorEl;
- separatorEl.addEventListener("pointerdown", this.separatorPointerDown);
- };
- this.disconnectSeparator = () => {
- var _a;
- (_a = this.separatorEl) === null || _a === void 0 ? void 0 : _a.removeEventListener("pointerdown", this.separatorPointerDown);
- };
- }
- watchHandler() {
- this.calciteShellPanelToggle.emit();
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- connectConditionalSlotComponent(this);
- }
- disconnectedCallback() {
- disconnectConditionalSlotComponent(this);
- this.disconnectSeparator();
- }
- componentDidLoad() {
- this.updateAriaValues();
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- renderHeader() {
- const { el } = this;
- const hasHeader = getSlotted(el, SLOTS$5.header);
- return hasHeader ? (h("div", { class: CSS$9.contentHeader, key: "header" }, h("slot", { name: SLOTS$5.header }))) : null;
- }
- render() {
- const { collapsed, detached, position, initialContentWidth, contentWidth, contentWidthMax, contentWidthMin, intlResize, resizable } = this;
- const allowResizing = !detached && resizable;
- const contentNode = (h("div", { class: { [CSS$9.content]: true, [CSS$9.contentDetached]: detached }, hidden: collapsed, key: "content", ref: this.storeContentEl, style: allowResizing && contentWidth ? { width: `${contentWidth}px` } : null }, this.renderHeader(), h("div", { class: CSS$9.contentBody }, h("slot", null))));
- const separatorNode = allowResizing ? (h("div", { "aria-label": intlResize, "aria-orientation": "horizontal", "aria-valuemax": contentWidthMax, "aria-valuemin": contentWidthMin, "aria-valuenow": contentWidth !== null && contentWidth !== void 0 ? contentWidth : initialContentWidth, class: CSS$9.separator, key: "separator", onKeyDown: this.separatorKeyDown, ref: this.connectSeparator, role: "separator", tabIndex: 0, "touch-action": "none" })) : null;
- const actionBarNode = h("slot", { key: "action-bar", name: SLOTS$5.actionBar });
- const mainNodes = [actionBarNode, contentNode, separatorNode];
- if (position === "end") {
- mainNodes.reverse();
- }
- return h("div", { class: { [CSS$9.container]: true } }, mainNodes);
- }
- // --------------------------------------------------------------------------
- //
- // private Methods
- //
- // --------------------------------------------------------------------------
- setContentWidth(width) {
- const { contentWidthMax, contentWidthMin } = this;
- const roundedWidth = Math.round(width);
- this.contentWidth =
- typeof contentWidthMax === "number" && typeof contentWidthMin === "number"
- ? clamp(roundedWidth, contentWidthMin, contentWidthMax)
- : roundedWidth;
- }
- updateAriaValues() {
- const { contentEl } = this;
- const computedStyle = contentEl && getComputedStyle(contentEl);
- if (!computedStyle) {
- return;
- }
- const max = parseInt(computedStyle.getPropertyValue("max-width"), 10);
- const min = parseInt(computedStyle.getPropertyValue("min-width"), 10);
- const valueNow = parseInt(computedStyle.getPropertyValue("width"), 10);
- if (typeof valueNow === "number" && !isNaN(valueNow)) {
- this.initialContentWidth = valueNow;
- }
- if (typeof max === "number" && !isNaN(max)) {
- this.contentWidthMax = max;
- }
- if (typeof min === "number" && !isNaN(min)) {
- this.contentWidthMin = min;
- }
- forceUpdate(this);
- }
- get el() { return this; }
- static get watchers() { return {
- "collapsed": ["watchHandler"]
- }; }
- static get style() { return shellPanelCss; }
- };
- const sliderCss = "@charset \"UTF-8\";@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}.scale--s{--calcite-slider-handle-size:10px;--calcite-slider-handle-extension-height:6.5px;--calcite-slider-container-font-size:var(--calcite-font-size--3)}.scale--s .handle__label,.scale--s .tick__label{line-height:.75rem}.scale--m{--calcite-slider-handle-size:14px;--calcite-slider-handle-extension-height:8px;--calcite-slider-container-font-size:var(--calcite-font-size--2)}.scale--m .handle__label,.scale--m .tick__label{line-height:1rem}.scale--l{--calcite-slider-handle-size:16px;--calcite-slider-handle-extension-height:10.5px;--calcite-slider-container-font-size:var(--calcite-font-size--1)}.scale--l .handle__label,.scale--l .tick__label{line-height:1rem}.handle__label,.tick__label{font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-2);font-size:var(--calcite-slider-container-font-size)}:host{display:block}.container{position:relative;display:block;overflow-wrap:normal;word-break:normal;padding:calc(var(--calcite-slider-handle-size) * 0.5);margin:calc(var(--calcite-slider-handle-size) * 0.5) 0;--calcite-slider-full-handle-height:calc(\n var(--calcite-slider-handle-size) + var(--calcite-slider-handle-extension-height)\n )}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) .track__range,:host([disabled]) .tick--active{background-color:var(--calcite-ui-text-3)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.scale--s .thumb:not(.thumb--precise){--calcite-slider-thumb-y-offset:-6px}.scale--m .thumb:not(.thumb--precise){--calcite-slider-thumb-y-offset:-8px}.scale--l .thumb:not(.thumb--precise){--calcite-slider-thumb-y-offset:-9px}:host([precise]:not([has-histogram])) .container .thumb--value{--calcite-slider-thumb-y-offset:calc(var(--calcite-slider-full-handle-height) * -1)}.thumb-container{position:relative;max-width:100%}.thumb{--calcite-slider-thumb-x-offset:calc(var(--calcite-slider-handle-size) * 0.5);position:absolute;margin:0px;display:-ms-flexbox;display:flex;cursor:pointer;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:center;align-items:center;border-style:none;background-color:transparent;padding:0px;font-family:inherit;outline:2px solid transparent;outline-offset:2px;-webkit-transform:translate(var(--calcite-slider-thumb-x-offset), var(--calcite-slider-thumb-y-offset));transform:translate(var(--calcite-slider-thumb-x-offset), var(--calcite-slider-thumb-y-offset))}.thumb .handle__label.static,.thumb .handle__label.transformed{position:absolute;top:0px;bottom:0px;opacity:0}.thumb .handle__label.hyphen::after{content:\"—\";display:inline-block;width:1em}.thumb .handle__label.hyphen--wrap{display:-ms-flexbox;display:flex}.thumb .handle{-webkit-box-sizing:border-box;box-sizing:border-box;border-radius:9999px;background-color:var(--calcite-ui-foreground-1);outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;height:var(--calcite-slider-handle-size);width:var(--calcite-slider-handle-size);-webkit-box-shadow:0 0 0 2px var(--calcite-ui-text-3) inset;box-shadow:0 0 0 2px var(--calcite-ui-text-3) inset;-webkit-transition:border var(--calcite-internal-animation-timing-medium) ease, background-color var(--calcite-internal-animation-timing-medium) ease, -webkit-box-shadow var(--calcite-animation-timing) ease;transition:border var(--calcite-internal-animation-timing-medium) ease, background-color var(--calcite-internal-animation-timing-medium) ease, -webkit-box-shadow var(--calcite-animation-timing) ease;transition:border var(--calcite-internal-animation-timing-medium) ease, background-color var(--calcite-internal-animation-timing-medium) ease, box-shadow var(--calcite-animation-timing) ease;transition:border var(--calcite-internal-animation-timing-medium) ease, background-color var(--calcite-internal-animation-timing-medium) ease, box-shadow var(--calcite-animation-timing) ease, -webkit-box-shadow var(--calcite-animation-timing) ease}.thumb .handle-extension{width:0.125rem;height:var(--calcite-slider-handle-extension-height);background-color:var(--calcite-ui-text-3)}.thumb:hover .handle{-webkit-box-shadow:0 0 0 3px var(--calcite-ui-brand) inset;box-shadow:0 0 0 3px var(--calcite-ui-brand) inset}.thumb:hover .handle-extension{background-color:var(--calcite-ui-brand)}.thumb:focus .handle{outline:2px solid var(--calcite-ui-brand);outline-offset:2px}.thumb:focus .handle-extension{background-color:var(--calcite-ui-brand)}.thumb.thumb--minValue{-webkit-transform:translate(calc(var(--calcite-slider-thumb-x-offset) * -1), var(--calcite-slider-thumb-y-offset));transform:translate(calc(var(--calcite-slider-thumb-x-offset) * -1), var(--calcite-slider-thumb-y-offset))}.thumb.thumb--precise{--calcite-slider-thumb-y-offset:-2px}:host([label-handles]) .thumb{--calcite-slider-thumb-x-offset:50%}:host([label-handles]):host(:not([has-histogram])) .scale--s .thumb:not(.thumb--precise){--calcite-slider-thumb-y-offset:-23px}:host([label-handles]):host(:not([has-histogram])) .scale--m .thumb:not(.thumb--precise){--calcite-slider-thumb-y-offset:-30px}:host([label-handles]):host(:not([has-histogram])) .scale--l .thumb:not(.thumb--precise){--calcite-slider-thumb-y-offset:-32px}:host([has-histogram][label-handles]) .handle__label,:host([label-handles]:not([has-histogram])) .thumb--minValue.thumb--precise .handle__label{margin-top:0.5em}:host(:not([has-histogram]):not([precise])) .handle__label,:host([label-handles]:not([has-histogram])) .thumb--value .handle__label{margin-bottom:0.5em}:host([label-handles][precise]):host(:not([has-histogram])) .scale--s .thumb--value{--calcite-slider-thumb-y-offset:-33px}:host([label-handles][precise]):host(:not([has-histogram])) .scale--m .thumb--value{--calcite-slider-thumb-y-offset:-44px}:host([label-handles][precise]):host(:not([has-histogram])) .scale--l .thumb--value{--calcite-slider-thumb-y-offset:-49px}.thumb:focus .handle,.thumb--active .handle{background-color:var(--calcite-ui-brand);-webkit-box-shadow:0 0 8px 0 rgba(0, 0, 0, 0.16);box-shadow:0 0 8px 0 rgba(0, 0, 0, 0.16)}.thumb:hover.thumb--precise:after,.thumb:focus.thumb--precise:after,.thumb--active.thumb--precise:after{background-color:var(--calcite-ui-brand)}.track{position:relative;height:0.125rem;border-radius:0px;background-color:var(--calcite-ui-border-2);-webkit-transition:all var(--calcite-internal-animation-timing-medium) ease-in;transition:all var(--calcite-internal-animation-timing-medium) ease-in}.track__range{position:absolute;top:0px;height:0.125rem;background-color:var(--calcite-ui-brand)}.container--range .track__range:hover{cursor:ew-resize}.container--range .track__range:after{position:absolute;width:100%;content:\"\";top:calc(var(--calcite-slider-full-handle-height) * 0.5 * -1);height:calc(var(--calcite-slider-handle-size) + var(--calcite-slider-handle-extension-height))}@media (forced-colors: active){.thumb{outline-width:0;outline-offset:0}.handle{outline:2px solid transparent;outline-offset:2px}.thumb:focus .handle,.thumb .handle-extension,.thumb:hover .handle-extension,.thumb:focus .handle-extension,.thumb:active .handle-extension{background-color:canvasText}.track{background-color:canvasText}.track__range{background-color:highlight}}.tick{position:absolute;height:0.25rem;width:0.125rem;border-width:1px;border-style:solid;background-color:var(--calcite-ui-border-input);border-color:var(--calcite-ui-foreground-1);top:-2px;pointer-events:none;-webkit-margin-start:calc(-1 * 0.125rem);margin-inline-start:calc(-1 * 0.125rem)}.tick--active{background-color:var(--calcite-ui-brand)}.tick__label{pointer-events:none;margin-top:0.875rem;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center}.tick__label--min{-webkit-transition:opacity var(--calcite-animation-timing);transition:opacity var(--calcite-animation-timing)}.tick__label--max{-webkit-transition:opacity var(--calcite-internal-animation-timing-fast);transition:opacity var(--calcite-internal-animation-timing-fast)}:host([has-histogram][label-handles]) .tick__label--min,:host([has-histogram][label-handles]) .tick__label--max,:host([has-histogram][precise]) .tick__label--min,:host([has-histogram][precise]) .tick__label--max{font-weight:var(--calcite-font-weight-normal);color:var(--calcite-ui-text-3)}.graph{color:var(--calcite-ui-foreground-3);height:48px}:host([label-ticks][ticks]) .container{padding-bottom:calc(0.875rem + var(--calcite-slider-container-font-size))}:host([has-histogram]):host([precise][label-handles]) .container{padding-bottom:calc(var(--calcite-slider-full-handle-height) + 1em)}:host([has-histogram]):host([label-handles]:not([precise])) .container{padding-bottom:calc(var(--calcite-slider-handle-size) * 0.5 + 1em)}:host([has-histogram]):host([precise]:not([label-handles])) .container{padding-bottom:var(--calcite-slider-full-handle-height)}:host(:not([has-histogram])):host([precise]:not([label-handles])) .container{padding-top:var(--calcite-slider-full-handle-height)}:host(:not([has-histogram])):host([precise]:not([label-handles])) .container--range{padding-bottom:var(--calcite-slider-full-handle-height)}:host(:not([has-histogram])):host([label-handles]:not([precise])) .container{padding-top:calc(var(--calcite-slider-full-handle-height) + 4px)}:host(:not([has-histogram])):host([label-handles][precise]) .container{padding-top:calc(var(--calcite-slider-full-handle-height) + var(--calcite-slider-container-font-size) + 4px)}:host(:not([has-histogram])):host([label-handles][precise]) .container--range{padding-bottom:calc(var(--calcite-slider-full-handle-height) + var(--calcite-slider-container-font-size) + 4px)}::slotted(input[slot=hidden-form-input]){bottom:0 !important;left:0 !important;margin:0 !important;opacity:0 !important;outline:none !important;padding:0 !important;position:absolute !important;right:0 !important;top:0 !important;-webkit-transform:none !important;transform:none !important;-webkit-appearance:none !important;z-index:-1 !important}";
- function isRange(value) {
- return Array.isArray(value);
- }
- const Slider = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteSliderInput = createEvent(this, "calciteSliderInput", 7);
- this.calciteSliderChange = createEvent(this, "calciteSliderChange", 7);
- this.calciteSliderUpdate = createEvent(this, "calciteSliderUpdate", 7);
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** Disable and gray out the slider */
- this.disabled = false;
- /** Indicates if a histogram is present */
- this.hasHistogram = false;
- /** Label handles with their numeric value */
- this.labelHandles = false;
- /** Label tick marks with their numeric value. */
- this.labelTicks = false;
- /** Maximum selectable value */
- this.max = 100;
- /** Minimum selectable value */
- this.min = 0;
- /**
- * When true, the slider will display values from high to low.
- *
- * Note that this value will be ignored if the slider has an associated histogram.
- */
- this.mirrored = false;
- /** Use finer point for handles */
- this.precise = false;
- /**
- * When true, makes the component required for form-submission.
- */
- this.required = false;
- /** When true, enables snap selection along the step interval */
- this.snap = false;
- /** Interval to move on up/down keys */
- this.step = 1;
- /** Currently selected number (if single select) */
- this.value = 0;
- /**
- * Specify the scale of the slider, defaults to m
- */
- this.scale = "m";
- this.guid = `calcite-slider-${guid()}`;
- this.activeProp = "value";
- this.minMaxValueRange = null;
- this.minValueDragRange = null;
- this.maxValueDragRange = null;
- this.tickValues = [];
- this.dragUpdate = (event) => {
- event.preventDefault();
- if (this.dragProp) {
- const value = this.translate(event.clientX || event.pageX);
- if (isRange(this.value) && this.dragProp === "minMaxValue") {
- if (this.minValueDragRange && this.maxValueDragRange && this.minMaxValueRange) {
- const newMinValue = value - this.minValueDragRange;
- const newMaxValue = value + this.maxValueDragRange;
- if (newMaxValue <= this.max &&
- newMinValue >= this.min &&
- newMaxValue - newMinValue === this.minMaxValueRange) {
- this.minValue = this.clamp(newMinValue, "minValue");
- this.maxValue = this.clamp(newMaxValue, "maxValue");
- }
- }
- else {
- this.minValueDragRange = value - this.minValue;
- this.maxValueDragRange = this.maxValue - value;
- this.minMaxValueRange = this.maxValue - this.minValue;
- }
- }
- else {
- this.setValue(this.dragProp, this.clamp(value, this.dragProp));
- }
- }
- };
- this.dragEnd = (event) => {
- this.removeDragListeners();
- this.focusActiveHandle(event.clientX);
- if (this.lastDragPropValue != this[this.dragProp]) {
- this.emitChange();
- }
- this.dragProp = null;
- this.lastDragPropValue = null;
- this.minValueDragRange = null;
- this.maxValueDragRange = null;
- this.minMaxValueRange = null;
- };
- /**
- * Set the reference of the track Element
- * @internal
- * @param node
- */
- this.storeTrackRef = (node) => {
- this.trackEl = node;
- };
- }
- histogramWatcher(newHistogram) {
- this.hasHistogram = !!newHistogram;
- }
- valueHandler() {
- this.setMinMaxFromValue();
- }
- minMaxValueHandler() {
- this.setValueFromMinMax();
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- this.setMinMaxFromValue();
- this.setValueFromMinMax();
- connectLabel(this);
- connectForm(this);
- }
- disconnectedCallback() {
- disconnectLabel(this);
- disconnectForm(this);
- this.removeDragListeners();
- }
- componentWillLoad() {
- this.tickValues = this.generateTickValues();
- if (!isRange(this.value)) {
- this.value = this.clamp(this.value);
- }
- afterConnectDefaultValueSet(this, this.value);
- if (this.snap && !isRange(this.value)) {
- this.value = this.getClosestStep(this.value);
- }
- if (this.histogram) {
- this.hasHistogram = true;
- }
- }
- componentDidRender() {
- if (this.labelHandles) {
- this.adjustHostObscuredHandleLabel("value");
- if (isRange(this.value)) {
- this.adjustHostObscuredHandleLabel("minValue");
- if (!(this.precise && !this.hasHistogram)) {
- this.hyphenateCollidingRangeHandleLabels();
- }
- }
- }
- this.hideObscuredBoundingTickLabels();
- updateHostInteraction(this);
- }
- render() {
- const id = this.el.id || this.guid;
- const maxProp = isRange(this.value) ? "maxValue" : "value";
- const value = isRange(this.value) ? this.maxValue : this.value;
- const min = this.minValue || this.min;
- const useMinValue = this.shouldUseMinValue();
- const minInterval = this.getUnitInterval(useMinValue ? this.minValue : min) * 100;
- const maxInterval = this.getUnitInterval(value) * 100;
- const mirror = this.shouldMirror();
- const leftThumbOffset = `${mirror ? 100 - minInterval : minInterval}%`;
- const rightThumbOffset = `${mirror ? maxInterval : 100 - maxInterval}%`;
- const valueIsRange = isRange(this.value);
- const handle = (h("div", { "aria-disabled": this.disabled, "aria-label": valueIsRange ? this.maxLabel : this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": value, class: {
- thumb: true,
- "thumb--value": true,
- "thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp
- }, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: () => this.dragStart(maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, h("div", { class: "handle" })));
- const labeledHandle = (h("div", { "aria-disabled": this.disabled, "aria-label": valueIsRange ? this.maxLabel : this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": value, class: {
- thumb: true,
- "thumb--value": true,
- "thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp
- }, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: () => this.dragStart(maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, h("span", { "aria-hidden": "true", class: "handle__label handle__label--value" }, value ? value.toLocaleString() : value), h("span", { "aria-hidden": "true", class: "handle__label handle__label--value static" }, value ? value.toLocaleString() : value), h("span", { "aria-hidden": "true", class: "handle__label handle__label--value transformed" }, value ? value.toLocaleString() : value), h("div", { class: "handle" })));
- const histogramLabeledHandle = (h("div", { "aria-disabled": this.disabled, "aria-label": valueIsRange ? this.maxLabel : this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": value, class: {
- thumb: true,
- "thumb--value": true,
- "thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp
- }, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: () => this.dragStart(maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, h("div", { class: "handle" }), h("span", { "aria-hidden": "true", class: "handle__label handle__label--value" }, value ? value.toLocaleString() : value), h("span", { "aria-hidden": "true", class: "handle__label handle__label--value static" }, value ? value.toLocaleString() : value), h("span", { "aria-hidden": "true", class: "handle__label handle__label--value transformed" }, value ? value.toLocaleString() : value)));
- const preciseHandle = (h("div", { "aria-disabled": this.disabled, "aria-label": valueIsRange ? this.maxLabel : this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": value, class: {
- thumb: true,
- "thumb--value": true,
- "thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp,
- "thumb--precise": true
- }, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: () => this.dragStart(maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, h("div", { class: "handle" }), h("div", { class: "handle-extension" })));
- const histogramPreciseHandle = (h("div", { "aria-disabled": this.disabled, "aria-label": valueIsRange ? this.maxLabel : this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": value, class: {
- thumb: true,
- "thumb--value": true,
- "thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp,
- "thumb--precise": true
- }, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: () => this.dragStart(maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, h("div", { class: "handle-extension" }), h("div", { class: "handle" })));
- const labeledPreciseHandle = (h("div", { "aria-disabled": this.disabled, "aria-label": valueIsRange ? this.maxLabel : this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": value, class: {
- thumb: true,
- "thumb--value": true,
- "thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp,
- "thumb--precise": true
- }, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: () => this.dragStart(maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, h("span", { "aria-hidden": "true", class: "handle__label handle__label--value" }, value ? value.toLocaleString() : value), h("span", { "aria-hidden": "true", class: "handle__label handle__label--value static" }, value ? value.toLocaleString() : value), h("span", { "aria-hidden": "true", class: "handle__label handle__label--value transformed" }, value ? value.toLocaleString() : value), h("div", { class: "handle" }), h("div", { class: "handle-extension" })));
- const histogramLabeledPreciseHandle = (h("div", { "aria-disabled": this.disabled, "aria-label": valueIsRange ? this.maxLabel : this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": value, class: {
- thumb: true,
- "thumb--value": true,
- "thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp,
- "thumb--precise": true
- }, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: () => this.dragStart(maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, h("div", { class: "handle-extension" }), h("div", { class: "handle" }), h("span", { "aria-hidden": "true", class: "handle__label handle__label--value" }, value ? value.toLocaleString() : value), h("span", { "aria-hidden": "true", class: "handle__label handle__label--value static" }, value ? value.toLocaleString() : value), h("span", { "aria-hidden": "true", class: "handle__label handle__label--value transformed" }, value ? value.toLocaleString() : value)));
- const minHandle = (h("div", { "aria-disabled": this.disabled, "aria-label": this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": this.minValue, class: {
- thumb: true,
- "thumb--minValue": true,
- "thumb--active": this.dragProp === "minValue"
- }, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = "minValue"), onPointerDown: () => this.dragStart("minValue"), ref: (el) => (this.minHandle = el), role: "slider", style: { left: leftThumbOffset }, tabIndex: 0 }, h("div", { class: "handle" })));
- const minLabeledHandle = (h("div", { "aria-disabled": this.disabled, "aria-label": this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": this.minValue, class: {
- thumb: true,
- "thumb--minValue": true,
- "thumb--active": this.dragProp === "minValue"
- }, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = "minValue"), onPointerDown: () => this.dragStart("minValue"), ref: (el) => (this.minHandle = el), role: "slider", style: { left: leftThumbOffset }, tabIndex: 0 }, h("span", { "aria-hidden": "true", class: "handle__label handle__label--minValue" }, this.minValue && this.minValue.toLocaleString()), h("span", { "aria-hidden": "true", class: "handle__label handle__label--minValue static" }, this.minValue && this.minValue.toLocaleString()), h("span", { "aria-hidden": "true", class: "handle__label handle__label--minValue transformed" }, this.minValue && this.minValue.toLocaleString()), h("div", { class: "handle" })));
- const minHistogramLabeledHandle = (h("div", { "aria-disabled": this.disabled, "aria-label": this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": this.minValue, class: {
- thumb: true,
- "thumb--minValue": true,
- "thumb--active": this.dragProp === "minValue"
- }, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = "minValue"), onPointerDown: () => this.dragStart("minValue"), ref: (el) => (this.minHandle = el), role: "slider", style: { left: leftThumbOffset }, tabIndex: 0 }, h("div", { class: "handle" }), h("span", { "aria-hidden": "true", class: "handle__label handle__label--minValue" }, this.minValue && this.minValue.toLocaleString()), h("span", { "aria-hidden": "true", class: "handle__label handle__label--minValue static" }, this.minValue && this.minValue.toLocaleString()), h("span", { "aria-hidden": "true", class: "handle__label handle__label--minValue transformed" }, this.minValue && this.minValue.toLocaleString())));
- const minPreciseHandle = (h("div", { "aria-disabled": this.disabled, "aria-label": this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": this.minValue, class: {
- thumb: true,
- "thumb--minValue": true,
- "thumb--active": this.dragProp === "minValue",
- "thumb--precise": true
- }, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = "minValue"), onPointerDown: () => this.dragStart("minValue"), ref: (el) => (this.minHandle = el), role: "slider", style: { left: leftThumbOffset }, tabIndex: 0 }, h("div", { class: "handle-extension" }), h("div", { class: "handle" })));
- const minLabeledPreciseHandle = (h("div", { "aria-disabled": this.disabled, "aria-label": this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": this.minValue, class: {
- thumb: true,
- "thumb--minValue": true,
- "thumb--active": this.dragProp === "minValue",
- "thumb--precise": true
- }, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = "minValue"), onPointerDown: () => this.dragStart("minValue"), ref: (el) => (this.minHandle = el), role: "slider", style: { left: leftThumbOffset }, tabIndex: 0 }, h("div", { class: "handle-extension" }), h("div", { class: "handle" }), h("span", { "aria-hidden": "true", class: "handle__label handle__label--minValue" }, this.minValue && this.minValue.toLocaleString()), h("span", { "aria-hidden": "true", class: "handle__label handle__label--minValue static" }, this.minValue && this.minValue.toLocaleString()), h("span", { "aria-hidden": "true", class: "handle__label handle__label--minValue transformed" }, this.minValue && this.minValue.toLocaleString())));
- return (h(Host, { id: id, onTouchStart: this.handleTouchStart }, h("div", { class: {
- ["container"]: true,
- ["container--range"]: valueIsRange,
- [`scale--${this.scale}`]: true
- } }, this.renderGraph(), h("div", { class: "track", ref: this.storeTrackRef }, h("div", { class: "track__range", onPointerDown: () => this.dragStart("minMaxValue"), style: {
- left: `${mirror ? 100 - maxInterval : minInterval}%`,
- right: `${mirror ? minInterval : 100 - maxInterval}%`
- } }), h("div", { class: "ticks" }, this.tickValues.map((tick) => {
- const tickOffset = `${this.getUnitInterval(tick) * 100}%`;
- let activeTicks = tick >= min && tick <= value;
- if (useMinValue) {
- activeTicks = tick >= this.minValue && tick <= this.maxValue;
- }
- return (h("span", { class: {
- tick: true,
- "tick--active": activeTicks
- }, style: {
- left: mirror ? "" : tickOffset,
- right: mirror ? tickOffset : ""
- } }, this.renderTickLabel(tick)));
- }))), h("div", { class: "thumb-container" }, !this.precise && !this.labelHandles && valueIsRange && minHandle, !this.hasHistogram &&
- !this.precise &&
- this.labelHandles &&
- valueIsRange &&
- minLabeledHandle, this.precise && !this.labelHandles && valueIsRange && minPreciseHandle, this.precise && this.labelHandles && valueIsRange && minLabeledPreciseHandle, this.hasHistogram &&
- !this.precise &&
- this.labelHandles &&
- valueIsRange &&
- minHistogramLabeledHandle, !this.precise && !this.labelHandles && handle, !this.hasHistogram && !this.precise && this.labelHandles && labeledHandle, !this.hasHistogram && this.precise && !this.labelHandles && preciseHandle, this.hasHistogram && this.precise && !this.labelHandles && histogramPreciseHandle, !this.hasHistogram && this.precise && this.labelHandles && labeledPreciseHandle, this.hasHistogram && !this.precise && this.labelHandles && histogramLabeledHandle, this.hasHistogram &&
- this.precise &&
- this.labelHandles &&
- histogramLabeledPreciseHandle, h(HiddenFormInputSlot, { component: this })))));
- }
- renderGraph() {
- return this.histogram ? (h("calcite-graph", { class: "graph", colorStops: this.histogramStops, data: this.histogram, highlightMax: isRange(this.value) ? this.maxValue : this.value, highlightMin: isRange(this.value) ? this.minValue : this.min, max: this.max, min: this.min })) : null;
- }
- renderTickLabel(tick) {
- const valueIsRange = isRange(this.value);
- const isMinTickLabel = tick === this.min;
- const isMaxTickLabel = tick === this.max;
- const tickLabel = (h("span", { class: {
- tick__label: true,
- "tick__label--min": isMinTickLabel,
- "tick__label--max": isMaxTickLabel
- } }, tick.toLocaleString()));
- if (this.labelTicks && !this.hasHistogram && !valueIsRange) {
- return tickLabel;
- }
- if (this.labelTicks &&
- !this.hasHistogram &&
- valueIsRange &&
- !this.precise &&
- !this.labelHandles) {
- return tickLabel;
- }
- if (this.labelTicks &&
- !this.hasHistogram &&
- valueIsRange &&
- !this.precise &&
- this.labelHandles) {
- return tickLabel;
- }
- if (this.labelTicks &&
- !this.hasHistogram &&
- valueIsRange &&
- this.precise &&
- (isMinTickLabel || isMaxTickLabel)) {
- return tickLabel;
- }
- if (this.labelTicks && this.hasHistogram && !this.precise && !this.labelHandles) {
- return tickLabel;
- }
- if (this.labelTicks &&
- this.hasHistogram &&
- this.precise &&
- !this.labelHandles &&
- (isMinTickLabel || isMaxTickLabel)) {
- return tickLabel;
- }
- if (this.labelTicks &&
- this.hasHistogram &&
- !this.precise &&
- this.labelHandles &&
- (isMinTickLabel || isMaxTickLabel)) {
- return tickLabel;
- }
- if (this.labelTicks &&
- this.hasHistogram &&
- this.precise &&
- this.labelHandles &&
- (isMinTickLabel || isMaxTickLabel)) {
- return tickLabel;
- }
- return null;
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- keyDownHandler(event) {
- const mirror = this.shouldMirror();
- const { activeProp, max, min, pageStep, step } = this;
- const value = this[activeProp];
- const key = event.key;
- if (key === "Enter" || key === " ") {
- event.preventDefault();
- return;
- }
- let adjustment;
- if (key === "ArrowUp" || key === "ArrowRight") {
- const directionFactor = mirror && key === "ArrowRight" ? -1 : 1;
- adjustment = value + step * directionFactor;
- }
- else if (key === "ArrowDown" || key === "ArrowLeft") {
- const directionFactor = mirror && key === "ArrowLeft" ? -1 : 1;
- adjustment = value - step * directionFactor;
- }
- else if (key === "PageUp") {
- if (pageStep) {
- adjustment = value + pageStep;
- }
- }
- else if (key === "PageDown") {
- if (pageStep) {
- adjustment = value - pageStep;
- }
- }
- else if (key === "Home") {
- adjustment = min;
- }
- else if (key === "End") {
- adjustment = max;
- }
- if (isNaN(adjustment)) {
- return;
- }
- event.preventDefault();
- const fixedDecimalAdjustment = Number(adjustment.toFixed(decimalPlaces(step)));
- this.setValue(activeProp, this.clamp(fixedDecimalAdjustment, activeProp));
- }
- clickHandler(event) {
- this.focusActiveHandle(event.clientX);
- }
- pointerDownHandler(event) {
- const x = event.clientX || event.pageX;
- const position = this.translate(x);
- let prop = "value";
- if (isRange(this.value)) {
- const inRange = position >= this.minValue && position <= this.maxValue;
- if (inRange && this.lastDragProp === "minMaxValue") {
- prop = "minMaxValue";
- }
- else {
- const closerToMax = Math.abs(this.maxValue - position) < Math.abs(this.minValue - position);
- prop = closerToMax || position > this.maxValue ? "maxValue" : "minValue";
- }
- }
- this.lastDragPropValue = this[prop];
- this.dragStart(prop);
- const isThumbActive = this.el.shadowRoot.querySelector(".thumb:active");
- if (!isThumbActive) {
- this.setValue(prop, this.clamp(position, prop));
- }
- }
- handleTouchStart(event) {
- // needed to prevent extra click at the end of a handle drag
- event.preventDefault();
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- const handle = this.minHandle ? this.minHandle : this.maxHandle;
- handle.focus();
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- setValueFromMinMax() {
- const { minValue, maxValue } = this;
- if (typeof minValue === "number" && typeof maxValue === "number") {
- this.value = [minValue, maxValue];
- }
- }
- setMinMaxFromValue() {
- const { value } = this;
- if (isRange(value)) {
- this.minValue = value[0];
- this.maxValue = value[1];
- }
- }
- onLabelClick() {
- this.setFocus();
- }
- shouldMirror() {
- return this.mirrored && !this.hasHistogram;
- }
- shouldUseMinValue() {
- if (!isRange(this.value)) {
- return false;
- }
- return ((this.hasHistogram && this.maxValue === 0) || (!this.hasHistogram && this.minValue === 0));
- }
- generateTickValues() {
- const ticks = [];
- let current = this.min;
- while (this.ticks && current < this.max + this.ticks) {
- ticks.push(Math.min(current, this.max));
- current = current + this.ticks;
- }
- return ticks;
- }
- dragStart(prop) {
- this.dragProp = prop;
- this.lastDragProp = this.dragProp;
- this.activeProp = prop;
- document.addEventListener("pointermove", this.dragUpdate);
- document.addEventListener("pointerup", this.dragEnd);
- document.addEventListener("pointercancel", this.dragEnd);
- }
- focusActiveHandle(valueX) {
- switch (this.dragProp) {
- case "minValue":
- this.minHandle.focus();
- break;
- case "maxValue":
- this.maxHandle.focus();
- break;
- case "minMaxValue":
- this.getClosestHandle(valueX).focus();
- break;
- }
- }
- emitInput() {
- this.calciteSliderInput.emit();
- this.calciteSliderUpdate.emit();
- }
- emitChange() {
- this.calciteSliderChange.emit();
- }
- removeDragListeners() {
- document.removeEventListener("pointermove", this.dragUpdate);
- document.removeEventListener("pointerup", this.dragEnd);
- document.removeEventListener("pointercancel", this.dragEnd);
- }
- /**
- * Set the prop value if changed at the component level
- * @param valueProp
- * @param value
- */
- setValue(valueProp, value) {
- const oldValue = this[valueProp];
- const valueChanged = oldValue !== value;
- if (!valueChanged) {
- return;
- }
- this[valueProp] = value;
- const dragging = this.dragProp;
- if (!dragging) {
- this.emitChange();
- }
- this.emitInput();
- }
- /**
- * If number is outside range, constrain to min or max
- * @internal
- */
- clamp(value, prop) {
- value = clamp(value, this.min, this.max);
- // ensure that maxValue and minValue don't swap positions
- if (prop === "maxValue") {
- value = Math.max(value, this.minValue);
- }
- if (prop === "minValue") {
- value = Math.min(value, this.maxValue);
- }
- return value;
- }
- /**
- * Translate a pixel position to value along the range
- * @internal
- */
- translate(x) {
- const range = this.max - this.min;
- const { left, width } = this.trackEl.getBoundingClientRect();
- const percent = (x - left) / width;
- const mirror = this.shouldMirror();
- const clampedValue = this.clamp(this.min + range * (mirror ? 1 - percent : percent));
- let value = Number(clampedValue.toFixed(decimalPlaces(this.step)));
- if (this.snap && this.step) {
- value = this.getClosestStep(value);
- }
- return value;
- }
- /**
- * Get closest allowed value along stepped values
- * @internal
- */
- getClosestStep(num) {
- num = Number(this.clamp(num).toFixed(decimalPlaces(this.step)));
- if (this.step) {
- const step = Math.round(num / this.step) * this.step;
- num = Number(this.clamp(step).toFixed(decimalPlaces(this.step)));
- }
- return num;
- }
- getClosestHandle(valueX) {
- return this.getDistanceX(this.maxHandle, valueX) > this.getDistanceX(this.minHandle, valueX)
- ? this.minHandle
- : this.maxHandle;
- }
- getDistanceX(el, valueX) {
- return Math.abs(el.getBoundingClientRect().left - valueX);
- }
- getFontSizeForElement(element) {
- return Number(window.getComputedStyle(element).getPropertyValue("font-size").match(/\d+/)[0]);
- }
- /**
- * Get position of value along range as fractional value
- * @return {number} number in the unit interval [0,1]
- * @internal
- */
- getUnitInterval(num) {
- num = this.clamp(num);
- const range = this.max - this.min;
- return (num - this.min) / range;
- }
- adjustHostObscuredHandleLabel(name) {
- const label = this.el.shadowRoot.querySelector(`.handle__label--${name}`);
- const labelStatic = this.el.shadowRoot.querySelector(`.handle__label--${name}.static`);
- const labelTransformed = this.el.shadowRoot.querySelector(`.handle__label--${name}.transformed`);
- const labelStaticBounds = labelStatic.getBoundingClientRect();
- const labelStaticOffset = this.getHostOffset(labelStaticBounds.left, labelStaticBounds.right);
- label.style.transform = `translateX(${labelStaticOffset}px)`;
- labelTransformed.style.transform = `translateX(${labelStaticOffset}px)`;
- }
- hyphenateCollidingRangeHandleLabels() {
- const { shadowRoot } = this.el;
- const mirror = this.shouldMirror();
- const leftModifier = mirror ? "value" : "minValue";
- const rightModifier = mirror ? "minValue" : "value";
- const leftValueLabel = shadowRoot.querySelector(`.handle__label--${leftModifier}`);
- const leftValueLabelStatic = shadowRoot.querySelector(`.handle__label--${leftModifier}.static`);
- const leftValueLabelTransformed = shadowRoot.querySelector(`.handle__label--${leftModifier}.transformed`);
- const leftValueLabelStaticHostOffset = this.getHostOffset(leftValueLabelStatic.getBoundingClientRect().left, leftValueLabelStatic.getBoundingClientRect().right);
- const rightValueLabel = shadowRoot.querySelector(`.handle__label--${rightModifier}`);
- const rightValueLabelStatic = shadowRoot.querySelector(`.handle__label--${rightModifier}.static`);
- const rightValueLabelTransformed = shadowRoot.querySelector(`.handle__label--${rightModifier}.transformed`);
- const rightValueLabelStaticHostOffset = this.getHostOffset(rightValueLabelStatic.getBoundingClientRect().left, rightValueLabelStatic.getBoundingClientRect().right);
- const labelFontSize = this.getFontSizeForElement(leftValueLabel);
- const labelTransformedOverlap = this.getRangeLabelOverlap(leftValueLabelTransformed, rightValueLabelTransformed);
- const hyphenLabel = leftValueLabel;
- const labelOffset = labelFontSize / 2;
- if (labelTransformedOverlap > 0) {
- hyphenLabel.classList.add("hyphen", "hyphen--wrap");
- if (rightValueLabelStaticHostOffset === 0 && leftValueLabelStaticHostOffset === 0) {
- // Neither handle overlaps the host boundary
- let leftValueLabelTranslate = labelTransformedOverlap / 2 - labelOffset;
- leftValueLabelTranslate =
- Math.sign(leftValueLabelTranslate) === -1
- ? Math.abs(leftValueLabelTranslate)
- : -leftValueLabelTranslate;
- const leftValueLabelTransformedHostOffset = this.getHostOffset(leftValueLabelTransformed.getBoundingClientRect().left +
- leftValueLabelTranslate -
- labelOffset, leftValueLabelTransformed.getBoundingClientRect().right +
- leftValueLabelTranslate -
- labelOffset);
- let rightValueLabelTranslate = labelTransformedOverlap / 2;
- const rightValueLabelTransformedHostOffset = this.getHostOffset(rightValueLabelTransformed.getBoundingClientRect().left + rightValueLabelTranslate, rightValueLabelTransformed.getBoundingClientRect().right + rightValueLabelTranslate);
- if (leftValueLabelTransformedHostOffset !== 0) {
- leftValueLabelTranslate += leftValueLabelTransformedHostOffset;
- rightValueLabelTranslate += leftValueLabelTransformedHostOffset;
- }
- if (rightValueLabelTransformedHostOffset !== 0) {
- leftValueLabelTranslate += rightValueLabelTransformedHostOffset;
- rightValueLabelTranslate += rightValueLabelTransformedHostOffset;
- }
- leftValueLabel.style.transform = `translateX(${leftValueLabelTranslate}px)`;
- leftValueLabelTransformed.style.transform = `translateX(${leftValueLabelTranslate - labelOffset}px)`;
- rightValueLabel.style.transform = `translateX(${rightValueLabelTranslate}px)`;
- rightValueLabelTransformed.style.transform = `translateX(${rightValueLabelTranslate}px)`;
- }
- else if (leftValueLabelStaticHostOffset > 0 || rightValueLabelStaticHostOffset > 0) {
- // labels overlap host boundary on the left side
- leftValueLabel.style.transform = `translateX(${leftValueLabelStaticHostOffset + labelOffset}px)`;
- rightValueLabel.style.transform = `translateX(${labelTransformedOverlap + rightValueLabelStaticHostOffset}px)`;
- rightValueLabelTransformed.style.transform = `translateX(${labelTransformedOverlap + rightValueLabelStaticHostOffset}px)`;
- }
- else if (leftValueLabelStaticHostOffset < 0 || rightValueLabelStaticHostOffset < 0) {
- // labels overlap host boundary on the right side
- let leftValueLabelTranslate = Math.abs(leftValueLabelStaticHostOffset) + labelTransformedOverlap - labelOffset;
- leftValueLabelTranslate =
- Math.sign(leftValueLabelTranslate) === -1
- ? Math.abs(leftValueLabelTranslate)
- : -leftValueLabelTranslate;
- leftValueLabel.style.transform = `translateX(${leftValueLabelTranslate}px)`;
- leftValueLabelTransformed.style.transform = `translateX(${leftValueLabelTranslate - labelOffset}px)`;
- }
- }
- else {
- hyphenLabel.classList.remove("hyphen", "hyphen--wrap");
- leftValueLabel.style.transform = `translateX(${leftValueLabelStaticHostOffset}px)`;
- leftValueLabelTransformed.style.transform = `translateX(${leftValueLabelStaticHostOffset}px)`;
- rightValueLabel.style.transform = `translateX(${rightValueLabelStaticHostOffset}px)`;
- rightValueLabelTransformed.style.transform = `translateX(${rightValueLabelStaticHostOffset}px)`;
- }
- }
- /**
- * Hides bounding tick labels that are obscured by either handle.
- */
- hideObscuredBoundingTickLabels() {
- const valueIsRange = isRange(this.value);
- if (!this.hasHistogram && !valueIsRange && !this.labelHandles && !this.precise) {
- return;
- }
- if (!this.hasHistogram && !valueIsRange && this.labelHandles && !this.precise) {
- return;
- }
- if (!this.hasHistogram && !valueIsRange && !this.labelHandles && this.precise) {
- return;
- }
- if (!this.hasHistogram && !valueIsRange && this.labelHandles && this.precise) {
- return;
- }
- if (!this.hasHistogram && valueIsRange && !this.precise) {
- return;
- }
- if (this.hasHistogram && !this.precise && !this.labelHandles) {
- return;
- }
- const minHandle = this.el.shadowRoot.querySelector(".thumb--minValue");
- const maxHandle = this.el.shadowRoot.querySelector(".thumb--value");
- const minTickLabel = this.el.shadowRoot.querySelector(".tick__label--min");
- const maxTickLabel = this.el.shadowRoot.querySelector(".tick__label--max");
- if (!minHandle && maxHandle && minTickLabel && maxTickLabel) {
- minTickLabel.style.opacity = this.isMinTickLabelObscured(minTickLabel, maxHandle) ? "0" : "1";
- maxTickLabel.style.opacity = this.isMaxTickLabelObscured(maxTickLabel, maxHandle) ? "0" : "1";
- }
- if (minHandle && maxHandle && minTickLabel && maxTickLabel) {
- minTickLabel.style.opacity =
- this.isMinTickLabelObscured(minTickLabel, minHandle) ||
- this.isMinTickLabelObscured(minTickLabel, maxHandle)
- ? "0"
- : "1";
- maxTickLabel.style.opacity =
- this.isMaxTickLabelObscured(maxTickLabel, minHandle) ||
- (this.isMaxTickLabelObscured(maxTickLabel, maxHandle) && this.hasHistogram)
- ? "0"
- : "1";
- }
- }
- /**
- * Returns an integer representing the number of pixels to offset on the left or right side based on desired position behavior.
- * @internal
- */
- getHostOffset(leftBounds, rightBounds) {
- const hostBounds = this.el.getBoundingClientRect();
- const buffer = 7;
- if (leftBounds + buffer < hostBounds.left) {
- return hostBounds.left - leftBounds - buffer;
- }
- if (rightBounds - buffer > hostBounds.right) {
- return -(rightBounds - hostBounds.right) + buffer;
- }
- return 0;
- }
- /**
- * Returns an integer representing the number of pixels that the two given span elements are overlapping, taking into account
- * a space in between the two spans equal to the font-size set on them to account for the space needed to render a hyphen.
- * @param leftLabel
- * @param rightLabel
- */
- getRangeLabelOverlap(leftLabel, rightLabel) {
- const leftLabelBounds = leftLabel.getBoundingClientRect();
- const rightLabelBounds = rightLabel.getBoundingClientRect();
- const leftLabelFontSize = this.getFontSizeForElement(leftLabel);
- const rangeLabelOverlap = leftLabelBounds.right + leftLabelFontSize - rightLabelBounds.left;
- return Math.max(rangeLabelOverlap, 0);
- }
- /**
- * Returns a boolean value representing if the minLabel span element is obscured (being overlapped) by the given handle div element.
- * @param minLabel
- * @param handle
- */
- isMinTickLabelObscured(minLabel, handle) {
- const minLabelBounds = minLabel.getBoundingClientRect();
- const handleBounds = handle.getBoundingClientRect();
- return intersects(minLabelBounds, handleBounds);
- }
- /**
- * Returns a boolean value representing if the maxLabel span element is obscured (being overlapped) by the given handle div element.
- * @param maxLabel
- * @param handle
- */
- isMaxTickLabelObscured(maxLabel, handle) {
- const maxLabelBounds = maxLabel.getBoundingClientRect();
- const handleBounds = handle.getBoundingClientRect();
- return intersects(maxLabelBounds, handleBounds);
- }
- get el() { return this; }
- static get watchers() { return {
- "histogram": ["histogramWatcher"],
- "value": ["valueHandler"],
- "minValue": ["minMaxValueHandler"],
- "maxValue": ["minMaxValueHandler"]
- }; }
- static get style() { return sliderCss; }
- };
- /**!
- * Sortable 1.15.0
- * @author RubaXa <trash@rubaxa.org>
- * @author owenm <owen23355@gmail.com>
- * @license MIT
- */
- function ownKeys(object, enumerableOnly) {
- var keys = Object.keys(object);
- if (Object.getOwnPropertySymbols) {
- var symbols = Object.getOwnPropertySymbols(object);
- if (enumerableOnly) {
- symbols = symbols.filter(function (sym) {
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
- });
- }
- keys.push.apply(keys, symbols);
- }
- return keys;
- }
- function _objectSpread2(target) {
- for (var i = 1; i < arguments.length; i++) {
- var source = arguments[i] != null ? arguments[i] : {};
- if (i % 2) {
- ownKeys(Object(source), true).forEach(function (key) {
- _defineProperty(target, key, source[key]);
- });
- } else if (Object.getOwnPropertyDescriptors) {
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
- } else {
- ownKeys(Object(source)).forEach(function (key) {
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
- });
- }
- }
- return target;
- }
- function _typeof(obj) {
- "@babel/helpers - typeof";
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
- _typeof = function (obj) {
- return typeof obj;
- };
- } else {
- _typeof = function (obj) {
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
- };
- }
- return _typeof(obj);
- }
- function _defineProperty(obj, key, value) {
- if (key in obj) {
- Object.defineProperty(obj, key, {
- value: value,
- enumerable: true,
- configurable: true,
- writable: true
- });
- } else {
- obj[key] = value;
- }
- return obj;
- }
- function _extends() {
- _extends = Object.assign || function (target) {
- for (var i = 1; i < arguments.length; i++) {
- var source = arguments[i];
- for (var key in source) {
- if (Object.prototype.hasOwnProperty.call(source, key)) {
- target[key] = source[key];
- }
- }
- }
- return target;
- };
- return _extends.apply(this, arguments);
- }
- function _objectWithoutPropertiesLoose(source, excluded) {
- if (source == null) return {};
- var target = {};
- var sourceKeys = Object.keys(source);
- var key, i;
- for (i = 0; i < sourceKeys.length; i++) {
- key = sourceKeys[i];
- if (excluded.indexOf(key) >= 0) continue;
- target[key] = source[key];
- }
- return target;
- }
- function _objectWithoutProperties(source, excluded) {
- if (source == null) return {};
- var target = _objectWithoutPropertiesLoose(source, excluded);
- var key, i;
- if (Object.getOwnPropertySymbols) {
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
- for (i = 0; i < sourceSymbolKeys.length; i++) {
- key = sourceSymbolKeys[i];
- if (excluded.indexOf(key) >= 0) continue;
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
- target[key] = source[key];
- }
- }
- return target;
- }
- var version = "1.15.0";
- function userAgent(pattern) {
- if (typeof window !== 'undefined' && window.navigator) {
- return !! /*@__PURE__*/navigator.userAgent.match(pattern);
- }
- }
- var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);
- var Edge = userAgent(/Edge/i);
- var FireFox = userAgent(/firefox/i);
- var Safari = userAgent(/safari/i) && !userAgent(/chrome/i) && !userAgent(/android/i);
- var IOS = userAgent(/iP(ad|od|hone)/i);
- var ChromeForAndroid = userAgent(/chrome/i) && userAgent(/android/i);
- var captureMode = {
- capture: false,
- passive: false
- };
- function on(el, event, fn) {
- el.addEventListener(event, fn, !IE11OrLess && captureMode);
- }
- function off(el, event, fn) {
- el.removeEventListener(event, fn, !IE11OrLess && captureMode);
- }
- function matches(
- /**HTMLElement*/
- el,
- /**String*/
- selector) {
- if (!selector) return;
- selector[0] === '>' && (selector = selector.substring(1));
- if (el) {
- try {
- if (el.matches) {
- return el.matches(selector);
- } else if (el.msMatchesSelector) {
- return el.msMatchesSelector(selector);
- } else if (el.webkitMatchesSelector) {
- return el.webkitMatchesSelector(selector);
- }
- } catch (_) {
- return false;
- }
- }
- return false;
- }
- function getParentOrHost(el) {
- return el.host && el !== document && el.host.nodeType ? el.host : el.parentNode;
- }
- function closest(
- /**HTMLElement*/
- el,
- /**String*/
- selector,
- /**HTMLElement*/
- ctx, includeCTX) {
- if (el) {
- ctx = ctx || document;
- do {
- if (selector != null && (selector[0] === '>' ? el.parentNode === ctx && matches(el, selector) : matches(el, selector)) || includeCTX && el === ctx) {
- return el;
- }
- if (el === ctx) break;
- /* jshint boss:true */
- } while (el = getParentOrHost(el));
- }
- return null;
- }
- var R_SPACE = /\s+/g;
- function toggleClass(el, name, state) {
- if (el && name) {
- if (el.classList) {
- el.classList[state ? 'add' : 'remove'](name);
- } else {
- var className = (' ' + el.className + ' ').replace(R_SPACE, ' ').replace(' ' + name + ' ', ' ');
- el.className = (className + (state ? ' ' + name : '')).replace(R_SPACE, ' ');
- }
- }
- }
- function css(el, prop, val) {
- var style = el && el.style;
- if (style) {
- if (val === void 0) {
- if (document.defaultView && document.defaultView.getComputedStyle) {
- val = document.defaultView.getComputedStyle(el, '');
- } else if (el.currentStyle) {
- val = el.currentStyle;
- }
- return prop === void 0 ? val : val[prop];
- } else {
- if (!(prop in style) && prop.indexOf('webkit') === -1) {
- prop = '-webkit-' + prop;
- }
- style[prop] = val + (typeof val === 'string' ? '' : 'px');
- }
- }
- }
- function matrix(el, selfOnly) {
- var appliedTransforms = '';
- if (typeof el === 'string') {
- appliedTransforms = el;
- } else {
- do {
- var transform = css(el, 'transform');
- if (transform && transform !== 'none') {
- appliedTransforms = transform + ' ' + appliedTransforms;
- }
- /* jshint boss:true */
- } while (!selfOnly && (el = el.parentNode));
- }
- var matrixFn = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix;
- /*jshint -W056 */
- return matrixFn && new matrixFn(appliedTransforms);
- }
- function find(ctx, tagName, iterator) {
- if (ctx) {
- var list = ctx.getElementsByTagName(tagName),
- i = 0,
- n = list.length;
- if (iterator) {
- for (; i < n; i++) {
- iterator(list[i], i);
- }
- }
- return list;
- }
- return [];
- }
- function getWindowScrollingElement() {
- var scrollingElement = document.scrollingElement;
- if (scrollingElement) {
- return scrollingElement;
- } else {
- return document.documentElement;
- }
- }
- /**
- * Returns the "bounding client rect" of given element
- * @param {HTMLElement} el The element whose boundingClientRect is wanted
- * @param {[Boolean]} relativeToContainingBlock Whether the rect should be relative to the containing block of (including) the container
- * @param {[Boolean]} relativeToNonStaticParent Whether the rect should be relative to the relative parent of (including) the contaienr
- * @param {[Boolean]} undoScale Whether the container's scale() should be undone
- * @param {[HTMLElement]} container The parent the element will be placed in
- * @return {Object} The boundingClientRect of el, with specified adjustments
- */
- function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container) {
- if (!el.getBoundingClientRect && el !== window) return;
- var elRect, top, left, bottom, right, height, width;
- if (el !== window && el.parentNode && el !== getWindowScrollingElement()) {
- elRect = el.getBoundingClientRect();
- top = elRect.top;
- left = elRect.left;
- bottom = elRect.bottom;
- right = elRect.right;
- height = elRect.height;
- width = elRect.width;
- } else {
- top = 0;
- left = 0;
- bottom = window.innerHeight;
- right = window.innerWidth;
- height = window.innerHeight;
- width = window.innerWidth;
- }
- if ((relativeToContainingBlock || relativeToNonStaticParent) && el !== window) {
- // Adjust for translate()
- container = container || el.parentNode; // solves #1123 (see: https://stackoverflow.com/a/37953806/6088312)
- // Not needed on <= IE11
- if (!IE11OrLess) {
- do {
- if (container && container.getBoundingClientRect && (css(container, 'transform') !== 'none' || relativeToNonStaticParent && css(container, 'position') !== 'static')) {
- var containerRect = container.getBoundingClientRect(); // Set relative to edges of padding box of container
- top -= containerRect.top + parseInt(css(container, 'border-top-width'));
- left -= containerRect.left + parseInt(css(container, 'border-left-width'));
- bottom = top + elRect.height;
- right = left + elRect.width;
- break;
- }
- /* jshint boss:true */
- } while (container = container.parentNode);
- }
- }
- if (undoScale && el !== window) {
- // Adjust for scale()
- var elMatrix = matrix(container || el),
- scaleX = elMatrix && elMatrix.a,
- scaleY = elMatrix && elMatrix.d;
- if (elMatrix) {
- top /= scaleY;
- left /= scaleX;
- width /= scaleX;
- height /= scaleY;
- bottom = top + height;
- right = left + width;
- }
- }
- return {
- top: top,
- left: left,
- bottom: bottom,
- right: right,
- width: width,
- height: height
- };
- }
- /**
- * Checks if a side of an element is scrolled past a side of its parents
- * @param {HTMLElement} el The element who's side being scrolled out of view is in question
- * @param {String} elSide Side of the element in question ('top', 'left', 'right', 'bottom')
- * @param {String} parentSide Side of the parent in question ('top', 'left', 'right', 'bottom')
- * @return {HTMLElement} The parent scroll element that the el's side is scrolled past, or null if there is no such element
- */
- function isScrolledPast(el, elSide, parentSide) {
- var parent = getParentAutoScrollElement(el, true),
- elSideVal = getRect(el)[elSide];
- /* jshint boss:true */
- while (parent) {
- var parentSideVal = getRect(parent)[parentSide],
- visible = void 0;
- if (parentSide === 'top' || parentSide === 'left') {
- visible = elSideVal >= parentSideVal;
- } else {
- visible = elSideVal <= parentSideVal;
- }
- if (!visible) return parent;
- if (parent === getWindowScrollingElement()) break;
- parent = getParentAutoScrollElement(parent, false);
- }
- return false;
- }
- /**
- * Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible)
- * and non-draggable elements
- * @param {HTMLElement} el The parent element
- * @param {Number} childNum The index of the child
- * @param {Object} options Parent Sortable's options
- * @return {HTMLElement} The child at index childNum, or null if not found
- */
- function getChild(el, childNum, options, includeDragEl) {
- var currentChild = 0,
- i = 0,
- children = el.children;
- while (i < children.length) {
- if (children[i].style.display !== 'none' && children[i] !== Sortable.ghost && (includeDragEl || children[i] !== Sortable.dragged) && closest(children[i], options.draggable, el, false)) {
- if (currentChild === childNum) {
- return children[i];
- }
- currentChild++;
- }
- i++;
- }
- return null;
- }
- /**
- * Gets the last child in the el, ignoring ghostEl or invisible elements (clones)
- * @param {HTMLElement} el Parent element
- * @param {selector} selector Any other elements that should be ignored
- * @return {HTMLElement} The last child, ignoring ghostEl
- */
- function lastChild(el, selector) {
- var last = el.lastElementChild;
- while (last && (last === Sortable.ghost || css(last, 'display') === 'none' || selector && !matches(last, selector))) {
- last = last.previousElementSibling;
- }
- return last || null;
- }
- /**
- * Returns the index of an element within its parent for a selected set of
- * elements
- * @param {HTMLElement} el
- * @param {selector} selector
- * @return {number}
- */
- function index(el, selector) {
- var index = 0;
- if (!el || !el.parentNode) {
- return -1;
- }
- /* jshint boss:true */
- while (el = el.previousElementSibling) {
- if (el.nodeName.toUpperCase() !== 'TEMPLATE' && el !== Sortable.clone && (!selector || matches(el, selector))) {
- index++;
- }
- }
- return index;
- }
- /**
- * Returns the scroll offset of the given element, added with all the scroll offsets of parent elements.
- * The value is returned in real pixels.
- * @param {HTMLElement} el
- * @return {Array} Offsets in the format of [left, top]
- */
- function getRelativeScrollOffset(el) {
- var offsetLeft = 0,
- offsetTop = 0,
- winScroller = getWindowScrollingElement();
- if (el) {
- do {
- var elMatrix = matrix(el),
- scaleX = elMatrix.a,
- scaleY = elMatrix.d;
- offsetLeft += el.scrollLeft * scaleX;
- offsetTop += el.scrollTop * scaleY;
- } while (el !== winScroller && (el = el.parentNode));
- }
- return [offsetLeft, offsetTop];
- }
- /**
- * Returns the index of the object within the given array
- * @param {Array} arr Array that may or may not hold the object
- * @param {Object} obj An object that has a key-value pair unique to and identical to a key-value pair in the object you want to find
- * @return {Number} The index of the object in the array, or -1
- */
- function indexOfObject(arr, obj) {
- for (var i in arr) {
- if (!arr.hasOwnProperty(i)) continue;
- for (var key in obj) {
- if (obj.hasOwnProperty(key) && obj[key] === arr[i][key]) return Number(i);
- }
- }
- return -1;
- }
- function getParentAutoScrollElement(el, includeSelf) {
- // skip to window
- if (!el || !el.getBoundingClientRect) return getWindowScrollingElement();
- var elem = el;
- var gotSelf = false;
- do {
- // we don't need to get elem css if it isn't even overflowing in the first place (performance)
- if (elem.clientWidth < elem.scrollWidth || elem.clientHeight < elem.scrollHeight) {
- var elemCSS = css(elem);
- if (elem.clientWidth < elem.scrollWidth && (elemCSS.overflowX == 'auto' || elemCSS.overflowX == 'scroll') || elem.clientHeight < elem.scrollHeight && (elemCSS.overflowY == 'auto' || elemCSS.overflowY == 'scroll')) {
- if (!elem.getBoundingClientRect || elem === document.body) return getWindowScrollingElement();
- if (gotSelf || includeSelf) return elem;
- gotSelf = true;
- }
- }
- /* jshint boss:true */
- } while (elem = elem.parentNode);
- return getWindowScrollingElement();
- }
- function extend(dst, src) {
- if (dst && src) {
- for (var key in src) {
- if (src.hasOwnProperty(key)) {
- dst[key] = src[key];
- }
- }
- }
- return dst;
- }
- function isRectEqual(rect1, rect2) {
- return Math.round(rect1.top) === Math.round(rect2.top) && Math.round(rect1.left) === Math.round(rect2.left) && Math.round(rect1.height) === Math.round(rect2.height) && Math.round(rect1.width) === Math.round(rect2.width);
- }
- var _throttleTimeout;
- function throttle(callback, ms) {
- return function () {
- if (!_throttleTimeout) {
- var args = arguments,
- _this = this;
- if (args.length === 1) {
- callback.call(_this, args[0]);
- } else {
- callback.apply(_this, args);
- }
- _throttleTimeout = setTimeout(function () {
- _throttleTimeout = void 0;
- }, ms);
- }
- };
- }
- function cancelThrottle() {
- clearTimeout(_throttleTimeout);
- _throttleTimeout = void 0;
- }
- function scrollBy(el, x, y) {
- el.scrollLeft += x;
- el.scrollTop += y;
- }
- function clone(el) {
- var Polymer = window.Polymer;
- var $ = window.jQuery || window.Zepto;
- if (Polymer && Polymer.dom) {
- return Polymer.dom(el).cloneNode(true);
- } else if ($) {
- return $(el).clone(true)[0];
- } else {
- return el.cloneNode(true);
- }
- }
- var expando = 'Sortable' + new Date().getTime();
- function AnimationStateManager() {
- var animationStates = [],
- animationCallbackId;
- return {
- captureAnimationState: function captureAnimationState() {
- animationStates = [];
- if (!this.options.animation) return;
- var children = [].slice.call(this.el.children);
- children.forEach(function (child) {
- if (css(child, 'display') === 'none' || child === Sortable.ghost) return;
- animationStates.push({
- target: child,
- rect: getRect(child)
- });
- var fromRect = _objectSpread2({}, animationStates[animationStates.length - 1].rect); // If animating: compensate for current animation
- if (child.thisAnimationDuration) {
- var childMatrix = matrix(child, true);
- if (childMatrix) {
- fromRect.top -= childMatrix.f;
- fromRect.left -= childMatrix.e;
- }
- }
- child.fromRect = fromRect;
- });
- },
- addAnimationState: function addAnimationState(state) {
- animationStates.push(state);
- },
- removeAnimationState: function removeAnimationState(target) {
- animationStates.splice(indexOfObject(animationStates, {
- target: target
- }), 1);
- },
- animateAll: function animateAll(callback) {
- var _this = this;
- if (!this.options.animation) {
- clearTimeout(animationCallbackId);
- if (typeof callback === 'function') callback();
- return;
- }
- var animating = false,
- animationTime = 0;
- animationStates.forEach(function (state) {
- var time = 0,
- target = state.target,
- fromRect = target.fromRect,
- toRect = getRect(target),
- prevFromRect = target.prevFromRect,
- prevToRect = target.prevToRect,
- animatingRect = state.rect,
- targetMatrix = matrix(target, true);
- if (targetMatrix) {
- // Compensate for current animation
- toRect.top -= targetMatrix.f;
- toRect.left -= targetMatrix.e;
- }
- target.toRect = toRect;
- if (target.thisAnimationDuration) {
- // Could also check if animatingRect is between fromRect and toRect
- if (isRectEqual(prevFromRect, toRect) && !isRectEqual(fromRect, toRect) && // Make sure animatingRect is on line between toRect & fromRect
- (animatingRect.top - toRect.top) / (animatingRect.left - toRect.left) === (fromRect.top - toRect.top) / (fromRect.left - toRect.left)) {
- // If returning to same place as started from animation and on same axis
- time = calculateRealTime(animatingRect, prevFromRect, prevToRect, _this.options);
- }
- } // if fromRect != toRect: animate
- if (!isRectEqual(toRect, fromRect)) {
- target.prevFromRect = fromRect;
- target.prevToRect = toRect;
- if (!time) {
- time = _this.options.animation;
- }
- _this.animate(target, animatingRect, toRect, time);
- }
- if (time) {
- animating = true;
- animationTime = Math.max(animationTime, time);
- clearTimeout(target.animationResetTimer);
- target.animationResetTimer = setTimeout(function () {
- target.animationTime = 0;
- target.prevFromRect = null;
- target.fromRect = null;
- target.prevToRect = null;
- target.thisAnimationDuration = null;
- }, time);
- target.thisAnimationDuration = time;
- }
- });
- clearTimeout(animationCallbackId);
- if (!animating) {
- if (typeof callback === 'function') callback();
- } else {
- animationCallbackId = setTimeout(function () {
- if (typeof callback === 'function') callback();
- }, animationTime);
- }
- animationStates = [];
- },
- animate: function animate(target, currentRect, toRect, duration) {
- if (duration) {
- css(target, 'transition', '');
- css(target, 'transform', '');
- var elMatrix = matrix(this.el),
- scaleX = elMatrix && elMatrix.a,
- scaleY = elMatrix && elMatrix.d,
- translateX = (currentRect.left - toRect.left) / (scaleX || 1),
- translateY = (currentRect.top - toRect.top) / (scaleY || 1);
- target.animatingX = !!translateX;
- target.animatingY = !!translateY;
- css(target, 'transform', 'translate3d(' + translateX + 'px,' + translateY + 'px,0)');
- this.forRepaintDummy = repaint(target); // repaint
- css(target, 'transition', 'transform ' + duration + 'ms' + (this.options.easing ? ' ' + this.options.easing : ''));
- css(target, 'transform', 'translate3d(0,0,0)');
- typeof target.animated === 'number' && clearTimeout(target.animated);
- target.animated = setTimeout(function () {
- css(target, 'transition', '');
- css(target, 'transform', '');
- target.animated = false;
- target.animatingX = false;
- target.animatingY = false;
- }, duration);
- }
- }
- };
- }
- function repaint(target) {
- return target.offsetWidth;
- }
- function calculateRealTime(animatingRect, fromRect, toRect, options) {
- return Math.sqrt(Math.pow(fromRect.top - animatingRect.top, 2) + Math.pow(fromRect.left - animatingRect.left, 2)) / Math.sqrt(Math.pow(fromRect.top - toRect.top, 2) + Math.pow(fromRect.left - toRect.left, 2)) * options.animation;
- }
- var plugins = [];
- var defaults = {
- initializeByDefault: true
- };
- var PluginManager = {
- mount: function mount(plugin) {
- // Set default static properties
- for (var option in defaults) {
- if (defaults.hasOwnProperty(option) && !(option in plugin)) {
- plugin[option] = defaults[option];
- }
- }
- plugins.forEach(function (p) {
- if (p.pluginName === plugin.pluginName) {
- throw "Sortable: Cannot mount plugin ".concat(plugin.pluginName, " more than once");
- }
- });
- plugins.push(plugin);
- },
- pluginEvent: function pluginEvent(eventName, sortable, evt) {
- var _this = this;
- this.eventCanceled = false;
- evt.cancel = function () {
- _this.eventCanceled = true;
- };
- var eventNameGlobal = eventName + 'Global';
- plugins.forEach(function (plugin) {
- if (!sortable[plugin.pluginName]) return; // Fire global events if it exists in this sortable
- if (sortable[plugin.pluginName][eventNameGlobal]) {
- sortable[plugin.pluginName][eventNameGlobal](_objectSpread2({
- sortable: sortable
- }, evt));
- } // Only fire plugin event if plugin is enabled in this sortable,
- // and plugin has event defined
- if (sortable.options[plugin.pluginName] && sortable[plugin.pluginName][eventName]) {
- sortable[plugin.pluginName][eventName](_objectSpread2({
- sortable: sortable
- }, evt));
- }
- });
- },
- initializePlugins: function initializePlugins(sortable, el, defaults, options) {
- plugins.forEach(function (plugin) {
- var pluginName = plugin.pluginName;
- if (!sortable.options[pluginName] && !plugin.initializeByDefault) return;
- var initialized = new plugin(sortable, el, sortable.options);
- initialized.sortable = sortable;
- initialized.options = sortable.options;
- sortable[pluginName] = initialized; // Add default options from plugin
- _extends(defaults, initialized.defaults);
- });
- for (var option in sortable.options) {
- if (!sortable.options.hasOwnProperty(option)) continue;
- var modified = this.modifyOption(sortable, option, sortable.options[option]);
- if (typeof modified !== 'undefined') {
- sortable.options[option] = modified;
- }
- }
- },
- getEventProperties: function getEventProperties(name, sortable) {
- var eventProperties = {};
- plugins.forEach(function (plugin) {
- if (typeof plugin.eventProperties !== 'function') return;
- _extends(eventProperties, plugin.eventProperties.call(sortable[plugin.pluginName], name));
- });
- return eventProperties;
- },
- modifyOption: function modifyOption(sortable, name, value) {
- var modifiedValue;
- plugins.forEach(function (plugin) {
- // Plugin must exist on the Sortable
- if (!sortable[plugin.pluginName]) return; // If static option listener exists for this option, call in the context of the Sortable's instance of this plugin
- if (plugin.optionListeners && typeof plugin.optionListeners[name] === 'function') {
- modifiedValue = plugin.optionListeners[name].call(sortable[plugin.pluginName], value);
- }
- });
- return modifiedValue;
- }
- };
- function dispatchEvent(_ref) {
- var sortable = _ref.sortable,
- rootEl = _ref.rootEl,
- name = _ref.name,
- targetEl = _ref.targetEl,
- cloneEl = _ref.cloneEl,
- toEl = _ref.toEl,
- fromEl = _ref.fromEl,
- oldIndex = _ref.oldIndex,
- newIndex = _ref.newIndex,
- oldDraggableIndex = _ref.oldDraggableIndex,
- newDraggableIndex = _ref.newDraggableIndex,
- originalEvent = _ref.originalEvent,
- putSortable = _ref.putSortable,
- extraEventProperties = _ref.extraEventProperties;
- sortable = sortable || rootEl && rootEl[expando];
- if (!sortable) return;
- var evt,
- options = sortable.options,
- onName = 'on' + name.charAt(0).toUpperCase() + name.substr(1); // Support for new CustomEvent feature
- if (window.CustomEvent && !IE11OrLess && !Edge) {
- evt = new CustomEvent(name, {
- bubbles: true,
- cancelable: true
- });
- } else {
- evt = document.createEvent('Event');
- evt.initEvent(name, true, true);
- }
- evt.to = toEl || rootEl;
- evt.from = fromEl || rootEl;
- evt.item = targetEl || rootEl;
- evt.clone = cloneEl;
- evt.oldIndex = oldIndex;
- evt.newIndex = newIndex;
- evt.oldDraggableIndex = oldDraggableIndex;
- evt.newDraggableIndex = newDraggableIndex;
- evt.originalEvent = originalEvent;
- evt.pullMode = putSortable ? putSortable.lastPutMode : undefined;
- var allEventProperties = _objectSpread2(_objectSpread2({}, extraEventProperties), PluginManager.getEventProperties(name, sortable));
- for (var option in allEventProperties) {
- evt[option] = allEventProperties[option];
- }
- if (rootEl) {
- rootEl.dispatchEvent(evt);
- }
- if (options[onName]) {
- options[onName].call(sortable, evt);
- }
- }
- var _excluded = ["evt"];
- var pluginEvent = function pluginEvent(eventName, sortable) {
- var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
- originalEvent = _ref.evt,
- data = _objectWithoutProperties(_ref, _excluded);
- PluginManager.pluginEvent.bind(Sortable)(eventName, sortable, _objectSpread2({
- dragEl: dragEl,
- parentEl: parentEl,
- ghostEl: ghostEl,
- rootEl: rootEl,
- nextEl: nextEl,
- lastDownEl: lastDownEl,
- cloneEl: cloneEl,
- cloneHidden: cloneHidden,
- dragStarted: moved,
- putSortable: putSortable,
- activeSortable: Sortable.active,
- originalEvent: originalEvent,
- oldIndex: oldIndex,
- oldDraggableIndex: oldDraggableIndex,
- newIndex: newIndex,
- newDraggableIndex: newDraggableIndex,
- hideGhostForTarget: _hideGhostForTarget,
- unhideGhostForTarget: _unhideGhostForTarget,
- cloneNowHidden: function cloneNowHidden() {
- cloneHidden = true;
- },
- cloneNowShown: function cloneNowShown() {
- cloneHidden = false;
- },
- dispatchSortableEvent: function dispatchSortableEvent(name) {
- _dispatchEvent({
- sortable: sortable,
- name: name,
- originalEvent: originalEvent
- });
- }
- }, data));
- };
- function _dispatchEvent(info) {
- dispatchEvent(_objectSpread2({
- putSortable: putSortable,
- cloneEl: cloneEl,
- targetEl: dragEl,
- rootEl: rootEl,
- oldIndex: oldIndex,
- oldDraggableIndex: oldDraggableIndex,
- newIndex: newIndex,
- newDraggableIndex: newDraggableIndex
- }, info));
- }
- var dragEl,
- parentEl,
- ghostEl,
- rootEl,
- nextEl,
- lastDownEl,
- cloneEl,
- cloneHidden,
- oldIndex,
- newIndex,
- oldDraggableIndex,
- newDraggableIndex,
- activeGroup,
- putSortable,
- awaitingDragStarted = false,
- ignoreNextClick = false,
- sortables = [],
- tapEvt,
- touchEvt,
- lastDx,
- lastDy,
- tapDistanceLeft,
- tapDistanceTop,
- moved,
- lastTarget,
- lastDirection,
- pastFirstInvertThresh = false,
- isCircumstantialInvert = false,
- targetMoveDistance,
- // For positioning ghost absolutely
- ghostRelativeParent,
- ghostRelativeParentInitialScroll = [],
- // (left, top)
- _silent = false,
- savedInputChecked = [];
- /** @const */
- var documentExists = typeof document !== 'undefined',
- PositionGhostAbsolutely = IOS,
- CSSFloatProperty = Edge || IE11OrLess ? 'cssFloat' : 'float',
- // This will not pass for IE9, because IE9 DnD only works on anchors
- supportDraggable = documentExists && !ChromeForAndroid && !IOS && 'draggable' in document.createElement('div'),
- supportCssPointerEvents = function () {
- if (!documentExists) return; // false when <= IE11
- if (IE11OrLess) {
- return false;
- }
- var el = document.createElement('x');
- el.style.cssText = 'pointer-events:auto';
- return el.style.pointerEvents === 'auto';
- }(),
- _detectDirection = function _detectDirection(el, options) {
- var elCSS = css(el),
- elWidth = parseInt(elCSS.width) - parseInt(elCSS.paddingLeft) - parseInt(elCSS.paddingRight) - parseInt(elCSS.borderLeftWidth) - parseInt(elCSS.borderRightWidth),
- child1 = getChild(el, 0, options),
- child2 = getChild(el, 1, options),
- firstChildCSS = child1 && css(child1),
- secondChildCSS = child2 && css(child2),
- firstChildWidth = firstChildCSS && parseInt(firstChildCSS.marginLeft) + parseInt(firstChildCSS.marginRight) + getRect(child1).width,
- secondChildWidth = secondChildCSS && parseInt(secondChildCSS.marginLeft) + parseInt(secondChildCSS.marginRight) + getRect(child2).width;
- if (elCSS.display === 'flex') {
- return elCSS.flexDirection === 'column' || elCSS.flexDirection === 'column-reverse' ? 'vertical' : 'horizontal';
- }
- if (elCSS.display === 'grid') {
- return elCSS.gridTemplateColumns.split(' ').length <= 1 ? 'vertical' : 'horizontal';
- }
- if (child1 && firstChildCSS["float"] && firstChildCSS["float"] !== 'none') {
- var touchingSideChild2 = firstChildCSS["float"] === 'left' ? 'left' : 'right';
- return child2 && (secondChildCSS.clear === 'both' || secondChildCSS.clear === touchingSideChild2) ? 'vertical' : 'horizontal';
- }
- return child1 && (firstChildCSS.display === 'block' || firstChildCSS.display === 'flex' || firstChildCSS.display === 'table' || firstChildCSS.display === 'grid' || firstChildWidth >= elWidth && elCSS[CSSFloatProperty] === 'none' || child2 && elCSS[CSSFloatProperty] === 'none' && firstChildWidth + secondChildWidth > elWidth) ? 'vertical' : 'horizontal';
- },
- _dragElInRowColumn = function _dragElInRowColumn(dragRect, targetRect, vertical) {
- var dragElS1Opp = vertical ? dragRect.left : dragRect.top,
- dragElS2Opp = vertical ? dragRect.right : dragRect.bottom,
- dragElOppLength = vertical ? dragRect.width : dragRect.height,
- targetS1Opp = vertical ? targetRect.left : targetRect.top,
- targetS2Opp = vertical ? targetRect.right : targetRect.bottom,
- targetOppLength = vertical ? targetRect.width : targetRect.height;
- return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2;
- },
- /**
- * Detects first nearest empty sortable to X and Y position using emptyInsertThreshold.
- * @param {Number} x X position
- * @param {Number} y Y position
- * @return {HTMLElement} Element of the first found nearest Sortable
- */
- _detectNearestEmptySortable = function _detectNearestEmptySortable(x, y) {
- var ret;
- sortables.some(function (sortable) {
- var threshold = sortable[expando].options.emptyInsertThreshold;
- if (!threshold || lastChild(sortable)) return;
- var rect = getRect(sortable),
- insideHorizontally = x >= rect.left - threshold && x <= rect.right + threshold,
- insideVertically = y >= rect.top - threshold && y <= rect.bottom + threshold;
- if (insideHorizontally && insideVertically) {
- return ret = sortable;
- }
- });
- return ret;
- },
- _prepareGroup = function _prepareGroup(options) {
- function toFn(value, pull) {
- return function (to, from, dragEl, evt) {
- var sameGroup = to.options.group.name && from.options.group.name && to.options.group.name === from.options.group.name;
- if (value == null && (pull || sameGroup)) {
- // Default pull value
- // Default pull and put value if same group
- return true;
- } else if (value == null || value === false) {
- return false;
- } else if (pull && value === 'clone') {
- return value;
- } else if (typeof value === 'function') {
- return toFn(value(to, from, dragEl, evt), pull)(to, from, dragEl, evt);
- } else {
- var otherGroup = (pull ? to : from).options.group.name;
- return value === true || typeof value === 'string' && value === otherGroup || value.join && value.indexOf(otherGroup) > -1;
- }
- };
- }
- var group = {};
- var originalGroup = options.group;
- if (!originalGroup || _typeof(originalGroup) != 'object') {
- originalGroup = {
- name: originalGroup
- };
- }
- group.name = originalGroup.name;
- group.checkPull = toFn(originalGroup.pull, true);
- group.checkPut = toFn(originalGroup.put);
- group.revertClone = originalGroup.revertClone;
- options.group = group;
- },
- _hideGhostForTarget = function _hideGhostForTarget() {
- if (!supportCssPointerEvents && ghostEl) {
- css(ghostEl, 'display', 'none');
- }
- },
- _unhideGhostForTarget = function _unhideGhostForTarget() {
- if (!supportCssPointerEvents && ghostEl) {
- css(ghostEl, 'display', '');
- }
- }; // #1184 fix - Prevent click event on fallback if dragged but item not changed position
- if (documentExists && !ChromeForAndroid) {
- document.addEventListener('click', function (evt) {
- if (ignoreNextClick) {
- evt.preventDefault();
- evt.stopPropagation && evt.stopPropagation();
- evt.stopImmediatePropagation && evt.stopImmediatePropagation();
- ignoreNextClick = false;
- return false;
- }
- }, true);
- }
- var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent(evt) {
- if (dragEl) {
- evt = evt.touches ? evt.touches[0] : evt;
- var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);
- if (nearest) {
- // Create imitation event
- var event = {};
- for (var i in evt) {
- if (evt.hasOwnProperty(i)) {
- event[i] = evt[i];
- }
- }
- event.target = event.rootEl = nearest;
- event.preventDefault = void 0;
- event.stopPropagation = void 0;
- nearest[expando]._onDragOver(event);
- }
- }
- };
- var _checkOutsideTargetEl = function _checkOutsideTargetEl(evt) {
- if (dragEl) {
- dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
- }
- };
- /**
- * @class Sortable
- * @param {HTMLElement} el
- * @param {Object} [options]
- */
- function Sortable(el, options) {
- if (!(el && el.nodeType && el.nodeType === 1)) {
- throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(el));
- }
- this.el = el; // root element
- this.options = options = _extends({}, options); // Export instance
- el[expando] = this;
- var defaults = {
- group: null,
- sort: true,
- disabled: false,
- store: null,
- handle: null,
- draggable: /^[uo]l$/i.test(el.nodeName) ? '>li' : '>*',
- swapThreshold: 1,
- // percentage; 0 <= x <= 1
- invertSwap: false,
- // invert always
- invertedSwapThreshold: null,
- // will be set to same as swapThreshold if default
- removeCloneOnHide: true,
- direction: function direction() {
- return _detectDirection(el, this.options);
- },
- ghostClass: 'sortable-ghost',
- chosenClass: 'sortable-chosen',
- dragClass: 'sortable-drag',
- ignore: 'a, img',
- filter: null,
- preventOnFilter: true,
- animation: 0,
- easing: null,
- setData: function setData(dataTransfer, dragEl) {
- dataTransfer.setData('Text', dragEl.textContent);
- },
- dropBubble: false,
- dragoverBubble: false,
- dataIdAttr: 'data-id',
- delay: 0,
- delayOnTouchOnly: false,
- touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
- forceFallback: false,
- fallbackClass: 'sortable-fallback',
- fallbackOnBody: false,
- fallbackTolerance: 0,
- fallbackOffset: {
- x: 0,
- y: 0
- },
- supportPointer: Sortable.supportPointer !== false && 'PointerEvent' in window && !Safari,
- emptyInsertThreshold: 5
- };
- PluginManager.initializePlugins(this, el, defaults); // Set default options
- for (var name in defaults) {
- !(name in options) && (options[name] = defaults[name]);
- }
- _prepareGroup(options); // Bind all private methods
- for (var fn in this) {
- if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
- this[fn] = this[fn].bind(this);
- }
- } // Setup drag mode
- this.nativeDraggable = options.forceFallback ? false : supportDraggable;
- if (this.nativeDraggable) {
- // Touch start threshold cannot be greater than the native dragstart threshold
- this.options.touchStartThreshold = 1;
- } // Bind events
- if (options.supportPointer) {
- on(el, 'pointerdown', this._onTapStart);
- } else {
- on(el, 'mousedown', this._onTapStart);
- on(el, 'touchstart', this._onTapStart);
- }
- if (this.nativeDraggable) {
- on(el, 'dragover', this);
- on(el, 'dragenter', this);
- }
- sortables.push(this.el); // Restore sorting
- options.store && options.store.get && this.sort(options.store.get(this) || []); // Add animation state manager
- _extends(this, AnimationStateManager());
- }
- Sortable.prototype =
- /** @lends Sortable.prototype */
- {
- constructor: Sortable,
- _isOutsideThisEl: function _isOutsideThisEl(target) {
- if (!this.el.contains(target) && target !== this.el) {
- lastTarget = null;
- }
- },
- _getDirection: function _getDirection(evt, target) {
- return typeof this.options.direction === 'function' ? this.options.direction.call(this, evt, target, dragEl) : this.options.direction;
- },
- _onTapStart: function _onTapStart(
- /** Event|TouchEvent */
- evt) {
- if (!evt.cancelable) return;
- var _this = this,
- el = this.el,
- options = this.options,
- preventOnFilter = options.preventOnFilter,
- type = evt.type,
- touch = evt.touches && evt.touches[0] || evt.pointerType && evt.pointerType === 'touch' && evt,
- target = (touch || evt).target,
- originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0] || evt.composedPath && evt.composedPath()[0]) || target,
- filter = options.filter;
- _saveInputCheckedState(el); // Don't trigger start event when an element is been dragged, otherwise the evt.oldindex always wrong when set option.group.
- if (dragEl) {
- return;
- }
- if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) {
- return; // only left button and enabled
- } // cancel dnd if original target is content editable
- if (originalTarget.isContentEditable) {
- return;
- } // Safari ignores further event handling after mousedown
- if (!this.nativeDraggable && Safari && target && target.tagName.toUpperCase() === 'SELECT') {
- return;
- }
- target = closest(target, options.draggable, el, false);
- if (target && target.animated) {
- return;
- }
- if (lastDownEl === target) {
- // Ignoring duplicate `down`
- return;
- } // Get the index of the dragged element within its parent
- oldIndex = index(target);
- oldDraggableIndex = index(target, options.draggable); // Check filter
- if (typeof filter === 'function') {
- if (filter.call(this, evt, target, this)) {
- _dispatchEvent({
- sortable: _this,
- rootEl: originalTarget,
- name: 'filter',
- targetEl: target,
- toEl: el,
- fromEl: el
- });
- pluginEvent('filter', _this, {
- evt: evt
- });
- preventOnFilter && evt.cancelable && evt.preventDefault();
- return; // cancel dnd
- }
- } else if (filter) {
- filter = filter.split(',').some(function (criteria) {
- criteria = closest(originalTarget, criteria.trim(), el, false);
- if (criteria) {
- _dispatchEvent({
- sortable: _this,
- rootEl: criteria,
- name: 'filter',
- targetEl: target,
- fromEl: el,
- toEl: el
- });
- pluginEvent('filter', _this, {
- evt: evt
- });
- return true;
- }
- });
- if (filter) {
- preventOnFilter && evt.cancelable && evt.preventDefault();
- return; // cancel dnd
- }
- }
- if (options.handle && !closest(originalTarget, options.handle, el, false)) {
- return;
- } // Prepare `dragstart`
- this._prepareDragStart(evt, touch, target);
- },
- _prepareDragStart: function _prepareDragStart(
- /** Event */
- evt,
- /** Touch */
- touch,
- /** HTMLElement */
- target) {
- var _this = this,
- el = _this.el,
- options = _this.options,
- ownerDocument = el.ownerDocument,
- dragStartFn;
- if (target && !dragEl && target.parentNode === el) {
- var dragRect = getRect(target);
- rootEl = el;
- dragEl = target;
- parentEl = dragEl.parentNode;
- nextEl = dragEl.nextSibling;
- lastDownEl = target;
- activeGroup = options.group;
- Sortable.dragged = dragEl;
- tapEvt = {
- target: dragEl,
- clientX: (touch || evt).clientX,
- clientY: (touch || evt).clientY
- };
- tapDistanceLeft = tapEvt.clientX - dragRect.left;
- tapDistanceTop = tapEvt.clientY - dragRect.top;
- this._lastX = (touch || evt).clientX;
- this._lastY = (touch || evt).clientY;
- dragEl.style['will-change'] = 'all';
- dragStartFn = function dragStartFn() {
- pluginEvent('delayEnded', _this, {
- evt: evt
- });
- if (Sortable.eventCanceled) {
- _this._onDrop();
- return;
- } // Delayed drag has been triggered
- // we can re-enable the events: touchmove/mousemove
- _this._disableDelayedDragEvents();
- if (!FireFox && _this.nativeDraggable) {
- dragEl.draggable = true;
- } // Bind the events: dragstart/dragend
- _this._triggerDragStart(evt, touch); // Drag start event
- _dispatchEvent({
- sortable: _this,
- name: 'choose',
- originalEvent: evt
- }); // Chosen item
- toggleClass(dragEl, options.chosenClass, true);
- }; // Disable "draggable"
- options.ignore.split(',').forEach(function (criteria) {
- find(dragEl, criteria.trim(), _disableDraggable);
- });
- on(ownerDocument, 'dragover', nearestEmptyInsertDetectEvent);
- on(ownerDocument, 'mousemove', nearestEmptyInsertDetectEvent);
- on(ownerDocument, 'touchmove', nearestEmptyInsertDetectEvent);
- on(ownerDocument, 'mouseup', _this._onDrop);
- on(ownerDocument, 'touchend', _this._onDrop);
- on(ownerDocument, 'touchcancel', _this._onDrop); // Make dragEl draggable (must be before delay for FireFox)
- if (FireFox && this.nativeDraggable) {
- this.options.touchStartThreshold = 4;
- dragEl.draggable = true;
- }
- pluginEvent('delayStart', this, {
- evt: evt
- }); // Delay is impossible for native DnD in Edge or IE
- if (options.delay && (!options.delayOnTouchOnly || touch) && (!this.nativeDraggable || !(Edge || IE11OrLess))) {
- if (Sortable.eventCanceled) {
- this._onDrop();
- return;
- } // If the user moves the pointer or let go the click or touch
- // before the delay has been reached:
- // disable the delayed drag
- on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
- on(ownerDocument, 'touchend', _this._disableDelayedDrag);
- on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
- on(ownerDocument, 'mousemove', _this._delayedDragTouchMoveHandler);
- on(ownerDocument, 'touchmove', _this._delayedDragTouchMoveHandler);
- options.supportPointer && on(ownerDocument, 'pointermove', _this._delayedDragTouchMoveHandler);
- _this._dragStartTimer = setTimeout(dragStartFn, options.delay);
- } else {
- dragStartFn();
- }
- }
- },
- _delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler(
- /** TouchEvent|PointerEvent **/
- e) {
- var touch = e.touches ? e.touches[0] : e;
- if (Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) >= Math.floor(this.options.touchStartThreshold / (this.nativeDraggable && window.devicePixelRatio || 1))) {
- this._disableDelayedDrag();
- }
- },
- _disableDelayedDrag: function _disableDelayedDrag() {
- dragEl && _disableDraggable(dragEl);
- clearTimeout(this._dragStartTimer);
- this._disableDelayedDragEvents();
- },
- _disableDelayedDragEvents: function _disableDelayedDragEvents() {
- var ownerDocument = this.el.ownerDocument;
- off(ownerDocument, 'mouseup', this._disableDelayedDrag);
- off(ownerDocument, 'touchend', this._disableDelayedDrag);
- off(ownerDocument, 'touchcancel', this._disableDelayedDrag);
- off(ownerDocument, 'mousemove', this._delayedDragTouchMoveHandler);
- off(ownerDocument, 'touchmove', this._delayedDragTouchMoveHandler);
- off(ownerDocument, 'pointermove', this._delayedDragTouchMoveHandler);
- },
- _triggerDragStart: function _triggerDragStart(
- /** Event */
- evt,
- /** Touch */
- touch) {
- touch = touch || evt.pointerType == 'touch' && evt;
- if (!this.nativeDraggable || touch) {
- if (this.options.supportPointer) {
- on(document, 'pointermove', this._onTouchMove);
- } else if (touch) {
- on(document, 'touchmove', this._onTouchMove);
- } else {
- on(document, 'mousemove', this._onTouchMove);
- }
- } else {
- on(dragEl, 'dragend', this);
- on(rootEl, 'dragstart', this._onDragStart);
- }
- try {
- if (document.selection) {
- // Timeout neccessary for IE9
- _nextTick(function () {
- document.selection.empty();
- });
- } else {
- window.getSelection().removeAllRanges();
- }
- } catch (err) {}
- },
- _dragStarted: function _dragStarted(fallback, evt) {
- awaitingDragStarted = false;
- if (rootEl && dragEl) {
- pluginEvent('dragStarted', this, {
- evt: evt
- });
- if (this.nativeDraggable) {
- on(document, 'dragover', _checkOutsideTargetEl);
- }
- var options = this.options; // Apply effect
- !fallback && toggleClass(dragEl, options.dragClass, false);
- toggleClass(dragEl, options.ghostClass, true);
- Sortable.active = this;
- fallback && this._appendGhost(); // Drag start event
- _dispatchEvent({
- sortable: this,
- name: 'start',
- originalEvent: evt
- });
- } else {
- this._nulling();
- }
- },
- _emulateDragOver: function _emulateDragOver() {
- if (touchEvt) {
- this._lastX = touchEvt.clientX;
- this._lastY = touchEvt.clientY;
- _hideGhostForTarget();
- var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
- var parent = target;
- while (target && target.shadowRoot) {
- target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
- if (target === parent) break;
- parent = target;
- }
- dragEl.parentNode[expando]._isOutsideThisEl(target);
- if (parent) {
- do {
- if (parent[expando]) {
- var inserted = void 0;
- inserted = parent[expando]._onDragOver({
- clientX: touchEvt.clientX,
- clientY: touchEvt.clientY,
- target: target,
- rootEl: parent
- });
- if (inserted && !this.options.dragoverBubble) {
- break;
- }
- }
- target = parent; // store last element
- }
- /* jshint boss:true */
- while (parent = parent.parentNode);
- }
- _unhideGhostForTarget();
- }
- },
- _onTouchMove: function _onTouchMove(
- /**TouchEvent*/
- evt) {
- if (tapEvt) {
- var options = this.options,
- fallbackTolerance = options.fallbackTolerance,
- fallbackOffset = options.fallbackOffset,
- touch = evt.touches ? evt.touches[0] : evt,
- ghostMatrix = ghostEl && matrix(ghostEl, true),
- scaleX = ghostEl && ghostMatrix && ghostMatrix.a,
- scaleY = ghostEl && ghostMatrix && ghostMatrix.d,
- relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset(ghostRelativeParent),
- dx = (touch.clientX - tapEvt.clientX + fallbackOffset.x) / (scaleX || 1) + (relativeScrollOffset ? relativeScrollOffset[0] - ghostRelativeParentInitialScroll[0] : 0) / (scaleX || 1),
- dy = (touch.clientY - tapEvt.clientY + fallbackOffset.y) / (scaleY || 1) + (relativeScrollOffset ? relativeScrollOffset[1] - ghostRelativeParentInitialScroll[1] : 0) / (scaleY || 1); // only set the status to dragging, when we are actually dragging
- if (!Sortable.active && !awaitingDragStarted) {
- if (fallbackTolerance && Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < fallbackTolerance) {
- return;
- }
- this._onDragStart(evt, true);
- }
- if (ghostEl) {
- if (ghostMatrix) {
- ghostMatrix.e += dx - (lastDx || 0);
- ghostMatrix.f += dy - (lastDy || 0);
- } else {
- ghostMatrix = {
- a: 1,
- b: 0,
- c: 0,
- d: 1,
- e: dx,
- f: dy
- };
- }
- var cssMatrix = "matrix(".concat(ghostMatrix.a, ",").concat(ghostMatrix.b, ",").concat(ghostMatrix.c, ",").concat(ghostMatrix.d, ",").concat(ghostMatrix.e, ",").concat(ghostMatrix.f, ")");
- css(ghostEl, 'webkitTransform', cssMatrix);
- css(ghostEl, 'mozTransform', cssMatrix);
- css(ghostEl, 'msTransform', cssMatrix);
- css(ghostEl, 'transform', cssMatrix);
- lastDx = dx;
- lastDy = dy;
- touchEvt = touch;
- }
- evt.cancelable && evt.preventDefault();
- }
- },
- _appendGhost: function _appendGhost() {
- // Bug if using scale(): https://stackoverflow.com/questions/2637058
- // Not being adjusted for
- if (!ghostEl) {
- var container = this.options.fallbackOnBody ? document.body : rootEl,
- rect = getRect(dragEl, true, PositionGhostAbsolutely, true, container),
- options = this.options; // Position absolutely
- if (PositionGhostAbsolutely) {
- // Get relatively positioned parent
- ghostRelativeParent = container;
- while (css(ghostRelativeParent, 'position') === 'static' && css(ghostRelativeParent, 'transform') === 'none' && ghostRelativeParent !== document) {
- ghostRelativeParent = ghostRelativeParent.parentNode;
- }
- if (ghostRelativeParent !== document.body && ghostRelativeParent !== document.documentElement) {
- if (ghostRelativeParent === document) ghostRelativeParent = getWindowScrollingElement();
- rect.top += ghostRelativeParent.scrollTop;
- rect.left += ghostRelativeParent.scrollLeft;
- } else {
- ghostRelativeParent = getWindowScrollingElement();
- }
- ghostRelativeParentInitialScroll = getRelativeScrollOffset(ghostRelativeParent);
- }
- ghostEl = dragEl.cloneNode(true);
- toggleClass(ghostEl, options.ghostClass, false);
- toggleClass(ghostEl, options.fallbackClass, true);
- toggleClass(ghostEl, options.dragClass, true);
- css(ghostEl, 'transition', '');
- css(ghostEl, 'transform', '');
- css(ghostEl, 'box-sizing', 'border-box');
- css(ghostEl, 'margin', 0);
- css(ghostEl, 'top', rect.top);
- css(ghostEl, 'left', rect.left);
- css(ghostEl, 'width', rect.width);
- css(ghostEl, 'height', rect.height);
- css(ghostEl, 'opacity', '0.8');
- css(ghostEl, 'position', PositionGhostAbsolutely ? 'absolute' : 'fixed');
- css(ghostEl, 'zIndex', '100000');
- css(ghostEl, 'pointerEvents', 'none');
- Sortable.ghost = ghostEl;
- container.appendChild(ghostEl); // Set transform-origin
- css(ghostEl, 'transform-origin', tapDistanceLeft / parseInt(ghostEl.style.width) * 100 + '% ' + tapDistanceTop / parseInt(ghostEl.style.height) * 100 + '%');
- }
- },
- _onDragStart: function _onDragStart(
- /**Event*/
- evt,
- /**boolean*/
- fallback) {
- var _this = this;
- var dataTransfer = evt.dataTransfer;
- var options = _this.options;
- pluginEvent('dragStart', this, {
- evt: evt
- });
- if (Sortable.eventCanceled) {
- this._onDrop();
- return;
- }
- pluginEvent('setupClone', this);
- if (!Sortable.eventCanceled) {
- cloneEl = clone(dragEl);
- cloneEl.removeAttribute("id");
- cloneEl.draggable = false;
- cloneEl.style['will-change'] = '';
- this._hideClone();
- toggleClass(cloneEl, this.options.chosenClass, false);
- Sortable.clone = cloneEl;
- } // #1143: IFrame support workaround
- _this.cloneId = _nextTick(function () {
- pluginEvent('clone', _this);
- if (Sortable.eventCanceled) return;
- if (!_this.options.removeCloneOnHide) {
- rootEl.insertBefore(cloneEl, dragEl);
- }
- _this._hideClone();
- _dispatchEvent({
- sortable: _this,
- name: 'clone'
- });
- });
- !fallback && toggleClass(dragEl, options.dragClass, true); // Set proper drop events
- if (fallback) {
- ignoreNextClick = true;
- _this._loopId = setInterval(_this._emulateDragOver, 50);
- } else {
- // Undo what was set in _prepareDragStart before drag started
- off(document, 'mouseup', _this._onDrop);
- off(document, 'touchend', _this._onDrop);
- off(document, 'touchcancel', _this._onDrop);
- if (dataTransfer) {
- dataTransfer.effectAllowed = 'move';
- options.setData && options.setData.call(_this, dataTransfer, dragEl);
- }
- on(document, 'drop', _this); // #1276 fix:
- css(dragEl, 'transform', 'translateZ(0)');
- }
- awaitingDragStarted = true;
- _this._dragStartId = _nextTick(_this._dragStarted.bind(_this, fallback, evt));
- on(document, 'selectstart', _this);
- moved = true;
- if (Safari) {
- css(document.body, 'user-select', 'none');
- }
- },
- // Returns true - if no further action is needed (either inserted or another condition)
- _onDragOver: function _onDragOver(
- /**Event*/
- evt) {
- var el = this.el,
- target = evt.target,
- dragRect,
- targetRect,
- revert,
- options = this.options,
- group = options.group,
- activeSortable = Sortable.active,
- isOwner = activeGroup === group,
- canSort = options.sort,
- fromSortable = putSortable || activeSortable,
- vertical,
- _this = this,
- completedFired = false;
- if (_silent) return;
- function dragOverEvent(name, extra) {
- pluginEvent(name, _this, _objectSpread2({
- evt: evt,
- isOwner: isOwner,
- axis: vertical ? 'vertical' : 'horizontal',
- revert: revert,
- dragRect: dragRect,
- targetRect: targetRect,
- canSort: canSort,
- fromSortable: fromSortable,
- target: target,
- completed: completed,
- onMove: function onMove(target, after) {
- return _onMove(rootEl, el, dragEl, dragRect, target, getRect(target), evt, after);
- },
- changed: changed
- }, extra));
- } // Capture animation state
- function capture() {
- dragOverEvent('dragOverAnimationCapture');
- _this.captureAnimationState();
- if (_this !== fromSortable) {
- fromSortable.captureAnimationState();
- }
- } // Return invocation when dragEl is inserted (or completed)
- function completed(insertion) {
- dragOverEvent('dragOverCompleted', {
- insertion: insertion
- });
- if (insertion) {
- // Clones must be hidden before folding animation to capture dragRectAbsolute properly
- if (isOwner) {
- activeSortable._hideClone();
- } else {
- activeSortable._showClone(_this);
- }
- if (_this !== fromSortable) {
- // Set ghost class to new sortable's ghost class
- toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false);
- toggleClass(dragEl, options.ghostClass, true);
- }
- if (putSortable !== _this && _this !== Sortable.active) {
- putSortable = _this;
- } else if (_this === Sortable.active && putSortable) {
- putSortable = null;
- } // Animation
- if (fromSortable === _this) {
- _this._ignoreWhileAnimating = target;
- }
- _this.animateAll(function () {
- dragOverEvent('dragOverAnimationComplete');
- _this._ignoreWhileAnimating = null;
- });
- if (_this !== fromSortable) {
- fromSortable.animateAll();
- fromSortable._ignoreWhileAnimating = null;
- }
- } // Null lastTarget if it is not inside a previously swapped element
- if (target === dragEl && !dragEl.animated || target === el && !target.animated) {
- lastTarget = null;
- } // no bubbling and not fallback
- if (!options.dragoverBubble && !evt.rootEl && target !== document) {
- dragEl.parentNode[expando]._isOutsideThisEl(evt.target); // Do not detect for empty insert if already inserted
- !insertion && nearestEmptyInsertDetectEvent(evt);
- }
- !options.dragoverBubble && evt.stopPropagation && evt.stopPropagation();
- return completedFired = true;
- } // Call when dragEl has been inserted
- function changed() {
- newIndex = index(dragEl);
- newDraggableIndex = index(dragEl, options.draggable);
- _dispatchEvent({
- sortable: _this,
- name: 'change',
- toEl: el,
- newIndex: newIndex,
- newDraggableIndex: newDraggableIndex,
- originalEvent: evt
- });
- }
- if (evt.preventDefault !== void 0) {
- evt.cancelable && evt.preventDefault();
- }
- target = closest(target, options.draggable, el, true);
- dragOverEvent('dragOver');
- if (Sortable.eventCanceled) return completedFired;
- if (dragEl.contains(evt.target) || target.animated && target.animatingX && target.animatingY || _this._ignoreWhileAnimating === target) {
- return completed(false);
- }
- ignoreNextClick = false;
- if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = parentEl !== rootEl) // Reverting item into the original list
- : putSortable === this || (this.lastPutMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && group.checkPut(this, activeSortable, dragEl, evt))) {
- vertical = this._getDirection(evt, target) === 'vertical';
- dragRect = getRect(dragEl);
- dragOverEvent('dragOverValid');
- if (Sortable.eventCanceled) return completedFired;
- if (revert) {
- parentEl = rootEl; // actualization
- capture();
- this._hideClone();
- dragOverEvent('revert');
- if (!Sortable.eventCanceled) {
- if (nextEl) {
- rootEl.insertBefore(dragEl, nextEl);
- } else {
- rootEl.appendChild(dragEl);
- }
- }
- return completed(true);
- }
- var elLastChild = lastChild(el, options.draggable);
- if (!elLastChild || _ghostIsLast(evt, vertical, this) && !elLastChild.animated) {
- // Insert to end of list
- // If already at end of list: Do not insert
- if (elLastChild === dragEl) {
- return completed(false);
- } // if there is a last element, it is the target
- if (elLastChild && el === evt.target) {
- target = elLastChild;
- }
- if (target) {
- targetRect = getRect(target);
- }
- if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, !!target) !== false) {
- capture();
- if (elLastChild && elLastChild.nextSibling) {
- // the last draggable element is not the last node
- el.insertBefore(dragEl, elLastChild.nextSibling);
- } else {
- el.appendChild(dragEl);
- }
- parentEl = el; // actualization
- changed();
- return completed(true);
- }
- } else if (elLastChild && _ghostIsFirst(evt, vertical, this)) {
- // Insert to start of list
- var firstChild = getChild(el, 0, options, true);
- if (firstChild === dragEl) {
- return completed(false);
- }
- target = firstChild;
- targetRect = getRect(target);
- if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, false) !== false) {
- capture();
- el.insertBefore(dragEl, firstChild);
- parentEl = el; // actualization
- changed();
- return completed(true);
- }
- } else if (target.parentNode === el) {
- targetRect = getRect(target);
- var direction = 0,
- targetBeforeFirstSwap,
- differentLevel = dragEl.parentNode !== el,
- differentRowCol = !_dragElInRowColumn(dragEl.animated && dragEl.toRect || dragRect, target.animated && target.toRect || targetRect, vertical),
- side1 = vertical ? 'top' : 'left',
- scrolledPastTop = isScrolledPast(target, 'top', 'top') || isScrolledPast(dragEl, 'top', 'top'),
- scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0;
- if (lastTarget !== target) {
- targetBeforeFirstSwap = targetRect[side1];
- pastFirstInvertThresh = false;
- isCircumstantialInvert = !differentRowCol && options.invertSwap || differentLevel;
- }
- direction = _getSwapDirection(evt, target, targetRect, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target);
- var sibling;
- if (direction !== 0) {
- // Check if target is beside dragEl in respective direction (ignoring hidden elements)
- var dragIndex = index(dragEl);
- do {
- dragIndex -= direction;
- sibling = parentEl.children[dragIndex];
- } while (sibling && (css(sibling, 'display') === 'none' || sibling === ghostEl));
- } // If dragEl is already beside target: Do not insert
- if (direction === 0 || sibling === target) {
- return completed(false);
- }
- lastTarget = target;
- lastDirection = direction;
- var nextSibling = target.nextElementSibling,
- after = false;
- after = direction === 1;
- var moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after);
- if (moveVector !== false) {
- if (moveVector === 1 || moveVector === -1) {
- after = moveVector === 1;
- }
- _silent = true;
- setTimeout(_unsilent, 30);
- capture();
- if (after && !nextSibling) {
- el.appendChild(dragEl);
- } else {
- target.parentNode.insertBefore(dragEl, after ? nextSibling : target);
- } // Undo chrome's scroll adjustment (has no effect on other browsers)
- if (scrolledPastTop) {
- scrollBy(scrolledPastTop, 0, scrollBefore - scrolledPastTop.scrollTop);
- }
- parentEl = dragEl.parentNode; // actualization
- // must be done before animation
- if (targetBeforeFirstSwap !== undefined && !isCircumstantialInvert) {
- targetMoveDistance = Math.abs(targetBeforeFirstSwap - getRect(target)[side1]);
- }
- changed();
- return completed(true);
- }
- }
- if (el.contains(dragEl)) {
- return completed(false);
- }
- }
- return false;
- },
- _ignoreWhileAnimating: null,
- _offMoveEvents: function _offMoveEvents() {
- off(document, 'mousemove', this._onTouchMove);
- off(document, 'touchmove', this._onTouchMove);
- off(document, 'pointermove', this._onTouchMove);
- off(document, 'dragover', nearestEmptyInsertDetectEvent);
- off(document, 'mousemove', nearestEmptyInsertDetectEvent);
- off(document, 'touchmove', nearestEmptyInsertDetectEvent);
- },
- _offUpEvents: function _offUpEvents() {
- var ownerDocument = this.el.ownerDocument;
- off(ownerDocument, 'mouseup', this._onDrop);
- off(ownerDocument, 'touchend', this._onDrop);
- off(ownerDocument, 'pointerup', this._onDrop);
- off(ownerDocument, 'touchcancel', this._onDrop);
- off(document, 'selectstart', this);
- },
- _onDrop: function _onDrop(
- /**Event*/
- evt) {
- var el = this.el,
- options = this.options; // Get the index of the dragged element within its parent
- newIndex = index(dragEl);
- newDraggableIndex = index(dragEl, options.draggable);
- pluginEvent('drop', this, {
- evt: evt
- });
- parentEl = dragEl && dragEl.parentNode; // Get again after plugin event
- newIndex = index(dragEl);
- newDraggableIndex = index(dragEl, options.draggable);
- if (Sortable.eventCanceled) {
- this._nulling();
- return;
- }
- awaitingDragStarted = false;
- isCircumstantialInvert = false;
- pastFirstInvertThresh = false;
- clearInterval(this._loopId);
- clearTimeout(this._dragStartTimer);
- _cancelNextTick(this.cloneId);
- _cancelNextTick(this._dragStartId); // Unbind events
- if (this.nativeDraggable) {
- off(document, 'drop', this);
- off(el, 'dragstart', this._onDragStart);
- }
- this._offMoveEvents();
- this._offUpEvents();
- if (Safari) {
- css(document.body, 'user-select', '');
- }
- css(dragEl, 'transform', '');
- if (evt) {
- if (moved) {
- evt.cancelable && evt.preventDefault();
- !options.dropBubble && evt.stopPropagation();
- }
- ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl);
- if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') {
- // Remove clone(s)
- cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl);
- }
- if (dragEl) {
- if (this.nativeDraggable) {
- off(dragEl, 'dragend', this);
- }
- _disableDraggable(dragEl);
- dragEl.style['will-change'] = ''; // Remove classes
- // ghostClass is added in dragStarted
- if (moved && !awaitingDragStarted) {
- toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : this.options.ghostClass, false);
- }
- toggleClass(dragEl, this.options.chosenClass, false); // Drag stop event
- _dispatchEvent({
- sortable: this,
- name: 'unchoose',
- toEl: parentEl,
- newIndex: null,
- newDraggableIndex: null,
- originalEvent: evt
- });
- if (rootEl !== parentEl) {
- if (newIndex >= 0) {
- // Add event
- _dispatchEvent({
- rootEl: parentEl,
- name: 'add',
- toEl: parentEl,
- fromEl: rootEl,
- originalEvent: evt
- }); // Remove event
- _dispatchEvent({
- sortable: this,
- name: 'remove',
- toEl: parentEl,
- originalEvent: evt
- }); // drag from one list and drop into another
- _dispatchEvent({
- rootEl: parentEl,
- name: 'sort',
- toEl: parentEl,
- fromEl: rootEl,
- originalEvent: evt
- });
- _dispatchEvent({
- sortable: this,
- name: 'sort',
- toEl: parentEl,
- originalEvent: evt
- });
- }
- putSortable && putSortable.save();
- } else {
- if (newIndex !== oldIndex) {
- if (newIndex >= 0) {
- // drag & drop within the same list
- _dispatchEvent({
- sortable: this,
- name: 'update',
- toEl: parentEl,
- originalEvent: evt
- });
- _dispatchEvent({
- sortable: this,
- name: 'sort',
- toEl: parentEl,
- originalEvent: evt
- });
- }
- }
- }
- if (Sortable.active) {
- /* jshint eqnull:true */
- if (newIndex == null || newIndex === -1) {
- newIndex = oldIndex;
- newDraggableIndex = oldDraggableIndex;
- }
- _dispatchEvent({
- sortable: this,
- name: 'end',
- toEl: parentEl,
- originalEvent: evt
- }); // Save sorting
- this.save();
- }
- }
- }
- this._nulling();
- },
- _nulling: function _nulling() {
- pluginEvent('nulling', this);
- rootEl = dragEl = parentEl = ghostEl = nextEl = cloneEl = lastDownEl = cloneHidden = tapEvt = touchEvt = moved = newIndex = newDraggableIndex = oldIndex = oldDraggableIndex = lastTarget = lastDirection = putSortable = activeGroup = Sortable.dragged = Sortable.ghost = Sortable.clone = Sortable.active = null;
- savedInputChecked.forEach(function (el) {
- el.checked = true;
- });
- savedInputChecked.length = lastDx = lastDy = 0;
- },
- handleEvent: function handleEvent(
- /**Event*/
- evt) {
- switch (evt.type) {
- case 'drop':
- case 'dragend':
- this._onDrop(evt);
- break;
- case 'dragenter':
- case 'dragover':
- if (dragEl) {
- this._onDragOver(evt);
- _globalDragOver(evt);
- }
- break;
- case 'selectstart':
- evt.preventDefault();
- break;
- }
- },
- /**
- * Serializes the item into an array of string.
- * @returns {String[]}
- */
- toArray: function toArray() {
- var order = [],
- el,
- children = this.el.children,
- i = 0,
- n = children.length,
- options = this.options;
- for (; i < n; i++) {
- el = children[i];
- if (closest(el, options.draggable, this.el, false)) {
- order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
- }
- }
- return order;
- },
- /**
- * Sorts the elements according to the array.
- * @param {String[]} order order of the items
- */
- sort: function sort(order, useAnimation) {
- var items = {},
- rootEl = this.el;
- this.toArray().forEach(function (id, i) {
- var el = rootEl.children[i];
- if (closest(el, this.options.draggable, rootEl, false)) {
- items[id] = el;
- }
- }, this);
- useAnimation && this.captureAnimationState();
- order.forEach(function (id) {
- if (items[id]) {
- rootEl.removeChild(items[id]);
- rootEl.appendChild(items[id]);
- }
- });
- useAnimation && this.animateAll();
- },
- /**
- * Save the current sorting
- */
- save: function save() {
- var store = this.options.store;
- store && store.set && store.set(this);
- },
- /**
- * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
- * @param {HTMLElement} el
- * @param {String} [selector] default: `options.draggable`
- * @returns {HTMLElement|null}
- */
- closest: function closest$1(el, selector) {
- return closest(el, selector || this.options.draggable, this.el, false);
- },
- /**
- * Set/get option
- * @param {string} name
- * @param {*} [value]
- * @returns {*}
- */
- option: function option(name, value) {
- var options = this.options;
- if (value === void 0) {
- return options[name];
- } else {
- var modifiedValue = PluginManager.modifyOption(this, name, value);
- if (typeof modifiedValue !== 'undefined') {
- options[name] = modifiedValue;
- } else {
- options[name] = value;
- }
- if (name === 'group') {
- _prepareGroup(options);
- }
- }
- },
- /**
- * Destroy
- */
- destroy: function destroy() {
- pluginEvent('destroy', this);
- var el = this.el;
- el[expando] = null;
- off(el, 'mousedown', this._onTapStart);
- off(el, 'touchstart', this._onTapStart);
- off(el, 'pointerdown', this._onTapStart);
- if (this.nativeDraggable) {
- off(el, 'dragover', this);
- off(el, 'dragenter', this);
- } // Remove draggable attributes
- Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function (el) {
- el.removeAttribute('draggable');
- });
- this._onDrop();
- this._disableDelayedDragEvents();
- sortables.splice(sortables.indexOf(this.el), 1);
- this.el = el = null;
- },
- _hideClone: function _hideClone() {
- if (!cloneHidden) {
- pluginEvent('hideClone', this);
- if (Sortable.eventCanceled) return;
- css(cloneEl, 'display', 'none');
- if (this.options.removeCloneOnHide && cloneEl.parentNode) {
- cloneEl.parentNode.removeChild(cloneEl);
- }
- cloneHidden = true;
- }
- },
- _showClone: function _showClone(putSortable) {
- if (putSortable.lastPutMode !== 'clone') {
- this._hideClone();
- return;
- }
- if (cloneHidden) {
- pluginEvent('showClone', this);
- if (Sortable.eventCanceled) return; // show clone at dragEl or original position
- if (dragEl.parentNode == rootEl && !this.options.group.revertClone) {
- rootEl.insertBefore(cloneEl, dragEl);
- } else if (nextEl) {
- rootEl.insertBefore(cloneEl, nextEl);
- } else {
- rootEl.appendChild(cloneEl);
- }
- if (this.options.group.revertClone) {
- this.animate(dragEl, cloneEl);
- }
- css(cloneEl, 'display', '');
- cloneHidden = false;
- }
- }
- };
- function _globalDragOver(
- /**Event*/
- evt) {
- if (evt.dataTransfer) {
- evt.dataTransfer.dropEffect = 'move';
- }
- evt.cancelable && evt.preventDefault();
- }
- function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvent, willInsertAfter) {
- var evt,
- sortable = fromEl[expando],
- onMoveFn = sortable.options.onMove,
- retVal; // Support for new CustomEvent feature
- if (window.CustomEvent && !IE11OrLess && !Edge) {
- evt = new CustomEvent('move', {
- bubbles: true,
- cancelable: true
- });
- } else {
- evt = document.createEvent('Event');
- evt.initEvent('move', true, true);
- }
- evt.to = toEl;
- evt.from = fromEl;
- evt.dragged = dragEl;
- evt.draggedRect = dragRect;
- evt.related = targetEl || toEl;
- evt.relatedRect = targetRect || getRect(toEl);
- evt.willInsertAfter = willInsertAfter;
- evt.originalEvent = originalEvent;
- fromEl.dispatchEvent(evt);
- if (onMoveFn) {
- retVal = onMoveFn.call(sortable, evt, originalEvent);
- }
- return retVal;
- }
- function _disableDraggable(el) {
- el.draggable = false;
- }
- function _unsilent() {
- _silent = false;
- }
- function _ghostIsFirst(evt, vertical, sortable) {
- var rect = getRect(getChild(sortable.el, 0, sortable.options, true));
- var spacer = 10;
- return vertical ? evt.clientX < rect.left - spacer || evt.clientY < rect.top && evt.clientX < rect.right : evt.clientY < rect.top - spacer || evt.clientY < rect.bottom && evt.clientX < rect.left;
- }
- function _ghostIsLast(evt, vertical, sortable) {
- var rect = getRect(lastChild(sortable.el, sortable.options.draggable));
- var spacer = 10;
- return vertical ? evt.clientX > rect.right + spacer || evt.clientX <= rect.right && evt.clientY > rect.bottom && evt.clientX >= rect.left : evt.clientX > rect.right && evt.clientY > rect.top || evt.clientX <= rect.right && evt.clientY > rect.bottom + spacer;
- }
- function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
- var mouseOnAxis = vertical ? evt.clientY : evt.clientX,
- targetLength = vertical ? targetRect.height : targetRect.width,
- targetS1 = vertical ? targetRect.top : targetRect.left,
- targetS2 = vertical ? targetRect.bottom : targetRect.right,
- invert = false;
- if (!invertSwap) {
- // Never invert or create dragEl shadow when target movemenet causes mouse to move past the end of regular swapThreshold
- if (isLastTarget && targetMoveDistance < targetLength * swapThreshold) {
- // multiplied only by swapThreshold because mouse will already be inside target by (1 - threshold) * targetLength / 2
- // check if past first invert threshold on side opposite of lastDirection
- if (!pastFirstInvertThresh && (lastDirection === 1 ? mouseOnAxis > targetS1 + targetLength * invertedSwapThreshold / 2 : mouseOnAxis < targetS2 - targetLength * invertedSwapThreshold / 2)) {
- // past first invert threshold, do not restrict inverted threshold to dragEl shadow
- pastFirstInvertThresh = true;
- }
- if (!pastFirstInvertThresh) {
- // dragEl shadow (target move distance shadow)
- if (lastDirection === 1 ? mouseOnAxis < targetS1 + targetMoveDistance // over dragEl shadow
- : mouseOnAxis > targetS2 - targetMoveDistance) {
- return -lastDirection;
- }
- } else {
- invert = true;
- }
- } else {
- // Regular
- if (mouseOnAxis > targetS1 + targetLength * (1 - swapThreshold) / 2 && mouseOnAxis < targetS2 - targetLength * (1 - swapThreshold) / 2) {
- return _getInsertDirection(target);
- }
- }
- }
- invert = invert || invertSwap;
- if (invert) {
- // Invert of regular
- if (mouseOnAxis < targetS1 + targetLength * invertedSwapThreshold / 2 || mouseOnAxis > targetS2 - targetLength * invertedSwapThreshold / 2) {
- return mouseOnAxis > targetS1 + targetLength / 2 ? 1 : -1;
- }
- }
- return 0;
- }
- /**
- * Gets the direction dragEl must be swapped relative to target in order to make it
- * seem that dragEl has been "inserted" into that element's position
- * @param {HTMLElement} target The target whose position dragEl is being inserted at
- * @return {Number} Direction dragEl must be swapped
- */
- function _getInsertDirection(target) {
- if (index(dragEl) < index(target)) {
- return 1;
- } else {
- return -1;
- }
- }
- /**
- * Generate id
- * @param {HTMLElement} el
- * @returns {String}
- * @private
- */
- function _generateId(el) {
- var str = el.tagName + el.className + el.src + el.href + el.textContent,
- i = str.length,
- sum = 0;
- while (i--) {
- sum += str.charCodeAt(i);
- }
- return sum.toString(36);
- }
- function _saveInputCheckedState(root) {
- savedInputChecked.length = 0;
- var inputs = root.getElementsByTagName('input');
- var idx = inputs.length;
- while (idx--) {
- var el = inputs[idx];
- el.checked && savedInputChecked.push(el);
- }
- }
- function _nextTick(fn) {
- return setTimeout(fn, 0);
- }
- function _cancelNextTick(id) {
- return clearTimeout(id);
- } // Fixed #973:
- if (documentExists) {
- on(document, 'touchmove', function (evt) {
- if ((Sortable.active || awaitingDragStarted) && evt.cancelable) {
- evt.preventDefault();
- }
- });
- } // Export utils
- Sortable.utils = {
- on: on,
- off: off,
- css: css,
- find: find,
- is: function is(el, selector) {
- return !!closest(el, selector, el, false);
- },
- extend: extend,
- throttle: throttle,
- closest: closest,
- toggleClass: toggleClass,
- clone: clone,
- index: index,
- nextTick: _nextTick,
- cancelNextTick: _cancelNextTick,
- detectDirection: _detectDirection,
- getChild: getChild
- };
- /**
- * Get the Sortable instance of an element
- * @param {HTMLElement} element The element
- * @return {Sortable|undefined} The instance of Sortable
- */
- Sortable.get = function (element) {
- return element[expando];
- };
- /**
- * Mount a plugin to Sortable
- * @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted
- */
- Sortable.mount = function () {
- for (var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++) {
- plugins[_key] = arguments[_key];
- }
- if (plugins[0].constructor === Array) plugins = plugins[0];
- plugins.forEach(function (plugin) {
- if (!plugin.prototype || !plugin.prototype.constructor) {
- throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(plugin));
- }
- if (plugin.utils) Sortable.utils = _objectSpread2(_objectSpread2({}, Sortable.utils), plugin.utils);
- PluginManager.mount(plugin);
- });
- };
- /**
- * Create sortable instance
- * @param {HTMLElement} el
- * @param {Object} [options]
- */
- Sortable.create = function (el, options) {
- return new Sortable(el, options);
- }; // Export
- Sortable.version = version;
- var autoScrolls = [],
- scrollEl,
- scrollRootEl,
- scrolling = false,
- lastAutoScrollX,
- lastAutoScrollY,
- touchEvt$1,
- pointerElemChangedInterval;
- function AutoScrollPlugin() {
- function AutoScroll() {
- this.defaults = {
- scroll: true,
- forceAutoScrollFallback: false,
- scrollSensitivity: 30,
- scrollSpeed: 10,
- bubbleScroll: true
- }; // Bind all private methods
- for (var fn in this) {
- if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
- this[fn] = this[fn].bind(this);
- }
- }
- }
- AutoScroll.prototype = {
- dragStarted: function dragStarted(_ref) {
- var originalEvent = _ref.originalEvent;
- if (this.sortable.nativeDraggable) {
- on(document, 'dragover', this._handleAutoScroll);
- } else {
- if (this.options.supportPointer) {
- on(document, 'pointermove', this._handleFallbackAutoScroll);
- } else if (originalEvent.touches) {
- on(document, 'touchmove', this._handleFallbackAutoScroll);
- } else {
- on(document, 'mousemove', this._handleFallbackAutoScroll);
- }
- }
- },
- dragOverCompleted: function dragOverCompleted(_ref2) {
- var originalEvent = _ref2.originalEvent;
- // For when bubbling is canceled and using fallback (fallback 'touchmove' always reached)
- if (!this.options.dragOverBubble && !originalEvent.rootEl) {
- this._handleAutoScroll(originalEvent);
- }
- },
- drop: function drop() {
- if (this.sortable.nativeDraggable) {
- off(document, 'dragover', this._handleAutoScroll);
- } else {
- off(document, 'pointermove', this._handleFallbackAutoScroll);
- off(document, 'touchmove', this._handleFallbackAutoScroll);
- off(document, 'mousemove', this._handleFallbackAutoScroll);
- }
- clearPointerElemChangedInterval();
- clearAutoScrolls();
- cancelThrottle();
- },
- nulling: function nulling() {
- touchEvt$1 = scrollRootEl = scrollEl = scrolling = pointerElemChangedInterval = lastAutoScrollX = lastAutoScrollY = null;
- autoScrolls.length = 0;
- },
- _handleFallbackAutoScroll: function _handleFallbackAutoScroll(evt) {
- this._handleAutoScroll(evt, true);
- },
- _handleAutoScroll: function _handleAutoScroll(evt, fallback) {
- var _this = this;
- var x = (evt.touches ? evt.touches[0] : evt).clientX,
- y = (evt.touches ? evt.touches[0] : evt).clientY,
- elem = document.elementFromPoint(x, y);
- touchEvt$1 = evt; // IE does not seem to have native autoscroll,
- // Edge's autoscroll seems too conditional,
- // MACOS Safari does not have autoscroll,
- // Firefox and Chrome are good
- if (fallback || this.options.forceAutoScrollFallback || Edge || IE11OrLess || Safari) {
- autoScroll(evt, this.options, elem, fallback); // Listener for pointer element change
- var ogElemScroller = getParentAutoScrollElement(elem, true);
- if (scrolling && (!pointerElemChangedInterval || x !== lastAutoScrollX || y !== lastAutoScrollY)) {
- pointerElemChangedInterval && clearPointerElemChangedInterval(); // Detect for pointer elem change, emulating native DnD behaviour
- pointerElemChangedInterval = setInterval(function () {
- var newElem = getParentAutoScrollElement(document.elementFromPoint(x, y), true);
- if (newElem !== ogElemScroller) {
- ogElemScroller = newElem;
- clearAutoScrolls();
- }
- autoScroll(evt, _this.options, newElem, fallback);
- }, 10);
- lastAutoScrollX = x;
- lastAutoScrollY = y;
- }
- } else {
- // if DnD is enabled (and browser has good autoscrolling), first autoscroll will already scroll, so get parent autoscroll of first autoscroll
- if (!this.options.bubbleScroll || getParentAutoScrollElement(elem, true) === getWindowScrollingElement()) {
- clearAutoScrolls();
- return;
- }
- autoScroll(evt, this.options, getParentAutoScrollElement(elem, false), false);
- }
- }
- };
- return _extends(AutoScroll, {
- pluginName: 'scroll',
- initializeByDefault: true
- });
- }
- function clearAutoScrolls() {
- autoScrolls.forEach(function (autoScroll) {
- clearInterval(autoScroll.pid);
- });
- autoScrolls = [];
- }
- function clearPointerElemChangedInterval() {
- clearInterval(pointerElemChangedInterval);
- }
- var autoScroll = throttle(function (evt, options, rootEl, isFallback) {
- // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521
- if (!options.scroll) return;
- var x = (evt.touches ? evt.touches[0] : evt).clientX,
- y = (evt.touches ? evt.touches[0] : evt).clientY,
- sens = options.scrollSensitivity,
- speed = options.scrollSpeed,
- winScroller = getWindowScrollingElement();
- var scrollThisInstance = false,
- scrollCustomFn; // New scroll root, set scrollEl
- if (scrollRootEl !== rootEl) {
- scrollRootEl = rootEl;
- clearAutoScrolls();
- scrollEl = options.scroll;
- scrollCustomFn = options.scrollFn;
- if (scrollEl === true) {
- scrollEl = getParentAutoScrollElement(rootEl, true);
- }
- }
- var layersOut = 0;
- var currentParent = scrollEl;
- do {
- var el = currentParent,
- rect = getRect(el),
- top = rect.top,
- bottom = rect.bottom,
- left = rect.left,
- right = rect.right,
- width = rect.width,
- height = rect.height,
- canScrollX = void 0,
- canScrollY = void 0,
- scrollWidth = el.scrollWidth,
- scrollHeight = el.scrollHeight,
- elCSS = css(el),
- scrollPosX = el.scrollLeft,
- scrollPosY = el.scrollTop;
- if (el === winScroller) {
- canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll' || elCSS.overflowX === 'visible');
- canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll' || elCSS.overflowY === 'visible');
- } else {
- canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll');
- canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll');
- }
- var vx = canScrollX && (Math.abs(right - x) <= sens && scrollPosX + width < scrollWidth) - (Math.abs(left - x) <= sens && !!scrollPosX);
- var vy = canScrollY && (Math.abs(bottom - y) <= sens && scrollPosY + height < scrollHeight) - (Math.abs(top - y) <= sens && !!scrollPosY);
- if (!autoScrolls[layersOut]) {
- for (var i = 0; i <= layersOut; i++) {
- if (!autoScrolls[i]) {
- autoScrolls[i] = {};
- }
- }
- }
- if (autoScrolls[layersOut].vx != vx || autoScrolls[layersOut].vy != vy || autoScrolls[layersOut].el !== el) {
- autoScrolls[layersOut].el = el;
- autoScrolls[layersOut].vx = vx;
- autoScrolls[layersOut].vy = vy;
- clearInterval(autoScrolls[layersOut].pid);
- if (vx != 0 || vy != 0) {
- scrollThisInstance = true;
- /* jshint loopfunc:true */
- autoScrolls[layersOut].pid = setInterval(function () {
- // emulate drag over during autoscroll (fallback), emulating native DnD behaviour
- if (isFallback && this.layer === 0) {
- Sortable.active._onTouchMove(touchEvt$1); // To move ghost if it is positioned absolutely
- }
- var scrollOffsetY = autoScrolls[this.layer].vy ? autoScrolls[this.layer].vy * speed : 0;
- var scrollOffsetX = autoScrolls[this.layer].vx ? autoScrolls[this.layer].vx * speed : 0;
- if (typeof scrollCustomFn === 'function') {
- if (scrollCustomFn.call(Sortable.dragged.parentNode[expando], scrollOffsetX, scrollOffsetY, evt, touchEvt$1, autoScrolls[this.layer].el) !== 'continue') {
- return;
- }
- }
- scrollBy(autoScrolls[this.layer].el, scrollOffsetX, scrollOffsetY);
- }.bind({
- layer: layersOut
- }), 24);
- }
- }
- layersOut++;
- } while (options.bubbleScroll && currentParent !== winScroller && (currentParent = getParentAutoScrollElement(currentParent, false)));
- scrolling = scrollThisInstance; // in case another function catches scrolling as false in between when it is not
- }, 30);
- var drop = function drop(_ref) {
- var originalEvent = _ref.originalEvent,
- putSortable = _ref.putSortable,
- dragEl = _ref.dragEl,
- activeSortable = _ref.activeSortable,
- dispatchSortableEvent = _ref.dispatchSortableEvent,
- hideGhostForTarget = _ref.hideGhostForTarget,
- unhideGhostForTarget = _ref.unhideGhostForTarget;
- if (!originalEvent) return;
- var toSortable = putSortable || activeSortable;
- hideGhostForTarget();
- var touch = originalEvent.changedTouches && originalEvent.changedTouches.length ? originalEvent.changedTouches[0] : originalEvent;
- var target = document.elementFromPoint(touch.clientX, touch.clientY);
- unhideGhostForTarget();
- if (toSortable && !toSortable.el.contains(target)) {
- dispatchSortableEvent('spill');
- this.onSpill({
- dragEl: dragEl,
- putSortable: putSortable
- });
- }
- };
- function Revert() {}
- Revert.prototype = {
- startIndex: null,
- dragStart: function dragStart(_ref2) {
- var oldDraggableIndex = _ref2.oldDraggableIndex;
- this.startIndex = oldDraggableIndex;
- },
- onSpill: function onSpill(_ref3) {
- var dragEl = _ref3.dragEl,
- putSortable = _ref3.putSortable;
- this.sortable.captureAnimationState();
- if (putSortable) {
- putSortable.captureAnimationState();
- }
- var nextSibling = getChild(this.sortable.el, this.startIndex, this.options);
- if (nextSibling) {
- this.sortable.el.insertBefore(dragEl, nextSibling);
- } else {
- this.sortable.el.appendChild(dragEl);
- }
- this.sortable.animateAll();
- if (putSortable) {
- putSortable.animateAll();
- }
- },
- drop: drop
- };
- _extends(Revert, {
- pluginName: 'revertOnSpill'
- });
- function Remove() {}
- Remove.prototype = {
- onSpill: function onSpill(_ref4) {
- var dragEl = _ref4.dragEl,
- putSortable = _ref4.putSortable;
- var parentSortable = putSortable || this.sortable;
- parentSortable.captureAnimationState();
- dragEl.parentNode && dragEl.parentNode.removeChild(dragEl);
- parentSortable.animateAll();
- },
- drop: drop
- };
- _extends(Remove, {
- pluginName: 'removeOnSpill'
- });
- Sortable.mount(new AutoScrollPlugin());
- Sortable.mount(Remove, Revert);
- const CSS$8 = {
- sortItem: "sort-item",
- container: "container",
- containerHorizontal: "container--horizontal",
- containerVertical: "container--vertical"
- };
- const sortableListCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:-ms-flexbox;display:flex}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.container{display:-ms-flexbox;display:flex;-ms-flex:1 1 auto;flex:1 1 auto}.container--vertical{-ms-flex-direction:column;flex-direction:column}.container--horizontal{-ms-flex-direction:row;flex-direction:row}";
- const SortableList = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteListOrderChange = createEvent(this, "calciteListOrderChange", 7);
- /**
- * The selector for the handle elements.
- */
- this.handleSelector = "calcite-handle";
- /**
- * Indicates the horizontal or vertical orientation of the component.
- */
- this.layout = "vertical";
- /**
- * When true, disabled prevents interaction. This state shows items with lower opacity/grayed.
- */
- this.disabled = false;
- /**
- * When true, content is waiting to be loaded. This state shows a busy indicator.
- */
- this.loading = false;
- this.handleActivated = false;
- this.items = [];
- this.mutationObserver = createObserver("mutation", () => {
- this.cleanUpDragAndDrop();
- this.items = Array.from(this.el.children);
- this.setUpDragAndDrop();
- });
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- this.items = Array.from(this.el.children);
- this.setUpDragAndDrop();
- this.beginObserving();
- }
- disconnectedCallback() {
- var _a;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- this.cleanUpDragAndDrop();
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- calciteHandleNudgeHandler(event) {
- var _a;
- const sortItem = this.items.find((item) => {
- return item.contains(event.detail.handle) || event.composedPath().includes(item);
- });
- const lastIndex = this.items.length - 1;
- const startingIndex = this.items.indexOf(sortItem);
- let appendInstead = false;
- let buddyIndex;
- switch (event.detail.direction) {
- case "up":
- event.preventDefault();
- if (startingIndex === 0) {
- appendInstead = true;
- }
- else {
- buddyIndex = startingIndex - 1;
- }
- break;
- case "down":
- event.preventDefault();
- if (startingIndex === lastIndex) {
- buddyIndex = 0;
- }
- else if (startingIndex === lastIndex - 1) {
- appendInstead = true;
- }
- else {
- buddyIndex = startingIndex + 2;
- }
- break;
- default:
- return;
- }
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- if (appendInstead) {
- sortItem.parentElement.appendChild(sortItem);
- }
- else {
- sortItem.parentElement.insertBefore(sortItem, this.items[buddyIndex]);
- }
- this.items = Array.from(this.el.children);
- event.detail.handle.activated = true;
- event.detail.handle.setFocus();
- this.beginObserving();
- }
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- setUpDragAndDrop() {
- this.cleanUpDragAndDrop();
- const options = {
- dataIdAttr: "id",
- group: this.group,
- handle: this.handleSelector,
- // Changed sorting within list
- onUpdate: () => {
- this.items = Array.from(this.el.children);
- this.calciteListOrderChange.emit();
- },
- // Element dragging started
- onStart: () => {
- var _a;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- },
- // Element dragging ended
- onEnd: () => {
- this.beginObserving();
- }
- };
- if (this.dragSelector) {
- options.draggable = this.dragSelector;
- }
- this.sortable = Sortable.create(this.el, options);
- }
- cleanUpDragAndDrop() {
- var _a;
- (_a = this.sortable) === null || _a === void 0 ? void 0 : _a.destroy();
- this.sortable = null;
- }
- beginObserving() {
- var _a;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- render() {
- const { layout } = this;
- const horizontal = layout === "horizontal" || false;
- return (h("div", { class: {
- [CSS$8.container]: true,
- [CSS$8.containerVertical]: !horizontal,
- [CSS$8.containerHorizontal]: horizontal
- } }, h("slot", null)));
- }
- get el() { return this; }
- static get style() { return sortableListCss; }
- };
- const CSS$7 = {
- container: "split-button__container",
- dividerContainer: "split-button__divider-container",
- divider: "split-button__divider",
- widthAuto: "width-auto",
- widthHalf: "width-half",
- widthFull: "width-full"
- };
- const splitButtonCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:inline-block}:host .split-button__container{display:-ms-flexbox;display:flex;-ms-flex-align:stretch;align-items:stretch}:host .split-button__container>calcite-dropdown>calcite-button{height:100%;vertical-align:top}:host([appearance=solid]):host([color=blue]){--calcite-split-button-background:var(--calcite-ui-brand);--calcite-split-button-divider:var(--calcite-ui-foreground-1)}:host([appearance=solid]):host([color=red]){--calcite-split-button-background:var(--calcite-ui-danger);--calcite-split-button-divider:var(--calcite-ui-foreground-1)}:host([appearance=solid]):host([color=neutral]){--calcite-split-button-background:var(--calcite-ui-foreground-3);--calcite-split-button-divider:var(--calcite-ui-text-1)}:host([appearance=solid]):host([color=inverse]){--calcite-split-button-background:var(--calcite-ui-inverse);--calcite-split-button-divider:var(--calcite-ui-foreground-1)}:host([appearance=transparent]):host([color=blue]){--calcite-split-button-divider:var(--calcite-ui-brand)}:host([appearance=transparent]):host([color=red]){--calcite-split-button-divider:var(--calcite-ui-danger)}:host([appearance=transparent]):host([color=neutral]){--calcite-split-button-divider:var(--calcite-ui-text-1)}:host([appearance=transparent]):host([color=inverse]){--calcite-split-button-divider:var(--calcite-ui-foreground-1)}:host([appearance=clear]),:host([appearance=transparent]){--calcite-split-button-background:transparent}:host([appearance=outline]){--calcite-split-button-background:var(--calcite-ui-foreground-1)}:host([appearance=clear]):host([color=blue]),:host([appearance=outline]):host([color=blue]){--calcite-split-button-divider:var(--calcite-ui-brand)}:host([appearance=clear]):host([color=red]),:host([appearance=outline]):host([color=red]){--calcite-split-button-divider:var(--calcite-ui-danger)}:host([appearance=clear]):host([color=neutral]),:host([appearance=outline]):host([color=neutral]){--calcite-split-button-divider:var(--calcite-ui-foreground-3)}:host([appearance=clear]):host([color=inverse]),:host([appearance=outline]):host([color=inverse]){--calcite-split-button-divider:var(--calcite-ui-inverse)}.width-auto{width:auto}.width-half{width:50%}.width-full{width:100%}.split-button__divider-container{display:-ms-flexbox;display:flex;width:1px;-ms-flex-align:stretch;align-items:stretch;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s;background-color:var(--calcite-split-button-background)}.split-button__divider{margin-top:0.25rem;margin-bottom:0.25rem;display:inline-block;width:1px;background-color:var(--calcite-split-button-divider)}:host([appearance=outline]) .split-button__divider-container,:host([appearance=clear]) .split-button__divider-container{border-top:1px solid var(--calcite-split-button-divider);border-bottom:1px solid var(--calcite-split-button-divider)}:host([appearance=outline]):hover .split-button__divider-container,:host([appearance=clear]):hover .split-button__divider-container{background-color:var(--calcite-split-button-divider)}:host([appearance=outline]:hover) .split-button__divider-container,:host([appearance=clear]:hover) .split-button__divider-container{background-color:var(--calcite-split-button-divider)}:host([appearance=outline]:focus-within):host([color=blue]),:host([appearance=clear]:focus-within):host([color=blue]){--calcite-split-button-divider:var(--calcite-ui-brand-press)}:host([appearance=outline]:focus-within):host([color=red]),:host([appearance=clear]:focus-within):host([color=red]){--calcite-split-button-divider:var(--calcite-ui-danger-press)}:host([appearance=outline]:focus-within) .split-button__divider-container,:host([appearance=clear]:focus-within) .split-button__divider-container{background-color:var(--calcite-split-button-divider)}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) .split-button__divider-container{opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) calcite-dropdown>calcite-button{pointer-events:none}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}";
- const SplitButton = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteSplitButtonPrimaryClick = createEvent(this, "calciteSplitButtonPrimaryClick", 7);
- this.calciteSplitButtonSecondaryClick = createEvent(this, "calciteSplitButtonSecondaryClick", 7);
- /** specify the appearance style of the button, defaults to solid. */
- this.appearance = "solid";
- /** specify the color of the control, defaults to blue */
- this.color = "blue";
- /** is the control disabled */
- this.disabled = false;
- /**
- * Is the dropdown currently active or not
- * @internal
- */
- this.active = false;
- /** specify the icon used for the dropdown menu, defaults to chevron */
- this.dropdownIconType = "chevron";
- /** optionally add a calcite-loader component to the control,
- disabling interaction. with the primary button */
- this.loading = false;
- /** Describes the type of positioning to use for the dropdown. If your element is in a fixed container, use the 'fixed' value. */
- this.overlayPositioning = "absolute";
- /** specify the scale of the control, defaults to m */
- this.scale = "m";
- /** specify the width of the button, defaults to auto */
- this.width = "auto";
- this.calciteSplitButtonPrimaryClickHandler = (e) => this.calciteSplitButtonPrimaryClick.emit(e);
- this.calciteSplitButtonSecondaryClickHandler = (e) => this.calciteSplitButtonSecondaryClick.emit(e);
- }
- handleDisabledChange(value) {
- if (!value) {
- this.active = false;
- }
- }
- activeHandler() {
- if (this.disabled) {
- this.active = false;
- }
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentDidRender() {
- updateHostInteraction(this);
- }
- render() {
- const widthClasses = {
- [CSS$7.container]: true,
- [CSS$7.widthAuto]: this.width === "auto",
- [CSS$7.widthHalf]: this.width === "half",
- [CSS$7.widthFull]: this.width === "full"
- };
- const buttonWidth = this.width === "auto" ? "auto" : "full";
- return (h("div", { class: widthClasses }, h("calcite-button", { appearance: this.appearance, color: this.color, disabled: this.disabled, "icon-end": this.primaryIconEnd ? this.primaryIconEnd : null, "icon-start": this.primaryIconStart ? this.primaryIconStart : null, iconFlipRtl: this.primaryIconFlipRtl ? this.primaryIconFlipRtl : null, label: this.primaryLabel, loading: this.loading, onClick: this.calciteSplitButtonPrimaryClickHandler, scale: this.scale, splitChild: "primary", type: "button", width: buttonWidth }, this.primaryText), h("div", { class: CSS$7.dividerContainer }, h("div", { class: CSS$7.divider })), h("calcite-dropdown", { active: this.active, disabled: this.disabled, onClick: this.calciteSplitButtonSecondaryClickHandler, overlayPositioning: this.overlayPositioning, placement: "bottom-trailing", scale: this.scale, width: this.scale }, h("calcite-button", { appearance: this.appearance, color: this.color, disabled: this.disabled, "icon-start": this.dropdownIcon, label: this.dropdownLabel, scale: this.scale, slot: "dropdown-trigger", splitChild: "secondary", type: "button" }), h("slot", null))));
- }
- get dropdownIcon() {
- return this.dropdownIconType === "chevron"
- ? "chevronDown"
- : this.dropdownIconType === "caret"
- ? "caretDown"
- : this.dropdownIconType === "ellipsis"
- ? "ellipsis"
- : "handle-vertical";
- }
- get el() { return this; }
- static get watchers() { return {
- "disabled": ["handleDisabledChange"],
- "active": ["activeHandler"]
- }; }
- static get style() { return splitButtonCss; }
- };
- const stepperCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;display:-ms-flexbox;display:flex;width:100%;min-width:100%;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-align:stretch;align-items:stretch;-ms-flex-pack:justify;justify-content:space-between}:host([layout=vertical]){-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-direction:column;flex-direction:column}:host ::slotted(.calcite-stepper-content){display:-ms-flexbox;display:flex;width:100%;min-width:100%;-ms-flex-direction:column;flex-direction:column;-ms-flex-wrap:wrap;flex-wrap:wrap}";
- const Stepper = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteStepperItemChange = createEvent(this, "calciteStepperItemChange", 7);
- //--------------------------------------------------------------------------
- //
- // Public Properties
- //
- //--------------------------------------------------------------------------
- /** optionally display a status icon next to the step title */
- this.icon = false;
- /** specify the layout of stepper, defaults to horizontal */
- this.layout = "horizontal";
- /** optionally display the number next to the step title */
- this.numbered = false;
- /** specify the scale of stepper, defaults to m */
- this.scale = "m";
- //--------------------------------------------------------------------------
- //
- // Private State/Props
- //
- //--------------------------------------------------------------------------
- this.itemMap = new Map();
- /** list of sorted Stepper items */
- this.items = [];
- /** list of enabled Stepper items */
- this.enabledItems = [];
- }
- // watch for removal of disabled to register step
- contentWatcher() {
- if (this.layout === "horizontal") {
- if (!this.stepperContentContainer && this.requestedContent) {
- this.addHorizontalContentContainer();
- }
- this.updateContent(this.requestedContent);
- }
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentDidLoad() {
- // if no stepper items are set as active, default to the first one
- if (!this.currentPosition) {
- this.calciteStepperItemChange.emit({
- position: 0
- });
- }
- }
- componentWillLoad() {
- if (this.layout === "horizontal" && !this.stepperContentContainer) {
- this.addHorizontalContentContainer();
- }
- }
- render() {
- return h("slot", null);
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- calciteStepperItemKeyEvent(e) {
- const item = e.detail.item;
- const itemToFocus = e.target;
- const isFirstItem = this.itemIndex(itemToFocus) === 0;
- const isLastItem = this.itemIndex(itemToFocus) === this.enabledItems.length - 1;
- switch (item.key) {
- case "ArrowDown":
- case "ArrowRight":
- if (isLastItem) {
- this.focusFirstItem();
- }
- else {
- this.focusNextItem(itemToFocus);
- }
- break;
- case "ArrowUp":
- case "ArrowLeft":
- if (isFirstItem) {
- this.focusLastItem();
- }
- else {
- this.focusPrevItem(itemToFocus);
- }
- break;
- case "Home":
- this.focusFirstItem();
- break;
- case "End":
- this.focusLastItem();
- break;
- }
- }
- registerItem(event) {
- const item = event.target;
- const { content, position } = event.detail;
- if (content && item.active) {
- this.requestedContent = content;
- }
- this.itemMap.set(item, position);
- this.items = this.sortItems();
- this.enabledItems = this.filterItems();
- }
- updateItem(event) {
- if (event.detail.content) {
- this.requestedContent = event.detail.content;
- }
- this.currentPosition = event.detail.position;
- this.calciteStepperItemChange.emit({
- position: this.currentPosition
- });
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /** set the next step as active */
- async nextStep() {
- const enabledStepIndex = this.getEnabledStepIndex(this.currentPosition + 1, "next");
- if (typeof enabledStepIndex !== "number") {
- return;
- }
- this.emitChangedItem(enabledStepIndex);
- }
- /** set the previous step as active */
- async prevStep() {
- const enabledStepIndex = this.getEnabledStepIndex(this.currentPosition - 1, "previous");
- if (typeof enabledStepIndex !== "number") {
- return;
- }
- this.emitChangedItem(enabledStepIndex);
- }
- /** set the requested step as active */
- async goToStep(step) {
- const position = step - 1;
- if (this.currentPosition !== position) {
- this.emitChangedItem(position);
- }
- }
- /** set the first step as active */
- async startStep() {
- const enabledStepIndex = this.getEnabledStepIndex(0, "next");
- if (typeof enabledStepIndex !== "number") {
- return;
- }
- this.emitChangedItem(enabledStepIndex);
- }
- /** set the last step as active */
- async endStep() {
- const enabledStepIndex = this.getEnabledStepIndex(this.items.length - 1, "previous");
- if (typeof enabledStepIndex !== "number") {
- return;
- }
- this.emitChangedItem(enabledStepIndex);
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- getEnabledStepIndex(startIndex, direction = "next") {
- var _a;
- const { items, currentPosition } = this;
- let newIndex = startIndex;
- while ((_a = items[newIndex]) === null || _a === void 0 ? void 0 : _a.disabled) {
- newIndex = newIndex + (direction === "previous" ? -1 : 1);
- }
- return newIndex !== currentPosition && newIndex < items.length && newIndex >= 0
- ? newIndex
- : null;
- }
- addHorizontalContentContainer() {
- this.stepperContentContainer = document.createElement("div");
- this.stepperContentContainer.classList.add("calcite-stepper-content");
- this.el.insertAdjacentElement("beforeend", this.stepperContentContainer);
- }
- emitChangedItem(position) {
- this.currentPosition = position;
- this.calciteStepperItemChange.emit({
- position
- });
- }
- focusFirstItem() {
- const firstItem = this.enabledItems[0];
- this.focusElement(firstItem);
- }
- focusLastItem() {
- const lastItem = this.enabledItems[this.enabledItems.length - 1];
- this.focusElement(lastItem);
- }
- focusNextItem(e) {
- const index = this.itemIndex(e);
- const nextItem = this.enabledItems[index + 1] || this.enabledItems[0];
- this.focusElement(nextItem);
- }
- focusPrevItem(e) {
- const index = this.itemIndex(e);
- const prevItem = this.enabledItems[index - 1] || this.enabledItems[this.enabledItems.length - 1];
- this.focusElement(prevItem);
- }
- itemIndex(e) {
- return this.enabledItems.indexOf(e);
- }
- focusElement(item) {
- item.focus();
- }
- sortItems() {
- const { itemMap } = this;
- return Array.from(itemMap.keys()).sort((a, b) => itemMap.get(a) - itemMap.get(b));
- }
- filterItems() {
- return this.items.filter((item) => !item.disabled);
- }
- updateContent(content) {
- this.stepperContentContainer.innerHTML = "";
- this.stepperContentContainer.append(...content);
- }
- get el() { return this; }
- static get watchers() { return {
- "requestedContent": ["contentWatcher"]
- }; }
- static get style() { return stepperCss; }
- };
- const stepperItemCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([scale=s]){--calcite-stepper-item-spacing-unit-s:0.25rem;--calcite-stepper-item-spacing-unit-m:0.75rem;--calcite-stepper-item-spacing-unit-l:1rem;font-size:var(--calcite-font-size--1);line-height:1rem;-webkit-margin-end:0.25rem;margin-inline-end:0.25rem}:host([scale=s]) .stepper-item-subtitle{font-size:var(--calcite-font-size--2);line-height:1rem}:host([scale=m]){--calcite-stepper-item-spacing-unit-s:0.5rem;--calcite-stepper-item-spacing-unit-m:1rem;--calcite-stepper-item-spacing-unit-l:1.25rem;font-size:var(--calcite-font-size-0);line-height:1.25rem;-webkit-margin-end:0.5rem;margin-inline-end:0.5rem}:host([scale=m]) .stepper-item-subtitle{font-size:var(--calcite-font-size--1);line-height:1rem}:host([scale=l]){--calcite-stepper-item-spacing-unit-s:0.75rem;--calcite-stepper-item-spacing-unit-m:1.25rem;--calcite-stepper-item-spacing-unit-l:1.5rem;font-size:var(--calcite-font-size-1);line-height:1.5rem;-webkit-margin-end:0.75rem;margin-inline-end:0.75rem}:host([scale=l]) .stepper-item-subtitle{font-size:var(--calcite-font-size-0);line-height:1.25rem}:host{position:relative;display:-ms-flexbox;display:flex;-ms-flex-positive:1;flex-grow:1;-ms-flex-direction:column;flex-direction:column;margin-bottom:var(--calcite-stepper-item-spacing-unit-s)}:host .container{position:relative;display:-ms-flexbox;display:flex;-ms-flex-positive:1;flex-grow:1;cursor:pointer;-ms-flex-direction:column;flex-direction:column;border-width:0px;border-top-width:2px;border-style:solid;border-color:var(--calcite-ui-border-3);color:var(--calcite-ui-text-3);-webkit-text-decoration-line:none;text-decoration-line:none;outline:2px solid transparent;outline-offset:2px;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}:host{outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out}:host(:focus){outline:2px solid var(--calcite-ui-brand);outline-offset:2px}:host .stepper-item-header{display:-ms-flexbox;display:flex;cursor:pointer;-ms-flex-align:start;align-items:flex-start}:host .stepper-item-content,:host .stepper-item-header{-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);padding-block:var(--calcite-stepper-item-spacing-unit-l);-webkit-padding-end:var(--calcite-stepper-item-spacing-unit-m);padding-inline-end:var(--calcite-stepper-item-spacing-unit-m);text-align:start}:host .stepper-item-header *{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}:host .stepper-item-content{display:none;width:100%;-ms-flex-direction:column;flex-direction:column;font-size:var(--calcite-font-size--2);line-height:1.375}:host .stepper-item-icon{-webkit-margin-end:var(--calcite-stepper-item-spacing-unit-m);margin-inline-end:var(--calcite-stepper-item-spacing-unit-m);margin-top:1px;display:-ms-inline-flexbox;display:inline-flex;height:0.75rem;-ms-flex-negative:0;flex-shrink:0;-ms-flex-item-align:start;align-self:flex-start;color:var(--calcite-ui-text-3);opacity:var(--calcite-ui-opacity-disabled);-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}:host .stepper-item-header-text{-ms-flex-direction:column;flex-direction:column;text-align:initial;-webkit-margin-end:auto;margin-inline-end:auto}:host .stepper-item-title,:host .stepper-item-subtitle{display:-ms-flexbox;display:flex;width:100%}:host .stepper-item-title{margin-bottom:0.25rem;font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-2)}:host .stepper-item-subtitle{color:var(--calcite-ui-text-3)}:host .stepper-item-number{font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-3);-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);-webkit-margin-end:var(--calcite-stepper-item-spacing-unit-m);margin-inline-end:var(--calcite-stepper-item-spacing-unit-m)}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host([complete]) .container{border-color:rgba(0, 122, 194, 0.5)}:host([complete]) .container .stepper-item-icon{color:var(--calcite-ui-brand)}:host([error]) .container{border-top-color:var(--calcite-ui-danger)}:host([error]) .container .stepper-item-number{color:var(--calcite-ui-danger)}:host([error]) .container .stepper-item-icon{opacity:1;color:var(--calcite-ui-danger)}:host(:hover:not([disabled]):not([active])) .container,:host(:focus:not([disabled]):not([active])) .container{border-top-color:var(--calcite-ui-brand)}:host(:hover:not([disabled]):not([active])) .container .stepper-item-title,:host(:focus:not([disabled]):not([active])) .container .stepper-item-title{color:var(--calcite-ui-text-1)}:host(:hover:not([disabled]):not([active])) .container .stepper-item-subtitle,:host(:focus:not([disabled]):not([active])) .container .stepper-item-subtitle{color:var(--calcite-ui-text-2)}:host([error]:hover:not([disabled]):not([active])) .container,:host([error]:focus:not([disabled]):not([active])) .container{border-top-color:var(--calcite-ui-danger-hover)}:host([active]) .container{border-top-color:var(--calcite-ui-brand)}:host([active]) .container .stepper-item-title{color:var(--calcite-ui-text-1)}:host([active]) .container .stepper-item-subtitle{color:var(--calcite-ui-text-2)}:host([active]) .container .stepper-item-number{color:var(--calcite-ui-brand)}:host([active]) .container .stepper-item-icon{color:var(--calcite-ui-brand);opacity:1}:host([layout=vertical]) .container{margin-left:0px;margin-right:0px;margin-top:0px;-ms-flex:1 1 auto;flex:1 1 auto;border-top-width:0px;border-style:solid;border-color:var(--calcite-ui-border-3);padding-top:0px;padding-bottom:0px;border-inline-start-width:2px;-webkit-padding-start:var(--calcite-stepper-item-spacing-unit-l);padding-inline-start:var(--calcite-stepper-item-spacing-unit-l)}:host([layout=vertical]) .container .stepper-item-icon{-ms-flex-order:3;order:3;margin-top:1px;margin-bottom:0px;-webkit-padding-start:var(--calcite-stepper-item-spacing-unit-s);padding-inline-start:var(--calcite-stepper-item-spacing-unit-s);-webkit-margin-start:auto;margin-inline-start:auto}:host([layout=vertical]) .container .stepper-item-header{-webkit-padding-end:0px;padding-inline-end:0px}:host([layout=vertical]) .container .stepper-item-content{padding:0px}:host([layout=vertical][active]) .container .stepper-item-content{display:-ms-flexbox;display:flex}:host([layout=vertical][active]) .container .stepper-item-content ::slotted(:last-child){margin-bottom:var(--calcite-stepper-item-spacing-unit-l)}:host([layout=vertical][complete]) .container{border-color:rgba(0, 122, 194, 0.5)}:host([layout=vertical][complete]:hover:not([disabled]):not([active])) .container,:host([layout=vertical][complete]:focus:not([disabled]):not([active])) .container{border-color:var(--calcite-ui-brand)}:host([layout=vertical][error]) .container{border-color:var(--calcite-ui-danger)}:host([layout=vertical][active]) .container{border-color:var(--calcite-ui-brand)}:host([layout=vertical]:hover:not([disabled]):not([active])) .container,:host([layout=vertical]:focus:not([disabled]):not([active])) .container{border-color:rgba(0, 122, 194, 0.5)}:host([layout=vertical][error]:hover:not([disabled]):not([active])) .container,:host([layout=vertical][error]:focus:not([disabled]):not([active])) .container{border-color:var(--calcite-ui-danger-hover)}";
- const StepperItem = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteStepperItemKeyEvent = createEvent(this, "calciteStepperItemKeyEvent", 7);
- this.calciteStepperItemSelect = createEvent(this, "calciteStepperItemSelect", 7);
- this.calciteStepperItemRegister = createEvent(this, "calciteStepperItemRegister", 7);
- //--------------------------------------------------------------------------
- //
- // Public Properties
- //
- //--------------------------------------------------------------------------
- /** is the step active */
- this.active = false;
- /** has the step been completed */
- this.complete = false;
- /** does the step contain an error that needs to be resolved by the user */
- this.error = false;
- /** is the step disabled and not navigable to by a user */
- this.disabled = false;
- /** should the items display an icon based on status */
- /** @internal */
- this.icon = false;
- /** optionally display the step number next to the title and subtitle */
- /** @internal */
- this.numbered = false;
- /** the scale of the item */
- /** @internal */
- this.scale = "m";
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- this.keyDownHandler = (e) => {
- if (!this.disabled && e.target === this.el) {
- switch (e.key) {
- case " ":
- case "Enter":
- this.emitRequestedItem();
- e.preventDefault();
- break;
- case "ArrowUp":
- case "ArrowDown":
- case "ArrowLeft":
- case "ArrowRight":
- case "Home":
- case "End":
- this.calciteStepperItemKeyEvent.emit({ item: e });
- e.preventDefault();
- break;
- }
- }
- };
- this.emitRequestedItem = () => {
- if (!this.disabled) {
- this.calciteStepperItemSelect.emit({
- position: this.itemPosition,
- content: this.itemContent
- });
- }
- };
- this.setItemContent = (event) => {
- this.itemPosition = this.getItemPosition();
- const itemContent = event.target.assignedNodes({ flatten: true });
- if (itemContent.length) {
- this.itemContent = itemContent;
- }
- this.registerStepperItem();
- if (this.active) {
- this.emitRequestedItem();
- }
- };
- }
- // watch for removal of disabled to register step
- disabledWatcher() {
- this.registerStepperItem();
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentWillLoad() {
- this.icon = getElementProp(this.el, "icon", false);
- this.numbered = getElementProp(this.el, "numbered", false);
- this.layout = getElementProp(this.el, "layout", false);
- this.scale = getElementProp(this.el, "scale", "m");
- this.parentStepperEl = this.el.parentElement;
- }
- componentDidRender() {
- updateHostInteraction(this, true);
- }
- render() {
- return (h(Host, { "aria-expanded": toAriaBoolean(this.active), onClick: this.emitRequestedItem, onKeyDown: this.keyDownHandler }, h("div", { class: "container" }, h("div", { class: "stepper-item-header" }, this.icon ? this.renderIcon() : null, this.numbered ? (h("div", { class: "stepper-item-number" }, this.getItemPosition() + 1, ".")) : null, h("div", { class: "stepper-item-header-text" }, h("span", { class: "stepper-item-title" }, this.itemTitle), h("span", { class: "stepper-item-subtitle" }, this.itemSubtitle))), h("div", { class: "stepper-item-content" }, h("slot", { onSlotchange: this.setItemContent })))));
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- updateActiveItemOnChange(event) {
- if (event.target === this.parentStepperEl ||
- event.composedPath().includes(this.parentStepperEl)) {
- this.activePosition = event.detail.position;
- this.determineActiveItem();
- }
- }
- renderIcon() {
- const path = this.active
- ? "circleF"
- : this.error
- ? "exclamationMarkCircleF"
- : this.complete
- ? "checkCircleF"
- : "circle";
- return h("calcite-icon", { class: "stepper-item-icon", icon: path, scale: "s" });
- }
- determineActiveItem() {
- this.active = !this.disabled && this.itemPosition === this.activePosition;
- }
- registerStepperItem() {
- this.calciteStepperItemRegister.emit({
- position: this.itemPosition,
- content: this.itemContent
- });
- }
- getItemPosition() {
- return Array.prototype.indexOf.call(this.parentStepperEl.querySelectorAll("calcite-stepper-item"), this.el);
- }
- get el() { return this; }
- static get watchers() { return {
- "disabled": ["disabledWatcher"]
- }; }
- static get style() { return stepperItemCss; }
- };
- const switchCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([scale=s]) .container{height:0.75rem}:host([scale=s]) .track{height:0.75rem;width:1.5rem}:host([scale=s]) .handle{height:0.5rem;width:0.5rem}:host([scale=m]) .container{height:1rem}:host([scale=m]) .track{height:1rem;width:2rem}:host([scale=m]) .handle{height:0.75rem;width:0.75rem}:host([scale=l]) .container{height:1.5rem}:host([scale=l]) .track{height:1.5rem;width:3rem}:host([scale=l]) .handle{height:1.25rem;width:1.25rem}:host{position:relative;display:inline-block;width:auto;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;vertical-align:middle;tap-highlight-color:transparent}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host{width:auto;outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out}.track{pointer-events:none;position:relative;-webkit-box-sizing:border-box;box-sizing:border-box;display:inline-block;border-radius:9999px;border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-2);background-color:var(--calcite-ui-foreground-2);vertical-align:top;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}.handle{pointer-events:none;position:absolute;display:block;border-radius:9999px;border-width:2px;border-style:solid;border-color:var(--calcite-ui-border-input);background-color:var(--calcite-ui-foreground-1);-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);top:-1px;inset-inline:-1px auto}:host(:hover) .handle,:host(:focus) .handle{border-color:var(--calcite-ui-brand);-webkit-box-shadow:inset 0 0 0 1px var(--calcite-ui-brand);box-shadow:inset 0 0 0 1px var(--calcite-ui-brand)}:host([checked]) .track{border-color:var(--calcite-ui-brand-hover);background-color:var(--calcite-ui-brand)}:host([checked]) .handle{border-color:var(--calcite-ui-brand);inset-inline:auto -1px}:host([checked]:hover) .track{border-color:var(--calcite-ui-brand-hover);background-color:var(--calcite-ui-brand)}:host([checked]:hover) .handle{border-color:var(--calcite-ui-brand-hover);-webkit-box-shadow:inset 0 0 0 1px var(--calcite-ui-brand-hover);box-shadow:inset 0 0 0 1px var(--calcite-ui-brand-hover)}@media (forced-colors: active){:host([checked]) .track{background-color:canvasText}}.container:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:2px}::slotted(input[slot=hidden-form-input]){bottom:0 !important;left:0 !important;margin:0 !important;opacity:0 !important;outline:none !important;padding:0 !important;position:absolute !important;right:0 !important;top:0 !important;-webkit-transform:none !important;transform:none !important;-webkit-appearance:none !important;z-index:-1 !important}";
- const Switch = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteSwitchChange = createEvent(this, "calciteSwitchChange", 7);
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** True if the switch is disabled */
- this.disabled = false;
- /** The scale of the switch */
- this.scale = "m";
- /** True if the switch is initially on
- * @deprecated use 'checked' instead.
- */
- this.switched = false;
- /** True if the switch is initially on */
- this.checked = false;
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- this.keyDownHandler = (e) => {
- const key = e.key;
- if (!this.disabled && (key === " " || key === "Enter")) {
- this.toggle();
- e.preventDefault();
- }
- };
- this.clickHandler = () => {
- this.toggle();
- };
- this.setSwitchEl = (el) => {
- this.switchEl = el;
- };
- }
- switchedWatcher(switched) {
- this.checked = switched;
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- focusElement(this.switchEl);
- }
- onLabelClick() {
- if (!this.disabled) {
- this.toggle();
- this.setFocus();
- }
- }
- toggle() {
- this.checked = !this.checked;
- this.calciteSwitchChange.emit({
- // todo: We should remove emmitting redudant props in event payload.
- // https://github.com/Esri/calcite-components/issues/3163
- switched: this.checked
- });
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- const initiallyChecked = this.checked || this.switched;
- if (initiallyChecked) {
- // if either prop is set, we ensure both are synced initially
- this.switched = this.checked = initiallyChecked;
- }
- connectLabel(this);
- connectForm(this);
- }
- disconnectedCallback() {
- disconnectLabel(this);
- disconnectForm(this);
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- render() {
- return (h(Host, { onClick: this.clickHandler, onKeyDown: this.keyDownHandler }, h("div", { "aria-checked": toAriaBoolean(this.checked), "aria-label": getLabelText(this), class: "container", ref: this.setSwitchEl, role: "switch", tabIndex: 0 }, h("div", { class: "track" }, h("div", { class: "handle" })), h(HiddenFormInputSlot, { component: this }))));
- }
- get el() { return this; }
- static get watchers() { return {
- "switched": ["switchedWatcher"]
- }; }
- static get style() { return switchCss; }
- };
- const tabCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([active]) section{display:block}:host{display:none;height:100%;width:100%}:host([active]){display:block;height:100%;width:100%;overflow:auto}section{display:none;height:100%;width:100%}:host([scale=s]){padding-top:0.25rem;padding-bottom:0.25rem;font-size:var(--calcite-font-size--2);line-height:1rem}:host([scale=m]){padding-top:0.5rem;padding-bottom:0.5rem;font-size:var(--calcite-font-size--1);line-height:1rem}:host([scale=l]){padding-top:0.75rem;padding-bottom:0.75rem;font-size:var(--calcite-font-size-0);line-height:1.25rem}";
- const Tab = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteTabRegister = createEvent(this, "calciteTabRegister", 7);
- /**
- * Show this tab
- */
- this.active = false;
- /** @internal Parent tabs component scale value */
- this.scale = "m";
- this.guid = `calcite-tab-title-${guid()}`;
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- render() {
- const id = this.el.id || this.guid;
- return (h(Host, { "aria-expanded": toAriaBoolean(this.active), "aria-labelledby": this.labeledBy, id: id, role: "tabpanel" }, h("section", null, h("slot", null))));
- }
- connectedCallback() {
- this.parentTabsEl = this.el.closest("calcite-tabs");
- }
- componentDidLoad() {
- this.calciteTabRegister.emit();
- }
- componentWillRender() {
- var _a;
- this.scale = (_a = this.parentTabsEl) === null || _a === void 0 ? void 0 : _a.scale;
- }
- disconnectedCallback() {
- var _a;
- // Dispatching to body in order to be listened by other elements that are still connected to the DOM.
- (_a = document.body) === null || _a === void 0 ? void 0 : _a.dispatchEvent(new CustomEvent("calciteTabUnregister", {
- detail: this.el
- }));
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- internalTabChangeHandler(event) {
- const targetTabsEl = event
- .composedPath()
- .find((el) => el.tagName === "CALCITE-TABS");
- // to allow `<calcite-tabs>` to be nested we need to make sure this
- // `calciteTabChange` event was actually fired from a within the same
- // `<calcite-tabs>` that is the a parent of this tab.
- if (targetTabsEl !== this.parentTabsEl) {
- return;
- }
- if (this.tab) {
- this.active = this.tab === event.detail.tab;
- }
- else {
- this.getTabIndex().then((index) => {
- this.active = index === event.detail.tab;
- });
- }
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /**
- * Return the index of this tab within the tab array
- */
- async getTabIndex() {
- return Array.prototype.indexOf.call(nodeListToArray(this.el.parentElement.children).filter((e) => e.matches("calcite-tab")), this.el);
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- /**
- * @internal
- */
- async updateAriaInfo(tabIds = [], titleIds = []) {
- this.labeledBy = titleIds[tabIds.indexOf(this.el.id)] || null;
- }
- get el() { return this; }
- static get style() { return tabCss; }
- };
- const tabNavCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;display:-ms-flexbox;display:flex}:host([scale=s]){min-height:1.5rem}:host([scale=m]){min-height:2rem}:host([scale=l]){min-height:2.75rem}.tab-nav{display:-ms-flexbox;display:flex;width:100%;-ms-flex-pack:start;justify-content:flex-start;overflow:auto}:host([layout=center]) .tab-nav{-ms-flex-pack:center;justify-content:center}.tab-nav-active-indicator-container{position:absolute;left:0px;right:0px;bottom:0px;height:0.125rem;width:100%;overflow:hidden}.tab-nav-active-indicator{position:absolute;bottom:0px;display:block;height:0.125rem;background-color:var(--calcite-ui-brand);-webkit-transition-property:all;transition-property:all;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0, 0, 0.2, 1);transition-timing-function:cubic-bezier(0, 0, 0.2, 1)}:host([position=below]) .tab-nav-active-indicator{bottom:unset;top:0px}:host([position=below]) .tab-nav-active-indicator-container{bottom:unset;top:0px}:host([bordered]) .tab-nav-active-indicator-container{bottom:unset}:host([bordered][position=below]) .tab-nav-active-indicator-container{bottom:0;top:unset}";
- const TabNav = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteTabChange = createEvent(this, "calciteTabChange", 7);
- this.calciteInternalTabChange = createEvent(this, "calciteInternalTabChange", 7);
- /** @internal Parent tabs component scale value */
- this.scale = "m";
- /** @internal Parent tabs component layout value */
- this.layout = "inline";
- /** @internal Parent tabs component position value */
- this.position = "below";
- /** @internal Parent tabs component bordered value when layout is "inline" */
- this.bordered = false;
- this.animationActiveDuration = 0.3;
- this.resizeObserver = createObserver("resize", () => {
- // remove active indicator transition duration during resize to prevent wobble
- this.activeIndicatorEl.style.transitionDuration = "0s";
- this.updateActiveWidth();
- this.updateOffsetPosition();
- });
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- this.handleContainerScroll = () => {
- // remove active indicator transition duration while container is scrolling to prevent wobble
- this.activeIndicatorEl.style.transitionDuration = "0s";
- this.updateOffsetPosition();
- };
- }
- async selectedTabChanged() {
- if (localStorage &&
- this.storageId &&
- this.selectedTab !== undefined &&
- this.selectedTab !== null) {
- localStorage.setItem(`calcite-tab-nav-${this.storageId}`, JSON.stringify(this.selectedTab));
- }
- this.calciteInternalTabChange.emit({
- tab: this.selectedTab
- });
- this.selectedTabEl = await this.getTabTitleById(this.selectedTab);
- }
- selectedTabElChanged() {
- this.updateOffsetPosition();
- this.updateActiveWidth();
- // reset the animation time on tab selection
- this.activeIndicatorEl.style.transitionDuration = `${this.animationActiveDuration}s`;
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- var _a;
- this.parentTabsEl = this.el.closest("calcite-tabs");
- (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el);
- }
- disconnectedCallback() {
- var _a;
- (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- }
- componentWillLoad() {
- const storageKey = `calcite-tab-nav-${this.storageId}`;
- if (localStorage && this.storageId && localStorage.getItem(storageKey)) {
- const storedTab = JSON.parse(localStorage.getItem(storageKey));
- this.selectedTab = storedTab;
- }
- }
- componentWillRender() {
- const { parentTabsEl } = this;
- this.layout = parentTabsEl === null || parentTabsEl === void 0 ? void 0 : parentTabsEl.layout;
- this.position = parentTabsEl === null || parentTabsEl === void 0 ? void 0 : parentTabsEl.position;
- this.scale = parentTabsEl === null || parentTabsEl === void 0 ? void 0 : parentTabsEl.scale;
- this.bordered = parentTabsEl === null || parentTabsEl === void 0 ? void 0 : parentTabsEl.bordered;
- // fix issue with active tab-title not lining up with blue indicator
- if (this.selectedTabEl) {
- this.updateOffsetPosition();
- }
- }
- componentDidRender() {
- // if every tab title is active select the first tab.
- if (this.tabTitles.length &&
- this.tabTitles.every((title) => !title.active) &&
- !this.selectedTab) {
- this.tabTitles[0].getTabIdentifier().then((tab) => {
- this.calciteInternalTabChange.emit({
- tab
- });
- });
- }
- }
- render() {
- const dir = getElementDir(this.el);
- const width = `${this.indicatorWidth}px`;
- const offset = `${this.indicatorOffset}px`;
- const indicatorStyle = dir !== "rtl" ? { width, left: offset } : { width, right: offset };
- return (h(Host, { role: "tablist" }, h("div", { class: "tab-nav", onScroll: this.handleContainerScroll, ref: (el) => (this.tabNavEl = el) }, h("div", { class: "tab-nav-active-indicator-container", ref: (el) => (this.activeIndicatorContainerEl = el) }, h("div", { class: "tab-nav-active-indicator", ref: (el) => (this.activeIndicatorEl = el), style: indicatorStyle })), h("slot", null))));
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- focusPreviousTabHandler(e) {
- const currentIndex = this.getIndexOfTabTitle(e.target, this.enabledTabTitles);
- const previousTab = this.enabledTabTitles[currentIndex - 1] ||
- this.enabledTabTitles[this.enabledTabTitles.length - 1];
- previousTab.focus();
- e.stopPropagation();
- e.preventDefault();
- }
- focusNextTabHandler(e) {
- const currentIndex = this.getIndexOfTabTitle(e.target, this.enabledTabTitles);
- const nextTab = this.enabledTabTitles[currentIndex + 1] || this.enabledTabTitles[0];
- nextTab.focus();
- e.stopPropagation();
- e.preventDefault();
- }
- internalActivateTabHandler(e) {
- this.selectedTab = e.detail.tab
- ? e.detail.tab
- : this.getIndexOfTabTitle(e.target);
- e.stopPropagation();
- e.preventDefault();
- }
- activateTabHandler(e) {
- this.calciteTabChange.emit({
- tab: this.selectedTab
- });
- e.stopPropagation();
- e.preventDefault();
- }
- /**
- * Check for active tabs on register and update selected
- */
- updateTabTitles(e) {
- if (e.target.active) {
- this.selectedTab = e.detail;
- }
- }
- globalInternalTabChangeHandler(e) {
- if (this.syncId &&
- e.target !== this.el &&
- e.target.syncId === this.syncId &&
- this.selectedTab !== e.detail.tab) {
- this.selectedTab = e.detail.tab;
- e.stopPropagation();
- }
- }
- updateOffsetPosition() {
- var _a, _b, _c, _d, _e;
- const dir = getElementDir(this.el);
- const navWidth = (_a = this.activeIndicatorContainerEl) === null || _a === void 0 ? void 0 : _a.offsetWidth;
- const tabLeft = (_b = this.selectedTabEl) === null || _b === void 0 ? void 0 : _b.offsetLeft;
- const tabWidth = (_c = this.selectedTabEl) === null || _c === void 0 ? void 0 : _c.offsetWidth;
- const offsetRight = navWidth - (tabLeft + tabWidth);
- this.indicatorOffset =
- dir !== "rtl" ? tabLeft - ((_d = this.tabNavEl) === null || _d === void 0 ? void 0 : _d.scrollLeft) : offsetRight + ((_e = this.tabNavEl) === null || _e === void 0 ? void 0 : _e.scrollLeft);
- }
- updateActiveWidth() {
- var _a;
- this.indicatorWidth = (_a = this.selectedTabEl) === null || _a === void 0 ? void 0 : _a.offsetWidth;
- }
- getIndexOfTabTitle(el, tabTitles = this.tabTitles) {
- // In most cases, since these indexes correlate with tab contents, we want to consider all tab titles.
- // However, when doing relative index operations, it makes sense to pass in this.enabledTabTitles as the 2nd arg.
- return tabTitles.indexOf(el);
- }
- async getTabTitleById(id) {
- return Promise.all(this.tabTitles.map((el) => el.getTabIdentifier())).then((ids) => {
- return this.tabTitles[ids.indexOf(id)];
- });
- }
- get tabTitles() {
- return filterDirectChildren(this.el, "calcite-tab-title");
- }
- get enabledTabTitles() {
- return filterDirectChildren(this.el, "calcite-tab-title:not([disabled])");
- }
- get el() { return this; }
- static get watchers() { return {
- "selectedTab": ["selectedTabChanged"],
- "selectedTabEl": ["selectedTabElChanged"]
- }; }
- static get style() { return tabNavCss; }
- };
- const tabTitleCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{margin-right:1.25rem;display:block;-ms-flex:0 1 auto;flex:0 1 auto;outline:2px solid transparent;outline-offset:2px;-webkit-margin-start:0px;margin-inline-start:0px;-webkit-margin-end:1.25rem;margin-inline-end:1.25rem}:host([layout=center]){margin-top:0px;margin-bottom:0px;margin-left:1.25rem;margin-right:1.25rem;text-align:center;-ms-flex-preferred-size:12rem;flex-basis:12rem}:host([position=below]) a{border-bottom-width:0px;border-top-width:2px;border-top-color:transparent;border-top-style:solid}:host a{outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out}:host(:focus) a{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}:host(:active) a,:host(:focus) a,:host(:hover) a{border-color:var(--calcite-ui-border-2);color:var(--calcite-ui-text-1);-webkit-text-decoration-line:none;text-decoration-line:none}:host([active]) a{border-color:transparent;color:var(--calcite-ui-text-1)}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) span,:host([disabled]) a{pointer-events:none;opacity:0.5}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host([scale=s]){-webkit-margin-end:1rem;margin-inline-end:1rem}:host([scale=s]) a,:host([scale=s]) span{padding-top:0.25rem;padding-bottom:0.25rem;font-size:var(--calcite-font-size--2);line-height:1rem}:host([scale=m]) a,:host([scale=m]) span{padding-top:0.5rem;padding-bottom:0.5rem;font-size:var(--calcite-font-size--1);line-height:1rem}:host([scale=l]){-webkit-margin-end:1.5rem;margin-inline-end:1.5rem}:host([scale=l]) a,:host([scale=l]) span{padding-top:0.75rem;padding-bottom:0.75rem;font-size:var(--calcite-font-size-0);line-height:1.25rem}a,span{-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;height:100%;width:100%;cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none;-ms-flex-pack:center;justify-content:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border-bottom-width:2px;padding-left:0px;padding-right:0px;padding-top:0.5rem;padding-bottom:0.5rem;font-size:var(--calcite-font-size--1);line-height:1rem;color:var(--calcite-ui-text-3);-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s;border-bottom-color:transparent;border-bottom-style:solid}span{cursor:default}.calcite-tab-title--icon{position:relative;margin:0px;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-item-align:center;align-self:center}.calcite-tab-title--icon svg{-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s}.container--has-text{padding:0.25rem}.container--has-text .calcite-tab-title--icon.icon-start{-webkit-margin-end:0.5rem;margin-inline-end:0.5rem}.container--has-text .calcite-tab-title--icon.icon-end{-webkit-margin-start:0.5rem;margin-inline-start:0.5rem}:host([icon-start][icon-end]) .calcite-tab-title--icon:first-child{-webkit-margin-end:0.5rem;margin-inline-end:0.5rem}:host([bordered]){-webkit-margin-end:0;margin-inline-end:0}:host([bordered][active]){-webkit-box-shadow:inset 0px -2px var(--calcite-ui-foreground-1);box-shadow:inset 0px -2px var(--calcite-ui-foreground-1)}:host([bordered][active][position=below]){-webkit-box-shadow:inset 0 2px 0 var(--calcite-ui-foreground-1);box-shadow:inset 0 2px 0 var(--calcite-ui-foreground-1)}:host([bordered]:hover) a,:host([bordered]:focus) a,:host([bordered]:active) a{position:relative}:host([bordered]:hover) a{background-color:var(--calcite-button-transparent-hover);-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s}:host([bordered]) a{border-bottom-style:unset}:host([bordered][position=below]) a{border-top-style:unset}:host([active][bordered]) a{border-left:1px solid var(--calcite-ui-border-1);border-right:1px solid var(--calcite-ui-border-1)}:host([bordered]) a,:host([bordered]) span{padding-left:0.75rem;padding-right:0.75rem}:host([bordered][scale=s]) a,:host([bordered][scale=s]) span{padding-left:0.5rem;padding-right:0.5rem}:host([bordered][scale=l]) a,:host([bordered][scale=l]) span{padding-left:1rem;padding-right:1rem}";
- const TabTitle = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteTabsActivate = createEvent(this, "calciteTabsActivate", 7);
- this.calciteInternalTabsActivate = createEvent(this, "calciteInternalTabsActivate", 7);
- this.calciteTabsFocusNext = createEvent(this, "calciteTabsFocusNext", 7);
- this.calciteTabsFocusPrevious = createEvent(this, "calciteTabsFocusPrevious", 7);
- this.calciteTabTitleRegister = createEvent(this, "calciteTabTitleRegister", 7);
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** Show this tab title as selected */
- this.active = false;
- /** Disable this tab title */
- this.disabled = false;
- /** @internal Parent tabs component bordered value */
- this.bordered = false;
- //--------------------------------------------------------------------------
- //
- // Private State/Props
- //
- //--------------------------------------------------------------------------
- /** watches for changing text content **/
- this.mutationObserver = createObserver("mutation", () => this.updateHasText());
- /** determine if there is slotted text for styling purposes */
- this.hasText = false;
- this.guid = `calcite-tab-title-${guid()}`;
- }
- activeTabChanged() {
- if (this.active) {
- this.emitActiveTab(false);
- }
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- this.setupTextContentObserver();
- this.parentTabNavEl = this.el.closest("calcite-tab-nav");
- this.parentTabsEl = this.el.closest("calcite-tabs");
- }
- disconnectedCallback() {
- var _a, _b;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- // Dispatching to body in order to be listened by other elements that are still connected to the DOM.
- (_b = document.body) === null || _b === void 0 ? void 0 : _b.dispatchEvent(new CustomEvent("calciteTabTitleUnregister", {
- detail: this.el
- }));
- }
- componentWillLoad() {
- if (Build.isBrowser) {
- this.updateHasText();
- }
- if (this.tab && this.active) {
- this.emitActiveTab(false);
- }
- }
- componentWillRender() {
- if (this.parentTabsEl) {
- this.layout = this.parentTabsEl.layout;
- this.position = this.parentTabsEl.position;
- this.scale = this.parentTabsEl.scale;
- this.bordered = this.parentTabsEl.bordered;
- }
- // handle case when tab-nav is only parent
- if (!this.parentTabsEl && this.parentTabNavEl) {
- this.position = getElementProp(this.parentTabNavEl, "position", this.position);
- this.scale = getElementProp(this.parentTabNavEl, "scale", this.scale);
- }
- }
- render() {
- const id = this.el.id || this.guid;
- const showSideBorders = this.bordered && !this.disabled && this.layout !== "center";
- const iconStartEl = (h("calcite-icon", { class: "calcite-tab-title--icon icon-start", flipRtl: this.iconFlipRtl === "start" || this.iconFlipRtl === "both", icon: this.iconStart, scale: "s" }));
- const iconEndEl = (h("calcite-icon", { class: "calcite-tab-title--icon icon-end", flipRtl: this.iconFlipRtl === "end" || this.iconFlipRtl === "both", icon: this.iconEnd, scale: "s" }));
- return (h(Host, { "aria-controls": this.controls, "aria-expanded": toAriaBoolean(this.active), id: id, role: "tab" }, h("a", { class: {
- container: true,
- "container--has-text": this.hasText
- }, style: showSideBorders && { width: `${this.parentTabNavEl.indicatorWidth}px` } }, this.iconStart ? iconStartEl : null, h("slot", null), this.iconEnd ? iconEndEl : null)));
- }
- async componentDidLoad() {
- this.calciteTabTitleRegister.emit(await this.getTabIdentifier());
- }
- componentDidRender() {
- updateHostInteraction(this, true);
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- internalTabChangeHandler(event) {
- const targetTabsEl = event
- .composedPath()
- .find((el) => el.tagName === "CALCITE-TABS");
- if (targetTabsEl !== this.parentTabsEl) {
- return;
- }
- if (this.tab) {
- this.active = this.tab === event.detail.tab;
- }
- else {
- this.getTabIndex().then((index) => {
- this.active = index === event.detail.tab;
- });
- }
- event.stopPropagation();
- }
- onClick() {
- this.emitActiveTab();
- }
- keyDownHandler(e) {
- switch (e.key) {
- case " ":
- case "Enter":
- this.emitActiveTab();
- e.preventDefault();
- break;
- case "ArrowRight":
- if (getElementDir(this.el) === "ltr") {
- this.calciteTabsFocusNext.emit();
- }
- else {
- this.calciteTabsFocusPrevious.emit();
- }
- break;
- case "ArrowLeft":
- if (getElementDir(this.el) === "ltr") {
- this.calciteTabsFocusPrevious.emit();
- }
- else {
- this.calciteTabsFocusNext.emit();
- }
- break;
- }
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /**
- * Return the index of this title within the nav
- */
- async getTabIndex() {
- return Array.prototype.indexOf.call(this.el.parentElement.querySelectorAll("calcite-tab-title"), this.el);
- }
- /**
- * @internal
- */
- async getTabIdentifier() {
- return this.tab ? this.tab : this.getTabIndex();
- }
- /**
- * @internal
- */
- async updateAriaInfo(tabIds = [], titleIds = []) {
- this.controls = tabIds[titleIds.indexOf(this.el.id)] || null;
- }
- updateHasText() {
- this.hasText = this.el.textContent.trim().length > 0;
- }
- setupTextContentObserver() {
- var _a;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
- }
- emitActiveTab(userTriggered = true) {
- if (this.disabled) {
- return;
- }
- const payload = { tab: this.tab };
- this.calciteInternalTabsActivate.emit(payload);
- if (userTriggered) {
- this.calciteTabsActivate.emit(payload);
- }
- }
- get el() { return this; }
- static get watchers() { return {
- "active": ["activeTabChanged"]
- }; }
- static get style() { return tabTitleCss; }
- };
- const SLOTS$4 = {
- tabNav: "tab-nav"
- };
- const tabsCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}:host([bordered]){-webkit-box-shadow:inset 0 1px 0 var(--calcite-ui-border-1);box-shadow:inset 0 1px 0 var(--calcite-ui-border-1);background-color:var(--calcite-ui-foreground-1)}:host([bordered]:not([position=below])) ::slotted(calcite-tab-nav){margin-bottom:-1px}:host([bordered][position=below]) ::slotted(calcite-tab-nav){margin-top:-1px}:host([bordered][position=below]){-webkit-box-shadow:inset 0 1px 0 var(--calcite-ui-border-1), inset 0 -1px 0 var(--calcite-ui-border-1);box-shadow:inset 0 1px 0 var(--calcite-ui-border-1), inset 0 -1px 0 var(--calcite-ui-border-1)}:host([bordered]) section{border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-1)}:host([bordered][scale=s]) section{padding:0.75rem}:host([bordered][scale=m]) section{padding:0.5rem}:host([bordered][scale=l]) section{padding:1rem}:host([position=below]){-ms-flex-direction:column-reverse;flex-direction:column-reverse}section{display:-ms-flexbox;display:flex;-ms-flex-positive:1;flex-grow:1;overflow:hidden;border-top-width:1px;border-top-color:var(--calcite-ui-border-1);border-top-style:solid}:host([position=below]) section{-ms-flex-direction:column-reverse;flex-direction:column-reverse;border-top-width:0px;border-bottom-width:1px;border-bottom-color:var(--calcite-ui-border-1)}:host([position=below]:not([bordered])) section{border-bottom-style:solid}";
- const Tabs = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- //--------------------------------------------------------------------------
- //
- // Public Properties
- //
- //--------------------------------------------------------------------------
- /**
- * Align tab titles to the edge or fully justify them across the tab nav ("center")
- */
- this.layout = "inline";
- /**
- * Display the tabs above (default) or below the tab content
- */
- this.position = "above";
- /**
- * Specify the scale of the tabs component, defaults to m
- */
- this.scale = "m";
- /**
- * Optionally enable tabs to appear like a folder-style menu when its layout is "inline"
- */
- this.bordered = false;
- //--------------------------------------------------------------------------
- //
- // Events
- //
- //--------------------------------------------------------------------------
- //--------------------------------------------------------------------------
- //
- // Private State/Props
- //
- //--------------------------------------------------------------------------
- /**
- *
- * Stores an array of ids of `<calcite-tab-titles>`s to match up ARIA
- * attributes.
- */
- this.titles = [];
- /**
- *
- * Stores an array of ids of `<calcite-tab>`s to match up ARIA attributes.
- */
- this.tabs = [];
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- if (this.layout === "center") {
- this.bordered = false;
- }
- }
- render() {
- return (h(Fragment, null, h("slot", { name: SLOTS$4.tabNav }), h("section", null, h("slot", null))));
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- /**
- * @internal
- */
- calciteTabTitleRegister(e) {
- this.titles = [...this.titles, e.target];
- this.registryHandler();
- e.stopPropagation();
- }
- /**
- * @internal
- */
- calciteTabTitleUnregister(e) {
- this.titles = this.titles.filter((el) => el !== e.detail);
- this.registryHandler();
- e.stopPropagation();
- }
- /**
- * @internal
- */
- calciteTabRegister(e) {
- this.tabs = [...this.tabs, e.target];
- this.registryHandler();
- e.stopPropagation();
- }
- /**
- * @internal
- */
- calciteTabUnregister(e) {
- this.tabs = this.tabs.filter((el) => el !== e.detail);
- this.registryHandler();
- e.stopPropagation();
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- /**
- *
- * Matches up elements from the internal `tabs` and `titles` to automatically
- * update the ARIA attributes and link `<calcite-tab>` and
- * `<calcite-tab-title>` components.
- */
- async registryHandler() {
- let tabIds;
- let titleIds;
- // determine if we are using `tab` based or `index` based tab identifiers.
- if (this.tabs.some((e) => e.tab) || this.titles.some((e) => e.tab)) {
- // if we are using `tab` based identifiers sort by `tab` to account for
- // possible out of order tabs and get the id of each tab
- tabIds = this.tabs.sort((a, b) => a.tab.localeCompare(b.tab)).map((e) => e.id);
- titleIds = this.titles.sort((a, b) => a.tab.localeCompare(b.tab)).map((e) => e.id);
- }
- else {
- // if we are using index based tabs then the `<calcite-tab>` and
- // `<calcite-tab-title>` might have been rendered out of order so the
- // order of `this.tabs` and `this.titles` might not reflect the DOM state,
- // and might not match each other so we need to get the index of all the
- // tabs and titles in the DOM order to match them up as a source of truth
- const tabDomIndexes = await Promise.all(this.tabs.map((el) => el.getTabIndex()));
- const titleDomIndexes = await Promise.all(this.titles.map((el) => el.getTabIndex()));
- // once we have the DOM order as a source of truth we can build the
- // matching tabIds and titleIds arrays
- tabIds = tabDomIndexes.reduce((ids, indexInDOM, registryIndex) => {
- ids[indexInDOM] = this.tabs[registryIndex].id;
- return ids;
- }, []);
- titleIds = titleDomIndexes.reduce((ids, indexInDOM, registryIndex) => {
- ids[indexInDOM] = this.titles[registryIndex].id;
- return ids;
- }, []);
- }
- // pass all our new aria information to each `<calcite-tab>` and
- // `<calcite-tab-title>` which will check if they can update their internal
- // `controlled` or `labeledBy` states and re-render if necessary
- this.tabs.forEach((el) => el.updateAriaInfo(tabIds, titleIds));
- this.titles.forEach((el) => el.updateAriaInfo(tabIds, titleIds));
- }
- get el() { return this; }
- static get style() { return tabsCss; }
- };
- const SLOTS$3 = {
- contentStart: "content-start",
- contentEnd: "content-end"
- };
- const tileCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{-webkit-box-sizing:border-box;box-sizing:border-box;display:inline-block;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-3);-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}:host .container{pointer-events:none;display:grid;grid-template-columns:repeat(1, minmax(0, 1fr));gap:0.5rem}:host .content{display:-ms-flexbox;display:flex;-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:center;justify-content:center;gap:0.5rem;width:10%}:host .content-container{display:-ms-flexbox;display:flex;width:100%;-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-align:stretch;align-items:stretch;padding:0px;color:var(--calcite-ui-text-2);outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out}:host .content-slot-container{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;background-color:var(--calcite-ui-foreground-1)}:host .content-slot-container:first-child{padding-inline:0 0.75rem}:host .content-slot-container:last-child{padding-inline:0.75rem 0}:host .heading{pointer-events:none;overflow-wrap:break-word;font-size:var(--calcite-font-size--1);line-height:1.375;font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-2);-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}:host .large-visual{-ms-flex-align:center;align-items:center;text-align:center;min-height:12rem}:host .large-visual .icon{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-item-align:end;align-self:flex-end}:host .large-visual .content-container{-ms-flex-item-align:center;align-self:center}:host .description{pointer-events:none;overflow-wrap:break-word;font-size:var(--calcite-font-size--2);line-height:1.375;color:var(--calcite-ui-text-3);-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}:host(:not([embed])){padding:0.75rem;-webkit-box-shadow:0 0 0 1px var(--calcite-ui-border-2);box-shadow:0 0 0 1px var(--calcite-ui-border-2)}:host(:not([embed])[href]:hover){cursor:pointer;-webkit-box-shadow:0 0 0 2px var(--calcite-ui-brand);box-shadow:0 0 0 2px var(--calcite-ui-brand)}:host(:not([embed])[href]:active){-webkit-box-shadow:0 0 0 3px var(--calcite-ui-brand);box-shadow:0 0 0 3px var(--calcite-ui-brand)}:host([icon][heading]:not([description]):not([embed])){padding:0px}:host([icon][heading]:not([description])) .icon{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center}:host([icon][heading]:not([description])) .large-visual{text-align:center}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host(:hover) .heading,:host([active]) .heading{color:var(--calcite-ui-text-1)}:host(:hover) .description,:host([active]) .description{color:var(--calcite-ui-text-2)}";
- const Tile = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** The active state of the tile. */
- this.active = false;
- /**
- * When true, prevents interaction.
- */
- this.disabled = false;
- /** The embed mode of the tile. When true, renders without a border and padding for use by other components. */
- this.embed = false;
- /**
- * The focused state of the tile.
- * @internal
- */
- this.focused = false;
- /** The hidden state of the tile. */
- this.hidden = false;
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- connectConditionalSlotComponent(this);
- }
- disconnectedCallback() {
- disconnectConditionalSlotComponent(this);
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- renderTile() {
- const { icon, el, heading, description } = this;
- const isLargeVisual = heading && icon && !description;
- const iconStyle = isLargeVisual
- ? {
- height: "64px",
- width: "64px"
- }
- : undefined;
- return (h("div", { class: { container: true, "large-visual": isLargeVisual } }, icon && (h("div", { class: "icon" }, h("calcite-icon", { icon: icon, scale: "l", style: iconStyle }))), h("div", { class: "content-container" }, getSlotted(el, SLOTS$3.contentStart) ? (h("div", { class: "content-slot-container" }, h("slot", { name: SLOTS$3.contentStart }))) : null, h("div", { class: "content" }, heading && h("div", { class: "heading" }, heading), description && h("div", { class: "description" }, description)), getSlotted(el, SLOTS$3.contentEnd) ? (h("div", { class: "content-slot-container" }, h("slot", { name: SLOTS$3.contentEnd }))) : null)));
- }
- render() {
- return (h(Fragment, null, this.href ? (h("calcite-link", { disabled: this.disabled, href: this.href }, this.renderTile())) : (this.renderTile())));
- }
- get el() { return this; }
- static get style() { return tileCss; }
- };
- const CSS$6 = {
- checked: "checked",
- description: "description",
- descriptionOnly: "description-only",
- disabled: "disabled",
- heading: "heading",
- headingOnly: "heading-only",
- icon: "icon",
- iconOnly: "icon-only",
- inputAlignmentEnd: "input-alignment-end",
- inputAlignmentStart: "input-alignment-start",
- inputEnabled: "input-enabled",
- largeVisual: "large-visual",
- widthAuto: "width-auto",
- widthFull: "width-full"
- };
- const tileSelectCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:block}:host .container{background-color:var(--calcite-ui-foreground-1);-webkit-box-shadow:0 0 0 1px var(--calcite-ui-border-2);box-shadow:0 0 0 1px var(--calcite-ui-border-2);-webkit-box-sizing:border-box;box-sizing:border-box;cursor:pointer;display:inline-block;height:100%;max-width:300px;padding:0.75rem;position:relative;-webkit-transition:var(--calcite-animation-timing);transition:var(--calcite-animation-timing);vertical-align:top;z-index:10}:host .container.checked{z-index:30;-webkit-box-shadow:0 0 0 1px var(--calcite-ui-brand);box-shadow:0 0 0 1px var(--calcite-ui-brand)}:host .container.heading-only{-ms-flex-align:center;align-items:center}:host .container:not(.input-enabled) ::slotted(calcite-checkbox),:host .container:not(.input-enabled) ::slotted(calcite-radio-button){position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}:host .container.focused:not(.disabled){z-index:30}:host .container.focused:not(.disabled):not(.input-enabled){-webkit-box-shadow:0 0 0 1px var(--calcite-ui-brand), inset 0 0 0 2px var(--calcite-ui-foreground-1), inset 0 0 0 5px var(--calcite-ui-brand);box-shadow:0 0 0 1px var(--calcite-ui-brand), inset 0 0 0 2px var(--calcite-ui-foreground-1), inset 0 0 0 5px var(--calcite-ui-brand)}:host .container.input-enabled.input-alignment-start.width-auto.heading-only,:host .container.input-enabled.input-alignment-start.width-auto.icon-only,:host .container.input-enabled.input-alignment-start.width-auto.description-only,:host .container.input-enabled.input-alignment-start.width-auto.heading.description,:host .container.input-enabled.input-alignment-start.width-auto.icon.description,:host .container.input-enabled.input-alignment-start.width-auto.heading.icon.description{display:inline-grid;grid-template-columns:-webkit-max-content 1fr;grid-template-columns:max-content 1fr}:host .container.input-enabled.input-alignment-start.heading-only,:host .container.input-enabled.input-alignment-start.icon-only,:host .container.input-enabled.input-alignment-start.description-only,:host .container.input-enabled.input-alignment-start.heading.description,:host .container.input-enabled.input-alignment-start.icon.description,:host .container.input-enabled.input-alignment-start.heading.icon.description{gap:0.75rem}:host .container.input-enabled.input-alignment-start calcite-tile{-ms-flex-order:1;order:1}:host .container.input-enabled.input-alignment-start.large-visual ::slotted(calcite-checkbox),:host .container.input-enabled.input-alignment-start.large-visual ::slotted(calcite-radio-button){position:absolute;inset-block-start:0.75rem;inset-inline-start:0.75rem}:host .container.input-enabled.input-alignment-end.width-auto.heading-only,:host .container.input-enabled.input-alignment-end.width-auto.icon-only{display:inline-grid;grid-gap:0.75rem;grid-template-columns:-webkit-max-content 1fr;grid-template-columns:max-content 1fr}:host .container.input-enabled.input-alignment-end.heading-only,:host .container.input-enabled.input-alignment-end.icon-only{gap:0.75rem}:host .container.input-enabled.input-alignment-end.description-only ::slotted(calcite-checkbox),:host .container.input-enabled.input-alignment-end.description-only ::slotted(calcite-radio-button),:host .container.input-enabled.input-alignment-end.heading.description ::slotted(calcite-checkbox),:host .container.input-enabled.input-alignment-end.heading.description ::slotted(calcite-radio-button),:host .container.input-enabled.input-alignment-end.icon.description ::slotted(calcite-checkbox),:host .container.input-enabled.input-alignment-end.icon.description ::slotted(calcite-radio-button),:host .container.input-enabled.input-alignment-end.heading.icon.description ::slotted(calcite-checkbox),:host .container.input-enabled.input-alignment-end.heading.icon.description ::slotted(calcite-radio-button){position:absolute;inset-block-start:0.75rem;inset-inline-end:0.75rem}:host .container.input-enabled.input-alignment-end.large-visual ::slotted(calcite-checkbox),:host .container.input-enabled.input-alignment-end.large-visual ::slotted(calcite-radio-button){position:absolute;inset-block-start:0.75rem;inset-inline-end:0.75rem}:host .container.width-full{display:-ms-flexbox;display:flex;max-width:none}:host .container.width-full calcite-tile{-ms-flex:1 1 auto;flex:1 1 auto}:host(:hover) .container{z-index:20}:host(:hover) .container:not(.input-enabled){-webkit-box-shadow:0 0 0 1px var(--calcite-ui-brand);box-shadow:0 0 0 1px var(--calcite-ui-brand)}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}";
- const TileSelect = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteTileSelectChange = createEvent(this, "calciteTileSelectChange", 7);
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** The checked state of the tile select. */
- this.checked = false;
- /** The disabled state of the tile select. */
- this.disabled = false;
- /** The hidden state of the tile select. */
- this.hidden = false;
- /** Display an interactive radio or checkbox. */
- this.inputEnabled = false;
- /** The side of the tile that the radio or checkbox appears on when inputEnabled is true. */
- this.inputAlignment = "start";
- /** The selection mode of the tile select: radio (single) or checkbox (multiple). */
- this.type = "radio";
- /** specify the width of the tile, defaults to auto */
- this.width = "auto";
- this.guid = `calcite-tile-select-${guid()}`;
- //--------------------------------------------------------------------------
- //
- // State
- //
- //--------------------------------------------------------------------------
- /** The focused state of the tile-select. */
- this.focused = false;
- }
- checkedChanged(newChecked) {
- this.input.checked = newChecked;
- }
- nameChanged(newName) {
- this.input.name = newName;
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- this.input.setFocus();
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- checkboxChangeHandler(event) {
- const checkbox = event.target;
- if (checkbox === this.input) {
- this.checked = checkbox.checked;
- }
- event.stopPropagation();
- this.calciteTileSelectChange.emit();
- }
- checkboxFocusBlurHandler(event) {
- const checkbox = event.target;
- if (checkbox === this.input) {
- this.focused = event.detail;
- }
- event.stopPropagation();
- }
- radioButtonChangeHandler(event) {
- const radioButton = event.target;
- if (radioButton === this.input) {
- this.checked = radioButton.checked;
- }
- event.stopPropagation();
- this.calciteTileSelectChange.emit();
- }
- radioButtonCheckedChangeHandler(event) {
- const radioButton = event.target;
- if (radioButton === this.input) {
- this.checked = radioButton.checked;
- }
- event.stopPropagation();
- }
- radioButtonFocusBlurHandler(event) {
- const radioButton = event.target;
- if (radioButton === this.input) {
- this.focused = radioButton.focused;
- }
- event.stopPropagation();
- }
- click(event) {
- const target = event.target;
- const targets = ["calcite-tile", "calcite-tile-select"];
- if (targets.includes(target.localName)) {
- this.input.click();
- }
- }
- mouseenter() {
- if (this.input.localName === "calcite-radio-button") {
- this.input.hovered = true;
- }
- if (this.input.localName === "calcite-checkbox") {
- this.input.hovered = true;
- }
- }
- mouseleave() {
- if (this.input.localName === "calcite-radio-button") {
- this.input.hovered = false;
- }
- if (this.input.localName === "calcite-checkbox") {
- this.input.hovered = false;
- }
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- this.renderInput();
- }
- disconnectedCallback() {
- this.input.parentNode.removeChild(this.input);
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- renderInput() {
- this.input = document.createElement(this.type === "radio" ? "calcite-radio-button" : "calcite-checkbox");
- this.input.checked = this.checked;
- this.input.disabled = this.disabled;
- this.input.hidden = this.hidden;
- this.input.id = this.guid;
- this.input.label = this.heading || this.name || "";
- if (this.name) {
- this.input.name = this.name;
- }
- if (this.value) {
- this.input.value = this.value != null ? this.value.toString() : "";
- }
- this.el.insertAdjacentElement("beforeend", this.input);
- }
- render() {
- const { checked, description, disabled, focused, heading, icon, inputAlignment, inputEnabled, width } = this;
- return (h("div", { class: {
- checked,
- container: true,
- [CSS$6.description]: Boolean(description),
- [CSS$6.descriptionOnly]: Boolean(!heading && !icon && description),
- disabled,
- focused,
- [CSS$6.heading]: Boolean(heading),
- [CSS$6.headingOnly]: heading && !icon && !description,
- [CSS$6.icon]: Boolean(icon),
- [CSS$6.iconOnly]: !heading && icon && !description,
- [CSS$6.inputAlignmentEnd]: inputAlignment === "end",
- [CSS$6.inputAlignmentStart]: inputAlignment === "start",
- [CSS$6.inputEnabled]: inputEnabled,
- [CSS$6.largeVisual]: heading && icon && !description,
- [CSS$6.widthAuto]: width === "auto",
- [CSS$6.widthFull]: width === "full"
- } }, h("calcite-tile", { active: checked, description: description, embed: true, heading: heading, icon: icon }), h("slot", null)));
- }
- get el() { return this; }
- static get watchers() { return {
- "checked": ["checkedChanged"],
- "name": ["nameChanged"]
- }; }
- static get style() { return tileSelectCss; }
- };
- const tileSelectGroupCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap}:host ::slotted(calcite-tile-select){margin-right:1px;margin-bottom:1px}:host([layout=vertical]){-ms-flex-direction:column;flex-direction:column}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}";
- const TileSelectGroup = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** The disabled state of the tile select. */
- this.disabled = false;
- /** Tiles by default move horizontally, stacking with each row, vertical allows single-column layouts */
- this.layout = "horizontal";
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentDidRender() {
- updateHostInteraction(this);
- }
- render() {
- return h("slot", null);
- }
- get el() { return this; }
- static get style() { return tileSelectGroupCss; }
- };
- const CSS$5 = {
- button: "button",
- buttonBottomLeft: "button--bottom-left",
- buttonBottomRight: "button--bottom-right",
- buttonHourDown: "button--hour-down",
- buttonHourUp: "button--hour-up",
- buttonMeridiemDown: "button--meridiem-down",
- buttonMeridiemUp: "button--meridiem-up",
- buttonMinuteDown: "button--minute-down",
- buttonMinuteUp: "button--minute-up",
- buttonSecondDown: "button--second-down",
- buttonSecondUp: "button--second-up",
- buttonTopLeft: "button--top-left",
- buttonTopRight: "button--top-right",
- column: "column",
- delimiter: "delimiter",
- hour: "hour",
- input: "input",
- meridiem: "meridiem",
- minute: "minute",
- second: "second",
- showMeridiem: "show-meridiem",
- showSecond: "show-second",
- "scale-s": "scale-s",
- "scale-m": "scale-m",
- "scale-l": "scale-l",
- timePicker: "time-picker",
- meridiemStart: "meridiem--start"
- };
- const TEXT$2 = {
- hour: "Hour",
- hourDown: "Decrease hour",
- hourUp: "Increase hour",
- meridiem: "AM/PM",
- meridiemDown: "Decrease AM/PM",
- meridiemUp: "Increase AM/PM",
- minute: "Minute",
- minuteDown: "Decrease minute",
- minuteUp: "Increase minute",
- second: "Second",
- secondDown: "Decrease second",
- secondUp: "Increase second"
- };
- const timePickerCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:inline-block}.time-picker{display:-ms-flexbox;display:flex;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-ms-flex-align:center;align-items:center;background-color:var(--calcite-ui-foreground-1);font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1);--tw-shadow:0 6px 20px -4px rgba(0, 0, 0, 0.1), 0 4px 12px -2px rgba(0, 0, 0, 0.08);--tw-shadow-colored:0 6px 20px -4px var(--tw-shadow-color), 0 4px 12px -2px var(--tw-shadow-color);-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);border-radius:var(--calcite-border-radius)}.time-picker .column{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}.time-picker .meridiem--start{-ms-flex-order:-1;order:-1}.time-picker .button{display:-ms-inline-flexbox;display:inline-flex;cursor:pointer;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;background-color:var(--calcite-ui-foreground-1)}.time-picker .button:hover,.time-picker .button:focus{background-color:var(--calcite-ui-foreground-2);outline:2px solid transparent;outline-offset:2px}.time-picker .button:active{background-color:var(--calcite-ui-foreground-3)}.time-picker .button.top-left{border-top-left-radius:var(--calcite-border-radius)}.time-picker .button.bottom-left{border-bottom-left-radius:var(--calcite-border-radius)}.time-picker .button.top-right{border-top-right-radius:var(--calcite-border-radius)}.time-picker .button.bottom-right{border-bottom-right-radius:var(--calcite-border-radius)}.time-picker .button calcite-icon{color:var(--calcite-ui-text-3)}.time-picker .input{display:-ms-inline-flexbox;display:inline-flex;cursor:pointer;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;background-color:var(--calcite-ui-foreground-1);font-weight:var(--calcite-font-weight-medium)}.time-picker .input:hover{-webkit-box-shadow:inset 0 0 0 2px var(--calcite-ui-foreground-2);box-shadow:inset 0 0 0 2px var(--calcite-ui-foreground-2)}.time-picker .input:focus,.time-picker .input:hover:focus{outline:2px solid transparent;outline-offset:2px;-webkit-box-shadow:inset 0 0 0 2px var(--calcite-ui-brand);box-shadow:inset 0 0 0 2px var(--calcite-ui-brand)}.time-picker.scale-s{font-size:var(--calcite-font-size--1)}.time-picker.scale-s .button,.time-picker.scale-s .input{padding-left:0.75rem;padding-right:0.75rem;padding-top:0.25rem;padding-bottom:0.25rem}.time-picker.scale-s:not(.show-meridiem) .delimiter:last-child{-webkit-padding-end:0.75rem;padding-inline-end:0.75rem}.time-picker.scale-m{font-size:var(--calcite-font-size-0)}.time-picker.scale-m .button,.time-picker.scale-m .input{padding-left:1rem;padding-right:1rem;padding-top:0.5rem;padding-bottom:0.5rem}.time-picker.scale-m:not(.show-meridiem) .delimiter:last-child{-webkit-padding-end:1rem;padding-inline-end:1rem}.time-picker.scale-l{font-size:var(--calcite-font-size-1)}.time-picker.scale-l .button,.time-picker.scale-l .input{padding-left:1.25rem;padding-right:1.25rem;padding-top:0.75rem;padding-bottom:0.75rem}.time-picker.scale-l:not(.show-meridiem) .delimiter:last-child{-webkit-padding-end:1.25rem;padding-inline-end:1.25rem}";
- function capitalize(str) {
- return str.charAt(0).toUpperCase() + str.slice(1);
- }
- const TimePicker = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteTimePickerBlur = createEvent(this, "calciteTimePickerBlur", 7);
- this.calciteTimePickerChange = createEvent(this, "calciteTimePickerChange", 7);
- this.calciteTimePickerFocus = createEvent(this, "calciteTimePickerFocus", 7);
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** aria-label for the hour input
- * @default "Hour"
- */
- this.intlHour = TEXT$2.hour;
- /** aria-label for the hour down button
- * @default "Decrease hour"
- */
- this.intlHourDown = TEXT$2.hourDown;
- /** aria-label for the hour up button
- * @default "Increase hour"
- */
- this.intlHourUp = TEXT$2.hourUp;
- /** aria-label for the meridiem (am/pm) input
- * @default "AM/PM"
- */
- this.intlMeridiem = TEXT$2.meridiem;
- /** aria-label for the meridiem (am/pm) down button
- * @default "Decrease AM/PM"
- */
- this.intlMeridiemDown = TEXT$2.meridiemDown;
- /** aria-label for the meridiem (am/pm) up button
- * @default "Increase AM/PM"
- */
- this.intlMeridiemUp = TEXT$2.meridiemUp;
- /** aria-label for the minute input
- * @default "Minute"
- */
- this.intlMinute = TEXT$2.minute;
- /** aria-label for the minute down button
- * @default "Decrease minute"
- */
- this.intlMinuteDown = TEXT$2.minuteDown;
- /** aria-label for the minute up button
- * @default "Increase minute"
- */
- this.intlMinuteUp = TEXT$2.minuteUp;
- /** aria-label for the second input
- * @default "Second"
- */
- this.intlSecond = TEXT$2.second;
- /** aria-label for the second down button
- * @default "Decrease second"
- */
- this.intlSecondDown = TEXT$2.secondDown;
- /** aria-label for the second up button
- * @default "Increase second"
- */
- this.intlSecondUp = TEXT$2.secondUp;
- /**
- * BCP 47 language tag for desired language and country format
- * @internal
- */
- this.locale = document.documentElement.lang || navigator.language || "en";
- /** The scale (size) of the time picker */
- this.scale = "m";
- /** number (seconds) that specifies the granularity that the value must adhere to */
- this.step = 60;
- /** The selected time in UTC (always 24-hour format) */
- this.value = null;
- this.showSecond = this.step < 60;
- this.decrementHour = () => {
- const newHour = !this.hour ? 0 : this.hour === "00" ? 23 : parseInt(this.hour) - 1;
- this.setValuePart("hour", newHour);
- };
- this.decrementMeridiem = () => {
- const newMeridiem = this.meridiem === "PM" ? "AM" : "PM";
- this.setValuePart("meridiem", newMeridiem);
- };
- this.decrementMinuteOrSecond = (key) => {
- let newValue;
- if (isValidNumber(this[key])) {
- const valueAsNumber = parseInt(this[key]);
- newValue = valueAsNumber === 0 ? 59 : valueAsNumber - 1;
- }
- else {
- newValue = 59;
- }
- this.setValuePart(key, newValue);
- };
- this.decrementMinute = () => {
- this.decrementMinuteOrSecond("minute");
- };
- this.decrementSecond = () => {
- this.decrementMinuteOrSecond("second");
- };
- this.focusHandler = (event) => {
- this.activeEl = event.currentTarget;
- };
- this.hourDownButtonKeyDownHandler = (event) => {
- if (this.buttonActivated(event)) {
- this.decrementHour();
- }
- };
- this.hourKeyDownHandler = (event) => {
- const key = event.key;
- if (numberKeys.includes(key)) {
- const keyAsNumber = parseInt(key);
- let newHour;
- if (isValidNumber(this.hour)) {
- switch (this.hourCycle) {
- case "12":
- newHour =
- this.hour === "01" && keyAsNumber >= 0 && keyAsNumber <= 2
- ? `1${keyAsNumber}`
- : keyAsNumber;
- break;
- case "24":
- if (this.hour === "01") {
- newHour = `1${keyAsNumber}`;
- }
- else if (this.hour === "02" && keyAsNumber >= 0 && keyAsNumber <= 3) {
- newHour = `2${keyAsNumber}`;
- }
- else {
- newHour = keyAsNumber;
- }
- break;
- }
- }
- else {
- newHour = keyAsNumber;
- }
- this.setValuePart("hour", newHour);
- }
- else {
- switch (key) {
- case "Backspace":
- case "Delete":
- this.setValuePart("hour", null);
- break;
- case "ArrowDown":
- event.preventDefault();
- this.decrementHour();
- break;
- case "ArrowUp":
- event.preventDefault();
- this.incrementHour();
- break;
- case " ":
- case "Spacebar":
- event.preventDefault();
- break;
- }
- }
- };
- this.hourUpButtonKeyDownHandler = (event) => {
- if (this.buttonActivated(event)) {
- this.incrementHour();
- }
- };
- this.incrementMeridiem = () => {
- const newMeridiem = this.meridiem === "AM" ? "PM" : "AM";
- this.setValuePart("meridiem", newMeridiem);
- };
- this.incrementHour = () => {
- const newHour = isValidNumber(this.hour)
- ? this.hour === "23"
- ? 0
- : parseInt(this.hour) + 1
- : 1;
- this.setValuePart("hour", newHour);
- };
- this.incrementMinuteOrSecond = (key) => {
- const newValue = isValidNumber(this[key])
- ? this[key] === "59"
- ? 0
- : parseInt(this[key]) + 1
- : 0;
- this.setValuePart(key, newValue);
- };
- this.incrementMinute = () => {
- this.incrementMinuteOrSecond("minute");
- };
- this.incrementSecond = () => {
- this.incrementMinuteOrSecond("second");
- };
- this.meridiemDownButtonKeyDownHandler = (event) => {
- if (this.buttonActivated(event)) {
- this.decrementMeridiem();
- }
- };
- this.meridiemKeyDownHandler = (event) => {
- switch (event.key) {
- case "a":
- this.setValuePart("meridiem", "AM");
- break;
- case "p":
- this.setValuePart("meridiem", "PM");
- break;
- case "Backspace":
- case "Delete":
- this.setValuePart("meridiem", null);
- break;
- case "ArrowUp":
- event.preventDefault();
- this.incrementMeridiem();
- break;
- case "ArrowDown":
- event.preventDefault();
- this.decrementMeridiem();
- break;
- case " ":
- case "Spacebar":
- event.preventDefault();
- break;
- }
- };
- this.meridiemUpButtonKeyDownHandler = (event) => {
- if (this.buttonActivated(event)) {
- this.incrementMeridiem();
- }
- };
- this.minuteDownButtonKeyDownHandler = (event) => {
- if (this.buttonActivated(event)) {
- this.decrementMinute();
- }
- };
- this.minuteKeyDownHandler = (event) => {
- const key = event.key;
- if (numberKeys.includes(key)) {
- const keyAsNumber = parseInt(key);
- let newMinute;
- if (isValidNumber(this.minute) && this.minute.startsWith("0")) {
- const minuteAsNumber = parseInt(this.minute);
- newMinute =
- minuteAsNumber > maxTenthForMinuteAndSecond
- ? keyAsNumber
- : `${minuteAsNumber}${keyAsNumber}`;
- }
- else {
- newMinute = keyAsNumber;
- }
- this.setValuePart("minute", newMinute);
- }
- else {
- switch (key) {
- case "Backspace":
- case "Delete":
- this.setValuePart("minute", null);
- break;
- case "ArrowDown":
- event.preventDefault();
- this.decrementMinute();
- break;
- case "ArrowUp":
- event.preventDefault();
- this.incrementMinute();
- break;
- case " ":
- case "Spacebar":
- event.preventDefault();
- break;
- }
- }
- };
- this.minuteUpButtonKeyDownHandler = (event) => {
- if (this.buttonActivated(event)) {
- this.incrementMinute();
- }
- };
- this.secondDownButtonKeyDownHandler = (event) => {
- if (this.buttonActivated(event)) {
- this.decrementSecond();
- }
- };
- this.secondKeyDownHandler = (event) => {
- const key = event.key;
- if (numberKeys.includes(key)) {
- const keyAsNumber = parseInt(key);
- let newSecond;
- if (isValidNumber(this.second) && this.second.startsWith("0")) {
- const secondAsNumber = parseInt(this.second);
- newSecond =
- secondAsNumber > maxTenthForMinuteAndSecond
- ? keyAsNumber
- : `${secondAsNumber}${keyAsNumber}`;
- }
- else {
- newSecond = keyAsNumber;
- }
- this.setValuePart("second", newSecond);
- }
- else {
- switch (key) {
- case "Backspace":
- case "Delete":
- this.setValuePart("second", null);
- break;
- case "ArrowDown":
- event.preventDefault();
- this.decrementSecond();
- break;
- case "ArrowUp":
- event.preventDefault();
- this.incrementSecond();
- break;
- case " ":
- case "Spacebar":
- event.preventDefault();
- break;
- }
- }
- };
- this.secondUpButtonKeyDownHandler = (event) => {
- if (this.buttonActivated(event)) {
- this.incrementSecond();
- }
- };
- this.setHourEl = (el) => (this.hourEl = el);
- this.setMeridiemEl = (el) => (this.meridiemEl = el);
- this.setMinuteEl = (el) => (this.minuteEl = el);
- this.setSecondEl = (el) => (this.secondEl = el);
- this.setValue = (value, emit = true) => {
- if (isValidTime(value)) {
- const { hour, minute, second } = parseTimeString(value);
- const { localizedHour, localizedHourSuffix, localizedMinute, localizedMinuteSuffix, localizedSecond, localizedSecondSuffix, localizedMeridiem } = localizeTimeStringToParts(value, this.locale);
- this.localizedHour = localizedHour;
- this.localizedHourSuffix = localizedHourSuffix;
- this.localizedMinute = localizedMinute;
- this.localizedMinuteSuffix = localizedMinuteSuffix;
- this.localizedSecond = localizedSecond;
- this.localizedSecondSuffix = localizedSecondSuffix;
- this.hour = hour;
- this.minute = minute;
- this.second = second;
- if (localizedMeridiem) {
- this.localizedMeridiem = localizedMeridiem;
- this.meridiem = getMeridiem(this.hour);
- const formatParts = getTimeParts(value, this.locale);
- this.meridiemOrder = this.getMeridiemOrder(formatParts);
- }
- }
- else {
- this.hour = null;
- this.localizedHour = null;
- this.localizedHourSuffix = null;
- this.localizedMeridiem = null;
- this.localizedMinute = null;
- this.localizedMinuteSuffix = null;
- this.localizedSecond = null;
- this.localizedSecondSuffix = null;
- this.meridiem = null;
- this.minute = null;
- this.second = null;
- this.value = null;
- }
- if (emit) {
- this.calciteTimePickerChange.emit();
- }
- };
- this.setValuePart = (key, value, emit = true) => {
- var _a;
- if (key === "meridiem") {
- this.meridiem = value;
- if (isValidNumber(this.hour)) {
- const hourAsNumber = parseInt(this.hour);
- switch (value) {
- case "AM":
- if (hourAsNumber >= 12) {
- this.hour = formatTimePart(hourAsNumber - 12);
- }
- break;
- case "PM":
- if (hourAsNumber < 12) {
- this.hour = formatTimePart(hourAsNumber + 12);
- }
- break;
- }
- this.localizedHour = localizeTimePart(this.hour, "hour", this.locale);
- }
- }
- else {
- this[key] = typeof value === "number" ? formatTimePart(value) : value;
- this[`localized${capitalize(key)}`] = localizeTimePart(this[key], key, this.locale);
- }
- if (this.hour && this.minute) {
- const showSeconds = this.second && this.showSecond;
- this.value = `${this.hour}:${this.minute}:${showSeconds ? this.second : "00"}`;
- }
- else {
- this.value = null;
- }
- this.localizedMeridiem = this.value
- ? ((_a = localizeTimeStringToParts(this.value, this.locale)) === null || _a === void 0 ? void 0 : _a.localizedMeridiem) || null
- : localizeTimePart(this.meridiem, "meridiem", this.locale);
- if (emit) {
- this.calciteTimePickerChange.emit();
- }
- };
- }
- localeWatcher(newLocale) {
- this.hourCycle = getLocaleHourCycle(newLocale);
- this.setValue(this.value, false);
- }
- valueWatcher(newValue) {
- this.setValue(newValue, false);
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- hostBlurHandler() {
- this.calciteTimePickerBlur.emit();
- }
- hostFocusHandler() {
- this.calciteTimePickerFocus.emit();
- }
- keyDownHandler(event) {
- const key = event.key;
- switch (this.activeEl) {
- case this.hourEl:
- if (key === "ArrowRight") {
- this.setFocus("minute");
- }
- break;
- case this.minuteEl:
- switch (key) {
- case "ArrowLeft":
- this.setFocus("hour");
- break;
- case "ArrowRight":
- if (this.step !== 60) {
- this.setFocus("second");
- }
- else if (this.hourCycle === "12") {
- this.setFocus("meridiem");
- }
- break;
- }
- break;
- case this.secondEl:
- switch (key) {
- case "ArrowLeft":
- this.setFocus("minute");
- break;
- case "ArrowRight":
- if (this.hourCycle === "12") {
- this.setFocus("meridiem");
- }
- break;
- }
- break;
- case this.meridiemEl:
- switch (key) {
- case "ArrowLeft":
- if (this.step !== 60) {
- this.setFocus("second");
- }
- else {
- this.setFocus("minute");
- }
- break;
- }
- break;
- }
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus(target) {
- var _a;
- (_a = this[`${target || "hour"}El`]) === null || _a === void 0 ? void 0 : _a.focus();
- }
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- buttonActivated(event) {
- const key = event.key;
- if (key === " ") {
- event.preventDefault();
- }
- return isActivationKey(key);
- }
- getMeridiemOrder(formatParts) {
- const isRTLKind = this.locale === "ar" || this.locale === "he";
- if (formatParts && !isRTLKind) {
- const index = formatParts.findIndex((parts) => {
- return parts.value === this.localizedMeridiem;
- });
- return index;
- }
- return 0;
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- this.setValue(this.value, false);
- this.hourCycle = getLocaleHourCycle(this.locale);
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- render() {
- const hourIsNumber = isValidNumber(this.hour);
- const iconScale = this.scale === "s" || this.scale === "m" ? "s" : "m";
- const minuteIsNumber = isValidNumber(this.minute);
- const secondIsNumber = isValidNumber(this.second);
- const showMeridiem = this.hourCycle === "12";
- return (h("div", { class: {
- [CSS$5.timePicker]: true,
- [CSS$5.showMeridiem]: showMeridiem,
- [CSS$5.showSecond]: this.showSecond,
- [CSS$5[`scale-${this.scale}`]]: true
- }, dir: "ltr" }, h("div", { class: CSS$5.column, role: "group" }, h("span", { "aria-label": this.intlHourUp, class: {
- [CSS$5.button]: true,
- [CSS$5.buttonHourUp]: true,
- [CSS$5.buttonTopLeft]: true
- }, onClick: this.incrementHour, onKeyDown: this.hourUpButtonKeyDownHandler, role: "button", tabIndex: -1 }, h("calcite-icon", { icon: "chevron-up", scale: iconScale })), h("span", { "aria-label": this.intlHour, "aria-valuemax": "23", "aria-valuemin": "1", "aria-valuenow": (hourIsNumber && parseInt(this.hour)) || "0", "aria-valuetext": this.hour, class: {
- [CSS$5.input]: true,
- [CSS$5.hour]: true
- }, onFocus: this.focusHandler, onKeyDown: this.hourKeyDownHandler, ref: this.setHourEl, role: "spinbutton", tabIndex: 0 }, this.localizedHour || "--"), h("span", { "aria-label": this.intlHourDown, class: {
- [CSS$5.button]: true,
- [CSS$5.buttonHourDown]: true,
- [CSS$5.buttonBottomLeft]: true
- }, onClick: this.decrementHour, onKeyDown: this.hourDownButtonKeyDownHandler, role: "button", tabIndex: -1 }, h("calcite-icon", { icon: "chevron-down", scale: iconScale }))), h("span", { class: CSS$5.delimiter }, this.localizedHourSuffix), h("div", { class: CSS$5.column, role: "group" }, h("span", { "aria-label": this.intlMinuteUp, class: {
- [CSS$5.button]: true,
- [CSS$5.buttonMinuteUp]: true
- }, onClick: this.incrementMinute, onKeyDown: this.minuteUpButtonKeyDownHandler, role: "button", tabIndex: -1 }, h("calcite-icon", { icon: "chevron-up", scale: iconScale })), h("span", { "aria-label": this.intlMinute, "aria-valuemax": "12", "aria-valuemin": "1", "aria-valuenow": (minuteIsNumber && parseInt(this.minute)) || "0", "aria-valuetext": this.minute, class: {
- [CSS$5.input]: true,
- [CSS$5.minute]: true
- }, onFocus: this.focusHandler, onKeyDown: this.minuteKeyDownHandler, ref: this.setMinuteEl, role: "spinbutton", tabIndex: 0 }, this.localizedMinute || "--"), h("span", { "aria-label": this.intlMinuteDown, class: {
- [CSS$5.button]: true,
- [CSS$5.buttonMinuteDown]: true
- }, onClick: this.decrementMinute, onKeyDown: this.minuteDownButtonKeyDownHandler, role: "button", tabIndex: -1 }, h("calcite-icon", { icon: "chevron-down", scale: iconScale }))), this.showSecond && h("span", { class: CSS$5.delimiter }, this.localizedMinuteSuffix), this.showSecond && (h("div", { class: CSS$5.column, role: "group" }, h("span", { "aria-label": this.intlSecondUp, class: {
- [CSS$5.button]: true,
- [CSS$5.buttonSecondUp]: true
- }, onClick: this.incrementSecond, onKeyDown: this.secondUpButtonKeyDownHandler, role: "button", tabIndex: -1 }, h("calcite-icon", { icon: "chevron-up", scale: iconScale })), h("span", { "aria-label": this.intlSecond, "aria-valuemax": "59", "aria-valuemin": "0", "aria-valuenow": (secondIsNumber && parseInt(this.second)) || "0", "aria-valuetext": this.second, class: {
- [CSS$5.input]: true,
- [CSS$5.second]: true
- }, onFocus: this.focusHandler, onKeyDown: this.secondKeyDownHandler, ref: this.setSecondEl, role: "spinbutton", tabIndex: 0 }, this.localizedSecond || "--"), h("span", { "aria-label": this.intlSecondDown, class: {
- [CSS$5.button]: true,
- [CSS$5.buttonSecondDown]: true
- }, onClick: this.decrementSecond, onKeyDown: this.secondDownButtonKeyDownHandler, role: "button", tabIndex: -1 }, h("calcite-icon", { icon: "chevron-down", scale: iconScale })))), this.localizedSecondSuffix && (h("span", { class: CSS$5.delimiter }, this.localizedSecondSuffix)), showMeridiem && (h("div", { class: {
- [CSS$5.column]: true,
- [CSS$5.meridiemStart]: this.meridiemOrder === 0
- }, role: "group" }, h("span", { "aria-label": this.intlMeridiemUp, class: {
- [CSS$5.button]: true,
- [CSS$5.buttonMeridiemUp]: true,
- [CSS$5.buttonTopRight]: true
- }, onClick: this.incrementMeridiem, onKeyDown: this.meridiemUpButtonKeyDownHandler, role: "button", tabIndex: -1 }, h("calcite-icon", { icon: "chevron-up", scale: iconScale })), h("span", { "aria-label": this.intlMeridiem, "aria-valuemax": "2", "aria-valuemin": "1", "aria-valuenow": (this.meridiem === "PM" && "2") || "1", "aria-valuetext": this.meridiem, class: {
- [CSS$5.input]: true,
- [CSS$5.meridiem]: true
- }, onFocus: this.focusHandler, onKeyDown: this.meridiemKeyDownHandler, ref: this.setMeridiemEl, role: "spinbutton", tabIndex: 0 }, this.localizedMeridiem || "--"), h("span", { "aria-label": this.intlMeridiemDown, class: {
- [CSS$5.button]: true,
- [CSS$5.buttonMeridiemDown]: true,
- [CSS$5.buttonBottomRight]: true
- }, onClick: this.decrementMeridiem, onKeyDown: this.meridiemDownButtonKeyDownHandler, role: "button", tabIndex: -1 }, h("calcite-icon", { icon: "chevron-down", scale: iconScale }))))));
- }
- get el() { return this; }
- static get watchers() { return {
- "locale": ["localeWatcher"],
- "value": ["valueWatcher"]
- }; }
- static get style() { return timePickerCss; }
- };
- const CSS$4 = {
- header: "header",
- heading: "heading",
- close: "close",
- container: "container",
- tipContainer: "tip-container",
- tipContainerAdvancing: "tip-container--advancing",
- tipContainerRetreating: "tip-container--retreating",
- pagination: "pagination",
- pagePosition: "page-position",
- pageNext: "page-next",
- pagePrevious: "page-previous"
- };
- const ICONS$3 = {
- chevronLeft: "chevron-left",
- chevronRight: "chevron-right",
- close: "x"
- };
- const TEXT$1 = {
- defaultGroupTitle: "Tips",
- defaultPaginationLabel: "Tip",
- close: "Close",
- previous: "Previous",
- next: "Next"
- };
- const HEADING_LEVEL$1 = 2;
- const CSS$3 = {
- container: "container",
- header: "header",
- heading: "heading",
- close: "close",
- imageFrame: "image-frame",
- content: "content",
- info: "info"
- };
- const ICONS$2 = {
- close: "x"
- };
- const SLOTS$2 = {
- thumbnail: "thumbnail"
- };
- const TEXT = {
- close: "Close"
- };
- const HEADING_LEVEL = (HEADING_LEVEL$1 + 1);
- const tipCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;margin:1rem;-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-2);background-color:var(--calcite-ui-foreground-1);font-size:var(--calcite-font-size--1);line-height:1rem;color:var(--calcite-ui-text-2)}:host *{-webkit-box-sizing:border-box;box-sizing:border-box}.container{width:100%;padding:1rem}:host([dismissed]),:host([dismissed]) .container{display:none}:host([selected]) .container{margin:0px;border-style:none;padding:0px}.header{margin:0px;display:-ms-flexbox;display:flex;-ms-flex-line-pack:justify;align-content:space-between;-ms-flex-align:center;align-items:center;fill:var(--calcite-ui-text-2);color:var(--calcite-ui-text-2)}.heading{margin:0px;padding:0px;font-weight:var(--calcite-font-weight-medium)}.header .heading{-ms-flex:1 1 auto;flex:1 1 auto;padding:0.5rem}h1.heading{font-size:var(--calcite-font-size-2);line-height:1.5rem}h2.heading{font-size:var(--calcite-font-size-1);line-height:1.5rem}h3.heading{font-size:var(--calcite-font-size-0);line-height:1.25rem}h4.heading,h5.heading{font-size:var(--calcite-font-size--1);line-height:1rem}.header{margin-bottom:0.5rem}.header .heading{padding:0px;color:var(--calcite-ui-text-1)}.container[hidden]{display:none}.content{display:-ms-flexbox;display:flex}.info{padding-top:0px;padding-bottom:0px;padding-left:1rem;padding-right:1rem;width:70%}.info:only-child{width:100%;padding-left:0px;padding-right:0px}::slotted(p){margin-top:0px}::slotted(a){outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;color:var(--calcite-ui-brand)}::slotted(a:focus){outline:2px solid var(--calcite-ui-brand);outline-offset:2px}.image-frame{width:25%}.image-frame img{max-width:100%}::slotted(img){max-width:100%}";
- const Tip = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteTipDismiss = createEvent(this, "calciteTipDismiss", 7);
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * No longer displays the tip.
- */
- this.dismissed = false;
- /**
- * Indicates whether the tip can be dismissed.
- */
- this.nonDismissible = false;
- /**
- * The selected state of the tip if it is being used inside a `calcite-tip-manager`.
- */
- this.selected = false;
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- this.hideTip = () => {
- this.dismissed = true;
- this.calciteTipDismiss.emit();
- };
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- connectConditionalSlotComponent(this);
- }
- disconnectedCallback() {
- disconnectConditionalSlotComponent(this);
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- renderHeader() {
- var _a;
- const { heading, headingLevel, el } = this;
- const parentLevel = (_a = el.closest("calcite-tip-manager")) === null || _a === void 0 ? void 0 : _a.headingLevel;
- const relativeLevel = parentLevel ? constrainHeadingLevel(parentLevel + 1) : null;
- const level = headingLevel || relativeLevel || HEADING_LEVEL;
- return heading ? (h("header", { class: CSS$3.header }, h(Heading, { class: CSS$3.heading, level: level }, heading))) : null;
- }
- renderDismissButton() {
- const { nonDismissible, hideTip, intlClose } = this;
- const text = intlClose || TEXT.close;
- return !nonDismissible ? (h("calcite-action", { class: CSS$3.close, icon: ICONS$2.close, onClick: hideTip, scale: "l", text: text })) : null;
- }
- renderImageFrame() {
- const { el } = this;
- return getSlotted(el, SLOTS$2.thumbnail) ? (h("div", { class: CSS$3.imageFrame, key: "thumbnail" }, h("slot", { name: SLOTS$2.thumbnail }))) : null;
- }
- renderInfoNode() {
- return (h("div", { class: CSS$3.info }, h("slot", null)));
- }
- renderContent() {
- return (h("div", { class: CSS$3.content }, this.renderImageFrame(), this.renderInfoNode()));
- }
- render() {
- return (h(Fragment, null, h("article", { class: CSS$3.container }, this.renderHeader(), this.renderContent()), this.renderDismissButton()));
- }
- get el() { return this; }
- static get style() { return tipCss; }
- };
- const tipGroupCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{-webkit-box-sizing:border-box;box-sizing:border-box;display:block;background-color:var(--calcite-ui-foreground-1);font-size:var(--calcite-font-size--1);line-height:1rem;color:var(--calcite-ui-text-2)}::slotted(calcite-tip){margin:0px;border-style:none}:host-context(calcite-tip-manager){margin-top:0.75rem;margin-bottom:0.75rem}:host-context(calcite-tip-manager) ::slotted(calcite-tip){padding:1rem}";
- const TipGroup = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- }
- render() {
- return h("slot", null);
- }
- static get style() { return tipGroupCss; }
- };
- const tipManagerCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{-webkit-box-sizing:border-box;box-sizing:border-box;display:block;background-color:var(--calcite-ui-foreground-1);font-size:var(--calcite-font-size--1);line-height:1rem;color:var(--calcite-ui-text-2);--calcite-tip-manager-height:19vh}:host *{-webkit-box-sizing:border-box;box-sizing:border-box}:host([closed]){display:none}.header{margin:0px;display:-ms-flexbox;display:flex;-ms-flex-line-pack:justify;align-content:space-between;-ms-flex-align:center;align-items:center;fill:var(--calcite-ui-text-2);color:var(--calcite-ui-text-2)}.heading{margin:0px;padding:0px;font-weight:var(--calcite-font-weight-medium)}.header .heading{-ms-flex:1 1 auto;flex:1 1 auto;padding:0.5rem}h1.heading{font-size:var(--calcite-font-size-2);line-height:1.5rem}h2.heading{font-size:var(--calcite-font-size-1);line-height:1.5rem}h3.heading{font-size:var(--calcite-font-size-0);line-height:1.25rem}h4.heading,h5.heading{font-size:var(--calcite-font-size--1);line-height:1rem}.header{border-width:0px;border-bottom-width:1px;border-style:solid;border-color:var(--calcite-ui-border-3);padding-top:0px;padding-bottom:0px;-webkit-padding-end:0px;padding-inline-end:0px;-webkit-padding-start:1rem;padding-inline-start:1rem}.header h2.heading{padding:0px;font-size:var(--calcite-font-size-1);line-height:1.5rem;font-weight:var(--calcite-font-weight-bold);color:var(--calcite-ui-text-1)}.container{position:relative;overflow:hidden;outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;min-height:150px}.container:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:2px}.tip-container{margin-top:1px;display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;-ms-flex-pack:center;justify-content:center;overflow:auto;outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;-webkit-animation-name:none;animation-name:none;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing);height:var(--calcite-tip-manager-height)}.tip-container:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:2px}::slotted(calcite-tip){border-style:none;padding:0.75rem;max-width:var(--calcite-tip-max-width)}.tip-container--advancing{-webkit-animation-name:tip-advance;animation-name:tip-advance}.tip-container--retreating{-webkit-animation-name:tip-retreat;animation-name:tip-retreat}.pagination{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding-left:0px;padding-right:0px;padding-top:0.75rem;padding-bottom:0.5rem}.page-position{margin-top:0px;margin-bottom:0px;margin-left:0.5rem;margin-right:0.5rem;font-size:var(--calcite-font-size--2);line-height:1rem}@-webkit-keyframes tip-advance{0%{opacity:0;-webkit-transform:translate3d(50px, 0, 0) scale(0.99);transform:translate3d(50px, 0, 0) scale(0.99)}100%{opacity:1;-webkit-transform:translate3d(0, 0, 0) scale(1);transform:translate3d(0, 0, 0) scale(1)}}@keyframes tip-advance{0%{opacity:0;-webkit-transform:translate3d(50px, 0, 0) scale(0.99);transform:translate3d(50px, 0, 0) scale(0.99)}100%{opacity:1;-webkit-transform:translate3d(0, 0, 0) scale(1);transform:translate3d(0, 0, 0) scale(1)}}@-webkit-keyframes tip-retreat{0%{opacity:0;-webkit-transform:translate3d(-50px, 0, 0) scale(0.99);transform:translate3d(-50px, 0, 0) scale(0.99)}100%{opacity:1;-webkit-transform:translate3d(0, 0, 0) scale(1);transform:translate3d(0, 0, 0) scale(1)}}@keyframes tip-retreat{0%{opacity:0;-webkit-transform:translate3d(-50px, 0, 0) scale(0.99);transform:translate3d(-50px, 0, 0) scale(0.99)}100%{opacity:1;-webkit-transform:translate3d(0, 0, 0) scale(1);transform:translate3d(0, 0, 0) scale(1)}}";
- const TipManager = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteTipManagerToggle = createEvent(this, "calciteTipManagerToggle", 7);
- this.calciteTipManagerClose = createEvent(this, "calciteTipManagerClose", 7);
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * Closed state of the `calcite-tip-manager`.
- */
- this.closed = false;
- this.mutationObserver = createObserver("mutation", () => this.setUpTips());
- this.hideTipManager = () => {
- this.closed = true;
- this.calciteTipManagerToggle.emit();
- this.calciteTipManagerClose.emit();
- };
- this.previousClicked = () => {
- this.previousTip();
- };
- this.nextClicked = () => {
- this.nextTip();
- };
- this.tipManagerKeyUpHandler = (event) => {
- if (event.target !== this.container) {
- return;
- }
- switch (event.key) {
- case "ArrowRight":
- event.preventDefault();
- this.nextTip();
- break;
- case "ArrowLeft":
- event.preventDefault();
- this.previousTip();
- break;
- case "Home":
- event.preventDefault();
- this.selectedIndex = 0;
- break;
- case "End":
- event.preventDefault();
- this.selectedIndex = this.total - 1;
- break;
- }
- };
- this.storeContainerRef = (el) => {
- this.container = el;
- };
- }
- closedChangeHandler() {
- this.direction = null;
- this.calciteTipManagerToggle.emit();
- }
- selectedChangeHandler() {
- this.showSelectedTip();
- this.updateGroupTitle();
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- var _a;
- this.setUpTips();
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
- }
- disconnectedCallback() {
- var _a;
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- }
- // --------------------------------------------------------------------------
- //
- // Public Methods
- //
- // --------------------------------------------------------------------------
- /** Selects the next tip to display */
- async nextTip() {
- this.direction = "advancing";
- const nextIndex = this.selectedIndex + 1;
- this.selectedIndex = (nextIndex + this.total) % this.total;
- }
- /** Selects the previous tip to display */
- async previousTip() {
- this.direction = "retreating";
- const previousIndex = this.selectedIndex - 1;
- this.selectedIndex = (previousIndex + this.total) % this.total;
- }
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- setUpTips() {
- const tips = Array.from(this.el.querySelectorAll("calcite-tip"));
- this.total = tips.length;
- if (this.total === 0) {
- return;
- }
- const selectedTip = this.el.querySelector("calcite-tip[selected]");
- this.tips = tips;
- this.selectedIndex = selectedTip ? tips.indexOf(selectedTip) : 0;
- tips.forEach((tip) => {
- tip.nonDismissible = true;
- });
- this.showSelectedTip();
- this.updateGroupTitle();
- }
- showSelectedTip() {
- this.tips.forEach((tip, index) => {
- const isSelected = this.selectedIndex === index;
- tip.selected = isSelected;
- tip.hidden = !isSelected;
- });
- }
- updateGroupTitle() {
- const selectedTip = this.tips[this.selectedIndex];
- const tipParent = selectedTip.closest("calcite-tip-group");
- this.groupTitle = (tipParent === null || tipParent === void 0 ? void 0 : tipParent.groupTitle) || this.intlDefaultTitle || TEXT$1.defaultGroupTitle;
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- renderPagination() {
- const dir = getElementDir(this.el);
- const { selectedIndex, tips, total, intlNext, intlPrevious, intlPaginationLabel } = this;
- const nextLabel = intlNext || TEXT$1.next;
- const previousLabel = intlPrevious || TEXT$1.previous;
- const paginationLabel = intlPaginationLabel || TEXT$1.defaultPaginationLabel;
- return tips.length > 1 ? (h("footer", { class: CSS$4.pagination }, h("calcite-action", { class: CSS$4.pagePrevious, icon: dir === "ltr" ? ICONS$3.chevronLeft : ICONS$3.chevronRight, onClick: this.previousClicked, scale: "m", text: previousLabel }), h("span", { class: CSS$4.pagePosition }, `${paginationLabel} ${selectedIndex + 1}/${total}`), h("calcite-action", { class: CSS$4.pageNext, icon: dir === "ltr" ? ICONS$3.chevronRight : ICONS$3.chevronLeft, onClick: this.nextClicked, scale: "m", text: nextLabel }))) : null;
- }
- render() {
- const { closed, direction, headingLevel, groupTitle, selectedIndex, intlClose, total } = this;
- const closeLabel = intlClose || TEXT$1.close;
- if (total === 0) {
- return null;
- }
- return (h("section", { "aria-hidden": toAriaBoolean(closed), class: CSS$4.container, hidden: closed, onKeyUp: this.tipManagerKeyUpHandler, ref: this.storeContainerRef, tabIndex: 0 }, h("header", { class: CSS$4.header }, h(Heading, { class: CSS$4.heading, level: headingLevel || HEADING_LEVEL$1 }, groupTitle), h("calcite-action", { class: CSS$4.close, onClick: this.hideTipManager, scale: "m", text: closeLabel }, h("calcite-icon", { icon: ICONS$3.close, scale: "m" }))), h("div", { class: {
- [CSS$4.tipContainer]: true,
- [CSS$4.tipContainerAdvancing]: !closed && direction === "advancing",
- [CSS$4.tipContainerRetreating]: !closed && direction === "retreating"
- }, key: selectedIndex, tabIndex: 0 }, h("slot", null)), this.renderPagination()));
- }
- get el() { return this; }
- static get watchers() { return {
- "closed": ["closedChangeHandler"],
- "selectedIndex": ["selectedChangeHandler"]
- }; }
- static get style() { return tipManagerCss; }
- };
- const CSS$2 = {
- container: "container",
- arrow: "arrow"
- };
- const TOOLTIP_DELAY_MS = 500;
- const ARIA_DESCRIBED_BY = "aria-describedby";
- class TooltipManager$1 {
- constructor() {
- // --------------------------------------------------------------------------
- //
- // Private Properties
- //
- // --------------------------------------------------------------------------
- this.registeredElements = new WeakMap();
- this.hoverTimeouts = new WeakMap();
- this.registeredElementCount = 0;
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- this.queryTooltip = (composedPath) => {
- const { registeredElements } = this;
- const registeredElement = composedPath.find((pathEl) => registeredElements.has(pathEl));
- return registeredElements.get(registeredElement);
- };
- this.keyDownHandler = (event) => {
- if (event.key === "Escape") {
- const { activeTooltipEl } = this;
- if (activeTooltipEl) {
- this.clearHoverTimeout(activeTooltipEl);
- this.toggleTooltip(activeTooltipEl, false);
- }
- }
- };
- this.mouseEnterShow = (event) => {
- this.hoverEvent(event, true);
- };
- this.mouseLeaveHide = (event) => {
- this.hoverEvent(event, false);
- };
- this.clickHandler = (event) => {
- this.clickedTooltip = this.queryTooltip(event.composedPath());
- };
- this.focusShow = (event) => {
- this.focusEvent(event, true);
- };
- this.blurHide = (event) => {
- this.focusEvent(event, false);
- };
- this.hoverToggle = (tooltip, value) => {
- const { hoverTimeouts } = this;
- hoverTimeouts.delete(tooltip);
- if (value) {
- this.closeExistingTooltip();
- }
- this.toggleTooltip(tooltip, value);
- };
- }
- // --------------------------------------------------------------------------
- //
- // Public Methods
- //
- // --------------------------------------------------------------------------
- registerElement(referenceEl, tooltip) {
- this.registeredElementCount++;
- this.registeredElements.set(referenceEl, tooltip);
- if (this.registeredElementCount === 1) {
- this.addListeners();
- }
- }
- unregisterElement(referenceEl) {
- if (this.registeredElements.delete(referenceEl)) {
- this.registeredElementCount--;
- }
- if (this.registeredElementCount === 0) {
- this.removeListeners();
- }
- }
- addListeners() {
- document.addEventListener("keydown", this.keyDownHandler);
- document.addEventListener("mouseover", this.mouseEnterShow, { capture: true });
- document.addEventListener("mouseout", this.mouseLeaveHide, { capture: true });
- document.addEventListener("pointerdown", this.clickHandler, { capture: true });
- document.addEventListener("focusin", this.focusShow), { capture: true };
- document.addEventListener("focusout", this.blurHide, { capture: true });
- }
- removeListeners() {
- document.removeEventListener("keydown", this.keyDownHandler);
- document.removeEventListener("mouseover", this.mouseEnterShow, { capture: true });
- document.removeEventListener("mouseout", this.mouseLeaveHide, { capture: true });
- document.removeEventListener("pointerdown", this.clickHandler, { capture: true });
- document.removeEventListener("focusin", this.focusShow, { capture: true });
- document.removeEventListener("focusout", this.blurHide, { capture: true });
- }
- clearHoverTimeout(tooltip) {
- const { hoverTimeouts } = this;
- if (hoverTimeouts.has(tooltip)) {
- window.clearTimeout(hoverTimeouts.get(tooltip));
- hoverTimeouts.delete(tooltip);
- }
- }
- closeExistingTooltip() {
- const { activeTooltipEl } = this;
- if (activeTooltipEl) {
- this.toggleTooltip(activeTooltipEl, false);
- }
- }
- focusTooltip(tooltip, value) {
- this.closeExistingTooltip();
- if (value) {
- this.clearHoverTimeout(tooltip);
- }
- this.toggleTooltip(tooltip, value);
- }
- toggleTooltip(tooltip, value) {
- tooltip.open = value;
- if (value) {
- this.activeTooltipEl = tooltip;
- }
- }
- hoverTooltip(tooltip, value) {
- this.clearHoverTimeout(tooltip);
- const { hoverTimeouts } = this;
- const timeoutId = window.setTimeout(() => this.hoverToggle(tooltip, value), TOOLTIP_DELAY_MS );
- hoverTimeouts.set(tooltip, timeoutId);
- }
- activeTooltipHover(event) {
- const { activeTooltipEl, hoverTimeouts } = this;
- const { type } = event;
- if (!activeTooltipEl) {
- return;
- }
- if (type === "mouseover" && event.composedPath().includes(activeTooltipEl)) {
- this.clearHoverTimeout(activeTooltipEl);
- }
- else if (type === "mouseout" && !hoverTimeouts.has(activeTooltipEl)) {
- this.hoverTooltip(activeTooltipEl, false);
- }
- }
- hoverEvent(event, value) {
- const tooltip = this.queryTooltip(event.composedPath());
- this.activeTooltipHover(event);
- if (!tooltip) {
- return;
- }
- this.hoverTooltip(tooltip, value);
- }
- focusEvent(event, value) {
- const tooltip = this.queryTooltip(event.composedPath());
- if (!tooltip || tooltip === this.clickedTooltip) {
- this.clickedTooltip = null;
- return;
- }
- this.focusTooltip(tooltip, value);
- }
- }
- const tooltipCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:block;position:absolute;z-index:999;-webkit-transform:scale(0);transform:scale(0)}.calcite-popper-anim{position:relative;z-index:1;-webkit-transition:var(--calcite-popper-transition);transition:var(--calcite-popper-transition);visibility:hidden;-webkit-transition-property:visibility, opacity, -webkit-transform;transition-property:visibility, opacity, -webkit-transform;transition-property:transform, visibility, opacity;transition-property:transform, visibility, opacity, -webkit-transform;opacity:0;-webkit-box-shadow:0 0 16px 0 rgba(0, 0, 0, 0.16);box-shadow:0 0 16px 0 rgba(0, 0, 0, 0.16);border-radius:0.25rem}:host([data-popper-placement^=bottom]) .calcite-popper-anim{-webkit-transform:translateY(-5px);transform:translateY(-5px)}:host([data-popper-placement^=top]) .calcite-popper-anim{-webkit-transform:translateY(5px);transform:translateY(5px)}:host([data-popper-placement^=left]) .calcite-popper-anim{-webkit-transform:translateX(5px);transform:translateX(5px)}:host([data-popper-placement^=right]) .calcite-popper-anim{-webkit-transform:translateX(-5px);transform:translateX(-5px)}:host([data-popper-placement]) .calcite-popper-anim--active{opacity:1;visibility:visible;-webkit-transform:translate(0);transform:translate(0)}:host([data-popper-placement][data-popper-reference-hidden]){pointer-events:none;opacity:0}.arrow,.arrow::before{position:absolute;width:8px;height:8px;z-index:-1}.arrow::before{content:\"\";--tw-shadow:0 4px 8px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);--tw-shadow-colored:0 4px 8px -1px var(--tw-shadow-color), 0 2px 4px -1px var(--tw-shadow-color);-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);-webkit-transform:rotate(45deg);transform:rotate(45deg);background:var(--calcite-ui-foreground-1)}:host([data-popper-placement^=top]) .arrow{bottom:-4px}:host([data-popper-placement^=bottom]) .arrow{top:-4px}:host([data-popper-placement^=left]) .arrow{right:-4px}:host([data-popper-placement^=right]) .arrow{left:-4px}.container{position:relative;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:start;justify-content:flex-start;overflow:hidden;border-radius:0.25rem;background-color:var(--calcite-ui-foreground-1);padding-top:0.75rem;padding-bottom:0.75rem;padding-left:1rem;padding-right:1rem;font-size:var(--calcite-font-size--2);line-height:1.375;font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1);max-width:20rem;max-height:20rem}.calcite-popper-anim{border-radius:0.25rem;border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-3);background-color:var(--calcite-ui-foreground-1)}.arrow::before{outline:1px solid var(--calcite-ui-border-3)}";
- const manager = new TooltipManager$1();
- const Tooltip = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- /**
- * Offset the position of the tooltip away from the reference element.
- * @default 6
- */
- this.offsetDistance = defaultOffsetDistance;
- /**
- * Offset the position of the tooltip along the reference element.
- */
- this.offsetSkidding = 0;
- /**
- * Display and position the component.
- */
- this.open = false;
- /** Describes the type of positioning to use for the overlaid content. If your element is in a fixed container, use the 'fixed' value. */
- this.overlayPositioning = "absolute";
- /**
- * Determines where the component will be positioned relative to the referenceElement.
- * @see [PopperPlacement](https://github.com/Esri/calcite-components/blob/master/src/utils/popper.ts#L25)
- */
- this.placement = "auto";
- this.guid = `calcite-tooltip-${guid()}`;
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- this.setUpReferenceElement = () => {
- this.removeReferences();
- this.effectiveReferenceElement = this.getReferenceElement();
- const { el, referenceElement, effectiveReferenceElement } = this;
- if (referenceElement && !effectiveReferenceElement) {
- console.warn(`${el.tagName}: reference-element id "${referenceElement}" was not found.`, {
- el
- });
- }
- this.addReferences();
- this.createPopper();
- };
- this.getId = () => {
- return this.el.id || this.guid;
- };
- this.addReferences = () => {
- const { effectiveReferenceElement } = this;
- if (!effectiveReferenceElement) {
- return;
- }
- const id = this.getId();
- effectiveReferenceElement.setAttribute(ARIA_DESCRIBED_BY, id);
- manager.registerElement(effectiveReferenceElement, this.el);
- };
- this.removeReferences = () => {
- const { effectiveReferenceElement } = this;
- if (!effectiveReferenceElement) {
- return;
- }
- effectiveReferenceElement.removeAttribute(ARIA_DESCRIBED_BY);
- manager.unregisterElement(effectiveReferenceElement);
- };
- }
- offsetDistanceOffsetHandler() {
- this.reposition();
- }
- offsetSkiddingHandler() {
- this.reposition();
- }
- openHandler() {
- this.reposition();
- }
- placementHandler() {
- this.reposition();
- }
- referenceElementHandler() {
- this.setUpReferenceElement();
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- componentWillLoad() {
- this.setUpReferenceElement();
- }
- componentDidLoad() {
- this.reposition();
- }
- disconnectedCallback() {
- this.removeReferences();
- this.destroyPopper();
- }
- // --------------------------------------------------------------------------
- //
- // Public Methods
- //
- // --------------------------------------------------------------------------
- /** Updates the position of the component. */
- async reposition() {
- const { popper, el, placement } = this;
- const modifiers = this.getModifiers();
- popper
- ? await updatePopper({
- el,
- modifiers,
- placement,
- popper
- })
- : this.createPopper();
- }
- getReferenceElement() {
- const { referenceElement, el } = this;
- return ((typeof referenceElement === "string"
- ? queryElementRoots(el, { id: referenceElement })
- : referenceElement) || null);
- }
- getModifiers() {
- const { arrowEl, offsetDistance, offsetSkidding } = this;
- const arrowModifier = {
- name: "arrow",
- enabled: true,
- options: {
- element: arrowEl
- }
- };
- const offsetModifier = {
- name: "offset",
- enabled: true,
- options: {
- offset: [offsetSkidding, offsetDistance]
- }
- };
- const eventListenerModifier = {
- name: "eventListeners",
- enabled: this.open
- };
- return [arrowModifier, offsetModifier, eventListenerModifier];
- }
- createPopper() {
- this.destroyPopper();
- const { el, placement, effectiveReferenceElement: referenceEl, overlayPositioning } = this;
- const modifiers = this.getModifiers();
- this.popper = createPopper({
- el,
- modifiers,
- placement,
- overlayPositioning,
- referenceEl
- });
- }
- destroyPopper() {
- const { popper } = this;
- if (popper) {
- popper.destroy();
- }
- this.popper = null;
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- render() {
- const { effectiveReferenceElement, label, open } = this;
- const displayed = effectiveReferenceElement && open;
- const hidden = !displayed;
- return (h(Host, { "aria-hidden": toAriaBoolean(hidden), "aria-label": label, "calcite-hydrated-hidden": hidden, id: this.getId(), role: "tooltip" }, h("div", { class: {
- [CSS$D.animation]: true,
- [CSS$D.animationActive]: displayed
- } }, h("div", { class: CSS$2.arrow, ref: (arrowEl) => (this.arrowEl = arrowEl) }), h("div", { class: CSS$2.container }, h("slot", null)))));
- }
- get el() { return this; }
- static get watchers() { return {
- "offsetDistance": ["offsetDistanceOffsetHandler"],
- "offsetSkidding": ["offsetSkiddingHandler"],
- "open": ["openHandler"],
- "placement": ["placementHandler"],
- "referenceElement": ["referenceElementHandler"]
- }; }
- static get style() { return tooltipCss; }
- };
- const tooltipManagerCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;display:block}";
- const TooltipManager = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * CSS Selector to match reference elements for tooltips. Reference elements will be identified by this selector in order to open their associated tooltip.
- * @default `[data-calcite-tooltip-reference]`
- */
- this.selector = "[data-calcite-tooltip-reference]";
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- render() {
- return h("slot", null);
- }
- static get style() { return tooltipManagerCss; }
- };
- var TreeSelectionMode;
- (function (TreeSelectionMode) {
- TreeSelectionMode["Single"] = "single";
- TreeSelectionMode["Multi"] = "multi";
- TreeSelectionMode["Children"] = "children";
- TreeSelectionMode["MultiChildren"] = "multi-children";
- TreeSelectionMode["Ancestors"] = "ancestors";
- })(TreeSelectionMode || (TreeSelectionMode = {}));
- const treeCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:block;outline:2px solid transparent;outline-offset:2px}";
- const Tree = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteTreeSelect = createEvent(this, "calciteTreeSelect", 7);
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** Display indentation guide lines. */
- this.lines = false;
- /** Display input
- * @deprecated Use "ancestors" selection-mode for checkbox input.
- */
- this.inputEnabled = false;
- /** Specify the scale of the tree. */
- this.scale = "m";
- /** Customize how tree selection works.
- * @default "single"
- * @see [TreeSelectionMode](https://github.com/Esri/calcite-components/blob/master/src/components/tree/interfaces.ts#L5)
- */
- this.selectionMode = TreeSelectionMode.Single;
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentWillRender() {
- const parent = this.el.parentElement.closest("calcite-tree");
- this.lines = parent ? parent.lines : this.lines;
- this.scale = parent ? parent.scale : this.scale;
- this.selectionMode = parent ? parent.selectionMode : this.selectionMode;
- this.child = !!parent;
- }
- render() {
- return (h(Host, { "aria-multiselectable": this.child
- ? undefined
- : (this.selectionMode === TreeSelectionMode.Multi ||
- this.selectionMode === TreeSelectionMode.MultiChildren).toString(), role: !this.child ? "tree" : undefined, tabIndex: this.getRootTabIndex() }, h("slot", null)));
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- onFocus() {
- if (!this.child) {
- const focusTarget = this.el.querySelector("calcite-tree-item[selected]") ||
- this.el.querySelector("calcite-tree-item");
- focusElement(focusTarget);
- }
- }
- onFocusIn(event) {
- const focusedFromRootOrOutsideTree = event.relatedTarget === this.el || !this.el.contains(event.relatedTarget);
- if (focusedFromRootOrOutsideTree) {
- // gives user the ability to tab into external elements (modifying tabindex property will not work in firefox)
- this.el.removeAttribute("tabindex");
- }
- }
- onFocusOut(event) {
- const willFocusOutsideTree = !this.el.contains(event.relatedTarget);
- if (willFocusOutsideTree) {
- this.el.tabIndex = this.getRootTabIndex();
- }
- }
- onClick(e) {
- const target = e.target;
- const childItems = nodeListToArray(target.querySelectorAll("calcite-tree-item"));
- if (this.child) {
- return;
- }
- if (!this.child) {
- e.preventDefault();
- e.stopPropagation();
- }
- if (this.selectionMode === TreeSelectionMode.Ancestors && !this.child) {
- this.updateAncestorTree(e);
- return;
- }
- const shouldSelect = this.selectionMode !== null &&
- (!target.hasChildren ||
- (target.hasChildren &&
- (this.selectionMode === TreeSelectionMode.Children ||
- this.selectionMode === TreeSelectionMode.MultiChildren)));
- const shouldModifyToCurrentSelection = e.detail.modifyCurrentSelection &&
- (this.selectionMode === TreeSelectionMode.Multi ||
- this.selectionMode === TreeSelectionMode.MultiChildren);
- const shouldSelectChildren = this.selectionMode === TreeSelectionMode.MultiChildren ||
- this.selectionMode === TreeSelectionMode.Children;
- const shouldClearCurrentSelection = !shouldModifyToCurrentSelection &&
- (((this.selectionMode === TreeSelectionMode.Single ||
- this.selectionMode === TreeSelectionMode.Multi) &&
- childItems.length <= 0) ||
- this.selectionMode === TreeSelectionMode.Children ||
- this.selectionMode === TreeSelectionMode.MultiChildren);
- const shouldExpandTarget = this.selectionMode === TreeSelectionMode.Children ||
- this.selectionMode === TreeSelectionMode.MultiChildren;
- if (!this.child) {
- const targetItems = [];
- if (shouldSelect) {
- targetItems.push(target);
- }
- if (shouldSelectChildren) {
- childItems.forEach((treeItem) => {
- targetItems.push(treeItem);
- });
- }
- if (shouldClearCurrentSelection) {
- const selectedItems = nodeListToArray(this.el.querySelectorAll("calcite-tree-item[selected]"));
- selectedItems.forEach((treeItem) => {
- if (!targetItems.includes(treeItem)) {
- treeItem.selected = false;
- }
- });
- }
- if (shouldExpandTarget && !e.detail.forceToggle) {
- target.expanded = true;
- }
- if (shouldModifyToCurrentSelection) {
- window.getSelection().removeAllRanges();
- }
- if ((shouldModifyToCurrentSelection && target.selected) ||
- (shouldSelectChildren && e.detail.forceToggle)) {
- targetItems.forEach((treeItem) => {
- treeItem.selected = false;
- });
- }
- else {
- targetItems.forEach((treeItem) => {
- treeItem.selected = true;
- });
- }
- }
- this.calciteTreeSelect.emit({
- selected: nodeListToArray(this.el.querySelectorAll("calcite-tree-item")).filter((i) => i.selected)
- });
- }
- keyDownHandler(event) {
- var _a;
- const root = this.el.closest("calcite-tree:not([child])");
- const target = event.target;
- if (root === this.el && target.tagName === "CALCITE-TREE-ITEM" && this.el.contains(target)) {
- switch (event.key) {
- case "ArrowDown":
- const next = target.nextElementSibling;
- if (next && next.matches("calcite-tree-item")) {
- next.focus();
- event.preventDefault();
- }
- break;
- case "ArrowLeft":
- // When focus is on an open node, closes the node.
- if (target.hasChildren && target.expanded) {
- target.expanded = false;
- event.preventDefault();
- break;
- }
- // When focus is on a child node that is also either an end node or a closed node, moves focus to its parent node.
- const parentItem = target.parentElement.closest("calcite-tree-item");
- if (parentItem && (!target.hasChildren || target.expanded === false)) {
- parentItem.focus();
- event.preventDefault();
- break;
- }
- // When focus is on a root node that is also either an end node or a closed node, does nothing.
- break;
- case "ArrowRight":
- if (!target.hasChildren) {
- break;
- }
- if (target.expanded && document.activeElement === target) {
- // When focus is on an open node, moves focus to the first child node.
- (_a = target.querySelector("calcite-tree-item")) === null || _a === void 0 ? void 0 : _a.focus();
- event.preventDefault();
- }
- else {
- // When focus is on a closed node, opens the node; focus does not move.
- target.expanded = true;
- event.preventDefault();
- }
- // When focus is on an end node, does nothing.
- break;
- case "ArrowUp":
- const previous = target.previousElementSibling;
- if (previous && previous.matches("calcite-tree-item")) {
- previous.focus();
- event.preventDefault();
- }
- break;
- }
- }
- }
- updateAncestorTree(e) {
- const item = e.target;
- const children = item.querySelectorAll("calcite-tree-item");
- const ancestors = [];
- let parent = item.parentElement.closest("calcite-tree-item");
- while (parent) {
- ancestors.push(parent);
- parent = parent.parentElement.closest("calcite-tree-item");
- }
- item.selected = !item.selected;
- item.indeterminate = false;
- if (children === null || children === void 0 ? void 0 : children.length) {
- children.forEach((el) => {
- el.selected = item.selected;
- el.indeterminate = false;
- });
- }
- if (ancestors) {
- ancestors.forEach((ancestor) => {
- const descendants = nodeListToArray(ancestor.querySelectorAll("calcite-tree-item"));
- const activeDescendants = descendants.filter((el) => el.selected);
- if (activeDescendants.length === 0) {
- ancestor.selected = false;
- ancestor.indeterminate = false;
- return;
- }
- const indeterminate = activeDescendants.length < descendants.length;
- ancestor.indeterminate = indeterminate;
- ancestor.selected = !indeterminate;
- });
- }
- this.calciteTreeSelect.emit({
- selected: nodeListToArray(this.el.querySelectorAll("calcite-tree-item")).filter((i) => i.selected)
- });
- }
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- getRootTabIndex() {
- return !this.child ? 0 : -1;
- }
- get el() { return this; }
- static get style() { return treeCss; }
- };
- const CSS$1 = {
- checkboxLabel: "checkbox-label",
- checkbox: "checkbox",
- chevron: "chevron",
- nodeContainer: "node-container",
- childrenContainer: "children-container",
- bulletPointIcon: "bullet-point",
- checkmarkIcon: "checkmark"
- };
- const SLOTS$1 = {
- children: "children"
- };
- const ICONS$1 = {
- bulletPoint: "bullet-point",
- checkmark: "check",
- chevronRight: "chevron-right"
- };
- const treeItemCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:block;max-width:100%;cursor:pointer;color:var(--calcite-ui-text-3);outline:2px solid transparent;outline-offset:2px}:host([scale=s]){font-size:var(--calcite-font-size--2);line-height:1rem}:host([scale=s]) .node-container{--calcite-tree-padding-y:0.25rem}:host([scale=s]) .node-container .checkbox,:host([scale=s]) .node-container .chevron,:host([scale=s]) .node-container .checkmark,:host([scale=s]) .node-container .bullet-point{margin-inline:0.25rem}:host([scale=m]){font-size:var(--calcite-font-size--1);line-height:1rem}:host([scale=m]) .node-container{--calcite-tree-padding-y:0.5rem}:host([scale=m]) .node-container .checkbox,:host([scale=m]) .node-container .chevron,:host([scale=m]) .node-container .checkmark,:host([scale=m]) .node-container .bullet-point{margin-inline:0.5rem}:host([scale=l]){font-size:var(--calcite-font-size-0);line-height:1.25rem}:host([scale=l]) .node-container{--calcite-tree-padding-y:0.75rem}:host([scale=l]) .node-container .checkbox,:host([scale=l]) .node-container .chevron,:host([scale=l]) .node-container .checkmark,:host([scale=l]) .node-container .bullet-point{margin-inline:0.75rem}:host([lines]) .children-container:after{position:absolute;top:0px;width:1px;transition-property:color, background-color, border-color, fill, stroke, -webkit-text-decoration-color;-webkit-transition-property:color, background-color, border-color, fill, stroke, -webkit-text-decoration-color;transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-property:color, background-color, border-color, text-decoration-color, fill, stroke, -webkit-text-decoration-color;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s;height:96%;content:\"\";background-color:var(--calcite-ui-border-2);z-index:-1}:host(:not([lines])) .node-container:after{display:none}::slotted(*){min-width:0px;max-width:100%;overflow-wrap:break-word;color:inherit;text-decoration:none !important}::slotted(*):hover{text-decoration:none !important}::slotted(a){width:100%;-webkit-text-decoration-line:none;text-decoration-line:none}:host{outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out}:host(:focus){outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.checkbox{outline:2px solid transparent;outline-offset:2px;line-height:0}.checkbox-label{pointer-events:none;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.children-container{position:relative;height:0px;overflow:hidden;-webkit-margin-start:1.25rem;margin-inline-start:1.25rem;-webkit-transform:scaleY(0);transform:scaleY(0);opacity:0;-webkit-transition:var(--calcite-animation-timing) cubic-bezier(0.215, 0.44, 0.42, 0.88), opacity var(--calcite-animation-timing) cubic-bezier(0.215, 0.44, 0.42, 0.88), all var(--calcite-animation-timing) ease-in-out;transition:var(--calcite-animation-timing) cubic-bezier(0.215, 0.44, 0.42, 0.88), opacity var(--calcite-animation-timing) cubic-bezier(0.215, 0.44, 0.42, 0.88), all var(--calcite-animation-timing) ease-in-out;-webkit-transform-origin:top;transform-origin:top}:host([expanded])>.children-container{-webkit-transform:scaleY(1);transform:scaleY(1);opacity:1;height:auto}.node-container{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;padding:var(--calcite-tree-padding-y) 0}.node-container .checkmark,.node-container .bullet-point{opacity:0;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s;color:var(--calcite-ui-border-1)}.node-container:hover .checkmark,.node-container:hover .bullet-point,:host([selected]) .node-container:hover .checkmark,:host([selected]) .node-container:hover .bullet-point,:host(:focus) .node-container .checkmark,:host(:focus) .node-container .bullet-point{opacity:1}:host([selected])>.node-container,:host([selected])>.node-container:hover{font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1)}:host([selected])>.node-container .bullet-point,:host([selected])>.node-container .checkmark,:host([selected])>.node-container:hover .bullet-point,:host([selected])>.node-container:hover .checkmark{opacity:1;color:var(--calcite-ui-brand)}:host(:not([has-children])):host([scale=s])>.node-container[data-selection-mode=ancestors] .checkbox{-webkit-padding-start:1.25rem;padding-inline-start:1.25rem}:host(:not([has-children])):host([scale=m])>.node-container[data-selection-mode=ancestors] .checkbox{-webkit-padding-start:1.5rem;padding-inline-start:1.5rem}:host(:not([has-children])):host([scale=l])>.node-container[data-selection-mode=ancestors] .checkbox{-webkit-padding-start:1.75rem;padding-inline-start:1.75rem}:host([has-children])>.node-container[data-selection-mode=ancestors] .checkbox{-webkit-margin-start:0;margin-inline-start:0}:host([has-children])>.node-container .bullet-point,:host([has-children])>.node-container .checkmark{display:none}:host([has-children][expanded]:not([selected]))>.node-container ::slotted(*){font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1)}:host([has-children][selected])>.node-container[data-selection-mode=children],:host([has-children][selected])>.node-container[data-selection-mode=multi-children]{color:var(--calcite-ui-brand)}.chevron{position:relative;-ms-flex-item-align:center;align-self:center;color:var(--calcite-ui-text-3);-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s;-ms-flex:0 0 auto;flex:0 0 auto;-webkit-transform:rotate(0deg);transform:rotate(0deg)}.calcite--rtl .chevron{-webkit-transform:rotate(180deg);transform:rotate(180deg)}:host([expanded])>.node-container>.chevron{-webkit-transform:rotate(90deg);transform:rotate(90deg)}:host([selected]) .checkmark,:host([selected]) .bullet-point{color:var(--calcite-ui-brand)}";
- const TreeItem = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteTreeItemSelect = createEvent(this, "calciteTreeItemSelect", 7);
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** Selected state of the item. */
- this.selected = false;
- /** Expanded state of the item. */
- this.expanded = false;
- /** @internal Expanded state of the parent. */
- this.parentExpanded = false;
- /** @internal Level of depth of the item. */
- this.depth = -1;
- /** @internal Does this tree item have a tree inside it? */
- this.hasChildren = null;
- this.iconClickHandler = (event) => {
- event.stopPropagation();
- this.expanded = !this.expanded;
- };
- this.childrenClickHandler = (event) => event.stopPropagation();
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- this.updateParentIsExpanded = (el, expanded) => {
- const items = getSlotted(el, SLOTS$1.children, {
- all: true,
- selector: "calcite-tree-item"
- });
- items.forEach((item) => (item.parentExpanded = expanded));
- };
- this.updateAncestorTree = () => {
- if (this.selected && this.selectionMode === TreeSelectionMode.Ancestors) {
- const ancestors = [];
- let parent = this.parentTreeItem;
- while (parent) {
- ancestors.push(parent);
- parent = parent.parentElement.closest("calcite-tree-item");
- }
- ancestors.forEach((item) => (item.indeterminate = true));
- return;
- }
- };
- }
- expandedHandler(newValue) {
- this.updateParentIsExpanded(this.el, newValue);
- }
- getselectionMode() {
- this.isSelectionMultiLike =
- this.selectionMode === TreeSelectionMode.Multi ||
- this.selectionMode === TreeSelectionMode.MultiChildren;
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- this.parentTreeItem = this.el.parentElement.closest("calcite-tree-item");
- if (this.parentTreeItem) {
- const { expanded } = this.parentTreeItem;
- this.updateParentIsExpanded(this.parentTreeItem, expanded);
- }
- connectConditionalSlotComponent(this);
- }
- disconnectedCallback() {
- disconnectConditionalSlotComponent(this);
- }
- componentWillRender() {
- this.hasChildren = !!this.el.querySelector("calcite-tree");
- this.depth = 0;
- let parentTree = this.el.closest("calcite-tree");
- if (!parentTree) {
- return;
- }
- this.selectionMode = parentTree.selectionMode;
- this.scale = parentTree.scale || "m";
- this.lines = parentTree.lines;
- let nextParentTree;
- while (parentTree) {
- nextParentTree = parentTree.parentElement.closest("calcite-tree");
- if (nextParentTree === parentTree) {
- break;
- }
- else {
- parentTree = nextParentTree;
- this.depth = this.depth + 1;
- }
- }
- }
- componentDidLoad() {
- this.updateAncestorTree();
- }
- render() {
- const rtl = getElementDir(this.el) === "rtl";
- const showBulletPoint = this.selectionMode === TreeSelectionMode.Single ||
- this.selectionMode === TreeSelectionMode.Children;
- const showCheckmark = this.selectionMode === TreeSelectionMode.Multi ||
- this.selectionMode === TreeSelectionMode.MultiChildren;
- const chevron = this.hasChildren ? (h("calcite-icon", { class: {
- [CSS$1.chevron]: true,
- [CSS_UTILITY.rtl]: rtl
- }, "data-test-id": "icon", icon: ICONS$1.chevronRight, onClick: this.iconClickHandler, scale: "s" })) : null;
- const defaultSlotNode = h("slot", { key: "default-slot" });
- const checkbox = this.selectionMode === TreeSelectionMode.Ancestors ? (h("label", { class: CSS$1.checkboxLabel, key: "checkbox-label" }, h("calcite-checkbox", { checked: this.selected, class: CSS$1.checkbox, "data-test-id": "checkbox", indeterminate: this.hasChildren && this.indeterminate, scale: this.scale, tabIndex: -1 }), defaultSlotNode)) : null;
- const selectedIcon = showBulletPoint
- ? ICONS$1.bulletPoint
- : showCheckmark
- ? ICONS$1.checkmark
- : null;
- const bulletOrCheckIcon = selectedIcon ? (h("calcite-icon", { class: {
- [CSS$1.bulletPointIcon]: selectedIcon === ICONS$1.bulletPoint,
- [CSS$1.checkmarkIcon]: selectedIcon === ICONS$1.checkmark,
- [CSS_UTILITY.rtl]: rtl
- }, icon: selectedIcon, scale: "s" })) : null;
- const hidden = !(this.parentExpanded || this.depth === 1);
- return (h(Host, { "aria-expanded": this.hasChildren ? toAriaBoolean(this.expanded) : undefined, "aria-hidden": toAriaBoolean(hidden), "aria-selected": this.selected ? "true" : showCheckmark ? "false" : undefined, "calcite-hydrated-hidden": hidden, role: "treeitem", tabindex: this.parentExpanded || this.depth === 1 ? "0" : "-1" }, h("div", { class: {
- [CSS$1.nodeContainer]: true,
- [CSS_UTILITY.rtl]: rtl
- }, "data-selection-mode": this.selectionMode, ref: (el) => (this.defaultSlotWrapper = el) }, chevron, bulletOrCheckIcon, checkbox ? checkbox : defaultSlotNode), h("div", { class: {
- [CSS$1.childrenContainer]: true,
- [CSS_UTILITY.rtl]: rtl
- }, "data-test-id": "calcite-tree-children", onClick: this.childrenClickHandler, ref: (el) => (this.childrenSlotWrapper = el), role: this.hasChildren ? "group" : undefined }, h("slot", { name: SLOTS$1.children }))));
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- onClick(e) {
- // Solve for if the item is clicked somewhere outside the slotted anchor.
- // Anchor is triggered anywhere you click
- const [link] = filterDirectChildren(this.el, "a");
- if (link && e.composedPath()[0].tagName.toLowerCase() !== "a") {
- const target = link.target === "" ? "_self" : link.target;
- window.open(link.href, target);
- }
- this.calciteTreeItemSelect.emit({
- modifyCurrentSelection: this.selectionMode === TreeSelectionMode.Ancestors || this.isSelectionMultiLike,
- forceToggle: false
- });
- }
- keyDownHandler(e) {
- let root;
- switch (e.key) {
- case " ":
- this.calciteTreeItemSelect.emit({
- modifyCurrentSelection: this.isSelectionMultiLike,
- forceToggle: false
- });
- e.preventDefault();
- break;
- case "Enter":
- // activates a node, i.e., performs its default action. For parent nodes, one possible default action is to open or close the node. In single-select trees where selection does not follow focus (see note below), the default action is typically to select the focused node.
- const link = nodeListToArray(this.el.children).find((e) => e.matches("a"));
- if (link) {
- link.click();
- this.selected = true;
- }
- else {
- this.calciteTreeItemSelect.emit({
- modifyCurrentSelection: this.isSelectionMultiLike,
- forceToggle: false
- });
- }
- e.preventDefault();
- break;
- case "Home":
- root = this.el.closest("calcite-tree:not([child])");
- const firstNode = root.querySelector("calcite-tree-item");
- firstNode.focus();
- break;
- case "End":
- root = this.el.closest("calcite-tree:not([child])");
- let currentNode = root.children[root.children.length - 1]; // last child
- let currentTree = nodeListToArray(currentNode.children).find((e) => e.matches("calcite-tree"));
- while (currentTree) {
- currentNode = currentTree.children[root.children.length - 1];
- currentTree = nodeListToArray(currentNode.children).find((e) => e.matches("calcite-tree"));
- }
- currentNode.focus();
- break;
- }
- }
- get el() { return this; }
- static get watchers() { return {
- "expanded": ["expandedHandler"],
- "selectionMode": ["getselectionMode"]
- }; }
- static get style() { return treeItemCss; }
- };
- const CSS = {
- container: "container",
- handle: "handle"
- };
- var ICON_TYPES;
- (function (ICON_TYPES) {
- ICON_TYPES["grip"] = "grip";
- })(ICON_TYPES || (ICON_TYPES = {}));
- const valueListCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;-ms-flex-negative:0;flex-shrink:0;-ms-flex-positive:0;flex-grow:0;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:stretch;align-items:stretch;background-color:transparent;font-size:var(--calcite-font-size--1);color:var(--calcite-ui-text-2)}:host *{-webkit-box-sizing:border-box;box-sizing:border-box}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}calcite-value-list-item:last-of-type{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}:host([filter-enabled]) header{margin-bottom:0.25rem;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:end;justify-content:flex-end;background-color:var(--calcite-ui-foreground-1);--tw-shadow:0 1px 0 var(--calcite-ui-border-3);--tw-shadow-colored:0 1px 0 var(--tw-shadow-color);-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}:host([filter-enabled]) header.sticky-pos{position:-webkit-sticky;position:sticky;top:0px;z-index:10}calcite-filter{margin-bottom:1px}";
- const ValueList = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteListChange = createEvent(this, "calciteListChange", 7);
- this.calciteListOrderChange = createEvent(this, "calciteListOrderChange", 7);
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * When true, prevents user interaction. This state shows list items grayed out and with lower opacity.
- */
- this.disabled = false;
- /**
- * When true, list items are sortable via a draggable button.
- */
- this.dragEnabled = false;
- /**
- * When true, an input appears at the top of the list that can be used by end users to filter list items.
- */
- this.filterEnabled = false;
- /**
- * When true, content is waiting to be loaded. This state shows a busy indicator.
- */
- this.loading = false;
- /**
- * Similar to standard radio buttons and checkboxes.
- * When true, a user can select multiple list items at a time.
- * When false, only a single list item can be selected at a time,
- * and selecting a new list item will deselect any other selected list items.
- */
- this.multiple = false;
- /**
- * When true and single-selection is enabled, the selection changes when navigating list items via the keyboard.
- */
- this.selectionFollowsFocus = false;
- // --------------------------------------------------------------------------
- //
- // Private Properties
- //
- // --------------------------------------------------------------------------
- this.selectedValues = new Map();
- this.dataForFilter = [];
- this.lastSelectedItem = null;
- this.mutationObserver = createObserver("mutation", mutationObserverCallback.bind(this));
- this.setFilterEl = (el) => {
- this.filterEl = el;
- };
- this.deselectRemovedItems = deselectRemovedItems.bind(this);
- this.deselectSiblingItems = deselectSiblingItems.bind(this);
- this.selectSiblings = selectSiblings.bind(this);
- this.handleFilter = handleFilter.bind(this);
- this.getItemData = getItemData.bind(this);
- this.keyDownHandler = (event) => {
- const handleElement = event
- .composedPath()
- .find((item) => { var _a; return ((_a = item.dataset) === null || _a === void 0 ? void 0 : _a.jsHandle) !== undefined; });
- const item = event
- .composedPath()
- .find((item) => { var _a; return ((_a = item.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "calcite-value-list-item"; });
- // Only trigger keyboard sorting when the internal drag handle is focused and activated
- if (!handleElement || !item.handleActivated) {
- keyDownHandler.call(this, event);
- return;
- }
- const { items } = this;
- if ((event.key !== "ArrowUp" && event.key !== "ArrowDown") || items.length <= 1) {
- return;
- }
- event.preventDefault();
- const { el } = this;
- const nextIndex = moveItemIndex(this, item, event.key === "ArrowUp" ? "up" : "down");
- if (nextIndex === items.length - 1) {
- el.appendChild(item);
- }
- else {
- const itemAtNextIndex = el.children[nextIndex];
- const insertionReferenceItem = itemAtNextIndex === item.nextElementSibling
- ? itemAtNextIndex.nextElementSibling
- : itemAtNextIndex;
- el.insertBefore(item, insertionReferenceItem);
- }
- this.items = this.getItems();
- this.calciteListOrderChange.emit(this.items.map(({ value }) => value));
- requestAnimationFrame(() => handleElement.focus());
- item.handleActivated = true;
- };
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- initialize.call(this);
- initializeObserver.call(this);
- }
- componentDidLoad() {
- this.setUpDragAndDrop();
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- disconnectedCallback() {
- cleanUpObserver.call(this);
- this.cleanUpDragAndDrop();
- }
- calciteListFocusOutHandler(event) {
- calciteListFocusOutHandler.call(this, event);
- }
- calciteListItemRemoveHandler(event) {
- removeItem.call(this, event);
- }
- calciteListItemChangeHandler(event) {
- calciteListItemChangeHandler.call(this, event);
- }
- calciteListItemPropsChangeHandler(event) {
- event.stopPropagation();
- this.setUpFilter();
- }
- calciteListItemValueChangeHandler(event) {
- calciteListItemValueChangeHandler.call(this, event);
- }
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- getItems() {
- return Array.from(this.el.querySelectorAll("calcite-value-list-item"));
- }
- setUpItems() {
- setUpItems.call(this, "calcite-value-list-item");
- }
- setUpFilter() {
- if (this.filterEnabled) {
- this.dataForFilter = this.getItemData();
- }
- }
- setUpDragAndDrop() {
- this.cleanUpDragAndDrop();
- if (!this.dragEnabled) {
- return;
- }
- this.sortable = Sortable.create(this.el, {
- dataIdAttr: "id",
- handle: `.${CSS.handle}`,
- draggable: "calcite-value-list-item",
- group: this.group,
- onSort: () => {
- this.items = Array.from(this.el.querySelectorAll("calcite-value-list-item"));
- const values = this.items.map((item) => item.value);
- this.calciteListOrderChange.emit(values);
- }
- });
- }
- cleanUpDragAndDrop() {
- var _a;
- (_a = this.sortable) === null || _a === void 0 ? void 0 : _a.destroy();
- this.sortable = null;
- }
- // --------------------------------------------------------------------------
- //
- // Public Methods
- //
- // --------------------------------------------------------------------------
- /** Returns the currently selected items */
- async getSelectedItems() {
- return this.selectedValues;
- }
- /** Sets focus on the component. */
- async setFocus(focusId) {
- return setFocus.call(this, focusId);
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- getIconType() {
- let type = null;
- if (this.dragEnabled) {
- type = ICON_TYPES.grip;
- }
- return type;
- }
- render() {
- return h(List, { onKeyDown: this.keyDownHandler, props: this });
- }
- get el() { return this; }
- static get style() { return valueListCss; }
- };
- const ICONS = {
- drag: "drag"
- };
- const SLOTS = {
- actionsEnd: "actions-end",
- actionsStart: "actions-start"
- };
- const valueListItemCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{margin-bottom:1px;-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;background-color:var(--calcite-ui-foreground-1);font-size:var(--calcite-font-size--1);color:var(--calcite-ui-text-2);--tw-shadow:0 1px 0 var(--calcite-ui-border-3);--tw-shadow-colored:0 1px 0 var(--tw-shadow-color);-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);-webkit-transition:background-color var(--calcite-animation-timing), -webkit-box-shadow var(--calcite-animation-timing);transition:background-color var(--calcite-animation-timing), -webkit-box-shadow var(--calcite-animation-timing);transition:background-color var(--calcite-animation-timing), box-shadow var(--calcite-animation-timing);transition:background-color var(--calcite-animation-timing), box-shadow var(--calcite-animation-timing), -webkit-box-shadow var(--calcite-animation-timing)}:host *{-webkit-box-sizing:border-box;box-sizing:border-box}calcite-pick-list-item{position:relative;margin:0px;-ms-flex-positive:1;flex-grow:1;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}:host([active]),:host([selected]){--tw-shadow:0 0 0 1px var(--calcite-ui-brand);--tw-shadow-colored:0 0 0 1px var(--tw-shadow-color);-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.handle{display:-ms-flexbox;display:flex;cursor:move;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;border-style:none;background-color:transparent;padding-top:0px;padding-bottom:0px;padding-left:0.25rem;padding-right:0.25rem;color:var(--calcite-ui-text-1);color:var(--calcite-ui-border-1);outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out}.handle:hover{background-color:var(--calcite-ui-foreground-2);color:var(--calcite-ui-text-1)}.handle:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.handle--activated{background-color:var(--calcite-ui-foreground-3);color:var(--calcite-ui-text-1)}.handle calcite-icon{color:inherit}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}";
- const ValueListItem = class extends HTMLElement$1 {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteListItemRemove = createEvent(this, "calciteListItemRemove", 7);
- /**
- * When true, the list item cannot be clicked and is visually muted.
- */
- this.disabled = false;
- /**
- * @internal When false, the list item cannot be deselected by user interaction.
- */
- this.disableDeselect = false;
- /**
- * When true, prevents the content of the list item from user interaction.
- */
- this.nonInteractive = false;
- /**
- * @internal - Stores the activated state of the drag handle.
- */
- this.handleActivated = false;
- /**
- * Determines the icon SVG symbol that will be shown. Options are circle, square, grip or null.
- * @see [ICON_TYPES](https://github.com/Esri/calcite-components/blob/master/src/components/pick-list/resources.ts#L5)
- */
- this.icon = null;
- /**
- * When true, adds an action to remove the list item.
- */
- this.removable = false;
- /**
- * When true, preselects the list item. Toggles when an item is checked/unchecked.
- */
- this.selected = false;
- this.pickListItem = null;
- this.guid = `calcite-value-list-item-${guid()}`;
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- this.getPickListRef = (el) => (this.pickListItem = el);
- this.handleKeyDown = (event) => {
- if (event.key === " ") {
- this.handleActivated = !this.handleActivated;
- }
- };
- this.handleBlur = () => {
- this.handleActivated = false;
- };
- this.handleSelectChange = (event) => {
- this.selected = event.detail.selected;
- };
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- connectConditionalSlotComponent(this);
- }
- disconnectedCallback() {
- disconnectConditionalSlotComponent(this);
- }
- componentDidRender() {
- updateHostInteraction(this, this.el.closest("calcite-value-list") ? "managed" : false);
- }
- // --------------------------------------------------------------------------
- //
- // Public Methods
- //
- // --------------------------------------------------------------------------
- /**
- * Toggle the selection state. By default this won't trigger an event.
- * The first argument allows the value to be coerced, rather than swapping values.
- */
- async toggleSelected(coerce) {
- this.pickListItem.toggleSelected(coerce);
- }
- /** Set focus on the component. */
- async setFocus() {
- var _a;
- (_a = this.pickListItem) === null || _a === void 0 ? void 0 : _a.setFocus();
- }
- calciteListItemChangeHandler(event) {
- // adjust item payload from wrapped item before bubbling
- event.detail.item = this.el;
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- renderActionsEnd() {
- const { el } = this;
- const hasActionsEnd = getSlotted(el, SLOTS.actionsEnd);
- return hasActionsEnd ? (h("slot", { name: SLOTS.actionsEnd, slot: SLOTS$9.actionsEnd })) : null;
- }
- renderActionsStart() {
- const { el } = this;
- const hasActionsStart = getSlotted(el, SLOTS.actionsStart);
- return hasActionsStart ? (h("slot", { name: SLOTS.actionsStart, slot: SLOTS$9.actionsStart })) : null;
- }
- renderHandle() {
- const { icon } = this;
- if (icon === ICON_TYPES$1.grip) {
- return (h("span", { "aria-pressed": toAriaBoolean(this.handleActivated), class: {
- [CSS$h.handle]: true,
- [CSS$h.handleActivated]: this.handleActivated
- }, "data-js-handle": true, onBlur: this.handleBlur, onKeyDown: this.handleKeyDown, role: "button", tabindex: "0" }, h("calcite-icon", { icon: ICONS.drag, scale: "s" })));
- }
- }
- render() {
- return (h(Host, { id: this.el.id || this.guid }, this.renderHandle(), h("calcite-pick-list-item", { description: this.description, disableDeselect: this.disableDeselect, disabled: this.disabled, label: this.label, metadata: this.metadata, nonInteractive: this.nonInteractive, onCalciteListItemChange: this.handleSelectChange, ref: this.getPickListRef, removable: this.removable, selected: this.selected, value: this.value }, this.renderActionsStart(), this.renderActionsEnd())));
- }
- get el() { return this; }
- static get style() { return valueListItemCss; }
- };
- const CalciteAccordion = /*@__PURE__*/proxyCustomElement(Accordion, [1,"calcite-accordion",{"appearance":[513],"iconPosition":[513,"icon-position"],"iconType":[513,"icon-type"],"scale":[513],"selectionMode":[513,"selection-mode"]},[[0,"calciteAccordionItemKeyEvent","calciteAccordionItemKeyEvent"],[0,"calciteAccordionItemRegister","registerCalciteAccordionItem"],[0,"calciteAccordionItemSelect","updateActiveItemOnChange"]]]);
- const CalciteAccordionItem = /*@__PURE__*/proxyCustomElement(AccordionItem, [1,"calcite-accordion-item",{"active":[1540],"itemTitle":[1,"item-title"],"itemSubtitle":[1,"item-subtitle"],"icon":[513]},[[0,"keydown","keyDownHandler"],[16,"calciteAccordionChange","updateActiveItemOnChange"]]]);
- const CalciteAction = /*@__PURE__*/proxyCustomElement(Action, [1,"calcite-action",{"active":[516],"alignment":[513],"appearance":[513],"compact":[516],"disabled":[516],"icon":[1],"indicator":[516],"intlLoading":[1,"intl-loading"],"label":[1],"loading":[516],"scale":[513],"text":[1],"textEnabled":[516,"text-enabled"]}]);
- const CalciteActionBar = /*@__PURE__*/proxyCustomElement(ActionBar, [1,"calcite-action-bar",{"expandDisabled":[516,"expand-disabled"],"expanded":[1540],"intlExpand":[1,"intl-expand"],"intlCollapse":[1,"intl-collapse"],"overflowActionsDisabled":[4,"overflow-actions-disabled"],"position":[513],"scale":[513]}]);
- const CalciteActionGroup = /*@__PURE__*/proxyCustomElement(ActionGroup, [1,"calcite-action-group",{"expanded":[516],"layout":[513],"columns":[514],"intlMore":[1,"intl-more"],"menuOpen":[1540,"menu-open"],"scale":[513]}]);
- const CalciteActionMenu = /*@__PURE__*/proxyCustomElement(ActionMenu, [1,"calcite-action-menu",{"expanded":[516],"flipPlacements":[16],"label":[1],"open":[1540],"overlayPositioning":[1,"overlay-positioning"],"placement":[513],"scale":[513],"activeMenuItemIndex":[32]},[[8,"click","closeCalciteActionMenuOnClick"]]]);
- const CalciteActionPad = /*@__PURE__*/proxyCustomElement(ActionPad, [1,"calcite-action-pad",{"expandDisabled":[516,"expand-disabled"],"expanded":[1540],"layout":[513],"intlExpand":[1,"intl-expand"],"intlCollapse":[1,"intl-collapse"],"position":[513],"scale":[513]}]);
- const CalciteAlert = /*@__PURE__*/proxyCustomElement(Alert, [1,"calcite-alert",{"active":[1540],"autoDismiss":[4,"auto-dismiss"],"autoDismissDuration":[513,"auto-dismiss-duration"],"color":[513],"icon":[520],"intlClose":[1,"intl-close"],"label":[1],"placement":[1],"scale":[513],"queue":[32],"queueLength":[32],"queued":[32],"requestedIcon":[32]},[[8,"calciteAlertSync","alertSync"],[8,"calciteAlertRegister","alertRegister"]]]);
- const CalciteAvatar = /*@__PURE__*/proxyCustomElement(Avatar, [1,"calcite-avatar",{"scale":[513],"thumbnail":[1],"fullName":[1,"full-name"],"username":[1],"userId":[1,"user-id"],"error":[32]}]);
- const CalciteBlock = /*@__PURE__*/proxyCustomElement(Block, [1,"calcite-block",{"collapsible":[4],"disabled":[516],"dragHandle":[516,"drag-handle"],"heading":[1],"headingLevel":[2,"heading-level"],"intlCollapse":[1,"intl-collapse"],"intlExpand":[1,"intl-expand"],"intlLoading":[1,"intl-loading"],"intlOptions":[1,"intl-options"],"loading":[516],"open":[1540],"status":[513],"summary":[1]}]);
- const CalciteBlockSection = /*@__PURE__*/proxyCustomElement(BlockSection, [1,"calcite-block-section",{"intlCollapse":[1,"intl-collapse"],"intlExpand":[1,"intl-expand"],"open":[1540],"status":[513],"text":[1],"toggleDisplay":[513,"toggle-display"]}]);
- const CalciteButton = /*@__PURE__*/proxyCustomElement(Button, [1,"calcite-button",{"alignment":[513],"appearance":[513],"label":[1],"color":[513],"disabled":[516],"href":[513],"iconEnd":[513,"icon-end"],"iconFlipRtl":[513,"icon-flip-rtl"],"iconStart":[513,"icon-start"],"intlLoading":[1,"intl-loading"],"loading":[516],"name":[1],"rel":[1],"form":[1],"round":[516],"scale":[513],"splitChild":[520,"split-child"],"target":[1],"type":[1025],"width":[513],"hasContent":[32],"hasLoader":[32]}]);
- const CalciteCard = /*@__PURE__*/proxyCustomElement(Card, [1,"calcite-card",{"loading":[516],"selected":[1540],"selectable":[516],"intlLoading":[1,"intl-loading"],"intlSelect":[1,"intl-select"],"intlDeselect":[1,"intl-deselect"]}]);
- const CalciteCheckbox = /*@__PURE__*/proxyCustomElement(Checkbox, [1,"calcite-checkbox",{"checked":[1540],"disabled":[516],"guid":[1537],"hovered":[1540],"indeterminate":[1540],"label":[1],"name":[520],"required":[516],"scale":[513],"value":[8]}]);
- const CalciteChip = /*@__PURE__*/proxyCustomElement(Chip, [1,"calcite-chip",{"appearance":[513],"color":[513],"dismissible":[516],"dismissLabel":[1,"dismiss-label"],"icon":[513],"iconFlipRtl":[516,"icon-flip-rtl"],"scale":[513],"value":[8]}]);
- const CalciteColorPicker = /*@__PURE__*/proxyCustomElement(ColorPicker, [1,"calcite-color-picker",{"allowEmpty":[4,"allow-empty"],"appearance":[513],"color":[1040],"disabled":[516],"format":[1],"hideHex":[4,"hide-hex"],"hideChannels":[4,"hide-channels"],"hideSaved":[4,"hide-saved"],"intlB":[1,"intl-b"],"intlBlue":[1,"intl-blue"],"intlDeleteColor":[1,"intl-delete-color"],"intlG":[1,"intl-g"],"intlGreen":[1,"intl-green"],"intlH":[1,"intl-h"],"intlHsv":[1,"intl-hsv"],"intlHex":[1,"intl-hex"],"intlHue":[1,"intl-hue"],"intlNoColor":[1,"intl-no-color"],"intlR":[1,"intl-r"],"intlRed":[1,"intl-red"],"intlRgb":[1,"intl-rgb"],"intlS":[1,"intl-s"],"intlSaturation":[1,"intl-saturation"],"intlSaveColor":[1,"intl-save-color"],"intlSaved":[1,"intl-saved"],"intlV":[1,"intl-v"],"intlValue":[1,"intl-value"],"scale":[513],"storageId":[1,"storage-id"],"value":[1025],"colorFieldAndSliderInteractive":[32],"channelMode":[32],"channels":[32],"dimensions":[32],"savedColors":[32],"colorFieldScopeTop":[32],"colorFieldScopeLeft":[32],"scopeOrientation":[32],"hueScopeLeft":[32],"hueScopeTop":[32]},[[2,"keydown","handleChannelKeyUpOrDown"],[2,"keyup","handleChannelKeyUpOrDown"]]]);
- const CalciteColorPickerHexInput = /*@__PURE__*/proxyCustomElement(ColorPickerHexInput, [1,"calcite-color-picker-hex-input",{"allowEmpty":[4,"allow-empty"],"intlHex":[1,"intl-hex"],"intlNoColor":[1,"intl-no-color"],"scale":[513],"value":[1537],"internalColor":[32]},[[2,"keydown","onInputKeyDown"]]]);
- const CalciteColorPickerSwatch = /*@__PURE__*/proxyCustomElement(ColorPickerSwatch, [1,"calcite-color-picker-swatch",{"active":[516],"color":[1],"scale":[513]}]);
- const CalciteCombobox = /*@__PURE__*/proxyCustomElement(Combobox, [1,"calcite-combobox",{"active":[1540],"disabled":[516],"label":[1],"placeholder":[1],"maxItems":[2,"max-items"],"name":[513],"allowCustomValues":[4,"allow-custom-values"],"overlayPositioning":[1,"overlay-positioning"],"required":[4],"selectionMode":[513,"selection-mode"],"scale":[513],"value":[1025],"intlRemoveTag":[1,"intl-remove-tag"],"flipPlacements":[16],"items":[32],"groupItems":[32],"selectedItems":[32],"visibleItems":[32],"needsIcon":[32],"activeItemIndex":[32],"activeChipIndex":[32],"activeDescendant":[32],"text":[32]},[[4,"click","documentClickHandler"],[0,"calciteComboboxItemChange","calciteComboboxItemChangeHandler"]]]);
- const CalciteComboboxItem = /*@__PURE__*/proxyCustomElement(ComboboxItem, [1,"calcite-combobox-item",{"disabled":[516],"selected":[1540],"active":[4],"ancestors":[1040],"guid":[1],"icon":[1],"textLabel":[513,"text-label"],"value":[8],"constant":[516]}]);
- const CalciteComboboxItemGroup = /*@__PURE__*/proxyCustomElement(ComboboxItemGroup, [1,"calcite-combobox-item-group",{"ancestors":[1040],"label":[1]}]);
- const CalciteDatePicker = /*@__PURE__*/proxyCustomElement(DatePicker, [1,"calcite-date-picker",{"activeRange":[1,"active-range"],"value":[1025],"headingLevel":[2,"heading-level"],"valueAsDate":[1040],"startAsDate":[1040],"endAsDate":[1040],"minAsDate":[1040],"maxAsDate":[1040],"min":[1025],"max":[1025],"intlPrevMonth":[1,"intl-prev-month"],"intlNextMonth":[1,"intl-next-month"],"intlYear":[1,"intl-year"],"locale":[1],"scale":[513],"range":[516],"start":[1025],"end":[1025],"proximitySelectionDisabled":[4,"proximity-selection-disabled"],"activeDate":[32],"activeStartDate":[32],"activeEndDate":[32],"localeData":[32],"hoverRange":[32]}]);
- const CalciteDatePickerDay = /*@__PURE__*/proxyCustomElement(DatePickerDay, [1,"calcite-date-picker-day",{"day":[2],"disabled":[516],"currentMonth":[516,"current-month"],"selected":[516],"highlighted":[516],"range":[516],"startOfRange":[516,"start-of-range"],"endOfRange":[516,"end-of-range"],"rangeHover":[516,"range-hover"],"active":[516],"localeData":[16],"scale":[513],"value":[16]},[[1,"mouseover","mouseoverHandler"]]]);
- const CalciteDatePickerMonth = /*@__PURE__*/proxyCustomElement(DatePickerMonth, [1,"calcite-date-picker-month",{"selectedDate":[16],"activeDate":[16],"startDate":[16],"endDate":[16],"min":[16],"max":[16],"scale":[513],"localeData":[16],"hoverRange":[16]},[[1,"mouseout","mouseoutHandler"]]]);
- const CalciteDatePickerMonthHeader = /*@__PURE__*/proxyCustomElement(DatePickerMonthHeader, [1,"calcite-date-picker-month-header",{"selectedDate":[16],"activeDate":[16],"headingLevel":[2,"heading-level"],"min":[16],"max":[16],"locale":[1],"intlPrevMonth":[1,"intl-prev-month"],"intlNextMonth":[1,"intl-next-month"],"intlYear":[1,"intl-year"],"scale":[513],"localeData":[16],"nextMonthDate":[32],"prevMonthDate":[32]}]);
- const CalciteDropdown = /*@__PURE__*/proxyCustomElement(Dropdown, [1,"calcite-dropdown",{"active":[1540],"disableCloseOnSelect":[516,"disable-close-on-select"],"disabled":[516],"flipPlacements":[16],"maxItems":[2,"max-items"],"overlayPositioning":[1,"overlay-positioning"],"placement":[513],"scale":[513],"selectedItems":[1040],"type":[513],"width":[513]},[[8,"click","closeCalciteDropdownOnClick"],[0,"calciteDropdownCloseRequest","closeCalciteDropdownOnEvent"],[8,"calciteDropdownOpen","closeCalciteDropdownOnOpenEvent"],[1,"mouseenter","mouseEnterHandler"],[1,"mouseleave","mouseLeaveHandler"],[0,"calciteDropdownItemKeyEvent","calciteDropdownItemKeyEvent"],[0,"calciteDropdownItemSelect","handleItemSelect"]]]);
- const CalciteDropdownGroup = /*@__PURE__*/proxyCustomElement(DropdownGroup, [1,"calcite-dropdown-group",{"groupTitle":[513,"group-title"],"selectionMode":[513,"selection-mode"],"scale":[513]},[[0,"calciteDropdownItemSelect","updateActiveItemOnChange"]]]);
- const CalciteDropdownItem = /*@__PURE__*/proxyCustomElement(DropdownItem, [1,"calcite-dropdown-item",{"active":[1540],"iconFlipRtl":[513,"icon-flip-rtl"],"iconStart":[513,"icon-start"],"iconEnd":[513,"icon-end"],"href":[513],"label":[1],"rel":[1],"target":[1]},[[0,"click","onClick"],[0,"keydown","keyDownHandler"],[16,"calciteDropdownItemChange","updateActiveItemOnChange"]]]);
- const CalciteFab = /*@__PURE__*/proxyCustomElement(Fab, [1,"calcite-fab",{"appearance":[513],"color":[513],"disabled":[516],"icon":[1],"label":[1],"loading":[516],"scale":[513],"text":[1],"textEnabled":[516,"text-enabled"]}]);
- const CalciteFilter = /*@__PURE__*/proxyCustomElement(Filter, [1,"calcite-filter",{"items":[1040],"disabled":[516],"filteredItems":[1040],"intlClear":[1,"intl-clear"],"intlLabel":[1,"intl-label"],"placeholder":[1],"scale":[513],"value":[1025]}]);
- const CalciteFlow = /*@__PURE__*/proxyCustomElement(Flow, [1,"calcite-flow",{"panelCount":[32],"flowDirection":[32],"panels":[32]},[[0,"calcitePanelBackClick","handleCalcitePanelBackClick"]]]);
- const CalciteGraph = /*@__PURE__*/proxyCustomElement(Graph, [1,"calcite-graph",{"data":[16],"colorStops":[16],"highlightMin":[2,"highlight-min"],"highlightMax":[2,"highlight-max"],"min":[2],"max":[2]}]);
- const CalciteHandle = /*@__PURE__*/proxyCustomElement(Handle, [1,"calcite-handle",{"activated":[1540],"textTitle":[513,"text-title"]}]);
- const CalciteIcon = /*@__PURE__*/proxyCustomElement(Icon, [1,"calcite-icon",{"icon":[513],"flipRtl":[516,"flip-rtl"],"scale":[513],"textLabel":[1,"text-label"],"pathData":[32],"visible":[32]}]);
- const CalciteInlineEditable = /*@__PURE__*/proxyCustomElement(InlineEditable, [1,"calcite-inline-editable",{"disabled":[516],"editingEnabled":[1540,"editing-enabled"],"loading":[1540],"controls":[516],"intlEnableEditing":[513,"intl-enable-editing"],"intlCancelEditing":[513,"intl-cancel-editing"],"intlConfirmChanges":[513,"intl-confirm-changes"],"scale":[1537],"afterConfirm":[16]},[[0,"calciteInputBlur","blurHandler"]]]);
- const CalciteInput = /*@__PURE__*/proxyCustomElement(Input, [1,"calcite-input",{"alignment":[513],"autofocus":[4],"clearable":[516],"disabled":[516],"groupSeparator":[4,"group-separator"],"hidden":[4],"icon":[520],"intlClear":[1,"intl-clear"],"intlLoading":[1,"intl-loading"],"iconFlipRtl":[516,"icon-flip-rtl"],"label":[1],"loading":[516],"locale":[1],"localeFormat":[4,"locale-format"],"max":[514],"min":[514],"maxlength":[514],"maxLength":[514,"max-length"],"minLength":[514,"min-length"],"name":[513],"numberButtonType":[513,"number-button-type"],"placeholder":[1],"prefixText":[1,"prefix-text"],"readOnly":[4,"read-only"],"required":[4],"scale":[1537],"status":[1537],"step":[520],"suffixText":[1,"suffix-text"],"editingEnabled":[1540,"editing-enabled"],"type":[513],"value":[1025],"localizedValue":[32]}]);
- const CalciteInputDatePicker = /*@__PURE__*/proxyCustomElement(InputDatePicker, [1,"calcite-input-date-picker",{"disabled":[516],"value":[1025],"flipPlacements":[16],"headingLevel":[2,"heading-level"],"valueAsDate":[1040],"startAsDate":[1040],"endAsDate":[1040],"minAsDate":[1040],"maxAsDate":[1040],"min":[1025],"max":[1025],"active":[1540],"name":[1],"intlPrevMonth":[1,"intl-prev-month"],"intlNextMonth":[1,"intl-next-month"],"intlYear":[1,"intl-year"],"locale":[1],"scale":[513],"placement":[513],"range":[516],"required":[516],"start":[1025],"end":[1025],"overlayPositioning":[1,"overlay-positioning"],"proximitySelectionDisabled":[4,"proximity-selection-disabled"],"layout":[513],"focusedInput":[32],"localeData":[32]},[[0,"calciteDatePickerChange","handleDateOrRangeChange"],[0,"calciteDatePickerRangeChange","handleDateOrRangeChange"],[0,"calciteDaySelect","calciteDaySelectHandler"]]]);
- const CalciteInputMessage = /*@__PURE__*/proxyCustomElement(InputMessage, [1,"calcite-input-message",{"active":[516],"icon":[520],"scale":[1537],"status":[1537],"type":[513]}]);
- const CalciteInputTimePicker = /*@__PURE__*/proxyCustomElement(InputTimePicker, [1,"calcite-input-time-picker",{"active":[1540],"disabled":[516],"intlHour":[1,"intl-hour"],"intlHourDown":[1,"intl-hour-down"],"intlHourUp":[1,"intl-hour-up"],"intlMeridiem":[1,"intl-meridiem"],"intlMeridiemDown":[1,"intl-meridiem-down"],"intlMeridiemUp":[1,"intl-meridiem-up"],"intlMinute":[1,"intl-minute"],"intlMinuteDown":[1,"intl-minute-down"],"intlMinuteUp":[1,"intl-minute-up"],"intlSecond":[1,"intl-second"],"intlSecondDown":[1,"intl-second-down"],"intlSecondUp":[1,"intl-second-up"],"locale":[1025,"lang"],"name":[1],"required":[516],"scale":[513],"placement":[513],"step":[2],"value":[1025],"localizedValue":[32]},[[0,"click","clickHandler"],[0,"keyup","keyUpHandler"],[0,"calciteTimePickerBlur","timePickerBlurHandler"],[0,"calciteTimePickerFocus","timePickerFocusHandler"]]]);
- const CalciteLabel = /*@__PURE__*/proxyCustomElement(Label, [1,"calcite-label",{"alignment":[513],"status":[513],"for":[513],"scale":[513],"layout":[513],"disableSpacing":[4,"disable-spacing"],"disabled":[516]}]);
- const CalciteLink = /*@__PURE__*/proxyCustomElement(Link, [1,"calcite-link",{"disabled":[516],"download":[520],"href":[513],"iconEnd":[513,"icon-end"],"iconFlipRtl":[513,"icon-flip-rtl"],"iconStart":[513,"icon-start"],"rel":[1],"target":[1]}]);
- const CalciteList = /*@__PURE__*/proxyCustomElement(List$1, [1,"calcite-list",{"disabled":[516],"headingLevel":[2,"heading-level"]}]);
- const CalciteListItem = /*@__PURE__*/proxyCustomElement(ListItem, [1,"calcite-list-item",{"nonInteractive":[516,"non-interactive"],"description":[1],"disabled":[516],"label":[1]}]);
- const CalciteListItemGroup = /*@__PURE__*/proxyCustomElement(ListItemGroup, [1,"calcite-list-item-group",{"heading":[513],"headingLevel":[2,"heading-level"]}]);
- const CalciteLoader = /*@__PURE__*/proxyCustomElement(Loader, [1,"calcite-loader",{"active":[516],"inline":[516],"label":[1],"scale":[513],"type":[513],"value":[2],"text":[1],"noPadding":[4,"no-padding"]}]);
- const CalciteModal = /*@__PURE__*/proxyCustomElement(Modal, [1,"calcite-modal",{"active":[1540],"beforeClose":[16],"disableCloseButton":[4,"disable-close-button"],"disableOutsideClose":[4,"disable-outside-close"],"intlClose":[1,"intl-close"],"docked":[516],"firstFocus":[16],"disableEscape":[4,"disable-escape"],"scale":[513],"width":[520],"fullscreen":[516],"color":[513],"backgroundColor":[513,"background-color"],"noPadding":[4,"no-padding"],"hasFooter":[32]},[[8,"keyup","handleEscape"]]]);
- const CalciteNotice = /*@__PURE__*/proxyCustomElement(Notice, [1,"calcite-notice",{"active":[1540],"color":[513],"dismissible":[516],"icon":[520],"intlClose":[1,"intl-close"],"scale":[513],"width":[513]}]);
- const CalciteOption = /*@__PURE__*/proxyCustomElement(Option, [1,"calcite-option",{"disabled":[516],"label":[1025],"selected":[516],"value":[1032]}]);
- const CalciteOptionGroup = /*@__PURE__*/proxyCustomElement(OptionGroup, [1,"calcite-option-group",{"disabled":[516],"label":[1]}]);
- const CalcitePagination = /*@__PURE__*/proxyCustomElement(Pagination, [1,"calcite-pagination",{"num":[2],"start":[1026],"total":[2],"textLabelNext":[1,"text-label-next"],"textLabelPrevious":[1,"text-label-previous"],"scale":[513]}]);
- const CalcitePanel = /*@__PURE__*/proxyCustomElement(Panel, [1,"calcite-panel",{"dismissed":[1540],"beforeBack":[16],"disabled":[516],"dismissible":[516],"headingLevel":[2,"heading-level"],"showBackButton":[516,"show-back-button"],"intlBack":[1,"intl-back"],"heightScale":[513,"height-scale"],"widthScale":[513,"width-scale"],"loading":[516],"intlClose":[1,"intl-close"],"intlOptions":[1,"intl-options"],"heading":[1],"summary":[1],"menuOpen":[516,"menu-open"]}]);
- const CalcitePickList = /*@__PURE__*/proxyCustomElement(PickList, [1,"calcite-pick-list",{"disabled":[516],"filterEnabled":[516,"filter-enabled"],"filterPlaceholder":[513,"filter-placeholder"],"headingLevel":[2,"heading-level"],"loading":[516],"multiple":[516],"selectionFollowsFocus":[4,"selection-follows-focus"],"selectedValues":[32],"dataForFilter":[32]},[[0,"calciteListItemRemove","calciteListItemRemoveHandler"],[0,"calciteListItemChange","calciteListItemChangeHandler"],[0,"calciteListItemPropsChange","calciteListItemPropsChangeHandler"],[0,"calciteListItemValueChange","calciteListItemValueChangeHandler"],[0,"focusout","calciteListFocusOutHandler"]]]);
- const CalcitePickListGroup = /*@__PURE__*/proxyCustomElement(PickListGroup, [1,"calcite-pick-list-group",{"groupTitle":[513,"group-title"],"headingLevel":[2,"heading-level"]}]);
- const CalcitePickListItem = /*@__PURE__*/proxyCustomElement(PickListItem, [1,"calcite-pick-list-item",{"description":[513],"disabled":[516],"disableDeselect":[4,"disable-deselect"],"nonInteractive":[516,"non-interactive"],"icon":[513],"label":[513],"metadata":[16],"removable":[516],"selected":[1540],"intlRemove":[513,"intl-remove"],"value":[8]}]);
- const CalcitePopover = /*@__PURE__*/proxyCustomElement(Popover, [1,"calcite-popover",{"autoClose":[516,"auto-close"],"closeButton":[516,"close-button"],"dismissible":[516],"disableFlip":[516,"disable-flip"],"disablePointer":[516,"disable-pointer"],"flipPlacements":[16],"heading":[1],"headingLevel":[2,"heading-level"],"label":[1],"offsetDistance":[514,"offset-distance"],"offsetSkidding":[514,"offset-skidding"],"open":[1540],"overlayPositioning":[1,"overlay-positioning"],"placement":[513],"referenceElement":[1,"reference-element"],"intlClose":[1,"intl-close"],"effectiveReferenceElement":[32]}]);
- const CalcitePopoverManager = /*@__PURE__*/proxyCustomElement(PopoverManager, [1,"calcite-popover-manager",{"selector":[1],"autoClose":[516,"auto-close"]}]);
- const CalciteProgress = /*@__PURE__*/proxyCustomElement(Progress, [1,"calcite-progress",{"type":[1],"value":[2],"label":[1],"text":[1],"reversed":[4]}]);
- const CalciteRadioButton = /*@__PURE__*/proxyCustomElement(RadioButton, [1,"calcite-radio-button",{"checked":[1540],"disabled":[516],"focused":[1540],"guid":[1537],"hidden":[516],"hovered":[1540],"label":[1],"name":[513],"required":[516],"scale":[513],"value":[1032]},[[1,"mouseenter","mouseenter"],[1,"mouseleave","mouseleave"]]]);
- const CalciteRadioButtonGroup = /*@__PURE__*/proxyCustomElement(RadioButtonGroup, [1,"calcite-radio-button-group",{"disabled":[516],"hidden":[516],"layout":[513],"name":[513],"required":[516],"scale":[513]},[[0,"calciteRadioButtonChange","radioButtonChangeHandler"]]]);
- const CalciteRadioGroup = /*@__PURE__*/proxyCustomElement(RadioGroup, [1,"calcite-radio-group",{"appearance":[513],"disabled":[516],"required":[516],"layout":[513],"name":[1],"scale":[513],"value":[1025],"selectedItem":[1040],"width":[513]},[[0,"calciteRadioGroupItemChange","handleSelected"],[0,"keydown","handleKeyDown"]]]);
- const CalciteRadioGroupItem = /*@__PURE__*/proxyCustomElement(RadioGroupItem, [1,"calcite-radio-group-item",{"checked":[1540],"icon":[513],"iconFlipRtl":[516,"icon-flip-rtl"],"iconPosition":[513,"icon-position"],"value":[1032]}]);
- const CalciteRating = /*@__PURE__*/proxyCustomElement(Rating, [1,"calcite-rating",{"scale":[513],"value":[1538],"readOnly":[516,"read-only"],"disabled":[516],"showChip":[516,"show-chip"],"count":[514],"average":[514],"name":[513],"intlRating":[1,"intl-rating"],"intlStars":[1,"intl-stars"],"required":[516],"hoverValue":[32],"focusValue":[32],"hasFocus":[32]},[[0,"blur","blurHandler"]]]);
- const CalciteScrim = /*@__PURE__*/proxyCustomElement(Scrim, [1,"calcite-scrim",{"intlLoading":[1,"intl-loading"],"loading":[516]}]);
- const CalciteSelect = /*@__PURE__*/proxyCustomElement(Select, [1,"calcite-select",{"disabled":[516],"label":[1],"name":[1],"required":[516],"scale":[513],"value":[1025],"selectedOption":[1040],"width":[513]},[[0,"calciteOptionChange","handleOptionOrGroupChange"],[0,"calciteOptionGroupChange","handleOptionOrGroupChange"]]]);
- const CalciteShell = /*@__PURE__*/proxyCustomElement(Shell, [1,"calcite-shell",{"contentBehind":[516,"content-behind"]}]);
- const CalciteShellCenterRow = /*@__PURE__*/proxyCustomElement(ShellCenterRow, [1,"calcite-shell-center-row",{"detached":[516],"heightScale":[513,"height-scale"],"position":[513]}]);
- const CalciteShellPanel = /*@__PURE__*/proxyCustomElement(ShellPanel, [1,"calcite-shell-panel",{"collapsed":[516],"detached":[516],"detachedHeightScale":[513,"detached-height-scale"],"widthScale":[513,"width-scale"],"position":[513],"intlResize":[1,"intl-resize"],"resizable":[516],"contentWidth":[32]}]);
- const CalciteSlider = /*@__PURE__*/proxyCustomElement(Slider, [1,"calcite-slider",{"disabled":[516],"hasHistogram":[1540,"has-histogram"],"histogram":[16],"histogramStops":[16],"labelHandles":[516,"label-handles"],"labelTicks":[516,"label-ticks"],"max":[514],"maxLabel":[1,"max-label"],"maxValue":[1026,"max-value"],"min":[514],"minLabel":[1,"min-label"],"minValue":[1026,"min-value"],"mirrored":[516],"name":[513],"pageStep":[2,"page-step"],"precise":[4],"required":[516],"snap":[4],"step":[2],"ticks":[2],"value":[1538],"scale":[1],"activeProp":[32],"minMaxValueRange":[32],"minValueDragRange":[32],"maxValueDragRange":[32],"tickValues":[32]},[[0,"keydown","keyDownHandler"],[0,"click","clickHandler"],[1,"pointerdown","pointerDownHandler"]]]);
- const CalciteSortableList = /*@__PURE__*/proxyCustomElement(SortableList, [1,"calcite-sortable-list",{"dragSelector":[1,"drag-selector"],"group":[1],"handleSelector":[1,"handle-selector"],"layout":[1],"disabled":[516],"loading":[516],"handleActivated":[32]},[[0,"calciteHandleNudge","calciteHandleNudgeHandler"]]]);
- const CalciteSplitButton = /*@__PURE__*/proxyCustomElement(SplitButton, [1,"calcite-split-button",{"appearance":[513],"color":[513],"disabled":[516],"active":[1540],"dropdownIconType":[513,"dropdown-icon-type"],"dropdownLabel":[513,"dropdown-label"],"loading":[516],"overlayPositioning":[1,"overlay-positioning"],"primaryIconEnd":[513,"primary-icon-end"],"primaryIconFlipRtl":[513,"primary-icon-flip-rtl"],"primaryIconStart":[513,"primary-icon-start"],"primaryLabel":[513,"primary-label"],"primaryText":[513,"primary-text"],"scale":[513],"width":[513]}]);
- const CalciteStepper = /*@__PURE__*/proxyCustomElement(Stepper, [1,"calcite-stepper",{"icon":[516],"layout":[513],"numbered":[516],"scale":[513],"requestedContent":[1040]},[[0,"calciteStepperItemKeyEvent","calciteStepperItemKeyEvent"],[0,"calciteStepperItemRegister","registerItem"],[0,"calciteStepperItemSelect","updateItem"]]]);
- const CalciteStepperItem = /*@__PURE__*/proxyCustomElement(StepperItem, [1,"calcite-stepper-item",{"active":[1540],"complete":[516],"error":[4],"disabled":[516],"itemTitle":[1,"item-title"],"itemSubtitle":[1,"item-subtitle"],"layout":[1537],"icon":[1028],"numbered":[1028],"scale":[1537]},[[16,"calciteStepperItemChange","updateActiveItemOnChange"]]]);
- const CalciteSwitch = /*@__PURE__*/proxyCustomElement(Switch, [1,"calcite-switch",{"disabled":[516],"label":[1],"name":[513],"scale":[513],"switched":[1028],"checked":[1540],"value":[8]}]);
- const CalciteTab = /*@__PURE__*/proxyCustomElement(Tab, [1,"calcite-tab",{"tab":[513],"active":[1540],"scale":[1537],"labeledBy":[32]},[[16,"calciteInternalTabChange","internalTabChangeHandler"]]]);
- const CalciteTabNav = /*@__PURE__*/proxyCustomElement(TabNav, [1,"calcite-tab-nav",{"storageId":[1,"storage-id"],"syncId":[1,"sync-id"],"scale":[1537],"layout":[1537],"position":[1537],"bordered":[1540],"indicatorOffset":[1026,"indicator-offset"],"indicatorWidth":[1026,"indicator-width"],"selectedTab":[32],"selectedTabEl":[32]},[[0,"calciteTabsFocusPrevious","focusPreviousTabHandler"],[0,"calciteTabsFocusNext","focusNextTabHandler"],[0,"calciteInternalTabsActivate","internalActivateTabHandler"],[0,"calciteTabsActivate","activateTabHandler"],[0,"calciteTabTitleRegister","updateTabTitles"],[16,"calciteInternalTabChange","globalInternalTabChangeHandler"]]]);
- const CalciteTabTitle = /*@__PURE__*/proxyCustomElement(TabTitle, [1,"calcite-tab-title",{"active":[1540],"disabled":[516],"iconEnd":[513,"icon-end"],"iconFlipRtl":[513,"icon-flip-rtl"],"iconStart":[513,"icon-start"],"layout":[1537],"position":[1537],"scale":[1537],"bordered":[1540],"tab":[513],"controls":[32],"hasText":[32]},[[16,"calciteInternalTabChange","internalTabChangeHandler"],[0,"click","onClick"],[0,"keydown","keyDownHandler"]]]);
- const CalciteTabs = /*@__PURE__*/proxyCustomElement(Tabs, [1,"calcite-tabs",{"layout":[513],"position":[513],"scale":[513],"bordered":[1540],"titles":[32],"tabs":[32]},[[0,"calciteTabTitleRegister","calciteTabTitleRegister"],[16,"calciteTabTitleUnregister","calciteTabTitleUnregister"],[0,"calciteTabRegister","calciteTabRegister"],[16,"calciteTabUnregister","calciteTabUnregister"]]]);
- const CalciteTile = /*@__PURE__*/proxyCustomElement(Tile, [1,"calcite-tile",{"active":[516],"description":[513],"disabled":[516],"embed":[516],"focused":[516],"heading":[513],"hidden":[516],"href":[513],"icon":[513]}]);
- const CalciteTileSelect = /*@__PURE__*/proxyCustomElement(TileSelect, [1,"calcite-tile-select",{"checked":[1540],"description":[513],"disabled":[516],"heading":[513],"hidden":[516],"icon":[513],"name":[520],"inputEnabled":[516,"input-enabled"],"inputAlignment":[513,"input-alignment"],"type":[513],"value":[8],"width":[513],"focused":[32]},[[0,"calciteCheckboxChange","checkboxChangeHandler"],[0,"calciteInternalCheckboxFocus","checkboxFocusBlurHandler"],[0,"calciteInternalCheckboxBlur","checkboxFocusBlurHandler"],[0,"calciteRadioButtonChange","radioButtonChangeHandler"],[0,"calciteInternalRadioButtonCheckedChange","radioButtonCheckedChangeHandler"],[0,"calciteInternalRadioButtonFocus","radioButtonFocusBlurHandler"],[0,"calciteInternalRadioButtonBlur","radioButtonFocusBlurHandler"],[0,"click","click"],[1,"mouseenter","mouseenter"],[1,"mouseleave","mouseleave"]]]);
- const CalciteTileSelectGroup = /*@__PURE__*/proxyCustomElement(TileSelectGroup, [1,"calcite-tile-select-group",{"disabled":[516],"layout":[513]}]);
- const CalciteTimePicker = /*@__PURE__*/proxyCustomElement(TimePicker, [1,"calcite-time-picker",{"intlHour":[1,"intl-hour"],"intlHourDown":[1,"intl-hour-down"],"intlHourUp":[1,"intl-hour-up"],"intlMeridiem":[1,"intl-meridiem"],"intlMeridiemDown":[1,"intl-meridiem-down"],"intlMeridiemUp":[1,"intl-meridiem-up"],"intlMinute":[1,"intl-minute"],"intlMinuteDown":[1,"intl-minute-down"],"intlMinuteUp":[1,"intl-minute-up"],"intlSecond":[1,"intl-second"],"intlSecondDown":[1,"intl-second-down"],"intlSecondUp":[1,"intl-second-up"],"locale":[1025,"lang"],"scale":[1],"step":[2],"value":[1025],"hour":[32],"hourCycle":[32],"localizedHour":[32],"localizedHourSuffix":[32],"localizedMeridiem":[32],"localizedMinute":[32],"localizedMinuteSuffix":[32],"localizedSecond":[32],"localizedSecondSuffix":[32],"meridiem":[32],"minute":[32],"second":[32],"showSecond":[32]},[[0,"blur","hostBlurHandler"],[0,"focus","hostFocusHandler"],[0,"keydown","keyDownHandler"]]]);
- const CalciteTip = /*@__PURE__*/proxyCustomElement(Tip, [1,"calcite-tip",{"dismissed":[1540],"nonDismissible":[516,"non-dismissible"],"heading":[1],"headingLevel":[2,"heading-level"],"selected":[516],"intlClose":[1,"intl-close"]}]);
- const CalciteTipGroup = /*@__PURE__*/proxyCustomElement(TipGroup, [1,"calcite-tip-group",{"groupTitle":[1,"group-title"]}]);
- const CalciteTipManager = /*@__PURE__*/proxyCustomElement(TipManager, [1,"calcite-tip-manager",{"closed":[1540],"headingLevel":[2,"heading-level"],"intlClose":[1,"intl-close"],"intlDefaultTitle":[1,"intl-default-title"],"intlNext":[1,"intl-next"],"intlPaginationLabel":[1,"intl-pagination-label"],"intlPrevious":[1,"intl-previous"],"selectedIndex":[32],"tips":[32],"total":[32],"direction":[32],"groupTitle":[32]}]);
- const CalciteTooltip = /*@__PURE__*/proxyCustomElement(Tooltip, [1,"calcite-tooltip",{"label":[1],"offsetDistance":[514,"offset-distance"],"offsetSkidding":[514,"offset-skidding"],"open":[516],"overlayPositioning":[1,"overlay-positioning"],"placement":[513],"referenceElement":[1,"reference-element"],"effectiveReferenceElement":[32]}]);
- const CalciteTooltipManager = /*@__PURE__*/proxyCustomElement(TooltipManager, [1,"calcite-tooltip-manager",{"selector":[1]}]);
- const CalciteTree = /*@__PURE__*/proxyCustomElement(Tree, [1,"calcite-tree",{"lines":[1540],"inputEnabled":[4,"input-enabled"],"child":[1540],"scale":[1537],"selectionMode":[1537,"selection-mode"]},[[0,"focus","onFocus"],[0,"focusin","onFocusIn"],[0,"focusout","onFocusOut"],[0,"calciteTreeItemSelect","onClick"],[0,"keydown","keyDownHandler"]]]);
- const CalciteTreeItem = /*@__PURE__*/proxyCustomElement(TreeItem, [1,"calcite-tree-item",{"selected":[1540],"expanded":[1540],"parentExpanded":[4,"parent-expanded"],"depth":[1538],"hasChildren":[1540,"has-children"],"lines":[1540],"inputEnabled":[4,"input-enabled"],"scale":[1537],"indeterminate":[516],"selectionMode":[1025,"selection-mode"]},[[0,"click","onClick"],[0,"keydown","keyDownHandler"]]]);
- const CalciteValueList = /*@__PURE__*/proxyCustomElement(ValueList, [1,"calcite-value-list",{"disabled":[516],"dragEnabled":[516,"drag-enabled"],"filterEnabled":[516,"filter-enabled"],"filterPlaceholder":[513,"filter-placeholder"],"group":[1],"loading":[516],"multiple":[516],"selectionFollowsFocus":[4,"selection-follows-focus"],"selectedValues":[32],"dataForFilter":[32]},[[0,"focusout","calciteListFocusOutHandler"],[0,"calciteListItemRemove","calciteListItemRemoveHandler"],[0,"calciteListItemChange","calciteListItemChangeHandler"],[0,"calciteListItemPropsChange","calciteListItemPropsChangeHandler"],[0,"calciteListItemValueChange","calciteListItemValueChangeHandler"]]]);
- const CalciteValueListItem = /*@__PURE__*/proxyCustomElement(ValueListItem, [1,"calcite-value-list-item",{"description":[513],"disabled":[516],"disableDeselect":[4,"disable-deselect"],"nonInteractive":[516,"non-interactive"],"handleActivated":[1028,"handle-activated"],"icon":[513],"label":[513],"metadata":[16],"removable":[516],"selected":[1540],"value":[8]},[[0,"calciteListItemChange","calciteListItemChangeHandler"]]]);
- const defineCustomElements = (opts) => {
- if (typeof customElements !== 'undefined') {
- [
- CalciteAccordion,
- CalciteAccordionItem,
- CalciteAction,
- CalciteActionBar,
- CalciteActionGroup,
- CalciteActionMenu,
- CalciteActionPad,
- CalciteAlert,
- CalciteAvatar,
- CalciteBlock,
- CalciteBlockSection,
- CalciteButton,
- CalciteCard,
- CalciteCheckbox,
- CalciteChip,
- CalciteColorPicker,
- CalciteColorPickerHexInput,
- CalciteColorPickerSwatch,
- CalciteCombobox,
- CalciteComboboxItem,
- CalciteComboboxItemGroup,
- CalciteDatePicker,
- CalciteDatePickerDay,
- CalciteDatePickerMonth,
- CalciteDatePickerMonthHeader,
- CalciteDropdown,
- CalciteDropdownGroup,
- CalciteDropdownItem,
- CalciteFab,
- CalciteFilter,
- CalciteFlow,
- CalciteGraph,
- CalciteHandle,
- CalciteIcon,
- CalciteInlineEditable,
- CalciteInput,
- CalciteInputDatePicker,
- CalciteInputMessage,
- CalciteInputTimePicker,
- CalciteLabel,
- CalciteLink,
- CalciteList,
- CalciteListItem,
- CalciteListItemGroup,
- CalciteLoader,
- CalciteModal,
- CalciteNotice,
- CalciteOption,
- CalciteOptionGroup,
- CalcitePagination,
- CalcitePanel,
- CalcitePickList,
- CalcitePickListGroup,
- CalcitePickListItem,
- CalcitePopover,
- CalcitePopoverManager,
- CalciteProgress,
- CalciteRadioButton,
- CalciteRadioButtonGroup,
- CalciteRadioGroup,
- CalciteRadioGroupItem,
- CalciteRating,
- CalciteScrim,
- CalciteSelect,
- CalciteShell,
- CalciteShellCenterRow,
- CalciteShellPanel,
- CalciteSlider,
- CalciteSortableList,
- CalciteSplitButton,
- CalciteStepper,
- CalciteStepperItem,
- CalciteSwitch,
- CalciteTab,
- CalciteTabNav,
- CalciteTabTitle,
- CalciteTabs,
- CalciteTile,
- CalciteTileSelect,
- CalciteTileSelectGroup,
- CalciteTimePicker,
- CalciteTip,
- CalciteTipGroup,
- CalciteTipManager,
- CalciteTooltip,
- CalciteTooltipManager,
- CalciteTree,
- CalciteTreeItem,
- CalciteValueList,
- CalciteValueListItem
- ].forEach(cmp => {
- if (!customElements.get(cmp.is)) {
- customElements.define(cmp.is, cmp, opts);
- }
- });
- }
- };
- export { CalciteAccordion, CalciteAccordionItem, CalciteAction, CalciteActionBar, CalciteActionGroup, CalciteActionMenu, CalciteActionPad, CalciteAlert, CalciteAvatar, CalciteBlock, CalciteBlockSection, CalciteButton, CalciteCard, CalciteCheckbox, CalciteChip, CalciteColorPicker, CalciteColorPickerHexInput, CalciteColorPickerSwatch, CalciteCombobox, CalciteComboboxItem, CalciteComboboxItemGroup, CalciteDatePicker, CalciteDatePickerDay, CalciteDatePickerMonth, CalciteDatePickerMonthHeader, CalciteDropdown, CalciteDropdownGroup, CalciteDropdownItem, CalciteFab, CalciteFilter, CalciteFlow, CalciteGraph, CalciteHandle, CalciteIcon, CalciteInlineEditable, CalciteInput, CalciteInputDatePicker, CalciteInputMessage, CalciteInputTimePicker, CalciteLabel, CalciteLink, CalciteList, CalciteListItem, CalciteListItemGroup, CalciteLoader, CalciteModal, CalciteNotice, CalciteOption, CalciteOptionGroup, CalcitePagination, CalcitePanel, CalcitePickList, CalcitePickListGroup, CalcitePickListItem, CalcitePopover, CalcitePopoverManager, CalciteProgress, CalciteRadioButton, CalciteRadioButtonGroup, CalciteRadioGroup, CalciteRadioGroupItem, CalciteRating, CalciteScrim, CalciteSelect, CalciteShell, CalciteShellCenterRow, CalciteShellPanel, CalciteSlider, CalciteSortableList, CalciteSplitButton, CalciteStepper, CalciteStepperItem, CalciteSwitch, CalciteTab, CalciteTabNav, CalciteTabTitle, CalciteTabs, CalciteTile, CalciteTileSelect, CalciteTileSelectGroup, CalciteTimePicker, CalciteTip, CalciteTipGroup, CalciteTipManager, CalciteTooltip, CalciteTooltipManager, CalciteTree, CalciteTreeItem, CalciteValueList, CalciteValueListItem, defineCustomElements };
|