index.js 1.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500
  1. /*!
  2. * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
  4. * v1.0.0-beta.82
  5. */
  6. import { HTMLElement as HTMLElement$1, createEvent, h, Host, Build, forceUpdate, Fragment, getAssetPath, proxyCustomElement } from '@stencil/core/internal/client';
  7. export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client';
  8. 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)}";
  9. const Accordion = class extends HTMLElement$1 {
  10. constructor() {
  11. super();
  12. this.__registerHost();
  13. this.__attachShadow();
  14. this.calciteAccordionChange = createEvent(this, "calciteAccordionChange", 7);
  15. //--------------------------------------------------------------------------
  16. //
  17. // Public Properties
  18. //
  19. //--------------------------------------------------------------------------
  20. /** specify the appearance - default (containing border), or minimal (no containing border), defaults to default */
  21. this.appearance = "default";
  22. /** specify the placement of the icon in the header, defaults to end */
  23. this.iconPosition = "end";
  24. /** specify the type of the icon in the header, defaults to chevron */
  25. this.iconType = "chevron";
  26. /** specify the scale of accordion, defaults to m */
  27. this.scale = "m";
  28. /** specify the selection mode - multi (allow any number of open items), single (allow one open item),
  29. * or single-persist (allow and require one open item), defaults to multi */
  30. this.selectionMode = "multi";
  31. //--------------------------------------------------------------------------
  32. //
  33. // Private State/Props
  34. //
  35. //--------------------------------------------------------------------------
  36. /** created list of Accordion items */
  37. this.items = [];
  38. /** keep track of whether the items have been sorted so we don't re-sort */
  39. this.sorted = false;
  40. this.sortItems = (items) => items.sort((a, b) => a.position - b.position).map((a) => a.item);
  41. }
  42. //--------------------------------------------------------------------------
  43. //
  44. // Lifecycle
  45. //
  46. //--------------------------------------------------------------------------
  47. componentDidLoad() {
  48. if (!this.sorted) {
  49. this.items = this.sortItems(this.items);
  50. this.sorted = true;
  51. }
  52. }
  53. render() {
  54. return (h("div", { class: {
  55. "accordion--transparent": this.appearance === "transparent",
  56. "accordion--minimal": this.appearance === "minimal",
  57. accordion: this.appearance === "default"
  58. } }, h("slot", null)));
  59. }
  60. //--------------------------------------------------------------------------
  61. //
  62. // Event Listeners
  63. //
  64. //--------------------------------------------------------------------------
  65. calciteAccordionItemKeyEvent(e) {
  66. const item = e.detail.item;
  67. const parent = e.detail.parent;
  68. if (this.el === parent) {
  69. const key = item.key;
  70. const itemToFocus = e.target;
  71. const isFirstItem = this.itemIndex(itemToFocus) === 0;
  72. const isLastItem = this.itemIndex(itemToFocus) === this.items.length - 1;
  73. switch (key) {
  74. case "ArrowDown":
  75. if (isLastItem) {
  76. this.focusFirstItem();
  77. }
  78. else {
  79. this.focusNextItem(itemToFocus);
  80. }
  81. break;
  82. case "ArrowUp":
  83. if (isFirstItem) {
  84. this.focusLastItem();
  85. }
  86. else {
  87. this.focusPrevItem(itemToFocus);
  88. }
  89. break;
  90. case "Home":
  91. this.focusFirstItem();
  92. break;
  93. case "End":
  94. this.focusLastItem();
  95. break;
  96. }
  97. }
  98. }
  99. registerCalciteAccordionItem(e) {
  100. const item = {
  101. item: e.target,
  102. parent: e.detail.parent,
  103. position: e.detail.position
  104. };
  105. if (this.el === item.parent) {
  106. this.items.push(item);
  107. }
  108. }
  109. updateActiveItemOnChange(event) {
  110. this.requestedAccordionItem = event.detail.requestedAccordionItem;
  111. this.calciteAccordionChange.emit({
  112. requestedAccordionItem: this.requestedAccordionItem
  113. });
  114. }
  115. //--------------------------------------------------------------------------
  116. //
  117. // Private Methods
  118. //
  119. //--------------------------------------------------------------------------
  120. focusFirstItem() {
  121. const firstItem = this.items[0];
  122. this.focusElement(firstItem);
  123. }
  124. focusLastItem() {
  125. const lastItem = this.items[this.items.length - 1];
  126. this.focusElement(lastItem);
  127. }
  128. focusNextItem(e) {
  129. const index = this.itemIndex(e);
  130. const nextItem = this.items[index + 1] || this.items[0];
  131. this.focusElement(nextItem);
  132. }
  133. focusPrevItem(e) {
  134. const index = this.itemIndex(e);
  135. const prevItem = this.items[index - 1] || this.items[this.items.length - 1];
  136. this.focusElement(prevItem);
  137. }
  138. itemIndex(e) {
  139. return this.items.indexOf(e);
  140. }
  141. focusElement(item) {
  142. const target = item;
  143. target.focus();
  144. }
  145. get el() { return this; }
  146. static get style() { return accordionCss; }
  147. };
  148. const autoTheme = "calcite-theme-auto";
  149. const darkTheme = "calcite-theme-dark";
  150. const lightTheme = "calcite-theme-light";
  151. const CSS_UTILITY = {
  152. autoTheme,
  153. darkTheme,
  154. lightTheme,
  155. rtl: "calcite--rtl"
  156. };
  157. const TEXT$s = {
  158. loading: "Loading"
  159. };
  160. function gen(counts) {
  161. return counts
  162. .map((count) => {
  163. let out = "";
  164. for (let i = 0; i < count; i++) {
  165. out += (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
  166. }
  167. return out;
  168. })
  169. .join("-");
  170. }
  171. const guid = () => gen([2, 1, 1, 1, 3]);
  172. /**
  173. * This helper will guarantee an ID on the provided element.
  174. *
  175. * If it already has an ID, it will be preserved, otherwise a unique one will be generated and assigned.
  176. *
  177. * @returns {string} The element's ID.
  178. */
  179. function ensureId(el) {
  180. if (!el) {
  181. return "";
  182. }
  183. return (el.id = el.id || `${el.tagName.toLowerCase()}-${guid()}`);
  184. }
  185. function nodeListToArray(nodeList) {
  186. return Array.isArray(nodeList) ? nodeList : Array.from(nodeList);
  187. }
  188. function getThemeName(el) {
  189. const closestElWithTheme = closestElementCrossShadowBoundary(el, `.${CSS_UTILITY.darkTheme}, .${CSS_UTILITY.lightTheme}`);
  190. return (closestElWithTheme === null || closestElWithTheme === void 0 ? void 0 : closestElWithTheme.classList.contains("calcite-theme-dark")) ? "dark" : "light";
  191. }
  192. function getElementDir(el) {
  193. const prop = "dir";
  194. const selector = `[${prop}]`;
  195. const closest = closestElementCrossShadowBoundary(el, selector);
  196. return closest ? closest.getAttribute(prop) : "ltr";
  197. }
  198. function getElementProp(el, prop, fallbackValue) {
  199. const selector = `[${prop}]`;
  200. const closest = el.closest(selector);
  201. return closest ? closest.getAttribute(prop) : fallbackValue;
  202. }
  203. function getRootNode(el) {
  204. return el.getRootNode();
  205. }
  206. function getHost(root) {
  207. return root.host || null;
  208. }
  209. /**
  210. * This helper queries an element's rootNodes and any ancestor rootNodes.
  211. *
  212. * @returns {Element[]} The elements.
  213. */
  214. function queryElementsRoots(element, selector) {
  215. // Gets the rootNode and any ancestor rootNodes (shadowRoot or document) of an element and queries them for a selector.
  216. // Based on: https://stackoverflow.com/q/54520554/194216
  217. function queryFromAll(el, allResults) {
  218. if (!el) {
  219. return allResults;
  220. }
  221. if (el.assignedSlot) {
  222. el = el.assignedSlot;
  223. }
  224. const rootNode = getRootNode(el);
  225. const results = Array.from(rootNode.querySelectorAll(selector));
  226. const uniqueResults = results.filter((result) => !allResults.includes(result));
  227. allResults = [...allResults, ...uniqueResults];
  228. const host = getHost(rootNode);
  229. return host ? queryFromAll(host, allResults) : allResults;
  230. }
  231. return queryFromAll(element, []);
  232. }
  233. /**
  234. * This helper queries an element's rootNode and any ancestor rootNodes.
  235. *
  236. * If both an 'id' and 'selector' are supplied, 'id' will take precedence over 'selector'.
  237. *
  238. * @returns {Element} The element.
  239. */
  240. function queryElementRoots(element, { selector, id }) {
  241. // Gets the rootNode and any ancestor rootNodes (shadowRoot or document) of an element and queries them for a selector.
  242. // Based on: https://stackoverflow.com/q/54520554/194216
  243. function queryFrom(el) {
  244. if (!el) {
  245. return null;
  246. }
  247. if (el.assignedSlot) {
  248. el = el.assignedSlot;
  249. }
  250. const rootNode = getRootNode(el);
  251. const found = id
  252. ? "getElementById" in rootNode
  253. ? /*
  254. Check to make sure 'getElementById' exists in cases where element is no longer connected to the DOM and getRootNode() returns the element.
  255. https://github.com/Esri/calcite-components/pull/4280
  256. */
  257. rootNode.getElementById(id)
  258. : null
  259. : selector
  260. ? rootNode.querySelector(selector)
  261. : null;
  262. const host = getHost(rootNode);
  263. return found ? found : host ? queryFrom(host) : null;
  264. }
  265. return queryFrom(element);
  266. }
  267. function closestElementCrossShadowBoundary(element, selector) {
  268. // based on https://stackoverflow.com/q/54520554/194216
  269. function closestFrom(el) {
  270. return el ? el.closest(selector) || closestFrom(getHost(getRootNode(el))) : null;
  271. }
  272. return closestFrom(element);
  273. }
  274. function isCalciteFocusable(el) {
  275. return typeof (el === null || el === void 0 ? void 0 : el.setFocus) === "function";
  276. }
  277. async function focusElement(el) {
  278. if (!el) {
  279. return;
  280. }
  281. return isCalciteFocusable(el) ? el.setFocus() : el.focus();
  282. }
  283. const defaultSlotSelector = ":not([slot])";
  284. function getSlotted(element, slotName, options) {
  285. if (slotName && !Array.isArray(slotName) && typeof slotName !== "string") {
  286. options = slotName;
  287. slotName = null;
  288. }
  289. const slotSelector = slotName
  290. ? Array.isArray(slotName)
  291. ? slotName.map((name) => `[slot="${name}"]`).join(",")
  292. : `[slot="${slotName}"]`
  293. : defaultSlotSelector;
  294. if (options === null || options === void 0 ? void 0 : options.all) {
  295. return queryMultiple(element, slotSelector, options);
  296. }
  297. return querySingle(element, slotSelector, options);
  298. }
  299. function getDirectChildren(el, selector) {
  300. return el ? Array.from(el.children || []).filter((child) => child === null || child === void 0 ? void 0 : child.matches(selector)) : [];
  301. }
  302. function queryMultiple(element, slotSelector, options) {
  303. let matches = slotSelector === defaultSlotSelector
  304. ? getDirectChildren(element, defaultSlotSelector)
  305. : Array.from(element.querySelectorAll(slotSelector));
  306. matches = options && options.direct === false ? matches : matches.filter((el) => el.parentElement === element);
  307. 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;
  308. const selector = options === null || options === void 0 ? void 0 : options.selector;
  309. return selector
  310. ? matches
  311. .map((item) => Array.from(item.querySelectorAll(selector)))
  312. .reduce((previousValue, currentValue) => [...previousValue, ...currentValue], [])
  313. .filter((match) => !!match)
  314. : matches;
  315. }
  316. function querySingle(element, slotSelector, options) {
  317. let match = slotSelector === defaultSlotSelector
  318. ? getDirectChildren(element, defaultSlotSelector)[0] || null
  319. : element.querySelector(slotSelector);
  320. match = options && options.direct === false ? match : (match === null || match === void 0 ? void 0 : match.parentElement) === element ? match : null;
  321. match = (options === null || options === void 0 ? void 0 : options.matches) ? ((match === null || match === void 0 ? void 0 : match.matches(options.matches)) ? match : null) : match;
  322. const selector = options === null || options === void 0 ? void 0 : options.selector;
  323. return selector ? match === null || match === void 0 ? void 0 : match.querySelector(selector) : match;
  324. }
  325. function filterDirectChildren(el, selector) {
  326. return Array.from(el.children).filter((child) => child.matches(selector));
  327. }
  328. // set a default icon from a defined set or allow an override with an icon name string
  329. function setRequestedIcon(iconObject, iconValue, matchedValue) {
  330. if (typeof iconValue === "string" && iconValue !== "") {
  331. return iconValue;
  332. }
  333. else if (iconValue === "") {
  334. return iconObject[matchedValue];
  335. }
  336. }
  337. function intersects(rect1, rect2) {
  338. return !(rect2.left > rect1.right ||
  339. rect2.right < rect1.left ||
  340. rect2.top > rect1.bottom ||
  341. rect2.bottom < rect1.top);
  342. }
  343. /**
  344. * This helper makes sure that boolean aria attributes are properly converted to a string.
  345. *
  346. * It should only be used for aria attributes that require a string value of "true" or "false".
  347. *
  348. * @returns {string} The string conversion of a boolean value ("true" | "false").
  349. */
  350. function toAriaBoolean(value) {
  351. return (!!value).toString();
  352. }
  353. 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)}";
  354. const AccordionItem = class extends HTMLElement$1 {
  355. constructor() {
  356. super();
  357. this.__registerHost();
  358. this.__attachShadow();
  359. this.calciteAccordionItemKeyEvent = createEvent(this, "calciteAccordionItemKeyEvent", 7);
  360. this.calciteAccordionItemSelect = createEvent(this, "calciteAccordionItemSelect", 7);
  361. this.calciteAccordionItemClose = createEvent(this, "calciteAccordionItemClose", 7);
  362. this.calciteAccordionItemRegister = createEvent(this, "calciteAccordionItemRegister", 7);
  363. //--------------------------------------------------------------------------
  364. //
  365. // Public Properties
  366. //
  367. //--------------------------------------------------------------------------
  368. /** Indicates whether the item is active. */
  369. this.active = false;
  370. //--------------------------------------------------------------------------
  371. //
  372. // Private State/Props
  373. //
  374. //--------------------------------------------------------------------------
  375. this.guid = guid();
  376. /** what icon position does the parent accordion specify */
  377. this.iconPosition = "end";
  378. /** handle clicks on item header */
  379. this.itemHeaderClickHandler = () => this.emitRequestedItem();
  380. }
  381. //--------------------------------------------------------------------------
  382. //
  383. // Lifecycle
  384. //
  385. //--------------------------------------------------------------------------
  386. connectedCallback() {
  387. this.parent = this.el.parentElement;
  388. this.selectionMode = getElementProp(this.el, "selection-mode", "multi");
  389. this.iconType = getElementProp(this.el, "icon-type", "chevron");
  390. this.iconPosition = getElementProp(this.el, "icon-position", this.iconPosition);
  391. }
  392. componentDidLoad() {
  393. this.itemPosition = this.getItemPosition();
  394. this.calciteAccordionItemRegister.emit({
  395. parent: this.parent,
  396. position: this.itemPosition
  397. });
  398. }
  399. render() {
  400. const dir = getElementDir(this.el);
  401. const iconEl = h("calcite-icon", { class: "accordion-item-icon", icon: this.icon, scale: "s" });
  402. const { guid } = this;
  403. const regionId = `${guid}-region`;
  404. const buttonId = `${guid}-button`;
  405. return (h(Host, { tabindex: "0" }, h("div", { class: {
  406. [`icon-position--${this.iconPosition}`]: true,
  407. [`icon-type--${this.iconType}`]: true
  408. } }, 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"
  409. ? "chevronDown"
  410. : this.iconType === "caret"
  411. ? "caretDown"
  412. : this.active
  413. ? "minus"
  414. : "plus", scale: "s" })), h("div", { "aria-expanded": toAriaBoolean(this.active), "aria-labelledby": buttonId, class: "accordion-item-content", id: regionId, role: "region" }, h("slot", null)))));
  415. }
  416. //--------------------------------------------------------------------------
  417. //
  418. // Event Listeners
  419. //
  420. //--------------------------------------------------------------------------
  421. keyDownHandler(e) {
  422. if (e.target === this.el) {
  423. switch (e.key) {
  424. case " ":
  425. case "Enter":
  426. this.emitRequestedItem();
  427. e.preventDefault();
  428. break;
  429. case "ArrowUp":
  430. case "ArrowDown":
  431. case "Home":
  432. case "End":
  433. this.calciteAccordionItemKeyEvent.emit({
  434. parent: this.parent,
  435. item: e
  436. });
  437. e.preventDefault();
  438. break;
  439. }
  440. }
  441. }
  442. updateActiveItemOnChange(event) {
  443. this.requestedAccordionItem = event.detail
  444. .requestedAccordionItem;
  445. if (this.el.parentNode !== this.requestedAccordionItem.parentNode) {
  446. return;
  447. }
  448. this.determineActiveItem();
  449. }
  450. //--------------------------------------------------------------------------
  451. //
  452. // Private Methods
  453. //
  454. //--------------------------------------------------------------------------
  455. determineActiveItem() {
  456. switch (this.selectionMode) {
  457. case "multi":
  458. if (this.el === this.requestedAccordionItem) {
  459. this.active = !this.active;
  460. }
  461. break;
  462. case "single":
  463. this.active = this.el === this.requestedAccordionItem ? !this.active : false;
  464. break;
  465. case "single-persist":
  466. this.active = this.el === this.requestedAccordionItem;
  467. break;
  468. }
  469. }
  470. emitRequestedItem() {
  471. this.calciteAccordionItemSelect.emit({
  472. requestedAccordionItem: this.el
  473. });
  474. }
  475. getItemPosition() {
  476. return Array.prototype.indexOf.call(this.parent.querySelectorAll("calcite-accordion-item"), this.el);
  477. }
  478. get el() { return this; }
  479. static get style() { return accordionItemCss; }
  480. };
  481. const CSS$P = {
  482. button: "button",
  483. buttonTextVisible: "button--text-visible",
  484. buttonCompact: "button--compact",
  485. iconContainer: "icon-container",
  486. slotContainer: "slot-container",
  487. slotContainerHidden: "slot-container--hidden",
  488. textContainer: "text-container",
  489. textContainerVisible: "text-container--visible"
  490. };
  491. const TEXT$r = {
  492. loading: "Loading"
  493. };
  494. /**
  495. * This utility ensures observers are created only for browser contexts.
  496. *
  497. * @param type - the type of observer to create
  498. * @param callback - the observer callback
  499. * @param options - the observer options
  500. */
  501. function createObserver(type, callback, options) {
  502. const Observer = getObserver(type);
  503. return Build.isBrowser ? new Observer(callback, options) : undefined;
  504. }
  505. function getObserver(type) {
  506. return (type === "intersection"
  507. ? window.IntersectionObserver
  508. : type === "mutation"
  509. ? window.MutationObserver
  510. : window.ResizeObserver);
  511. }
  512. function noopClick() {
  513. /** noop **/
  514. }
  515. /**
  516. * This helper updates the host element to prevent keyboard interaction on its subtree and sets the appropriate aria attribute for accessibility.
  517. *
  518. * This should be used in the `componentDidRender` lifecycle hook.
  519. *
  520. * **Notes**
  521. *
  522. * * 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.
  523. * * technically, users can override `tabindex` and restore keyboard navigation, but this will be considered user error
  524. */
  525. function updateHostInteraction(component, hostIsTabbable = false) {
  526. if (component.disabled) {
  527. component.el.setAttribute("tabindex", "-1");
  528. component.el.setAttribute("aria-disabled", "true");
  529. if (component.el.contains(document.activeElement)) {
  530. document.activeElement.blur();
  531. }
  532. component.el.click = noopClick;
  533. return;
  534. }
  535. component.el.click = HTMLElement.prototype.click;
  536. if (typeof hostIsTabbable === "function") {
  537. component.el.setAttribute("tabindex", hostIsTabbable.call(component) ? "0" : "-1");
  538. }
  539. else if (hostIsTabbable === true) {
  540. component.el.setAttribute("tabindex", "0");
  541. }
  542. else if (hostIsTabbable === false) {
  543. component.el.removeAttribute("tabindex");
  544. }
  545. else ;
  546. component.el.removeAttribute("aria-disabled");
  547. }
  548. 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)}";
  549. const Action = class extends HTMLElement$1 {
  550. constructor() {
  551. super();
  552. this.__registerHost();
  553. this.__attachShadow();
  554. this.calciteActionClick = createEvent(this, "calciteActionClick", 7);
  555. // --------------------------------------------------------------------------
  556. //
  557. // Properties
  558. //
  559. // --------------------------------------------------------------------------
  560. /**
  561. * Indicates whether the action is highlighted.
  562. */
  563. this.active = false;
  564. /** Specify the appearance style of the action, defaults to solid. */
  565. this.appearance = "solid";
  566. /**
  567. * Compact mode is used internally by components to reduce side padding, e.g. calcite-block-section.
  568. */
  569. this.compact = false;
  570. /**
  571. * When true, disabled prevents interaction. This state shows items with lower opacity/grayed.
  572. */
  573. this.disabled = false;
  574. /**
  575. * Indicates unread changes.
  576. */
  577. this.indicator = false;
  578. /** string to override English loading text
  579. * @default "Loading"
  580. */
  581. this.intlLoading = TEXT$r.loading;
  582. /**
  583. * When true, content is waiting to be loaded. This state shows a busy indicator.
  584. */
  585. this.loading = false;
  586. /**
  587. * Specifies the size of the action.
  588. */
  589. this.scale = "m";
  590. /**
  591. * Indicates whether the text is displayed.
  592. */
  593. this.textEnabled = false;
  594. this.mutationObserver = createObserver("mutation", () => forceUpdate(this));
  595. // --------------------------------------------------------------------------
  596. //
  597. // Private Methods
  598. //
  599. // --------------------------------------------------------------------------
  600. this.calciteActionClickHandler = () => {
  601. if (!this.disabled) {
  602. this.calciteActionClick.emit();
  603. }
  604. };
  605. }
  606. // --------------------------------------------------------------------------
  607. //
  608. // Lifecycle
  609. //
  610. // --------------------------------------------------------------------------
  611. connectedCallback() {
  612. var _a;
  613. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
  614. }
  615. disconnectedCallback() {
  616. var _a;
  617. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  618. }
  619. componentDidRender() {
  620. updateHostInteraction(this);
  621. }
  622. // --------------------------------------------------------------------------
  623. //
  624. // Methods
  625. //
  626. // --------------------------------------------------------------------------
  627. /** Sets focus on the component. */
  628. async setFocus() {
  629. this.buttonEl.focus();
  630. }
  631. // --------------------------------------------------------------------------
  632. //
  633. // Render Methods
  634. //
  635. // --------------------------------------------------------------------------
  636. renderTextContainer() {
  637. const { text, textEnabled } = this;
  638. const textContainerClasses = {
  639. [CSS$P.textContainer]: true,
  640. [CSS$P.textContainerVisible]: textEnabled
  641. };
  642. return text ? (h("div", { class: textContainerClasses, key: "text-container" }, text)) : null;
  643. }
  644. renderIconContainer() {
  645. var _a;
  646. const { loading, icon, scale, el, intlLoading } = this;
  647. const iconScale = scale === "l" ? "m" : "s";
  648. const loaderScale = scale === "l" ? "l" : "m";
  649. const calciteLoaderNode = loading ? (h("calcite-loader", { active: true, inline: true, label: intlLoading, scale: loaderScale })) : null;
  650. const calciteIconNode = icon ? h("calcite-icon", { icon: icon, scale: iconScale }) : null;
  651. const iconNode = calciteLoaderNode || calciteIconNode;
  652. const hasIconToDisplay = iconNode || ((_a = el.children) === null || _a === void 0 ? void 0 : _a.length);
  653. const slotContainerNode = (h("div", { class: {
  654. [CSS$P.slotContainer]: true,
  655. [CSS$P.slotContainerHidden]: loading
  656. } }, h("slot", null)));
  657. return hasIconToDisplay ? (h("div", { "aria-hidden": "true", class: CSS$P.iconContainer, key: "icon-container" }, iconNode, slotContainerNode)) : null;
  658. }
  659. render() {
  660. const { compact, disabled, loading, textEnabled, label, text } = this;
  661. const ariaLabel = label || text;
  662. const buttonClasses = {
  663. [CSS$P.button]: true,
  664. [CSS$P.buttonTextVisible]: textEnabled,
  665. [CSS$P.buttonCompact]: compact
  666. };
  667. 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())));
  668. }
  669. get el() { return this; }
  670. static get style() { return actionCss; }
  671. };
  672. const CSS$O = {
  673. menu: "menu",
  674. defaultTrigger: "default-trigger"
  675. };
  676. const SLOTS$p = {
  677. tooltip: "tooltip",
  678. trigger: "trigger"
  679. };
  680. const ICONS$f = {
  681. menu: "ellipsis"
  682. };
  683. const SLOTS$o = {
  684. menuActions: "menu-actions",
  685. menuTooltip: "menu-tooltip"
  686. };
  687. const TEXT$q = {
  688. more: "More"
  689. };
  690. const ICONS$e = {
  691. menu: "ellipsis"
  692. };
  693. const overflowActionsDebounceInMs = 150;
  694. const groupBufferHeight = 2;
  695. const getMaxActionCount = ({ height, actionHeight, groupCount }) => {
  696. return Math.floor((height - groupCount * groupBufferHeight) / actionHeight);
  697. };
  698. const getOverflowCount = ({ actionCount, actionHeight, height, groupCount }) => {
  699. return Math.max(actionCount - getMaxActionCount({ height, actionHeight, groupCount }), 0);
  700. };
  701. const queryActions = (el) => {
  702. return Array.from(el.querySelectorAll("calcite-action")).filter((action) => action.closest("calcite-action-menu") ? action.slot === SLOTS$p.trigger : true);
  703. };
  704. const overflowActions = ({ actionGroups, expanded, overflowCount }) => {
  705. let needToSlotCount = overflowCount;
  706. actionGroups.reverse().forEach((group) => {
  707. let slottedWithinGroupCount = 0;
  708. const groupActions = queryActions(group).reverse();
  709. groupActions.forEach((groupAction) => {
  710. if (groupAction.slot === SLOTS$o.menuActions) {
  711. groupAction.removeAttribute("slot");
  712. groupAction.textEnabled = expanded;
  713. }
  714. });
  715. if (needToSlotCount > 0) {
  716. groupActions.some((groupAction) => {
  717. const unslottedActions = groupActions.filter((action) => !action.slot);
  718. if (unslottedActions.length > 1 && groupActions.length > 2 && !groupAction.closest("calcite-action-menu")) {
  719. groupAction.textEnabled = true;
  720. groupAction.setAttribute("slot", SLOTS$o.menuActions);
  721. slottedWithinGroupCount++;
  722. if (slottedWithinGroupCount > 1) {
  723. needToSlotCount--;
  724. }
  725. }
  726. return needToSlotCount < 1;
  727. });
  728. }
  729. forceUpdate(group);
  730. });
  731. };
  732. const ICONS$d = {
  733. chevronsLeft: "chevrons-left",
  734. chevronsRight: "chevrons-right"
  735. };
  736. function getCalcitePosition(position, el) {
  737. var _a;
  738. return position || ((_a = el.closest("calcite-shell-panel")) === null || _a === void 0 ? void 0 : _a.position) || "start";
  739. }
  740. function toggleChildActionText({ parent, expanded }) {
  741. queryActions(parent)
  742. .filter((el) => el.slot !== SLOTS$o.menuActions)
  743. .forEach((action) => (action.textEnabled = expanded));
  744. parent.querySelectorAll("calcite-action-group").forEach((group) => (group.expanded = expanded));
  745. }
  746. const setTooltipReference = ({ tooltip, referenceElement, expanded, ref }) => {
  747. if (tooltip) {
  748. tooltip.referenceElement = !expanded && referenceElement ? referenceElement : null;
  749. }
  750. if (ref) {
  751. ref(referenceElement);
  752. }
  753. return referenceElement;
  754. };
  755. const ExpandToggle = ({ expanded, intlExpand, intlCollapse, toggle, el, position, tooltip, ref, scale }) => {
  756. const rtl = getElementDir(el) === "rtl";
  757. const expandText = expanded ? intlCollapse : intlExpand;
  758. const icons = [ICONS$d.chevronsLeft, ICONS$d.chevronsRight];
  759. if (rtl) {
  760. icons.reverse();
  761. }
  762. const end = getCalcitePosition(position, el) === "end";
  763. const expandIcon = end ? icons[1] : icons[0];
  764. const collapseIcon = end ? icons[0] : icons[1];
  765. const actionNode = (h("calcite-action", { icon: expanded ? expandIcon : collapseIcon, onClick: toggle, ref: (referenceElement) => setTooltipReference({ tooltip, referenceElement, expanded, ref }), scale: scale, text: expandText, textEnabled: expanded }));
  766. return actionNode;
  767. };
  768. const CSS$N = {
  769. actionGroupBottom: "action-group--bottom"
  770. };
  771. const SLOTS$n = {
  772. bottomActions: "bottom-actions",
  773. expandTooltip: "expand-tooltip"
  774. };
  775. const TEXT$p = {
  776. expand: "Expand",
  777. collapse: "Collapse"
  778. };
  779. /** Detect free variable `global` from Node.js. */
  780. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  781. /** Detect free variable `self`. */
  782. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  783. /** Used as a reference to the global object. */
  784. var root = freeGlobal || freeSelf || Function('return this')();
  785. /** Built-in value references. */
  786. var Symbol$1 = root.Symbol;
  787. /** Used for built-in method references. */
  788. var objectProto$5 = Object.prototype;
  789. /** Used to check objects for own properties. */
  790. var hasOwnProperty$3 = objectProto$5.hasOwnProperty;
  791. /**
  792. * Used to resolve the
  793. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  794. * of values.
  795. */
  796. var nativeObjectToString$1 = objectProto$5.toString;
  797. /** Built-in value references. */
  798. var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
  799. /**
  800. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  801. *
  802. * @private
  803. * @param {*} value The value to query.
  804. * @returns {string} Returns the raw `toStringTag`.
  805. */
  806. function getRawTag(value) {
  807. var isOwn = hasOwnProperty$3.call(value, symToStringTag$1),
  808. tag = value[symToStringTag$1];
  809. try {
  810. value[symToStringTag$1] = undefined;
  811. var unmasked = true;
  812. } catch (e) {}
  813. var result = nativeObjectToString$1.call(value);
  814. if (unmasked) {
  815. if (isOwn) {
  816. value[symToStringTag$1] = tag;
  817. } else {
  818. delete value[symToStringTag$1];
  819. }
  820. }
  821. return result;
  822. }
  823. /** Used for built-in method references. */
  824. var objectProto$4 = Object.prototype;
  825. /**
  826. * Used to resolve the
  827. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  828. * of values.
  829. */
  830. var nativeObjectToString = objectProto$4.toString;
  831. /**
  832. * Converts `value` to a string using `Object.prototype.toString`.
  833. *
  834. * @private
  835. * @param {*} value The value to convert.
  836. * @returns {string} Returns the converted string.
  837. */
  838. function objectToString(value) {
  839. return nativeObjectToString.call(value);
  840. }
  841. /** `Object#toString` result references. */
  842. var nullTag = '[object Null]',
  843. undefinedTag = '[object Undefined]';
  844. /** Built-in value references. */
  845. var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
  846. /**
  847. * The base implementation of `getTag` without fallbacks for buggy environments.
  848. *
  849. * @private
  850. * @param {*} value The value to query.
  851. * @returns {string} Returns the `toStringTag`.
  852. */
  853. function baseGetTag(value) {
  854. if (value == null) {
  855. return value === undefined ? undefinedTag : nullTag;
  856. }
  857. return (symToStringTag && symToStringTag in Object(value))
  858. ? getRawTag(value)
  859. : objectToString(value);
  860. }
  861. /**
  862. * Checks if `value` is object-like. A value is object-like if it's not `null`
  863. * and has a `typeof` result of "object".
  864. *
  865. * @static
  866. * @memberOf _
  867. * @since 4.0.0
  868. * @category Lang
  869. * @param {*} value The value to check.
  870. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  871. * @example
  872. *
  873. * _.isObjectLike({});
  874. * // => true
  875. *
  876. * _.isObjectLike([1, 2, 3]);
  877. * // => true
  878. *
  879. * _.isObjectLike(_.noop);
  880. * // => false
  881. *
  882. * _.isObjectLike(null);
  883. * // => false
  884. */
  885. function isObjectLike(value) {
  886. return value != null && typeof value == 'object';
  887. }
  888. /** `Object#toString` result references. */
  889. var symbolTag = '[object Symbol]';
  890. /**
  891. * Checks if `value` is classified as a `Symbol` primitive or object.
  892. *
  893. * @static
  894. * @memberOf _
  895. * @since 4.0.0
  896. * @category Lang
  897. * @param {*} value The value to check.
  898. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  899. * @example
  900. *
  901. * _.isSymbol(Symbol.iterator);
  902. * // => true
  903. *
  904. * _.isSymbol('abc');
  905. * // => false
  906. */
  907. function isSymbol(value) {
  908. return typeof value == 'symbol' ||
  909. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  910. }
  911. /**
  912. * A specialized version of `_.map` for arrays without support for iteratee
  913. * shorthands.
  914. *
  915. * @private
  916. * @param {Array} [array] The array to iterate over.
  917. * @param {Function} iteratee The function invoked per iteration.
  918. * @returns {Array} Returns the new mapped array.
  919. */
  920. function arrayMap(array, iteratee) {
  921. var index = -1,
  922. length = array == null ? 0 : array.length,
  923. result = Array(length);
  924. while (++index < length) {
  925. result[index] = iteratee(array[index], index, array);
  926. }
  927. return result;
  928. }
  929. /**
  930. * Checks if `value` is classified as an `Array` object.
  931. *
  932. * @static
  933. * @memberOf _
  934. * @since 0.1.0
  935. * @category Lang
  936. * @param {*} value The value to check.
  937. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  938. * @example
  939. *
  940. * _.isArray([1, 2, 3]);
  941. * // => true
  942. *
  943. * _.isArray(document.body.children);
  944. * // => false
  945. *
  946. * _.isArray('abc');
  947. * // => false
  948. *
  949. * _.isArray(_.noop);
  950. * // => false
  951. */
  952. var isArray = Array.isArray;
  953. /** Used as references for various `Number` constants. */
  954. var INFINITY = 1 / 0;
  955. /** Used to convert symbols to primitives and strings. */
  956. var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
  957. symbolToString = symbolProto ? symbolProto.toString : undefined;
  958. /**
  959. * The base implementation of `_.toString` which doesn't convert nullish
  960. * values to empty strings.
  961. *
  962. * @private
  963. * @param {*} value The value to process.
  964. * @returns {string} Returns the string.
  965. */
  966. function baseToString(value) {
  967. // Exit early for strings to avoid a performance hit in some environments.
  968. if (typeof value == 'string') {
  969. return value;
  970. }
  971. if (isArray(value)) {
  972. // Recursively convert values (susceptible to call stack limits).
  973. return arrayMap(value, baseToString) + '';
  974. }
  975. if (isSymbol(value)) {
  976. return symbolToString ? symbolToString.call(value) : '';
  977. }
  978. var result = (value + '');
  979. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  980. }
  981. /** Used to match a single whitespace character. */
  982. var reWhitespace = /\s/;
  983. /**
  984. * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
  985. * character of `string`.
  986. *
  987. * @private
  988. * @param {string} string The string to inspect.
  989. * @returns {number} Returns the index of the last non-whitespace character.
  990. */
  991. function trimmedEndIndex(string) {
  992. var index = string.length;
  993. while (index-- && reWhitespace.test(string.charAt(index))) {}
  994. return index;
  995. }
  996. /** Used to match leading whitespace. */
  997. var reTrimStart = /^\s+/;
  998. /**
  999. * The base implementation of `_.trim`.
  1000. *
  1001. * @private
  1002. * @param {string} string The string to trim.
  1003. * @returns {string} Returns the trimmed string.
  1004. */
  1005. function baseTrim(string) {
  1006. return string
  1007. ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
  1008. : string;
  1009. }
  1010. /**
  1011. * Checks if `value` is the
  1012. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  1013. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  1014. *
  1015. * @static
  1016. * @memberOf _
  1017. * @since 0.1.0
  1018. * @category Lang
  1019. * @param {*} value The value to check.
  1020. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  1021. * @example
  1022. *
  1023. * _.isObject({});
  1024. * // => true
  1025. *
  1026. * _.isObject([1, 2, 3]);
  1027. * // => true
  1028. *
  1029. * _.isObject(_.noop);
  1030. * // => true
  1031. *
  1032. * _.isObject(null);
  1033. * // => false
  1034. */
  1035. function isObject(value) {
  1036. var type = typeof value;
  1037. return value != null && (type == 'object' || type == 'function');
  1038. }
  1039. /** Used as references for various `Number` constants. */
  1040. var NAN = 0 / 0;
  1041. /** Used to detect bad signed hexadecimal string values. */
  1042. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  1043. /** Used to detect binary string values. */
  1044. var reIsBinary = /^0b[01]+$/i;
  1045. /** Used to detect octal string values. */
  1046. var reIsOctal = /^0o[0-7]+$/i;
  1047. /** Built-in method references without a dependency on `root`. */
  1048. var freeParseInt = parseInt;
  1049. /**
  1050. * Converts `value` to a number.
  1051. *
  1052. * @static
  1053. * @memberOf _
  1054. * @since 4.0.0
  1055. * @category Lang
  1056. * @param {*} value The value to process.
  1057. * @returns {number} Returns the number.
  1058. * @example
  1059. *
  1060. * _.toNumber(3.2);
  1061. * // => 3.2
  1062. *
  1063. * _.toNumber(Number.MIN_VALUE);
  1064. * // => 5e-324
  1065. *
  1066. * _.toNumber(Infinity);
  1067. * // => Infinity
  1068. *
  1069. * _.toNumber('3.2');
  1070. * // => 3.2
  1071. */
  1072. function toNumber(value) {
  1073. if (typeof value == 'number') {
  1074. return value;
  1075. }
  1076. if (isSymbol(value)) {
  1077. return NAN;
  1078. }
  1079. if (isObject(value)) {
  1080. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  1081. value = isObject(other) ? (other + '') : other;
  1082. }
  1083. if (typeof value != 'string') {
  1084. return value === 0 ? value : +value;
  1085. }
  1086. value = baseTrim(value);
  1087. var isBinary = reIsBinary.test(value);
  1088. return (isBinary || reIsOctal.test(value))
  1089. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  1090. : (reIsBadHex.test(value) ? NAN : +value);
  1091. }
  1092. /**
  1093. * This method returns the first argument it receives.
  1094. *
  1095. * @static
  1096. * @since 0.1.0
  1097. * @memberOf _
  1098. * @category Util
  1099. * @param {*} value Any value.
  1100. * @returns {*} Returns `value`.
  1101. * @example
  1102. *
  1103. * var object = { 'a': 1 };
  1104. *
  1105. * console.log(_.identity(object) === object);
  1106. * // => true
  1107. */
  1108. function identity(value) {
  1109. return value;
  1110. }
  1111. /** `Object#toString` result references. */
  1112. var asyncTag = '[object AsyncFunction]',
  1113. funcTag$1 = '[object Function]',
  1114. genTag = '[object GeneratorFunction]',
  1115. proxyTag = '[object Proxy]';
  1116. /**
  1117. * Checks if `value` is classified as a `Function` object.
  1118. *
  1119. * @static
  1120. * @memberOf _
  1121. * @since 0.1.0
  1122. * @category Lang
  1123. * @param {*} value The value to check.
  1124. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  1125. * @example
  1126. *
  1127. * _.isFunction(_);
  1128. * // => true
  1129. *
  1130. * _.isFunction(/abc/);
  1131. * // => false
  1132. */
  1133. function isFunction(value) {
  1134. if (!isObject(value)) {
  1135. return false;
  1136. }
  1137. // The use of `Object#toString` avoids issues with the `typeof` operator
  1138. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  1139. var tag = baseGetTag(value);
  1140. return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
  1141. }
  1142. /** Used as references for various `Number` constants. */
  1143. var MAX_SAFE_INTEGER$1 = 9007199254740991;
  1144. /** Used to detect unsigned integer values. */
  1145. var reIsUint = /^(?:0|[1-9]\d*)$/;
  1146. /**
  1147. * Checks if `value` is a valid array-like index.
  1148. *
  1149. * @private
  1150. * @param {*} value The value to check.
  1151. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  1152. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  1153. */
  1154. function isIndex(value, length) {
  1155. var type = typeof value;
  1156. length = length == null ? MAX_SAFE_INTEGER$1 : length;
  1157. return !!length &&
  1158. (type == 'number' ||
  1159. (type != 'symbol' && reIsUint.test(value))) &&
  1160. (value > -1 && value % 1 == 0 && value < length);
  1161. }
  1162. /** Used as references for various `Number` constants. */
  1163. var MAX_SAFE_INTEGER = 9007199254740991;
  1164. /**
  1165. * Checks if `value` is a valid array-like length.
  1166. *
  1167. * **Note:** This method is loosely based on
  1168. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  1169. *
  1170. * @static
  1171. * @memberOf _
  1172. * @since 4.0.0
  1173. * @category Lang
  1174. * @param {*} value The value to check.
  1175. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  1176. * @example
  1177. *
  1178. * _.isLength(3);
  1179. * // => true
  1180. *
  1181. * _.isLength(Number.MIN_VALUE);
  1182. * // => false
  1183. *
  1184. * _.isLength(Infinity);
  1185. * // => false
  1186. *
  1187. * _.isLength('3');
  1188. * // => false
  1189. */
  1190. function isLength(value) {
  1191. return typeof value == 'number' &&
  1192. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  1193. }
  1194. /**
  1195. * Checks if `value` is array-like. A value is considered array-like if it's
  1196. * not a function and has a `value.length` that's an integer greater than or
  1197. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  1198. *
  1199. * @static
  1200. * @memberOf _
  1201. * @since 4.0.0
  1202. * @category Lang
  1203. * @param {*} value The value to check.
  1204. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  1205. * @example
  1206. *
  1207. * _.isArrayLike([1, 2, 3]);
  1208. * // => true
  1209. *
  1210. * _.isArrayLike(document.body.children);
  1211. * // => true
  1212. *
  1213. * _.isArrayLike('abc');
  1214. * // => true
  1215. *
  1216. * _.isArrayLike(_.noop);
  1217. * // => false
  1218. */
  1219. function isArrayLike(value) {
  1220. return value != null && isLength(value.length) && !isFunction(value);
  1221. }
  1222. /** Used for built-in method references. */
  1223. var objectProto$3 = Object.prototype;
  1224. /**
  1225. * Checks if `value` is likely a prototype object.
  1226. *
  1227. * @private
  1228. * @param {*} value The value to check.
  1229. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  1230. */
  1231. function isPrototype(value) {
  1232. var Ctor = value && value.constructor,
  1233. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$3;
  1234. return value === proto;
  1235. }
  1236. /**
  1237. * The base implementation of `_.times` without support for iteratee shorthands
  1238. * or max array length checks.
  1239. *
  1240. * @private
  1241. * @param {number} n The number of times to invoke `iteratee`.
  1242. * @param {Function} iteratee The function invoked per iteration.
  1243. * @returns {Array} Returns the array of results.
  1244. */
  1245. function baseTimes(n, iteratee) {
  1246. var index = -1,
  1247. result = Array(n);
  1248. while (++index < n) {
  1249. result[index] = iteratee(index);
  1250. }
  1251. return result;
  1252. }
  1253. /** `Object#toString` result references. */
  1254. var argsTag$1 = '[object Arguments]';
  1255. /**
  1256. * The base implementation of `_.isArguments`.
  1257. *
  1258. * @private
  1259. * @param {*} value The value to check.
  1260. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  1261. */
  1262. function baseIsArguments(value) {
  1263. return isObjectLike(value) && baseGetTag(value) == argsTag$1;
  1264. }
  1265. /** Used for built-in method references. */
  1266. var objectProto$2 = Object.prototype;
  1267. /** Used to check objects for own properties. */
  1268. var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
  1269. /** Built-in value references. */
  1270. var propertyIsEnumerable = objectProto$2.propertyIsEnumerable;
  1271. /**
  1272. * Checks if `value` is likely an `arguments` object.
  1273. *
  1274. * @static
  1275. * @memberOf _
  1276. * @since 0.1.0
  1277. * @category Lang
  1278. * @param {*} value The value to check.
  1279. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  1280. * else `false`.
  1281. * @example
  1282. *
  1283. * _.isArguments(function() { return arguments; }());
  1284. * // => true
  1285. *
  1286. * _.isArguments([1, 2, 3]);
  1287. * // => false
  1288. */
  1289. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  1290. return isObjectLike(value) && hasOwnProperty$2.call(value, 'callee') &&
  1291. !propertyIsEnumerable.call(value, 'callee');
  1292. };
  1293. /**
  1294. * This method returns `false`.
  1295. *
  1296. * @static
  1297. * @memberOf _
  1298. * @since 4.13.0
  1299. * @category Util
  1300. * @returns {boolean} Returns `false`.
  1301. * @example
  1302. *
  1303. * _.times(2, _.stubFalse);
  1304. * // => [false, false]
  1305. */
  1306. function stubFalse() {
  1307. return false;
  1308. }
  1309. /** Detect free variable `exports`. */
  1310. var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
  1311. /** Detect free variable `module`. */
  1312. var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
  1313. /** Detect the popular CommonJS extension `module.exports`. */
  1314. var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
  1315. /** Built-in value references. */
  1316. var Buffer = moduleExports$1 ? root.Buffer : undefined;
  1317. /* Built-in method references for those with the same name as other `lodash` methods. */
  1318. var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
  1319. /**
  1320. * Checks if `value` is a buffer.
  1321. *
  1322. * @static
  1323. * @memberOf _
  1324. * @since 4.3.0
  1325. * @category Lang
  1326. * @param {*} value The value to check.
  1327. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  1328. * @example
  1329. *
  1330. * _.isBuffer(new Buffer(2));
  1331. * // => true
  1332. *
  1333. * _.isBuffer(new Uint8Array(2));
  1334. * // => false
  1335. */
  1336. var isBuffer = nativeIsBuffer || stubFalse;
  1337. /** `Object#toString` result references. */
  1338. var argsTag = '[object Arguments]',
  1339. arrayTag = '[object Array]',
  1340. boolTag = '[object Boolean]',
  1341. dateTag = '[object Date]',
  1342. errorTag = '[object Error]',
  1343. funcTag = '[object Function]',
  1344. mapTag = '[object Map]',
  1345. numberTag = '[object Number]',
  1346. objectTag = '[object Object]',
  1347. regexpTag = '[object RegExp]',
  1348. setTag = '[object Set]',
  1349. stringTag = '[object String]',
  1350. weakMapTag = '[object WeakMap]';
  1351. var arrayBufferTag = '[object ArrayBuffer]',
  1352. dataViewTag = '[object DataView]',
  1353. float32Tag = '[object Float32Array]',
  1354. float64Tag = '[object Float64Array]',
  1355. int8Tag = '[object Int8Array]',
  1356. int16Tag = '[object Int16Array]',
  1357. int32Tag = '[object Int32Array]',
  1358. uint8Tag = '[object Uint8Array]',
  1359. uint8ClampedTag = '[object Uint8ClampedArray]',
  1360. uint16Tag = '[object Uint16Array]',
  1361. uint32Tag = '[object Uint32Array]';
  1362. /** Used to identify `toStringTag` values of typed arrays. */
  1363. var typedArrayTags = {};
  1364. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  1365. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  1366. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  1367. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  1368. typedArrayTags[uint32Tag] = true;
  1369. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  1370. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  1371. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  1372. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  1373. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  1374. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  1375. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  1376. typedArrayTags[weakMapTag] = false;
  1377. /**
  1378. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  1379. *
  1380. * @private
  1381. * @param {*} value The value to check.
  1382. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  1383. */
  1384. function baseIsTypedArray(value) {
  1385. return isObjectLike(value) &&
  1386. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  1387. }
  1388. /**
  1389. * The base implementation of `_.unary` without support for storing metadata.
  1390. *
  1391. * @private
  1392. * @param {Function} func The function to cap arguments for.
  1393. * @returns {Function} Returns the new capped function.
  1394. */
  1395. function baseUnary(func) {
  1396. return function(value) {
  1397. return func(value);
  1398. };
  1399. }
  1400. /** Detect free variable `exports`. */
  1401. var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
  1402. /** Detect free variable `module`. */
  1403. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  1404. /** Detect the popular CommonJS extension `module.exports`. */
  1405. var moduleExports = freeModule && freeModule.exports === freeExports;
  1406. /** Detect free variable `process` from Node.js. */
  1407. var freeProcess = moduleExports && freeGlobal.process;
  1408. /** Used to access faster Node.js helpers. */
  1409. var nodeUtil = (function() {
  1410. try {
  1411. // Use `util.types` for Node.js 10+.
  1412. var types = freeModule && freeModule.require && freeModule.require('util').types;
  1413. if (types) {
  1414. return types;
  1415. }
  1416. // Legacy `process.binding('util')` for Node.js < 10.
  1417. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  1418. } catch (e) {}
  1419. }());
  1420. /* Node.js helper references. */
  1421. var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  1422. /**
  1423. * Checks if `value` is classified as a typed array.
  1424. *
  1425. * @static
  1426. * @memberOf _
  1427. * @since 3.0.0
  1428. * @category Lang
  1429. * @param {*} value The value to check.
  1430. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  1431. * @example
  1432. *
  1433. * _.isTypedArray(new Uint8Array);
  1434. * // => true
  1435. *
  1436. * _.isTypedArray([]);
  1437. * // => false
  1438. */
  1439. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  1440. /** Used for built-in method references. */
  1441. var objectProto$1 = Object.prototype;
  1442. /** Used to check objects for own properties. */
  1443. var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
  1444. /**
  1445. * Creates an array of the enumerable property names of the array-like `value`.
  1446. *
  1447. * @private
  1448. * @param {*} value The value to query.
  1449. * @param {boolean} inherited Specify returning inherited property names.
  1450. * @returns {Array} Returns the array of property names.
  1451. */
  1452. function arrayLikeKeys(value, inherited) {
  1453. var isArr = isArray(value),
  1454. isArg = !isArr && isArguments(value),
  1455. isBuff = !isArr && !isArg && isBuffer(value),
  1456. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  1457. skipIndexes = isArr || isArg || isBuff || isType,
  1458. result = skipIndexes ? baseTimes(value.length, String) : [],
  1459. length = result.length;
  1460. for (var key in value) {
  1461. if ((inherited || hasOwnProperty$1.call(value, key)) &&
  1462. !(skipIndexes && (
  1463. // Safari 9 has enumerable `arguments.length` in strict mode.
  1464. key == 'length' ||
  1465. // Node.js 0.10 has enumerable non-index properties on buffers.
  1466. (isBuff && (key == 'offset' || key == 'parent')) ||
  1467. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  1468. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  1469. // Skip index properties.
  1470. isIndex(key, length)
  1471. ))) {
  1472. result.push(key);
  1473. }
  1474. }
  1475. return result;
  1476. }
  1477. /**
  1478. * This function is like
  1479. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  1480. * except that it includes inherited enumerable properties.
  1481. *
  1482. * @private
  1483. * @param {Object} object The object to query.
  1484. * @returns {Array} Returns the array of property names.
  1485. */
  1486. function nativeKeysIn(object) {
  1487. var result = [];
  1488. if (object != null) {
  1489. for (var key in Object(object)) {
  1490. result.push(key);
  1491. }
  1492. }
  1493. return result;
  1494. }
  1495. /** Used for built-in method references. */
  1496. var objectProto = Object.prototype;
  1497. /** Used to check objects for own properties. */
  1498. var hasOwnProperty = objectProto.hasOwnProperty;
  1499. /**
  1500. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  1501. *
  1502. * @private
  1503. * @param {Object} object The object to query.
  1504. * @returns {Array} Returns the array of property names.
  1505. */
  1506. function baseKeysIn(object) {
  1507. if (!isObject(object)) {
  1508. return nativeKeysIn(object);
  1509. }
  1510. var isProto = isPrototype(object),
  1511. result = [];
  1512. for (var key in object) {
  1513. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  1514. result.push(key);
  1515. }
  1516. }
  1517. return result;
  1518. }
  1519. /**
  1520. * Creates an array of the own and inherited enumerable property names of `object`.
  1521. *
  1522. * **Note:** Non-object values are coerced to objects.
  1523. *
  1524. * @static
  1525. * @memberOf _
  1526. * @since 3.0.0
  1527. * @category Object
  1528. * @param {Object} object The object to query.
  1529. * @returns {Array} Returns the array of property names.
  1530. * @example
  1531. *
  1532. * function Foo() {
  1533. * this.a = 1;
  1534. * this.b = 2;
  1535. * }
  1536. *
  1537. * Foo.prototype.c = 3;
  1538. *
  1539. * _.keysIn(new Foo);
  1540. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  1541. */
  1542. function keysIn(object) {
  1543. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  1544. }
  1545. /**
  1546. * Converts `value` to a string. An empty string is returned for `null`
  1547. * and `undefined` values. The sign of `-0` is preserved.
  1548. *
  1549. * @static
  1550. * @memberOf _
  1551. * @since 4.0.0
  1552. * @category Lang
  1553. * @param {*} value The value to convert.
  1554. * @returns {string} Returns the converted string.
  1555. * @example
  1556. *
  1557. * _.toString(null);
  1558. * // => ''
  1559. *
  1560. * _.toString(-0);
  1561. * // => '-0'
  1562. *
  1563. * _.toString([1, 2, 3]);
  1564. * // => '1,2,3'
  1565. */
  1566. function toString(value) {
  1567. return value == null ? '' : baseToString(value);
  1568. }
  1569. /**
  1570. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  1571. *
  1572. * @private
  1573. * @param {boolean} [fromRight] Specify iterating from right to left.
  1574. * @returns {Function} Returns the new base function.
  1575. */
  1576. function createBaseFor(fromRight) {
  1577. return function(object, iteratee, keysFunc) {
  1578. var index = -1,
  1579. iterable = Object(object),
  1580. props = keysFunc(object),
  1581. length = props.length;
  1582. while (length--) {
  1583. var key = props[fromRight ? length : ++index];
  1584. if (iteratee(iterable[key], key, iterable) === false) {
  1585. break;
  1586. }
  1587. }
  1588. return object;
  1589. };
  1590. }
  1591. /**
  1592. * The base implementation of `baseForOwn` which iterates over `object`
  1593. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  1594. * Iteratee functions may exit iteration early by explicitly returning `false`.
  1595. *
  1596. * @private
  1597. * @param {Object} object The object to iterate over.
  1598. * @param {Function} iteratee The function invoked per iteration.
  1599. * @param {Function} keysFunc The function to get the keys of `object`.
  1600. * @returns {Object} Returns `object`.
  1601. */
  1602. var baseFor = createBaseFor();
  1603. /**
  1604. * Gets the timestamp of the number of milliseconds that have elapsed since
  1605. * the Unix epoch (1 January 1970 00:00:00 UTC).
  1606. *
  1607. * @static
  1608. * @memberOf _
  1609. * @since 2.4.0
  1610. * @category Date
  1611. * @returns {number} Returns the timestamp.
  1612. * @example
  1613. *
  1614. * _.defer(function(stamp) {
  1615. * console.log(_.now() - stamp);
  1616. * }, _.now());
  1617. * // => Logs the number of milliseconds it took for the deferred invocation.
  1618. */
  1619. var now = function() {
  1620. return root.Date.now();
  1621. };
  1622. /** Error message constants. */
  1623. var FUNC_ERROR_TEXT$1 = 'Expected a function';
  1624. /* Built-in method references for those with the same name as other `lodash` methods. */
  1625. var nativeMax = Math.max,
  1626. nativeMin = Math.min;
  1627. /**
  1628. * Creates a debounced function that delays invoking `func` until after `wait`
  1629. * milliseconds have elapsed since the last time the debounced function was
  1630. * invoked. The debounced function comes with a `cancel` method to cancel
  1631. * delayed `func` invocations and a `flush` method to immediately invoke them.
  1632. * Provide `options` to indicate whether `func` should be invoked on the
  1633. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  1634. * with the last arguments provided to the debounced function. Subsequent
  1635. * calls to the debounced function return the result of the last `func`
  1636. * invocation.
  1637. *
  1638. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  1639. * invoked on the trailing edge of the timeout only if the debounced function
  1640. * is invoked more than once during the `wait` timeout.
  1641. *
  1642. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  1643. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  1644. *
  1645. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  1646. * for details over the differences between `_.debounce` and `_.throttle`.
  1647. *
  1648. * @static
  1649. * @memberOf _
  1650. * @since 0.1.0
  1651. * @category Function
  1652. * @param {Function} func The function to debounce.
  1653. * @param {number} [wait=0] The number of milliseconds to delay.
  1654. * @param {Object} [options={}] The options object.
  1655. * @param {boolean} [options.leading=false]
  1656. * Specify invoking on the leading edge of the timeout.
  1657. * @param {number} [options.maxWait]
  1658. * The maximum time `func` is allowed to be delayed before it's invoked.
  1659. * @param {boolean} [options.trailing=true]
  1660. * Specify invoking on the trailing edge of the timeout.
  1661. * @returns {Function} Returns the new debounced function.
  1662. * @example
  1663. *
  1664. * // Avoid costly calculations while the window size is in flux.
  1665. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  1666. *
  1667. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  1668. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  1669. * 'leading': true,
  1670. * 'trailing': false
  1671. * }));
  1672. *
  1673. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  1674. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  1675. * var source = new EventSource('/stream');
  1676. * jQuery(source).on('message', debounced);
  1677. *
  1678. * // Cancel the trailing debounced invocation.
  1679. * jQuery(window).on('popstate', debounced.cancel);
  1680. */
  1681. function debounce$1(func, wait, options) {
  1682. var lastArgs,
  1683. lastThis,
  1684. maxWait,
  1685. result,
  1686. timerId,
  1687. lastCallTime,
  1688. lastInvokeTime = 0,
  1689. leading = false,
  1690. maxing = false,
  1691. trailing = true;
  1692. if (typeof func != 'function') {
  1693. throw new TypeError(FUNC_ERROR_TEXT$1);
  1694. }
  1695. wait = toNumber(wait) || 0;
  1696. if (isObject(options)) {
  1697. leading = !!options.leading;
  1698. maxing = 'maxWait' in options;
  1699. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  1700. trailing = 'trailing' in options ? !!options.trailing : trailing;
  1701. }
  1702. function invokeFunc(time) {
  1703. var args = lastArgs,
  1704. thisArg = lastThis;
  1705. lastArgs = lastThis = undefined;
  1706. lastInvokeTime = time;
  1707. result = func.apply(thisArg, args);
  1708. return result;
  1709. }
  1710. function leadingEdge(time) {
  1711. // Reset any `maxWait` timer.
  1712. lastInvokeTime = time;
  1713. // Start the timer for the trailing edge.
  1714. timerId = setTimeout(timerExpired, wait);
  1715. // Invoke the leading edge.
  1716. return leading ? invokeFunc(time) : result;
  1717. }
  1718. function remainingWait(time) {
  1719. var timeSinceLastCall = time - lastCallTime,
  1720. timeSinceLastInvoke = time - lastInvokeTime,
  1721. timeWaiting = wait - timeSinceLastCall;
  1722. return maxing
  1723. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  1724. : timeWaiting;
  1725. }
  1726. function shouldInvoke(time) {
  1727. var timeSinceLastCall = time - lastCallTime,
  1728. timeSinceLastInvoke = time - lastInvokeTime;
  1729. // Either this is the first call, activity has stopped and we're at the
  1730. // trailing edge, the system time has gone backwards and we're treating
  1731. // it as the trailing edge, or we've hit the `maxWait` limit.
  1732. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  1733. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  1734. }
  1735. function timerExpired() {
  1736. var time = now();
  1737. if (shouldInvoke(time)) {
  1738. return trailingEdge(time);
  1739. }
  1740. // Restart the timer.
  1741. timerId = setTimeout(timerExpired, remainingWait(time));
  1742. }
  1743. function trailingEdge(time) {
  1744. timerId = undefined;
  1745. // Only invoke if we have `lastArgs` which means `func` has been
  1746. // debounced at least once.
  1747. if (trailing && lastArgs) {
  1748. return invokeFunc(time);
  1749. }
  1750. lastArgs = lastThis = undefined;
  1751. return result;
  1752. }
  1753. function cancel() {
  1754. if (timerId !== undefined) {
  1755. clearTimeout(timerId);
  1756. }
  1757. lastInvokeTime = 0;
  1758. lastArgs = lastCallTime = lastThis = timerId = undefined;
  1759. }
  1760. function flush() {
  1761. return timerId === undefined ? result : trailingEdge(now());
  1762. }
  1763. function debounced() {
  1764. var time = now(),
  1765. isInvoking = shouldInvoke(time);
  1766. lastArgs = arguments;
  1767. lastThis = this;
  1768. lastCallTime = time;
  1769. if (isInvoking) {
  1770. if (timerId === undefined) {
  1771. return leadingEdge(lastCallTime);
  1772. }
  1773. if (maxing) {
  1774. // Handle invocations in a tight loop.
  1775. clearTimeout(timerId);
  1776. timerId = setTimeout(timerExpired, wait);
  1777. return invokeFunc(lastCallTime);
  1778. }
  1779. }
  1780. if (timerId === undefined) {
  1781. timerId = setTimeout(timerExpired, wait);
  1782. }
  1783. return result;
  1784. }
  1785. debounced.cancel = cancel;
  1786. debounced.flush = flush;
  1787. return debounced;
  1788. }
  1789. /**
  1790. * Casts `value` to `identity` if it's not a function.
  1791. *
  1792. * @private
  1793. * @param {*} value The value to inspect.
  1794. * @returns {Function} Returns cast function.
  1795. */
  1796. function castFunction(value) {
  1797. return typeof value == 'function' ? value : identity;
  1798. }
  1799. /**
  1800. * Used to match `RegExp`
  1801. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  1802. */
  1803. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  1804. reHasRegExpChar = RegExp(reRegExpChar.source);
  1805. /**
  1806. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  1807. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  1808. *
  1809. * @static
  1810. * @memberOf _
  1811. * @since 3.0.0
  1812. * @category String
  1813. * @param {string} [string=''] The string to escape.
  1814. * @returns {string} Returns the escaped string.
  1815. * @example
  1816. *
  1817. * _.escapeRegExp('[lodash](https://lodash.com/)');
  1818. * // => '\[lodash\]\(https://lodash\.com/\)'
  1819. */
  1820. function escapeRegExp(string) {
  1821. string = toString(string);
  1822. return (string && reHasRegExpChar.test(string))
  1823. ? string.replace(reRegExpChar, '\\$&')
  1824. : string;
  1825. }
  1826. /**
  1827. * Iterates over own and inherited enumerable string keyed properties of an
  1828. * object and invokes `iteratee` for each property. The iteratee is invoked
  1829. * with three arguments: (value, key, object). Iteratee functions may exit
  1830. * iteration early by explicitly returning `false`.
  1831. *
  1832. * @static
  1833. * @memberOf _
  1834. * @since 0.3.0
  1835. * @category Object
  1836. * @param {Object} object The object to iterate over.
  1837. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  1838. * @returns {Object} Returns `object`.
  1839. * @see _.forInRight
  1840. * @example
  1841. *
  1842. * function Foo() {
  1843. * this.a = 1;
  1844. * this.b = 2;
  1845. * }
  1846. *
  1847. * Foo.prototype.c = 3;
  1848. *
  1849. * _.forIn(new Foo, function(value, key) {
  1850. * console.log(key);
  1851. * });
  1852. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  1853. */
  1854. function forIn(object, iteratee) {
  1855. return object == null
  1856. ? object
  1857. : baseFor(object, castFunction(iteratee), keysIn);
  1858. }
  1859. /** Error message constants. */
  1860. var FUNC_ERROR_TEXT = 'Expected a function';
  1861. /**
  1862. * Creates a throttled function that only invokes `func` at most once per
  1863. * every `wait` milliseconds. The throttled function comes with a `cancel`
  1864. * method to cancel delayed `func` invocations and a `flush` method to
  1865. * immediately invoke them. Provide `options` to indicate whether `func`
  1866. * should be invoked on the leading and/or trailing edge of the `wait`
  1867. * timeout. The `func` is invoked with the last arguments provided to the
  1868. * throttled function. Subsequent calls to the throttled function return the
  1869. * result of the last `func` invocation.
  1870. *
  1871. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  1872. * invoked on the trailing edge of the timeout only if the throttled function
  1873. * is invoked more than once during the `wait` timeout.
  1874. *
  1875. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  1876. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  1877. *
  1878. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  1879. * for details over the differences between `_.throttle` and `_.debounce`.
  1880. *
  1881. * @static
  1882. * @memberOf _
  1883. * @since 0.1.0
  1884. * @category Function
  1885. * @param {Function} func The function to throttle.
  1886. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  1887. * @param {Object} [options={}] The options object.
  1888. * @param {boolean} [options.leading=true]
  1889. * Specify invoking on the leading edge of the timeout.
  1890. * @param {boolean} [options.trailing=true]
  1891. * Specify invoking on the trailing edge of the timeout.
  1892. * @returns {Function} Returns the new throttled function.
  1893. * @example
  1894. *
  1895. * // Avoid excessively updating the position while scrolling.
  1896. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  1897. *
  1898. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  1899. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  1900. * jQuery(element).on('click', throttled);
  1901. *
  1902. * // Cancel the trailing throttled invocation.
  1903. * jQuery(window).on('popstate', throttled.cancel);
  1904. */
  1905. function throttle$1(func, wait, options) {
  1906. var leading = true,
  1907. trailing = true;
  1908. if (typeof func != 'function') {
  1909. throw new TypeError(FUNC_ERROR_TEXT);
  1910. }
  1911. if (isObject(options)) {
  1912. leading = 'leading' in options ? !!options.leading : leading;
  1913. trailing = 'trailing' in options ? !!options.trailing : trailing;
  1914. }
  1915. return debounce$1(func, wait, {
  1916. 'leading': leading,
  1917. 'maxWait': wait,
  1918. 'trailing': trailing
  1919. });
  1920. }
  1921. const observed = new Set();
  1922. let mutationObserver;
  1923. const observerOptions = { childList: true };
  1924. /**
  1925. * Helper to set up a conditional slot component on connectedCallback.
  1926. */
  1927. function connectConditionalSlotComponent(component) {
  1928. if (!mutationObserver) {
  1929. mutationObserver = createObserver("mutation", processMutations);
  1930. }
  1931. mutationObserver.observe(component.el, observerOptions);
  1932. }
  1933. /**
  1934. * Helper to tear down a conditional slot component on disconnectedCallback.
  1935. */
  1936. function disconnectConditionalSlotComponent(component) {
  1937. observed.delete(component.el);
  1938. // we explicitly process queued mutations and disconnect and reconnect
  1939. // the observer until MutationObserver gets an `unobserve` method
  1940. // see https://github.com/whatwg/dom/issues/126
  1941. processMutations(mutationObserver.takeRecords());
  1942. mutationObserver.disconnect();
  1943. for (const [element] of observed.entries()) {
  1944. mutationObserver.observe(element, observerOptions);
  1945. }
  1946. }
  1947. function processMutations(mutations) {
  1948. mutations.forEach(({ target }) => {
  1949. forceUpdate(target);
  1950. });
  1951. }
  1952. 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}";
  1953. const ActionBar = class extends HTMLElement$1 {
  1954. constructor() {
  1955. super();
  1956. this.__registerHost();
  1957. this.__attachShadow();
  1958. this.calciteActionBarToggle = createEvent(this, "calciteActionBarToggle", 7);
  1959. // --------------------------------------------------------------------------
  1960. //
  1961. // Properties
  1962. //
  1963. // --------------------------------------------------------------------------
  1964. /**
  1965. * When set to true, the expand-toggling behavior will be disabled.
  1966. */
  1967. this.expandDisabled = false;
  1968. /**
  1969. * Indicates whether widget is expanded.
  1970. */
  1971. this.expanded = false;
  1972. /**
  1973. * Disables automatically overflowing actions that won't fit into menus.
  1974. */
  1975. this.overflowActionsDisabled = false;
  1976. this.mutationObserver = createObserver("mutation", () => {
  1977. const { el, expanded } = this;
  1978. toggleChildActionText({ parent: el, expanded });
  1979. this.conditionallyOverflowActions();
  1980. });
  1981. this.resizeObserver = createObserver("resize", (entries) => this.resizeHandlerEntries(entries));
  1982. // --------------------------------------------------------------------------
  1983. //
  1984. // Private Methods
  1985. //
  1986. // --------------------------------------------------------------------------
  1987. this.actionMenuOpenChangeHandler = (event) => {
  1988. if (event.detail) {
  1989. const composedPath = event.composedPath();
  1990. Array.from(this.el.querySelectorAll("calcite-action-group")).forEach((group) => {
  1991. if (!composedPath.includes(group)) {
  1992. group.menuOpen = false;
  1993. }
  1994. });
  1995. }
  1996. };
  1997. this.resizeHandlerEntries = (entries) => {
  1998. entries.forEach(this.resizeHandler);
  1999. };
  2000. this.resizeHandler = (entry) => {
  2001. const { height } = entry.contentRect;
  2002. this.resize(height);
  2003. };
  2004. this.resize = debounce$1((height) => {
  2005. var _a;
  2006. const { el, expanded, expandDisabled } = this;
  2007. if (!height) {
  2008. return;
  2009. }
  2010. const actions = queryActions(el);
  2011. const actionCount = expandDisabled ? actions.length : actions.length + 1;
  2012. const actionGroups = Array.from(el.querySelectorAll("calcite-action-group"));
  2013. const groupCount = getSlotted(el, SLOTS$n.bottomActions) || !expandDisabled
  2014. ? actionGroups.length + 1
  2015. : actionGroups.length;
  2016. const overflowCount = getOverflowCount({
  2017. actionCount,
  2018. actionHeight: (_a = actions[0]) === null || _a === void 0 ? void 0 : _a.clientHeight,
  2019. height,
  2020. groupCount
  2021. });
  2022. overflowActions({
  2023. actionGroups,
  2024. expanded,
  2025. overflowCount
  2026. });
  2027. }, overflowActionsDebounceInMs);
  2028. this.conditionallyOverflowActions = () => {
  2029. if (!this.overflowActionsDisabled) {
  2030. this.overflowActions();
  2031. }
  2032. };
  2033. this.toggleExpand = () => {
  2034. this.expanded = !this.expanded;
  2035. this.calciteActionBarToggle.emit();
  2036. };
  2037. this.setExpandToggleRef = (el) => {
  2038. this.expandToggleEl = el;
  2039. };
  2040. }
  2041. expandHandler() {
  2042. this.conditionallyOverflowActions();
  2043. }
  2044. expandedHandler(expanded) {
  2045. toggleChildActionText({ parent: this.el, expanded });
  2046. }
  2047. overflowDisabledHandler(overflowActionsDisabled) {
  2048. overflowActionsDisabled
  2049. ? this.resizeObserver.disconnect()
  2050. : this.resizeObserver.observe(this.el);
  2051. }
  2052. // --------------------------------------------------------------------------
  2053. //
  2054. // Lifecycle
  2055. //
  2056. // --------------------------------------------------------------------------
  2057. componentDidLoad() {
  2058. this.conditionallyOverflowActions();
  2059. }
  2060. connectedCallback() {
  2061. var _a, _b;
  2062. const { el, expanded } = this;
  2063. toggleChildActionText({ parent: el, expanded });
  2064. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(el, { childList: true, subtree: true });
  2065. if (!this.overflowActionsDisabled) {
  2066. (_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.observe(el);
  2067. }
  2068. this.conditionallyOverflowActions();
  2069. connectConditionalSlotComponent(this);
  2070. }
  2071. disconnectedCallback() {
  2072. var _a, _b;
  2073. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  2074. (_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
  2075. disconnectConditionalSlotComponent(this);
  2076. }
  2077. // --------------------------------------------------------------------------
  2078. //
  2079. // Methods
  2080. //
  2081. // --------------------------------------------------------------------------
  2082. /**
  2083. * Overflows actions that won't fit into menus.
  2084. * @internal
  2085. */
  2086. async overflowActions() {
  2087. this.resize(this.el.clientHeight);
  2088. }
  2089. /** Sets focus on the component. */
  2090. async setFocus(focusId) {
  2091. if (focusId === "expand-toggle") {
  2092. await focusElement(this.expandToggleEl);
  2093. return;
  2094. }
  2095. this.el.focus();
  2096. }
  2097. // --------------------------------------------------------------------------
  2098. //
  2099. // Render Methods
  2100. //
  2101. // --------------------------------------------------------------------------
  2102. renderBottomActionGroup() {
  2103. const { expanded, expandDisabled, intlExpand, intlCollapse, el, position, toggleExpand, scale } = this;
  2104. const tooltip = getSlotted(el, SLOTS$n.expandTooltip);
  2105. const expandLabel = intlExpand || TEXT$p.expand;
  2106. const collapseLabel = intlCollapse || TEXT$p.collapse;
  2107. 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;
  2108. 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;
  2109. }
  2110. render() {
  2111. return (h(Host, { onCalciteActionMenuOpenChange: this.actionMenuOpenChangeHandler }, h("slot", null), this.renderBottomActionGroup()));
  2112. }
  2113. get el() { return this; }
  2114. static get watchers() { return {
  2115. "expandDisabled": ["expandHandler"],
  2116. "expanded": ["expandedHandler"],
  2117. "overflowActionsDisabled": ["overflowDisabledHandler"]
  2118. }; }
  2119. static get style() { return actionBarCss; }
  2120. };
  2121. 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)}";
  2122. const ActionGroup = class extends HTMLElement$1 {
  2123. constructor() {
  2124. super();
  2125. this.__registerHost();
  2126. this.__attachShadow();
  2127. // --------------------------------------------------------------------------
  2128. //
  2129. // Properties
  2130. //
  2131. // --------------------------------------------------------------------------
  2132. /**
  2133. * Indicates whether widget is expanded.
  2134. */
  2135. this.expanded = false;
  2136. /**
  2137. * Indicates the horizontal, vertical, or grid layout of the component.
  2138. */
  2139. this.layout = "vertical";
  2140. /**
  2141. * Opens the action menu.
  2142. */
  2143. this.menuOpen = false;
  2144. // --------------------------------------------------------------------------
  2145. //
  2146. // Private Methods
  2147. //
  2148. // --------------------------------------------------------------------------
  2149. this.setMenuOpen = (event) => {
  2150. this.menuOpen = !!event.detail;
  2151. };
  2152. }
  2153. expandedHandler() {
  2154. this.menuOpen = false;
  2155. }
  2156. // --------------------------------------------------------------------------
  2157. //
  2158. // Lifecycle
  2159. //
  2160. // --------------------------------------------------------------------------
  2161. connectedCallback() {
  2162. connectConditionalSlotComponent(this);
  2163. }
  2164. disconnectedCallback() {
  2165. disconnectConditionalSlotComponent(this);
  2166. }
  2167. // --------------------------------------------------------------------------
  2168. //
  2169. // Component Methods
  2170. //
  2171. // --------------------------------------------------------------------------
  2172. renderTooltip() {
  2173. const { el } = this;
  2174. const hasTooltip = getSlotted(el, SLOTS$o.menuTooltip);
  2175. return hasTooltip ? h("slot", { name: SLOTS$o.menuTooltip, slot: SLOTS$p.tooltip }) : null;
  2176. }
  2177. renderMenu() {
  2178. const { el, expanded, intlMore, menuOpen, scale } = this;
  2179. const hasMenuItems = getSlotted(el, SLOTS$o.menuActions);
  2180. 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;
  2181. }
  2182. render() {
  2183. return (h(Fragment, null, h("slot", null), this.renderMenu()));
  2184. }
  2185. get el() { return this; }
  2186. static get watchers() { return {
  2187. "expanded": ["expandedHandler"]
  2188. }; }
  2189. static get style() { return actionGroupCss; }
  2190. };
  2191. function getRoundRobinIndex(index, total) {
  2192. return (index + total) % total;
  2193. }
  2194. 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}";
  2195. const SUPPORTED_BUTTON_NAV_KEYS = ["ArrowUp", "ArrowDown"];
  2196. const SUPPORTED_MENU_NAV_KEYS = ["ArrowUp", "ArrowDown", "End", "Home"];
  2197. const ActionMenu = class extends HTMLElement$1 {
  2198. constructor() {
  2199. super();
  2200. this.__registerHost();
  2201. this.__attachShadow();
  2202. this.calciteActionMenuOpenChange = createEvent(this, "calciteActionMenuOpenChange", 7);
  2203. // --------------------------------------------------------------------------
  2204. //
  2205. // Properties
  2206. //
  2207. // --------------------------------------------------------------------------
  2208. /**
  2209. * Indicates whether widget is expanded.
  2210. */
  2211. this.expanded = false;
  2212. /**
  2213. * Opens the action menu.
  2214. */
  2215. this.open = false;
  2216. /** Describes the type of positioning to use for the overlaid content. If your element is in a fixed container, use the 'fixed' value. */
  2217. this.overlayPositioning = "absolute";
  2218. /**
  2219. * Determines where the component will be positioned relative to the referenceElement.
  2220. * @see [PopperPlacement](https://github.com/Esri/calcite-components/blob/master/src/utils/popper.ts#L25)
  2221. */
  2222. this.placement = "auto";
  2223. this.actionElements = [];
  2224. this.mutationObserver = createObserver("mutation", () => this.getActions());
  2225. this.guid = `calcite-action-menu-${guid()}`;
  2226. this.menuId = `${this.guid}-menu`;
  2227. this.menuButtonId = `${this.guid}-menu-button`;
  2228. this.activeMenuItemIndex = -1;
  2229. // --------------------------------------------------------------------------
  2230. //
  2231. // Component Methods
  2232. //
  2233. // --------------------------------------------------------------------------
  2234. this.connectMenuButtonEl = () => {
  2235. const { el, menuButtonId, menuId, open, label } = this;
  2236. const menuButtonEl = getSlotted(el, SLOTS$p.trigger) || this.defaultMenuButtonEl;
  2237. if (this.menuButtonEl === menuButtonEl) {
  2238. return;
  2239. }
  2240. this.disconnectMenuButtonEl();
  2241. this.menuButtonEl = menuButtonEl;
  2242. this.setTooltipReferenceElement();
  2243. if (!menuButtonEl) {
  2244. return;
  2245. }
  2246. menuButtonEl.active = open;
  2247. menuButtonEl.setAttribute("aria-controls", menuId);
  2248. menuButtonEl.setAttribute("aria-expanded", toAriaBoolean(open));
  2249. menuButtonEl.setAttribute("aria-haspopup", "true");
  2250. if (!menuButtonEl.id) {
  2251. menuButtonEl.id = menuButtonId;
  2252. }
  2253. if (!menuButtonEl.label) {
  2254. menuButtonEl.label = label;
  2255. }
  2256. if (!menuButtonEl.text) {
  2257. menuButtonEl.text = label;
  2258. }
  2259. menuButtonEl.addEventListener("click", this.menuButtonClick);
  2260. menuButtonEl.addEventListener("keydown", this.menuButtonKeyDown);
  2261. menuButtonEl.addEventListener("keyup", this.menuButtonKeyUp);
  2262. };
  2263. this.disconnectMenuButtonEl = () => {
  2264. const { menuButtonEl } = this;
  2265. if (!menuButtonEl) {
  2266. return;
  2267. }
  2268. menuButtonEl.removeEventListener("click", this.menuButtonClick);
  2269. menuButtonEl.removeEventListener("keydown", this.menuButtonKeyDown);
  2270. menuButtonEl.removeEventListener("keyup", this.menuButtonKeyUp);
  2271. };
  2272. this.setDefaultMenuButtonEl = (el) => {
  2273. this.defaultMenuButtonEl = el;
  2274. this.connectMenuButtonEl();
  2275. };
  2276. // --------------------------------------------------------------------------
  2277. //
  2278. // Private Methods
  2279. //
  2280. // --------------------------------------------------------------------------
  2281. this.handleCalciteActionClick = () => {
  2282. this.open = false;
  2283. this.setFocus();
  2284. };
  2285. this.menuButtonClick = () => {
  2286. this.toggleOpen();
  2287. };
  2288. this.updateTooltip = (event) => {
  2289. const tooltips = event.target
  2290. .assignedElements({
  2291. flatten: true
  2292. })
  2293. .filter((el) => el === null || el === void 0 ? void 0 : el.matches("calcite-tooltip"));
  2294. this.tooltipEl = tooltips[0];
  2295. this.setTooltipReferenceElement();
  2296. };
  2297. this.setTooltipReferenceElement = () => {
  2298. const { tooltipEl, expanded, menuButtonEl } = this;
  2299. if (tooltipEl) {
  2300. tooltipEl.referenceElement = !expanded ? menuButtonEl : null;
  2301. }
  2302. };
  2303. this.updateAction = (action, index) => {
  2304. const { guid, activeMenuItemIndex } = this;
  2305. const id = `${guid}-action-${index}`;
  2306. action.tabIndex = -1;
  2307. action.setAttribute("role", "menuitem");
  2308. if (!action.id) {
  2309. action.id = id;
  2310. }
  2311. action.active = index === activeMenuItemIndex;
  2312. };
  2313. this.updateActions = (actions) => {
  2314. actions === null || actions === void 0 ? void 0 : actions.forEach(this.updateAction);
  2315. };
  2316. this.getActions = () => {
  2317. const { el } = this;
  2318. const actionElements = getSlotted(el, { all: true, matches: "calcite-action" });
  2319. this.updateActions(actionElements);
  2320. this.actionElements = actionElements;
  2321. this.connectMenuButtonEl();
  2322. };
  2323. this.menuButtonKeyUp = (event) => {
  2324. const { key } = event;
  2325. const { actionElements } = this;
  2326. if (!this.isValidKey(key, SUPPORTED_BUTTON_NAV_KEYS)) {
  2327. return;
  2328. }
  2329. event.preventDefault();
  2330. if (!actionElements.length) {
  2331. return;
  2332. }
  2333. this.toggleOpen(true);
  2334. this.handleActionNavigation(key, actionElements);
  2335. };
  2336. this.menuButtonKeyDown = (event) => {
  2337. const { key } = event;
  2338. if (!this.isValidKey(key, SUPPORTED_BUTTON_NAV_KEYS)) {
  2339. return;
  2340. }
  2341. event.preventDefault();
  2342. };
  2343. this.menuActionsContainerKeyDown = (event) => {
  2344. const { key } = event;
  2345. const { actionElements, activeMenuItemIndex } = this;
  2346. if (key === "Tab") {
  2347. this.open = false;
  2348. return;
  2349. }
  2350. if (key === " " || key === "Enter") {
  2351. event.preventDefault();
  2352. const action = actionElements[activeMenuItemIndex];
  2353. action ? action.click() : this.toggleOpen(false);
  2354. return;
  2355. }
  2356. if (this.isValidKey(key, SUPPORTED_MENU_NAV_KEYS)) {
  2357. event.preventDefault();
  2358. }
  2359. };
  2360. this.menuActionsContainerKeyUp = (event) => {
  2361. const { key } = event;
  2362. const { actionElements } = this;
  2363. if (key === "Escape") {
  2364. this.toggleOpen(false);
  2365. return;
  2366. }
  2367. if (!this.isValidKey(key, SUPPORTED_MENU_NAV_KEYS)) {
  2368. return;
  2369. }
  2370. event.preventDefault();
  2371. if (!actionElements.length) {
  2372. return;
  2373. }
  2374. this.handleActionNavigation(key, actionElements);
  2375. };
  2376. this.handleActionNavigation = (key, actions) => {
  2377. const currentIndex = this.activeMenuItemIndex;
  2378. if (key === "Home") {
  2379. this.activeMenuItemIndex = 0;
  2380. }
  2381. if (key === "End") {
  2382. this.activeMenuItemIndex = actions.length - 1;
  2383. }
  2384. if (key === "ArrowUp") {
  2385. this.activeMenuItemIndex = getRoundRobinIndex(Math.max(currentIndex - 1, -1), actions.length);
  2386. }
  2387. if (key === "ArrowDown") {
  2388. this.activeMenuItemIndex = getRoundRobinIndex(currentIndex + 1, actions.length);
  2389. }
  2390. };
  2391. this.toggleOpenEnd = () => {
  2392. this.setFocus();
  2393. this.el.removeEventListener("calcitePopoverOpen", this.toggleOpenEnd);
  2394. };
  2395. this.toggleOpen = (value = !this.open) => {
  2396. this.el.addEventListener("calcitePopoverOpen", this.toggleOpenEnd);
  2397. this.open = value;
  2398. };
  2399. }
  2400. // --------------------------------------------------------------------------
  2401. //
  2402. // Lifecycle
  2403. //
  2404. // --------------------------------------------------------------------------
  2405. connectedCallback() {
  2406. var _a;
  2407. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
  2408. this.getActions();
  2409. connectConditionalSlotComponent(this);
  2410. }
  2411. disconnectedCallback() {
  2412. var _a;
  2413. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  2414. this.disconnectMenuButtonEl();
  2415. disconnectConditionalSlotComponent(this);
  2416. }
  2417. expandedHandler() {
  2418. this.open = false;
  2419. this.setTooltipReferenceElement();
  2420. }
  2421. openHandler(open) {
  2422. this.activeMenuItemIndex = this.open ? 0 : -1;
  2423. if (this.menuButtonEl) {
  2424. this.menuButtonEl.active = open;
  2425. }
  2426. this.calciteActionMenuOpenChange.emit(open);
  2427. }
  2428. closeCalciteActionMenuOnClick(event) {
  2429. const composedPath = event.composedPath();
  2430. if (composedPath.includes(this.el)) {
  2431. return;
  2432. }
  2433. this.open = false;
  2434. }
  2435. activeMenuItemIndexHandler() {
  2436. this.updateActions(this.actionElements);
  2437. }
  2438. // --------------------------------------------------------------------------
  2439. //
  2440. // Methods
  2441. //
  2442. // --------------------------------------------------------------------------
  2443. /** Sets focus on the component. */
  2444. async setFocus() {
  2445. focusElement(this.open ? this.menuEl : this.menuButtonEl);
  2446. }
  2447. renderMenuButton() {
  2448. const { label, scale } = this;
  2449. 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 })));
  2450. return menuButtonSlot;
  2451. }
  2452. renderMenuItems() {
  2453. const { actionElements, activeMenuItemIndex, open, menuId, menuButtonEl, label, placement, overlayPositioning, flipPlacements } = this;
  2454. const activeAction = actionElements[activeMenuItemIndex];
  2455. const activeDescendantId = (activeAction === null || activeAction === void 0 ? void 0 : activeAction.id) || null;
  2456. 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))));
  2457. }
  2458. render() {
  2459. return (h(Fragment, null, this.renderMenuButton(), this.renderMenuItems(), h("slot", { name: SLOTS$p.tooltip, onSlotchange: this.updateTooltip })));
  2460. }
  2461. isValidKey(key, supportedKeys) {
  2462. return !!supportedKeys.find((k) => k === key);
  2463. }
  2464. get el() { return this; }
  2465. static get watchers() { return {
  2466. "expanded": ["expandedHandler"],
  2467. "open": ["openHandler"],
  2468. "activeMenuItemIndex": ["activeMenuItemIndexHandler"]
  2469. }; }
  2470. static get style() { return actionMenuCss; }
  2471. };
  2472. const CSS$M = {
  2473. actionGroupBottom: "action-group--bottom",
  2474. container: "container"
  2475. };
  2476. const TEXT$o = {
  2477. expand: "Expand",
  2478. collapse: "Collapse"
  2479. };
  2480. const SLOTS$m = {
  2481. expandTooltip: "expand-tooltip"
  2482. };
  2483. 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}";
  2484. const ActionPad = class extends HTMLElement$1 {
  2485. constructor() {
  2486. super();
  2487. this.__registerHost();
  2488. this.__attachShadow();
  2489. this.calciteActionPadToggle = createEvent(this, "calciteActionPadToggle", 7);
  2490. // --------------------------------------------------------------------------
  2491. //
  2492. // Properties
  2493. //
  2494. // --------------------------------------------------------------------------
  2495. /**
  2496. * When set to true, the expand-toggling behavior will be disabled.
  2497. */
  2498. this.expandDisabled = false;
  2499. /**
  2500. * Indicates whether widget is expanded.
  2501. */
  2502. this.expanded = false;
  2503. /**
  2504. * Indicates the horizontal or vertical layout of the component.
  2505. */
  2506. this.layout = "vertical";
  2507. // --------------------------------------------------------------------------
  2508. //
  2509. // Private Methods
  2510. //
  2511. // --------------------------------------------------------------------------
  2512. this.actionMenuOpenChangeHandler = (event) => {
  2513. if (event.detail) {
  2514. const composedPath = event.composedPath();
  2515. Array.from(this.el.querySelectorAll("calcite-action-group")).forEach((group) => {
  2516. if (!composedPath.includes(group)) {
  2517. group.menuOpen = false;
  2518. }
  2519. });
  2520. }
  2521. };
  2522. this.toggleExpand = () => {
  2523. this.expanded = !this.expanded;
  2524. this.calciteActionPadToggle.emit();
  2525. };
  2526. this.setExpandToggleRef = (el) => {
  2527. this.expandToggleEl = el;
  2528. };
  2529. }
  2530. expandedHandler(expanded) {
  2531. toggleChildActionText({ parent: this.el, expanded });
  2532. }
  2533. // --------------------------------------------------------------------------
  2534. //
  2535. // Lifecycle
  2536. //
  2537. // --------------------------------------------------------------------------
  2538. connectedCallback() {
  2539. connectConditionalSlotComponent(this);
  2540. }
  2541. disconnectedCallback() {
  2542. disconnectConditionalSlotComponent(this);
  2543. }
  2544. componentWillLoad() {
  2545. const { el, expanded } = this;
  2546. toggleChildActionText({ parent: el, expanded });
  2547. }
  2548. // --------------------------------------------------------------------------
  2549. //
  2550. // Methods
  2551. //
  2552. // --------------------------------------------------------------------------
  2553. /** Sets focus on the component. */
  2554. async setFocus(focusId) {
  2555. if (focusId === "expand-toggle") {
  2556. await focusElement(this.expandToggleEl);
  2557. return;
  2558. }
  2559. this.el.focus();
  2560. }
  2561. // --------------------------------------------------------------------------
  2562. //
  2563. // Component Methods
  2564. //
  2565. // --------------------------------------------------------------------------
  2566. renderBottomActionGroup() {
  2567. const { expanded, expandDisabled, intlExpand, intlCollapse, el, position, toggleExpand, scale } = this;
  2568. const tooltip = getSlotted(el, SLOTS$m.expandTooltip);
  2569. const expandLabel = intlExpand || TEXT$o.expand;
  2570. const collapseLabel = intlCollapse || TEXT$o.collapse;
  2571. 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;
  2572. return expandToggleNode ? (h("calcite-action-group", { class: CSS$M.actionGroupBottom, scale: scale }, h("slot", { name: SLOTS$m.expandTooltip }), expandToggleNode)) : null;
  2573. }
  2574. render() {
  2575. return (h(Host, { onCalciteActionMenuOpenChange: this.actionMenuOpenChangeHandler }, h("div", { class: CSS$M.container }, h("slot", null), this.renderBottomActionGroup())));
  2576. }
  2577. get el() { return this; }
  2578. static get watchers() { return {
  2579. "expanded": ["expandedHandler"]
  2580. }; }
  2581. static get style() { return actionPadCss; }
  2582. };
  2583. const TEXT$n = {
  2584. intlClose: "Close"
  2585. };
  2586. const DURATIONS = {
  2587. slow: 14000,
  2588. medium: 10000,
  2589. fast: 6000
  2590. };
  2591. const SLOTS$l = {
  2592. title: "title",
  2593. message: "message",
  2594. link: "link"
  2595. };
  2596. var StatusIcons;
  2597. (function (StatusIcons) {
  2598. StatusIcons["green"] = "checkCircle";
  2599. StatusIcons["yellow"] = "exclamationMarkTriangle";
  2600. StatusIcons["red"] = "exclamationMarkTriangle";
  2601. StatusIcons["blue"] = "lightbulb";
  2602. })(StatusIcons || (StatusIcons = {}));
  2603. 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}}";
  2604. const Alert = class extends HTMLElement$1 {
  2605. constructor() {
  2606. super();
  2607. this.__registerHost();
  2608. this.__attachShadow();
  2609. this.calciteAlertClose = createEvent(this, "calciteAlertClose", 7);
  2610. this.calciteAlertOpen = createEvent(this, "calciteAlertOpen", 7);
  2611. this.calciteAlertSync = createEvent(this, "calciteAlertSync", 7);
  2612. this.calciteAlertRegister = createEvent(this, "calciteAlertRegister", 7);
  2613. //--------------------------------------------------------------------------
  2614. //
  2615. // Properties
  2616. //
  2617. //---------------------------------------------------------------------------
  2618. /** Is the alert currently active or not */
  2619. this.active = false;
  2620. /** Close the alert automatically (recommended for passive, non-blocking alerts) */
  2621. this.autoDismiss = false;
  2622. /** Duration of autoDismiss (only used with `autoDismiss`) */
  2623. this.autoDismissDuration = this.autoDismiss ? "medium" : null;
  2624. /** Color for the alert (will apply to top border and icon) */
  2625. this.color = "blue";
  2626. /** string to override English close text
  2627. * @default "Close"
  2628. */
  2629. this.intlClose = TEXT$n.intlClose;
  2630. /** specify the placement of the alert */
  2631. this.placement = "bottom";
  2632. /** specify the scale of the alert, defaults to m */
  2633. this.scale = "m";
  2634. //--------------------------------------------------------------------------
  2635. //
  2636. // Private State/Props
  2637. //
  2638. //--------------------------------------------------------------------------
  2639. /** the list of queued alerts */
  2640. this.queue = [];
  2641. /** the count of queued alerts */
  2642. this.queueLength = 0;
  2643. /** is the alert queued */
  2644. this.queued = false;
  2645. this.autoDismissTimeoutId = null;
  2646. this.trackTimer = Date.now();
  2647. this.activeTransitionProp = "opacity";
  2648. /** close and emit the closed alert and the queue */
  2649. this.closeAlert = () => {
  2650. this.autoDismissTimeoutId = null;
  2651. this.queued = false;
  2652. this.active = false;
  2653. this.queue = this.queue.filter((e) => e !== this.el);
  2654. this.determineActiveAlert();
  2655. this.calciteAlertSync.emit({ queue: this.queue });
  2656. };
  2657. this.transitionEnd = (event) => {
  2658. if (event.propertyName === this.activeTransitionProp) {
  2659. this.active
  2660. ? this.calciteAlertOpen.emit({
  2661. el: this.el,
  2662. queue: this.queue
  2663. })
  2664. : this.calciteAlertClose.emit({
  2665. el: this.el,
  2666. queue: this.queue
  2667. });
  2668. }
  2669. };
  2670. }
  2671. watchActive() {
  2672. if (this.active && !this.queued) {
  2673. this.calciteAlertRegister.emit();
  2674. }
  2675. if (!this.active) {
  2676. this.queue = this.queue.filter((e) => e !== this.el);
  2677. this.calciteAlertSync.emit({ queue: this.queue });
  2678. }
  2679. }
  2680. updateRequestedIcon() {
  2681. this.requestedIcon = setRequestedIcon(StatusIcons, this.icon, this.color);
  2682. }
  2683. updateDuration() {
  2684. if (this.autoDismiss && this.autoDismissTimeoutId) {
  2685. window.clearTimeout(this.autoDismissTimeoutId);
  2686. this.autoDismissTimeoutId = window.setTimeout(() => this.closeAlert(), DURATIONS[this.autoDismissDuration] - (Date.now() - this.trackTimer));
  2687. }
  2688. }
  2689. //--------------------------------------------------------------------------
  2690. //
  2691. // Lifecycle
  2692. //
  2693. //--------------------------------------------------------------------------
  2694. connectedCallback() {
  2695. if (this.active && !this.queued) {
  2696. this.calciteAlertRegister.emit();
  2697. }
  2698. }
  2699. componentWillLoad() {
  2700. this.requestedIcon = setRequestedIcon(StatusIcons, this.icon, this.color);
  2701. }
  2702. disconnectedCallback() {
  2703. window.clearTimeout(this.autoDismissTimeoutId);
  2704. }
  2705. render() {
  2706. 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" })));
  2707. const queueText = `+${this.queueLength > 2 ? this.queueLength - 1 : 1}`;
  2708. const queueCount = (h("div", { class: `${this.queueLength > 1 ? "active " : ""}alert-queue-count` }, h("calcite-chip", { scale: this.scale, value: queueText }, queueText)));
  2709. const { active, autoDismiss, label, placement, queued, requestedIcon } = this;
  2710. const role = autoDismiss ? "alert" : "alertdialog";
  2711. const hidden = !active;
  2712. return (h(Host, { "aria-hidden": toAriaBoolean(hidden), "aria-label": label, "calcite-hydrated-hidden": hidden, role: role }, h("div", { class: {
  2713. container: true,
  2714. queued,
  2715. [placement]: true
  2716. }, 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)));
  2717. }
  2718. // when an alert is opened or closed, update queue and determine active alert
  2719. alertSync(event) {
  2720. if (this.queue !== event.detail.queue) {
  2721. this.queue = event.detail.queue;
  2722. }
  2723. this.queueLength = this.queue.length;
  2724. this.determineActiveAlert();
  2725. }
  2726. // when an alert is first registered, trigger a queue sync to get queue
  2727. alertRegister() {
  2728. if (this.active && !this.queue.includes(this.el)) {
  2729. this.queued = true;
  2730. this.queue.push(this.el);
  2731. }
  2732. this.calciteAlertSync.emit({ queue: this.queue });
  2733. this.determineActiveAlert();
  2734. }
  2735. //--------------------------------------------------------------------------
  2736. //
  2737. // Public Methods
  2738. //
  2739. //--------------------------------------------------------------------------
  2740. /** Sets focus on the component. */
  2741. async setFocus() {
  2742. const alertLinkEl = getSlotted(this.el, { selector: "calcite-link" });
  2743. if (!this.closeButton && !alertLinkEl) {
  2744. return;
  2745. }
  2746. else if (alertLinkEl) {
  2747. alertLinkEl.setFocus();
  2748. }
  2749. else if (this.closeButton) {
  2750. this.closeButton.focus();
  2751. }
  2752. }
  2753. //--------------------------------------------------------------------------
  2754. //
  2755. // Private Methods
  2756. //
  2757. //--------------------------------------------------------------------------
  2758. /** determine which alert is active */
  2759. determineActiveAlert() {
  2760. var _a;
  2761. if (((_a = this.queue) === null || _a === void 0 ? void 0 : _a[0]) === this.el) {
  2762. this.openAlert();
  2763. if (this.autoDismiss && !this.autoDismissTimeoutId) {
  2764. this.trackTimer = Date.now();
  2765. this.autoDismissTimeoutId = window.setTimeout(() => this.closeAlert(), DURATIONS[this.autoDismissDuration]);
  2766. }
  2767. }
  2768. else {
  2769. return;
  2770. }
  2771. }
  2772. /** emit the opened alert and the queue */
  2773. openAlert() {
  2774. window.clearTimeout(this.queueTimeout);
  2775. this.queueTimeout = window.setTimeout(() => (this.queued = false), 300);
  2776. }
  2777. get el() { return this; }
  2778. static get watchers() { return {
  2779. "active": ["watchActive"],
  2780. "icon": ["updateRequestedIcon"],
  2781. "color": ["updateRequestedIcon"],
  2782. "autoDismissDuration": ["updateDuration"]
  2783. }; }
  2784. static get style() { return alertCss; }
  2785. };
  2786. function rgbToHex(color) {
  2787. const { r, g, b } = color;
  2788. return `#${r.toString(16).padStart(2, "0")}${g.toString(16).padStart(2, "0")}${b
  2789. .toString(16)
  2790. .padStart(2, "0")}`.toLowerCase();
  2791. }
  2792. const hexChar = /^[0-9A-F]$/i;
  2793. const shortHandHex = /^#[0-9A-F]{3}$/i;
  2794. const longhandHex = /^#[0-9A-F]{6}$/i;
  2795. function isValidHex(hex) {
  2796. return isShorthandHex(hex) || isLonghandHex(hex);
  2797. }
  2798. function isShorthandHex(hex) {
  2799. return hex && hex.length === 4 && shortHandHex.test(hex);
  2800. }
  2801. function isLonghandHex(hex) {
  2802. return hex && hex.length === 7 && longhandHex.test(hex);
  2803. }
  2804. function normalizeHex(hex) {
  2805. hex = hex.toLowerCase();
  2806. if (!hex.startsWith("#")) {
  2807. hex = `#${hex}`;
  2808. }
  2809. if (isShorthandHex(hex)) {
  2810. return rgbToHex(hexToRGB(hex));
  2811. }
  2812. return hex;
  2813. }
  2814. function hexToRGB(hex) {
  2815. if (!isValidHex(hex)) {
  2816. return null;
  2817. }
  2818. hex = hex.replace("#", "");
  2819. if (hex.length === 3) {
  2820. const [first, second, third] = hex.split("");
  2821. const r = parseInt(`${first}${first}`, 16);
  2822. const g = parseInt(`${second}${second}`, 16);
  2823. const b = parseInt(`${third}${third}`, 16);
  2824. return { r, g, b };
  2825. }
  2826. const r = parseInt(hex.slice(0, 2), 16);
  2827. const g = parseInt(hex.slice(2, 4), 16);
  2828. const b = parseInt(hex.slice(4, 6), 16);
  2829. return { r, g, b };
  2830. }
  2831. // these utils allow users to pass enum values as strings without having to access the enum
  2832. // based on the approach suggested by https://github.com/microsoft/TypeScript/issues/17690#issuecomment-321365759,
  2833. const enumify = (x) => x;
  2834. const CSSColorMode = enumify({
  2835. HEX: "hex",
  2836. HEXA: "hexa",
  2837. RGB_CSS: "rgb-css",
  2838. RGBA_CSS: "rgba-css",
  2839. HSL_CSS: "hsl-css",
  2840. HSLA_CSS: "hsla-css"
  2841. });
  2842. const ObjectColorMode = enumify({
  2843. RGB: "rgb",
  2844. RGBA: "rgba",
  2845. HSL: "hsl",
  2846. HSLA: "hsla",
  2847. HSV: "hsv",
  2848. HSVA: "hsva"
  2849. });
  2850. function parseMode(colorValue) {
  2851. if (typeof colorValue === "string") {
  2852. if (colorValue.startsWith("#")) {
  2853. const { length } = colorValue;
  2854. if (length === 4 || length === 7) {
  2855. return CSSColorMode.HEX;
  2856. }
  2857. if (length === 5 || length === 9) {
  2858. return CSSColorMode.HEXA;
  2859. }
  2860. }
  2861. if (colorValue.startsWith("rgba(")) {
  2862. return CSSColorMode.RGBA_CSS;
  2863. }
  2864. if (colorValue.startsWith("rgb(")) {
  2865. return CSSColorMode.RGB_CSS;
  2866. }
  2867. if (colorValue.startsWith("hsl(")) {
  2868. return CSSColorMode.HSL_CSS;
  2869. }
  2870. if (colorValue.startsWith("hsla(")) {
  2871. return CSSColorMode.HSLA_CSS;
  2872. }
  2873. }
  2874. if (typeof colorValue === "object") {
  2875. if (hasChannels(colorValue, "r", "g", "b")) {
  2876. return hasChannels(colorValue, "a") ? ObjectColorMode.RGBA : ObjectColorMode.RGB;
  2877. }
  2878. if (hasChannels(colorValue, "h", "s", "l")) {
  2879. return hasChannels(colorValue, "a") ? ObjectColorMode.HSLA : ObjectColorMode.HSL;
  2880. }
  2881. if (hasChannels(colorValue, "h", "s", "v")) {
  2882. return hasChannels(colorValue, "a") ? ObjectColorMode.HSVA : ObjectColorMode.HSV;
  2883. }
  2884. }
  2885. return null;
  2886. }
  2887. function hasChannels(colorObject, ...channels) {
  2888. return channels.every((channel) => channel && colorObject && `${channel}` in colorObject);
  2889. }
  2890. function colorEqual(value1, value2) {
  2891. return (value1 === null || value1 === void 0 ? void 0 : value1.rgbNumber()) === (value2 === null || value2 === void 0 ? void 0 : value2.rgbNumber());
  2892. }
  2893. /**
  2894. * Convert a string to a valid hex by hashing its contents
  2895. * and using the hash as a seed for three distinct color values
  2896. */
  2897. function stringToHex(str) {
  2898. let hash = 0;
  2899. for (let i = 0; i < str.length; i++) {
  2900. hash = str.charCodeAt(i) + ((hash << 5) - hash);
  2901. }
  2902. let hex = "#";
  2903. for (let j = 0; j < 3; j++) {
  2904. const value = (hash >> (j * 8)) & 0xff;
  2905. hex += ("00" + value.toString(16)).substr(-2);
  2906. }
  2907. return hex;
  2908. }
  2909. /**
  2910. * Find the hue of a color given the separate RGB color channels
  2911. */
  2912. function rgbToHue(rgb) {
  2913. let { r, g, b } = rgb;
  2914. r /= 255;
  2915. g /= 255;
  2916. b /= 255;
  2917. const max = Math.max(r, g, b);
  2918. const min = Math.min(r, g, b);
  2919. const delta = max - min;
  2920. if (max === min) {
  2921. return 0;
  2922. }
  2923. let hue = (max + min) / 2;
  2924. switch (max) {
  2925. case r:
  2926. hue = (g - b) / delta + (g < b ? 6 : 0);
  2927. break;
  2928. case g:
  2929. hue = (b - r) / delta + 2;
  2930. break;
  2931. case b:
  2932. hue = (r - g) / delta + 4;
  2933. break;
  2934. }
  2935. return Math.round(hue * 60);
  2936. }
  2937. /**
  2938. * For a hex color, find the hue
  2939. * @param hex {string} - form of "#------"
  2940. */
  2941. function hexToHue(hex) {
  2942. return rgbToHue(hexToRGB(hex));
  2943. }
  2944. 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%}";
  2945. const Avatar = class extends HTMLElement$1 {
  2946. constructor() {
  2947. super();
  2948. this.__registerHost();
  2949. this.__attachShadow();
  2950. //--------------------------------------------------------------------------
  2951. //
  2952. // Properties
  2953. //
  2954. //--------------------------------------------------------------------------
  2955. /** specify the scale of the avatar, defaults to m */
  2956. this.scale = "m";
  2957. //--------------------------------------------------------------------------
  2958. //
  2959. // Private State/Props
  2960. //
  2961. //--------------------------------------------------------------------------
  2962. /** True if thumnail fails to load */
  2963. this.error = false;
  2964. }
  2965. //--------------------------------------------------------------------------
  2966. //
  2967. // Lifecycle
  2968. //
  2969. //--------------------------------------------------------------------------
  2970. render() {
  2971. return this.determineContent();
  2972. }
  2973. //--------------------------------------------------------------------------
  2974. //
  2975. // Private Methods
  2976. //
  2977. //--------------------------------------------------------------------------
  2978. determineContent() {
  2979. if (this.thumbnail && !this.error) {
  2980. return (h("img", { alt: "", class: "thumbnail", onError: () => (this.error = true), src: this.thumbnail }));
  2981. }
  2982. const initials = this.generateInitials();
  2983. const backgroundColor = this.generateFillColor();
  2984. 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 }))));
  2985. }
  2986. /**
  2987. * Generate a valid background color that is consistent and unique to this user
  2988. */
  2989. generateFillColor() {
  2990. const { userId, username, fullName, el } = this;
  2991. const theme = getThemeName(el);
  2992. const id = userId && `#${userId.substr(userId.length - 6)}`;
  2993. const name = username || fullName || "";
  2994. const hex = id && isValidHex(id) ? id : stringToHex(name);
  2995. // if there is not unique information, or an invalid hex is produced, return a default
  2996. if ((!userId && !name) || !isValidHex(hex)) {
  2997. return `var(--calcite-ui-foreground-2)`;
  2998. }
  2999. const hue = hexToHue(hex);
  3000. const l = theme === "dark" ? 20 : 90;
  3001. return `hsl(${hue}, 60%, ${l}%)`;
  3002. }
  3003. /**
  3004. * Use fullname or username to generate initials
  3005. */
  3006. generateInitials() {
  3007. const { fullName, username } = this;
  3008. if (fullName) {
  3009. return fullName
  3010. .trim()
  3011. .split(" ")
  3012. .map((name) => name.substring(0, 1))
  3013. .join("");
  3014. }
  3015. else if (username) {
  3016. return username.substring(0, 2);
  3017. }
  3018. return false;
  3019. }
  3020. get el() { return this; }
  3021. static get style() { return avatarCss; }
  3022. };
  3023. const CSS$L = {
  3024. article: "article",
  3025. content: "content",
  3026. headerContainer: "header-container",
  3027. icon: "icon",
  3028. statusIcon: "status-icon",
  3029. toggle: "toggle",
  3030. toggleIcon: "toggle-icon",
  3031. title: "title",
  3032. heading: "heading",
  3033. header: "header",
  3034. button: "button",
  3035. summary: "summary",
  3036. controlContainer: "control-container",
  3037. valid: "valid",
  3038. invalid: "invalid",
  3039. loading: "loading"
  3040. };
  3041. const TEXT$m = {
  3042. collapse: "Collapse",
  3043. expand: "Expand",
  3044. loading: "Loading",
  3045. options: "Options"
  3046. };
  3047. const SLOTS$k = {
  3048. icon: "icon",
  3049. control: "control",
  3050. headerMenuActions: "header-menu-actions"
  3051. };
  3052. const ICONS$c = {
  3053. opened: "chevron-up",
  3054. closed: "chevron-down",
  3055. valid: "check-circle",
  3056. invalid: "exclamation-mark-triangle",
  3057. refresh: "refresh"
  3058. };
  3059. const HEADING_LEVEL$7 = 4;
  3060. function constrainHeadingLevel(level) {
  3061. return Math.min(Math.max(Math.ceil(level), 1), 6);
  3062. }
  3063. const Heading = (props, children) => {
  3064. const HeadingTag = `h${props.level}`;
  3065. delete props.level;
  3066. return h(HeadingTag, Object.assign({}, props), children);
  3067. };
  3068. 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)}";
  3069. const Block = class extends HTMLElement$1 {
  3070. constructor() {
  3071. super();
  3072. this.__registerHost();
  3073. this.__attachShadow();
  3074. this.calciteBlockToggle = createEvent(this, "calciteBlockToggle", 7);
  3075. // --------------------------------------------------------------------------
  3076. //
  3077. // Properties
  3078. //
  3079. // --------------------------------------------------------------------------
  3080. /**
  3081. * When true, this block will be collapsible.
  3082. */
  3083. this.collapsible = false;
  3084. /**
  3085. * When true, disabled prevents interaction. This state shows items with lower opacity/grayed.
  3086. */
  3087. this.disabled = false;
  3088. /**
  3089. * When true, displays a drag handle in the header.
  3090. */
  3091. this.dragHandle = false;
  3092. /**
  3093. * Aria-label for collapsing the toggle and tooltip used for the toggle when expanded.
  3094. */
  3095. this.intlCollapse = TEXT$m.collapse;
  3096. /**
  3097. * Aria-label for expanding the toggle and tooltip used for the toggle when collapsed.
  3098. */
  3099. this.intlExpand = TEXT$m.expand;
  3100. /** string to override English loading text
  3101. * @default "Loading"
  3102. */
  3103. this.intlLoading = TEXT$m.loading;
  3104. /** Text string used for the actions menu
  3105. * @default "Options"
  3106. */
  3107. this.intlOptions = TEXT$m.options;
  3108. /**
  3109. * When true, content is waiting to be loaded. This state shows a busy indicator.
  3110. */
  3111. this.loading = false;
  3112. /**
  3113. * When true, the block's content will be displayed.
  3114. */
  3115. this.open = false;
  3116. this.guid = guid();
  3117. // --------------------------------------------------------------------------
  3118. //
  3119. // Private Methods
  3120. //
  3121. // --------------------------------------------------------------------------
  3122. this.onHeaderClick = () => {
  3123. this.open = !this.open;
  3124. this.calciteBlockToggle.emit();
  3125. };
  3126. }
  3127. //--------------------------------------------------------------------------
  3128. //
  3129. // Lifecycle
  3130. //
  3131. //--------------------------------------------------------------------------
  3132. componentDidRender() {
  3133. updateHostInteraction(this);
  3134. }
  3135. // --------------------------------------------------------------------------
  3136. //
  3137. // Lifecycle
  3138. //
  3139. // --------------------------------------------------------------------------
  3140. connectedCallback() {
  3141. connectConditionalSlotComponent(this);
  3142. }
  3143. disconnectedCallback() {
  3144. disconnectConditionalSlotComponent(this);
  3145. }
  3146. // --------------------------------------------------------------------------
  3147. //
  3148. // Render Methods
  3149. //
  3150. // --------------------------------------------------------------------------
  3151. renderScrim() {
  3152. const { loading } = this;
  3153. const defaultSlot = h("slot", null);
  3154. return [loading ? h("calcite-scrim", { loading: loading }) : null, defaultSlot];
  3155. }
  3156. renderIcon() {
  3157. const { el, status } = this;
  3158. const showingLoadingStatus = this.loading && !this.open;
  3159. const statusIcon = showingLoadingStatus ? ICONS$c.refresh : ICONS$c[status];
  3160. const hasIcon = getSlotted(el, SLOTS$k.icon) || statusIcon;
  3161. const iconEl = !statusIcon ? (h("slot", { key: "icon-slot", name: SLOTS$k.icon })) : (h("calcite-icon", { class: {
  3162. [CSS$L.statusIcon]: true,
  3163. [CSS$L.valid]: status == "valid",
  3164. [CSS$L.invalid]: status == "invalid",
  3165. [CSS$L.loading]: showingLoadingStatus
  3166. }, icon: statusIcon, scale: "m" }));
  3167. return hasIcon ? h("div", { class: CSS$L.icon }, iconEl) : null;
  3168. }
  3169. renderTitle() {
  3170. const { heading, headingLevel, summary } = this;
  3171. 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;
  3172. }
  3173. render() {
  3174. const { collapsible, el, intlCollapse, intlExpand, loading, open, intlLoading } = this;
  3175. const toggleLabel = open ? intlCollapse || TEXT$m.collapse : intlExpand || TEXT$m.expand;
  3176. const headerContent = (h("header", { class: CSS$L.header }, this.renderIcon(), this.renderTitle()));
  3177. const hasControl = !!getSlotted(el, SLOTS$k.control);
  3178. const hasMenuActions = !!getSlotted(el, SLOTS$k.headerMenuActions);
  3179. const collapseIcon = open ? ICONS$c.opened : ICONS$c.closed;
  3180. const { guid } = this;
  3181. const regionId = `${guid}-region`;
  3182. const buttonId = `${guid}-button`;
  3183. 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));
  3184. return (h(Host, null, h("article", { "aria-busy": toAriaBoolean(loading), class: {
  3185. [CSS$L.article]: true
  3186. } }, headerNode, h("section", { "aria-expanded": toAriaBoolean(open), "aria-labelledby": buttonId, class: CSS$L.content, hidden: !open, id: regionId }, this.renderScrim()))));
  3187. }
  3188. get el() { return this; }
  3189. static get style() { return blockCss; }
  3190. };
  3191. const CSS$K = {
  3192. content: "content",
  3193. invalid: "invalid",
  3194. toggle: "toggle",
  3195. toggleSwitch: "toggle--switch",
  3196. toggleSwitchContent: "toggle--switch__content",
  3197. toggleSwitchText: "toggle--switch__text",
  3198. sectionHeader: "section-header",
  3199. sectionHeaderText: "section-header__text",
  3200. statusIcon: "status-icon",
  3201. valid: "valid"
  3202. };
  3203. const TEXT$l = {
  3204. collapse: "Collapse",
  3205. expand: "Expand"
  3206. };
  3207. const ICONS$b = {
  3208. menuOpen: "chevron-down",
  3209. menuClosedLeft: "chevron-left",
  3210. menuClosedRight: "chevron-right",
  3211. valid: "check-circle",
  3212. invalid: "exclamation-mark-triangle"
  3213. };
  3214. 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)}";
  3215. const BlockSection = class extends HTMLElement$1 {
  3216. constructor() {
  3217. super();
  3218. this.__registerHost();
  3219. this.__attachShadow();
  3220. this.calciteBlockSectionToggle = createEvent(this, "calciteBlockSectionToggle", 7);
  3221. /**
  3222. * When true, the block's section content will be displayed.
  3223. */
  3224. this.open = false;
  3225. /**
  3226. * This property determines the look of the section toggle.
  3227. * If the value is "switch", a toggle-switch will be displayed.
  3228. * If the value is "button", a clickable header is displayed.
  3229. */
  3230. this.toggleDisplay = "button";
  3231. this.guid = guid();
  3232. // --------------------------------------------------------------------------
  3233. //
  3234. // Private Methods
  3235. //
  3236. // --------------------------------------------------------------------------
  3237. this.handleHeaderKeyDown = (event) => {
  3238. if (event.key === " " || event.key === "Enter") {
  3239. this.toggleSection();
  3240. event.preventDefault();
  3241. event.stopPropagation();
  3242. }
  3243. };
  3244. this.toggleSection = () => {
  3245. this.open = !this.open;
  3246. this.calciteBlockSectionToggle.emit();
  3247. };
  3248. }
  3249. // --------------------------------------------------------------------------
  3250. //
  3251. // Render Methods
  3252. //
  3253. // --------------------------------------------------------------------------
  3254. renderStatusIcon() {
  3255. var _a;
  3256. const { status } = this;
  3257. const statusIcon = (_a = ICONS$b[status]) !== null && _a !== void 0 ? _a : false;
  3258. const statusIconClasses = {
  3259. [CSS$K.statusIcon]: true,
  3260. [CSS$K.valid]: status == "valid",
  3261. [CSS$K.invalid]: status == "invalid"
  3262. };
  3263. return !!statusIcon ? (h("calcite-icon", { class: statusIconClasses, icon: statusIcon, scale: "s" })) : null;
  3264. }
  3265. render() {
  3266. const { el, intlCollapse, intlExpand, open, text, toggleDisplay } = this;
  3267. const dir = getElementDir(el);
  3268. const arrowIcon = open
  3269. ? ICONS$b.menuOpen
  3270. : dir === "rtl"
  3271. ? ICONS$b.menuClosedLeft
  3272. : ICONS$b.menuClosedRight;
  3273. const toggleLabel = open ? intlCollapse || TEXT$l.collapse : intlExpand || TEXT$l.expand;
  3274. const { guid } = this;
  3275. const regionId = `${guid}-region`;
  3276. const buttonId = `${guid}-button`;
  3277. const headerNode = toggleDisplay === "switch" ? (h("div", { "aria-controls": regionId, "aria-label": toggleLabel, class: {
  3278. [CSS$K.toggle]: true,
  3279. [CSS$K.toggleSwitch]: true
  3280. }, 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: {
  3281. [CSS$K.sectionHeader]: true,
  3282. [CSS$K.toggle]: true
  3283. }, id: buttonId, name: toggleLabel, onClick: this.toggleSection }, h("calcite-icon", { icon: arrowIcon, scale: "s" }), h("span", { class: CSS$K.sectionHeaderText }, text), this.renderStatusIcon()));
  3284. 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))));
  3285. }
  3286. get el() { return this; }
  3287. static get style() { return blockSectionCss; }
  3288. };
  3289. (function(prototype) {
  3290. if (typeof prototype.requestSubmit == "function") return
  3291. prototype.requestSubmit = function(submitter) {
  3292. if (submitter) {
  3293. validateSubmitter(submitter, this);
  3294. submitter.click();
  3295. } else {
  3296. submitter = document.createElement("input");
  3297. submitter.type = "submit";
  3298. submitter.hidden = true;
  3299. this.appendChild(submitter);
  3300. submitter.click();
  3301. this.removeChild(submitter);
  3302. }
  3303. };
  3304. function validateSubmitter(submitter, form) {
  3305. submitter instanceof HTMLElement || raise(TypeError, "parameter 1 is not of type 'HTMLElement'");
  3306. submitter.type == "submit" || raise(TypeError, "The specified element is not a submit button");
  3307. submitter.form == form || raise(DOMException, "The specified element is not owned by this form element", "NotFoundError");
  3308. }
  3309. function raise(errorConstructor, message, name) {
  3310. throw new errorConstructor("Failed to execute 'requestSubmit' on 'HTMLFormElement': " + message + ".", name)
  3311. }
  3312. })(HTMLFormElement.prototype);
  3313. const CSS$J = {
  3314. buttonLoader: "calcite-button--loader",
  3315. content: "content",
  3316. contentSlotted: "content--slotted",
  3317. icon: "icon",
  3318. iconStart: "icon--start",
  3319. iconEnd: "icon--end",
  3320. loadingIn: "loading-in",
  3321. loadingOut: "loading-out",
  3322. iconStartEmpty: "icon-start-empty",
  3323. iconEndEmpty: "icon-end-empty"
  3324. };
  3325. const TEXT$k = {
  3326. loading: "Loading"
  3327. };
  3328. /**
  3329. * Exported for testing purposes only
  3330. * @internal
  3331. */
  3332. const labelClickEvent = "calciteInternalLabelClick";
  3333. const labelConnectedEvent = "calciteInternalLabelConnected";
  3334. const labelDisconnectedEvent = "calciteInternaLabelDisconnected";
  3335. const labelTagName = "calcite-label";
  3336. const onLabelClickMap = new WeakMap();
  3337. const onLabelConnectedMap = new WeakMap();
  3338. const onLabelDisconnectedMap = new WeakMap();
  3339. const unlabeledComponents = new Set();
  3340. const findLabelForComponent = (componentEl) => {
  3341. const { id } = componentEl;
  3342. const forLabel = id && queryElementRoots(componentEl, { selector: `${labelTagName}[for="${id}"]` });
  3343. if (forLabel) {
  3344. return forLabel;
  3345. }
  3346. const parentLabel = closestElementCrossShadowBoundary(componentEl, labelTagName);
  3347. if (!parentLabel ||
  3348. // labelable components within other custom elements are not considered labelable
  3349. hasAncestorCustomElements(parentLabel, componentEl)) {
  3350. return null;
  3351. }
  3352. return parentLabel;
  3353. };
  3354. function hasAncestorCustomElements(label, componentEl) {
  3355. let traversedElements;
  3356. const customElementAncestorCheckEventType = "custom-element-ancestor-check";
  3357. const listener = (event) => {
  3358. event.stopImmediatePropagation();
  3359. const composedPath = event.composedPath();
  3360. traversedElements = composedPath.slice(composedPath.indexOf(componentEl), composedPath.indexOf(label));
  3361. };
  3362. label.addEventListener(customElementAncestorCheckEventType, listener, { once: true });
  3363. componentEl.dispatchEvent(new CustomEvent(customElementAncestorCheckEventType, { composed: true, bubbles: true }));
  3364. label.removeEventListener(customElementAncestorCheckEventType, listener);
  3365. const ancestorCustomElements = traversedElements
  3366. .filter((el) => el !== componentEl && el !== label)
  3367. .filter((el) => { var _a; return (_a = el.tagName) === null || _a === void 0 ? void 0 : _a.includes("-"); });
  3368. return ancestorCustomElements.length > 0;
  3369. }
  3370. /**
  3371. * Helper to set up label interactions on connectedCallback.
  3372. */
  3373. function connectLabel(component) {
  3374. const labelEl = findLabelForComponent(component.el);
  3375. if (onLabelClickMap.has(labelEl) || (!labelEl && unlabeledComponents.has(component))) {
  3376. return;
  3377. }
  3378. const boundOnLabelDisconnected = onLabelDisconnected.bind(component);
  3379. if (labelEl) {
  3380. component.labelEl = labelEl;
  3381. const boundOnLabelClick = onLabelClick.bind(component);
  3382. onLabelClickMap.set(component.labelEl, boundOnLabelClick);
  3383. component.labelEl.addEventListener(labelClickEvent, boundOnLabelClick);
  3384. unlabeledComponents.delete(component);
  3385. document.removeEventListener(labelConnectedEvent, onLabelConnectedMap.get(component));
  3386. onLabelDisconnectedMap.set(component, boundOnLabelDisconnected);
  3387. document.addEventListener(labelDisconnectedEvent, boundOnLabelDisconnected);
  3388. }
  3389. else if (!unlabeledComponents.has(component)) {
  3390. boundOnLabelDisconnected();
  3391. document.removeEventListener(labelDisconnectedEvent, onLabelDisconnectedMap.get(component));
  3392. }
  3393. }
  3394. /**
  3395. * Helper to tear down label interactions on disconnectedCallback on labelable components.
  3396. */
  3397. function disconnectLabel(component) {
  3398. unlabeledComponents.delete(component);
  3399. document.removeEventListener(labelConnectedEvent, onLabelConnectedMap.get(component));
  3400. document.removeEventListener(labelDisconnectedEvent, onLabelDisconnectedMap.get(component));
  3401. onLabelConnectedMap.delete(component);
  3402. onLabelDisconnectedMap.delete(component);
  3403. if (!component.labelEl) {
  3404. return;
  3405. }
  3406. const boundOnLabelClick = onLabelClickMap.get(component.labelEl);
  3407. component.labelEl.removeEventListener(labelClickEvent, boundOnLabelClick);
  3408. onLabelClickMap.delete(component.labelEl);
  3409. }
  3410. /**
  3411. * Helper to get the label text from a component.
  3412. */
  3413. function getLabelText(component) {
  3414. var _a, _b;
  3415. return component.label || ((_b = (_a = component.labelEl) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || "";
  3416. }
  3417. function onLabelClick(event) {
  3418. if (this.disabled) {
  3419. return;
  3420. }
  3421. const containedLabelableChildClicked = this.el.contains(event.detail.sourceEvent.target);
  3422. if (containedLabelableChildClicked) {
  3423. return;
  3424. }
  3425. this.onLabelClick(event);
  3426. }
  3427. function onLabelConnected() {
  3428. if (unlabeledComponents.has(this)) {
  3429. connectLabel(this);
  3430. }
  3431. }
  3432. function onLabelDisconnected() {
  3433. unlabeledComponents.add(this);
  3434. const boundOnLabelConnected = onLabelConnectedMap.get(this) || onLabelConnected.bind(this);
  3435. onLabelConnectedMap.set(this, boundOnLabelConnected);
  3436. document.addEventListener(labelConnectedEvent, boundOnLabelConnected);
  3437. }
  3438. /**
  3439. * Exported for testing purposes.
  3440. */
  3441. const hiddenFormInputSlotName = "hidden-form-input";
  3442. function isCheckable(component) {
  3443. return "checked" in component;
  3444. }
  3445. const onFormResetMap = new WeakMap();
  3446. const formComponentSet = new WeakSet();
  3447. function hasRegisteredFormComponentParent(form, formComponentEl) {
  3448. // we use events as a way to test for nested form-associated components across shadow bounds
  3449. const formComponentRegisterEventName = "calciteInternalFormComponentRegister";
  3450. let hasRegisteredFormComponentParent = false;
  3451. form.addEventListener(formComponentRegisterEventName, (event) => {
  3452. hasRegisteredFormComponentParent = event
  3453. .composedPath()
  3454. .some((element) => formComponentSet.has(element));
  3455. event.stopPropagation();
  3456. }, { once: true });
  3457. formComponentEl.dispatchEvent(new CustomEvent(formComponentRegisterEventName, {
  3458. bubbles: true,
  3459. composed: true
  3460. }));
  3461. return hasRegisteredFormComponentParent;
  3462. }
  3463. /**
  3464. * Helper to submit a form.
  3465. */
  3466. function submitForm(component) {
  3467. var _a;
  3468. (_a = component.formEl) === null || _a === void 0 ? void 0 : _a.requestSubmit();
  3469. }
  3470. /**
  3471. * Helper to reset a form.
  3472. */
  3473. function resetForm(component) {
  3474. var _a;
  3475. (_a = component.formEl) === null || _a === void 0 ? void 0 : _a.reset();
  3476. }
  3477. /**
  3478. * Helper to set up form interactions on connectedCallback.
  3479. */
  3480. function connectForm(component) {
  3481. const { el, value } = component;
  3482. const form = closestElementCrossShadowBoundary(el, "form");
  3483. if (!form || hasRegisteredFormComponentParent(form, el)) {
  3484. return;
  3485. }
  3486. component.formEl = form;
  3487. component.defaultValue = value;
  3488. if (isCheckable(component)) {
  3489. component.defaultChecked = component.checked;
  3490. }
  3491. const boundOnFormReset = (component.onFormReset || onFormReset).bind(component);
  3492. form.addEventListener("reset", boundOnFormReset);
  3493. onFormResetMap.set(component.el, boundOnFormReset);
  3494. formComponentSet.add(el);
  3495. }
  3496. function onFormReset() {
  3497. if (isCheckable(this)) {
  3498. this.checked = this.defaultChecked;
  3499. return;
  3500. }
  3501. this.value = this.defaultValue;
  3502. }
  3503. /**
  3504. * Helper to tear down form interactions on disconnectedCallback.
  3505. */
  3506. function disconnectForm(component) {
  3507. const { el, formEl } = component;
  3508. if (!formEl) {
  3509. return;
  3510. }
  3511. const boundOnFormReset = onFormResetMap.get(el);
  3512. formEl.removeEventListener("reset", boundOnFormReset);
  3513. onFormResetMap.delete(el);
  3514. component.formEl = null;
  3515. formComponentSet.delete(el);
  3516. }
  3517. /**
  3518. * Helper for setting the default value on initialization after connectedCallback.
  3519. *
  3520. * Note that this is only needed if the default value cannot be determined on connectedCallback.
  3521. */
  3522. function afterConnectDefaultValueSet(component, value) {
  3523. component.defaultValue = value;
  3524. }
  3525. /**
  3526. * Helper for maintaining a form-associated's hidden input in sync with the component.
  3527. *
  3528. * Based on Ionic's approach: https://github.com/ionic-team/ionic-framework/blob/e4bf052794af9aac07f887013b9250d2a045eba3/core/src/utils/helpers.ts#L198
  3529. */
  3530. function syncHiddenFormInput(component) {
  3531. const { el, formEl, name, value } = component;
  3532. const { ownerDocument } = el;
  3533. const inputs = el.querySelectorAll(`input[slot="${hiddenFormInputSlotName}"]`);
  3534. if (!formEl || !name) {
  3535. inputs.forEach((input) => input.remove());
  3536. return;
  3537. }
  3538. const values = Array.isArray(value) ? value : [value];
  3539. const extra = [];
  3540. const seen = new Set();
  3541. inputs.forEach((input) => {
  3542. const valueMatch = values.find((val) =>
  3543. /* intentional non-strict equality check */
  3544. val == input.value);
  3545. if (valueMatch != null) {
  3546. seen.add(valueMatch);
  3547. defaultSyncHiddenFormInput(component, input, valueMatch);
  3548. }
  3549. else {
  3550. extra.push(input);
  3551. }
  3552. });
  3553. let docFrag;
  3554. values.forEach((value) => {
  3555. if (seen.has(value)) {
  3556. return;
  3557. }
  3558. let input = extra.pop();
  3559. if (!input) {
  3560. input = ownerDocument.createElement("input");
  3561. input.slot = hiddenFormInputSlotName;
  3562. }
  3563. if (!docFrag) {
  3564. docFrag = ownerDocument.createDocumentFragment();
  3565. }
  3566. docFrag.append(input);
  3567. defaultSyncHiddenFormInput(component, input, value);
  3568. });
  3569. if (docFrag) {
  3570. el.append(docFrag);
  3571. }
  3572. extra.forEach((input) => input.remove());
  3573. }
  3574. function defaultSyncHiddenFormInput(component, input, value) {
  3575. var _a;
  3576. const { defaultValue, disabled, name, required } = component;
  3577. // keep in sync to prevent losing reset value
  3578. input.defaultValue = defaultValue;
  3579. input.disabled = disabled;
  3580. input.name = name;
  3581. input.required = required;
  3582. input.tabIndex = -1;
  3583. if (isCheckable(component)) {
  3584. // keep in sync to prevent losing reset value
  3585. input.defaultChecked = component.defaultChecked;
  3586. // heuristic to support default/on mode from https://html.spec.whatwg.org/multipage/input.html#dom-input-value-default-on
  3587. input.value = component.checked ? value || "on" : "";
  3588. // we disable the component when not checked to avoid having its value submitted
  3589. if (!disabled && !component.checked) {
  3590. input.disabled = true;
  3591. }
  3592. }
  3593. else {
  3594. input.value = value || "";
  3595. }
  3596. (_a = component.syncHiddenFormInput) === null || _a === void 0 ? void 0 : _a.call(component, input);
  3597. }
  3598. /**
  3599. * Helper to render the slot for form-associated component's hidden input.
  3600. *
  3601. * 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.
  3602. *
  3603. * render(): VNode {
  3604. * <Host>
  3605. * <div class={CSS.container}>
  3606. * // ...
  3607. * <HiddenFormInputSlot component={this} />
  3608. * </div>
  3609. * </Host>
  3610. * }
  3611. *
  3612. * Note that the hidden-form-input Sass mixin must be added to the component's style to apply specific styles.
  3613. */
  3614. const HiddenFormInputSlot = ({ component }) => {
  3615. syncHiddenFormInput(component);
  3616. return h("slot", { name: hiddenFormInputSlotName });
  3617. };
  3618. 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}";
  3619. const Button = class extends HTMLElement$1 {
  3620. constructor() {
  3621. super();
  3622. this.__registerHost();
  3623. this.__attachShadow();
  3624. //--------------------------------------------------------------------------
  3625. //
  3626. // Properties
  3627. //
  3628. //--------------------------------------------------------------------------
  3629. /** optionally specify alignment of button elements. */
  3630. this.alignment = "center";
  3631. /** specify the appearance style of the button, defaults to solid. */
  3632. this.appearance = "solid";
  3633. /** specify the color of the button, defaults to blue */
  3634. this.color = "blue";
  3635. /** is the button disabled */
  3636. this.disabled = false;
  3637. /** string to override English loading text
  3638. * @default "Loading"
  3639. */
  3640. this.intlLoading = TEXT$k.loading;
  3641. /** optionally add a calcite-loader component to the button, disabling interaction. */
  3642. this.loading = false;
  3643. /** optionally add a round style to the button */
  3644. this.round = false;
  3645. /** specify the scale of the button, defaults to m */
  3646. this.scale = "m";
  3647. /** is the button a child of a calcite-split-button */
  3648. this.splitChild = false;
  3649. /** The type attribute to apply to the button */
  3650. this.type = "button";
  3651. /** specify the width of the button, defaults to auto */
  3652. this.width = "auto";
  3653. /** watches for changing text content **/
  3654. this.mutationObserver = createObserver("mutation", () => this.updateHasContent());
  3655. /** determine if there is slotted content for styling purposes */
  3656. this.hasContent = false;
  3657. /** determine if loader present for styling purposes */
  3658. this.hasLoader = false;
  3659. // act on a requested or nearby form based on type
  3660. this.handleClick = () => {
  3661. const { type } = this;
  3662. if (this.href) {
  3663. return;
  3664. }
  3665. // this.type refers to type attribute, not child element type
  3666. if (type === "submit") {
  3667. submitForm(this);
  3668. }
  3669. else if (type === "reset") {
  3670. resetForm(this);
  3671. }
  3672. };
  3673. }
  3674. loadingChanged(newValue, oldValue) {
  3675. if (!!newValue && !oldValue) {
  3676. this.hasLoader = true;
  3677. }
  3678. if (!newValue && !!oldValue) {
  3679. window.setTimeout(() => {
  3680. this.hasLoader = false;
  3681. }, 300);
  3682. }
  3683. }
  3684. //--------------------------------------------------------------------------
  3685. //
  3686. // Lifecycle
  3687. //
  3688. //--------------------------------------------------------------------------
  3689. connectedCallback() {
  3690. this.hasLoader = this.loading;
  3691. this.setupTextContentObserver();
  3692. connectLabel(this);
  3693. this.formEl = closestElementCrossShadowBoundary(this.el, this.form ? `#${this.form}` : "form");
  3694. }
  3695. disconnectedCallback() {
  3696. var _a;
  3697. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  3698. disconnectLabel(this);
  3699. this.formEl = null;
  3700. }
  3701. componentWillLoad() {
  3702. if (Build.isBrowser) {
  3703. this.updateHasContent();
  3704. }
  3705. }
  3706. componentDidRender() {
  3707. updateHostInteraction(this);
  3708. }
  3709. render() {
  3710. const childElType = this.href ? "a" : "button";
  3711. const Tag = childElType;
  3712. 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;
  3713. 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" }));
  3714. 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" }));
  3715. const contentEl = (h("span", { class: CSS$J.content }, h("slot", null)));
  3716. return (h(Tag, { "aria-label": getLabelText(this), class: {
  3717. [CSS$J.contentSlotted]: this.hasContent,
  3718. [CSS$J.iconStartEmpty]: !this.iconStart,
  3719. [CSS$J.iconEndEmpty]: !this.iconEnd
  3720. }, 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));
  3721. }
  3722. //--------------------------------------------------------------------------
  3723. //
  3724. // Public Methods
  3725. //
  3726. //--------------------------------------------------------------------------
  3727. /** Sets focus on the component. */
  3728. async setFocus() {
  3729. this.childEl.focus();
  3730. }
  3731. updateHasContent() {
  3732. var _a, _b;
  3733. const slottedContent = this.el.textContent.trim().length > 0 || this.el.childNodes.length > 0;
  3734. this.hasContent =
  3735. this.el.childNodes.length === 1 && ((_a = this.el.childNodes[0]) === null || _a === void 0 ? void 0 : _a.nodeName) === "#text"
  3736. ? ((_b = this.el.textContent) === null || _b === void 0 ? void 0 : _b.trim().length) > 0
  3737. : slottedContent;
  3738. }
  3739. setupTextContentObserver() {
  3740. var _a;
  3741. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
  3742. }
  3743. //--------------------------------------------------------------------------
  3744. //
  3745. // Private Methods
  3746. //
  3747. //--------------------------------------------------------------------------
  3748. onLabelClick() {
  3749. this.handleClick();
  3750. this.setFocus();
  3751. }
  3752. get el() { return this; }
  3753. static get watchers() { return {
  3754. "loading": ["loadingChanged"]
  3755. }; }
  3756. static get style() { return buttonCss; }
  3757. };
  3758. const CSS$I = {
  3759. container: "container",
  3760. header: "header",
  3761. footer: "footer",
  3762. title: "title",
  3763. subtitle: "subtitle",
  3764. thumbnailWrapper: "thumbnail-wrapper",
  3765. checkboxWrapper: "checkbox-wrapper"
  3766. };
  3767. const SLOTS$j = {
  3768. thumbnail: "thumbnail",
  3769. title: "title",
  3770. subtitle: "subtitle",
  3771. footerLeading: "footer-leading",
  3772. footerTrailing: "footer-trailing"
  3773. };
  3774. const TEXT$j = {
  3775. select: "Select",
  3776. deselect: "Deselect",
  3777. loading: "Loading"
  3778. };
  3779. 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}";
  3780. const Card = class extends HTMLElement$1 {
  3781. constructor() {
  3782. super();
  3783. this.__registerHost();
  3784. this.__attachShadow();
  3785. this.calciteCardSelect = createEvent(this, "calciteCardSelect", 7);
  3786. //--------------------------------------------------------------------------
  3787. //
  3788. // Public Properties
  3789. //
  3790. //--------------------------------------------------------------------------
  3791. /** When true, the cards content is waiting to be loaded. This state shows a busy indicator.*/
  3792. this.loading = false;
  3793. /** Indicates whether the card is selected. */
  3794. this.selected = false;
  3795. /** Indicates whether the card is selectable. */
  3796. this.selectable = false;
  3797. /** string to override English loading text
  3798. * @default "Loading"
  3799. */
  3800. this.intlLoading = TEXT$j.loading;
  3801. /** string to override English select text for checkbox when selectable is true
  3802. * @default "Select"
  3803. */
  3804. this.intlSelect = TEXT$j.select;
  3805. /** string to override English deselect text for checkbox when selectable is true
  3806. * @default "Deselect"
  3807. */
  3808. this.intlDeselect = TEXT$j.deselect;
  3809. //--------------------------------------------------------------------------
  3810. //
  3811. // Private State/Props
  3812. //
  3813. //--------------------------------------------------------------------------
  3814. //--------------------------------------------------------------------------
  3815. //
  3816. // Private Methods
  3817. //
  3818. //--------------------------------------------------------------------------
  3819. this.cardSelectClick = () => {
  3820. this.selectCard();
  3821. };
  3822. this.cardSelectKeyDown = (e) => {
  3823. switch (e.key) {
  3824. case " ":
  3825. case "Enter":
  3826. this.selectCard();
  3827. e.preventDefault();
  3828. break;
  3829. }
  3830. };
  3831. }
  3832. // --------------------------------------------------------------------------
  3833. //
  3834. // Lifecycle
  3835. //
  3836. // --------------------------------------------------------------------------
  3837. connectedCallback() {
  3838. connectConditionalSlotComponent(this);
  3839. }
  3840. disonnectedCallback() {
  3841. disconnectConditionalSlotComponent(this);
  3842. }
  3843. render() {
  3844. 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())));
  3845. }
  3846. selectCard() {
  3847. this.selected = !this.selected;
  3848. this.calciteCardSelect.emit();
  3849. }
  3850. renderThumbnail() {
  3851. return getSlotted(this.el, SLOTS$j.thumbnail) ? (h("div", { class: CSS$I.thumbnailWrapper, key: "thumbnail-wrapper" }, h("slot", { name: SLOTS$j.thumbnail }))) : null;
  3852. }
  3853. renderCheckbox() {
  3854. const checkboxLabel = this.selected ? this.intlDeselect : this.intlSelect;
  3855. return (h("calcite-label", { class: CSS$I.checkboxWrapper, onClick: this.cardSelectClick, onKeyDown: this.cardSelectKeyDown }, h("calcite-checkbox", { checked: this.selected, label: checkboxLabel })));
  3856. }
  3857. renderHeader() {
  3858. const { el } = this;
  3859. const title = getSlotted(el, SLOTS$j.title);
  3860. const subtitle = getSlotted(el, SLOTS$j.subtitle);
  3861. const hasHeader = title || subtitle;
  3862. return hasHeader ? (h("header", { class: CSS$I.header }, h("slot", { name: SLOTS$j.title }), h("slot", { name: SLOTS$j.subtitle }))) : null;
  3863. }
  3864. renderFooter() {
  3865. const { el } = this;
  3866. const leadingFooter = getSlotted(el, SLOTS$j.footerLeading);
  3867. const trailingFooter = getSlotted(el, SLOTS$j.footerTrailing);
  3868. const hasFooter = leadingFooter || trailingFooter;
  3869. return hasFooter ? (h("footer", { class: CSS$I.footer }, h("slot", { name: SLOTS$j.footerLeading }), h("slot", { name: SLOTS$j.footerTrailing }))) : null;
  3870. }
  3871. get el() { return this; }
  3872. static get style() { return cardCss; }
  3873. };
  3874. 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}";
  3875. const Checkbox = class extends HTMLElement$1 {
  3876. constructor() {
  3877. super();
  3878. this.__registerHost();
  3879. this.__attachShadow();
  3880. this.calciteInternalCheckboxBlur = createEvent(this, "calciteInternalCheckboxBlur", 7);
  3881. this.calciteCheckboxChange = createEvent(this, "calciteCheckboxChange", 7);
  3882. this.calciteInternalCheckboxFocus = createEvent(this, "calciteInternalCheckboxFocus", 7);
  3883. //--------------------------------------------------------------------------
  3884. //
  3885. // Properties
  3886. //
  3887. //--------------------------------------------------------------------------
  3888. /** The checked state of the checkbox. */
  3889. this.checked = false;
  3890. /** True if the checkbox is disabled */
  3891. this.disabled = false;
  3892. /**
  3893. * The hovered state of the checkbox.
  3894. * @internal
  3895. */
  3896. this.hovered = false;
  3897. /**
  3898. * True if the checkbox is initially indeterminate,
  3899. * which is independent from its checked state
  3900. * https://css-tricks.com/indeterminate-checkboxes/
  3901. * */
  3902. this.indeterminate = false;
  3903. /**
  3904. * When true, makes the component required for form-submission.
  3905. *
  3906. * @internal
  3907. */
  3908. this.required = false;
  3909. /** specify the scale of the checkbox, defaults to m */
  3910. this.scale = "m";
  3911. //--------------------------------------------------------------------------
  3912. //
  3913. // Private Properties
  3914. //
  3915. //--------------------------------------------------------------------------
  3916. this.checkedPath = "M5.5 12L2 8.689l.637-.636L5.5 10.727l8.022-7.87.637.637z";
  3917. this.indeterminatePath = "M13 8v1H3V8z";
  3918. //--------------------------------------------------------------------------
  3919. //
  3920. // Private Methods
  3921. //
  3922. //--------------------------------------------------------------------------
  3923. this.getPath = () => this.indeterminate ? this.indeterminatePath : this.checked ? this.checkedPath : "";
  3924. this.toggle = () => {
  3925. if (!this.disabled) {
  3926. this.checked = !this.checked;
  3927. this.setFocus();
  3928. this.indeterminate = false;
  3929. this.calciteCheckboxChange.emit();
  3930. }
  3931. };
  3932. this.keyDownHandler = (event) => {
  3933. if (event.key === " " || event.key === "Enter") {
  3934. this.toggle();
  3935. event.preventDefault();
  3936. }
  3937. };
  3938. this.clickHandler = () => {
  3939. this.toggle();
  3940. };
  3941. //--------------------------------------------------------------------------
  3942. //
  3943. // Event Listeners
  3944. //
  3945. //--------------------------------------------------------------------------
  3946. this.onToggleBlur = () => {
  3947. this.calciteInternalCheckboxBlur.emit(false);
  3948. };
  3949. this.onToggleFocus = () => {
  3950. this.calciteInternalCheckboxFocus.emit(true);
  3951. };
  3952. this.onLabelClick = () => {
  3953. this.toggle();
  3954. };
  3955. }
  3956. //--------------------------------------------------------------------------
  3957. //
  3958. // Public Methods
  3959. //
  3960. //--------------------------------------------------------------------------
  3961. /** Sets focus on the component. */
  3962. async setFocus() {
  3963. var _a;
  3964. (_a = this.toggleEl) === null || _a === void 0 ? void 0 : _a.focus();
  3965. }
  3966. //--------------------------------------------------------------------------
  3967. //
  3968. // Lifecycle
  3969. //
  3970. //--------------------------------------------------------------------------
  3971. connectedCallback() {
  3972. this.guid = this.el.id || `calcite-checkbox-${guid()}`;
  3973. connectLabel(this);
  3974. connectForm(this);
  3975. }
  3976. disconnectedCallback() {
  3977. disconnectLabel(this);
  3978. disconnectForm(this);
  3979. }
  3980. componentDidRender() {
  3981. updateHostInteraction(this);
  3982. }
  3983. // --------------------------------------------------------------------------
  3984. //
  3985. // Render Methods
  3986. //
  3987. // --------------------------------------------------------------------------
  3988. render() {
  3989. 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 })));
  3990. }
  3991. get el() { return this; }
  3992. static get style() { return checkboxCss; }
  3993. };
  3994. const CSS$H = {
  3995. title: "title",
  3996. close: "close",
  3997. imageContainer: "image-container",
  3998. chipIcon: "chip-icon",
  3999. closeIcon: "close-icon"
  4000. };
  4001. const TEXT$i = {
  4002. close: "Close"
  4003. };
  4004. const SLOTS$i = {
  4005. image: "image"
  4006. };
  4007. const ICONS$a = {
  4008. close: "x"
  4009. };
  4010. 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))}";
  4011. const Chip = class extends HTMLElement$1 {
  4012. constructor() {
  4013. super();
  4014. this.__registerHost();
  4015. this.__attachShadow();
  4016. this.calciteChipDismiss = createEvent(this, "calciteChipDismiss", 7);
  4017. //--------------------------------------------------------------------------
  4018. //
  4019. // Public Properties
  4020. //
  4021. //--------------------------------------------------------------------------
  4022. /** specify the appearance style of the button, defaults to solid. */
  4023. this.appearance = "solid";
  4024. /** specify the color of the button, defaults to blue */
  4025. this.color = "grey";
  4026. /** Optionally show a button the user can click to dismiss the chip */
  4027. this.dismissible = false;
  4028. /** Aria label for the "x" button
  4029. * @default "Close"
  4030. */
  4031. this.dismissLabel = TEXT$i.close;
  4032. /** flip the icon in rtl */
  4033. this.iconFlipRtl = false;
  4034. /** specify the scale of the chip, defaults to m */
  4035. this.scale = "m";
  4036. // --------------------------------------------------------------------------
  4037. //
  4038. // Private Methods
  4039. //
  4040. // --------------------------------------------------------------------------
  4041. this.closeClickHandler = (event) => {
  4042. event.preventDefault();
  4043. this.calciteChipDismiss.emit(this.el);
  4044. };
  4045. this.guid = guid();
  4046. }
  4047. // --------------------------------------------------------------------------
  4048. //
  4049. // Lifecycle
  4050. //
  4051. // --------------------------------------------------------------------------
  4052. connectedCallback() {
  4053. connectConditionalSlotComponent(this);
  4054. }
  4055. disconnectedCallback() {
  4056. disconnectConditionalSlotComponent(this);
  4057. }
  4058. //--------------------------------------------------------------------------
  4059. //
  4060. // Public Methods
  4061. //
  4062. //--------------------------------------------------------------------------
  4063. /** Sets focus on the component. */
  4064. async setFocus() {
  4065. var _a;
  4066. (_a = this.closeButton) === null || _a === void 0 ? void 0 : _a.focus();
  4067. }
  4068. //--------------------------------------------------------------------------
  4069. //
  4070. // Render Methods
  4071. //
  4072. //--------------------------------------------------------------------------
  4073. renderChipImage() {
  4074. const { el } = this;
  4075. const hasChipImage = getSlotted(el, SLOTS$i.image);
  4076. return hasChipImage ? (h("div", { class: CSS$H.imageContainer, key: "image" }, h("slot", { name: SLOTS$i.image }))) : null;
  4077. }
  4078. render() {
  4079. const iconEl = (h("calcite-icon", { class: CSS$H.chipIcon, flipRtl: this.iconFlipRtl, icon: this.icon, scale: "s" }));
  4080. 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" })));
  4081. 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));
  4082. }
  4083. get el() { return this; }
  4084. static get style() { return chipCss; }
  4085. };
  4086. function createCommonjsModule(fn, basedir, module) {
  4087. return module = {
  4088. path: basedir,
  4089. exports: {},
  4090. require: function (path, base) {
  4091. return commonjsRequire();
  4092. }
  4093. }, fn(module, module.exports), module.exports;
  4094. }
  4095. function commonjsRequire () {
  4096. throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
  4097. }
  4098. var colorName$1 = {
  4099. "aliceblue": [240, 248, 255],
  4100. "antiquewhite": [250, 235, 215],
  4101. "aqua": [0, 255, 255],
  4102. "aquamarine": [127, 255, 212],
  4103. "azure": [240, 255, 255],
  4104. "beige": [245, 245, 220],
  4105. "bisque": [255, 228, 196],
  4106. "black": [0, 0, 0],
  4107. "blanchedalmond": [255, 235, 205],
  4108. "blue": [0, 0, 255],
  4109. "blueviolet": [138, 43, 226],
  4110. "brown": [165, 42, 42],
  4111. "burlywood": [222, 184, 135],
  4112. "cadetblue": [95, 158, 160],
  4113. "chartreuse": [127, 255, 0],
  4114. "chocolate": [210, 105, 30],
  4115. "coral": [255, 127, 80],
  4116. "cornflowerblue": [100, 149, 237],
  4117. "cornsilk": [255, 248, 220],
  4118. "crimson": [220, 20, 60],
  4119. "cyan": [0, 255, 255],
  4120. "darkblue": [0, 0, 139],
  4121. "darkcyan": [0, 139, 139],
  4122. "darkgoldenrod": [184, 134, 11],
  4123. "darkgray": [169, 169, 169],
  4124. "darkgreen": [0, 100, 0],
  4125. "darkgrey": [169, 169, 169],
  4126. "darkkhaki": [189, 183, 107],
  4127. "darkmagenta": [139, 0, 139],
  4128. "darkolivegreen": [85, 107, 47],
  4129. "darkorange": [255, 140, 0],
  4130. "darkorchid": [153, 50, 204],
  4131. "darkred": [139, 0, 0],
  4132. "darksalmon": [233, 150, 122],
  4133. "darkseagreen": [143, 188, 143],
  4134. "darkslateblue": [72, 61, 139],
  4135. "darkslategray": [47, 79, 79],
  4136. "darkslategrey": [47, 79, 79],
  4137. "darkturquoise": [0, 206, 209],
  4138. "darkviolet": [148, 0, 211],
  4139. "deeppink": [255, 20, 147],
  4140. "deepskyblue": [0, 191, 255],
  4141. "dimgray": [105, 105, 105],
  4142. "dimgrey": [105, 105, 105],
  4143. "dodgerblue": [30, 144, 255],
  4144. "firebrick": [178, 34, 34],
  4145. "floralwhite": [255, 250, 240],
  4146. "forestgreen": [34, 139, 34],
  4147. "fuchsia": [255, 0, 255],
  4148. "gainsboro": [220, 220, 220],
  4149. "ghostwhite": [248, 248, 255],
  4150. "gold": [255, 215, 0],
  4151. "goldenrod": [218, 165, 32],
  4152. "gray": [128, 128, 128],
  4153. "green": [0, 128, 0],
  4154. "greenyellow": [173, 255, 47],
  4155. "grey": [128, 128, 128],
  4156. "honeydew": [240, 255, 240],
  4157. "hotpink": [255, 105, 180],
  4158. "indianred": [205, 92, 92],
  4159. "indigo": [75, 0, 130],
  4160. "ivory": [255, 255, 240],
  4161. "khaki": [240, 230, 140],
  4162. "lavender": [230, 230, 250],
  4163. "lavenderblush": [255, 240, 245],
  4164. "lawngreen": [124, 252, 0],
  4165. "lemonchiffon": [255, 250, 205],
  4166. "lightblue": [173, 216, 230],
  4167. "lightcoral": [240, 128, 128],
  4168. "lightcyan": [224, 255, 255],
  4169. "lightgoldenrodyellow": [250, 250, 210],
  4170. "lightgray": [211, 211, 211],
  4171. "lightgreen": [144, 238, 144],
  4172. "lightgrey": [211, 211, 211],
  4173. "lightpink": [255, 182, 193],
  4174. "lightsalmon": [255, 160, 122],
  4175. "lightseagreen": [32, 178, 170],
  4176. "lightskyblue": [135, 206, 250],
  4177. "lightslategray": [119, 136, 153],
  4178. "lightslategrey": [119, 136, 153],
  4179. "lightsteelblue": [176, 196, 222],
  4180. "lightyellow": [255, 255, 224],
  4181. "lime": [0, 255, 0],
  4182. "limegreen": [50, 205, 50],
  4183. "linen": [250, 240, 230],
  4184. "magenta": [255, 0, 255],
  4185. "maroon": [128, 0, 0],
  4186. "mediumaquamarine": [102, 205, 170],
  4187. "mediumblue": [0, 0, 205],
  4188. "mediumorchid": [186, 85, 211],
  4189. "mediumpurple": [147, 112, 219],
  4190. "mediumseagreen": [60, 179, 113],
  4191. "mediumslateblue": [123, 104, 238],
  4192. "mediumspringgreen": [0, 250, 154],
  4193. "mediumturquoise": [72, 209, 204],
  4194. "mediumvioletred": [199, 21, 133],
  4195. "midnightblue": [25, 25, 112],
  4196. "mintcream": [245, 255, 250],
  4197. "mistyrose": [255, 228, 225],
  4198. "moccasin": [255, 228, 181],
  4199. "navajowhite": [255, 222, 173],
  4200. "navy": [0, 0, 128],
  4201. "oldlace": [253, 245, 230],
  4202. "olive": [128, 128, 0],
  4203. "olivedrab": [107, 142, 35],
  4204. "orange": [255, 165, 0],
  4205. "orangered": [255, 69, 0],
  4206. "orchid": [218, 112, 214],
  4207. "palegoldenrod": [238, 232, 170],
  4208. "palegreen": [152, 251, 152],
  4209. "paleturquoise": [175, 238, 238],
  4210. "palevioletred": [219, 112, 147],
  4211. "papayawhip": [255, 239, 213],
  4212. "peachpuff": [255, 218, 185],
  4213. "peru": [205, 133, 63],
  4214. "pink": [255, 192, 203],
  4215. "plum": [221, 160, 221],
  4216. "powderblue": [176, 224, 230],
  4217. "purple": [128, 0, 128],
  4218. "rebeccapurple": [102, 51, 153],
  4219. "red": [255, 0, 0],
  4220. "rosybrown": [188, 143, 143],
  4221. "royalblue": [65, 105, 225],
  4222. "saddlebrown": [139, 69, 19],
  4223. "salmon": [250, 128, 114],
  4224. "sandybrown": [244, 164, 96],
  4225. "seagreen": [46, 139, 87],
  4226. "seashell": [255, 245, 238],
  4227. "sienna": [160, 82, 45],
  4228. "silver": [192, 192, 192],
  4229. "skyblue": [135, 206, 235],
  4230. "slateblue": [106, 90, 205],
  4231. "slategray": [112, 128, 144],
  4232. "slategrey": [112, 128, 144],
  4233. "snow": [255, 250, 250],
  4234. "springgreen": [0, 255, 127],
  4235. "steelblue": [70, 130, 180],
  4236. "tan": [210, 180, 140],
  4237. "teal": [0, 128, 128],
  4238. "thistle": [216, 191, 216],
  4239. "tomato": [255, 99, 71],
  4240. "turquoise": [64, 224, 208],
  4241. "violet": [238, 130, 238],
  4242. "wheat": [245, 222, 179],
  4243. "white": [255, 255, 255],
  4244. "whitesmoke": [245, 245, 245],
  4245. "yellow": [255, 255, 0],
  4246. "yellowgreen": [154, 205, 50]
  4247. };
  4248. var isArrayish = function isArrayish(obj) {
  4249. if (!obj || typeof obj === 'string') {
  4250. return false;
  4251. }
  4252. return obj instanceof Array || Array.isArray(obj) ||
  4253. (obj.length >= 0 && (obj.splice instanceof Function ||
  4254. (Object.getOwnPropertyDescriptor(obj, (obj.length - 1)) && obj.constructor.name !== 'String')));
  4255. };
  4256. var simpleSwizzle = createCommonjsModule(function (module) {
  4257. var concat = Array.prototype.concat;
  4258. var slice = Array.prototype.slice;
  4259. var swizzle = module.exports = function swizzle(args) {
  4260. var results = [];
  4261. for (var i = 0, len = args.length; i < len; i++) {
  4262. var arg = args[i];
  4263. if (isArrayish(arg)) {
  4264. // http://jsperf.com/javascript-array-concat-vs-push/98
  4265. results = concat.call(results, slice.call(arg));
  4266. } else {
  4267. results.push(arg);
  4268. }
  4269. }
  4270. return results;
  4271. };
  4272. swizzle.wrap = function (fn) {
  4273. return function () {
  4274. return fn(swizzle(arguments));
  4275. };
  4276. };
  4277. });
  4278. var colorString = createCommonjsModule(function (module) {
  4279. /* MIT license */
  4280. var hasOwnProperty = Object.hasOwnProperty;
  4281. var reverseNames = {};
  4282. // create a list of reverse color names
  4283. for (var name in colorName$1) {
  4284. if (hasOwnProperty.call(colorName$1, name)) {
  4285. reverseNames[colorName$1[name]] = name;
  4286. }
  4287. }
  4288. var cs = module.exports = {
  4289. to: {},
  4290. get: {}
  4291. };
  4292. cs.get = function (string) {
  4293. var prefix = string.substring(0, 3).toLowerCase();
  4294. var val;
  4295. var model;
  4296. switch (prefix) {
  4297. case 'hsl':
  4298. val = cs.get.hsl(string);
  4299. model = 'hsl';
  4300. break;
  4301. case 'hwb':
  4302. val = cs.get.hwb(string);
  4303. model = 'hwb';
  4304. break;
  4305. default:
  4306. val = cs.get.rgb(string);
  4307. model = 'rgb';
  4308. break;
  4309. }
  4310. if (!val) {
  4311. return null;
  4312. }
  4313. return {model: model, value: val};
  4314. };
  4315. cs.get.rgb = function (string) {
  4316. if (!string) {
  4317. return null;
  4318. }
  4319. var abbr = /^#([a-f0-9]{3,4})$/i;
  4320. var hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;
  4321. var rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
  4322. var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
  4323. var keyword = /^(\w+)$/;
  4324. var rgb = [0, 0, 0, 1];
  4325. var match;
  4326. var i;
  4327. var hexAlpha;
  4328. if (match = string.match(hex)) {
  4329. hexAlpha = match[2];
  4330. match = match[1];
  4331. for (i = 0; i < 3; i++) {
  4332. // https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19
  4333. var i2 = i * 2;
  4334. rgb[i] = parseInt(match.slice(i2, i2 + 2), 16);
  4335. }
  4336. if (hexAlpha) {
  4337. rgb[3] = parseInt(hexAlpha, 16) / 255;
  4338. }
  4339. } else if (match = string.match(abbr)) {
  4340. match = match[1];
  4341. hexAlpha = match[3];
  4342. for (i = 0; i < 3; i++) {
  4343. rgb[i] = parseInt(match[i] + match[i], 16);
  4344. }
  4345. if (hexAlpha) {
  4346. rgb[3] = parseInt(hexAlpha + hexAlpha, 16) / 255;
  4347. }
  4348. } else if (match = string.match(rgba)) {
  4349. for (i = 0; i < 3; i++) {
  4350. rgb[i] = parseInt(match[i + 1], 0);
  4351. }
  4352. if (match[4]) {
  4353. if (match[5]) {
  4354. rgb[3] = parseFloat(match[4]) * 0.01;
  4355. } else {
  4356. rgb[3] = parseFloat(match[4]);
  4357. }
  4358. }
  4359. } else if (match = string.match(per)) {
  4360. for (i = 0; i < 3; i++) {
  4361. rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
  4362. }
  4363. if (match[4]) {
  4364. if (match[5]) {
  4365. rgb[3] = parseFloat(match[4]) * 0.01;
  4366. } else {
  4367. rgb[3] = parseFloat(match[4]);
  4368. }
  4369. }
  4370. } else if (match = string.match(keyword)) {
  4371. if (match[1] === 'transparent') {
  4372. return [0, 0, 0, 0];
  4373. }
  4374. if (!hasOwnProperty.call(colorName$1, match[1])) {
  4375. return null;
  4376. }
  4377. rgb = colorName$1[match[1]];
  4378. rgb[3] = 1;
  4379. return rgb;
  4380. } else {
  4381. return null;
  4382. }
  4383. for (i = 0; i < 3; i++) {
  4384. rgb[i] = clamp(rgb[i], 0, 255);
  4385. }
  4386. rgb[3] = clamp(rgb[3], 0, 1);
  4387. return rgb;
  4388. };
  4389. cs.get.hsl = function (string) {
  4390. if (!string) {
  4391. return null;
  4392. }
  4393. 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*)?\)$/;
  4394. var match = string.match(hsl);
  4395. if (match) {
  4396. var alpha = parseFloat(match[4]);
  4397. var h = ((parseFloat(match[1]) % 360) + 360) % 360;
  4398. var s = clamp(parseFloat(match[2]), 0, 100);
  4399. var l = clamp(parseFloat(match[3]), 0, 100);
  4400. var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
  4401. return [h, s, l, a];
  4402. }
  4403. return null;
  4404. };
  4405. cs.get.hwb = function (string) {
  4406. if (!string) {
  4407. return null;
  4408. }
  4409. 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*)?\)$/;
  4410. var match = string.match(hwb);
  4411. if (match) {
  4412. var alpha = parseFloat(match[4]);
  4413. var h = ((parseFloat(match[1]) % 360) + 360) % 360;
  4414. var w = clamp(parseFloat(match[2]), 0, 100);
  4415. var b = clamp(parseFloat(match[3]), 0, 100);
  4416. var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
  4417. return [h, w, b, a];
  4418. }
  4419. return null;
  4420. };
  4421. cs.to.hex = function () {
  4422. var rgba = simpleSwizzle(arguments);
  4423. return (
  4424. '#' +
  4425. hexDouble(rgba[0]) +
  4426. hexDouble(rgba[1]) +
  4427. hexDouble(rgba[2]) +
  4428. (rgba[3] < 1
  4429. ? (hexDouble(Math.round(rgba[3] * 255)))
  4430. : '')
  4431. );
  4432. };
  4433. cs.to.rgb = function () {
  4434. var rgba = simpleSwizzle(arguments);
  4435. return rgba.length < 4 || rgba[3] === 1
  4436. ? 'rgb(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ')'
  4437. : 'rgba(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ', ' + rgba[3] + ')';
  4438. };
  4439. cs.to.rgb.percent = function () {
  4440. var rgba = simpleSwizzle(arguments);
  4441. var r = Math.round(rgba[0] / 255 * 100);
  4442. var g = Math.round(rgba[1] / 255 * 100);
  4443. var b = Math.round(rgba[2] / 255 * 100);
  4444. return rgba.length < 4 || rgba[3] === 1
  4445. ? 'rgb(' + r + '%, ' + g + '%, ' + b + '%)'
  4446. : 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + rgba[3] + ')';
  4447. };
  4448. cs.to.hsl = function () {
  4449. var hsla = simpleSwizzle(arguments);
  4450. return hsla.length < 4 || hsla[3] === 1
  4451. ? 'hsl(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%)'
  4452. : 'hsla(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%, ' + hsla[3] + ')';
  4453. };
  4454. // hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax
  4455. // (hwb have alpha optional & 1 is default value)
  4456. cs.to.hwb = function () {
  4457. var hwba = simpleSwizzle(arguments);
  4458. var a = '';
  4459. if (hwba.length >= 4 && hwba[3] !== 1) {
  4460. a = ', ' + hwba[3];
  4461. }
  4462. return 'hwb(' + hwba[0] + ', ' + hwba[1] + '%, ' + hwba[2] + '%' + a + ')';
  4463. };
  4464. cs.to.keyword = function (rgb) {
  4465. return reverseNames[rgb.slice(0, 3)];
  4466. };
  4467. // helpers
  4468. function clamp(num, min, max) {
  4469. return Math.min(Math.max(min, num), max);
  4470. }
  4471. function hexDouble(num) {
  4472. var str = Math.round(num).toString(16).toUpperCase();
  4473. return (str.length < 2) ? '0' + str : str;
  4474. }
  4475. });
  4476. var colorName = {
  4477. "aliceblue": [240, 248, 255],
  4478. "antiquewhite": [250, 235, 215],
  4479. "aqua": [0, 255, 255],
  4480. "aquamarine": [127, 255, 212],
  4481. "azure": [240, 255, 255],
  4482. "beige": [245, 245, 220],
  4483. "bisque": [255, 228, 196],
  4484. "black": [0, 0, 0],
  4485. "blanchedalmond": [255, 235, 205],
  4486. "blue": [0, 0, 255],
  4487. "blueviolet": [138, 43, 226],
  4488. "brown": [165, 42, 42],
  4489. "burlywood": [222, 184, 135],
  4490. "cadetblue": [95, 158, 160],
  4491. "chartreuse": [127, 255, 0],
  4492. "chocolate": [210, 105, 30],
  4493. "coral": [255, 127, 80],
  4494. "cornflowerblue": [100, 149, 237],
  4495. "cornsilk": [255, 248, 220],
  4496. "crimson": [220, 20, 60],
  4497. "cyan": [0, 255, 255],
  4498. "darkblue": [0, 0, 139],
  4499. "darkcyan": [0, 139, 139],
  4500. "darkgoldenrod": [184, 134, 11],
  4501. "darkgray": [169, 169, 169],
  4502. "darkgreen": [0, 100, 0],
  4503. "darkgrey": [169, 169, 169],
  4504. "darkkhaki": [189, 183, 107],
  4505. "darkmagenta": [139, 0, 139],
  4506. "darkolivegreen": [85, 107, 47],
  4507. "darkorange": [255, 140, 0],
  4508. "darkorchid": [153, 50, 204],
  4509. "darkred": [139, 0, 0],
  4510. "darksalmon": [233, 150, 122],
  4511. "darkseagreen": [143, 188, 143],
  4512. "darkslateblue": [72, 61, 139],
  4513. "darkslategray": [47, 79, 79],
  4514. "darkslategrey": [47, 79, 79],
  4515. "darkturquoise": [0, 206, 209],
  4516. "darkviolet": [148, 0, 211],
  4517. "deeppink": [255, 20, 147],
  4518. "deepskyblue": [0, 191, 255],
  4519. "dimgray": [105, 105, 105],
  4520. "dimgrey": [105, 105, 105],
  4521. "dodgerblue": [30, 144, 255],
  4522. "firebrick": [178, 34, 34],
  4523. "floralwhite": [255, 250, 240],
  4524. "forestgreen": [34, 139, 34],
  4525. "fuchsia": [255, 0, 255],
  4526. "gainsboro": [220, 220, 220],
  4527. "ghostwhite": [248, 248, 255],
  4528. "gold": [255, 215, 0],
  4529. "goldenrod": [218, 165, 32],
  4530. "gray": [128, 128, 128],
  4531. "green": [0, 128, 0],
  4532. "greenyellow": [173, 255, 47],
  4533. "grey": [128, 128, 128],
  4534. "honeydew": [240, 255, 240],
  4535. "hotpink": [255, 105, 180],
  4536. "indianred": [205, 92, 92],
  4537. "indigo": [75, 0, 130],
  4538. "ivory": [255, 255, 240],
  4539. "khaki": [240, 230, 140],
  4540. "lavender": [230, 230, 250],
  4541. "lavenderblush": [255, 240, 245],
  4542. "lawngreen": [124, 252, 0],
  4543. "lemonchiffon": [255, 250, 205],
  4544. "lightblue": [173, 216, 230],
  4545. "lightcoral": [240, 128, 128],
  4546. "lightcyan": [224, 255, 255],
  4547. "lightgoldenrodyellow": [250, 250, 210],
  4548. "lightgray": [211, 211, 211],
  4549. "lightgreen": [144, 238, 144],
  4550. "lightgrey": [211, 211, 211],
  4551. "lightpink": [255, 182, 193],
  4552. "lightsalmon": [255, 160, 122],
  4553. "lightseagreen": [32, 178, 170],
  4554. "lightskyblue": [135, 206, 250],
  4555. "lightslategray": [119, 136, 153],
  4556. "lightslategrey": [119, 136, 153],
  4557. "lightsteelblue": [176, 196, 222],
  4558. "lightyellow": [255, 255, 224],
  4559. "lime": [0, 255, 0],
  4560. "limegreen": [50, 205, 50],
  4561. "linen": [250, 240, 230],
  4562. "magenta": [255, 0, 255],
  4563. "maroon": [128, 0, 0],
  4564. "mediumaquamarine": [102, 205, 170],
  4565. "mediumblue": [0, 0, 205],
  4566. "mediumorchid": [186, 85, 211],
  4567. "mediumpurple": [147, 112, 219],
  4568. "mediumseagreen": [60, 179, 113],
  4569. "mediumslateblue": [123, 104, 238],
  4570. "mediumspringgreen": [0, 250, 154],
  4571. "mediumturquoise": [72, 209, 204],
  4572. "mediumvioletred": [199, 21, 133],
  4573. "midnightblue": [25, 25, 112],
  4574. "mintcream": [245, 255, 250],
  4575. "mistyrose": [255, 228, 225],
  4576. "moccasin": [255, 228, 181],
  4577. "navajowhite": [255, 222, 173],
  4578. "navy": [0, 0, 128],
  4579. "oldlace": [253, 245, 230],
  4580. "olive": [128, 128, 0],
  4581. "olivedrab": [107, 142, 35],
  4582. "orange": [255, 165, 0],
  4583. "orangered": [255, 69, 0],
  4584. "orchid": [218, 112, 214],
  4585. "palegoldenrod": [238, 232, 170],
  4586. "palegreen": [152, 251, 152],
  4587. "paleturquoise": [175, 238, 238],
  4588. "palevioletred": [219, 112, 147],
  4589. "papayawhip": [255, 239, 213],
  4590. "peachpuff": [255, 218, 185],
  4591. "peru": [205, 133, 63],
  4592. "pink": [255, 192, 203],
  4593. "plum": [221, 160, 221],
  4594. "powderblue": [176, 224, 230],
  4595. "purple": [128, 0, 128],
  4596. "rebeccapurple": [102, 51, 153],
  4597. "red": [255, 0, 0],
  4598. "rosybrown": [188, 143, 143],
  4599. "royalblue": [65, 105, 225],
  4600. "saddlebrown": [139, 69, 19],
  4601. "salmon": [250, 128, 114],
  4602. "sandybrown": [244, 164, 96],
  4603. "seagreen": [46, 139, 87],
  4604. "seashell": [255, 245, 238],
  4605. "sienna": [160, 82, 45],
  4606. "silver": [192, 192, 192],
  4607. "skyblue": [135, 206, 235],
  4608. "slateblue": [106, 90, 205],
  4609. "slategray": [112, 128, 144],
  4610. "slategrey": [112, 128, 144],
  4611. "snow": [255, 250, 250],
  4612. "springgreen": [0, 255, 127],
  4613. "steelblue": [70, 130, 180],
  4614. "tan": [210, 180, 140],
  4615. "teal": [0, 128, 128],
  4616. "thistle": [216, 191, 216],
  4617. "tomato": [255, 99, 71],
  4618. "turquoise": [64, 224, 208],
  4619. "violet": [238, 130, 238],
  4620. "wheat": [245, 222, 179],
  4621. "white": [255, 255, 255],
  4622. "whitesmoke": [245, 245, 245],
  4623. "yellow": [255, 255, 0],
  4624. "yellowgreen": [154, 205, 50]
  4625. };
  4626. /* MIT license */
  4627. /* eslint-disable no-mixed-operators */
  4628. // NOTE: conversions should only return primitive values (i.e. arrays, or
  4629. // values that give correct `typeof` results).
  4630. // do not use box values types (i.e. Number(), String(), etc.)
  4631. const reverseKeywords = {};
  4632. for (const key of Object.keys(colorName)) {
  4633. reverseKeywords[colorName[key]] = key;
  4634. }
  4635. const convert$1 = {
  4636. rgb: {channels: 3, labels: 'rgb'},
  4637. hsl: {channels: 3, labels: 'hsl'},
  4638. hsv: {channels: 3, labels: 'hsv'},
  4639. hwb: {channels: 3, labels: 'hwb'},
  4640. cmyk: {channels: 4, labels: 'cmyk'},
  4641. xyz: {channels: 3, labels: 'xyz'},
  4642. lab: {channels: 3, labels: 'lab'},
  4643. lch: {channels: 3, labels: 'lch'},
  4644. hex: {channels: 1, labels: ['hex']},
  4645. keyword: {channels: 1, labels: ['keyword']},
  4646. ansi16: {channels: 1, labels: ['ansi16']},
  4647. ansi256: {channels: 1, labels: ['ansi256']},
  4648. hcg: {channels: 3, labels: ['h', 'c', 'g']},
  4649. apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
  4650. gray: {channels: 1, labels: ['gray']}
  4651. };
  4652. var conversions = convert$1;
  4653. // Hide .channels and .labels properties
  4654. for (const model of Object.keys(convert$1)) {
  4655. if (!('channels' in convert$1[model])) {
  4656. throw new Error('missing channels property: ' + model);
  4657. }
  4658. if (!('labels' in convert$1[model])) {
  4659. throw new Error('missing channel labels property: ' + model);
  4660. }
  4661. if (convert$1[model].labels.length !== convert$1[model].channels) {
  4662. throw new Error('channel and label counts mismatch: ' + model);
  4663. }
  4664. const {channels, labels} = convert$1[model];
  4665. delete convert$1[model].channels;
  4666. delete convert$1[model].labels;
  4667. Object.defineProperty(convert$1[model], 'channels', {value: channels});
  4668. Object.defineProperty(convert$1[model], 'labels', {value: labels});
  4669. }
  4670. convert$1.rgb.hsl = function (rgb) {
  4671. const r = rgb[0] / 255;
  4672. const g = rgb[1] / 255;
  4673. const b = rgb[2] / 255;
  4674. const min = Math.min(r, g, b);
  4675. const max = Math.max(r, g, b);
  4676. const delta = max - min;
  4677. let h;
  4678. let s;
  4679. if (max === min) {
  4680. h = 0;
  4681. } else if (r === max) {
  4682. h = (g - b) / delta;
  4683. } else if (g === max) {
  4684. h = 2 + (b - r) / delta;
  4685. } else if (b === max) {
  4686. h = 4 + (r - g) / delta;
  4687. }
  4688. h = Math.min(h * 60, 360);
  4689. if (h < 0) {
  4690. h += 360;
  4691. }
  4692. const l = (min + max) / 2;
  4693. if (max === min) {
  4694. s = 0;
  4695. } else if (l <= 0.5) {
  4696. s = delta / (max + min);
  4697. } else {
  4698. s = delta / (2 - max - min);
  4699. }
  4700. return [h, s * 100, l * 100];
  4701. };
  4702. convert$1.rgb.hsv = function (rgb) {
  4703. let rdif;
  4704. let gdif;
  4705. let bdif;
  4706. let h;
  4707. let s;
  4708. const r = rgb[0] / 255;
  4709. const g = rgb[1] / 255;
  4710. const b = rgb[2] / 255;
  4711. const v = Math.max(r, g, b);
  4712. const diff = v - Math.min(r, g, b);
  4713. const diffc = function (c) {
  4714. return (v - c) / 6 / diff + 1 / 2;
  4715. };
  4716. if (diff === 0) {
  4717. h = 0;
  4718. s = 0;
  4719. } else {
  4720. s = diff / v;
  4721. rdif = diffc(r);
  4722. gdif = diffc(g);
  4723. bdif = diffc(b);
  4724. if (r === v) {
  4725. h = bdif - gdif;
  4726. } else if (g === v) {
  4727. h = (1 / 3) + rdif - bdif;
  4728. } else if (b === v) {
  4729. h = (2 / 3) + gdif - rdif;
  4730. }
  4731. if (h < 0) {
  4732. h += 1;
  4733. } else if (h > 1) {
  4734. h -= 1;
  4735. }
  4736. }
  4737. return [
  4738. h * 360,
  4739. s * 100,
  4740. v * 100
  4741. ];
  4742. };
  4743. convert$1.rgb.hwb = function (rgb) {
  4744. const r = rgb[0];
  4745. const g = rgb[1];
  4746. let b = rgb[2];
  4747. const h = convert$1.rgb.hsl(rgb)[0];
  4748. const w = 1 / 255 * Math.min(r, Math.min(g, b));
  4749. b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
  4750. return [h, w * 100, b * 100];
  4751. };
  4752. convert$1.rgb.cmyk = function (rgb) {
  4753. const r = rgb[0] / 255;
  4754. const g = rgb[1] / 255;
  4755. const b = rgb[2] / 255;
  4756. const k = Math.min(1 - r, 1 - g, 1 - b);
  4757. const c = (1 - r - k) / (1 - k) || 0;
  4758. const m = (1 - g - k) / (1 - k) || 0;
  4759. const y = (1 - b - k) / (1 - k) || 0;
  4760. return [c * 100, m * 100, y * 100, k * 100];
  4761. };
  4762. function comparativeDistance(x, y) {
  4763. /*
  4764. See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
  4765. */
  4766. return (
  4767. ((x[0] - y[0]) ** 2) +
  4768. ((x[1] - y[1]) ** 2) +
  4769. ((x[2] - y[2]) ** 2)
  4770. );
  4771. }
  4772. convert$1.rgb.keyword = function (rgb) {
  4773. const reversed = reverseKeywords[rgb];
  4774. if (reversed) {
  4775. return reversed;
  4776. }
  4777. let currentClosestDistance = Infinity;
  4778. let currentClosestKeyword;
  4779. for (const keyword of Object.keys(colorName)) {
  4780. const value = colorName[keyword];
  4781. // Compute comparative distance
  4782. const distance = comparativeDistance(rgb, value);
  4783. // Check if its less, if so set as closest
  4784. if (distance < currentClosestDistance) {
  4785. currentClosestDistance = distance;
  4786. currentClosestKeyword = keyword;
  4787. }
  4788. }
  4789. return currentClosestKeyword;
  4790. };
  4791. convert$1.keyword.rgb = function (keyword) {
  4792. return colorName[keyword];
  4793. };
  4794. convert$1.rgb.xyz = function (rgb) {
  4795. let r = rgb[0] / 255;
  4796. let g = rgb[1] / 255;
  4797. let b = rgb[2] / 255;
  4798. // Assume sRGB
  4799. r = r > 0.04045 ? (((r + 0.055) / 1.055) ** 2.4) : (r / 12.92);
  4800. g = g > 0.04045 ? (((g + 0.055) / 1.055) ** 2.4) : (g / 12.92);
  4801. b = b > 0.04045 ? (((b + 0.055) / 1.055) ** 2.4) : (b / 12.92);
  4802. const x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
  4803. const y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
  4804. const z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
  4805. return [x * 100, y * 100, z * 100];
  4806. };
  4807. convert$1.rgb.lab = function (rgb) {
  4808. const xyz = convert$1.rgb.xyz(rgb);
  4809. let x = xyz[0];
  4810. let y = xyz[1];
  4811. let z = xyz[2];
  4812. x /= 95.047;
  4813. y /= 100;
  4814. z /= 108.883;
  4815. x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
  4816. y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
  4817. z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
  4818. const l = (116 * y) - 16;
  4819. const a = 500 * (x - y);
  4820. const b = 200 * (y - z);
  4821. return [l, a, b];
  4822. };
  4823. convert$1.hsl.rgb = function (hsl) {
  4824. const h = hsl[0] / 360;
  4825. const s = hsl[1] / 100;
  4826. const l = hsl[2] / 100;
  4827. let t2;
  4828. let t3;
  4829. let val;
  4830. if (s === 0) {
  4831. val = l * 255;
  4832. return [val, val, val];
  4833. }
  4834. if (l < 0.5) {
  4835. t2 = l * (1 + s);
  4836. } else {
  4837. t2 = l + s - l * s;
  4838. }
  4839. const t1 = 2 * l - t2;
  4840. const rgb = [0, 0, 0];
  4841. for (let i = 0; i < 3; i++) {
  4842. t3 = h + 1 / 3 * -(i - 1);
  4843. if (t3 < 0) {
  4844. t3++;
  4845. }
  4846. if (t3 > 1) {
  4847. t3--;
  4848. }
  4849. if (6 * t3 < 1) {
  4850. val = t1 + (t2 - t1) * 6 * t3;
  4851. } else if (2 * t3 < 1) {
  4852. val = t2;
  4853. } else if (3 * t3 < 2) {
  4854. val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
  4855. } else {
  4856. val = t1;
  4857. }
  4858. rgb[i] = val * 255;
  4859. }
  4860. return rgb;
  4861. };
  4862. convert$1.hsl.hsv = function (hsl) {
  4863. const h = hsl[0];
  4864. let s = hsl[1] / 100;
  4865. let l = hsl[2] / 100;
  4866. let smin = s;
  4867. const lmin = Math.max(l, 0.01);
  4868. l *= 2;
  4869. s *= (l <= 1) ? l : 2 - l;
  4870. smin *= lmin <= 1 ? lmin : 2 - lmin;
  4871. const v = (l + s) / 2;
  4872. const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
  4873. return [h, sv * 100, v * 100];
  4874. };
  4875. convert$1.hsv.rgb = function (hsv) {
  4876. const h = hsv[0] / 60;
  4877. const s = hsv[1] / 100;
  4878. let v = hsv[2] / 100;
  4879. const hi = Math.floor(h) % 6;
  4880. const f = h - Math.floor(h);
  4881. const p = 255 * v * (1 - s);
  4882. const q = 255 * v * (1 - (s * f));
  4883. const t = 255 * v * (1 - (s * (1 - f)));
  4884. v *= 255;
  4885. switch (hi) {
  4886. case 0:
  4887. return [v, t, p];
  4888. case 1:
  4889. return [q, v, p];
  4890. case 2:
  4891. return [p, v, t];
  4892. case 3:
  4893. return [p, q, v];
  4894. case 4:
  4895. return [t, p, v];
  4896. case 5:
  4897. return [v, p, q];
  4898. }
  4899. };
  4900. convert$1.hsv.hsl = function (hsv) {
  4901. const h = hsv[0];
  4902. const s = hsv[1] / 100;
  4903. const v = hsv[2] / 100;
  4904. const vmin = Math.max(v, 0.01);
  4905. let sl;
  4906. let l;
  4907. l = (2 - s) * v;
  4908. const lmin = (2 - s) * vmin;
  4909. sl = s * vmin;
  4910. sl /= (lmin <= 1) ? lmin : 2 - lmin;
  4911. sl = sl || 0;
  4912. l /= 2;
  4913. return [h, sl * 100, l * 100];
  4914. };
  4915. // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
  4916. convert$1.hwb.rgb = function (hwb) {
  4917. const h = hwb[0] / 360;
  4918. let wh = hwb[1] / 100;
  4919. let bl = hwb[2] / 100;
  4920. const ratio = wh + bl;
  4921. let f;
  4922. // Wh + bl cant be > 1
  4923. if (ratio > 1) {
  4924. wh /= ratio;
  4925. bl /= ratio;
  4926. }
  4927. const i = Math.floor(6 * h);
  4928. const v = 1 - bl;
  4929. f = 6 * h - i;
  4930. if ((i & 0x01) !== 0) {
  4931. f = 1 - f;
  4932. }
  4933. const n = wh + f * (v - wh); // Linear interpolation
  4934. let r;
  4935. let g;
  4936. let b;
  4937. /* eslint-disable max-statements-per-line,no-multi-spaces */
  4938. switch (i) {
  4939. default:
  4940. case 6:
  4941. case 0: r = v; g = n; b = wh; break;
  4942. case 1: r = n; g = v; b = wh; break;
  4943. case 2: r = wh; g = v; b = n; break;
  4944. case 3: r = wh; g = n; b = v; break;
  4945. case 4: r = n; g = wh; b = v; break;
  4946. case 5: r = v; g = wh; b = n; break;
  4947. }
  4948. /* eslint-enable max-statements-per-line,no-multi-spaces */
  4949. return [r * 255, g * 255, b * 255];
  4950. };
  4951. convert$1.cmyk.rgb = function (cmyk) {
  4952. const c = cmyk[0] / 100;
  4953. const m = cmyk[1] / 100;
  4954. const y = cmyk[2] / 100;
  4955. const k = cmyk[3] / 100;
  4956. const r = 1 - Math.min(1, c * (1 - k) + k);
  4957. const g = 1 - Math.min(1, m * (1 - k) + k);
  4958. const b = 1 - Math.min(1, y * (1 - k) + k);
  4959. return [r * 255, g * 255, b * 255];
  4960. };
  4961. convert$1.xyz.rgb = function (xyz) {
  4962. const x = xyz[0] / 100;
  4963. const y = xyz[1] / 100;
  4964. const z = xyz[2] / 100;
  4965. let r;
  4966. let g;
  4967. let b;
  4968. r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
  4969. g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
  4970. b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
  4971. // Assume sRGB
  4972. r = r > 0.0031308
  4973. ? ((1.055 * (r ** (1.0 / 2.4))) - 0.055)
  4974. : r * 12.92;
  4975. g = g > 0.0031308
  4976. ? ((1.055 * (g ** (1.0 / 2.4))) - 0.055)
  4977. : g * 12.92;
  4978. b = b > 0.0031308
  4979. ? ((1.055 * (b ** (1.0 / 2.4))) - 0.055)
  4980. : b * 12.92;
  4981. r = Math.min(Math.max(0, r), 1);
  4982. g = Math.min(Math.max(0, g), 1);
  4983. b = Math.min(Math.max(0, b), 1);
  4984. return [r * 255, g * 255, b * 255];
  4985. };
  4986. convert$1.xyz.lab = function (xyz) {
  4987. let x = xyz[0];
  4988. let y = xyz[1];
  4989. let z = xyz[2];
  4990. x /= 95.047;
  4991. y /= 100;
  4992. z /= 108.883;
  4993. x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
  4994. y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
  4995. z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
  4996. const l = (116 * y) - 16;
  4997. const a = 500 * (x - y);
  4998. const b = 200 * (y - z);
  4999. return [l, a, b];
  5000. };
  5001. convert$1.lab.xyz = function (lab) {
  5002. const l = lab[0];
  5003. const a = lab[1];
  5004. const b = lab[2];
  5005. let x;
  5006. let y;
  5007. let z;
  5008. y = (l + 16) / 116;
  5009. x = a / 500 + y;
  5010. z = y - b / 200;
  5011. const y2 = y ** 3;
  5012. const x2 = x ** 3;
  5013. const z2 = z ** 3;
  5014. y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
  5015. x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
  5016. z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
  5017. x *= 95.047;
  5018. y *= 100;
  5019. z *= 108.883;
  5020. return [x, y, z];
  5021. };
  5022. convert$1.lab.lch = function (lab) {
  5023. const l = lab[0];
  5024. const a = lab[1];
  5025. const b = lab[2];
  5026. let h;
  5027. const hr = Math.atan2(b, a);
  5028. h = hr * 360 / 2 / Math.PI;
  5029. if (h < 0) {
  5030. h += 360;
  5031. }
  5032. const c = Math.sqrt(a * a + b * b);
  5033. return [l, c, h];
  5034. };
  5035. convert$1.lch.lab = function (lch) {
  5036. const l = lch[0];
  5037. const c = lch[1];
  5038. const h = lch[2];
  5039. const hr = h / 360 * 2 * Math.PI;
  5040. const a = c * Math.cos(hr);
  5041. const b = c * Math.sin(hr);
  5042. return [l, a, b];
  5043. };
  5044. convert$1.rgb.ansi16 = function (args, saturation = null) {
  5045. const [r, g, b] = args;
  5046. let value = saturation === null ? convert$1.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization
  5047. value = Math.round(value / 50);
  5048. if (value === 0) {
  5049. return 30;
  5050. }
  5051. let ansi = 30
  5052. + ((Math.round(b / 255) << 2)
  5053. | (Math.round(g / 255) << 1)
  5054. | Math.round(r / 255));
  5055. if (value === 2) {
  5056. ansi += 60;
  5057. }
  5058. return ansi;
  5059. };
  5060. convert$1.hsv.ansi16 = function (args) {
  5061. // Optimization here; we already know the value and don't need to get
  5062. // it converted for us.
  5063. return convert$1.rgb.ansi16(convert$1.hsv.rgb(args), args[2]);
  5064. };
  5065. convert$1.rgb.ansi256 = function (args) {
  5066. const r = args[0];
  5067. const g = args[1];
  5068. const b = args[2];
  5069. // We use the extended greyscale palette here, with the exception of
  5070. // black and white. normal palette only has 4 greyscale shades.
  5071. if (r === g && g === b) {
  5072. if (r < 8) {
  5073. return 16;
  5074. }
  5075. if (r > 248) {
  5076. return 231;
  5077. }
  5078. return Math.round(((r - 8) / 247) * 24) + 232;
  5079. }
  5080. const ansi = 16
  5081. + (36 * Math.round(r / 255 * 5))
  5082. + (6 * Math.round(g / 255 * 5))
  5083. + Math.round(b / 255 * 5);
  5084. return ansi;
  5085. };
  5086. convert$1.ansi16.rgb = function (args) {
  5087. let color = args % 10;
  5088. // Handle greyscale
  5089. if (color === 0 || color === 7) {
  5090. if (args > 50) {
  5091. color += 3.5;
  5092. }
  5093. color = color / 10.5 * 255;
  5094. return [color, color, color];
  5095. }
  5096. const mult = (~~(args > 50) + 1) * 0.5;
  5097. const r = ((color & 1) * mult) * 255;
  5098. const g = (((color >> 1) & 1) * mult) * 255;
  5099. const b = (((color >> 2) & 1) * mult) * 255;
  5100. return [r, g, b];
  5101. };
  5102. convert$1.ansi256.rgb = function (args) {
  5103. // Handle greyscale
  5104. if (args >= 232) {
  5105. const c = (args - 232) * 10 + 8;
  5106. return [c, c, c];
  5107. }
  5108. args -= 16;
  5109. let rem;
  5110. const r = Math.floor(args / 36) / 5 * 255;
  5111. const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
  5112. const b = (rem % 6) / 5 * 255;
  5113. return [r, g, b];
  5114. };
  5115. convert$1.rgb.hex = function (args) {
  5116. const integer = ((Math.round(args[0]) & 0xFF) << 16)
  5117. + ((Math.round(args[1]) & 0xFF) << 8)
  5118. + (Math.round(args[2]) & 0xFF);
  5119. const string = integer.toString(16).toUpperCase();
  5120. return '000000'.substring(string.length) + string;
  5121. };
  5122. convert$1.hex.rgb = function (args) {
  5123. const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
  5124. if (!match) {
  5125. return [0, 0, 0];
  5126. }
  5127. let colorString = match[0];
  5128. if (match[0].length === 3) {
  5129. colorString = colorString.split('').map(char => {
  5130. return char + char;
  5131. }).join('');
  5132. }
  5133. const integer = parseInt(colorString, 16);
  5134. const r = (integer >> 16) & 0xFF;
  5135. const g = (integer >> 8) & 0xFF;
  5136. const b = integer & 0xFF;
  5137. return [r, g, b];
  5138. };
  5139. convert$1.rgb.hcg = function (rgb) {
  5140. const r = rgb[0] / 255;
  5141. const g = rgb[1] / 255;
  5142. const b = rgb[2] / 255;
  5143. const max = Math.max(Math.max(r, g), b);
  5144. const min = Math.min(Math.min(r, g), b);
  5145. const chroma = (max - min);
  5146. let grayscale;
  5147. let hue;
  5148. if (chroma < 1) {
  5149. grayscale = min / (1 - chroma);
  5150. } else {
  5151. grayscale = 0;
  5152. }
  5153. if (chroma <= 0) {
  5154. hue = 0;
  5155. } else
  5156. if (max === r) {
  5157. hue = ((g - b) / chroma) % 6;
  5158. } else
  5159. if (max === g) {
  5160. hue = 2 + (b - r) / chroma;
  5161. } else {
  5162. hue = 4 + (r - g) / chroma;
  5163. }
  5164. hue /= 6;
  5165. hue %= 1;
  5166. return [hue * 360, chroma * 100, grayscale * 100];
  5167. };
  5168. convert$1.hsl.hcg = function (hsl) {
  5169. const s = hsl[1] / 100;
  5170. const l = hsl[2] / 100;
  5171. const c = l < 0.5 ? (2.0 * s * l) : (2.0 * s * (1.0 - l));
  5172. let f = 0;
  5173. if (c < 1.0) {
  5174. f = (l - 0.5 * c) / (1.0 - c);
  5175. }
  5176. return [hsl[0], c * 100, f * 100];
  5177. };
  5178. convert$1.hsv.hcg = function (hsv) {
  5179. const s = hsv[1] / 100;
  5180. const v = hsv[2] / 100;
  5181. const c = s * v;
  5182. let f = 0;
  5183. if (c < 1.0) {
  5184. f = (v - c) / (1 - c);
  5185. }
  5186. return [hsv[0], c * 100, f * 100];
  5187. };
  5188. convert$1.hcg.rgb = function (hcg) {
  5189. const h = hcg[0] / 360;
  5190. const c = hcg[1] / 100;
  5191. const g = hcg[2] / 100;
  5192. if (c === 0.0) {
  5193. return [g * 255, g * 255, g * 255];
  5194. }
  5195. const pure = [0, 0, 0];
  5196. const hi = (h % 1) * 6;
  5197. const v = hi % 1;
  5198. const w = 1 - v;
  5199. let mg = 0;
  5200. /* eslint-disable max-statements-per-line */
  5201. switch (Math.floor(hi)) {
  5202. case 0:
  5203. pure[0] = 1; pure[1] = v; pure[2] = 0; break;
  5204. case 1:
  5205. pure[0] = w; pure[1] = 1; pure[2] = 0; break;
  5206. case 2:
  5207. pure[0] = 0; pure[1] = 1; pure[2] = v; break;
  5208. case 3:
  5209. pure[0] = 0; pure[1] = w; pure[2] = 1; break;
  5210. case 4:
  5211. pure[0] = v; pure[1] = 0; pure[2] = 1; break;
  5212. default:
  5213. pure[0] = 1; pure[1] = 0; pure[2] = w;
  5214. }
  5215. /* eslint-enable max-statements-per-line */
  5216. mg = (1.0 - c) * g;
  5217. return [
  5218. (c * pure[0] + mg) * 255,
  5219. (c * pure[1] + mg) * 255,
  5220. (c * pure[2] + mg) * 255
  5221. ];
  5222. };
  5223. convert$1.hcg.hsv = function (hcg) {
  5224. const c = hcg[1] / 100;
  5225. const g = hcg[2] / 100;
  5226. const v = c + g * (1.0 - c);
  5227. let f = 0;
  5228. if (v > 0.0) {
  5229. f = c / v;
  5230. }
  5231. return [hcg[0], f * 100, v * 100];
  5232. };
  5233. convert$1.hcg.hsl = function (hcg) {
  5234. const c = hcg[1] / 100;
  5235. const g = hcg[2] / 100;
  5236. const l = g * (1.0 - c) + 0.5 * c;
  5237. let s = 0;
  5238. if (l > 0.0 && l < 0.5) {
  5239. s = c / (2 * l);
  5240. } else
  5241. if (l >= 0.5 && l < 1.0) {
  5242. s = c / (2 * (1 - l));
  5243. }
  5244. return [hcg[0], s * 100, l * 100];
  5245. };
  5246. convert$1.hcg.hwb = function (hcg) {
  5247. const c = hcg[1] / 100;
  5248. const g = hcg[2] / 100;
  5249. const v = c + g * (1.0 - c);
  5250. return [hcg[0], (v - c) * 100, (1 - v) * 100];
  5251. };
  5252. convert$1.hwb.hcg = function (hwb) {
  5253. const w = hwb[1] / 100;
  5254. const b = hwb[2] / 100;
  5255. const v = 1 - b;
  5256. const c = v - w;
  5257. let g = 0;
  5258. if (c < 1) {
  5259. g = (v - c) / (1 - c);
  5260. }
  5261. return [hwb[0], c * 100, g * 100];
  5262. };
  5263. convert$1.apple.rgb = function (apple) {
  5264. return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
  5265. };
  5266. convert$1.rgb.apple = function (rgb) {
  5267. return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
  5268. };
  5269. convert$1.gray.rgb = function (args) {
  5270. return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
  5271. };
  5272. convert$1.gray.hsl = function (args) {
  5273. return [0, 0, args[0]];
  5274. };
  5275. convert$1.gray.hsv = convert$1.gray.hsl;
  5276. convert$1.gray.hwb = function (gray) {
  5277. return [0, 100, gray[0]];
  5278. };
  5279. convert$1.gray.cmyk = function (gray) {
  5280. return [0, 0, 0, gray[0]];
  5281. };
  5282. convert$1.gray.lab = function (gray) {
  5283. return [gray[0], 0, 0];
  5284. };
  5285. convert$1.gray.hex = function (gray) {
  5286. const val = Math.round(gray[0] / 100 * 255) & 0xFF;
  5287. const integer = (val << 16) + (val << 8) + val;
  5288. const string = integer.toString(16).toUpperCase();
  5289. return '000000'.substring(string.length) + string;
  5290. };
  5291. convert$1.rgb.gray = function (rgb) {
  5292. const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
  5293. return [val / 255 * 100];
  5294. };
  5295. /*
  5296. This function routes a model to all other models.
  5297. all functions that are routed have a property `.conversion` attached
  5298. to the returned synthetic function. This property is an array
  5299. of strings, each with the steps in between the 'from' and 'to'
  5300. color models (inclusive).
  5301. conversions that are not possible simply are not included.
  5302. */
  5303. function buildGraph() {
  5304. const graph = {};
  5305. // https://jsperf.com/object-keys-vs-for-in-with-closure/3
  5306. const models = Object.keys(conversions);
  5307. for (let len = models.length, i = 0; i < len; i++) {
  5308. graph[models[i]] = {
  5309. // http://jsperf.com/1-vs-infinity
  5310. // micro-opt, but this is simple.
  5311. distance: -1,
  5312. parent: null
  5313. };
  5314. }
  5315. return graph;
  5316. }
  5317. // https://en.wikipedia.org/wiki/Breadth-first_search
  5318. function deriveBFS(fromModel) {
  5319. const graph = buildGraph();
  5320. const queue = [fromModel]; // Unshift -> queue -> pop
  5321. graph[fromModel].distance = 0;
  5322. while (queue.length) {
  5323. const current = queue.pop();
  5324. const adjacents = Object.keys(conversions[current]);
  5325. for (let len = adjacents.length, i = 0; i < len; i++) {
  5326. const adjacent = adjacents[i];
  5327. const node = graph[adjacent];
  5328. if (node.distance === -1) {
  5329. node.distance = graph[current].distance + 1;
  5330. node.parent = current;
  5331. queue.unshift(adjacent);
  5332. }
  5333. }
  5334. }
  5335. return graph;
  5336. }
  5337. function link(from, to) {
  5338. return function (args) {
  5339. return to(from(args));
  5340. };
  5341. }
  5342. function wrapConversion(toModel, graph) {
  5343. const path = [graph[toModel].parent, toModel];
  5344. let fn = conversions[graph[toModel].parent][toModel];
  5345. let cur = graph[toModel].parent;
  5346. while (graph[cur].parent) {
  5347. path.unshift(graph[cur].parent);
  5348. fn = link(conversions[graph[cur].parent][cur], fn);
  5349. cur = graph[cur].parent;
  5350. }
  5351. fn.conversion = path;
  5352. return fn;
  5353. }
  5354. var route = function (fromModel) {
  5355. const graph = deriveBFS(fromModel);
  5356. const conversion = {};
  5357. const models = Object.keys(graph);
  5358. for (let len = models.length, i = 0; i < len; i++) {
  5359. const toModel = models[i];
  5360. const node = graph[toModel];
  5361. if (node.parent === null) {
  5362. // No possible conversion, or this node is the source model.
  5363. continue;
  5364. }
  5365. conversion[toModel] = wrapConversion(toModel, graph);
  5366. }
  5367. return conversion;
  5368. };
  5369. const convert = {};
  5370. const models = Object.keys(conversions);
  5371. function wrapRaw(fn) {
  5372. const wrappedFn = function (...args) {
  5373. const arg0 = args[0];
  5374. if (arg0 === undefined || arg0 === null) {
  5375. return arg0;
  5376. }
  5377. if (arg0.length > 1) {
  5378. args = arg0;
  5379. }
  5380. return fn(args);
  5381. };
  5382. // Preserve .conversion property if there is one
  5383. if ('conversion' in fn) {
  5384. wrappedFn.conversion = fn.conversion;
  5385. }
  5386. return wrappedFn;
  5387. }
  5388. function wrapRounded(fn) {
  5389. const wrappedFn = function (...args) {
  5390. const arg0 = args[0];
  5391. if (arg0 === undefined || arg0 === null) {
  5392. return arg0;
  5393. }
  5394. if (arg0.length > 1) {
  5395. args = arg0;
  5396. }
  5397. const result = fn(args);
  5398. // We're assuming the result is an array here.
  5399. // see notice in conversions.js; don't use box types
  5400. // in conversion functions.
  5401. if (typeof result === 'object') {
  5402. for (let len = result.length, i = 0; i < len; i++) {
  5403. result[i] = Math.round(result[i]);
  5404. }
  5405. }
  5406. return result;
  5407. };
  5408. // Preserve .conversion property if there is one
  5409. if ('conversion' in fn) {
  5410. wrappedFn.conversion = fn.conversion;
  5411. }
  5412. return wrappedFn;
  5413. }
  5414. models.forEach(fromModel => {
  5415. convert[fromModel] = {};
  5416. Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
  5417. Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
  5418. const routes = route(fromModel);
  5419. const routeModels = Object.keys(routes);
  5420. routeModels.forEach(toModel => {
  5421. const fn = routes[toModel];
  5422. convert[fromModel][toModel] = wrapRounded(fn);
  5423. convert[fromModel][toModel].raw = wrapRaw(fn);
  5424. });
  5425. });
  5426. var colorConvert = convert;
  5427. const skippedModels = [
  5428. // To be honest, I don't really feel like keyword belongs in color convert, but eh.
  5429. 'keyword',
  5430. // Gray conflicts with some method names, and has its own method defined.
  5431. 'gray',
  5432. // Shouldn't really be in color-convert either...
  5433. 'hex',
  5434. ];
  5435. const hashedModelKeys = {};
  5436. for (const model of Object.keys(colorConvert)) {
  5437. hashedModelKeys[[...colorConvert[model].labels].sort().join('')] = model;
  5438. }
  5439. const limiters = {};
  5440. function Color(object, model) {
  5441. if (!(this instanceof Color)) {
  5442. return new Color(object, model);
  5443. }
  5444. if (model && model in skippedModels) {
  5445. model = null;
  5446. }
  5447. if (model && !(model in colorConvert)) {
  5448. throw new Error('Unknown model: ' + model);
  5449. }
  5450. let i;
  5451. let channels;
  5452. if (object == null) { // eslint-disable-line no-eq-null,eqeqeq
  5453. this.model = 'rgb';
  5454. this.color = [0, 0, 0];
  5455. this.valpha = 1;
  5456. } else if (object instanceof Color) {
  5457. this.model = object.model;
  5458. this.color = [...object.color];
  5459. this.valpha = object.valpha;
  5460. } else if (typeof object === 'string') {
  5461. const result = colorString.get(object);
  5462. if (result === null) {
  5463. throw new Error('Unable to parse color from string: ' + object);
  5464. }
  5465. this.model = result.model;
  5466. channels = colorConvert[this.model].channels;
  5467. this.color = result.value.slice(0, channels);
  5468. this.valpha = typeof result.value[channels] === 'number' ? result.value[channels] : 1;
  5469. } else if (object.length > 0) {
  5470. this.model = model || 'rgb';
  5471. channels = colorConvert[this.model].channels;
  5472. const newArray = Array.prototype.slice.call(object, 0, channels);
  5473. this.color = zeroArray(newArray, channels);
  5474. this.valpha = typeof object[channels] === 'number' ? object[channels] : 1;
  5475. } else if (typeof object === 'number') {
  5476. // This is always RGB - can be converted later on.
  5477. this.model = 'rgb';
  5478. this.color = [
  5479. (object >> 16) & 0xFF,
  5480. (object >> 8) & 0xFF,
  5481. object & 0xFF,
  5482. ];
  5483. this.valpha = 1;
  5484. } else {
  5485. this.valpha = 1;
  5486. const keys = Object.keys(object);
  5487. if ('alpha' in object) {
  5488. keys.splice(keys.indexOf('alpha'), 1);
  5489. this.valpha = typeof object.alpha === 'number' ? object.alpha : 0;
  5490. }
  5491. const hashedKeys = keys.sort().join('');
  5492. if (!(hashedKeys in hashedModelKeys)) {
  5493. throw new Error('Unable to parse color from object: ' + JSON.stringify(object));
  5494. }
  5495. this.model = hashedModelKeys[hashedKeys];
  5496. const {labels} = colorConvert[this.model];
  5497. const color = [];
  5498. for (i = 0; i < labels.length; i++) {
  5499. color.push(object[labels[i]]);
  5500. }
  5501. this.color = zeroArray(color);
  5502. }
  5503. // Perform limitations (clamping, etc.)
  5504. if (limiters[this.model]) {
  5505. channels = colorConvert[this.model].channels;
  5506. for (i = 0; i < channels; i++) {
  5507. const limit = limiters[this.model][i];
  5508. if (limit) {
  5509. this.color[i] = limit(this.color[i]);
  5510. }
  5511. }
  5512. }
  5513. this.valpha = Math.max(0, Math.min(1, this.valpha));
  5514. if (Object.freeze) {
  5515. Object.freeze(this);
  5516. }
  5517. }
  5518. Color.prototype = {
  5519. toString() {
  5520. return this.string();
  5521. },
  5522. toJSON() {
  5523. return this[this.model]();
  5524. },
  5525. string(places) {
  5526. let self = this.model in colorString.to ? this : this.rgb();
  5527. self = self.round(typeof places === 'number' ? places : 1);
  5528. const args = self.valpha === 1 ? self.color : [...self.color, this.valpha];
  5529. return colorString.to[self.model](args);
  5530. },
  5531. percentString(places) {
  5532. const self = this.rgb().round(typeof places === 'number' ? places : 1);
  5533. const args = self.valpha === 1 ? self.color : [...self.color, this.valpha];
  5534. return colorString.to.rgb.percent(args);
  5535. },
  5536. array() {
  5537. return this.valpha === 1 ? [...this.color] : [...this.color, this.valpha];
  5538. },
  5539. object() {
  5540. const result = {};
  5541. const {channels} = colorConvert[this.model];
  5542. const {labels} = colorConvert[this.model];
  5543. for (let i = 0; i < channels; i++) {
  5544. result[labels[i]] = this.color[i];
  5545. }
  5546. if (this.valpha !== 1) {
  5547. result.alpha = this.valpha;
  5548. }
  5549. return result;
  5550. },
  5551. unitArray() {
  5552. const rgb = this.rgb().color;
  5553. rgb[0] /= 255;
  5554. rgb[1] /= 255;
  5555. rgb[2] /= 255;
  5556. if (this.valpha !== 1) {
  5557. rgb.push(this.valpha);
  5558. }
  5559. return rgb;
  5560. },
  5561. unitObject() {
  5562. const rgb = this.rgb().object();
  5563. rgb.r /= 255;
  5564. rgb.g /= 255;
  5565. rgb.b /= 255;
  5566. if (this.valpha !== 1) {
  5567. rgb.alpha = this.valpha;
  5568. }
  5569. return rgb;
  5570. },
  5571. round(places) {
  5572. places = Math.max(places || 0, 0);
  5573. return new Color([...this.color.map(roundToPlace(places)), this.valpha], this.model);
  5574. },
  5575. alpha(value) {
  5576. if (value !== undefined) {
  5577. return new Color([...this.color, Math.max(0, Math.min(1, value))], this.model);
  5578. }
  5579. return this.valpha;
  5580. },
  5581. // Rgb
  5582. red: getset('rgb', 0, maxfn(255)),
  5583. green: getset('rgb', 1, maxfn(255)),
  5584. blue: getset('rgb', 2, maxfn(255)),
  5585. hue: getset(['hsl', 'hsv', 'hsl', 'hwb', 'hcg'], 0, value => ((value % 360) + 360) % 360),
  5586. saturationl: getset('hsl', 1, maxfn(100)),
  5587. lightness: getset('hsl', 2, maxfn(100)),
  5588. saturationv: getset('hsv', 1, maxfn(100)),
  5589. value: getset('hsv', 2, maxfn(100)),
  5590. chroma: getset('hcg', 1, maxfn(100)),
  5591. gray: getset('hcg', 2, maxfn(100)),
  5592. white: getset('hwb', 1, maxfn(100)),
  5593. wblack: getset('hwb', 2, maxfn(100)),
  5594. cyan: getset('cmyk', 0, maxfn(100)),
  5595. magenta: getset('cmyk', 1, maxfn(100)),
  5596. yellow: getset('cmyk', 2, maxfn(100)),
  5597. black: getset('cmyk', 3, maxfn(100)),
  5598. x: getset('xyz', 0, maxfn(95.047)),
  5599. y: getset('xyz', 1, maxfn(100)),
  5600. z: getset('xyz', 2, maxfn(108.833)),
  5601. l: getset('lab', 0, maxfn(100)),
  5602. a: getset('lab', 1),
  5603. b: getset('lab', 2),
  5604. keyword(value) {
  5605. if (value !== undefined) {
  5606. return new Color(value);
  5607. }
  5608. return colorConvert[this.model].keyword(this.color);
  5609. },
  5610. hex(value) {
  5611. if (value !== undefined) {
  5612. return new Color(value);
  5613. }
  5614. return colorString.to.hex(this.rgb().round().color);
  5615. },
  5616. hexa(value) {
  5617. if (value !== undefined) {
  5618. return new Color(value);
  5619. }
  5620. const rgbArray = this.rgb().round().color;
  5621. let alphaHex = Math.round(this.valpha * 255).toString(16).toUpperCase();
  5622. if (alphaHex.length === 1) {
  5623. alphaHex = '0' + alphaHex;
  5624. }
  5625. return colorString.to.hex(rgbArray) + alphaHex;
  5626. },
  5627. rgbNumber() {
  5628. const rgb = this.rgb().color;
  5629. return ((rgb[0] & 0xFF) << 16) | ((rgb[1] & 0xFF) << 8) | (rgb[2] & 0xFF);
  5630. },
  5631. luminosity() {
  5632. // http://www.w3.org/TR/WCAG20/#relativeluminancedef
  5633. const rgb = this.rgb().color;
  5634. const lum = [];
  5635. for (const [i, element] of rgb.entries()) {
  5636. const chan = element / 255;
  5637. lum[i] = (chan <= 0.04045) ? chan / 12.92 : ((chan + 0.055) / 1.055) ** 2.4;
  5638. }
  5639. return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
  5640. },
  5641. contrast(color2) {
  5642. // http://www.w3.org/TR/WCAG20/#contrast-ratiodef
  5643. const lum1 = this.luminosity();
  5644. const lum2 = color2.luminosity();
  5645. if (lum1 > lum2) {
  5646. return (lum1 + 0.05) / (lum2 + 0.05);
  5647. }
  5648. return (lum2 + 0.05) / (lum1 + 0.05);
  5649. },
  5650. level(color2) {
  5651. // https://www.w3.org/TR/WCAG/#contrast-enhanced
  5652. const contrastRatio = this.contrast(color2);
  5653. if (contrastRatio >= 7) {
  5654. return 'AAA';
  5655. }
  5656. return (contrastRatio >= 4.5) ? 'AA' : '';
  5657. },
  5658. isDark() {
  5659. // YIQ equation from http://24ways.org/2010/calculating-color-contrast
  5660. const rgb = this.rgb().color;
  5661. const yiq = (rgb[0] * 2126 + rgb[1] * 7152 + rgb[2] * 722) / 10000;
  5662. return yiq < 128;
  5663. },
  5664. isLight() {
  5665. return !this.isDark();
  5666. },
  5667. negate() {
  5668. const rgb = this.rgb();
  5669. for (let i = 0; i < 3; i++) {
  5670. rgb.color[i] = 255 - rgb.color[i];
  5671. }
  5672. return rgb;
  5673. },
  5674. lighten(ratio) {
  5675. const hsl = this.hsl();
  5676. hsl.color[2] += hsl.color[2] * ratio;
  5677. return hsl;
  5678. },
  5679. darken(ratio) {
  5680. const hsl = this.hsl();
  5681. hsl.color[2] -= hsl.color[2] * ratio;
  5682. return hsl;
  5683. },
  5684. saturate(ratio) {
  5685. const hsl = this.hsl();
  5686. hsl.color[1] += hsl.color[1] * ratio;
  5687. return hsl;
  5688. },
  5689. desaturate(ratio) {
  5690. const hsl = this.hsl();
  5691. hsl.color[1] -= hsl.color[1] * ratio;
  5692. return hsl;
  5693. },
  5694. whiten(ratio) {
  5695. const hwb = this.hwb();
  5696. hwb.color[1] += hwb.color[1] * ratio;
  5697. return hwb;
  5698. },
  5699. blacken(ratio) {
  5700. const hwb = this.hwb();
  5701. hwb.color[2] += hwb.color[2] * ratio;
  5702. return hwb;
  5703. },
  5704. grayscale() {
  5705. // http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale
  5706. const rgb = this.rgb().color;
  5707. const value = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
  5708. return Color.rgb(value, value, value);
  5709. },
  5710. fade(ratio) {
  5711. return this.alpha(this.valpha - (this.valpha * ratio));
  5712. },
  5713. opaquer(ratio) {
  5714. return this.alpha(this.valpha + (this.valpha * ratio));
  5715. },
  5716. rotate(degrees) {
  5717. const hsl = this.hsl();
  5718. let hue = hsl.color[0];
  5719. hue = (hue + degrees) % 360;
  5720. hue = hue < 0 ? 360 + hue : hue;
  5721. hsl.color[0] = hue;
  5722. return hsl;
  5723. },
  5724. mix(mixinColor, weight) {
  5725. // Ported from sass implementation in C
  5726. // https://github.com/sass/libsass/blob/0e6b4a2850092356aa3ece07c6b249f0221caced/functions.cpp#L209
  5727. if (!mixinColor || !mixinColor.rgb) {
  5728. throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof mixinColor);
  5729. }
  5730. const color1 = mixinColor.rgb();
  5731. const color2 = this.rgb();
  5732. const p = weight === undefined ? 0.5 : weight;
  5733. const w = 2 * p - 1;
  5734. const a = color1.alpha() - color2.alpha();
  5735. const w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2;
  5736. const w2 = 1 - w1;
  5737. return Color.rgb(
  5738. w1 * color1.red() + w2 * color2.red(),
  5739. w1 * color1.green() + w2 * color2.green(),
  5740. w1 * color1.blue() + w2 * color2.blue(),
  5741. color1.alpha() * p + color2.alpha() * (1 - p));
  5742. },
  5743. };
  5744. // Model conversion methods and static constructors
  5745. for (const model of Object.keys(colorConvert)) {
  5746. if (skippedModels.includes(model)) {
  5747. continue;
  5748. }
  5749. const {channels} = colorConvert[model];
  5750. // Conversion methods
  5751. Color.prototype[model] = function (...args) {
  5752. if (this.model === model) {
  5753. return new Color(this);
  5754. }
  5755. if (args.length > 0) {
  5756. return new Color(args, model);
  5757. }
  5758. return new Color([...assertArray(colorConvert[this.model][model].raw(this.color)), this.valpha], model);
  5759. };
  5760. // 'static' construction methods
  5761. Color[model] = function (...args) {
  5762. let color = args[0];
  5763. if (typeof color === 'number') {
  5764. color = zeroArray(args, channels);
  5765. }
  5766. return new Color(color, model);
  5767. };
  5768. }
  5769. function roundTo(number, places) {
  5770. return Number(number.toFixed(places));
  5771. }
  5772. function roundToPlace(places) {
  5773. return function (number) {
  5774. return roundTo(number, places);
  5775. };
  5776. }
  5777. function getset(model, channel, modifier) {
  5778. model = Array.isArray(model) ? model : [model];
  5779. for (const m of model) {
  5780. (limiters[m] || (limiters[m] = []))[channel] = modifier;
  5781. }
  5782. model = model[0];
  5783. return function (value) {
  5784. let result;
  5785. if (value !== undefined) {
  5786. if (modifier) {
  5787. value = modifier(value);
  5788. }
  5789. result = this[model]();
  5790. result.color[channel] = value;
  5791. return result;
  5792. }
  5793. result = this[model]().color[channel];
  5794. if (modifier) {
  5795. result = modifier(result);
  5796. }
  5797. return result;
  5798. };
  5799. }
  5800. function maxfn(max) {
  5801. return function (v) {
  5802. return Math.max(0, Math.min(max, v));
  5803. };
  5804. }
  5805. function assertArray(value) {
  5806. return Array.isArray(value) ? value : [value];
  5807. }
  5808. function zeroArray(array, length) {
  5809. for (let i = 0; i < length; i++) {
  5810. if (typeof array[i] !== 'number') {
  5811. array[i] = 0;
  5812. }
  5813. }
  5814. return array;
  5815. }
  5816. var color = Color;
  5817. const CSS$G = {
  5818. container: "container",
  5819. controlSection: "control-section",
  5820. hexOptions: "color-hex-options",
  5821. section: "section",
  5822. header: "header",
  5823. control: "control",
  5824. splitSection: "section--split",
  5825. colorModeContainer: "color-mode-container",
  5826. colorMode: "color-mode",
  5827. channels: "channels",
  5828. channel: "channel",
  5829. savedColors: "saved-colors",
  5830. savedColorsSection: "saved-colors-section",
  5831. saveColor: "save-color",
  5832. deleteColor: "delete-color",
  5833. savedColorsButtons: "saved-colors-buttons",
  5834. headerHex: "header--hex",
  5835. colorFieldAndSlider: "color-field-and-slider",
  5836. colorFieldAndSliderInteractive: "color-field-and-slider--interactive",
  5837. colorFieldAndSliderWrap: "color-field-and-slider-wrap",
  5838. scope: "scope",
  5839. hueScope: "scope--hue",
  5840. colorFieldScope: "scope--color-field",
  5841. savedColor: "saved-color"
  5842. };
  5843. const DEFAULT_COLOR$1 = color("#007AC2");
  5844. const DEFAULT_STORAGE_KEY_PREFIX = "calcite-color-";
  5845. const RGB_LIMITS = {
  5846. r: 255,
  5847. g: 255,
  5848. b: 255
  5849. };
  5850. const HSV_LIMITS = {
  5851. h: 360,
  5852. s: 100,
  5853. v: 100
  5854. };
  5855. const TEXT$h = {
  5856. b: "B",
  5857. blue: "Blue",
  5858. deleteColor: "Delete color",
  5859. g: "G",
  5860. green: "Green",
  5861. h: "H",
  5862. hsv: "HSV",
  5863. hex: "Hex",
  5864. hue: "Hue",
  5865. noColor: "No color",
  5866. r: "R",
  5867. red: "Red",
  5868. rgb: "RGB",
  5869. s: "S",
  5870. saturation: "Saturation",
  5871. saveColor: "Save color",
  5872. saved: "Saved",
  5873. v: "V",
  5874. value: "Value"
  5875. };
  5876. const DIMENSIONS = {
  5877. s: {
  5878. slider: {
  5879. height: 10,
  5880. width: 160
  5881. },
  5882. colorField: {
  5883. height: 80,
  5884. width: 160
  5885. },
  5886. thumb: {
  5887. radius: 8
  5888. }
  5889. },
  5890. m: {
  5891. slider: {
  5892. height: 14,
  5893. width: 272
  5894. },
  5895. colorField: {
  5896. height: 150,
  5897. width: 272
  5898. },
  5899. thumb: {
  5900. radius: 10
  5901. }
  5902. },
  5903. l: {
  5904. slider: {
  5905. height: 16,
  5906. width: 464
  5907. },
  5908. colorField: {
  5909. height: 200,
  5910. width: 464
  5911. },
  5912. thumb: {
  5913. radius: 12
  5914. }
  5915. }
  5916. };
  5917. const clamp = (value, min, max) => Math.max(min, Math.min(value, max));
  5918. const decimalPlaces = (value) => {
  5919. const match = ("" + value).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
  5920. if (!match) {
  5921. return 0;
  5922. }
  5923. return Math.max(0,
  5924. // Number of digits right of decimal point.
  5925. (match[1] ? match[1].length : 0) -
  5926. // Adjust for scientific notation.
  5927. (match[2] ? +match[2] : 0));
  5928. };
  5929. 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}";
  5930. const throttleFor60FpsInMs = 16;
  5931. const defaultValue = normalizeHex(DEFAULT_COLOR$1.hex());
  5932. const defaultFormat = "auto";
  5933. const ColorPicker = class extends HTMLElement$1 {
  5934. constructor() {
  5935. super();
  5936. this.__registerHost();
  5937. this.__attachShadow();
  5938. this.calciteColorPickerChange = createEvent(this, "calciteColorPickerChange", 7);
  5939. this.calciteColorPickerInput = createEvent(this, "calciteColorPickerInput", 7);
  5940. //--------------------------------------------------------------------------
  5941. //
  5942. // Public properties
  5943. //
  5944. //--------------------------------------------------------------------------
  5945. /**
  5946. * When false, empty color (null) will be allowed as a value. Otherwise, a color value is always enforced by the component.
  5947. *
  5948. * When true, clearing the input and blurring will restore the last valid color set. When false, it will set it to empty.
  5949. */
  5950. this.allowEmpty = false;
  5951. /** specify the appearance - default (containing border), or minimal (no containing border) */
  5952. this.appearance = "default";
  5953. /**
  5954. * Internal prop for advanced use-cases.
  5955. *
  5956. * @internal
  5957. */
  5958. this.color = DEFAULT_COLOR$1;
  5959. /**
  5960. * When true, disabled prevents user interaction.
  5961. */
  5962. this.disabled = false;
  5963. /**
  5964. * The format of the value property.
  5965. *
  5966. * When "auto", the format will be inferred from `value` when set.
  5967. * @default "auto"
  5968. */
  5969. this.format = defaultFormat;
  5970. /** When true, hides the hex input */
  5971. this.hideHex = false;
  5972. /** When true, hides the RGB/HSV channel inputs */
  5973. this.hideChannels = false;
  5974. /** When true, hides the saved colors section */
  5975. this.hideSaved = false;
  5976. /** Label used for the blue channel
  5977. * @default "B"
  5978. */
  5979. this.intlB = TEXT$h.b;
  5980. /** Label used for the blue channel description
  5981. * @default "Blue"
  5982. */
  5983. this.intlBlue = TEXT$h.blue;
  5984. /** Label used for the delete color button.
  5985. * @default "Delete color"
  5986. */
  5987. this.intlDeleteColor = TEXT$h.deleteColor;
  5988. /** Label used for the green channel
  5989. * @default "G"
  5990. */
  5991. this.intlG = TEXT$h.g;
  5992. /** Label used for the green channel description
  5993. * @default "Green"
  5994. */
  5995. this.intlGreen = TEXT$h.green;
  5996. /** Label used for the hue channel
  5997. * @default "H"
  5998. */
  5999. this.intlH = TEXT$h.h;
  6000. /** Label used for the HSV mode
  6001. * @default "HSV"
  6002. */
  6003. this.intlHsv = TEXT$h.hsv;
  6004. /** Label used for the hex input
  6005. * @default "Hex"
  6006. */
  6007. this.intlHex = TEXT$h.hex;
  6008. /** Label used for the hue channel description
  6009. * @default "Hue"
  6010. */
  6011. this.intlHue = TEXT$h.hue;
  6012. /**
  6013. * Label used for the hex input when there is no color selected.
  6014. * @default "No color"
  6015. */
  6016. this.intlNoColor = TEXT$h.noColor;
  6017. /** Label used for the red channel
  6018. * @default "R"
  6019. */
  6020. this.intlR = TEXT$h.r;
  6021. /** Label used for the red channel description
  6022. * @default "Red"
  6023. */
  6024. this.intlRed = TEXT$h.red;
  6025. /** Label used for the RGB mode
  6026. * @default "RGB"
  6027. */
  6028. this.intlRgb = TEXT$h.rgb;
  6029. /** Label used for the saturation channel
  6030. * @default "S"
  6031. */
  6032. this.intlS = TEXT$h.s;
  6033. /** Label used for the saturation channel description
  6034. * @default "Saturation"
  6035. */
  6036. this.intlSaturation = TEXT$h.saturation;
  6037. /** Label used for the save color button.
  6038. * @default "Save color"
  6039. */
  6040. this.intlSaveColor = TEXT$h.saveColor;
  6041. /** Label used for the saved colors section
  6042. * @default "Saved"
  6043. */
  6044. this.intlSaved = TEXT$h.saved;
  6045. /** Label used for the value channel
  6046. * @default "V"
  6047. */
  6048. this.intlV = TEXT$h.v;
  6049. /** Label used for the
  6050. * @default "Value"
  6051. */
  6052. this.intlValue = TEXT$h.value;
  6053. /**
  6054. * The scale of the color picker.
  6055. */
  6056. this.scale = "m";
  6057. /**
  6058. * The color value.
  6059. *
  6060. * This value can be either a {@link https://developer.mozilla.org/en-US/docs/Web/CSS/color|CSS string}
  6061. * a RGB, HSL or HSV object.
  6062. *
  6063. * The type will be preserved as the color is updated.
  6064. * @default "#007ac2"
  6065. * @see [ColorValue](https://github.com/Esri/calcite-components/blob/master/src/components/color-picker/interfaces.ts#L10)
  6066. */
  6067. this.value = defaultValue;
  6068. this.colorFieldAndSliderHovered = false;
  6069. this.hueThumbState = "idle";
  6070. this.internalColorUpdateContext = null;
  6071. this.mode = CSSColorMode.HEX;
  6072. this.shiftKeyChannelAdjustment = 0;
  6073. this.sliderThumbState = "idle";
  6074. this.colorFieldAndSliderInteractive = false;
  6075. this.channelMode = "rgb";
  6076. this.channels = this.toChannels(DEFAULT_COLOR$1);
  6077. this.dimensions = DIMENSIONS.m;
  6078. this.savedColors = [];
  6079. this.handleTabActivate = (event) => {
  6080. this.channelMode = event.currentTarget.getAttribute("data-color-mode");
  6081. this.updateChannelsFromColor(this.color);
  6082. };
  6083. this.handleColorFieldScopeKeyDown = (event) => {
  6084. const key = event.key;
  6085. const arrowKeyToXYOffset = {
  6086. ArrowUp: { x: 0, y: -10 },
  6087. ArrowRight: { x: 10, y: 0 },
  6088. ArrowDown: { x: 0, y: 10 },
  6089. ArrowLeft: { x: -10, y: 0 }
  6090. };
  6091. if (arrowKeyToXYOffset[key]) {
  6092. event.preventDefault();
  6093. this.scopeOrientation = key === "ArrowDown" || key === "ArrowUp" ? "vertical" : "horizontal";
  6094. this.captureColorFieldColor(this.colorFieldScopeLeft + arrowKeyToXYOffset[key].x || 0, this.colorFieldScopeTop + arrowKeyToXYOffset[key].y || 0, false);
  6095. }
  6096. };
  6097. this.handleHueScopeKeyDown = (event) => {
  6098. const modifier = event.shiftKey ? 10 : 1;
  6099. const key = event.key;
  6100. const arrowKeyToXOffset = {
  6101. ArrowUp: 1,
  6102. ArrowRight: 1,
  6103. ArrowDown: -1,
  6104. ArrowLeft: -1
  6105. };
  6106. if (arrowKeyToXOffset[key]) {
  6107. event.preventDefault();
  6108. const delta = arrowKeyToXOffset[key] * modifier;
  6109. const hue = this.baseColorFieldColor.hue();
  6110. const color = this.baseColorFieldColor.hue(hue + delta);
  6111. this.internalColorSet(color, false);
  6112. }
  6113. };
  6114. this.handleHexInputChange = (event) => {
  6115. event.stopPropagation();
  6116. const { allowEmpty, color: color$1 } = this;
  6117. const input = event.target;
  6118. const hex = input.value;
  6119. if (allowEmpty && !hex) {
  6120. this.internalColorSet(null);
  6121. return;
  6122. }
  6123. const normalizedHex = color$1 && normalizeHex(color$1.hex());
  6124. if (hex !== normalizedHex) {
  6125. this.internalColorSet(color(hex));
  6126. }
  6127. };
  6128. this.handleSavedColorSelect = (event) => {
  6129. const swatch = event.currentTarget;
  6130. this.internalColorSet(color(swatch.color));
  6131. };
  6132. this.handleChannelInput = (event) => {
  6133. const input = event.currentTarget;
  6134. const internalInput = event.detail.nativeEvent.target;
  6135. const channelIndex = Number(input.getAttribute("data-channel-index"));
  6136. const limit = this.channelMode === "rgb"
  6137. ? RGB_LIMITS[Object.keys(RGB_LIMITS)[channelIndex]]
  6138. : HSV_LIMITS[Object.keys(HSV_LIMITS)[channelIndex]];
  6139. let inputValue;
  6140. if (this.allowEmpty && !input.value) {
  6141. inputValue = "";
  6142. }
  6143. else {
  6144. const value = Number(input.value) + this.shiftKeyChannelAdjustment;
  6145. const clamped = clamp(value, 0, limit);
  6146. inputValue = clamped.toString();
  6147. }
  6148. input.value = inputValue;
  6149. internalInput.value = inputValue;
  6150. };
  6151. this.handleChannelChange = (event) => {
  6152. const input = event.currentTarget;
  6153. const channelIndex = Number(input.getAttribute("data-channel-index"));
  6154. const channels = [...this.channels];
  6155. const shouldClearChannels = this.allowEmpty && !input.value;
  6156. if (shouldClearChannels) {
  6157. this.channels = [null, null, null];
  6158. this.internalColorSet(null);
  6159. return;
  6160. }
  6161. channels[channelIndex] = Number(input.value);
  6162. this.updateColorFromChannels(channels);
  6163. };
  6164. this.handleSavedColorKeyDown = (event) => {
  6165. if (event.key === " " || event.key === "Enter") {
  6166. event.preventDefault();
  6167. event.stopPropagation();
  6168. this.handleSavedColorSelect(event);
  6169. }
  6170. };
  6171. this.handleColorFieldAndSliderMouseLeave = () => {
  6172. this.colorFieldAndSliderInteractive = false;
  6173. this.colorFieldAndSliderHovered = false;
  6174. if (this.sliderThumbState !== "drag" && this.hueThumbState !== "drag") {
  6175. this.hueThumbState = "idle";
  6176. this.sliderThumbState = "idle";
  6177. this.drawColorFieldAndSlider();
  6178. }
  6179. };
  6180. this.handleColorFieldAndSliderMouseDown = (event) => {
  6181. const { offsetX, offsetY } = event;
  6182. const region = this.getCanvasRegion(offsetY);
  6183. if (region === "color-field") {
  6184. this.hueThumbState = "drag";
  6185. this.captureColorFieldColor(offsetX, offsetY);
  6186. this.colorFieldScopeNode.focus();
  6187. }
  6188. else if (region === "slider") {
  6189. this.sliderThumbState = "drag";
  6190. this.captureHueSliderColor(offsetX);
  6191. this.hueScopeNode.focus();
  6192. }
  6193. // prevent text selection outside of color field & slider area
  6194. event.preventDefault();
  6195. document.addEventListener("mousemove", this.globalMouseMoveHandler);
  6196. document.addEventListener("mouseup", this.globalMouseUpHandler, { once: true });
  6197. this.activeColorFieldAndSliderRect =
  6198. this.fieldAndSliderRenderingContext.canvas.getBoundingClientRect();
  6199. };
  6200. this.globalMouseUpHandler = () => {
  6201. const previouslyDragging = this.sliderThumbState === "drag" || this.hueThumbState === "drag";
  6202. this.hueThumbState = "idle";
  6203. this.sliderThumbState = "idle";
  6204. this.activeColorFieldAndSliderRect = null;
  6205. this.drawColorFieldAndSlider();
  6206. if (previouslyDragging) {
  6207. this.calciteColorPickerChange.emit();
  6208. }
  6209. };
  6210. this.globalMouseMoveHandler = (event) => {
  6211. const { el, dimensions } = this;
  6212. const sliderThumbDragging = this.sliderThumbState === "drag";
  6213. const hueThumbDragging = this.hueThumbState === "drag";
  6214. if (!el.isConnected || (!sliderThumbDragging && !hueThumbDragging)) {
  6215. return;
  6216. }
  6217. let samplingX;
  6218. let samplingY;
  6219. const colorFieldAndSliderRect = this.activeColorFieldAndSliderRect;
  6220. const { clientX, clientY } = event;
  6221. if (this.colorFieldAndSliderHovered) {
  6222. samplingX = clientX - colorFieldAndSliderRect.x;
  6223. samplingY = clientY - colorFieldAndSliderRect.y;
  6224. }
  6225. else {
  6226. const colorFieldWidth = dimensions.colorField.width;
  6227. const colorFieldHeight = dimensions.colorField.height;
  6228. const hueSliderHeight = dimensions.slider.height;
  6229. if (clientX < colorFieldAndSliderRect.x + colorFieldWidth &&
  6230. clientX > colorFieldAndSliderRect.x) {
  6231. samplingX = clientX - colorFieldAndSliderRect.x;
  6232. }
  6233. else if (clientX < colorFieldAndSliderRect.x) {
  6234. samplingX = 0;
  6235. }
  6236. else {
  6237. samplingX = colorFieldWidth;
  6238. }
  6239. if (clientY < colorFieldAndSliderRect.y + colorFieldHeight + hueSliderHeight &&
  6240. clientY > colorFieldAndSliderRect.y) {
  6241. samplingY = clientY - colorFieldAndSliderRect.y;
  6242. }
  6243. else if (clientY < colorFieldAndSliderRect.y) {
  6244. samplingY = 0;
  6245. }
  6246. else {
  6247. samplingY = colorFieldHeight + hueSliderHeight;
  6248. }
  6249. }
  6250. if (hueThumbDragging) {
  6251. this.captureColorFieldColor(samplingX, samplingY, false);
  6252. }
  6253. else {
  6254. this.captureHueSliderColor(samplingX);
  6255. }
  6256. };
  6257. this.handleColorFieldAndSliderMouseEnterOrMove = ({ offsetX, offsetY }) => {
  6258. const { dimensions: { colorField, slider, thumb } } = this;
  6259. this.colorFieldAndSliderInteractive = offsetY <= colorField.height + slider.height;
  6260. this.colorFieldAndSliderHovered = true;
  6261. const region = this.getCanvasRegion(offsetY);
  6262. if (region === "color-field") {
  6263. const prevHueThumbState = this.hueThumbState;
  6264. const color = this.baseColorFieldColor.hsv();
  6265. const centerX = Math.round(color.saturationv() / (HSV_LIMITS.s / colorField.width));
  6266. const centerY = Math.round(colorField.height - color.value() / (HSV_LIMITS.v / colorField.height));
  6267. const hoveringThumb = this.containsPoint(offsetX, offsetY, centerX, centerY, thumb.radius);
  6268. let transitionedBetweenHoverAndIdle = false;
  6269. if (prevHueThumbState === "idle" && hoveringThumb) {
  6270. this.hueThumbState = "hover";
  6271. transitionedBetweenHoverAndIdle = true;
  6272. }
  6273. else if (prevHueThumbState === "hover" && !hoveringThumb) {
  6274. this.hueThumbState = "idle";
  6275. transitionedBetweenHoverAndIdle = true;
  6276. }
  6277. if (this.hueThumbState !== "drag") {
  6278. if (transitionedBetweenHoverAndIdle) {
  6279. // refresh since we won't update color and thus no redraw
  6280. this.drawColorFieldAndSlider();
  6281. }
  6282. }
  6283. }
  6284. else if (region === "slider") {
  6285. const sliderThumbColor = this.baseColorFieldColor.hsv().saturationv(100).value(100);
  6286. const prevSliderThumbState = this.sliderThumbState;
  6287. const sliderThumbCenterX = Math.round(sliderThumbColor.hue() / (360 / slider.width));
  6288. const sliderThumbCenterY = Math.round((slider.height + this.getSliderCapSpacing()) / 2) + colorField.height;
  6289. const hoveringSliderThumb = this.containsPoint(offsetX, offsetY, sliderThumbCenterX, sliderThumbCenterY, thumb.radius);
  6290. let sliderThumbTransitionedBetweenHoverAndIdle = false;
  6291. if (prevSliderThumbState === "idle" && hoveringSliderThumb) {
  6292. this.sliderThumbState = "hover";
  6293. sliderThumbTransitionedBetweenHoverAndIdle = true;
  6294. }
  6295. else if (prevSliderThumbState === "hover" && !hoveringSliderThumb) {
  6296. this.sliderThumbState = "idle";
  6297. sliderThumbTransitionedBetweenHoverAndIdle = true;
  6298. }
  6299. if (this.sliderThumbState !== "drag") {
  6300. if (sliderThumbTransitionedBetweenHoverAndIdle) {
  6301. // refresh since we won't update color and thus no redraw
  6302. this.drawColorFieldAndSlider();
  6303. }
  6304. }
  6305. }
  6306. };
  6307. this.storeColorFieldScope = (node) => {
  6308. this.colorFieldScopeNode = node;
  6309. };
  6310. this.storeHueScope = (node) => {
  6311. this.hueScopeNode = node;
  6312. };
  6313. this.renderChannelsTabTitle = (channelMode) => {
  6314. const { channelMode: activeChannelMode, intlRgb, intlHsv } = this;
  6315. const active = channelMode === activeChannelMode;
  6316. const label = channelMode === "rgb" ? intlRgb : intlHsv;
  6317. return (h("calcite-tab-title", { active: active, class: CSS$G.colorMode, "data-color-mode": channelMode, key: channelMode, onCalciteTabsActivate: this.handleTabActivate }, label));
  6318. };
  6319. this.renderChannelsTab = (channelMode) => {
  6320. const { channelMode: activeChannelMode, channels, intlB, intlBlue, intlG, intlGreen, intlH, intlHue, intlR, intlRed, intlS, intlSaturation, intlV, intlValue } = this;
  6321. const active = channelMode === activeChannelMode;
  6322. const isRgb = channelMode === "rgb";
  6323. const channelLabels = isRgb ? [intlR, intlG, intlB] : [intlH, intlS, intlV];
  6324. const channelAriaLabels = isRgb
  6325. ? [intlRed, intlGreen, intlBlue]
  6326. : [intlHue, intlSaturation, intlValue];
  6327. const direction = getElementDir(this.el);
  6328. return (h("calcite-tab", { active: active, class: CSS$G.control, key: channelMode }, h("div", { class: CSS$G.channels, dir: "ltr" }, channels.map((channel, index) =>
  6329. /* the channel container is ltr, so we apply the host's direction */
  6330. this.renderChannel(channel, index, channelLabels[index], channelAriaLabels[index], direction)))));
  6331. };
  6332. 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() }));
  6333. this.deleteColor = () => {
  6334. const colorToDelete = this.color.hex();
  6335. const inStorage = this.savedColors.indexOf(colorToDelete) > -1;
  6336. if (!inStorage) {
  6337. return;
  6338. }
  6339. const savedColors = this.savedColors.filter((color) => color !== colorToDelete);
  6340. this.savedColors = savedColors;
  6341. const storageKey = `${DEFAULT_STORAGE_KEY_PREFIX}${this.storageId}`;
  6342. if (this.storageId) {
  6343. localStorage.setItem(storageKey, JSON.stringify(savedColors));
  6344. }
  6345. };
  6346. this.saveColor = () => {
  6347. const colorToSave = this.color.hex();
  6348. const alreadySaved = this.savedColors.indexOf(colorToSave) > -1;
  6349. if (alreadySaved) {
  6350. return;
  6351. }
  6352. const savedColors = [...this.savedColors, colorToSave];
  6353. this.savedColors = savedColors;
  6354. const storageKey = `${DEFAULT_STORAGE_KEY_PREFIX}${this.storageId}`;
  6355. if (this.storageId) {
  6356. localStorage.setItem(storageKey, JSON.stringify(savedColors));
  6357. }
  6358. };
  6359. this.drawColorFieldAndSlider = throttle$1(() => {
  6360. if (!this.fieldAndSliderRenderingContext) {
  6361. return;
  6362. }
  6363. this.drawColorField();
  6364. this.drawHueSlider();
  6365. }, throttleFor60FpsInMs);
  6366. this.captureColorFieldColor = (x, y, skipEqual = true) => {
  6367. const { dimensions: { colorField: { height, width } } } = this;
  6368. const saturation = Math.round((HSV_LIMITS.s / width) * x);
  6369. const value = Math.round((HSV_LIMITS.v / height) * (height - y));
  6370. this.internalColorSet(this.baseColorFieldColor.hsv().saturationv(saturation).value(value), skipEqual);
  6371. };
  6372. this.initColorFieldAndSlider = (canvas) => {
  6373. this.fieldAndSliderRenderingContext = canvas.getContext("2d");
  6374. this.setCanvasContextSize(canvas, {
  6375. width: this.dimensions.colorField.width,
  6376. height: this.dimensions.colorField.height +
  6377. this.dimensions.slider.height +
  6378. this.getSliderCapSpacing() * 2
  6379. });
  6380. this.drawColorFieldAndSlider();
  6381. };
  6382. }
  6383. handleColorChange(color, oldColor) {
  6384. this.drawColorFieldAndSlider();
  6385. this.updateChannelsFromColor(color);
  6386. this.previousColor = oldColor;
  6387. }
  6388. handleFormatChange(format) {
  6389. this.setMode(format);
  6390. this.internalColorSet(this.color, false, "internal");
  6391. }
  6392. handleScaleChange(scale = "m") {
  6393. this.updateDimensions(scale);
  6394. }
  6395. handleValueChange(value, oldValue) {
  6396. const { allowEmpty, format } = this;
  6397. const checkMode = !allowEmpty || value;
  6398. let modeChanged = false;
  6399. if (checkMode) {
  6400. const nextMode = parseMode(value);
  6401. if (!nextMode || (format !== "auto" && nextMode !== format)) {
  6402. this.showIncompatibleColorWarning(value, format);
  6403. this.value = oldValue;
  6404. return;
  6405. }
  6406. modeChanged = this.mode !== nextMode;
  6407. this.setMode(nextMode);
  6408. }
  6409. const dragging = this.sliderThumbState === "drag" || this.hueThumbState === "drag";
  6410. if (this.internalColorUpdateContext === "initial") {
  6411. return;
  6412. }
  6413. if (this.internalColorUpdateContext === "user-interaction") {
  6414. this.calciteColorPickerInput.emit();
  6415. if (!dragging) {
  6416. this.calciteColorPickerChange.emit();
  6417. }
  6418. return;
  6419. }
  6420. const color$1 = allowEmpty && !value ? null : color(value);
  6421. const colorChanged = !colorEqual(color$1, this.color);
  6422. if (modeChanged || colorChanged) {
  6423. this.internalColorSet(color$1, true, "internal");
  6424. }
  6425. }
  6426. //--------------------------------------------------------------------------
  6427. //
  6428. // Internal State/Props
  6429. //
  6430. //--------------------------------------------------------------------------
  6431. get baseColorFieldColor() {
  6432. return this.color || this.previousColor || DEFAULT_COLOR$1;
  6433. }
  6434. // using @Listen as a workaround for VDOM listener not firing
  6435. handleChannelKeyUpOrDown(event) {
  6436. this.shiftKeyChannelAdjustment = 0;
  6437. const key = event.key;
  6438. if ((key !== "ArrowUp" && key !== "ArrowDown") ||
  6439. !event.composedPath().some((node) => { var _a; return (_a = node.classList) === null || _a === void 0 ? void 0 : _a.contains(CSS$G.channel); })) {
  6440. return;
  6441. }
  6442. const { shiftKey } = event;
  6443. event.preventDefault();
  6444. if (!this.color) {
  6445. this.internalColorSet(this.previousColor);
  6446. event.stopPropagation();
  6447. return;
  6448. }
  6449. // this gets applied to the input's up/down arrow increment/decrement
  6450. const complementaryBump = 9;
  6451. this.shiftKeyChannelAdjustment =
  6452. key === "ArrowUp" && shiftKey
  6453. ? complementaryBump
  6454. : key === "ArrowDown" && shiftKey
  6455. ? -complementaryBump
  6456. : 0;
  6457. }
  6458. //--------------------------------------------------------------------------
  6459. //
  6460. // Public Methods
  6461. //
  6462. //--------------------------------------------------------------------------
  6463. /** Sets focus on the component. */
  6464. async setFocus() {
  6465. return focusElement(this.colorFieldScopeNode);
  6466. }
  6467. //--------------------------------------------------------------------------
  6468. //
  6469. // Lifecycle
  6470. //
  6471. //--------------------------------------------------------------------------
  6472. componentWillLoad() {
  6473. const { allowEmpty, color: color$1, format, value } = this;
  6474. const willSetNoColor = allowEmpty && !value;
  6475. const parsedMode = parseMode(value);
  6476. const valueIsCompatible = willSetNoColor || (format === "auto" && parsedMode) || format === parsedMode;
  6477. const initialColor = willSetNoColor ? null : valueIsCompatible ? color(value) : color$1;
  6478. if (!valueIsCompatible) {
  6479. this.showIncompatibleColorWarning(value, format);
  6480. }
  6481. this.setMode(format);
  6482. this.internalColorSet(initialColor, false, "initial");
  6483. this.updateDimensions(this.scale);
  6484. const storageKey = `${DEFAULT_STORAGE_KEY_PREFIX}${this.storageId}`;
  6485. if (this.storageId && localStorage.getItem(storageKey)) {
  6486. this.savedColors = JSON.parse(localStorage.getItem(storageKey));
  6487. }
  6488. }
  6489. disconnectedCallback() {
  6490. document.removeEventListener("mousemove", this.globalMouseMoveHandler);
  6491. document.removeEventListener("mouseup", this.globalMouseUpHandler);
  6492. }
  6493. componentDidRender() {
  6494. updateHostInteraction(this);
  6495. }
  6496. //--------------------------------------------------------------------------
  6497. //
  6498. // Render Methods
  6499. //
  6500. //--------------------------------------------------------------------------
  6501. render() {
  6502. const { allowEmpty, color, intlDeleteColor, hideHex, hideChannels, hideSaved, intlHex, intlSaved, intlSaveColor, savedColors, scale } = this;
  6503. const selectedColorInHex = color ? color.hex() : null;
  6504. const hexInputScale = scale === "l" ? "m" : "s";
  6505. const { colorFieldAndSliderInteractive, colorFieldScopeTop, colorFieldScopeLeft, hueScopeLeft, hueScopeTop, scopeOrientation, dimensions: { colorField: { height: colorFieldHeight, width: colorFieldWidth }, slider: { height: sliderHeight } } } = this;
  6506. const hueTop = hueScopeTop !== null && hueScopeTop !== void 0 ? hueScopeTop : sliderHeight / 2 + colorFieldHeight;
  6507. const hueLeft = hueScopeLeft !== null && hueScopeLeft !== void 0 ? hueScopeLeft : (colorFieldWidth * DEFAULT_COLOR$1.hue()) / HSV_LIMITS.h;
  6508. const noColor = color === null;
  6509. const vertical = scopeOrientation === "vertical";
  6510. return (h("div", { class: CSS$G.container }, h("div", { class: CSS$G.colorFieldAndSliderWrap }, h("canvas", { class: {
  6511. [CSS$G.colorFieldAndSlider]: true,
  6512. [CSS$G.colorFieldAndSliderInteractive]: colorFieldAndSliderInteractive
  6513. }, 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: {
  6514. [CSS$G.controlSection]: true,
  6515. [CSS$G.section]: true
  6516. } }, hideHex ? null : (h("div", { class: CSS$G.hexOptions }, h("span", { class: {
  6517. [CSS$G.header]: true,
  6518. [CSS$G.headerHex]: true
  6519. } }, 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: {
  6520. [CSS$G.colorModeContainer]: true,
  6521. [CSS$G.splitSection]: true
  6522. }, 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 }, [
  6523. ...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 })))
  6524. ])) : null))));
  6525. }
  6526. // --------------------------------------------------------------------------
  6527. //
  6528. // Private Methods
  6529. //
  6530. //--------------------------------------------------------------------------
  6531. handleKeyDown(event) {
  6532. if (event.key === "Enter") {
  6533. event.preventDefault();
  6534. }
  6535. }
  6536. showIncompatibleColorWarning(value, format) {
  6537. console.warn(`ignoring color value (${value}) as it is not compatible with the current format (${format})`);
  6538. }
  6539. setMode(format) {
  6540. this.mode = format === "auto" ? this.mode : format;
  6541. }
  6542. captureHueSliderColor(x) {
  6543. const { dimensions: { slider: { width } } } = this;
  6544. const hue = (360 / width) * x;
  6545. this.internalColorSet(this.baseColorFieldColor.hue(hue), false);
  6546. }
  6547. getCanvasRegion(y) {
  6548. const { dimensions: { colorField: { height: colorFieldHeight }, slider: { height: sliderHeight } } } = this;
  6549. if (y <= colorFieldHeight) {
  6550. return "color-field";
  6551. }
  6552. if (y <= colorFieldHeight + sliderHeight) {
  6553. return "slider";
  6554. }
  6555. return "none";
  6556. }
  6557. internalColorSet(color, skipEqual = true, context = "user-interaction") {
  6558. if (skipEqual && colorEqual(color, this.color)) {
  6559. return;
  6560. }
  6561. this.internalColorUpdateContext = context;
  6562. this.color = color;
  6563. this.value = this.toValue(color);
  6564. this.internalColorUpdateContext = null;
  6565. }
  6566. toValue(color, format = this.mode) {
  6567. if (!color) {
  6568. return null;
  6569. }
  6570. const hexMode = "hex";
  6571. if (format.includes(hexMode)) {
  6572. return normalizeHex(color.round()[hexMode]());
  6573. }
  6574. if (format.includes("-css")) {
  6575. return color[format.replace("-css", "").replace("a", "")]().round().string();
  6576. }
  6577. const colorObject = color[format]().round().object();
  6578. if (format.endsWith("a")) {
  6579. // normalize alpha prop
  6580. colorObject.a = colorObject.alpha;
  6581. delete colorObject.alpha;
  6582. }
  6583. return colorObject;
  6584. }
  6585. getSliderCapSpacing() {
  6586. const { dimensions: { slider: { height }, thumb: { radius } } } = this;
  6587. return radius * 2 - height;
  6588. }
  6589. updateDimensions(scale = "m") {
  6590. this.dimensions = DIMENSIONS[scale];
  6591. }
  6592. drawColorField() {
  6593. const context = this.fieldAndSliderRenderingContext;
  6594. const { dimensions: { colorField: { height, width } } } = this;
  6595. context.fillStyle = this.baseColorFieldColor.hsv().saturationv(100).value(100).string();
  6596. context.fillRect(0, 0, width, height);
  6597. const whiteGradient = context.createLinearGradient(0, 0, width, 0);
  6598. whiteGradient.addColorStop(0, "rgba(255,255,255,1)");
  6599. whiteGradient.addColorStop(1, "rgba(255,255,255,0)");
  6600. context.fillStyle = whiteGradient;
  6601. context.fillRect(0, 0, width, height);
  6602. const blackGradient = context.createLinearGradient(0, 0, 0, height);
  6603. blackGradient.addColorStop(0, "rgba(0,0,0,0)");
  6604. blackGradient.addColorStop(1, "rgba(0,0,0,1)");
  6605. context.fillStyle = blackGradient;
  6606. context.fillRect(0, 0, width, height);
  6607. this.drawActiveColorFieldColor();
  6608. }
  6609. setCanvasContextSize(canvas, { height, width }) {
  6610. const devicePixelRatio = window.devicePixelRatio || 1;
  6611. canvas.width = width * devicePixelRatio;
  6612. canvas.height = height * devicePixelRatio;
  6613. canvas.style.height = `${height}px`;
  6614. canvas.style.width = `${width}px`;
  6615. const context = canvas.getContext("2d");
  6616. context.scale(devicePixelRatio, devicePixelRatio);
  6617. }
  6618. containsPoint(testPointX, testPointY, boundsX, boundsY, boundsRadius) {
  6619. return (Math.pow(testPointX - boundsX, 2) + Math.pow(testPointY - boundsY, 2) <=
  6620. Math.pow(boundsRadius, 2));
  6621. }
  6622. drawActiveColorFieldColor() {
  6623. const { color } = this;
  6624. if (!color) {
  6625. return;
  6626. }
  6627. const hsvColor = color.hsv();
  6628. const { dimensions: { colorField: { height, width }, thumb: { radius } } } = this;
  6629. const x = hsvColor.saturationv() / (HSV_LIMITS.s / width);
  6630. const y = height - hsvColor.value() / (HSV_LIMITS.v / height);
  6631. requestAnimationFrame(() => {
  6632. this.colorFieldScopeLeft = x;
  6633. this.colorFieldScopeTop = y;
  6634. });
  6635. this.drawThumb(this.fieldAndSliderRenderingContext, radius, x, y, hsvColor, this.hueThumbState);
  6636. }
  6637. drawThumb(context, radius, x, y, color, state) {
  6638. const startAngle = 0;
  6639. const endAngle = 2 * Math.PI;
  6640. context.beginPath();
  6641. context.arc(x, y, radius, startAngle, endAngle);
  6642. context.shadowBlur = state === "hover" ? 32 : 16;
  6643. context.shadowColor = `rgba(0, 0, 0, ${state === "drag" ? 0.32 : 0.16})`;
  6644. context.fillStyle = "#fff";
  6645. context.fill();
  6646. context.beginPath();
  6647. context.arc(x, y, radius - 3, startAngle, endAngle);
  6648. context.shadowBlur = 0;
  6649. context.shadowColor = "transparent";
  6650. context.fillStyle = color.rgb().string();
  6651. context.fill();
  6652. }
  6653. drawActiveHueSliderColor() {
  6654. const { color } = this;
  6655. if (!color) {
  6656. return;
  6657. }
  6658. const hsvColor = color.hsv().saturationv(100).value(100);
  6659. const { dimensions: { colorField: { height: colorFieldHeight }, slider: { height, width }, thumb: { radius } } } = this;
  6660. const x = hsvColor.hue() / (360 / width);
  6661. const y = height / 2 + colorFieldHeight;
  6662. requestAnimationFrame(() => {
  6663. this.hueScopeLeft = x;
  6664. this.hueScopeTop = y;
  6665. });
  6666. this.drawThumb(this.fieldAndSliderRenderingContext, radius, x, y, hsvColor, this.sliderThumbState);
  6667. }
  6668. drawHueSlider() {
  6669. const context = this.fieldAndSliderRenderingContext;
  6670. const { dimensions: { colorField: { height: colorFieldHeight }, slider: { height, width } } } = this;
  6671. const gradient = context.createLinearGradient(0, 0, width, 0);
  6672. const hueSliderColorStopKeywords = ["red", "yellow", "lime", "cyan", "blue", "magenta", "red"];
  6673. const offset = 1 / (hueSliderColorStopKeywords.length - 1);
  6674. let currentOffset = 0;
  6675. hueSliderColorStopKeywords.forEach((keyword) => {
  6676. gradient.addColorStop(currentOffset, color(keyword).string());
  6677. currentOffset += offset;
  6678. });
  6679. context.fillStyle = gradient;
  6680. context.clearRect(0, colorFieldHeight, width, height + this.getSliderCapSpacing() * 2);
  6681. context.fillRect(0, colorFieldHeight, width, height);
  6682. this.drawActiveHueSliderColor();
  6683. }
  6684. updateColorFromChannels(channels) {
  6685. this.internalColorSet(color(channels, this.channelMode));
  6686. }
  6687. updateChannelsFromColor(color) {
  6688. this.channels = color ? this.toChannels(color) : [null, null, null];
  6689. }
  6690. toChannels(color) {
  6691. const { channelMode } = this;
  6692. return color[channelMode]()
  6693. .array()
  6694. .map((value) => Math.floor(value));
  6695. }
  6696. get el() { return this; }
  6697. static get watchers() { return {
  6698. "color": ["handleColorChange"],
  6699. "format": ["handleFormatChange"],
  6700. "scale": ["handleScaleChange"],
  6701. "value": ["handleValueChange"]
  6702. }; }
  6703. static get style() { return colorPickerCss; }
  6704. };
  6705. const CSS$F = {
  6706. container: "container",
  6707. preview: "preview",
  6708. input: "input"
  6709. };
  6710. 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}";
  6711. const DEFAULT_COLOR = color();
  6712. const ColorPickerHexInput = class extends HTMLElement$1 {
  6713. constructor() {
  6714. super();
  6715. this.__registerHost();
  6716. this.__attachShadow();
  6717. this.calciteColorPickerHexInputChange = createEvent(this, "calciteColorPickerHexInputChange", 7);
  6718. //--------------------------------------------------------------------------
  6719. //
  6720. // Public Properties
  6721. //
  6722. //--------------------------------------------------------------------------
  6723. /**
  6724. * When false, empty color (null) will be allowed as a value. Otherwise, a color value is always enforced by the component.
  6725. *
  6726. * When true, clearing the input and blurring will restore the last valid color set. When false, it will set it to empty.
  6727. */
  6728. this.allowEmpty = false;
  6729. /**
  6730. * Label used for the hex input.
  6731. * @default "Hex"
  6732. */
  6733. this.intlHex = TEXT$h.hex;
  6734. /**
  6735. * Label used for the hex input when there is no color selected.
  6736. * @default "No color"
  6737. */
  6738. this.intlNoColor = TEXT$h.noColor;
  6739. /**
  6740. * The component's scale.
  6741. */
  6742. this.scale = "m";
  6743. /**
  6744. * The hex value.
  6745. */
  6746. this.value = normalizeHex(DEFAULT_COLOR.hex());
  6747. this.onCalciteInputBlur = () => {
  6748. const node = this.inputNode;
  6749. const inputValue = node.value;
  6750. const hex = `#${inputValue}`;
  6751. const willClearValue = this.allowEmpty && !inputValue;
  6752. if (willClearValue || (isValidHex(hex) && isLonghandHex(hex))) {
  6753. return;
  6754. }
  6755. // manipulating DOM directly since rerender doesn't update input value
  6756. node.value =
  6757. this.allowEmpty && !this.internalColor
  6758. ? ""
  6759. : this.formatForInternalInput(rgbToHex(this.internalColor.object()));
  6760. };
  6761. this.onInputChange = () => {
  6762. this.internalSetValue(this.inputNode.value, this.value);
  6763. };
  6764. /**
  6765. * The last valid/selected color. Used as a fallback if an invalid hex code is entered.
  6766. */
  6767. this.internalColor = DEFAULT_COLOR;
  6768. this.previousNonNullValue = this.value;
  6769. this.storeInputRef = (node) => {
  6770. this.inputNode = node;
  6771. };
  6772. }
  6773. //--------------------------------------------------------------------------
  6774. //
  6775. // Lifecycle
  6776. //
  6777. //--------------------------------------------------------------------------
  6778. connectedCallback() {
  6779. const { allowEmpty, value } = this;
  6780. if (value) {
  6781. const normalized = normalizeHex(value);
  6782. if (isValidHex(normalized)) {
  6783. this.internalSetValue(normalized, normalized, false);
  6784. }
  6785. return;
  6786. }
  6787. if (allowEmpty) {
  6788. this.internalSetValue(null, null, false);
  6789. }
  6790. }
  6791. handleValueChange(value, oldValue) {
  6792. this.internalSetValue(value, oldValue, false);
  6793. }
  6794. // using @Listen as a workaround for VDOM listener not firing
  6795. onInputKeyDown(event) {
  6796. const { altKey, ctrlKey, metaKey, shiftKey } = event;
  6797. const { internalColor, value } = this;
  6798. const key = event.key;
  6799. if (key === "Tab" || key === "Enter") {
  6800. this.onInputChange();
  6801. return;
  6802. }
  6803. const isNudgeKey = key === "ArrowDown" || key === "ArrowUp";
  6804. const oldValue = this.value;
  6805. if (isNudgeKey) {
  6806. if (!value) {
  6807. this.internalSetValue(this.previousNonNullValue, oldValue);
  6808. event.preventDefault();
  6809. return;
  6810. }
  6811. const direction = key === "ArrowUp" ? 1 : -1;
  6812. const bump = shiftKey ? 10 : 1;
  6813. this.internalSetValue(normalizeHex(this.nudgeRGBChannels(internalColor, bump * direction).hex()), oldValue);
  6814. event.preventDefault();
  6815. return;
  6816. }
  6817. const withModifiers = altKey || ctrlKey || metaKey;
  6818. const singleChar = key.length === 1;
  6819. const validHexChar = hexChar.test(key);
  6820. if (singleChar && !withModifiers && !validHexChar) {
  6821. event.preventDefault();
  6822. }
  6823. }
  6824. //--------------------------------------------------------------------------
  6825. //
  6826. // Lifecycle
  6827. //
  6828. //--------------------------------------------------------------------------
  6829. render() {
  6830. const { intlHex, value } = this;
  6831. const hexInputValue = this.formatForInternalInput(value);
  6832. 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));
  6833. }
  6834. //--------------------------------------------------------------------------
  6835. //
  6836. // Public Methods
  6837. //
  6838. //--------------------------------------------------------------------------
  6839. /** Sets focus on the component. */
  6840. async setFocus() {
  6841. focusElement(this.inputNode);
  6842. }
  6843. //--------------------------------------------------------------------------
  6844. //
  6845. // Private Methods
  6846. //
  6847. //--------------------------------------------------------------------------
  6848. internalSetValue(value, oldValue, emit = true) {
  6849. if (value) {
  6850. const normalized = normalizeHex(value);
  6851. if (isValidHex(normalized)) {
  6852. const { internalColor } = this;
  6853. const changed = !internalColor || normalized !== normalizeHex(internalColor.hex());
  6854. this.internalColor = color(normalized);
  6855. this.previousNonNullValue = normalized;
  6856. this.value = normalized;
  6857. if (changed && emit) {
  6858. this.calciteColorPickerHexInputChange.emit();
  6859. }
  6860. return;
  6861. }
  6862. }
  6863. else if (this.allowEmpty) {
  6864. this.internalColor = null;
  6865. this.value = null;
  6866. if (emit) {
  6867. this.calciteColorPickerHexInputChange.emit();
  6868. }
  6869. return;
  6870. }
  6871. this.value = oldValue;
  6872. }
  6873. formatForInternalInput(hex) {
  6874. return hex ? hex.replace("#", "") : "";
  6875. }
  6876. nudgeRGBChannels(color$1, amount) {
  6877. return color.rgb(color$1.array().map((channel) => channel + amount));
  6878. }
  6879. handleKeyDown(event) {
  6880. if (event.key === "Enter") {
  6881. event.preventDefault();
  6882. }
  6883. }
  6884. get el() { return this; }
  6885. static get watchers() { return {
  6886. "value": ["handleValueChange"]
  6887. }; }
  6888. static get style() { return colorPickerHexInputCss; }
  6889. };
  6890. const CSS$E = {
  6891. swatch: "swatch",
  6892. noColorIcon: "no-color-icon"
  6893. };
  6894. const COLORS = {
  6895. borderLight: "rgba(0, 0, 0, 0.3)",
  6896. borderDark: "rgba(255, 255, 255, 0.15)"
  6897. };
  6898. 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%}";
  6899. const ColorPickerSwatch = class extends HTMLElement$1 {
  6900. constructor() {
  6901. super();
  6902. this.__registerHost();
  6903. this.__attachShadow();
  6904. //--------------------------------------------------------------------------
  6905. //
  6906. // Properties
  6907. //
  6908. //--------------------------------------------------------------------------
  6909. /**
  6910. * Used to display whether the swatch is active or not.
  6911. */
  6912. this.active = false;
  6913. /**
  6914. * The component scale.
  6915. */
  6916. this.scale = "m";
  6917. }
  6918. handleColorChange(color$1) {
  6919. this.internalColor = color(color$1);
  6920. }
  6921. //--------------------------------------------------------------------------
  6922. //
  6923. // Lifecycle
  6924. //
  6925. //--------------------------------------------------------------------------
  6926. componentWillLoad() {
  6927. this.handleColorChange(this.color);
  6928. }
  6929. render() {
  6930. const { active, el, internalColor } = this;
  6931. const borderRadius = active ? "100%" : "0";
  6932. const hex = internalColor.hex();
  6933. const theme = getThemeName(el);
  6934. const borderColor = theme === "light" ? COLORS.borderLight : COLORS.borderDark;
  6935. 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%" })));
  6936. }
  6937. get el() { return this; }
  6938. static get watchers() { return {
  6939. "color": ["handleColorChange"]
  6940. }; }
  6941. static get style() { return colorPickerSwatchCss; }
  6942. };
  6943. const filter = (data, value) => {
  6944. const escapedValue = escapeRegExp(value);
  6945. const regex = new RegExp(escapedValue, "i");
  6946. if (data.length === 0) {
  6947. console.warn(`No data was passed to the filter function.
  6948. The data argument should be an array of objects`);
  6949. }
  6950. const find = (input, RE) => {
  6951. var _a;
  6952. if ((_a = input) === null || _a === void 0 ? void 0 : _a.constant) {
  6953. return true;
  6954. }
  6955. let found = false;
  6956. forIn(input, (val) => {
  6957. if (typeof val === "function" || val == null /* intentional == to catch undefined */) {
  6958. return;
  6959. }
  6960. if (Array.isArray(val) || (typeof val === "object" && val !== null)) {
  6961. if (find(val, RE)) {
  6962. found = true;
  6963. }
  6964. }
  6965. else if (RE.test(val)) {
  6966. found = true;
  6967. }
  6968. });
  6969. return found;
  6970. };
  6971. const result = data.filter((item) => {
  6972. return find(item, regex);
  6973. });
  6974. return result;
  6975. };
  6976. var top = 'top';
  6977. var bottom = 'bottom';
  6978. var right = 'right';
  6979. var left = 'left';
  6980. var auto = 'auto';
  6981. var basePlacements = [top, bottom, right, left];
  6982. var start = 'start';
  6983. var end = 'end';
  6984. var clippingParents = 'clippingParents';
  6985. var viewport = 'viewport';
  6986. var popper = 'popper';
  6987. var reference = 'reference';
  6988. var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
  6989. return acc.concat([placement + "-" + start, placement + "-" + end]);
  6990. }, []);
  6991. var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
  6992. return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
  6993. }, []); // modifiers that need to read the DOM
  6994. var beforeRead = 'beforeRead';
  6995. var read = 'read';
  6996. var afterRead = 'afterRead'; // pure-logic modifiers
  6997. var beforeMain = 'beforeMain';
  6998. var main = 'main';
  6999. var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
  7000. var beforeWrite = 'beforeWrite';
  7001. var write = 'write';
  7002. var afterWrite = 'afterWrite';
  7003. var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
  7004. function getNodeName(element) {
  7005. return element ? (element.nodeName || '').toLowerCase() : null;
  7006. }
  7007. function getWindow(node) {
  7008. if (node == null) {
  7009. return window;
  7010. }
  7011. if (node.toString() !== '[object Window]') {
  7012. var ownerDocument = node.ownerDocument;
  7013. return ownerDocument ? ownerDocument.defaultView || window : window;
  7014. }
  7015. return node;
  7016. }
  7017. function isElement(node) {
  7018. var OwnElement = getWindow(node).Element;
  7019. return node instanceof OwnElement || node instanceof Element;
  7020. }
  7021. function isHTMLElement(node) {
  7022. var OwnElement = getWindow(node).HTMLElement;
  7023. return node instanceof OwnElement || node instanceof HTMLElement;
  7024. }
  7025. function isShadowRoot(node) {
  7026. // IE 11 has no ShadowRoot
  7027. if (typeof ShadowRoot === 'undefined') {
  7028. return false;
  7029. }
  7030. var OwnElement = getWindow(node).ShadowRoot;
  7031. return node instanceof OwnElement || node instanceof ShadowRoot;
  7032. }
  7033. // and applies them to the HTMLElements such as popper and arrow
  7034. function applyStyles(_ref) {
  7035. var state = _ref.state;
  7036. Object.keys(state.elements).forEach(function (name) {
  7037. var style = state.styles[name] || {};
  7038. var attributes = state.attributes[name] || {};
  7039. var element = state.elements[name]; // arrow is optional + virtual elements
  7040. if (!isHTMLElement(element) || !getNodeName(element)) {
  7041. return;
  7042. } // Flow doesn't support to extend this property, but it's the most
  7043. // effective way to apply styles to an HTMLElement
  7044. // $FlowFixMe[cannot-write]
  7045. Object.assign(element.style, style);
  7046. Object.keys(attributes).forEach(function (name) {
  7047. var value = attributes[name];
  7048. if (value === false) {
  7049. element.removeAttribute(name);
  7050. } else {
  7051. element.setAttribute(name, value === true ? '' : value);
  7052. }
  7053. });
  7054. });
  7055. }
  7056. function effect$2(_ref2) {
  7057. var state = _ref2.state;
  7058. var initialStyles = {
  7059. popper: {
  7060. position: state.options.strategy,
  7061. left: '0',
  7062. top: '0',
  7063. margin: '0'
  7064. },
  7065. arrow: {
  7066. position: 'absolute'
  7067. },
  7068. reference: {}
  7069. };
  7070. Object.assign(state.elements.popper.style, initialStyles.popper);
  7071. state.styles = initialStyles;
  7072. if (state.elements.arrow) {
  7073. Object.assign(state.elements.arrow.style, initialStyles.arrow);
  7074. }
  7075. return function () {
  7076. Object.keys(state.elements).forEach(function (name) {
  7077. var element = state.elements[name];
  7078. var attributes = state.attributes[name] || {};
  7079. var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
  7080. var style = styleProperties.reduce(function (style, property) {
  7081. style[property] = '';
  7082. return style;
  7083. }, {}); // arrow is optional + virtual elements
  7084. if (!isHTMLElement(element) || !getNodeName(element)) {
  7085. return;
  7086. }
  7087. Object.assign(element.style, style);
  7088. Object.keys(attributes).forEach(function (attribute) {
  7089. element.removeAttribute(attribute);
  7090. });
  7091. });
  7092. };
  7093. } // eslint-disable-next-line import/no-unused-modules
  7094. const applyStyles$1 = {
  7095. name: 'applyStyles',
  7096. enabled: true,
  7097. phase: 'write',
  7098. fn: applyStyles,
  7099. effect: effect$2,
  7100. requires: ['computeStyles']
  7101. };
  7102. function getBasePlacement(placement) {
  7103. return placement.split('-')[0];
  7104. }
  7105. var max = Math.max;
  7106. var min = Math.min;
  7107. var round = Math.round;
  7108. function getBoundingClientRect(element, includeScale) {
  7109. if (includeScale === void 0) {
  7110. includeScale = false;
  7111. }
  7112. var rect = element.getBoundingClientRect();
  7113. var scaleX = 1;
  7114. var scaleY = 1;
  7115. if (isHTMLElement(element) && includeScale) {
  7116. var offsetHeight = element.offsetHeight;
  7117. var offsetWidth = element.offsetWidth; // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
  7118. // Fallback to 1 in case both values are `0`
  7119. if (offsetWidth > 0) {
  7120. scaleX = round(rect.width) / offsetWidth || 1;
  7121. }
  7122. if (offsetHeight > 0) {
  7123. scaleY = round(rect.height) / offsetHeight || 1;
  7124. }
  7125. }
  7126. return {
  7127. width: rect.width / scaleX,
  7128. height: rect.height / scaleY,
  7129. top: rect.top / scaleY,
  7130. right: rect.right / scaleX,
  7131. bottom: rect.bottom / scaleY,
  7132. left: rect.left / scaleX,
  7133. x: rect.left / scaleX,
  7134. y: rect.top / scaleY
  7135. };
  7136. }
  7137. // means it doesn't take into account transforms.
  7138. function getLayoutRect(element) {
  7139. var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
  7140. // Fixes https://github.com/popperjs/popper-core/issues/1223
  7141. var width = element.offsetWidth;
  7142. var height = element.offsetHeight;
  7143. if (Math.abs(clientRect.width - width) <= 1) {
  7144. width = clientRect.width;
  7145. }
  7146. if (Math.abs(clientRect.height - height) <= 1) {
  7147. height = clientRect.height;
  7148. }
  7149. return {
  7150. x: element.offsetLeft,
  7151. y: element.offsetTop,
  7152. width: width,
  7153. height: height
  7154. };
  7155. }
  7156. function contains(parent, child) {
  7157. var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
  7158. if (parent.contains(child)) {
  7159. return true;
  7160. } // then fallback to custom implementation with Shadow DOM support
  7161. else if (rootNode && isShadowRoot(rootNode)) {
  7162. var next = child;
  7163. do {
  7164. if (next && parent.isSameNode(next)) {
  7165. return true;
  7166. } // $FlowFixMe[prop-missing]: need a better way to handle this...
  7167. next = next.parentNode || next.host;
  7168. } while (next);
  7169. } // Give up, the result is false
  7170. return false;
  7171. }
  7172. function getComputedStyle$1(element) {
  7173. return getWindow(element).getComputedStyle(element);
  7174. }
  7175. function isTableElement(element) {
  7176. return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
  7177. }
  7178. function getDocumentElement(element) {
  7179. // $FlowFixMe[incompatible-return]: assume body is always available
  7180. return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
  7181. element.document) || window.document).documentElement;
  7182. }
  7183. function getParentNode(element) {
  7184. if (getNodeName(element) === 'html') {
  7185. return element;
  7186. }
  7187. return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
  7188. // $FlowFixMe[incompatible-return]
  7189. // $FlowFixMe[prop-missing]
  7190. element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
  7191. element.parentNode || ( // DOM Element detected
  7192. isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
  7193. // $FlowFixMe[incompatible-call]: HTMLElement is a Node
  7194. getDocumentElement(element) // fallback
  7195. );
  7196. }
  7197. function getTrueOffsetParent(element) {
  7198. if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
  7199. getComputedStyle$1(element).position === 'fixed') {
  7200. return null;
  7201. }
  7202. return element.offsetParent;
  7203. } // `.offsetParent` reports `null` for fixed elements, while absolute elements
  7204. // return the containing block
  7205. function getContainingBlock(element) {
  7206. var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') !== -1;
  7207. var isIE = navigator.userAgent.indexOf('Trident') !== -1;
  7208. if (isIE && isHTMLElement(element)) {
  7209. // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
  7210. var elementCss = getComputedStyle$1(element);
  7211. if (elementCss.position === 'fixed') {
  7212. return null;
  7213. }
  7214. }
  7215. var currentNode = getParentNode(element);
  7216. if (isShadowRoot(currentNode)) {
  7217. currentNode = currentNode.host;
  7218. }
  7219. while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
  7220. var css = getComputedStyle$1(currentNode); // This is non-exhaustive but covers the most common CSS properties that
  7221. // create a containing block.
  7222. // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
  7223. 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') {
  7224. return currentNode;
  7225. } else {
  7226. currentNode = currentNode.parentNode;
  7227. }
  7228. }
  7229. return null;
  7230. } // Gets the closest ancestor positioned element. Handles some edge cases,
  7231. // such as table ancestors and cross browser bugs.
  7232. function getOffsetParent(element) {
  7233. var window = getWindow(element);
  7234. var offsetParent = getTrueOffsetParent(element);
  7235. while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
  7236. offsetParent = getTrueOffsetParent(offsetParent);
  7237. }
  7238. if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static')) {
  7239. return window;
  7240. }
  7241. return offsetParent || getContainingBlock(element) || window;
  7242. }
  7243. function getMainAxisFromPlacement(placement) {
  7244. return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
  7245. }
  7246. function within(min$1, value, max$1) {
  7247. return max(min$1, min(value, max$1));
  7248. }
  7249. function withinMaxClamp(min, value, max) {
  7250. var v = within(min, value, max);
  7251. return v > max ? max : v;
  7252. }
  7253. function getFreshSideObject() {
  7254. return {
  7255. top: 0,
  7256. right: 0,
  7257. bottom: 0,
  7258. left: 0
  7259. };
  7260. }
  7261. function mergePaddingObject(paddingObject) {
  7262. return Object.assign({}, getFreshSideObject(), paddingObject);
  7263. }
  7264. function expandToHashMap(value, keys) {
  7265. return keys.reduce(function (hashMap, key) {
  7266. hashMap[key] = value;
  7267. return hashMap;
  7268. }, {});
  7269. }
  7270. var toPaddingObject = function toPaddingObject(padding, state) {
  7271. padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
  7272. placement: state.placement
  7273. })) : padding;
  7274. return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
  7275. };
  7276. function arrow(_ref) {
  7277. var _state$modifiersData$;
  7278. var state = _ref.state,
  7279. name = _ref.name,
  7280. options = _ref.options;
  7281. var arrowElement = state.elements.arrow;
  7282. var popperOffsets = state.modifiersData.popperOffsets;
  7283. var basePlacement = getBasePlacement(state.placement);
  7284. var axis = getMainAxisFromPlacement(basePlacement);
  7285. var isVertical = [left, right].indexOf(basePlacement) >= 0;
  7286. var len = isVertical ? 'height' : 'width';
  7287. if (!arrowElement || !popperOffsets) {
  7288. return;
  7289. }
  7290. var paddingObject = toPaddingObject(options.padding, state);
  7291. var arrowRect = getLayoutRect(arrowElement);
  7292. var minProp = axis === 'y' ? top : left;
  7293. var maxProp = axis === 'y' ? bottom : right;
  7294. var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
  7295. var startDiff = popperOffsets[axis] - state.rects.reference[axis];
  7296. var arrowOffsetParent = getOffsetParent(arrowElement);
  7297. var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
  7298. var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
  7299. // outside of the popper bounds
  7300. var min = paddingObject[minProp];
  7301. var max = clientSize - arrowRect[len] - paddingObject[maxProp];
  7302. var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
  7303. var offset = within(min, center, max); // Prevents breaking syntax highlighting...
  7304. var axisProp = axis;
  7305. state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
  7306. }
  7307. function effect$1(_ref2) {
  7308. var state = _ref2.state,
  7309. options = _ref2.options;
  7310. var _options$element = options.element,
  7311. arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
  7312. if (arrowElement == null) {
  7313. return;
  7314. } // CSS selector
  7315. if (typeof arrowElement === 'string') {
  7316. arrowElement = state.elements.popper.querySelector(arrowElement);
  7317. if (!arrowElement) {
  7318. return;
  7319. }
  7320. }
  7321. if (!contains(state.elements.popper, arrowElement)) {
  7322. return;
  7323. }
  7324. state.elements.arrow = arrowElement;
  7325. } // eslint-disable-next-line import/no-unused-modules
  7326. const arrow$1 = {
  7327. name: 'arrow',
  7328. enabled: true,
  7329. phase: 'main',
  7330. fn: arrow,
  7331. effect: effect$1,
  7332. requires: ['popperOffsets'],
  7333. requiresIfExists: ['preventOverflow']
  7334. };
  7335. function getVariation(placement) {
  7336. return placement.split('-')[1];
  7337. }
  7338. var unsetSides = {
  7339. top: 'auto',
  7340. right: 'auto',
  7341. bottom: 'auto',
  7342. left: 'auto'
  7343. }; // Round the offsets to the nearest suitable subpixel based on the DPR.
  7344. // Zooming can change the DPR, but it seems to report a value that will
  7345. // cleanly divide the values into the appropriate subpixels.
  7346. function roundOffsetsByDPR(_ref) {
  7347. var x = _ref.x,
  7348. y = _ref.y;
  7349. var win = window;
  7350. var dpr = win.devicePixelRatio || 1;
  7351. return {
  7352. x: round(x * dpr) / dpr || 0,
  7353. y: round(y * dpr) / dpr || 0
  7354. };
  7355. }
  7356. function mapToStyles(_ref2) {
  7357. var _Object$assign2;
  7358. var popper = _ref2.popper,
  7359. popperRect = _ref2.popperRect,
  7360. placement = _ref2.placement,
  7361. variation = _ref2.variation,
  7362. offsets = _ref2.offsets,
  7363. position = _ref2.position,
  7364. gpuAcceleration = _ref2.gpuAcceleration,
  7365. adaptive = _ref2.adaptive,
  7366. roundOffsets = _ref2.roundOffsets,
  7367. isFixed = _ref2.isFixed;
  7368. var _offsets$x = offsets.x,
  7369. x = _offsets$x === void 0 ? 0 : _offsets$x,
  7370. _offsets$y = offsets.y,
  7371. y = _offsets$y === void 0 ? 0 : _offsets$y;
  7372. var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
  7373. x: x,
  7374. y: y
  7375. }) : {
  7376. x: x,
  7377. y: y
  7378. };
  7379. x = _ref3.x;
  7380. y = _ref3.y;
  7381. var hasX = offsets.hasOwnProperty('x');
  7382. var hasY = offsets.hasOwnProperty('y');
  7383. var sideX = left;
  7384. var sideY = top;
  7385. var win = window;
  7386. if (adaptive) {
  7387. var offsetParent = getOffsetParent(popper);
  7388. var heightProp = 'clientHeight';
  7389. var widthProp = 'clientWidth';
  7390. if (offsetParent === getWindow(popper)) {
  7391. offsetParent = getDocumentElement(popper);
  7392. if (getComputedStyle$1(offsetParent).position !== 'static' && position === 'absolute') {
  7393. heightProp = 'scrollHeight';
  7394. widthProp = 'scrollWidth';
  7395. }
  7396. } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
  7397. offsetParent = offsetParent;
  7398. if (placement === top || (placement === left || placement === right) && variation === end) {
  7399. sideY = bottom;
  7400. var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
  7401. offsetParent[heightProp];
  7402. y -= offsetY - popperRect.height;
  7403. y *= gpuAcceleration ? 1 : -1;
  7404. }
  7405. if (placement === left || (placement === top || placement === bottom) && variation === end) {
  7406. sideX = right;
  7407. var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
  7408. offsetParent[widthProp];
  7409. x -= offsetX - popperRect.width;
  7410. x *= gpuAcceleration ? 1 : -1;
  7411. }
  7412. }
  7413. var commonStyles = Object.assign({
  7414. position: position
  7415. }, adaptive && unsetSides);
  7416. var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
  7417. x: x,
  7418. y: y
  7419. }) : {
  7420. x: x,
  7421. y: y
  7422. };
  7423. x = _ref4.x;
  7424. y = _ref4.y;
  7425. if (gpuAcceleration) {
  7426. var _Object$assign;
  7427. 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));
  7428. }
  7429. return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
  7430. }
  7431. function computeStyles(_ref5) {
  7432. var state = _ref5.state,
  7433. options = _ref5.options;
  7434. var _options$gpuAccelerat = options.gpuAcceleration,
  7435. gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
  7436. _options$adaptive = options.adaptive,
  7437. adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
  7438. _options$roundOffsets = options.roundOffsets,
  7439. roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
  7440. var commonStyles = {
  7441. placement: getBasePlacement(state.placement),
  7442. variation: getVariation(state.placement),
  7443. popper: state.elements.popper,
  7444. popperRect: state.rects.popper,
  7445. gpuAcceleration: gpuAcceleration,
  7446. isFixed: state.options.strategy === 'fixed'
  7447. };
  7448. if (state.modifiersData.popperOffsets != null) {
  7449. state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
  7450. offsets: state.modifiersData.popperOffsets,
  7451. position: state.options.strategy,
  7452. adaptive: adaptive,
  7453. roundOffsets: roundOffsets
  7454. })));
  7455. }
  7456. if (state.modifiersData.arrow != null) {
  7457. state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
  7458. offsets: state.modifiersData.arrow,
  7459. position: 'absolute',
  7460. adaptive: false,
  7461. roundOffsets: roundOffsets
  7462. })));
  7463. }
  7464. state.attributes.popper = Object.assign({}, state.attributes.popper, {
  7465. 'data-popper-placement': state.placement
  7466. });
  7467. } // eslint-disable-next-line import/no-unused-modules
  7468. const computeStyles$1 = {
  7469. name: 'computeStyles',
  7470. enabled: true,
  7471. phase: 'beforeWrite',
  7472. fn: computeStyles,
  7473. data: {}
  7474. };
  7475. var passive = {
  7476. passive: true
  7477. };
  7478. function effect(_ref) {
  7479. var state = _ref.state,
  7480. instance = _ref.instance,
  7481. options = _ref.options;
  7482. var _options$scroll = options.scroll,
  7483. scroll = _options$scroll === void 0 ? true : _options$scroll,
  7484. _options$resize = options.resize,
  7485. resize = _options$resize === void 0 ? true : _options$resize;
  7486. var window = getWindow(state.elements.popper);
  7487. var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
  7488. if (scroll) {
  7489. scrollParents.forEach(function (scrollParent) {
  7490. scrollParent.addEventListener('scroll', instance.update, passive);
  7491. });
  7492. }
  7493. if (resize) {
  7494. window.addEventListener('resize', instance.update, passive);
  7495. }
  7496. return function () {
  7497. if (scroll) {
  7498. scrollParents.forEach(function (scrollParent) {
  7499. scrollParent.removeEventListener('scroll', instance.update, passive);
  7500. });
  7501. }
  7502. if (resize) {
  7503. window.removeEventListener('resize', instance.update, passive);
  7504. }
  7505. };
  7506. } // eslint-disable-next-line import/no-unused-modules
  7507. const eventListeners = {
  7508. name: 'eventListeners',
  7509. enabled: true,
  7510. phase: 'write',
  7511. fn: function fn() {},
  7512. effect: effect,
  7513. data: {}
  7514. };
  7515. var hash$1 = {
  7516. left: 'right',
  7517. right: 'left',
  7518. bottom: 'top',
  7519. top: 'bottom'
  7520. };
  7521. function getOppositePlacement(placement) {
  7522. return placement.replace(/left|right|bottom|top/g, function (matched) {
  7523. return hash$1[matched];
  7524. });
  7525. }
  7526. var hash = {
  7527. start: 'end',
  7528. end: 'start'
  7529. };
  7530. function getOppositeVariationPlacement(placement) {
  7531. return placement.replace(/start|end/g, function (matched) {
  7532. return hash[matched];
  7533. });
  7534. }
  7535. function getWindowScroll(node) {
  7536. var win = getWindow(node);
  7537. var scrollLeft = win.pageXOffset;
  7538. var scrollTop = win.pageYOffset;
  7539. return {
  7540. scrollLeft: scrollLeft,
  7541. scrollTop: scrollTop
  7542. };
  7543. }
  7544. function getWindowScrollBarX(element) {
  7545. // If <html> has a CSS width greater than the viewport, then this will be
  7546. // incorrect for RTL.
  7547. // Popper 1 is broken in this case and never had a bug report so let's assume
  7548. // it's not an issue. I don't think anyone ever specifies width on <html>
  7549. // anyway.
  7550. // Browsers where the left scrollbar doesn't cause an issue report `0` for
  7551. // this (e.g. Edge 2019, IE11, Safari)
  7552. return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
  7553. }
  7554. function getViewportRect(element) {
  7555. var win = getWindow(element);
  7556. var html = getDocumentElement(element);
  7557. var visualViewport = win.visualViewport;
  7558. var width = html.clientWidth;
  7559. var height = html.clientHeight;
  7560. var x = 0;
  7561. var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
  7562. // can be obscured underneath it.
  7563. // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
  7564. // if it isn't open, so if this isn't available, the popper will be detected
  7565. // to overflow the bottom of the screen too early.
  7566. if (visualViewport) {
  7567. width = visualViewport.width;
  7568. height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
  7569. // In Chrome, it returns a value very close to 0 (+/-) but contains rounding
  7570. // errors due to floating point numbers, so we need to check precision.
  7571. // Safari returns a number <= 0, usually < -1 when pinch-zoomed
  7572. // Feature detection fails in mobile emulation mode in Chrome.
  7573. // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
  7574. // 0.001
  7575. // Fallback here: "Not Safari" userAgent
  7576. if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
  7577. x = visualViewport.offsetLeft;
  7578. y = visualViewport.offsetTop;
  7579. }
  7580. }
  7581. return {
  7582. width: width,
  7583. height: height,
  7584. x: x + getWindowScrollBarX(element),
  7585. y: y
  7586. };
  7587. }
  7588. // of the `<html>` and `<body>` rect bounds if horizontally scrollable
  7589. function getDocumentRect(element) {
  7590. var _element$ownerDocumen;
  7591. var html = getDocumentElement(element);
  7592. var winScroll = getWindowScroll(element);
  7593. var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
  7594. var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
  7595. var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
  7596. var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
  7597. var y = -winScroll.scrollTop;
  7598. if (getComputedStyle$1(body || html).direction === 'rtl') {
  7599. x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
  7600. }
  7601. return {
  7602. width: width,
  7603. height: height,
  7604. x: x,
  7605. y: y
  7606. };
  7607. }
  7608. function isScrollParent(element) {
  7609. // Firefox wants us to check `-x` and `-y` variations as well
  7610. var _getComputedStyle = getComputedStyle$1(element),
  7611. overflow = _getComputedStyle.overflow,
  7612. overflowX = _getComputedStyle.overflowX,
  7613. overflowY = _getComputedStyle.overflowY;
  7614. return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
  7615. }
  7616. function getScrollParent(node) {
  7617. if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
  7618. // $FlowFixMe[incompatible-return]: assume body is always available
  7619. return node.ownerDocument.body;
  7620. }
  7621. if (isHTMLElement(node) && isScrollParent(node)) {
  7622. return node;
  7623. }
  7624. return getScrollParent(getParentNode(node));
  7625. }
  7626. /*
  7627. given a DOM element, return the list of all scroll parents, up the list of ancesors
  7628. until we get to the top window object. This list is what we attach scroll listeners
  7629. to, because if any of these parent elements scroll, we'll need to re-calculate the
  7630. reference element's position.
  7631. */
  7632. function listScrollParents(element, list) {
  7633. var _element$ownerDocumen;
  7634. if (list === void 0) {
  7635. list = [];
  7636. }
  7637. var scrollParent = getScrollParent(element);
  7638. var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
  7639. var win = getWindow(scrollParent);
  7640. var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
  7641. var updatedList = list.concat(target);
  7642. return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
  7643. updatedList.concat(listScrollParents(getParentNode(target)));
  7644. }
  7645. function rectToClientRect(rect) {
  7646. return Object.assign({}, rect, {
  7647. left: rect.x,
  7648. top: rect.y,
  7649. right: rect.x + rect.width,
  7650. bottom: rect.y + rect.height
  7651. });
  7652. }
  7653. function getInnerBoundingClientRect(element) {
  7654. var rect = getBoundingClientRect(element);
  7655. rect.top = rect.top + element.clientTop;
  7656. rect.left = rect.left + element.clientLeft;
  7657. rect.bottom = rect.top + element.clientHeight;
  7658. rect.right = rect.left + element.clientWidth;
  7659. rect.width = element.clientWidth;
  7660. rect.height = element.clientHeight;
  7661. rect.x = rect.left;
  7662. rect.y = rect.top;
  7663. return rect;
  7664. }
  7665. function getClientRectFromMixedType(element, clippingParent) {
  7666. return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
  7667. } // A "clipping parent" is an overflowable container with the characteristic of
  7668. // clipping (or hiding) overflowing elements with a position different from
  7669. // `initial`
  7670. function getClippingParents(element) {
  7671. var clippingParents = listScrollParents(getParentNode(element));
  7672. var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle$1(element).position) >= 0;
  7673. var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
  7674. if (!isElement(clipperElement)) {
  7675. return [];
  7676. } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
  7677. return clippingParents.filter(function (clippingParent) {
  7678. return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
  7679. });
  7680. } // Gets the maximum area that the element is visible in due to any number of
  7681. // clipping parents
  7682. function getClippingRect(element, boundary, rootBoundary) {
  7683. var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
  7684. var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
  7685. var firstClippingParent = clippingParents[0];
  7686. var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
  7687. var rect = getClientRectFromMixedType(element, clippingParent);
  7688. accRect.top = max(rect.top, accRect.top);
  7689. accRect.right = min(rect.right, accRect.right);
  7690. accRect.bottom = min(rect.bottom, accRect.bottom);
  7691. accRect.left = max(rect.left, accRect.left);
  7692. return accRect;
  7693. }, getClientRectFromMixedType(element, firstClippingParent));
  7694. clippingRect.width = clippingRect.right - clippingRect.left;
  7695. clippingRect.height = clippingRect.bottom - clippingRect.top;
  7696. clippingRect.x = clippingRect.left;
  7697. clippingRect.y = clippingRect.top;
  7698. return clippingRect;
  7699. }
  7700. function computeOffsets(_ref) {
  7701. var reference = _ref.reference,
  7702. element = _ref.element,
  7703. placement = _ref.placement;
  7704. var basePlacement = placement ? getBasePlacement(placement) : null;
  7705. var variation = placement ? getVariation(placement) : null;
  7706. var commonX = reference.x + reference.width / 2 - element.width / 2;
  7707. var commonY = reference.y + reference.height / 2 - element.height / 2;
  7708. var offsets;
  7709. switch (basePlacement) {
  7710. case top:
  7711. offsets = {
  7712. x: commonX,
  7713. y: reference.y - element.height
  7714. };
  7715. break;
  7716. case bottom:
  7717. offsets = {
  7718. x: commonX,
  7719. y: reference.y + reference.height
  7720. };
  7721. break;
  7722. case right:
  7723. offsets = {
  7724. x: reference.x + reference.width,
  7725. y: commonY
  7726. };
  7727. break;
  7728. case left:
  7729. offsets = {
  7730. x: reference.x - element.width,
  7731. y: commonY
  7732. };
  7733. break;
  7734. default:
  7735. offsets = {
  7736. x: reference.x,
  7737. y: reference.y
  7738. };
  7739. }
  7740. var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
  7741. if (mainAxis != null) {
  7742. var len = mainAxis === 'y' ? 'height' : 'width';
  7743. switch (variation) {
  7744. case start:
  7745. offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
  7746. break;
  7747. case end:
  7748. offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
  7749. break;
  7750. }
  7751. }
  7752. return offsets;
  7753. }
  7754. function detectOverflow(state, options) {
  7755. if (options === void 0) {
  7756. options = {};
  7757. }
  7758. var _options = options,
  7759. _options$placement = _options.placement,
  7760. placement = _options$placement === void 0 ? state.placement : _options$placement,
  7761. _options$boundary = _options.boundary,
  7762. boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
  7763. _options$rootBoundary = _options.rootBoundary,
  7764. rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
  7765. _options$elementConte = _options.elementContext,
  7766. elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
  7767. _options$altBoundary = _options.altBoundary,
  7768. altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
  7769. _options$padding = _options.padding,
  7770. padding = _options$padding === void 0 ? 0 : _options$padding;
  7771. var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
  7772. var altContext = elementContext === popper ? reference : popper;
  7773. var popperRect = state.rects.popper;
  7774. var element = state.elements[altBoundary ? altContext : elementContext];
  7775. var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
  7776. var referenceClientRect = getBoundingClientRect(state.elements.reference);
  7777. var popperOffsets = computeOffsets({
  7778. reference: referenceClientRect,
  7779. element: popperRect,
  7780. strategy: 'absolute',
  7781. placement: placement
  7782. });
  7783. var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
  7784. var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
  7785. // 0 or negative = within the clipping rect
  7786. var overflowOffsets = {
  7787. top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
  7788. bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
  7789. left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
  7790. right: elementClientRect.right - clippingClientRect.right + paddingObject.right
  7791. };
  7792. var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
  7793. if (elementContext === popper && offsetData) {
  7794. var offset = offsetData[placement];
  7795. Object.keys(overflowOffsets).forEach(function (key) {
  7796. var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
  7797. var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
  7798. overflowOffsets[key] += offset[axis] * multiply;
  7799. });
  7800. }
  7801. return overflowOffsets;
  7802. }
  7803. function computeAutoPlacement(state, options) {
  7804. if (options === void 0) {
  7805. options = {};
  7806. }
  7807. var _options = options,
  7808. placement = _options.placement,
  7809. boundary = _options.boundary,
  7810. rootBoundary = _options.rootBoundary,
  7811. padding = _options.padding,
  7812. flipVariations = _options.flipVariations,
  7813. _options$allowedAutoP = _options.allowedAutoPlacements,
  7814. allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
  7815. var variation = getVariation(placement);
  7816. var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
  7817. return getVariation(placement) === variation;
  7818. }) : basePlacements;
  7819. var allowedPlacements = placements$1.filter(function (placement) {
  7820. return allowedAutoPlacements.indexOf(placement) >= 0;
  7821. });
  7822. if (allowedPlacements.length === 0) {
  7823. allowedPlacements = placements$1;
  7824. } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
  7825. var overflows = allowedPlacements.reduce(function (acc, placement) {
  7826. acc[placement] = detectOverflow(state, {
  7827. placement: placement,
  7828. boundary: boundary,
  7829. rootBoundary: rootBoundary,
  7830. padding: padding
  7831. })[getBasePlacement(placement)];
  7832. return acc;
  7833. }, {});
  7834. return Object.keys(overflows).sort(function (a, b) {
  7835. return overflows[a] - overflows[b];
  7836. });
  7837. }
  7838. function getExpandedFallbackPlacements(placement) {
  7839. if (getBasePlacement(placement) === auto) {
  7840. return [];
  7841. }
  7842. var oppositePlacement = getOppositePlacement(placement);
  7843. return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
  7844. }
  7845. function flip(_ref) {
  7846. var state = _ref.state,
  7847. options = _ref.options,
  7848. name = _ref.name;
  7849. if (state.modifiersData[name]._skip) {
  7850. return;
  7851. }
  7852. var _options$mainAxis = options.mainAxis,
  7853. checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
  7854. _options$altAxis = options.altAxis,
  7855. checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
  7856. specifiedFallbackPlacements = options.fallbackPlacements,
  7857. padding = options.padding,
  7858. boundary = options.boundary,
  7859. rootBoundary = options.rootBoundary,
  7860. altBoundary = options.altBoundary,
  7861. _options$flipVariatio = options.flipVariations,
  7862. flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
  7863. allowedAutoPlacements = options.allowedAutoPlacements;
  7864. var preferredPlacement = state.options.placement;
  7865. var basePlacement = getBasePlacement(preferredPlacement);
  7866. var isBasePlacement = basePlacement === preferredPlacement;
  7867. var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
  7868. var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
  7869. return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
  7870. placement: placement,
  7871. boundary: boundary,
  7872. rootBoundary: rootBoundary,
  7873. padding: padding,
  7874. flipVariations: flipVariations,
  7875. allowedAutoPlacements: allowedAutoPlacements
  7876. }) : placement);
  7877. }, []);
  7878. var referenceRect = state.rects.reference;
  7879. var popperRect = state.rects.popper;
  7880. var checksMap = new Map();
  7881. var makeFallbackChecks = true;
  7882. var firstFittingPlacement = placements[0];
  7883. for (var i = 0; i < placements.length; i++) {
  7884. var placement = placements[i];
  7885. var _basePlacement = getBasePlacement(placement);
  7886. var isStartVariation = getVariation(placement) === start;
  7887. var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
  7888. var len = isVertical ? 'width' : 'height';
  7889. var overflow = detectOverflow(state, {
  7890. placement: placement,
  7891. boundary: boundary,
  7892. rootBoundary: rootBoundary,
  7893. altBoundary: altBoundary,
  7894. padding: padding
  7895. });
  7896. var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
  7897. if (referenceRect[len] > popperRect[len]) {
  7898. mainVariationSide = getOppositePlacement(mainVariationSide);
  7899. }
  7900. var altVariationSide = getOppositePlacement(mainVariationSide);
  7901. var checks = [];
  7902. if (checkMainAxis) {
  7903. checks.push(overflow[_basePlacement] <= 0);
  7904. }
  7905. if (checkAltAxis) {
  7906. checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
  7907. }
  7908. if (checks.every(function (check) {
  7909. return check;
  7910. })) {
  7911. firstFittingPlacement = placement;
  7912. makeFallbackChecks = false;
  7913. break;
  7914. }
  7915. checksMap.set(placement, checks);
  7916. }
  7917. if (makeFallbackChecks) {
  7918. // `2` may be desired in some cases – research later
  7919. var numberOfChecks = flipVariations ? 3 : 1;
  7920. var _loop = function _loop(_i) {
  7921. var fittingPlacement = placements.find(function (placement) {
  7922. var checks = checksMap.get(placement);
  7923. if (checks) {
  7924. return checks.slice(0, _i).every(function (check) {
  7925. return check;
  7926. });
  7927. }
  7928. });
  7929. if (fittingPlacement) {
  7930. firstFittingPlacement = fittingPlacement;
  7931. return "break";
  7932. }
  7933. };
  7934. for (var _i = numberOfChecks; _i > 0; _i--) {
  7935. var _ret = _loop(_i);
  7936. if (_ret === "break") break;
  7937. }
  7938. }
  7939. if (state.placement !== firstFittingPlacement) {
  7940. state.modifiersData[name]._skip = true;
  7941. state.placement = firstFittingPlacement;
  7942. state.reset = true;
  7943. }
  7944. } // eslint-disable-next-line import/no-unused-modules
  7945. const flip$1 = {
  7946. name: 'flip',
  7947. enabled: true,
  7948. phase: 'main',
  7949. fn: flip,
  7950. requiresIfExists: ['offset'],
  7951. data: {
  7952. _skip: false
  7953. }
  7954. };
  7955. function getSideOffsets(overflow, rect, preventedOffsets) {
  7956. if (preventedOffsets === void 0) {
  7957. preventedOffsets = {
  7958. x: 0,
  7959. y: 0
  7960. };
  7961. }
  7962. return {
  7963. top: overflow.top - rect.height - preventedOffsets.y,
  7964. right: overflow.right - rect.width + preventedOffsets.x,
  7965. bottom: overflow.bottom - rect.height + preventedOffsets.y,
  7966. left: overflow.left - rect.width - preventedOffsets.x
  7967. };
  7968. }
  7969. function isAnySideFullyClipped(overflow) {
  7970. return [top, right, bottom, left].some(function (side) {
  7971. return overflow[side] >= 0;
  7972. });
  7973. }
  7974. function hide(_ref) {
  7975. var state = _ref.state,
  7976. name = _ref.name;
  7977. var referenceRect = state.rects.reference;
  7978. var popperRect = state.rects.popper;
  7979. var preventedOffsets = state.modifiersData.preventOverflow;
  7980. var referenceOverflow = detectOverflow(state, {
  7981. elementContext: 'reference'
  7982. });
  7983. var popperAltOverflow = detectOverflow(state, {
  7984. altBoundary: true
  7985. });
  7986. var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
  7987. var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
  7988. var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
  7989. var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
  7990. state.modifiersData[name] = {
  7991. referenceClippingOffsets: referenceClippingOffsets,
  7992. popperEscapeOffsets: popperEscapeOffsets,
  7993. isReferenceHidden: isReferenceHidden,
  7994. hasPopperEscaped: hasPopperEscaped
  7995. };
  7996. state.attributes.popper = Object.assign({}, state.attributes.popper, {
  7997. 'data-popper-reference-hidden': isReferenceHidden,
  7998. 'data-popper-escaped': hasPopperEscaped
  7999. });
  8000. } // eslint-disable-next-line import/no-unused-modules
  8001. const hide$1 = {
  8002. name: 'hide',
  8003. enabled: true,
  8004. phase: 'main',
  8005. requiresIfExists: ['preventOverflow'],
  8006. fn: hide
  8007. };
  8008. function distanceAndSkiddingToXY(placement, rects, offset) {
  8009. var basePlacement = getBasePlacement(placement);
  8010. var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
  8011. var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
  8012. placement: placement
  8013. })) : offset,
  8014. skidding = _ref[0],
  8015. distance = _ref[1];
  8016. skidding = skidding || 0;
  8017. distance = (distance || 0) * invertDistance;
  8018. return [left, right].indexOf(basePlacement) >= 0 ? {
  8019. x: distance,
  8020. y: skidding
  8021. } : {
  8022. x: skidding,
  8023. y: distance
  8024. };
  8025. }
  8026. function offset(_ref2) {
  8027. var state = _ref2.state,
  8028. options = _ref2.options,
  8029. name = _ref2.name;
  8030. var _options$offset = options.offset,
  8031. offset = _options$offset === void 0 ? [0, 0] : _options$offset;
  8032. var data = placements.reduce(function (acc, placement) {
  8033. acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
  8034. return acc;
  8035. }, {});
  8036. var _data$state$placement = data[state.placement],
  8037. x = _data$state$placement.x,
  8038. y = _data$state$placement.y;
  8039. if (state.modifiersData.popperOffsets != null) {
  8040. state.modifiersData.popperOffsets.x += x;
  8041. state.modifiersData.popperOffsets.y += y;
  8042. }
  8043. state.modifiersData[name] = data;
  8044. } // eslint-disable-next-line import/no-unused-modules
  8045. const offset$1 = {
  8046. name: 'offset',
  8047. enabled: true,
  8048. phase: 'main',
  8049. requires: ['popperOffsets'],
  8050. fn: offset
  8051. };
  8052. function popperOffsets(_ref) {
  8053. var state = _ref.state,
  8054. name = _ref.name;
  8055. // Offsets are the actual position the popper needs to have to be
  8056. // properly positioned near its reference element
  8057. // This is the most basic placement, and will be adjusted by
  8058. // the modifiers in the next step
  8059. state.modifiersData[name] = computeOffsets({
  8060. reference: state.rects.reference,
  8061. element: state.rects.popper,
  8062. strategy: 'absolute',
  8063. placement: state.placement
  8064. });
  8065. } // eslint-disable-next-line import/no-unused-modules
  8066. const popperOffsets$1 = {
  8067. name: 'popperOffsets',
  8068. enabled: true,
  8069. phase: 'read',
  8070. fn: popperOffsets,
  8071. data: {}
  8072. };
  8073. function getAltAxis(axis) {
  8074. return axis === 'x' ? 'y' : 'x';
  8075. }
  8076. function preventOverflow(_ref) {
  8077. var state = _ref.state,
  8078. options = _ref.options,
  8079. name = _ref.name;
  8080. var _options$mainAxis = options.mainAxis,
  8081. checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
  8082. _options$altAxis = options.altAxis,
  8083. checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
  8084. boundary = options.boundary,
  8085. rootBoundary = options.rootBoundary,
  8086. altBoundary = options.altBoundary,
  8087. padding = options.padding,
  8088. _options$tether = options.tether,
  8089. tether = _options$tether === void 0 ? true : _options$tether,
  8090. _options$tetherOffset = options.tetherOffset,
  8091. tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
  8092. var overflow = detectOverflow(state, {
  8093. boundary: boundary,
  8094. rootBoundary: rootBoundary,
  8095. padding: padding,
  8096. altBoundary: altBoundary
  8097. });
  8098. var basePlacement = getBasePlacement(state.placement);
  8099. var variation = getVariation(state.placement);
  8100. var isBasePlacement = !variation;
  8101. var mainAxis = getMainAxisFromPlacement(basePlacement);
  8102. var altAxis = getAltAxis(mainAxis);
  8103. var popperOffsets = state.modifiersData.popperOffsets;
  8104. var referenceRect = state.rects.reference;
  8105. var popperRect = state.rects.popper;
  8106. var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
  8107. placement: state.placement
  8108. })) : tetherOffset;
  8109. var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
  8110. mainAxis: tetherOffsetValue,
  8111. altAxis: tetherOffsetValue
  8112. } : Object.assign({
  8113. mainAxis: 0,
  8114. altAxis: 0
  8115. }, tetherOffsetValue);
  8116. var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
  8117. var data = {
  8118. x: 0,
  8119. y: 0
  8120. };
  8121. if (!popperOffsets) {
  8122. return;
  8123. }
  8124. if (checkMainAxis) {
  8125. var _offsetModifierState$;
  8126. var mainSide = mainAxis === 'y' ? top : left;
  8127. var altSide = mainAxis === 'y' ? bottom : right;
  8128. var len = mainAxis === 'y' ? 'height' : 'width';
  8129. var offset = popperOffsets[mainAxis];
  8130. var min$1 = offset + overflow[mainSide];
  8131. var max$1 = offset - overflow[altSide];
  8132. var additive = tether ? -popperRect[len] / 2 : 0;
  8133. var minLen = variation === start ? referenceRect[len] : popperRect[len];
  8134. var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
  8135. // outside the reference bounds
  8136. var arrowElement = state.elements.arrow;
  8137. var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
  8138. width: 0,
  8139. height: 0
  8140. };
  8141. var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
  8142. var arrowPaddingMin = arrowPaddingObject[mainSide];
  8143. var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
  8144. // to include its full size in the calculation. If the reference is small
  8145. // and near the edge of a boundary, the popper can overflow even if the
  8146. // reference is not overflowing as well (e.g. virtual elements with no
  8147. // width or height)
  8148. var arrowLen = within(0, referenceRect[len], arrowRect[len]);
  8149. var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
  8150. var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
  8151. var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
  8152. var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
  8153. var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
  8154. var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
  8155. var tetherMax = offset + maxOffset - offsetModifierValue;
  8156. var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
  8157. popperOffsets[mainAxis] = preventedOffset;
  8158. data[mainAxis] = preventedOffset - offset;
  8159. }
  8160. if (checkAltAxis) {
  8161. var _offsetModifierState$2;
  8162. var _mainSide = mainAxis === 'x' ? top : left;
  8163. var _altSide = mainAxis === 'x' ? bottom : right;
  8164. var _offset = popperOffsets[altAxis];
  8165. var _len = altAxis === 'y' ? 'height' : 'width';
  8166. var _min = _offset + overflow[_mainSide];
  8167. var _max = _offset - overflow[_altSide];
  8168. var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
  8169. var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
  8170. var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
  8171. var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
  8172. var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
  8173. popperOffsets[altAxis] = _preventedOffset;
  8174. data[altAxis] = _preventedOffset - _offset;
  8175. }
  8176. state.modifiersData[name] = data;
  8177. } // eslint-disable-next-line import/no-unused-modules
  8178. const preventOverflow$1 = {
  8179. name: 'preventOverflow',
  8180. enabled: true,
  8181. phase: 'main',
  8182. fn: preventOverflow,
  8183. requiresIfExists: ['offset']
  8184. };
  8185. function getHTMLElementScroll(element) {
  8186. return {
  8187. scrollLeft: element.scrollLeft,
  8188. scrollTop: element.scrollTop
  8189. };
  8190. }
  8191. function getNodeScroll(node) {
  8192. if (node === getWindow(node) || !isHTMLElement(node)) {
  8193. return getWindowScroll(node);
  8194. } else {
  8195. return getHTMLElementScroll(node);
  8196. }
  8197. }
  8198. function isElementScaled(element) {
  8199. var rect = element.getBoundingClientRect();
  8200. var scaleX = round(rect.width) / element.offsetWidth || 1;
  8201. var scaleY = round(rect.height) / element.offsetHeight || 1;
  8202. return scaleX !== 1 || scaleY !== 1;
  8203. } // Returns the composite rect of an element relative to its offsetParent.
  8204. // Composite means it takes into account transforms as well as layout.
  8205. function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
  8206. if (isFixed === void 0) {
  8207. isFixed = false;
  8208. }
  8209. var isOffsetParentAnElement = isHTMLElement(offsetParent);
  8210. var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
  8211. var documentElement = getDocumentElement(offsetParent);
  8212. var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
  8213. var scroll = {
  8214. scrollLeft: 0,
  8215. scrollTop: 0
  8216. };
  8217. var offsets = {
  8218. x: 0,
  8219. y: 0
  8220. };
  8221. if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
  8222. if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
  8223. isScrollParent(documentElement)) {
  8224. scroll = getNodeScroll(offsetParent);
  8225. }
  8226. if (isHTMLElement(offsetParent)) {
  8227. offsets = getBoundingClientRect(offsetParent, true);
  8228. offsets.x += offsetParent.clientLeft;
  8229. offsets.y += offsetParent.clientTop;
  8230. } else if (documentElement) {
  8231. offsets.x = getWindowScrollBarX(documentElement);
  8232. }
  8233. }
  8234. return {
  8235. x: rect.left + scroll.scrollLeft - offsets.x,
  8236. y: rect.top + scroll.scrollTop - offsets.y,
  8237. width: rect.width,
  8238. height: rect.height
  8239. };
  8240. }
  8241. function order(modifiers) {
  8242. var map = new Map();
  8243. var visited = new Set();
  8244. var result = [];
  8245. modifiers.forEach(function (modifier) {
  8246. map.set(modifier.name, modifier);
  8247. }); // On visiting object, check for its dependencies and visit them recursively
  8248. function sort(modifier) {
  8249. visited.add(modifier.name);
  8250. var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
  8251. requires.forEach(function (dep) {
  8252. if (!visited.has(dep)) {
  8253. var depModifier = map.get(dep);
  8254. if (depModifier) {
  8255. sort(depModifier);
  8256. }
  8257. }
  8258. });
  8259. result.push(modifier);
  8260. }
  8261. modifiers.forEach(function (modifier) {
  8262. if (!visited.has(modifier.name)) {
  8263. // check for visited object
  8264. sort(modifier);
  8265. }
  8266. });
  8267. return result;
  8268. }
  8269. function orderModifiers(modifiers) {
  8270. // order based on dependencies
  8271. var orderedModifiers = order(modifiers); // order based on phase
  8272. return modifierPhases.reduce(function (acc, phase) {
  8273. return acc.concat(orderedModifiers.filter(function (modifier) {
  8274. return modifier.phase === phase;
  8275. }));
  8276. }, []);
  8277. }
  8278. function debounce(fn) {
  8279. var pending;
  8280. return function () {
  8281. if (!pending) {
  8282. pending = new Promise(function (resolve) {
  8283. Promise.resolve().then(function () {
  8284. pending = undefined;
  8285. resolve(fn());
  8286. });
  8287. });
  8288. }
  8289. return pending;
  8290. };
  8291. }
  8292. function mergeByName(modifiers) {
  8293. var merged = modifiers.reduce(function (merged, current) {
  8294. var existing = merged[current.name];
  8295. merged[current.name] = existing ? Object.assign({}, existing, current, {
  8296. options: Object.assign({}, existing.options, current.options),
  8297. data: Object.assign({}, existing.data, current.data)
  8298. }) : current;
  8299. return merged;
  8300. }, {}); // IE11 does not support Object.values
  8301. return Object.keys(merged).map(function (key) {
  8302. return merged[key];
  8303. });
  8304. }
  8305. var DEFAULT_OPTIONS = {
  8306. placement: 'bottom',
  8307. modifiers: [],
  8308. strategy: 'absolute'
  8309. };
  8310. function areValidElements() {
  8311. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  8312. args[_key] = arguments[_key];
  8313. }
  8314. return !args.some(function (element) {
  8315. return !(element && typeof element.getBoundingClientRect === 'function');
  8316. });
  8317. }
  8318. function popperGenerator(generatorOptions) {
  8319. if (generatorOptions === void 0) {
  8320. generatorOptions = {};
  8321. }
  8322. var _generatorOptions = generatorOptions,
  8323. _generatorOptions$def = _generatorOptions.defaultModifiers,
  8324. defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
  8325. _generatorOptions$def2 = _generatorOptions.defaultOptions,
  8326. defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
  8327. return function createPopper(reference, popper, options) {
  8328. if (options === void 0) {
  8329. options = defaultOptions;
  8330. }
  8331. var state = {
  8332. placement: 'bottom',
  8333. orderedModifiers: [],
  8334. options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
  8335. modifiersData: {},
  8336. elements: {
  8337. reference: reference,
  8338. popper: popper
  8339. },
  8340. attributes: {},
  8341. styles: {}
  8342. };
  8343. var effectCleanupFns = [];
  8344. var isDestroyed = false;
  8345. var instance = {
  8346. state: state,
  8347. setOptions: function setOptions(setOptionsAction) {
  8348. var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
  8349. cleanupModifierEffects();
  8350. state.options = Object.assign({}, defaultOptions, state.options, options);
  8351. state.scrollParents = {
  8352. reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
  8353. popper: listScrollParents(popper)
  8354. }; // Orders the modifiers based on their dependencies and `phase`
  8355. // properties
  8356. var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
  8357. state.orderedModifiers = orderedModifiers.filter(function (m) {
  8358. return m.enabled;
  8359. }); // Validate the provided modifiers so that the consumer will get warned
  8360. runModifierEffects();
  8361. return instance.update();
  8362. },
  8363. // Sync update – it will always be executed, even if not necessary. This
  8364. // is useful for low frequency updates where sync behavior simplifies the
  8365. // logic.
  8366. // For high frequency updates (e.g. `resize` and `scroll` events), always
  8367. // prefer the async Popper#update method
  8368. forceUpdate: function forceUpdate() {
  8369. if (isDestroyed) {
  8370. return;
  8371. }
  8372. var _state$elements = state.elements,
  8373. reference = _state$elements.reference,
  8374. popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
  8375. // anymore
  8376. if (!areValidElements(reference, popper)) {
  8377. return;
  8378. } // Store the reference and popper rects to be read by modifiers
  8379. state.rects = {
  8380. reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
  8381. popper: getLayoutRect(popper)
  8382. }; // Modifiers have the ability to reset the current update cycle. The
  8383. // most common use case for this is the `flip` modifier changing the
  8384. // placement, which then needs to re-run all the modifiers, because the
  8385. // logic was previously ran for the previous placement and is therefore
  8386. // stale/incorrect
  8387. state.reset = false;
  8388. state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
  8389. // is filled with the initial data specified by the modifier. This means
  8390. // it doesn't persist and is fresh on each update.
  8391. // To ensure persistent data, use `${name}#persistent`
  8392. state.orderedModifiers.forEach(function (modifier) {
  8393. return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
  8394. });
  8395. for (var index = 0; index < state.orderedModifiers.length; index++) {
  8396. if (state.reset === true) {
  8397. state.reset = false;
  8398. index = -1;
  8399. continue;
  8400. }
  8401. var _state$orderedModifie = state.orderedModifiers[index],
  8402. fn = _state$orderedModifie.fn,
  8403. _state$orderedModifie2 = _state$orderedModifie.options,
  8404. _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
  8405. name = _state$orderedModifie.name;
  8406. if (typeof fn === 'function') {
  8407. state = fn({
  8408. state: state,
  8409. options: _options,
  8410. name: name,
  8411. instance: instance
  8412. }) || state;
  8413. }
  8414. }
  8415. },
  8416. // Async and optimistically optimized update – it will not be executed if
  8417. // not necessary (debounced to run at most once-per-tick)
  8418. update: debounce(function () {
  8419. return new Promise(function (resolve) {
  8420. instance.forceUpdate();
  8421. resolve(state);
  8422. });
  8423. }),
  8424. destroy: function destroy() {
  8425. cleanupModifierEffects();
  8426. isDestroyed = true;
  8427. }
  8428. };
  8429. if (!areValidElements(reference, popper)) {
  8430. return instance;
  8431. }
  8432. instance.setOptions(options).then(function (state) {
  8433. if (!isDestroyed && options.onFirstUpdate) {
  8434. options.onFirstUpdate(state);
  8435. }
  8436. }); // Modifiers have the ability to execute arbitrary code before the first
  8437. // update cycle runs. They will be executed in the same order as the update
  8438. // cycle. This is useful when a modifier adds some persistent data that
  8439. // other modifiers need to use, but the modifier is run after the dependent
  8440. // one.
  8441. function runModifierEffects() {
  8442. state.orderedModifiers.forEach(function (_ref3) {
  8443. var name = _ref3.name,
  8444. _ref3$options = _ref3.options,
  8445. options = _ref3$options === void 0 ? {} : _ref3$options,
  8446. effect = _ref3.effect;
  8447. if (typeof effect === 'function') {
  8448. var cleanupFn = effect({
  8449. state: state,
  8450. name: name,
  8451. instance: instance,
  8452. options: options
  8453. });
  8454. var noopFn = function noopFn() {};
  8455. effectCleanupFns.push(cleanupFn || noopFn);
  8456. }
  8457. });
  8458. }
  8459. function cleanupModifierEffects() {
  8460. effectCleanupFns.forEach(function (fn) {
  8461. return fn();
  8462. });
  8463. effectCleanupFns = [];
  8464. }
  8465. return instance;
  8466. };
  8467. }
  8468. var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
  8469. var createPopper$1 = /*#__PURE__*/popperGenerator({
  8470. defaultModifiers: defaultModifiers
  8471. }); // eslint-disable-next-line import/no-unused-modules
  8472. const popperComputedPlacements = [
  8473. "top",
  8474. "bottom",
  8475. "right",
  8476. "left",
  8477. "top-start",
  8478. "top-end",
  8479. "bottom-start",
  8480. "bottom-end",
  8481. "right-start",
  8482. "right-end",
  8483. "left-start",
  8484. "left-end"
  8485. ];
  8486. const defaultMenuPlacement = "bottom-leading";
  8487. const popperMenuComputedPlacements = [
  8488. "top-start",
  8489. "top",
  8490. "top-end",
  8491. "bottom-start",
  8492. "bottom",
  8493. "bottom-end"
  8494. ];
  8495. const CSS$D = {
  8496. animation: "calcite-popper-anim",
  8497. animationActive: "calcite-popper-anim--active"
  8498. };
  8499. function filterComputedPlacements(placements, el) {
  8500. const filteredPlacements = placements.filter((placement) => popperComputedPlacements.includes(placement));
  8501. if (filteredPlacements.length !== placements.length) {
  8502. console.warn(`${el.tagName}: Invalid value found in: flipPlacements. Try any of these: ${popperComputedPlacements
  8503. .map((placement) => `"${placement}"`)
  8504. .join(", ")
  8505. .trim()}`, { el });
  8506. }
  8507. return filteredPlacements;
  8508. }
  8509. function getPlacement(el, placement) {
  8510. const placements = ["left", "right"];
  8511. const variations = ["start", "end"];
  8512. if (getElementDir(el) === "rtl") {
  8513. placements.reverse();
  8514. variations.reverse();
  8515. }
  8516. return placement
  8517. .replace(/-leading/gi, `-${variations[0]}`)
  8518. .replace(/-trailing/gi, `-${variations[1]}`)
  8519. .replace(/leading/gi, placements[0])
  8520. .replace(/trailing/gi, placements[1]);
  8521. }
  8522. function createPopper({ referenceEl, el, placement, overlayPositioning = "absolute", modifiers }) {
  8523. if (!referenceEl) {
  8524. return null;
  8525. }
  8526. return createPopper$1(referenceEl, el, {
  8527. strategy: overlayPositioning,
  8528. placement: getPlacement(el, placement),
  8529. modifiers
  8530. });
  8531. }
  8532. async function updatePopper({ el, modifiers, placement: PopperPlacement, popper }) {
  8533. const placement = getPlacement(el, PopperPlacement);
  8534. await popper.setOptions({
  8535. modifiers,
  8536. placement
  8537. });
  8538. }
  8539. function hypotenuse(sideA, sideB) {
  8540. return Math.sqrt(Math.pow(sideA, 2) + Math.pow(sideB, 2));
  8541. }
  8542. const visiblePointerSize = 4;
  8543. const defaultOffsetDistance = Math.ceil(hypotenuse(visiblePointerSize, visiblePointerSize));
  8544. const ComboboxItem$1 = "CALCITE-COMBOBOX-ITEM";
  8545. const ComboboxItemGroup$1 = "CALCITE-COMBOBOX-ITEM-GROUP";
  8546. const ComboboxChildSelector = `${ComboboxItem$1}, ${ComboboxItemGroup$1}`;
  8547. const TEXT$g = {
  8548. removeTag: "Remove tag"
  8549. };
  8550. function getAncestors(element) {
  8551. var _a, _b;
  8552. const parent = (_a = element.parentElement) === null || _a === void 0 ? void 0 : _a.closest(ComboboxChildSelector);
  8553. const grandparent = (_b = parent === null || parent === void 0 ? void 0 : parent.parentElement) === null || _b === void 0 ? void 0 : _b.closest(ComboboxChildSelector);
  8554. return [parent, grandparent].filter((el) => el);
  8555. }
  8556. function getItemAncestors(item) {
  8557. var _a;
  8558. return (((_a = item.ancestors) === null || _a === void 0 ? void 0 : _a.filter((el) => el.nodeName === "CALCITE-COMBOBOX-ITEM")) || []);
  8559. }
  8560. function getItemChildren(item) {
  8561. return nodeListToArray(item.querySelectorAll("calcite-combobox-item"));
  8562. }
  8563. function hasActiveChildren(node) {
  8564. const items = nodeListToArray(node.querySelectorAll("calcite-combobox-item"));
  8565. return items.filter((item) => item.selected).length > 0;
  8566. }
  8567. function getDepth(element) {
  8568. if (!Build.isBrowser) {
  8569. return 0;
  8570. }
  8571. const result = document.evaluate("ancestor::calcite-combobox-item | ancestor::calcite-combobox-item-group", element, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  8572. return result.snapshotLength;
  8573. }
  8574. 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}";
  8575. const isGroup = (el) => el.tagName === ComboboxItemGroup$1;
  8576. const itemUidPrefix = "combobox-item-";
  8577. const chipUidPrefix = "combobox-chip-";
  8578. const labelUidPrefix = "combobox-label-";
  8579. const listboxUidPrefix = "combobox-listbox-";
  8580. const inputUidPrefix = "combobox-input-";
  8581. const Combobox = class extends HTMLElement$1 {
  8582. constructor() {
  8583. super();
  8584. this.__registerHost();
  8585. this.__attachShadow();
  8586. this.calciteLookupChange = createEvent(this, "calciteLookupChange", 7);
  8587. this.calciteComboboxChange = createEvent(this, "calciteComboboxChange", 7);
  8588. this.calciteComboboxFilterChange = createEvent(this, "calciteComboboxFilterChange", 7);
  8589. this.calciteComboboxChipDismiss = createEvent(this, "calciteComboboxChipDismiss", 7);
  8590. this.calciteComboboxOpen = createEvent(this, "calciteComboboxOpen", 7);
  8591. this.calciteComboboxClose = createEvent(this, "calciteComboboxClose", 7);
  8592. //--------------------------------------------------------------------------
  8593. //
  8594. // Public Properties
  8595. //
  8596. //--------------------------------------------------------------------------
  8597. /** Opens or closes the combobox */
  8598. this.active = false;
  8599. /** Disable combobox input */
  8600. this.disabled = false;
  8601. /** Specify the maximum number of combobox items (including nested children) to display before showing the scroller */
  8602. this.maxItems = 0;
  8603. /** Describes the type of positioning to use for the overlaid content. If your element is in a fixed container, use the 'fixed' value. */
  8604. this.overlayPositioning = "absolute";
  8605. /**
  8606. * When true, makes the component required for form-submission.
  8607. *
  8608. * @internal
  8609. */
  8610. this.required = false;
  8611. /** specify the selection mode
  8612. * - multi: allow any number of selected items (default)
  8613. * - single: only one selection)
  8614. * - ancestors: like multi, but show ancestors of selected items as selected, only deepest children shown in chips
  8615. */
  8616. this.selectionMode = "multi";
  8617. /** Specify the scale of the combobox, defaults to m */
  8618. this.scale = "m";
  8619. /** The value(s) of the selectedItem(s) */
  8620. this.value = null;
  8621. /** string to override the English "Remove tag" text for when an item is selected.
  8622. * @default "Remove tag"
  8623. */
  8624. this.intlRemoveTag = TEXT$g.removeTag;
  8625. this.internalValueChangeFlag = false;
  8626. this.items = [];
  8627. this.groupItems = [];
  8628. this.selectedItems = [];
  8629. this.visibleItems = [];
  8630. this.activeItemIndex = -1;
  8631. this.activeChipIndex = -1;
  8632. this.activeDescendant = "";
  8633. this.text = "";
  8634. this.textInput = null;
  8635. this.mutationObserver = createObserver("mutation", () => this.updateItems());
  8636. this.resizeObserver = createObserver("resize", () => this.setMaxScrollerHeight());
  8637. this.guid = guid();
  8638. this.inputHeight = 0;
  8639. this.ignoreSelectedEventsFlag = false;
  8640. this.activeTransitionProp = "opacity";
  8641. // --------------------------------------------------------------------------
  8642. //
  8643. // Private Methods
  8644. //
  8645. // --------------------------------------------------------------------------
  8646. this.setFilteredPlacements = () => {
  8647. const { el, flipPlacements } = this;
  8648. this.filteredFlipPlacements = flipPlacements
  8649. ? filterComputedPlacements(flipPlacements, el)
  8650. : null;
  8651. };
  8652. this.getValue = () => {
  8653. 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(); });
  8654. return (items === null || items === void 0 ? void 0 : items.length) ? (items.length > 1 ? items : items[0]) : "";
  8655. };
  8656. this.onLabelClick = () => {
  8657. this.setFocus();
  8658. };
  8659. this.keydownHandler = (event) => {
  8660. const { key } = event;
  8661. switch (key) {
  8662. case "Tab":
  8663. this.activeChipIndex = -1;
  8664. this.activeItemIndex = -1;
  8665. if (this.allowCustomValues && this.text) {
  8666. this.addCustomChip(this.text, true);
  8667. event.preventDefault();
  8668. }
  8669. else if (this.active) {
  8670. this.active = false;
  8671. event.preventDefault();
  8672. }
  8673. break;
  8674. case "ArrowLeft":
  8675. this.previousChip();
  8676. break;
  8677. case "ArrowRight":
  8678. this.nextChip();
  8679. break;
  8680. case "ArrowUp":
  8681. this.shiftActiveItemIndex(-1);
  8682. if (!this.comboboxInViewport()) {
  8683. this.el.scrollIntoView();
  8684. }
  8685. break;
  8686. case "ArrowDown":
  8687. if (!this.active) {
  8688. event.preventDefault();
  8689. this.active = true;
  8690. }
  8691. this.shiftActiveItemIndex(1);
  8692. if (!this.comboboxInViewport()) {
  8693. this.el.scrollIntoView();
  8694. }
  8695. break;
  8696. case " ":
  8697. if (!this.textInput.value) {
  8698. event.preventDefault();
  8699. this.active = true;
  8700. this.shiftActiveItemIndex(1);
  8701. }
  8702. break;
  8703. case "Home":
  8704. if (this.active) {
  8705. event.preventDefault();
  8706. }
  8707. this.updateActiveItemIndex(0);
  8708. this.scrollToActiveItem();
  8709. if (!this.comboboxInViewport()) {
  8710. this.el.scrollIntoView();
  8711. }
  8712. break;
  8713. case "End":
  8714. if (this.active) {
  8715. event.preventDefault();
  8716. }
  8717. this.updateActiveItemIndex(this.visibleItems.length - 1);
  8718. this.scrollToActiveItem();
  8719. if (!this.comboboxInViewport()) {
  8720. this.el.scrollIntoView();
  8721. }
  8722. break;
  8723. case "Escape":
  8724. this.active = false;
  8725. break;
  8726. case "Enter":
  8727. if (this.activeItemIndex > -1) {
  8728. this.toggleSelection(this.visibleItems[this.activeItemIndex]);
  8729. }
  8730. else if (this.activeChipIndex > -1) {
  8731. this.removeActiveChip();
  8732. }
  8733. else if (this.allowCustomValues && this.text) {
  8734. this.addCustomChip(this.text, true);
  8735. }
  8736. else if (!event.defaultPrevented) {
  8737. submitForm(this);
  8738. }
  8739. break;
  8740. case "Delete":
  8741. case "Backspace":
  8742. if (this.activeChipIndex > -1) {
  8743. this.removeActiveChip();
  8744. }
  8745. else if (!this.text && this.isMulti()) {
  8746. this.removeLastChip();
  8747. }
  8748. break;
  8749. }
  8750. };
  8751. this.toggleCloseEnd = () => {
  8752. this.active = false;
  8753. this.el.removeEventListener("calciteComboboxClose", this.toggleCloseEnd);
  8754. };
  8755. this.toggleOpenEnd = () => {
  8756. this.active = true;
  8757. this.el.removeEventListener("calciteComboboxOpen", this.toggleOpenEnd);
  8758. };
  8759. this.transitionEnd = (event) => {
  8760. if (event.propertyName === this.activeTransitionProp) {
  8761. this.active ? this.calciteComboboxOpen.emit() : this.calciteComboboxClose.emit();
  8762. }
  8763. };
  8764. this.setMaxScrollerHeight = () => {
  8765. const { active, listContainerEl } = this;
  8766. if (!listContainerEl || !active) {
  8767. return;
  8768. }
  8769. this.reposition();
  8770. const maxScrollerHeight = this.getMaxScrollerHeight();
  8771. listContainerEl.style.maxHeight = maxScrollerHeight > 0 ? `${maxScrollerHeight}px` : "";
  8772. this.reposition();
  8773. };
  8774. this.calciteChipDismissHandler = (event, comboboxItem) => {
  8775. this.active = false;
  8776. const selection = this.items.find((item) => item === comboboxItem);
  8777. if (selection) {
  8778. this.toggleSelection(selection, false);
  8779. }
  8780. this.calciteComboboxChipDismiss.emit(event.detail);
  8781. };
  8782. this.clickHandler = (event) => {
  8783. if (event.composedPath().some((node) => node.tagName === "CALCITE-CHIP")) {
  8784. return;
  8785. }
  8786. this.active = !this.active;
  8787. this.updateActiveItemIndex(0);
  8788. this.setFocus();
  8789. };
  8790. this.setInactiveIfNotContained = (event) => {
  8791. const composedPath = event.composedPath();
  8792. if (!this.active || composedPath.includes(this.el) || composedPath.includes(this.referenceEl)) {
  8793. return;
  8794. }
  8795. if (this.allowCustomValues && this.text.trim().length) {
  8796. this.addCustomChip(this.text);
  8797. }
  8798. if (this.selectionMode === "single") {
  8799. if (this.textInput) {
  8800. this.textInput.value = "";
  8801. }
  8802. this.text = "";
  8803. this.filterItems("");
  8804. this.updateActiveItemIndex(-1);
  8805. }
  8806. this.active = false;
  8807. };
  8808. this.setMenuEl = (el) => {
  8809. this.menuEl = el;
  8810. };
  8811. this.setListContainerEl = (el) => {
  8812. this.resizeObserver.observe(el);
  8813. this.listContainerEl = el;
  8814. };
  8815. this.setReferenceEl = (el) => {
  8816. this.referenceEl = el;
  8817. };
  8818. this.inputHandler = (event) => {
  8819. const value = event.target.value;
  8820. this.text = value;
  8821. this.filterItems(value);
  8822. if (value) {
  8823. this.activeChipIndex = -1;
  8824. }
  8825. };
  8826. this.filterItems = (() => {
  8827. const find = (item, filteredData) => item &&
  8828. filteredData.some(({ label, value }) => {
  8829. if (isGroup(item)) {
  8830. return value === item.label;
  8831. }
  8832. return (value === item.textLabel ||
  8833. value === item.value ||
  8834. label === item.textLabel ||
  8835. label === item.value);
  8836. });
  8837. return debounce$1((text) => {
  8838. const filteredData = filter(this.data, text);
  8839. const items = this.getCombinedItems();
  8840. items.forEach((item) => {
  8841. const hidden = !find(item, filteredData);
  8842. item.hidden = hidden;
  8843. const [parent, grandparent] = item.ancestors;
  8844. if (find(parent, filteredData) || find(grandparent, filteredData)) {
  8845. item.hidden = false;
  8846. }
  8847. if (!hidden) {
  8848. item.ancestors.forEach((ancestor) => (ancestor.hidden = false));
  8849. }
  8850. });
  8851. this.visibleItems = this.getVisibleItems();
  8852. this.calciteComboboxFilterChange.emit({ visibleItems: [...this.visibleItems], text: text });
  8853. }, 100);
  8854. })();
  8855. this.internalCalciteLookupChangeEvent = () => {
  8856. this.calciteLookupChange.emit(this.selectedItems);
  8857. };
  8858. this.emitCalciteLookupChange = debounce$1(this.internalCalciteLookupChangeEvent, 0);
  8859. this.internalComboboxChangeEvent = () => {
  8860. const { selectedItems } = this;
  8861. this.calciteComboboxChange.emit({ selectedItems });
  8862. };
  8863. this.emitComboboxChange = debounce$1(this.internalComboboxChangeEvent, 0);
  8864. this.updateItems = () => {
  8865. this.items = this.getItems();
  8866. this.groupItems = this.getGroupItems();
  8867. this.data = this.getData();
  8868. this.selectedItems = this.getSelectedItems();
  8869. this.visibleItems = this.getVisibleItems();
  8870. this.needsIcon = this.getNeedsIcon();
  8871. if (!this.allowCustomValues) {
  8872. this.setMaxScrollerHeight();
  8873. }
  8874. };
  8875. this.scrollToActiveItem = () => {
  8876. const activeItem = this.visibleItems[this.activeItemIndex];
  8877. const height = this.calculateSingleItemHeight(activeItem);
  8878. const { offsetHeight, scrollTop } = this.listContainerEl;
  8879. if (offsetHeight + scrollTop < activeItem.offsetTop + height) {
  8880. this.listContainerEl.scrollTop = activeItem.offsetTop - offsetHeight + height;
  8881. }
  8882. else if (activeItem.offsetTop < scrollTop) {
  8883. this.listContainerEl.scrollTop = activeItem.offsetTop;
  8884. }
  8885. };
  8886. this.comboboxFocusHandler = () => {
  8887. var _a;
  8888. (_a = this.textInput) === null || _a === void 0 ? void 0 : _a.focus();
  8889. };
  8890. this.comboboxBlurHandler = (event) => {
  8891. this.setInactiveIfNotContained(event);
  8892. };
  8893. }
  8894. activeHandler() {
  8895. if (this.disabled) {
  8896. this.active = false;
  8897. return;
  8898. }
  8899. this.reposition();
  8900. }
  8901. handleDisabledChange(value) {
  8902. if (!value) {
  8903. this.active = false;
  8904. }
  8905. }
  8906. maxItemsHandler() {
  8907. this.setMaxScrollerHeight();
  8908. }
  8909. valueHandler(value) {
  8910. if (!this.internalValueChangeFlag) {
  8911. const items = this.getItems();
  8912. if (Array.isArray(value)) {
  8913. items.forEach((item) => (item.selected = value.includes(item.value)));
  8914. }
  8915. else if (value) {
  8916. items.forEach((item) => (item.selected = value === item.value));
  8917. }
  8918. else {
  8919. items.forEach((item) => (item.selected = false));
  8920. }
  8921. this.updateItems();
  8922. }
  8923. }
  8924. flipPlacementsHandler() {
  8925. this.setFilteredPlacements();
  8926. }
  8927. //--------------------------------------------------------------------------
  8928. //
  8929. // Event Listeners
  8930. //
  8931. //--------------------------------------------------------------------------
  8932. documentClickHandler(event) {
  8933. this.setInactiveIfNotContained(event);
  8934. }
  8935. calciteComboboxItemChangeHandler(event) {
  8936. if (this.ignoreSelectedEventsFlag) {
  8937. return;
  8938. }
  8939. const target = event.target;
  8940. const newIndex = this.visibleItems.indexOf(target);
  8941. this.updateActiveItemIndex(newIndex);
  8942. this.toggleSelection(target, target.selected);
  8943. }
  8944. //--------------------------------------------------------------------------
  8945. //
  8946. // Public Methods
  8947. //
  8948. //--------------------------------------------------------------------------
  8949. /** Updates the position of the component. */
  8950. async reposition() {
  8951. const { popper, menuEl } = this;
  8952. const modifiers = this.getModifiers();
  8953. popper
  8954. ? await updatePopper({
  8955. el: menuEl,
  8956. modifiers,
  8957. placement: defaultMenuPlacement,
  8958. popper
  8959. })
  8960. : this.createPopper();
  8961. }
  8962. /** Sets focus on the component. */
  8963. async setFocus() {
  8964. var _a;
  8965. (_a = this.textInput) === null || _a === void 0 ? void 0 : _a.focus();
  8966. this.activeChipIndex = -1;
  8967. this.activeItemIndex = -1;
  8968. }
  8969. // --------------------------------------------------------------------------
  8970. //
  8971. // Lifecycle
  8972. //
  8973. // --------------------------------------------------------------------------
  8974. connectedCallback() {
  8975. var _a;
  8976. this.internalValueChangeFlag = true;
  8977. this.value = this.getValue();
  8978. this.internalValueChangeFlag = false;
  8979. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
  8980. this.createPopper();
  8981. connectLabel(this);
  8982. connectForm(this);
  8983. this.setFilteredPlacements();
  8984. }
  8985. componentWillLoad() {
  8986. this.updateItems();
  8987. }
  8988. componentDidLoad() {
  8989. afterConnectDefaultValueSet(this, this.getValue());
  8990. }
  8991. componentDidRender() {
  8992. if (this.el.offsetHeight !== this.inputHeight) {
  8993. this.reposition();
  8994. this.inputHeight = this.el.offsetHeight;
  8995. }
  8996. updateHostInteraction(this);
  8997. }
  8998. disconnectedCallback() {
  8999. var _a, _b;
  9000. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  9001. (_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
  9002. this.destroyPopper();
  9003. disconnectLabel(this);
  9004. disconnectForm(this);
  9005. }
  9006. selectedItemsHandler() {
  9007. this.internalValueChangeFlag = true;
  9008. this.value = this.getValue();
  9009. this.internalValueChangeFlag = false;
  9010. }
  9011. /** when search text is cleared, reset active to */
  9012. textHandler() {
  9013. this.updateActiveItemIndex(-1);
  9014. }
  9015. comboboxInViewport() {
  9016. const bounding = this.el.getBoundingClientRect();
  9017. return (bounding.top >= 0 &&
  9018. bounding.left >= 0 &&
  9019. bounding.right <= (window.innerWidth || document.documentElement.clientWidth) &&
  9020. bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight));
  9021. }
  9022. getModifiers() {
  9023. const flipModifier = {
  9024. name: "flip",
  9025. enabled: true
  9026. };
  9027. flipModifier.options = {
  9028. fallbackPlacements: this.filteredFlipPlacements || popperMenuComputedPlacements
  9029. };
  9030. const eventListenerModifier = {
  9031. name: "eventListeners",
  9032. enabled: this.active
  9033. };
  9034. return [flipModifier, eventListenerModifier];
  9035. }
  9036. createPopper() {
  9037. this.destroyPopper();
  9038. const { menuEl, referenceEl, overlayPositioning } = this;
  9039. const modifiers = this.getModifiers();
  9040. this.popper = createPopper({
  9041. el: menuEl,
  9042. modifiers,
  9043. overlayPositioning,
  9044. placement: defaultMenuPlacement,
  9045. referenceEl
  9046. });
  9047. }
  9048. destroyPopper() {
  9049. const { popper } = this;
  9050. if (popper) {
  9051. popper.destroy();
  9052. }
  9053. this.popper = null;
  9054. }
  9055. getMaxScrollerHeight() {
  9056. const items = this.getCombinedItems().filter((item) => !item.hidden);
  9057. const { maxItems } = this;
  9058. let itemsToProcess = 0;
  9059. let maxScrollerHeight = 0;
  9060. if (items.length > maxItems) {
  9061. items.forEach((item) => {
  9062. if (itemsToProcess < maxItems && maxItems > 0) {
  9063. const height = this.calculateSingleItemHeight(item);
  9064. if (height > 0) {
  9065. maxScrollerHeight += height;
  9066. itemsToProcess++;
  9067. }
  9068. }
  9069. });
  9070. }
  9071. return maxScrollerHeight;
  9072. }
  9073. calculateSingleItemHeight(item) {
  9074. let height = item.offsetHeight;
  9075. // if item has children items, don't count their height twice
  9076. const children = Array.from(item.querySelectorAll(ComboboxChildSelector));
  9077. children
  9078. .map((child) => child === null || child === void 0 ? void 0 : child.offsetHeight)
  9079. .forEach((offsetHeight) => {
  9080. height -= offsetHeight;
  9081. });
  9082. return height;
  9083. }
  9084. getCombinedItems() {
  9085. return [...this.groupItems, ...this.items];
  9086. }
  9087. toggleSelection(item, value = !item.selected) {
  9088. if (!item) {
  9089. return;
  9090. }
  9091. if (this.isMulti()) {
  9092. item.selected = value;
  9093. this.updateAncestors(item);
  9094. this.selectedItems = this.getSelectedItems();
  9095. this.emitCalciteLookupChange();
  9096. this.emitComboboxChange();
  9097. this.resetText();
  9098. this.filterItems("");
  9099. }
  9100. else {
  9101. this.ignoreSelectedEventsFlag = true;
  9102. this.items.forEach((el) => (el.selected = el === item ? value : false));
  9103. this.ignoreSelectedEventsFlag = false;
  9104. this.selectedItems = this.getSelectedItems();
  9105. this.emitComboboxChange();
  9106. if (this.textInput) {
  9107. this.textInput.value = item.textLabel;
  9108. }
  9109. this.active = false;
  9110. this.updateActiveItemIndex(-1);
  9111. this.resetText();
  9112. this.filterItems("");
  9113. }
  9114. }
  9115. updateAncestors(item) {
  9116. if (this.selectionMode !== "ancestors") {
  9117. return;
  9118. }
  9119. const ancestors = getItemAncestors(item);
  9120. const children = getItemChildren(item);
  9121. if (item.selected) {
  9122. ancestors.forEach((el) => {
  9123. el.selected = true;
  9124. });
  9125. }
  9126. else {
  9127. children.forEach((el) => (el.selected = false));
  9128. [...ancestors].forEach((el) => {
  9129. if (!hasActiveChildren(el)) {
  9130. el.selected = false;
  9131. }
  9132. });
  9133. }
  9134. }
  9135. getVisibleItems() {
  9136. return this.items.filter((item) => !item.hidden);
  9137. }
  9138. getSelectedItems() {
  9139. if (!this.isMulti()) {
  9140. const match = this.items.find(({ selected }) => selected);
  9141. return match ? [match] : [];
  9142. }
  9143. return (this.items
  9144. .filter((item) => item.selected && (this.selectionMode !== "ancestors" || !hasActiveChildren(item)))
  9145. /** Preserve order of entered tags */
  9146. .sort((a, b) => {
  9147. const aIdx = this.selectedItems.indexOf(a);
  9148. const bIdx = this.selectedItems.indexOf(b);
  9149. if (aIdx > -1 && bIdx > -1) {
  9150. return aIdx - bIdx;
  9151. }
  9152. return bIdx - aIdx;
  9153. }));
  9154. }
  9155. getData() {
  9156. return this.items.map((item) => ({
  9157. constant: item.constant,
  9158. value: item.value,
  9159. label: item.textLabel
  9160. }));
  9161. }
  9162. getNeedsIcon() {
  9163. return this.selectionMode === "single" && this.items.some((item) => item.icon);
  9164. }
  9165. resetText() {
  9166. if (this.textInput) {
  9167. this.textInput.value = "";
  9168. }
  9169. this.text = "";
  9170. }
  9171. getItems() {
  9172. const items = Array.from(this.el.querySelectorAll(ComboboxItem$1));
  9173. return items.filter((item) => !item.disabled);
  9174. }
  9175. getGroupItems() {
  9176. return Array.from(this.el.querySelectorAll(ComboboxItemGroup$1));
  9177. }
  9178. addCustomChip(value, focus) {
  9179. const existingItem = this.items.find((el) => el.textLabel === value);
  9180. if (existingItem) {
  9181. this.toggleSelection(existingItem, true);
  9182. }
  9183. else {
  9184. if (!this.isMulti()) {
  9185. this.toggleSelection(this.selectedItems[this.selectedItems.length - 1], false);
  9186. }
  9187. const item = document.createElement(ComboboxItem$1);
  9188. item.value = value;
  9189. item.textLabel = value;
  9190. item.selected = true;
  9191. this.el.appendChild(item);
  9192. this.resetText();
  9193. if (focus) {
  9194. this.setFocus();
  9195. }
  9196. this.updateItems();
  9197. this.filterItems("");
  9198. this.emitCalciteLookupChange();
  9199. this.emitComboboxChange();
  9200. }
  9201. }
  9202. removeActiveChip() {
  9203. this.toggleSelection(this.selectedItems[this.activeChipIndex], false);
  9204. this.setFocus();
  9205. }
  9206. removeLastChip() {
  9207. this.toggleSelection(this.selectedItems[this.selectedItems.length - 1], false);
  9208. this.setFocus();
  9209. }
  9210. previousChip() {
  9211. if (this.text) {
  9212. return;
  9213. }
  9214. const length = this.selectedItems.length - 1;
  9215. const active = this.activeChipIndex;
  9216. this.activeChipIndex = active === -1 ? length : Math.max(active - 1, 0);
  9217. this.updateActiveItemIndex(-1);
  9218. this.focusChip();
  9219. }
  9220. nextChip() {
  9221. if (this.text || this.activeChipIndex === -1) {
  9222. return;
  9223. }
  9224. const last = this.selectedItems.length - 1;
  9225. const newIndex = this.activeChipIndex + 1;
  9226. if (newIndex > last) {
  9227. this.activeChipIndex = -1;
  9228. this.setFocus();
  9229. }
  9230. else {
  9231. this.activeChipIndex = newIndex;
  9232. this.focusChip();
  9233. }
  9234. this.updateActiveItemIndex(-1);
  9235. }
  9236. focusChip() {
  9237. var _a;
  9238. const guid = (_a = this.selectedItems[this.activeChipIndex]) === null || _a === void 0 ? void 0 : _a.guid;
  9239. const chip = guid
  9240. ? this.referenceEl.querySelector(`#${chipUidPrefix}${guid}`)
  9241. : null;
  9242. chip === null || chip === void 0 ? void 0 : chip.setFocus();
  9243. }
  9244. shiftActiveItemIndex(delta) {
  9245. const { length } = this.visibleItems;
  9246. const newIndex = (this.activeItemIndex + length + delta) % length;
  9247. this.updateActiveItemIndex(newIndex);
  9248. this.scrollToActiveItem();
  9249. }
  9250. updateActiveItemIndex(index) {
  9251. var _a;
  9252. this.activeItemIndex = index;
  9253. let activeDescendant = null;
  9254. this.visibleItems.forEach((el, i) => {
  9255. if (i === index) {
  9256. el.active = true;
  9257. activeDescendant = el.guid;
  9258. }
  9259. else {
  9260. el.active = false;
  9261. }
  9262. });
  9263. this.activeDescendant = activeDescendant;
  9264. if (this.activeItemIndex > -1) {
  9265. this.activeChipIndex = -1;
  9266. (_a = this.textInput) === null || _a === void 0 ? void 0 : _a.focus();
  9267. }
  9268. }
  9269. isMulti() {
  9270. return this.selectionMode !== "single";
  9271. }
  9272. //--------------------------------------------------------------------------
  9273. //
  9274. // Render Methods
  9275. //
  9276. //--------------------------------------------------------------------------
  9277. renderChips() {
  9278. const { activeChipIndex, scale, selectionMode, intlRemoveTag } = this;
  9279. return this.selectedItems.map((item, i) => {
  9280. const chipClasses = {
  9281. chip: true,
  9282. "chip--active": activeChipIndex === i
  9283. };
  9284. const ancestors = [...getItemAncestors(item)].reverse();
  9285. const pathLabel = [...ancestors, item].map((el) => el.textLabel);
  9286. const label = selectionMode !== "ancestors" ? item.textLabel : pathLabel.join(" / ");
  9287. 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));
  9288. });
  9289. }
  9290. renderInput() {
  9291. const { guid, active, disabled, placeholder, selectionMode, needsIcon, selectedItems } = this;
  9292. const single = selectionMode === "single";
  9293. const selectedItem = selectedItems[0];
  9294. const showLabel = !active && single && !!selectedItem;
  9295. return (h("span", { class: {
  9296. "input-wrap": true,
  9297. "input-wrap--single": single
  9298. } }, showLabel && (h("span", { class: {
  9299. label: true,
  9300. "label--spaced": needsIcon
  9301. }, key: "label" }, selectedItem.textLabel)), h("input", { "aria-activedescendant": this.activeDescendant, "aria-autocomplete": "list", "aria-controls": `${listboxUidPrefix}${guid}`, "aria-label": getLabelText(this), class: {
  9302. input: true,
  9303. "input--single": true,
  9304. "input--transparent": this.activeChipIndex > -1,
  9305. "input--hidden": showLabel,
  9306. "input--icon": single && needsIcon
  9307. }, 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" })));
  9308. }
  9309. renderListBoxOptions() {
  9310. 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)));
  9311. }
  9312. renderPopperContainer() {
  9313. const { active, setMenuEl, setListContainerEl } = this;
  9314. const classes = {
  9315. "list-container": true,
  9316. [CSS$D.animation]: true,
  9317. [CSS$D.animationActive]: active
  9318. };
  9319. 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)))));
  9320. }
  9321. renderIconStart() {
  9322. const { selectionMode, needsIcon, selectedItems } = this;
  9323. const selectedItem = selectedItems[0];
  9324. return (selectionMode === "single" &&
  9325. 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" })))));
  9326. }
  9327. renderIconEnd() {
  9328. const { active } = this;
  9329. return (h("span", { class: "icon-end" }, h("calcite-icon", { icon: active ? "chevron-up" : "chevron-down", scale: "s" })));
  9330. }
  9331. render() {
  9332. const { active, guid, label } = this;
  9333. const single = this.selectionMode === "single";
  9334. 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: {
  9335. wrapper: true,
  9336. "wrapper--single": single || !this.selectedItems.length,
  9337. "wrapper--active": active
  9338. }, 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 })));
  9339. }
  9340. get el() { return this; }
  9341. static get watchers() { return {
  9342. "active": ["activeHandler"],
  9343. "disabled": ["handleDisabledChange"],
  9344. "maxItems": ["maxItemsHandler"],
  9345. "value": ["valueHandler"],
  9346. "flipPlacements": ["flipPlacementsHandler"],
  9347. "selectedItems": ["selectedItemsHandler"],
  9348. "text": ["textHandler"]
  9349. }; }
  9350. static get style() { return comboboxCss; }
  9351. };
  9352. const CSS$C = {
  9353. icon: "icon",
  9354. iconActive: "icon--active",
  9355. custom: "icon--custom",
  9356. dot: "icon--dot",
  9357. single: "label--single",
  9358. label: "label",
  9359. active: "label--active",
  9360. selected: "label--selected",
  9361. title: "title",
  9362. textContainer: "text-container"
  9363. };
  9364. 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}";
  9365. const ComboboxItem = class extends HTMLElement$1 {
  9366. constructor() {
  9367. super();
  9368. this.__registerHost();
  9369. this.__attachShadow();
  9370. this.calciteComboboxItemChange = createEvent(this, "calciteComboboxItemChange", 7);
  9371. // --------------------------------------------------------------------------
  9372. //
  9373. // Properties
  9374. //
  9375. // --------------------------------------------------------------------------
  9376. /** When true, the item cannot be clicked and is visually muted. */
  9377. this.disabled = false;
  9378. /** Set this to true to pre-select an item. Toggles when an item is checked/unchecked. */
  9379. this.selected = false;
  9380. /** True when item is highlighted either from keyboard or mouse hover */
  9381. this.active = false;
  9382. /** Unique identifier, used for accessibility */
  9383. this.guid = guid();
  9384. this.scale = "m";
  9385. // --------------------------------------------------------------------------
  9386. //
  9387. // Private Methods
  9388. //
  9389. // --------------------------------------------------------------------------
  9390. this.itemClickHandler = (event) => {
  9391. event.preventDefault();
  9392. if (this.disabled) {
  9393. return;
  9394. }
  9395. this.selected = !this.selected;
  9396. };
  9397. }
  9398. selectedWatchHandler() {
  9399. this.calciteComboboxItemChange.emit(this.el);
  9400. }
  9401. // --------------------------------------------------------------------------
  9402. //
  9403. // Lifecycle
  9404. //
  9405. // --------------------------------------------------------------------------
  9406. connectedCallback() {
  9407. this.ancestors = getAncestors(this.el);
  9408. this.scale = getElementProp(this.el, "scale", this.scale);
  9409. connectConditionalSlotComponent(this);
  9410. }
  9411. disconnectedCallback() {
  9412. disconnectConditionalSlotComponent(this);
  9413. }
  9414. componentDidRender() {
  9415. updateHostInteraction(this);
  9416. }
  9417. // --------------------------------------------------------------------------
  9418. //
  9419. // Public Methods
  9420. //
  9421. // --------------------------------------------------------------------------
  9422. /**
  9423. * Used to toggle the selection state. By default this won't trigger an event.
  9424. * The first argument allows the value to be coerced, rather than swapping values.
  9425. */
  9426. async toggleSelected(coerce) {
  9427. if (this.disabled) {
  9428. return;
  9429. }
  9430. this.selected = typeof coerce === "boolean" ? coerce : !this.selected;
  9431. }
  9432. // --------------------------------------------------------------------------
  9433. //
  9434. // Render Methods
  9435. //
  9436. // --------------------------------------------------------------------------
  9437. renderIcon(isSingle) {
  9438. const { icon, disabled, selected } = this;
  9439. const level = `${CSS$C.icon}--indent`;
  9440. const defaultIcon = isSingle ? "dot" : "check";
  9441. const iconPath = disabled ? "circle-disallowed" : defaultIcon;
  9442. const showDot = isSingle && !icon && !disabled;
  9443. return showDot ? (h("span", { class: {
  9444. [CSS$C.icon]: true,
  9445. [CSS$C.dot]: true,
  9446. [level]: true
  9447. } })) : (h("calcite-icon", { class: {
  9448. [CSS$C.icon]: !icon,
  9449. [CSS$C.custom]: !!icon,
  9450. [CSS$C.iconActive]: icon && selected,
  9451. [level]: true
  9452. }, icon: icon || iconPath, scale: "s" }));
  9453. }
  9454. renderChildren() {
  9455. if (getSlotted(this.el)) {
  9456. return (h("ul", { key: "default-slot-container" }, h("slot", null)));
  9457. }
  9458. return null;
  9459. }
  9460. render() {
  9461. const isSingleSelect = getElementProp(this.el, "selection-mode", "multi") === "single";
  9462. const classes = {
  9463. [CSS$C.label]: true,
  9464. [CSS$C.selected]: this.selected,
  9465. [CSS$C.active]: this.active,
  9466. [CSS$C.single]: isSingleSelect
  9467. };
  9468. const depth = getDepth(this.el);
  9469. 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())));
  9470. }
  9471. get el() { return this; }
  9472. static get watchers() { return {
  9473. "selected": ["selectedWatchHandler"]
  9474. }; }
  9475. static get style() { return comboboxItemCss; }
  9476. };
  9477. const CSS$B = {
  9478. list: "list",
  9479. label: "label",
  9480. title: "title"
  9481. };
  9482. 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)}";
  9483. const ComboboxItemGroup = class extends HTMLElement$1 {
  9484. constructor() {
  9485. super();
  9486. this.__registerHost();
  9487. this.__attachShadow();
  9488. this.guid = guid();
  9489. this.scale = "m";
  9490. }
  9491. // --------------------------------------------------------------------------
  9492. //
  9493. // Lifecycle
  9494. //
  9495. // --------------------------------------------------------------------------
  9496. connectedCallback() {
  9497. this.ancestors = getAncestors(this.el);
  9498. this.scale = getElementProp(this.el, "scale", this.scale);
  9499. }
  9500. // --------------------------------------------------------------------------
  9501. //
  9502. // Render Methods
  9503. //
  9504. // --------------------------------------------------------------------------
  9505. render() {
  9506. const { el, scale } = this;
  9507. const indent = `${CSS$B.label}--indent-${getDepth(el)}`;
  9508. 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)));
  9509. }
  9510. get el() { return this; }
  9511. static get style() { return comboboxItemGroupCss; }
  9512. };
  9513. function isActivationKey(key) {
  9514. return key === "Enter" || key === " ";
  9515. }
  9516. const numberKeys = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
  9517. function isValidNumber(numberString) {
  9518. return !(!numberString || isNaN(Number(numberString)));
  9519. }
  9520. function parseNumberString(numberString) {
  9521. if (!numberString || !stringContainsNumbers(numberString)) {
  9522. return "";
  9523. }
  9524. return sanitizeExponentialNumberString(numberString, (nonExpoNumString) => {
  9525. let containsDecimal = false;
  9526. const result = nonExpoNumString
  9527. .split("")
  9528. .filter((value, i) => {
  9529. if (value.match(/\./g) && !containsDecimal) {
  9530. containsDecimal = true;
  9531. return true;
  9532. }
  9533. if (value.match(/\-/g) && i === 0) {
  9534. return true;
  9535. }
  9536. return numberKeys.includes(value);
  9537. })
  9538. .reduce((string, part) => string + part);
  9539. return isValidNumber(result) ? Number(result).toString() : "";
  9540. });
  9541. }
  9542. function sanitizeDecimalString(decimalString) {
  9543. const decimalAtEndOfStringButNotStart = /(?!^\.)\.$/;
  9544. return decimalString.replace(decimalAtEndOfStringButNotStart, "");
  9545. }
  9546. function sanitizeNegativeString(negativeString) {
  9547. const allHyphensExceptTheStart = /(?!^-)-/g;
  9548. return negativeString.replace(allHyphensExceptTheStart, "");
  9549. }
  9550. function sanitizeLeadingZeroString(zeroString) {
  9551. const allLeadingZerosOptionallyNegative = /^([-0])0+(?=\d)/;
  9552. return zeroString.replace(allLeadingZerosOptionallyNegative, "$1");
  9553. }
  9554. function sanitizeNumberString(numberString) {
  9555. return sanitizeExponentialNumberString(numberString, (nonExpoNumString) => {
  9556. const sanitizedValue = sanitizeNegativeString(sanitizeDecimalString(sanitizeLeadingZeroString(nonExpoNumString)));
  9557. const isNegativeDecimalOnlyZeros = /^-\b0\b\.?0*$/;
  9558. return isValidNumber(sanitizedValue)
  9559. ? isNegativeDecimalOnlyZeros.test(sanitizedValue)
  9560. ? sanitizedValue
  9561. : Number(sanitizedValue).toString()
  9562. : nonExpoNumString;
  9563. });
  9564. }
  9565. function sanitizeExponentialNumberString(numberString, func) {
  9566. if (!numberString) {
  9567. return numberString;
  9568. }
  9569. const firstE = numberString.toLowerCase().indexOf("e") + 1;
  9570. return numberString
  9571. .replace(/[eE]*$/g, "")
  9572. .substring(0, firstE)
  9573. .concat(numberString.slice(firstE).replace(/[eE]/g, ""))
  9574. .split(/[eE]/)
  9575. .map((section, i) => (i === 1 ? func(section.replace(/\./g, "")) : func(section)))
  9576. .join("e")
  9577. .replace(/^e/, "1e");
  9578. }
  9579. function stringContainsNumbers(string) {
  9580. return numberKeys.some((number) => string.includes(number));
  9581. }
  9582. const locales = [
  9583. "ar",
  9584. "bg",
  9585. "bs",
  9586. "ca",
  9587. "cs",
  9588. "da",
  9589. "de",
  9590. "de-CH",
  9591. "el",
  9592. "en",
  9593. "en-AU",
  9594. "en-CA",
  9595. "en-GB",
  9596. "es",
  9597. "es-MX",
  9598. "et",
  9599. "fi",
  9600. "fr",
  9601. "fr-CH",
  9602. "he",
  9603. "hi",
  9604. "hr",
  9605. "hu",
  9606. "id",
  9607. "it",
  9608. "it-CH",
  9609. "ja",
  9610. "ko",
  9611. "lt",
  9612. "lv",
  9613. "mk",
  9614. "nb",
  9615. "nl",
  9616. "pl",
  9617. "pt",
  9618. "pt-PT",
  9619. "ro",
  9620. "ru",
  9621. "sk",
  9622. "sl",
  9623. "sr",
  9624. "sv",
  9625. "th",
  9626. "tr",
  9627. "uk",
  9628. "vi",
  9629. "zh-CN",
  9630. "zh-HK",
  9631. "zh-TW"
  9632. ];
  9633. const allDecimalsExceptLast = new RegExp(`[.](?=.*[.])`, "g");
  9634. const everythingExceptNumbersDecimalsAndMinusSigns = new RegExp("[^0-9-.]", "g");
  9635. const defaultGroupSeparator = new RegExp(",", "g");
  9636. function createLocaleNumberFormatter(locale) {
  9637. return new Intl.NumberFormat(locale, {
  9638. minimumFractionDigits: 0,
  9639. maximumFractionDigits: 20
  9640. });
  9641. }
  9642. function delocalizeNumberString(numberString, locale) {
  9643. return sanitizeExponentialNumberString(numberString, (nonExpoNumString) => {
  9644. const delocalizedNumberString = nonExpoNumString
  9645. .replace(getMinusSign(locale), "-")
  9646. .replace(getGroupSeparator(locale), "")
  9647. .replace(getDecimalSeparator(locale), ".")
  9648. .replace(allDecimalsExceptLast, "")
  9649. .replace(everythingExceptNumbersDecimalsAndMinusSigns, "");
  9650. return isValidNumber(delocalizedNumberString) ? delocalizedNumberString : nonExpoNumString;
  9651. });
  9652. }
  9653. function getGroupSeparator(locale) {
  9654. const formatter = createLocaleNumberFormatter(locale);
  9655. const parts = formatter.formatToParts(1234567);
  9656. const value = parts.find((part) => part.type === "group").value;
  9657. // change whitespace group characters that don't render correctly
  9658. return value.trim().length === 0 ? " " : value;
  9659. }
  9660. function getDecimalSeparator(locale) {
  9661. const formatter = createLocaleNumberFormatter(locale);
  9662. const parts = formatter.formatToParts(1.1);
  9663. return parts.find((part) => part.type === "decimal").value;
  9664. }
  9665. function getMinusSign(locale) {
  9666. const formatter = createLocaleNumberFormatter(locale);
  9667. const parts = formatter.formatToParts(-9);
  9668. return parts.find((part) => part.type === "minusSign").value;
  9669. }
  9670. function localizeNumberString(numberString, locale, displayGroupSeparator = false) {
  9671. return sanitizeExponentialNumberString(numberString, (nonExpoNumString) => {
  9672. if (nonExpoNumString) {
  9673. const number = Number(sanitizeDecimalString(nonExpoNumString.replace(defaultGroupSeparator, "")));
  9674. if (!isNaN(number)) {
  9675. const formatter = createLocaleNumberFormatter(locale);
  9676. const parts = formatter.formatToParts(number);
  9677. const localizedNumberString = parts
  9678. .map(({ type, value }) => {
  9679. switch (type) {
  9680. case "group":
  9681. return displayGroupSeparator ? getGroupSeparator(locale) : "";
  9682. case "decimal":
  9683. return getDecimalSeparator(locale);
  9684. case "minusSign":
  9685. return getMinusSign(locale);
  9686. default:
  9687. return value;
  9688. }
  9689. })
  9690. .reduce((string, part) => string + part);
  9691. return localizedNumberString;
  9692. }
  9693. }
  9694. return nonExpoNumString;
  9695. });
  9696. }
  9697. /**
  9698. * Get supported locale code from raw user input
  9699. * Exported for testing purposes.
  9700. * @private
  9701. */
  9702. function getSupportedLocale(lang = "") {
  9703. if (locales.indexOf(lang) > -1) {
  9704. return lang;
  9705. }
  9706. lang = lang.toLowerCase();
  9707. if (lang.includes("-")) {
  9708. lang = lang.replace(/(\w+)-(\w+)/, (_match, language, region) => `${language}-${region.toUpperCase()}`);
  9709. if (!locales.includes(lang)) {
  9710. lang = lang.split("-")[0];
  9711. }
  9712. }
  9713. return locales.includes(lang) ? lang : "en";
  9714. }
  9715. /**
  9716. * CLDR cache.
  9717. * Exported for testing purposes.
  9718. * @private
  9719. */
  9720. const translationCache = {};
  9721. /**
  9722. * CLDR request cache.
  9723. * Exported for testing purposes.
  9724. * @private
  9725. */
  9726. const requestCache$1 = {};
  9727. /**
  9728. * Fetch calendar data for a given locale from list of supported languages
  9729. * @public
  9730. */
  9731. async function getLocaleData(lang) {
  9732. const locale = getSupportedLocale(lang);
  9733. if (translationCache[locale]) {
  9734. return translationCache[locale];
  9735. }
  9736. if (!requestCache$1[locale]) {
  9737. requestCache$1[locale] = fetch(getAssetPath(`./assets/date-picker/nls/${locale}.json`))
  9738. .then((resp) => resp.json())
  9739. .catch(() => {
  9740. console.error(`Translations for "${locale}" not found or invalid, falling back to english`);
  9741. return getLocaleData("en");
  9742. });
  9743. }
  9744. const data = await requestCache$1[locale];
  9745. translationCache[locale] = data;
  9746. return data;
  9747. }
  9748. /**
  9749. * Check if date is within a min and max
  9750. */
  9751. function inRange(date, min, max) {
  9752. const time = date.getTime();
  9753. const afterMin = !(min instanceof Date) || time >= min.getTime();
  9754. const beforeMax = !(max instanceof Date) || time <= max.getTime();
  9755. return afterMin && beforeMax;
  9756. }
  9757. /**
  9758. * Ensures date is within range,
  9759. * returns min or max if out of bounds
  9760. */
  9761. function dateFromRange(date, min, max) {
  9762. if (!(date instanceof Date)) {
  9763. return null;
  9764. }
  9765. const time = date.getTime();
  9766. const beforeMin = min instanceof Date && time < min.getTime();
  9767. const afterMax = max instanceof Date && time > max.getTime();
  9768. if (beforeMin) {
  9769. return min;
  9770. }
  9771. if (afterMax) {
  9772. return max;
  9773. }
  9774. return date;
  9775. }
  9776. /**
  9777. * Parse an iso8601 string (YYYY-mm-dd) into a valid date.
  9778. * TODO: handle time when time of day UI is added
  9779. */
  9780. function dateFromISO(iso8601) {
  9781. if (iso8601 instanceof Date) {
  9782. return iso8601;
  9783. }
  9784. if (!iso8601 || typeof iso8601 !== "string") {
  9785. return null;
  9786. }
  9787. const d = iso8601.split(/[: T-]/).map(parseFloat);
  9788. const date = new Date(d[0], (d[1] || 1) - 1, d[2] || 1);
  9789. date.setFullYear(d[0]);
  9790. if (isNaN(date.getTime())) {
  9791. throw new Error(`Invalid ISO 8601 date: "${iso8601}"`);
  9792. }
  9793. return date;
  9794. }
  9795. /**
  9796. * Return first portion of ISO string (YYYY-mm-dd)
  9797. */
  9798. function dateToISO(date) {
  9799. if (typeof date === "string") {
  9800. return date;
  9801. }
  9802. if (date instanceof Date) {
  9803. return new Date(date.getTime() - date.getTimezoneOffset() * 60000).toISOString().split("T")[0];
  9804. }
  9805. return "";
  9806. }
  9807. /**
  9808. * Check if two dates are the same day, month, year
  9809. */
  9810. function sameDate(d1, d2) {
  9811. return (d1 instanceof Date &&
  9812. d2 instanceof Date &&
  9813. d1.getDate() === d2.getDate() &&
  9814. d1.getMonth() === d2.getMonth() &&
  9815. d1.getFullYear() === d2.getFullYear());
  9816. }
  9817. /**
  9818. * Get a date one month in the past
  9819. */
  9820. function prevMonth(date) {
  9821. const month = date.getMonth();
  9822. const nextDate = new Date(date);
  9823. nextDate.setMonth(month - 1);
  9824. // date doesn't exist in new month, use last day
  9825. if (month === nextDate.getMonth()) {
  9826. return new Date(date.getFullYear(), month, 0);
  9827. }
  9828. return nextDate;
  9829. }
  9830. /**
  9831. * Get a date one month in the future
  9832. */
  9833. function nextMonth(date) {
  9834. const month = date.getMonth();
  9835. const nextDate = new Date(date);
  9836. nextDate.setMonth(month + 1);
  9837. // date doesn't exist in new month, use last day
  9838. if ((month + 2) % 7 === nextDate.getMonth() % 7) {
  9839. return new Date(date.getFullYear(), month + 2, 0);
  9840. }
  9841. return nextDate;
  9842. }
  9843. /**
  9844. * Translate a number into a given locals numeral system
  9845. */
  9846. function localizeNumber(num, localeData) {
  9847. return String(num)
  9848. .split("")
  9849. .map((i) => localeData.numerals[i])
  9850. .join("");
  9851. }
  9852. /**
  9853. * Calculate actual number from localized string
  9854. */
  9855. function parseNumber(str, localeData) {
  9856. const numerals = "0123456789";
  9857. return parseInt(str
  9858. .split("")
  9859. .map((i) => numerals[localeData.numerals.indexOf(i)])
  9860. .filter((num) => num)
  9861. .join(""));
  9862. }
  9863. /**
  9864. * Parse numeric units for day, month, and year from a localized string
  9865. * month starts at 0 (can pass to date constructor)
  9866. */
  9867. function parseDateString(str, localeData) {
  9868. const { separator, unitOrder } = localeData;
  9869. const order = getOrder(unitOrder);
  9870. const values = replaceArabicNumerals(str).split(separator);
  9871. return {
  9872. day: parseInt(values[order.indexOf("d")]),
  9873. month: parseInt(values[order.indexOf("m")]) - 1,
  9874. year: parseInt(values[order.indexOf("y")])
  9875. };
  9876. }
  9877. /**
  9878. * Convert eastern arbic numerals
  9879. */
  9880. function replaceArabicNumerals(str = "") {
  9881. return str
  9882. .replace(/[\u0660-\u0669]/g, (c) => (c.charCodeAt(0) - 0x0660))
  9883. .replace(/[\u06f0-\u06f9]/g, (c) => (c.charCodeAt(0) - 0x06f0));
  9884. }
  9885. /**
  9886. * Based on the unitOrder string, find order of month, day, and year for locale
  9887. */
  9888. function getOrder(unitOrder) {
  9889. const signifiers = ["d", "m", "y"];
  9890. const order = unitOrder.toLowerCase();
  9891. return signifiers.sort((a, b) => order.indexOf(a) - order.indexOf(b));
  9892. }
  9893. /**
  9894. * Get number of days between two dates
  9895. */
  9896. function getDaysDiff(date1, date2) {
  9897. const ts1 = date1.getTime();
  9898. const ts2 = date2.getTime();
  9899. return (ts1 - ts2) / (1000 * 3600 * 24);
  9900. }
  9901. const HEADING_LEVEL$6 = 2;
  9902. const TEXT$f = {
  9903. nextMonth: "Next month",
  9904. prevMonth: "Previous month",
  9905. year: "Year"
  9906. };
  9907. 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}";
  9908. const DatePicker = class extends HTMLElement$1 {
  9909. constructor() {
  9910. super();
  9911. this.__registerHost();
  9912. this.__attachShadow();
  9913. this.calciteDatePickerChange = createEvent(this, "calciteDatePickerChange", 7);
  9914. this.calciteDatePickerRangeChange = createEvent(this, "calciteDatePickerRangeChange", 7);
  9915. /** Localized string for "previous month" (used for aria label)
  9916. * @default "Previous month"
  9917. */
  9918. this.intlPrevMonth = TEXT$f.prevMonth;
  9919. /** Localized string for "next month" (used for aria label)
  9920. * @default "Next month"
  9921. */
  9922. this.intlNextMonth = TEXT$f.nextMonth;
  9923. /** Localized string for "year" (used for aria label)
  9924. * @default "Year"
  9925. */
  9926. this.intlYear = TEXT$f.year;
  9927. /** BCP 47 language tag for desired language and country format */
  9928. this.locale = document.documentElement.lang || "en";
  9929. /** specify the scale of the date picker */
  9930. this.scale = "m";
  9931. /** Range mode activation */
  9932. this.range = false;
  9933. /** Disables the default behaviour on the third click of narrowing or extending the range and instead starts a new range. */
  9934. this.proximitySelectionDisabled = false;
  9935. //--------------------------------------------------------------------------
  9936. //
  9937. // Private Methods
  9938. //
  9939. //--------------------------------------------------------------------------
  9940. this.keyUpHandler = (e) => {
  9941. if (e.key === "Escape") {
  9942. this.reset();
  9943. }
  9944. };
  9945. this.monthHeaderSelectChange = (e) => {
  9946. const date = new Date(e.detail);
  9947. if (!this.range) {
  9948. this.activeDate = date;
  9949. }
  9950. else {
  9951. if (this.activeRange === "end") {
  9952. this.activeEndDate = date;
  9953. }
  9954. else {
  9955. this.activeStartDate = date;
  9956. }
  9957. this.mostRecentRangeValue = date;
  9958. }
  9959. };
  9960. this.monthActiveDateChange = (e) => {
  9961. const date = new Date(e.detail);
  9962. if (!this.range) {
  9963. this.activeDate = date;
  9964. }
  9965. else {
  9966. if (this.activeRange === "end") {
  9967. this.activeEndDate = date;
  9968. }
  9969. else {
  9970. this.activeStartDate = date;
  9971. }
  9972. this.mostRecentRangeValue = date;
  9973. }
  9974. };
  9975. this.monthHoverChange = (e) => {
  9976. if (!this.startAsDate) {
  9977. this.hoverRange = undefined;
  9978. return;
  9979. }
  9980. const date = new Date(e.detail);
  9981. this.hoverRange = {
  9982. focused: this.activeRange || "start",
  9983. start: this.startAsDate,
  9984. end: this.endAsDate
  9985. };
  9986. if (!this.proximitySelectionDisabled) {
  9987. if (this.endAsDate) {
  9988. const startDiff = getDaysDiff(date, this.startAsDate);
  9989. const endDiff = getDaysDiff(date, this.endAsDate);
  9990. if (endDiff > 0) {
  9991. this.hoverRange.end = date;
  9992. this.hoverRange.focused = "end";
  9993. }
  9994. else if (startDiff < 0) {
  9995. this.hoverRange.start = date;
  9996. this.hoverRange.focused = "start";
  9997. }
  9998. else if (startDiff > endDiff) {
  9999. this.hoverRange.start = date;
  10000. this.hoverRange.focused = "start";
  10001. }
  10002. else {
  10003. this.hoverRange.end = date;
  10004. this.hoverRange.focused = "end";
  10005. }
  10006. }
  10007. else {
  10008. if (date < this.startAsDate) {
  10009. this.hoverRange = {
  10010. focused: "start",
  10011. start: date,
  10012. end: this.startAsDate
  10013. };
  10014. }
  10015. else {
  10016. this.hoverRange.end = date;
  10017. this.hoverRange.focused = "end";
  10018. }
  10019. }
  10020. }
  10021. else {
  10022. if (!this.endAsDate) {
  10023. if (date < this.startAsDate) {
  10024. this.hoverRange = {
  10025. focused: "start",
  10026. start: date,
  10027. end: this.startAsDate
  10028. };
  10029. }
  10030. else {
  10031. this.hoverRange.end = date;
  10032. this.hoverRange.focused = "end";
  10033. }
  10034. }
  10035. else {
  10036. this.hoverRange = undefined;
  10037. }
  10038. }
  10039. };
  10040. this.monthMouseOutChange = () => {
  10041. if (this.hoverRange) {
  10042. this.hoverRange = undefined;
  10043. }
  10044. };
  10045. /**
  10046. * Reset active date and close
  10047. */
  10048. this.reset = () => {
  10049. var _a, _b, _c, _d, _e, _f;
  10050. if (!Array.isArray(this.valueAsDate) &&
  10051. this.valueAsDate &&
  10052. ((_a = this.valueAsDate) === null || _a === void 0 ? void 0 : _a.getTime()) !== ((_b = this.activeDate) === null || _b === void 0 ? void 0 : _b.getTime())) {
  10053. this.activeDate = new Date(this.valueAsDate);
  10054. }
  10055. 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())) {
  10056. this.activeStartDate = new Date(this.startAsDate);
  10057. }
  10058. 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())) {
  10059. this.activeEndDate = new Date(this.endAsDate);
  10060. }
  10061. };
  10062. /**
  10063. * Event handler for when the selected date changes
  10064. */
  10065. this.monthDateChange = (e) => {
  10066. const date = new Date(e.detail);
  10067. if (!this.range) {
  10068. this.value = date ? dateToISO(date) : "";
  10069. this.valueAsDate = date || null;
  10070. this.activeDate = date || null;
  10071. this.calciteDatePickerChange.emit(date);
  10072. return;
  10073. }
  10074. if (!this.startAsDate || (!this.endAsDate && date < this.startAsDate)) {
  10075. if (this.startAsDate) {
  10076. this.setEndDate(new Date(this.startAsDate));
  10077. }
  10078. if (this.activeRange == "end") {
  10079. this.setEndDate(date);
  10080. }
  10081. else {
  10082. this.setStartDate(date);
  10083. }
  10084. }
  10085. else if (!this.endAsDate) {
  10086. this.setEndDate(date);
  10087. }
  10088. else {
  10089. if (!this.proximitySelectionDisabled) {
  10090. if (this.activeRange) {
  10091. if (this.activeRange == "end") {
  10092. this.setEndDate(date);
  10093. }
  10094. else {
  10095. this.setStartDate(date);
  10096. }
  10097. }
  10098. else {
  10099. const startDiff = getDaysDiff(date, this.startAsDate);
  10100. const endDiff = getDaysDiff(date, this.endAsDate);
  10101. if (endDiff === 0 || startDiff < 0) {
  10102. this.setStartDate(date);
  10103. }
  10104. else if (startDiff === 0 || endDiff < 0) {
  10105. this.setEndDate(date);
  10106. }
  10107. else if (startDiff < endDiff) {
  10108. this.setStartDate(date);
  10109. }
  10110. else {
  10111. this.setEndDate(date);
  10112. }
  10113. }
  10114. }
  10115. else {
  10116. this.setStartDate(date);
  10117. this.endAsDate = this.activeEndDate = this.end = undefined;
  10118. }
  10119. }
  10120. this.calciteDatePickerChange.emit(date);
  10121. };
  10122. }
  10123. handleValueAsDate(date) {
  10124. if (!Array.isArray(date) && date && date !== this.activeDate) {
  10125. this.activeDate = date;
  10126. }
  10127. }
  10128. handleRangeChange() {
  10129. const { startAsDate: startDate, endAsDate: endDate } = this;
  10130. this.activeEndDate = endDate;
  10131. this.activeStartDate = startDate;
  10132. }
  10133. onMinChanged(min) {
  10134. if (min) {
  10135. this.minAsDate = dateFromISO(min);
  10136. }
  10137. }
  10138. onMaxChanged(max) {
  10139. if (max) {
  10140. this.maxAsDate = dateFromISO(max);
  10141. }
  10142. }
  10143. // --------------------------------------------------------------------------
  10144. //
  10145. // Lifecycle
  10146. //
  10147. // --------------------------------------------------------------------------
  10148. connectedCallback() {
  10149. if (Array.isArray(this.value)) {
  10150. this.valueAsDate = this.value.map((v) => dateFromISO(v));
  10151. this.start = this.value[0];
  10152. this.end = this.value[1];
  10153. }
  10154. else if (this.value) {
  10155. this.valueAsDate = dateFromISO(this.value);
  10156. }
  10157. if (this.start) {
  10158. this.setStartAsDate(dateFromISO(this.start));
  10159. }
  10160. if (this.end) {
  10161. this.setEndAsDate(dateFromISO(this.end));
  10162. }
  10163. if (this.min) {
  10164. this.minAsDate = dateFromISO(this.min);
  10165. }
  10166. if (this.max) {
  10167. this.maxAsDate = dateFromISO(this.max);
  10168. }
  10169. }
  10170. async componentWillLoad() {
  10171. await this.loadLocaleData();
  10172. this.onMinChanged(this.min);
  10173. this.onMaxChanged(this.max);
  10174. }
  10175. render() {
  10176. var _a;
  10177. const date = dateFromRange(this.range ? this.startAsDate : this.valueAsDate, this.minAsDate, this.maxAsDate);
  10178. const activeStartDate = this.range
  10179. ? this.getActiveStartDate(date, this.minAsDate, this.maxAsDate)
  10180. : this.getActiveDate(date, this.minAsDate, this.maxAsDate);
  10181. let activeDate = activeStartDate;
  10182. const endDate = this.range
  10183. ? dateFromRange(this.endAsDate, this.minAsDate, this.maxAsDate)
  10184. : null;
  10185. const activeEndDate = this.getActiveEndDate(endDate, this.minAsDate, this.maxAsDate);
  10186. if ((this.activeRange === "end" ||
  10187. (((_a = this.hoverRange) === null || _a === void 0 ? void 0 : _a.focused) === "end" && (!this.proximitySelectionDisabled || endDate))) &&
  10188. activeEndDate) {
  10189. activeDate = activeEndDate;
  10190. }
  10191. if (this.range && this.mostRecentRangeValue) {
  10192. activeDate = this.mostRecentRangeValue;
  10193. }
  10194. const minDate = this.range && this.activeRange
  10195. ? this.activeRange === "start"
  10196. ? this.minAsDate
  10197. : date || this.minAsDate
  10198. : this.minAsDate;
  10199. const maxDate = this.range && this.activeRange
  10200. ? this.activeRange === "start"
  10201. ? endDate || this.maxAsDate
  10202. : this.maxAsDate
  10203. : this.maxAsDate;
  10204. return (h(Host, { onBlur: this.reset, onKeyUp: this.keyUpHandler, role: "application" }, this.renderCalendar(activeDate, maxDate, minDate, date, endDate)));
  10205. }
  10206. valueHandler(value) {
  10207. if (Array.isArray(value)) {
  10208. this.valueAsDate = value.map((v) => dateFromISO(v));
  10209. this.start = value[0];
  10210. this.end = value[1];
  10211. }
  10212. else if (value) {
  10213. this.valueAsDate = dateFromISO(value);
  10214. this.start = "";
  10215. this.end = "";
  10216. }
  10217. }
  10218. startWatcher(start) {
  10219. this.setStartAsDate(dateFromISO(start));
  10220. }
  10221. endWatcher(end) {
  10222. this.setEndAsDate(dateFromISO(end));
  10223. }
  10224. async loadLocaleData() {
  10225. if (!Build.isBrowser) {
  10226. return;
  10227. }
  10228. const { locale } = this;
  10229. this.localeData = await getLocaleData(locale);
  10230. }
  10231. /**
  10232. * Render calcite-date-picker-month-header and calcite-date-picker-month
  10233. */
  10234. renderCalendar(activeDate, maxDate, minDate, date, endDate) {
  10235. return (this.localeData && [
  10236. 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() }),
  10237. 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 })
  10238. ]);
  10239. }
  10240. /**
  10241. * Update date instance of start if valid
  10242. */
  10243. setStartAsDate(startDate, emit) {
  10244. this.startAsDate = startDate;
  10245. this.mostRecentRangeValue = this.startAsDate;
  10246. if (emit) {
  10247. this.calciteDatePickerRangeChange.emit({
  10248. startDate,
  10249. endDate: this.endAsDate
  10250. });
  10251. }
  10252. }
  10253. /**
  10254. * Update date instance of end if valid
  10255. */
  10256. setEndAsDate(endDate, emit) {
  10257. this.endAsDate = endDate;
  10258. this.mostRecentRangeValue = this.endAsDate;
  10259. if (emit) {
  10260. this.calciteDatePickerRangeChange.emit({
  10261. startDate: this.startAsDate,
  10262. endDate
  10263. });
  10264. }
  10265. }
  10266. setEndDate(date) {
  10267. this.end = date ? dateToISO(date) : "";
  10268. this.setEndAsDate(date, true);
  10269. this.activeEndDate = date || null;
  10270. }
  10271. setStartDate(date) {
  10272. this.start = date ? dateToISO(date) : "";
  10273. this.setStartAsDate(date, true);
  10274. this.activeStartDate = date || null;
  10275. }
  10276. /**
  10277. * Get an active date using the value, or current date as default
  10278. */
  10279. getActiveDate(value, min, max) {
  10280. return dateFromRange(this.activeDate, min, max) || value || dateFromRange(new Date(), min, max);
  10281. }
  10282. getActiveStartDate(value, min, max) {
  10283. return (dateFromRange(this.activeStartDate, min, max) || value || dateFromRange(new Date(), min, max));
  10284. }
  10285. getActiveEndDate(value, min, max) {
  10286. return (dateFromRange(this.activeEndDate, min, max) || value || dateFromRange(new Date(), min, max));
  10287. }
  10288. static get assetsDirs() { return ["assets"]; }
  10289. get el() { return this; }
  10290. static get watchers() { return {
  10291. "valueAsDate": ["handleValueAsDate"],
  10292. "startAsDate": ["handleRangeChange"],
  10293. "endAsDate": ["handleRangeChange"],
  10294. "min": ["onMinChanged"],
  10295. "max": ["onMaxChanged"],
  10296. "value": ["valueHandler"],
  10297. "start": ["startWatcher"],
  10298. "end": ["endWatcher"],
  10299. "locale": ["loadLocaleData"]
  10300. }; }
  10301. static get style() { return datePickerCss; }
  10302. };
  10303. 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}}";
  10304. const DatePickerDay = class extends HTMLElement$1 {
  10305. constructor() {
  10306. super();
  10307. this.__registerHost();
  10308. this.__attachShadow();
  10309. this.calciteDaySelect = createEvent(this, "calciteDaySelect", 7);
  10310. this.calciteDayHover = createEvent(this, "calciteDayHover", 7);
  10311. /** Date is outside of range and can't be selected */
  10312. this.disabled = false;
  10313. /** Date is in the current month. */
  10314. this.currentMonth = false;
  10315. /** Date is the current selected date of the picker */
  10316. this.selected = false;
  10317. /** Date is currently highlighted as part of the range */
  10318. this.highlighted = false;
  10319. /** Showing date range */
  10320. this.range = false;
  10321. /** Date is the start of date range */
  10322. this.startOfRange = false;
  10323. /** Date is the end of date range */
  10324. this.endOfRange = false;
  10325. /** Date is being hovered and within the set range */
  10326. this.rangeHover = false;
  10327. /** Date is actively in focus for keyboard navigation */
  10328. this.active = false;
  10329. //--------------------------------------------------------------------------
  10330. //
  10331. // Event Listeners
  10332. //
  10333. //--------------------------------------------------------------------------
  10334. this.onClick = () => {
  10335. !this.disabled && this.calciteDaySelect.emit();
  10336. };
  10337. this.keyDownHandler = (e) => {
  10338. const key = e.key;
  10339. if (key === " " || key === "Enter") {
  10340. !this.disabled && this.calciteDaySelect.emit();
  10341. }
  10342. };
  10343. }
  10344. mouseoverHandler() {
  10345. this.calciteDayHover.emit({
  10346. disabled: this.disabled
  10347. });
  10348. }
  10349. //--------------------------------------------------------------------------
  10350. //
  10351. // Lifecycle
  10352. //
  10353. //--------------------------------------------------------------------------
  10354. render() {
  10355. const formattedDay = String(this.day)
  10356. .split("")
  10357. .map((i) => this.localeData.numerals[i])
  10358. .join("");
  10359. const dir = getElementDir(this.el);
  10360. 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))))));
  10361. }
  10362. componentDidRender() {
  10363. updateHostInteraction(this, this.isTabbable);
  10364. }
  10365. isTabbable() {
  10366. return this.active;
  10367. }
  10368. get el() { return this; }
  10369. static get style() { return datePickerDayCss; }
  10370. };
  10371. 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}";
  10372. const DatePickerMonth = class extends HTMLElement$1 {
  10373. constructor() {
  10374. super();
  10375. this.__registerHost();
  10376. this.__attachShadow();
  10377. this.calciteDatePickerSelect = createEvent(this, "calciteDatePickerSelect", 7);
  10378. this.calciteDatePickerHover = createEvent(this, "calciteDatePickerHover", 7);
  10379. this.calciteDatePickerActiveDateChange = createEvent(this, "calciteDatePickerActiveDateChange", 7);
  10380. this.calciteDatePickerMouseOut = createEvent(this, "calciteDatePickerMouseOut", 7);
  10381. /** Date currently active.*/
  10382. this.activeDate = new Date();
  10383. //--------------------------------------------------------------------------
  10384. //
  10385. // Event Listeners
  10386. //
  10387. //--------------------------------------------------------------------------
  10388. this.keyDownHandler = (e) => {
  10389. const isRTL = this.el.dir === "rtl";
  10390. switch (e.key) {
  10391. case "ArrowUp":
  10392. e.preventDefault();
  10393. this.addDays(-7);
  10394. break;
  10395. case "ArrowRight":
  10396. e.preventDefault();
  10397. this.addDays(isRTL ? -1 : 1);
  10398. break;
  10399. case "ArrowDown":
  10400. e.preventDefault();
  10401. this.addDays(7);
  10402. break;
  10403. case "ArrowLeft":
  10404. e.preventDefault();
  10405. this.addDays(isRTL ? 1 : -1);
  10406. break;
  10407. case "PageUp":
  10408. e.preventDefault();
  10409. this.addMonths(-1);
  10410. break;
  10411. case "PageDown":
  10412. e.preventDefault();
  10413. this.addMonths(1);
  10414. break;
  10415. case "Home":
  10416. e.preventDefault();
  10417. this.activeDate.setDate(1);
  10418. this.addDays();
  10419. break;
  10420. case "End":
  10421. e.preventDefault();
  10422. this.activeDate.setDate(new Date(this.activeDate.getFullYear(), this.activeDate.getMonth() + 1, 0).getDate());
  10423. this.addDays();
  10424. break;
  10425. case "Enter":
  10426. case " ":
  10427. e.preventDefault();
  10428. break;
  10429. case "Tab":
  10430. this.activeFocus = false;
  10431. }
  10432. };
  10433. /**
  10434. * Once user is not interacting via keyboard,
  10435. * disable auto focusing of active date
  10436. */
  10437. this.disableActiveFocus = () => {
  10438. this.activeFocus = false;
  10439. };
  10440. this.dayHover = (e) => {
  10441. const target = e.target;
  10442. if (e.detail.disabled) {
  10443. this.calciteDatePickerMouseOut.emit();
  10444. }
  10445. else {
  10446. this.calciteDatePickerHover.emit(target.value);
  10447. }
  10448. };
  10449. this.daySelect = (e) => {
  10450. const target = e.target;
  10451. this.calciteDatePickerSelect.emit(target.value);
  10452. };
  10453. }
  10454. mouseoutHandler() {
  10455. this.calciteDatePickerMouseOut.emit();
  10456. }
  10457. //--------------------------------------------------------------------------
  10458. //
  10459. // Lifecycle
  10460. //
  10461. //--------------------------------------------------------------------------
  10462. render() {
  10463. const month = this.activeDate.getMonth();
  10464. const year = this.activeDate.getFullYear();
  10465. const startOfWeek = this.localeData.weekStart % 7;
  10466. const { abbreviated, short, narrow } = this.localeData.days;
  10467. const weekDays = this.scale === "s" ? narrow || short || abbreviated : short || abbreviated || narrow;
  10468. const adjustedWeekDays = [...weekDays.slice(startOfWeek, 7), ...weekDays.slice(0, startOfWeek)];
  10469. const curMonDays = this.getCurrentMonthDays(month, year);
  10470. const prevMonDays = this.getPrevMonthdays(month, year, startOfWeek);
  10471. const nextMonDays = this.getNextMonthDays(month, year, startOfWeek);
  10472. const days = [
  10473. ...prevMonDays.map((day) => {
  10474. const date = new Date(year, month - 1, day);
  10475. return this.renderDateDay(false, day, date);
  10476. }),
  10477. ...curMonDays.map((day) => {
  10478. const date = new Date(year, month, day);
  10479. const active = sameDate(date, this.activeDate);
  10480. return this.renderDateDay(active, day, date, true, true);
  10481. }),
  10482. ...nextMonDays.map((day) => {
  10483. const date = new Date(year, month + 1, day);
  10484. return this.renderDateDay(false, day, date);
  10485. })
  10486. ];
  10487. const weeks = [];
  10488. for (let i = 0; i < days.length; i += 7) {
  10489. weeks.push(days.slice(i, i + 7));
  10490. }
  10491. 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))))));
  10492. }
  10493. //--------------------------------------------------------------------------
  10494. //
  10495. // Private Methods
  10496. //
  10497. //--------------------------------------------------------------------------
  10498. /**
  10499. * Add n months to the current month
  10500. */
  10501. addMonths(step) {
  10502. const nextDate = new Date(this.activeDate);
  10503. nextDate.setMonth(this.activeDate.getMonth() + step);
  10504. this.calciteDatePickerActiveDateChange.emit(dateFromRange(nextDate, this.min, this.max));
  10505. this.activeFocus = true;
  10506. }
  10507. /**
  10508. * Add n days to the current date
  10509. */
  10510. addDays(step = 0) {
  10511. const nextDate = new Date(this.activeDate);
  10512. nextDate.setDate(this.activeDate.getDate() + step);
  10513. this.calciteDatePickerActiveDateChange.emit(dateFromRange(nextDate, this.min, this.max));
  10514. this.activeFocus = true;
  10515. }
  10516. /**
  10517. * Get dates for last days of the previous month
  10518. */
  10519. getPrevMonthdays(month, year, startOfWeek) {
  10520. const lastDate = new Date(year, month, 0);
  10521. const date = lastDate.getDate();
  10522. const day = lastDate.getDay();
  10523. const days = [];
  10524. if (day - 6 === startOfWeek) {
  10525. return days;
  10526. }
  10527. for (let i = Math.abs(lastDate.getDay() - startOfWeek); i >= 0; i--) {
  10528. days.push(date - i);
  10529. }
  10530. return days;
  10531. }
  10532. /**
  10533. * Get dates for the current month
  10534. */
  10535. getCurrentMonthDays(month, year) {
  10536. const num = new Date(year, month + 1, 0).getDate();
  10537. const days = [];
  10538. for (let i = 0; i < num; i++) {
  10539. days.push(i + 1);
  10540. }
  10541. return days;
  10542. }
  10543. /**
  10544. * Get dates for first days of the next month
  10545. */
  10546. getNextMonthDays(month, year, startOfWeek) {
  10547. const endDay = new Date(year, month + 1, 0).getDay();
  10548. const days = [];
  10549. if (endDay === (startOfWeek + 6) % 7) {
  10550. return days;
  10551. }
  10552. for (let i = 0; i < (6 - (endDay - startOfWeek)) % 7; i++) {
  10553. days.push(i + 1);
  10554. }
  10555. return days;
  10556. }
  10557. /**
  10558. * Determine if the date is in between the start and end dates
  10559. */
  10560. betweenSelectedRange(date) {
  10561. return !!(this.startDate &&
  10562. this.endDate &&
  10563. date > this.startDate &&
  10564. date < this.endDate &&
  10565. !this.isRangeHover(date));
  10566. }
  10567. /**
  10568. * Determine if the date should be in selected state
  10569. */
  10570. isSelected(date) {
  10571. return !!(sameDate(date, this.selectedDate) ||
  10572. (this.startDate && sameDate(date, this.startDate)) ||
  10573. (this.endDate && sameDate(date, this.endDate)));
  10574. }
  10575. /**
  10576. * Determine if the date is the start of the date range
  10577. */
  10578. isStartOfRange(date) {
  10579. return !!(this.startDate &&
  10580. !sameDate(this.startDate, this.endDate) &&
  10581. sameDate(this.startDate, date) &&
  10582. !this.isEndOfRange(date));
  10583. }
  10584. isEndOfRange(date) {
  10585. return !!((this.endDate && !sameDate(this.startDate, this.endDate) && sameDate(this.endDate, date)) ||
  10586. (!this.endDate &&
  10587. this.hoverRange &&
  10588. sameDate(this.startDate, this.hoverRange.end) &&
  10589. sameDate(date, this.hoverRange.end)));
  10590. }
  10591. /**
  10592. * Render calcite-date-picker-day
  10593. */
  10594. renderDateDay(active, day, date, currentMonth, ref) {
  10595. var _a;
  10596. const isFocusedOnStart = this.isFocusedOnStart();
  10597. const isHoverInRange = this.isHoverInRange() ||
  10598. (!this.endDate && this.hoverRange && sameDate((_a = this.hoverRange) === null || _a === void 0 ? void 0 : _a.end, this.startDate));
  10599. return (h("calcite-date-picker-day", { active: active, class: {
  10600. "hover--inside-range": this.startDate && isHoverInRange,
  10601. "hover--outside-range": this.startDate && !isHoverInRange,
  10602. "focused--start": isFocusedOnStart,
  10603. "focused--end": !isFocusedOnStart
  10604. }, 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) => {
  10605. // when moving via keyboard, focus must be updated on active date
  10606. if (ref && active && this.activeFocus) {
  10607. el === null || el === void 0 ? void 0 : el.focus();
  10608. }
  10609. }, scale: this.scale, selected: this.isSelected(date), startOfRange: this.isStartOfRange(date), value: date }));
  10610. }
  10611. isFocusedOnStart() {
  10612. var _a;
  10613. return ((_a = this.hoverRange) === null || _a === void 0 ? void 0 : _a.focused) === "start";
  10614. }
  10615. isHoverInRange() {
  10616. if (!this.hoverRange) {
  10617. return false;
  10618. }
  10619. const { start, end } = this.hoverRange;
  10620. return !!((!this.isFocusedOnStart() && this.startDate && (!this.endDate || end < this.endDate)) ||
  10621. (this.isFocusedOnStart() && this.startDate && start > this.startDate));
  10622. }
  10623. isRangeHover(date) {
  10624. if (!this.hoverRange) {
  10625. return false;
  10626. }
  10627. const { start, end } = this.hoverRange;
  10628. const isStart = this.isFocusedOnStart();
  10629. const insideRange = this.isHoverInRange();
  10630. const cond1 = insideRange &&
  10631. ((!isStart && date > this.startDate && (date < end || sameDate(date, end))) ||
  10632. (isStart && date < this.endDate && (date > start || sameDate(date, start))));
  10633. const cond2 = !insideRange &&
  10634. ((!isStart && date >= this.endDate && (date < end || sameDate(date, end))) ||
  10635. (isStart &&
  10636. (date < this.startDate || (this.endDate && sameDate(date, this.startDate))) &&
  10637. (date > start || sameDate(date, start))));
  10638. return cond1 || cond2;
  10639. }
  10640. get el() { return this; }
  10641. static get style() { return datePickerMonthCss; }
  10642. };
  10643. 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}";
  10644. const DatePickerMonthHeader = class extends HTMLElement$1 {
  10645. constructor() {
  10646. super();
  10647. this.__registerHost();
  10648. this.__attachShadow();
  10649. this.calciteDatePickerSelect = createEvent(this, "calciteDatePickerSelect", 7);
  10650. //--------------------------------------------------------------------------
  10651. //
  10652. // Private Methods
  10653. //
  10654. //--------------------------------------------------------------------------
  10655. /**
  10656. * Increment year on UP/DOWN keys
  10657. */
  10658. this.onYearKey = (e) => {
  10659. const localizedYear = e.target.value;
  10660. switch (e.key) {
  10661. case "ArrowDown":
  10662. e.preventDefault();
  10663. this.setYear({ localizedYear, offset: -1 });
  10664. break;
  10665. case "ArrowUp":
  10666. e.preventDefault();
  10667. this.setYear({ localizedYear, offset: 1 });
  10668. break;
  10669. }
  10670. };
  10671. this.onYearChange = (event) => {
  10672. this.setYear({ localizedYear: event.target.value });
  10673. };
  10674. this.onYearInput = (event) => {
  10675. this.setYear({ localizedYear: event.target.value, commit: false });
  10676. };
  10677. this.prevMonthClick = (e) => {
  10678. this.handleArrowClick(e, this.prevMonthDate);
  10679. };
  10680. this.prevMonthKeydown = (e) => {
  10681. const key = e.key;
  10682. if (key === " " || key === "Enter") {
  10683. this.prevMonthClick(e);
  10684. }
  10685. };
  10686. this.nextMonthClick = (e) => {
  10687. this.handleArrowClick(e, this.nextMonthDate);
  10688. };
  10689. this.nextMonthKeydown = (e) => {
  10690. const key = e.key;
  10691. if (key === " " || key === "Enter") {
  10692. this.nextMonthClick(e);
  10693. }
  10694. };
  10695. /*
  10696. * Update active month on clicks of left/right arrows
  10697. */
  10698. this.handleArrowClick = (e, date) => {
  10699. e === null || e === void 0 ? void 0 : e.preventDefault();
  10700. e.stopPropagation();
  10701. this.calciteDatePickerSelect.emit(date);
  10702. };
  10703. }
  10704. //--------------------------------------------------------------------------
  10705. //
  10706. // Lifecycle
  10707. //
  10708. //--------------------------------------------------------------------------
  10709. connectedCallback() {
  10710. this.setNextPrevMonthDates();
  10711. }
  10712. render() {
  10713. return h("div", { class: "header" }, this.renderContent());
  10714. }
  10715. renderContent() {
  10716. var _a;
  10717. if (!this.activeDate || !this.localeData) {
  10718. return null;
  10719. }
  10720. const activeMonth = this.activeDate.getMonth();
  10721. const { months, unitOrder } = this.localeData;
  10722. const localizedMonth = (months.wide || months.narrow || months.abbreviated)[activeMonth];
  10723. const localizedYear = localizeNumber(this.activeDate.getFullYear(), this.localeData);
  10724. const iconScale = this.scale === "l" ? "m" : "s";
  10725. const order = getOrder(unitOrder);
  10726. const reverse = order.indexOf("y") < order.indexOf("m");
  10727. const suffix = (_a = this.localeData.year) === null || _a === void 0 ? void 0 : _a.suffix;
  10728. 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: {
  10729. year: true,
  10730. "year--suffix": !!suffix
  10731. }, 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 }))));
  10732. }
  10733. setNextPrevMonthDates() {
  10734. if (!this.activeDate) {
  10735. return;
  10736. }
  10737. this.nextMonthDate = dateFromRange(nextMonth(this.activeDate), this.min, this.max);
  10738. this.prevMonthDate = dateFromRange(prevMonth(this.activeDate), this.min, this.max);
  10739. }
  10740. getInRangeDate({ localizedYear, offset = 0 }) {
  10741. const { min, max, activeDate, localeData } = this;
  10742. const parsedYear = parseNumber(localizedYear, localeData);
  10743. const length = parsedYear.toString().length;
  10744. const year = isNaN(parsedYear) ? false : parsedYear + offset;
  10745. const inRange = year && (!min || min.getFullYear() <= year) && (!max || max.getFullYear() >= year);
  10746. // if you've supplied a year and it's in range
  10747. if (year && inRange && length === localizedYear.length) {
  10748. const nextDate = new Date(activeDate);
  10749. nextDate.setFullYear(year);
  10750. return dateFromRange(nextDate, min, max);
  10751. }
  10752. }
  10753. /**
  10754. * Parse localized year string from input,
  10755. * set to active if in range
  10756. */
  10757. setYear({ localizedYear, commit = true, offset = 0 }) {
  10758. const { yearInput, activeDate, localeData } = this;
  10759. const inRangeDate = this.getInRangeDate({ localizedYear, offset });
  10760. // if you've supplied a year and it's in range, update active date
  10761. if (inRangeDate) {
  10762. this.calciteDatePickerSelect.emit(inRangeDate);
  10763. }
  10764. if (commit) {
  10765. yearInput.value = localizeNumber((inRangeDate || activeDate).getFullYear(), localeData);
  10766. }
  10767. }
  10768. get el() { return this; }
  10769. static get watchers() { return {
  10770. "min": ["setNextPrevMonthDates"],
  10771. "max": ["setNextPrevMonthDates"],
  10772. "activeDate": ["setNextPrevMonthDates"]
  10773. }; }
  10774. static get style() { return datePickerMonthHeaderCss; }
  10775. };
  10776. const SLOTS$h = {
  10777. dropdownTrigger: "dropdown-trigger"
  10778. };
  10779. 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}";
  10780. const Dropdown = class extends HTMLElement$1 {
  10781. constructor() {
  10782. super();
  10783. this.__registerHost();
  10784. this.__attachShadow();
  10785. this.calciteDropdownSelect = createEvent(this, "calciteDropdownSelect", 7);
  10786. this.calciteDropdownOpen = createEvent(this, "calciteDropdownOpen", 7);
  10787. this.calciteDropdownClose = createEvent(this, "calciteDropdownClose", 7);
  10788. //--------------------------------------------------------------------------
  10789. //
  10790. // Public Properties
  10791. //
  10792. //--------------------------------------------------------------------------
  10793. /** Opens or closes the dropdown */
  10794. this.active = false;
  10795. /**
  10796. allow the dropdown to remain open after a selection is made
  10797. if the selection-mode of the selected item's containing group is "none", the dropdown will always close
  10798. */
  10799. this.disableCloseOnSelect = false;
  10800. /** is the dropdown disabled */
  10801. this.disabled = false;
  10802. /**
  10803. specify the maximum number of calcite-dropdown-items to display before showing the scroller, must be greater than 0 -
  10804. this value does not include groupTitles passed to calcite-dropdown-group
  10805. */
  10806. this.maxItems = 0;
  10807. /** Describes the type of positioning to use for the overlaid content. If your element is in a fixed container, use the 'fixed' value. */
  10808. this.overlayPositioning = "absolute";
  10809. /**
  10810. * Determines where the dropdown will be positioned relative to the button.
  10811. * @default "bottom-leading"
  10812. */
  10813. this.placement = defaultMenuPlacement;
  10814. /** specify the scale of dropdown, defaults to m */
  10815. this.scale = "m";
  10816. /**
  10817. * **read-only** The currently selected items
  10818. *
  10819. * @readonly
  10820. */
  10821. this.selectedItems = [];
  10822. /** specify whether the dropdown is opened by hover or click of a trigger element */
  10823. this.type = "click";
  10824. /** specify the width of dropdown, defaults to m */
  10825. this.width = "m";
  10826. this.items = [];
  10827. this.groups = [];
  10828. this.activeTransitionProp = "visibility";
  10829. this.mutationObserver = createObserver("mutation", () => this.updateItems());
  10830. this.resizeObserver = createObserver("resize", () => this.setMaxScrollerHeight());
  10831. //--------------------------------------------------------------------------
  10832. //
  10833. // Private Methods
  10834. //
  10835. //--------------------------------------------------------------------------
  10836. this.setFilteredPlacements = () => {
  10837. const { el, flipPlacements } = this;
  10838. this.filteredFlipPlacements = flipPlacements
  10839. ? filterComputedPlacements(flipPlacements, el)
  10840. : null;
  10841. };
  10842. this.updateTriggers = (event) => {
  10843. this.triggers = event.target.assignedElements({
  10844. flatten: true
  10845. });
  10846. this.reposition();
  10847. };
  10848. this.updateItems = () => {
  10849. this.items = this.groups
  10850. .map((group) => Array.from(group === null || group === void 0 ? void 0 : group.querySelectorAll("calcite-dropdown-item")))
  10851. .reduce((previousValue, currentValue) => [...previousValue, ...currentValue], []);
  10852. this.updateSelectedItems();
  10853. this.reposition();
  10854. };
  10855. this.updateGroups = (event) => {
  10856. const groups = event.target
  10857. .assignedElements({ flatten: true })
  10858. .filter((el) => el === null || el === void 0 ? void 0 : el.matches("calcite-dropdown-group"));
  10859. this.groups = groups;
  10860. this.updateItems();
  10861. };
  10862. this.setMaxScrollerHeight = () => {
  10863. const { active, scrollerEl } = this;
  10864. if (!scrollerEl || !active) {
  10865. return;
  10866. }
  10867. this.reposition();
  10868. const maxScrollerHeight = this.getMaxScrollerHeight();
  10869. scrollerEl.style.maxHeight = maxScrollerHeight > 0 ? `${maxScrollerHeight}px` : "";
  10870. this.reposition();
  10871. };
  10872. this.setScrollerEl = (scrollerEl) => {
  10873. this.resizeObserver.observe(scrollerEl);
  10874. this.scrollerEl = scrollerEl;
  10875. };
  10876. this.transitionEnd = (event) => {
  10877. if (event.propertyName === this.activeTransitionProp) {
  10878. this.active ? this.calciteDropdownOpen.emit() : this.calciteDropdownClose.emit();
  10879. }
  10880. };
  10881. this.setReferenceEl = (el) => {
  10882. this.referenceEl = el;
  10883. };
  10884. this.setMenuEl = (el) => {
  10885. this.menuEl = el;
  10886. };
  10887. this.keyDownHandler = (e) => {
  10888. const target = e.target;
  10889. if (target !== this.referenceEl) {
  10890. return;
  10891. }
  10892. const key = e.key;
  10893. if (this.active && (key === "Escape" || (e.shiftKey && key === "Tab"))) {
  10894. this.closeCalciteDropdown();
  10895. return;
  10896. }
  10897. switch (key) {
  10898. case " ":
  10899. case "Enter":
  10900. this.openCalciteDropdown();
  10901. break;
  10902. case "Escape":
  10903. this.closeCalciteDropdown();
  10904. break;
  10905. }
  10906. };
  10907. this.focusOnFirstActiveOrFirstItem = () => {
  10908. this.getFocusableElement(this.items.find((item) => item.active) || this.items[0]);
  10909. };
  10910. this.toggleOpenEnd = () => {
  10911. this.focusOnFirstActiveOrFirstItem();
  10912. this.el.removeEventListener("calciteDropdownOpen", this.toggleOpenEnd);
  10913. };
  10914. this.openCalciteDropdown = () => {
  10915. this.active = !this.active;
  10916. if (this.active) {
  10917. this.el.addEventListener("calciteDropdownOpen", this.toggleOpenEnd);
  10918. }
  10919. };
  10920. }
  10921. activeHandler() {
  10922. if (!this.disabled) {
  10923. this.reposition();
  10924. return;
  10925. }
  10926. this.active = false;
  10927. }
  10928. handleDisabledChange(value) {
  10929. if (!value) {
  10930. this.active = false;
  10931. }
  10932. }
  10933. flipPlacementsHandler() {
  10934. this.setFilteredPlacements();
  10935. }
  10936. maxItemsHandler() {
  10937. this.setMaxScrollerHeight();
  10938. }
  10939. placementHandler() {
  10940. this.reposition();
  10941. }
  10942. //--------------------------------------------------------------------------
  10943. //
  10944. // Lifecycle
  10945. //
  10946. //--------------------------------------------------------------------------
  10947. connectedCallback() {
  10948. var _a;
  10949. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
  10950. this.createPopper();
  10951. this.setFilteredPlacements();
  10952. }
  10953. componentDidLoad() {
  10954. this.reposition();
  10955. }
  10956. componentDidRender() {
  10957. updateHostInteraction(this);
  10958. }
  10959. disconnectedCallback() {
  10960. var _a, _b;
  10961. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  10962. (_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
  10963. this.destroyPopper();
  10964. }
  10965. render() {
  10966. const { active } = this;
  10967. 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: {
  10968. ["calcite-dropdown-content"]: true,
  10969. [CSS$D.animation]: true,
  10970. [CSS$D.animationActive]: active
  10971. }, onTransitionEnd: this.transitionEnd, ref: this.setScrollerEl }, h("div", { hidden: !this.active }, h("slot", { onSlotchange: this.updateGroups }))))));
  10972. }
  10973. //--------------------------------------------------------------------------
  10974. //
  10975. // Public Methods
  10976. //
  10977. //--------------------------------------------------------------------------
  10978. /** Updates the position of the component. */
  10979. async reposition() {
  10980. const { popper, menuEl, placement } = this;
  10981. const modifiers = this.getModifiers();
  10982. popper
  10983. ? await updatePopper({
  10984. el: menuEl,
  10985. modifiers,
  10986. placement,
  10987. popper
  10988. })
  10989. : this.createPopper();
  10990. }
  10991. closeCalciteDropdownOnClick(e) {
  10992. if (!this.active || e.composedPath().includes(this.el)) {
  10993. return;
  10994. }
  10995. this.closeCalciteDropdown(false);
  10996. }
  10997. closeCalciteDropdownOnEvent() {
  10998. this.closeCalciteDropdown();
  10999. }
  11000. closeCalciteDropdownOnOpenEvent(e) {
  11001. if (e.composedPath().includes(this.el)) {
  11002. return;
  11003. }
  11004. this.active = false;
  11005. }
  11006. mouseEnterHandler() {
  11007. if (this.type === "hover") {
  11008. this.openCalciteDropdown();
  11009. }
  11010. }
  11011. mouseLeaveHandler() {
  11012. if (this.type === "hover") {
  11013. this.closeCalciteDropdown();
  11014. }
  11015. }
  11016. calciteDropdownItemKeyEvent(e) {
  11017. const { keyboardEvent } = e.detail;
  11018. // handle edge
  11019. const target = keyboardEvent.target;
  11020. const itemToFocus = target.nodeName !== "A" ? target : target.parentNode;
  11021. const isFirstItem = this.itemIndex(itemToFocus) === 0;
  11022. const isLastItem = this.itemIndex(itemToFocus) === this.items.length - 1;
  11023. switch (keyboardEvent.key) {
  11024. case "Tab":
  11025. if (isLastItem && !keyboardEvent.shiftKey) {
  11026. this.closeCalciteDropdown();
  11027. }
  11028. else if (isFirstItem && keyboardEvent.shiftKey) {
  11029. this.closeCalciteDropdown();
  11030. }
  11031. else if (keyboardEvent.shiftKey) {
  11032. this.focusPrevItem(itemToFocus);
  11033. }
  11034. else {
  11035. this.focusNextItem(itemToFocus);
  11036. }
  11037. break;
  11038. case "ArrowDown":
  11039. this.focusNextItem(itemToFocus);
  11040. break;
  11041. case "ArrowUp":
  11042. this.focusPrevItem(itemToFocus);
  11043. break;
  11044. case "Home":
  11045. this.focusFirstItem();
  11046. break;
  11047. case "End":
  11048. this.focusLastItem();
  11049. break;
  11050. }
  11051. e.stopPropagation();
  11052. }
  11053. handleItemSelect(event) {
  11054. this.updateSelectedItems();
  11055. event.stopPropagation();
  11056. this.calciteDropdownSelect.emit();
  11057. if (!this.disableCloseOnSelect ||
  11058. event.detail.requestedDropdownGroup.selectionMode === "none") {
  11059. this.closeCalciteDropdown();
  11060. }
  11061. }
  11062. getModifiers() {
  11063. const flipModifier = {
  11064. name: "flip",
  11065. enabled: true
  11066. };
  11067. flipModifier.options = {
  11068. fallbackPlacements: this.filteredFlipPlacements || popperMenuComputedPlacements
  11069. };
  11070. const eventListenerModifier = {
  11071. name: "eventListeners",
  11072. enabled: this.active
  11073. };
  11074. return [flipModifier, eventListenerModifier];
  11075. }
  11076. createPopper() {
  11077. this.destroyPopper();
  11078. const { menuEl, referenceEl, placement, overlayPositioning } = this;
  11079. const modifiers = this.getModifiers();
  11080. this.popper = createPopper({
  11081. el: menuEl,
  11082. modifiers,
  11083. overlayPositioning,
  11084. placement,
  11085. referenceEl
  11086. });
  11087. }
  11088. destroyPopper() {
  11089. const { popper } = this;
  11090. if (popper) {
  11091. popper.destroy();
  11092. }
  11093. this.popper = null;
  11094. }
  11095. updateSelectedItems() {
  11096. this.selectedItems = this.items.filter((item) => item.active);
  11097. }
  11098. getMaxScrollerHeight() {
  11099. const { maxItems } = this;
  11100. let itemsToProcess = 0;
  11101. let maxScrollerHeight = 0;
  11102. let groupHeaderHeight;
  11103. this.groups.forEach((group) => {
  11104. if (maxItems > 0 && itemsToProcess < maxItems) {
  11105. Array.from(group.children).forEach((item, index) => {
  11106. if (index === 0) {
  11107. if (isNaN(groupHeaderHeight)) {
  11108. groupHeaderHeight = item.offsetTop;
  11109. }
  11110. maxScrollerHeight += groupHeaderHeight;
  11111. }
  11112. if (itemsToProcess < maxItems) {
  11113. maxScrollerHeight += item.offsetHeight;
  11114. itemsToProcess += 1;
  11115. }
  11116. });
  11117. }
  11118. });
  11119. return maxScrollerHeight;
  11120. }
  11121. closeCalciteDropdown(focusTrigger = true) {
  11122. this.active = false;
  11123. if (focusTrigger) {
  11124. focusElement(this.triggers[0]);
  11125. }
  11126. }
  11127. focusFirstItem() {
  11128. const firstItem = this.items[0];
  11129. this.getFocusableElement(firstItem);
  11130. }
  11131. focusLastItem() {
  11132. const lastItem = this.items[this.items.length - 1];
  11133. this.getFocusableElement(lastItem);
  11134. }
  11135. focusNextItem(e) {
  11136. const index = this.itemIndex(e);
  11137. const nextItem = this.items[index + 1] || this.items[0];
  11138. this.getFocusableElement(nextItem);
  11139. }
  11140. focusPrevItem(e) {
  11141. const index = this.itemIndex(e);
  11142. const prevItem = this.items[index - 1] || this.items[this.items.length - 1];
  11143. this.getFocusableElement(prevItem);
  11144. }
  11145. itemIndex(e) {
  11146. return this.items.indexOf(e);
  11147. }
  11148. getFocusableElement(item) {
  11149. if (!item) {
  11150. return;
  11151. }
  11152. const target = item.attributes.isLink
  11153. ? item.shadowRoot.querySelector("a")
  11154. : item;
  11155. focusElement(target);
  11156. }
  11157. get el() { return this; }
  11158. static get watchers() { return {
  11159. "active": ["activeHandler"],
  11160. "disabled": ["handleDisabledChange"],
  11161. "flipPlacements": ["flipPlacementsHandler"],
  11162. "maxItems": ["maxItemsHandler"],
  11163. "placement": ["placementHandler"]
  11164. }; }
  11165. static get style() { return dropdownCss; }
  11166. };
  11167. const CSS$A = {
  11168. containerSmall: "container--s",
  11169. containerMedium: "container--m",
  11170. containerLarge: "container--l"
  11171. };
  11172. 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)}";
  11173. const DropdownGroup = class extends HTMLElement$1 {
  11174. constructor() {
  11175. super();
  11176. this.__registerHost();
  11177. this.__attachShadow();
  11178. this.calciteDropdownItemChange = createEvent(this, "calciteDropdownItemChange", 7);
  11179. /** specify the selection mode - multi (allow any number of (or no) active items), single (allow and require one active item),
  11180. none (no active items), defaults to single */
  11181. this.selectionMode = "single";
  11182. }
  11183. //--------------------------------------------------------------------------
  11184. //
  11185. // Lifecycle
  11186. //
  11187. //--------------------------------------------------------------------------
  11188. componentWillLoad() {
  11189. this.groupPosition = this.getGroupPosition();
  11190. }
  11191. render() {
  11192. const scale = this.scale || getElementProp(this.el, "scale", "m");
  11193. const groupTitle = this.groupTitle ? (h("span", { "aria-hidden": "true", class: "dropdown-title" }, this.groupTitle)) : null;
  11194. const dropdownSeparator = this.groupPosition > 0 ? h("div", { class: "dropdown-separator", role: "separator" }) : null;
  11195. return (h(Host, { role: "menu" }, h("div", { class: {
  11196. container: true,
  11197. [CSS$A.containerSmall]: scale === "s",
  11198. [CSS$A.containerMedium]: scale === "m",
  11199. [CSS$A.containerLarge]: scale === "l"
  11200. }, title: this.groupTitle }, dropdownSeparator, groupTitle, h("slot", null))));
  11201. }
  11202. //--------------------------------------------------------------------------
  11203. //
  11204. // Event Listeners
  11205. //
  11206. //--------------------------------------------------------------------------
  11207. updateActiveItemOnChange(event) {
  11208. this.requestedDropdownGroup = event.detail.requestedDropdownGroup;
  11209. this.requestedDropdownItem = event.detail.requestedDropdownItem;
  11210. this.calciteDropdownItemChange.emit({
  11211. requestedDropdownGroup: this.requestedDropdownGroup,
  11212. requestedDropdownItem: this.requestedDropdownItem
  11213. });
  11214. }
  11215. //--------------------------------------------------------------------------
  11216. //
  11217. // Private Methods
  11218. //
  11219. //--------------------------------------------------------------------------
  11220. getGroupPosition() {
  11221. return Array.prototype.indexOf.call(this.el.parentElement.querySelectorAll("calcite-dropdown-group"), this.el);
  11222. }
  11223. get el() { return this; }
  11224. static get style() { return dropdownGroupCss; }
  11225. };
  11226. const CSS$z = {
  11227. containerLink: "container--link",
  11228. containerSmall: "container--s",
  11229. containerMedium: "container--m",
  11230. containerLarge: "container--l",
  11231. containerMulti: "container--multi-selection",
  11232. containerSingle: "container--single-selection",
  11233. containerNone: "container--none-selection"
  11234. };
  11235. 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}";
  11236. const DropdownItem = class extends HTMLElement$1 {
  11237. constructor() {
  11238. super();
  11239. this.__registerHost();
  11240. this.__attachShadow();
  11241. this.calciteDropdownItemSelect = createEvent(this, "calciteDropdownItemSelect", 7);
  11242. this.calciteDropdownItemKeyEvent = createEvent(this, "calciteDropdownItemKeyEvent", 7);
  11243. this.calciteDropdownCloseRequest = createEvent(this, "calciteDropdownCloseRequest", 7);
  11244. //--------------------------------------------------------------------------
  11245. //
  11246. // Public Properties
  11247. //
  11248. //--------------------------------------------------------------------------
  11249. /** Indicates whether the item is active. */
  11250. this.active = false;
  11251. }
  11252. //--------------------------------------------------------------------------
  11253. //
  11254. // Public Methods
  11255. //
  11256. //--------------------------------------------------------------------------
  11257. /** Sets focus on the component. */
  11258. async setFocus() {
  11259. this.el.focus();
  11260. }
  11261. //--------------------------------------------------------------------------
  11262. //
  11263. // Lifecycle
  11264. //
  11265. //--------------------------------------------------------------------------
  11266. componentWillLoad() {
  11267. this.initialize();
  11268. }
  11269. connectedCallback() {
  11270. this.initialize();
  11271. }
  11272. render() {
  11273. const scale = getElementProp(this.el, "scale", "m");
  11274. const iconStartEl = (h("calcite-icon", { class: "dropdown-item-icon-start", flipRtl: this.iconFlipRtl === "start" || this.iconFlipRtl === "both", icon: this.iconStart, scale: "s" }));
  11275. const contentNode = (h("span", { class: "dropdown-item-content" }, h("slot", null)));
  11276. const iconEndEl = (h("calcite-icon", { class: "dropdown-item-icon-end", flipRtl: this.iconFlipRtl === "end" || this.iconFlipRtl === "both", icon: this.iconEnd, scale: "s" }));
  11277. const slottedContent = this.iconStart && this.iconEnd
  11278. ? [iconStartEl, contentNode, iconEndEl]
  11279. : this.iconStart
  11280. ? [iconStartEl, h("slot", null)]
  11281. : this.iconEnd
  11282. ? [contentNode, iconEndEl]
  11283. : contentNode;
  11284. 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));
  11285. const itemRole = this.href
  11286. ? null
  11287. : this.selectionMode === "single"
  11288. ? "menuitemradio"
  11289. : this.selectionMode === "multi"
  11290. ? "menuitemcheckbox"
  11291. : "menuitem";
  11292. const itemAria = this.selectionMode !== "none" ? toAriaBoolean(this.active) : null;
  11293. return (h(Host, { "aria-checked": itemAria, role: itemRole, tabindex: "0" }, h("div", { class: {
  11294. container: true,
  11295. [CSS$z.containerLink]: !!this.href,
  11296. [CSS$z.containerSmall]: scale === "s",
  11297. [CSS$z.containerMedium]: scale === "m",
  11298. [CSS$z.containerLarge]: scale === "l",
  11299. [CSS$z.containerMulti]: this.selectionMode === "multi",
  11300. [CSS$z.containerSingle]: this.selectionMode === "single",
  11301. [CSS$z.containerNone]: this.selectionMode === "none"
  11302. } }, this.selectionMode !== "none" ? (h("calcite-icon", { class: "dropdown-item-icon", icon: this.selectionMode === "multi" ? "check" : "bullet-point", scale: "s" })) : null, contentEl)));
  11303. }
  11304. //--------------------------------------------------------------------------
  11305. //
  11306. // Event Listeners
  11307. //
  11308. //--------------------------------------------------------------------------
  11309. onClick() {
  11310. this.emitRequestedItem();
  11311. }
  11312. keyDownHandler(e) {
  11313. switch (e.key) {
  11314. case " ":
  11315. this.emitRequestedItem();
  11316. if (this.href) {
  11317. e.preventDefault();
  11318. this.childLink.click();
  11319. }
  11320. break;
  11321. case "Enter":
  11322. this.emitRequestedItem();
  11323. if (this.href) {
  11324. this.childLink.click();
  11325. }
  11326. break;
  11327. case "Escape":
  11328. this.calciteDropdownCloseRequest.emit();
  11329. break;
  11330. case "Tab":
  11331. case "ArrowUp":
  11332. case "ArrowDown":
  11333. case "Home":
  11334. case "End":
  11335. this.calciteDropdownItemKeyEvent.emit({ keyboardEvent: e });
  11336. break;
  11337. }
  11338. e.preventDefault();
  11339. }
  11340. updateActiveItemOnChange(event) {
  11341. const parentEmittedChange = event.composedPath().includes(this.parentDropdownGroupEl);
  11342. if (parentEmittedChange) {
  11343. this.requestedDropdownGroup = event.detail.requestedDropdownGroup;
  11344. this.requestedDropdownItem = event.detail.requestedDropdownItem;
  11345. this.determineActiveItem();
  11346. }
  11347. }
  11348. //--------------------------------------------------------------------------
  11349. //
  11350. // Private Methods
  11351. //
  11352. //--------------------------------------------------------------------------
  11353. initialize() {
  11354. this.selectionMode = getElementProp(this.el, "selection-mode", "single");
  11355. this.parentDropdownGroupEl = this.el.closest("calcite-dropdown-group");
  11356. if (this.selectionMode === "none") {
  11357. this.active = false;
  11358. }
  11359. }
  11360. determineActiveItem() {
  11361. switch (this.selectionMode) {
  11362. case "multi":
  11363. if (this.el === this.requestedDropdownItem) {
  11364. this.active = !this.active;
  11365. }
  11366. break;
  11367. case "single":
  11368. if (this.el === this.requestedDropdownItem) {
  11369. this.active = true;
  11370. }
  11371. else if (this.requestedDropdownGroup === this.parentDropdownGroupEl) {
  11372. this.active = false;
  11373. }
  11374. break;
  11375. case "none":
  11376. this.active = false;
  11377. break;
  11378. }
  11379. }
  11380. emitRequestedItem() {
  11381. this.calciteDropdownItemSelect.emit({
  11382. requestedDropdownItem: this.el,
  11383. requestedDropdownGroup: this.parentDropdownGroupEl
  11384. });
  11385. }
  11386. get el() { return this; }
  11387. static get style() { return dropdownItemCss; }
  11388. };
  11389. const CSS$y = {
  11390. button: "button"
  11391. };
  11392. const ICONS$9 = {
  11393. plus: "plus"
  11394. };
  11395. 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)}";
  11396. const Fab = class extends HTMLElement$1 {
  11397. constructor() {
  11398. super();
  11399. this.__registerHost();
  11400. this.__attachShadow();
  11401. // --------------------------------------------------------------------------
  11402. //
  11403. // Properties
  11404. //
  11405. // --------------------------------------------------------------------------
  11406. /**
  11407. * Used to set the button's appearance. Default is outline.
  11408. */
  11409. this.appearance = "outline";
  11410. /**
  11411. * Used to set the button's color. Default is light.
  11412. */
  11413. this.color = "neutral";
  11414. /**
  11415. * When true, disabled prevents interaction. This state shows items with lower opacity/grayed.
  11416. */
  11417. this.disabled = false;
  11418. /**
  11419. * 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/.
  11420. * @default "plus"
  11421. */
  11422. this.icon = ICONS$9.plus;
  11423. /**
  11424. * When true, content is waiting to be loaded. This state shows a busy indicator.
  11425. */
  11426. this.loading = false;
  11427. /**
  11428. * Specifies the size of the fab.
  11429. */
  11430. this.scale = "m";
  11431. /**
  11432. * Indicates whether the text is displayed.
  11433. */
  11434. this.textEnabled = false;
  11435. }
  11436. //--------------------------------------------------------------------------
  11437. //
  11438. // Lifecycle
  11439. //
  11440. //--------------------------------------------------------------------------
  11441. componentDidRender() {
  11442. updateHostInteraction(this);
  11443. }
  11444. // --------------------------------------------------------------------------
  11445. //
  11446. // Methods
  11447. //
  11448. // --------------------------------------------------------------------------
  11449. /** Sets focus on the component. */
  11450. async setFocus() {
  11451. focusElement(this.buttonEl);
  11452. }
  11453. // --------------------------------------------------------------------------
  11454. //
  11455. // Render Methods
  11456. //
  11457. // --------------------------------------------------------------------------
  11458. render() {
  11459. const { appearance, color, disabled, loading, scale, textEnabled, icon, label, text } = this;
  11460. const title = !textEnabled ? label || text || null : null;
  11461. 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) => {
  11462. this.buttonEl = buttonEl;
  11463. }, round: true, scale: scale, title: title, type: "button", width: "auto" }, this.textEnabled ? this.text : null));
  11464. }
  11465. get el() { return this; }
  11466. static get style() { return fabCss; }
  11467. };
  11468. const CSS$x = {
  11469. container: "container",
  11470. searchIcon: "search-icon"
  11471. };
  11472. const TEXT$e = {
  11473. filterLabel: "Filter",
  11474. clear: "Clear filter"
  11475. };
  11476. const ICONS$8 = {
  11477. search: "search",
  11478. close: "x"
  11479. };
  11480. const DEBOUNCE_TIMEOUT = 250;
  11481. 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)}";
  11482. const Filter = class extends HTMLElement$1 {
  11483. constructor() {
  11484. super();
  11485. this.__registerHost();
  11486. this.__attachShadow();
  11487. this.calciteFilterChange = createEvent(this, "calciteFilterChange", 7);
  11488. // --------------------------------------------------------------------------
  11489. //
  11490. // Properties
  11491. //
  11492. // --------------------------------------------------------------------------
  11493. /**
  11494. * The items to filter through. The filter uses this as the starting point, and returns items
  11495. * that contain the string entered in the input, using a partial match and recursive search.
  11496. *
  11497. * This property is required.
  11498. */
  11499. this.items = [];
  11500. /**
  11501. * When true, disabled prevents interaction. This state shows items with lower opacity/grayed.
  11502. */
  11503. this.disabled = false;
  11504. /**
  11505. * The resulting items after filtering.
  11506. *
  11507. * @readonly
  11508. */
  11509. this.filteredItems = [];
  11510. /** specify the scale of filter, defaults to m */
  11511. this.scale = "m";
  11512. /**
  11513. * Filter value.
  11514. */
  11515. this.value = "";
  11516. // --------------------------------------------------------------------------
  11517. //
  11518. // Private Methods
  11519. //
  11520. // --------------------------------------------------------------------------
  11521. this.filter = debounce$1((value, emit = false) => {
  11522. const regex = new RegExp(value, "i");
  11523. if (this.items.length === 0) {
  11524. this.updateFiltered([], emit);
  11525. return;
  11526. }
  11527. const find = (input, RE) => {
  11528. let found = false;
  11529. forIn(input, (val) => {
  11530. if (typeof val === "function" || val == null /* intentional == to catch undefined */) {
  11531. return;
  11532. }
  11533. if (Array.isArray(val) || (typeof val === "object" && val !== null)) {
  11534. if (find(val, RE)) {
  11535. found = true;
  11536. }
  11537. }
  11538. else if (RE.test(val)) {
  11539. found = true;
  11540. }
  11541. });
  11542. return found;
  11543. };
  11544. const result = this.items.filter((item) => {
  11545. return find(item, regex);
  11546. });
  11547. this.updateFiltered(result, emit);
  11548. }, DEBOUNCE_TIMEOUT);
  11549. this.inputHandler = (event) => {
  11550. const target = event.target;
  11551. this.value = target.value;
  11552. this.filter(target.value, true);
  11553. };
  11554. this.keyDownHandler = (event) => {
  11555. if (event.key === "Escape") {
  11556. this.clear();
  11557. }
  11558. if (event.key === "Enter") {
  11559. event.preventDefault();
  11560. }
  11561. };
  11562. this.clear = () => {
  11563. this.value = "";
  11564. this.filter("", true);
  11565. this.setFocus();
  11566. };
  11567. }
  11568. watchItemsHandler() {
  11569. this.filter(this.value);
  11570. }
  11571. valueHandler(value) {
  11572. this.filter(value);
  11573. }
  11574. //--------------------------------------------------------------------------
  11575. //
  11576. // Lifecycle
  11577. //
  11578. //--------------------------------------------------------------------------
  11579. componentDidRender() {
  11580. updateHostInteraction(this);
  11581. }
  11582. //--------------------------------------------------------------------------
  11583. //
  11584. // Lifecycle
  11585. //
  11586. //--------------------------------------------------------------------------
  11587. componentWillLoad() {
  11588. this.filter(this.value);
  11589. }
  11590. // --------------------------------------------------------------------------
  11591. //
  11592. // Public Methods
  11593. //
  11594. // --------------------------------------------------------------------------
  11595. /** Sets focus on the component. */
  11596. async setFocus() {
  11597. focusElement(this.textInput);
  11598. }
  11599. updateFiltered(filtered, emit = false) {
  11600. this.filteredItems.length = 0;
  11601. this.filteredItems = this.filteredItems.concat(filtered);
  11602. if (emit) {
  11603. this.calciteFilterChange.emit();
  11604. }
  11605. }
  11606. // --------------------------------------------------------------------------
  11607. //
  11608. // Render Methods
  11609. //
  11610. // --------------------------------------------------------------------------
  11611. render() {
  11612. const { disabled, scale } = this;
  11613. 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) => {
  11614. this.textInput = el;
  11615. }, scale: scale, type: "text", value: this.value })))));
  11616. }
  11617. get el() { return this; }
  11618. static get watchers() { return {
  11619. "items": ["watchItemsHandler"],
  11620. "value": ["valueHandler"]
  11621. }; }
  11622. static get style() { return filterCss; }
  11623. };
  11624. const CSS$w = {
  11625. frame: "frame",
  11626. frameAdvancing: "frame--advancing",
  11627. frameRetreating: "frame--retreating"
  11628. };
  11629. 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)}}";
  11630. const Flow = class extends HTMLElement$1 {
  11631. constructor() {
  11632. super();
  11633. this.__registerHost();
  11634. this.__attachShadow();
  11635. this.panelCount = 0;
  11636. this.flowDirection = null;
  11637. this.panels = [];
  11638. this.getFlowDirection = (oldPanelCount, newPanelCount) => {
  11639. const allowRetreatingDirection = oldPanelCount > 1;
  11640. const allowAdvancingDirection = oldPanelCount && newPanelCount > 1;
  11641. if (!allowAdvancingDirection && !allowRetreatingDirection) {
  11642. return null;
  11643. }
  11644. return newPanelCount < oldPanelCount ? "retreating" : "advancing";
  11645. };
  11646. this.updateFlowProps = () => {
  11647. const { panels } = this;
  11648. const newPanels = Array.from(this.el.querySelectorAll("calcite-panel"));
  11649. const oldPanelCount = panels.length;
  11650. const newPanelCount = newPanels.length;
  11651. const activePanel = newPanels[newPanelCount - 1];
  11652. const previousPanel = newPanels[newPanelCount - 2];
  11653. if (newPanelCount && activePanel) {
  11654. newPanels.forEach((panelNode) => {
  11655. panelNode.showBackButton = newPanelCount > 1;
  11656. panelNode.hidden = panelNode !== activePanel;
  11657. });
  11658. }
  11659. if (previousPanel) {
  11660. previousPanel.menuOpen = false;
  11661. }
  11662. this.panels = newPanels;
  11663. if (oldPanelCount !== newPanelCount) {
  11664. const flowDirection = this.getFlowDirection(oldPanelCount, newPanelCount);
  11665. this.panelCount = newPanelCount;
  11666. this.flowDirection = flowDirection;
  11667. }
  11668. };
  11669. this.panelItemMutationObserver = createObserver("mutation", this.updateFlowProps);
  11670. }
  11671. // --------------------------------------------------------------------------
  11672. //
  11673. // Public Methods
  11674. //
  11675. // --------------------------------------------------------------------------
  11676. /**
  11677. * Removes the currently active `calcite-panel`.
  11678. */
  11679. async back() {
  11680. const lastItem = this.el.querySelector("calcite-panel:last-child");
  11681. if (!lastItem) {
  11682. return;
  11683. }
  11684. const beforeBack = lastItem.beforeBack
  11685. ? lastItem.beforeBack
  11686. : () => Promise.resolve();
  11687. return beforeBack.call(lastItem).then(() => {
  11688. lastItem.remove();
  11689. return lastItem;
  11690. });
  11691. }
  11692. // --------------------------------------------------------------------------
  11693. //
  11694. // Lifecycle
  11695. //
  11696. // --------------------------------------------------------------------------
  11697. connectedCallback() {
  11698. var _a;
  11699. (_a = this.panelItemMutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
  11700. this.updateFlowProps();
  11701. }
  11702. disconnectedCallback() {
  11703. var _a;
  11704. (_a = this.panelItemMutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  11705. }
  11706. // --------------------------------------------------------------------------
  11707. //
  11708. // Private Methods
  11709. //
  11710. // --------------------------------------------------------------------------
  11711. handleCalcitePanelBackClick() {
  11712. this.back();
  11713. }
  11714. // --------------------------------------------------------------------------
  11715. //
  11716. // Render Methods
  11717. //
  11718. // --------------------------------------------------------------------------
  11719. render() {
  11720. const { flowDirection, panelCount } = this;
  11721. const frameDirectionClasses = {
  11722. [CSS$w.frame]: true,
  11723. [CSS$w.frameAdvancing]: flowDirection === "advancing",
  11724. [CSS$w.frameRetreating]: flowDirection === "retreating"
  11725. };
  11726. return (h("div", { class: frameDirectionClasses, key: panelCount }, h("slot", null)));
  11727. }
  11728. get el() { return this; }
  11729. static get style() { return flowCss; }
  11730. };
  11731. /**
  11732. * Calculate slope of the tangents
  11733. * uses Steffen interpolation as it's monotonic
  11734. * http://jrwalsh1.github.io/posts/interpolations/
  11735. */
  11736. function slope(p0, p1, p2) {
  11737. const dx = p1[0] - p0[0];
  11738. const dx1 = p2[0] - p1[0];
  11739. const dy = p1[1] - p0[1];
  11740. const dy1 = p2[1] - p1[1];
  11741. const m = dy / (dx || (dx1 < 0 && 0));
  11742. const m1 = dy1 / (dx1 || (dx < 0 && 0));
  11743. const p = (m * dx1 + m1 * dx) / (dx + dx1);
  11744. return (Math.sign(m) + Math.sign(m1)) * Math.min(Math.abs(m), Math.abs(m1), 0.5 * Math.abs(p)) || 0;
  11745. }
  11746. /**
  11747. * Calculate slope for just one tangent (single-sided)
  11748. */
  11749. function slopeSingle(p0, p1, m) {
  11750. const dx = p1[0] - p0[0];
  11751. const dy = p1[1] - p0[1];
  11752. return dx ? ((3 * dy) / dx - m) / 2 : m;
  11753. }
  11754. /**
  11755. * Given two points and their tangent slopes,
  11756. * calculate the bezier handle coordinates and return draw command.
  11757. *
  11758. * Translates Hermite Spline to Beziér curve:
  11759. * stackoverflow.com/questions/42574940/
  11760. */
  11761. function bezier(p0, p1, m0, m1, t) {
  11762. const [x0, y0] = p0;
  11763. const [x1, y1] = p1;
  11764. const dx = (x1 - x0) / 3;
  11765. const h1 = t([x0 + dx, y0 + dx * m0]).join(",");
  11766. const h2 = t([x1 - dx, y1 - dx * m1]).join(",");
  11767. const p = t([x1, y1]).join(",");
  11768. return `C ${h1} ${h2} ${p}`;
  11769. }
  11770. /**
  11771. * Generate a function which will translate a point
  11772. * from the data coordinate space to svg viewbox oriented pixels
  11773. */
  11774. function translate({ width, height, min, max }) {
  11775. const rangeX = max[0] - min[0];
  11776. const rangeY = max[1] - min[1];
  11777. return (point) => {
  11778. const x = ((point[0] - min[0]) / rangeX) * width;
  11779. const y = height - (point[1] / rangeY) * height;
  11780. return [x, y];
  11781. };
  11782. }
  11783. /**
  11784. * Get the min and max values from the dataset
  11785. */
  11786. function range(data) {
  11787. const [startX, startY] = data[0];
  11788. const min = [startX, startY];
  11789. const max = [startX, startY];
  11790. return data.reduce(({ min, max }, [x, y]) => ({
  11791. min: [Math.min(min[0], x), Math.min(min[1], y)],
  11792. max: [Math.max(max[0], x), Math.max(max[1], y)]
  11793. }), { min, max });
  11794. }
  11795. /**
  11796. * Generate drawing commands for an area graph
  11797. * returns a string can can be passed directly to a path element's `d` attribute
  11798. */
  11799. function area({ data, min, max, t }) {
  11800. if (data.length === 0) {
  11801. return "";
  11802. }
  11803. // important points for beginning and ending the path
  11804. const [startX, startY] = t(data[0]);
  11805. const [minX, minY] = t(min);
  11806. const [maxX] = t(max);
  11807. // keep track of previous slope/points
  11808. let m;
  11809. let p0;
  11810. let p1;
  11811. // iterate over data points, calculating command for each
  11812. const commands = data.reduce((acc, point, i) => {
  11813. p0 = data[i - 2];
  11814. p1 = data[i - 1];
  11815. if (i > 1) {
  11816. const m1 = slope(p0, p1, point);
  11817. const m0 = m === undefined ? slopeSingle(p0, p1, m1) : m;
  11818. const command = bezier(p0, p1, m0, m1, t);
  11819. m = m1;
  11820. return `${acc} ${command}`;
  11821. }
  11822. return acc;
  11823. }, `M ${minX},${minY} L ${minX},${startY} L ${startX},${startY}`);
  11824. // close the path
  11825. const last = data[data.length - 1];
  11826. const end = bezier(p1, last, m, slopeSingle(p1, last, m), t);
  11827. return `${commands} ${end} L ${maxX},${minY} Z`;
  11828. }
  11829. 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}";
  11830. const Graph = class extends HTMLElement$1 {
  11831. constructor() {
  11832. super();
  11833. this.__registerHost();
  11834. this.__attachShadow();
  11835. //--------------------------------------------------------------------------
  11836. //
  11837. // Properties
  11838. //
  11839. //--------------------------------------------------------------------------
  11840. /**
  11841. * Array of tuples describing a single data point ([x, y])
  11842. * These data points should be sorted by x-axis value
  11843. */
  11844. this.data = [];
  11845. //--------------------------------------------------------------------------
  11846. //
  11847. // Private State/Props
  11848. //
  11849. //--------------------------------------------------------------------------
  11850. this.graphId = `calcite-graph-${guid()}`;
  11851. this.resizeObserver = createObserver("resize", () => forceUpdate(this));
  11852. }
  11853. //--------------------------------------------------------------------------
  11854. //
  11855. // Lifecycle
  11856. //
  11857. //--------------------------------------------------------------------------
  11858. connectedCallback() {
  11859. var _a;
  11860. (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el);
  11861. }
  11862. disconnectedCallback() {
  11863. var _a;
  11864. (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  11865. }
  11866. render() {
  11867. const { data, colorStops, el, highlightMax, highlightMin, min, max } = this;
  11868. const id = this.graphId;
  11869. const { clientHeight: height, clientWidth: width } = el;
  11870. // if we have no data, return empty svg
  11871. if (!data || data.length === 0) {
  11872. return (h("svg", { class: "svg", height: height, preserveAspectRatio: "none", viewBox: `0 0 ${width} ${height}`, width: width }));
  11873. }
  11874. const { min: rangeMin, max: rangeMax } = range(data);
  11875. let currentMin = rangeMin;
  11876. let currentMax = rangeMax;
  11877. if (min < rangeMin[0] || min > rangeMin[0]) {
  11878. currentMin = [min, 0];
  11879. }
  11880. if (max > rangeMax[0] || max < rangeMax[0]) {
  11881. currentMax = [max, rangeMax[1]];
  11882. }
  11883. const t = translate({ min: currentMin, max: currentMax, width, height });
  11884. const [hMinX] = t([highlightMin, currentMax[1]]);
  11885. const [hMaxX] = t([highlightMax, currentMax[1]]);
  11886. const areaPath = area({ data, min: rangeMin, max: rangeMax, t });
  11887. const fill = colorStops ? `url(#linear-gradient-${id})` : undefined;
  11888. 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 ? ([
  11889. h("mask", { height: "100%", id: `${id}1`, width: "100%", x: "0%", y: "0%" }, h("path", { d: `
  11890. M 0,0
  11891. L ${hMinX - 1},0
  11892. L ${hMinX - 1},${height}
  11893. L 0,${height}
  11894. Z
  11895. `, fill: "white" })),
  11896. h("mask", { height: "100%", id: `${id}2`, width: "100%", x: "0%", y: "0%" }, h("path", { d: `
  11897. M ${hMinX + 1},0
  11898. L ${hMaxX - 1},0
  11899. L ${hMaxX - 1},${height}
  11900. L ${hMinX + 1}, ${height}
  11901. Z
  11902. `, fill: "white" })),
  11903. h("mask", { height: "100%", id: `${id}3`, width: "100%", x: "0%", y: "0%" }, h("path", { d: `
  11904. M ${hMaxX + 1},0
  11905. L ${width},0
  11906. L ${width},${height}
  11907. L ${hMaxX + 1}, ${height}
  11908. Z
  11909. `, fill: "white" })),
  11910. h("path", { class: "graph-path", d: areaPath, fill: fill, mask: `url(#${id}1)` }),
  11911. h("path", { class: "graph-path--highlight", d: areaPath, fill: fill, mask: `url(#${id}2)` }),
  11912. h("path", { class: "graph-path", d: areaPath, fill: fill, mask: `url(#${id}3)` })
  11913. ]) : (h("path", { class: "graph-path", d: areaPath, fill: fill }))));
  11914. }
  11915. get el() { return this; }
  11916. static get style() { return graphCss; }
  11917. };
  11918. const CSS$v = {
  11919. handle: "handle",
  11920. handleActivated: "handle--activated"
  11921. };
  11922. const ICONS$7 = {
  11923. drag: "drag"
  11924. };
  11925. 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}";
  11926. const Handle = class extends HTMLElement$1 {
  11927. constructor() {
  11928. super();
  11929. this.__registerHost();
  11930. this.__attachShadow();
  11931. this.calciteHandleNudge = createEvent(this, "calciteHandleNudge", 7);
  11932. // --------------------------------------------------------------------------
  11933. //
  11934. // Properties
  11935. //
  11936. // --------------------------------------------------------------------------
  11937. /**
  11938. * @internal - stores the activated state of the drag handle.
  11939. */
  11940. this.activated = false;
  11941. /**
  11942. * Value for the button title attribute
  11943. */
  11944. this.textTitle = "handle";
  11945. // --------------------------------------------------------------------------
  11946. //
  11947. // Private Methods
  11948. //
  11949. // --------------------------------------------------------------------------
  11950. this.handleKeyDown = (event) => {
  11951. switch (event.key) {
  11952. case " ":
  11953. this.activated = !this.activated;
  11954. break;
  11955. case "ArrowUp":
  11956. case "ArrowDown":
  11957. if (!this.activated) {
  11958. return;
  11959. }
  11960. const direction = event.key.toLowerCase().replace("arrow", "");
  11961. this.calciteHandleNudge.emit({ handle: this.el, direction });
  11962. break;
  11963. }
  11964. };
  11965. this.handleBlur = () => {
  11966. this.activated = false;
  11967. };
  11968. }
  11969. // --------------------------------------------------------------------------
  11970. //
  11971. // Methods
  11972. //
  11973. // --------------------------------------------------------------------------
  11974. /** Sets focus on the component. */
  11975. async setFocus() {
  11976. this.handleButton.focus();
  11977. }
  11978. // --------------------------------------------------------------------------
  11979. //
  11980. // Render Methods
  11981. //
  11982. // --------------------------------------------------------------------------
  11983. render() {
  11984. return (
  11985. // Needs to be a span because of https://github.com/SortableJS/Sortable/issues/1486
  11986. 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) => {
  11987. this.handleButton = el;
  11988. }, role: "button", tabindex: "0", title: this.textTitle }, h("calcite-icon", { icon: ICONS$7.drag, scale: "s" })));
  11989. }
  11990. get el() { return this; }
  11991. static get style() { return handleCss; }
  11992. };
  11993. const CSS$u = {
  11994. icon: "icon",
  11995. flipRtl: "flip-rtl"
  11996. };
  11997. /**
  11998. * Icon data cache.
  11999. * Exported for testing purposes.
  12000. * @private
  12001. */
  12002. const iconCache = {};
  12003. /**
  12004. * Icon request cache.
  12005. * Exported for testing purposes.
  12006. * @private
  12007. */
  12008. const requestCache = {};
  12009. const scaleToPx = {
  12010. s: 16,
  12011. m: 24,
  12012. l: 32
  12013. };
  12014. async function fetchIcon({ icon, scale }) {
  12015. const size = scaleToPx[scale];
  12016. const name = normalizeIconName(icon);
  12017. const filled = name.charAt(name.length - 1) === "F";
  12018. const iconName = filled ? name.substring(0, name.length - 1) : name;
  12019. const id = `${iconName}${size}${filled ? "F" : ""}`;
  12020. if (iconCache[id]) {
  12021. return iconCache[id];
  12022. }
  12023. if (!requestCache[id]) {
  12024. requestCache[id] = fetch(getAssetPath(`./assets/icon/${id}.json`))
  12025. .then((resp) => resp.json())
  12026. .catch(() => {
  12027. console.error(`"${id}" is not a valid calcite-ui-icon name`);
  12028. return "";
  12029. });
  12030. }
  12031. const path = await requestCache[id];
  12032. iconCache[id] = path;
  12033. return path;
  12034. }
  12035. /**
  12036. * Normalize the icon name to match the path data module exports.
  12037. * Exported for testing purposes.
  12038. * @private
  12039. */
  12040. function normalizeIconName(name) {
  12041. const numberLeadingName = !isNaN(Number(name.charAt(0)));
  12042. const parts = name.split("-");
  12043. if (parts.length === 1) {
  12044. return numberLeadingName ? `i${name}` : name;
  12045. }
  12046. return parts
  12047. .map((part, index) => {
  12048. if (index === 0) {
  12049. return numberLeadingName ? `i${part.toUpperCase()}` : part;
  12050. }
  12051. return part.charAt(0).toUpperCase() + part.slice(1);
  12052. })
  12053. .join("");
  12054. }
  12055. 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}";
  12056. const Icon = class extends HTMLElement$1 {
  12057. constructor() {
  12058. super();
  12059. this.__registerHost();
  12060. this.__attachShadow();
  12061. //--------------------------------------------------------------------------
  12062. //
  12063. // Properties
  12064. //
  12065. //--------------------------------------------------------------------------
  12066. /**
  12067. * 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/.
  12068. */
  12069. this.icon = null;
  12070. /**
  12071. * When true, the icon will be flipped when the element direction is 'rtl'.
  12072. */
  12073. this.flipRtl = false;
  12074. /**
  12075. * Icon scale.
  12076. */
  12077. this.scale = "m";
  12078. this.visible = false;
  12079. }
  12080. //--------------------------------------------------------------------------
  12081. //
  12082. // Lifecycle
  12083. //
  12084. //--------------------------------------------------------------------------
  12085. connectedCallback() {
  12086. this.waitUntilVisible(() => {
  12087. this.visible = true;
  12088. this.loadIconPathData();
  12089. });
  12090. }
  12091. disconnectedCallback() {
  12092. var _a;
  12093. (_a = this.intersectionObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  12094. this.intersectionObserver = null;
  12095. }
  12096. async componentWillLoad() {
  12097. this.loadIconPathData();
  12098. }
  12099. render() {
  12100. const { el, flipRtl, pathData, scale, textLabel } = this;
  12101. const dir = getElementDir(el);
  12102. const size = scaleToPx[scale];
  12103. const semantic = !!textLabel;
  12104. const paths = [].concat(pathData || "");
  12105. return (h(Host, { "aria-hidden": toAriaBoolean(!semantic), "aria-label": semantic ? textLabel : null, role: semantic ? "img" : null }, h("svg", { class: {
  12106. [CSS$u.flipRtl]: dir === "rtl" && flipRtl,
  12107. svg: true
  12108. }, 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 }))))));
  12109. }
  12110. //--------------------------------------------------------------------------
  12111. //
  12112. // Private Methods
  12113. //
  12114. //--------------------------------------------------------------------------
  12115. async loadIconPathData() {
  12116. const { icon, scale, visible } = this;
  12117. if (!Build.isBrowser || !icon || !visible) {
  12118. return;
  12119. }
  12120. this.pathData = await fetchIcon({ icon, scale });
  12121. }
  12122. waitUntilVisible(callback) {
  12123. this.intersectionObserver = createObserver("intersection", (entries) => {
  12124. entries.forEach((entry) => {
  12125. if (entry.isIntersecting) {
  12126. this.intersectionObserver.disconnect();
  12127. this.intersectionObserver = null;
  12128. callback();
  12129. }
  12130. });
  12131. }, { rootMargin: "50px" });
  12132. if (!this.intersectionObserver) {
  12133. callback();
  12134. return;
  12135. }
  12136. this.intersectionObserver.observe(this.el);
  12137. }
  12138. static get assetsDirs() { return ["assets"]; }
  12139. get el() { return this; }
  12140. static get watchers() { return {
  12141. "icon": ["loadIconPathData"],
  12142. "scale": ["loadIconPathData"]
  12143. }; }
  12144. static get style() { return iconCss; }
  12145. };
  12146. const CSS$t = {
  12147. wrapper: "wrapper",
  12148. confirmChangesButton: "confirm-changes-button",
  12149. cancelEditingButton: "cancel-editing-button",
  12150. inputWrapper: "input-wrapper",
  12151. cancelEditingButtonWrapper: "cancel-editing-button-wrapper",
  12152. enableEditingButton: "enable-editing-button",
  12153. controlsWrapper: "controls-wrapper"
  12154. };
  12155. const TEXT$d = {
  12156. intlEnablingEditing: "Click to edit",
  12157. intlCancelEditing: "Cancel",
  12158. intlConfirmChanges: "Save"
  12159. };
  12160. 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}";
  12161. const InlineEditable = class extends HTMLElement$1 {
  12162. constructor() {
  12163. super();
  12164. this.__registerHost();
  12165. this.__attachShadow();
  12166. this.calciteInlineEditableEditCancel = createEvent(this, "calciteInlineEditableEditCancel", 7);
  12167. this.calciteInlineEditableEditConfirm = createEvent(this, "calciteInlineEditableEditConfirm", 7);
  12168. this.calciteInlineEditableEnableEditingChange = createEvent(this, "calciteInlineEditableEnableEditingChange", 7);
  12169. //--------------------------------------------------------------------------
  12170. //
  12171. // Props
  12172. //
  12173. //--------------------------------------------------------------------------
  12174. /** specify whether editing can be enabled */
  12175. this.disabled = false;
  12176. /** specify whether the wrapped input element is editable, defaults to false */
  12177. this.editingEnabled = false;
  12178. /** specify whether the confirm button should display a loading state, defaults to false */
  12179. this.loading = false;
  12180. /** specify whether save/cancel controls should be displayed when editingEnabled is true, defaults to false */
  12181. this.controls = false;
  12182. /** specify text to be user for the enable editing button's aria-label, defaults to `Click to edit`
  12183. * @default "Click to edit"
  12184. */
  12185. this.intlEnableEditing = TEXT$d.intlEnablingEditing;
  12186. /** specify text to be user for the cancel editing button's aria-label, defaults to `Cancel`
  12187. * @default "Cancel"
  12188. */
  12189. this.intlCancelEditing = TEXT$d.intlCancelEditing;
  12190. /** specify text to be user for the confirm changes button's aria-label, defaults to `Save`
  12191. * @default "Save"
  12192. */
  12193. this.intlConfirmChanges = TEXT$d.intlConfirmChanges;
  12194. this.mutationObserver = createObserver("mutation", () => this.mutationObserverCallback());
  12195. this.enableEditing = () => {
  12196. var _a, _b;
  12197. this.valuePriorToEditing = (_a = this.inputElement) === null || _a === void 0 ? void 0 : _a.value;
  12198. this.editingEnabled = true;
  12199. (_b = this.inputElement) === null || _b === void 0 ? void 0 : _b.setFocus();
  12200. this.calciteInlineEditableEnableEditingChange.emit();
  12201. };
  12202. this.disableEditing = () => {
  12203. this.editingEnabled = false;
  12204. };
  12205. this.cancelEditing = () => {
  12206. if (this.inputElement) {
  12207. this.inputElement.value = this.valuePriorToEditing;
  12208. }
  12209. this.disableEditing();
  12210. this.enableEditingButton.setFocus();
  12211. if (!this.editingEnabled && !!this.shouldEmitCancel) {
  12212. this.calciteInlineEditableEditCancel.emit();
  12213. }
  12214. };
  12215. this.escapeKeyHandler = async (e) => {
  12216. var _a;
  12217. if (e.key !== "Escape") {
  12218. if (e.key === "Tab" && this.shouldShowControls) {
  12219. if (!e.shiftKey && e.target === this.inputElement) {
  12220. e.preventDefault();
  12221. this.cancelEditingButton.setFocus();
  12222. }
  12223. if (!!e.shiftKey && e.target === this.cancelEditingButton) {
  12224. e.preventDefault();
  12225. (_a = this.inputElement) === null || _a === void 0 ? void 0 : _a.setFocus();
  12226. }
  12227. }
  12228. return;
  12229. }
  12230. this.cancelEditing();
  12231. };
  12232. this.cancelEditingHandler = async (e) => {
  12233. e.preventDefault();
  12234. this.cancelEditing();
  12235. };
  12236. this.enableEditingHandler = async (e) => {
  12237. if (this.disabled ||
  12238. e.target === this.cancelEditingButton ||
  12239. e.target === this.confirmEditingButton) {
  12240. return;
  12241. }
  12242. e.preventDefault();
  12243. if (!this.editingEnabled) {
  12244. this.enableEditing();
  12245. }
  12246. };
  12247. this.confirmChangesHandler = async (e) => {
  12248. e.preventDefault();
  12249. this.calciteInlineEditableEditConfirm.emit();
  12250. try {
  12251. if (this.afterConfirm) {
  12252. this.loading = true;
  12253. await this.afterConfirm();
  12254. this.disableEditing();
  12255. this.enableEditingButton.setFocus();
  12256. }
  12257. }
  12258. catch (e) {
  12259. }
  12260. finally {
  12261. this.loading = false;
  12262. }
  12263. };
  12264. }
  12265. disabledWatcher(disabled) {
  12266. if (this.inputElement) {
  12267. this.inputElement.disabled = disabled;
  12268. }
  12269. }
  12270. editingEnabledWatcher(newValue, oldValue) {
  12271. if (this.inputElement) {
  12272. this.inputElement.editingEnabled = newValue;
  12273. }
  12274. if (!newValue && !!oldValue) {
  12275. this.shouldEmitCancel = true;
  12276. }
  12277. }
  12278. //--------------------------------------------------------------------------
  12279. //
  12280. // Lifecycle
  12281. //
  12282. //--------------------------------------------------------------------------
  12283. connectedCallback() {
  12284. var _a;
  12285. connectLabel(this);
  12286. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true });
  12287. this.mutationObserverCallback();
  12288. }
  12289. disconnectedCallback() {
  12290. var _a;
  12291. disconnectLabel(this);
  12292. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  12293. }
  12294. componentDidRender() {
  12295. updateHostInteraction(this);
  12296. }
  12297. render() {
  12298. 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: {
  12299. opacity: this.editingEnabled ? "0" : "1",
  12300. width: this.editingEnabled ? "0" : "inherit"
  12301. }, type: "button" }), this.shouldShowControls && [
  12302. 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" })),
  12303. 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" })
  12304. ])));
  12305. }
  12306. //--------------------------------------------------------------------------
  12307. //
  12308. // Event Listeners
  12309. //
  12310. //--------------------------------------------------------------------------
  12311. blurHandler() {
  12312. if (!this.controls) {
  12313. this.disableEditing();
  12314. }
  12315. }
  12316. //--------------------------------------------------------------------------
  12317. //
  12318. // Public Methods
  12319. //
  12320. //--------------------------------------------------------------------------
  12321. async setFocus() {
  12322. var _a, _b;
  12323. if (this.editingEnabled) {
  12324. (_a = this.inputElement) === null || _a === void 0 ? void 0 : _a.setFocus();
  12325. }
  12326. else {
  12327. (_b = this.enableEditingButton) === null || _b === void 0 ? void 0 : _b.setFocus();
  12328. }
  12329. }
  12330. //--------------------------------------------------------------------------
  12331. //
  12332. // Private Methods
  12333. //
  12334. //--------------------------------------------------------------------------
  12335. mutationObserverCallback() {
  12336. var _a;
  12337. this.updateSlottedInput();
  12338. this.scale =
  12339. this.scale || ((_a = this.inputElement) === null || _a === void 0 ? void 0 : _a.scale) || getElementProp(this.el, "scale", undefined);
  12340. }
  12341. onLabelClick() {
  12342. this.setFocus();
  12343. }
  12344. updateSlottedInput() {
  12345. const inputElement = getSlotted(this.el, {
  12346. matches: "calcite-input"
  12347. });
  12348. this.inputElement = inputElement;
  12349. if (!inputElement) {
  12350. return;
  12351. }
  12352. this.inputElement.disabled = this.disabled;
  12353. this.inputElement.label = this.inputElement.label || getLabelText(this);
  12354. }
  12355. get shouldShowControls() {
  12356. return this.editingEnabled && this.controls;
  12357. }
  12358. get el() { return this; }
  12359. static get watchers() { return {
  12360. "disabled": ["disabledWatcher"],
  12361. "editingEnabled": ["editingEnabledWatcher"]
  12362. }; }
  12363. static get style() { return inlineEditableCss; }
  12364. };
  12365. const CSS$s = {
  12366. loader: "loader",
  12367. clearButton: "clear-button",
  12368. editingEnabled: "editing-enabled",
  12369. inlineChild: "inline-child",
  12370. inputIcon: "icon",
  12371. prefix: "prefix",
  12372. suffix: "suffix",
  12373. numberButtonWrapper: "number-button-wrapper",
  12374. buttonItemHorizontal: "number-button-item--horizontal",
  12375. wrapper: "element-wrapper",
  12376. inputWrapper: "wrapper",
  12377. actionWrapper: "action-wrapper",
  12378. resizeIconWrapper: "resize-icon-wrapper",
  12379. numberButtonItem: "number-button-item"
  12380. };
  12381. const INPUT_TYPE_ICONS = {
  12382. tel: "phone",
  12383. password: "lock",
  12384. email: "email-address",
  12385. date: "calendar",
  12386. time: "clock",
  12387. search: "search"
  12388. };
  12389. const SLOTS$g = {
  12390. action: "action"
  12391. };
  12392. const TEXT$c = {
  12393. clear: "Clear value"
  12394. };
  12395. 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}";
  12396. const Input = class extends HTMLElement$1 {
  12397. constructor() {
  12398. super();
  12399. this.__registerHost();
  12400. this.__attachShadow();
  12401. this.calciteInputFocus = createEvent(this, "calciteInputFocus", 7);
  12402. this.calciteInputBlur = createEvent(this, "calciteInputBlur", 7);
  12403. this.calciteInputInput = createEvent(this, "calciteInputInput", 7);
  12404. this.calciteInputChange = createEvent(this, "calciteInputChange", 7);
  12405. //--------------------------------------------------------------------------
  12406. //
  12407. // Properties
  12408. //
  12409. //--------------------------------------------------------------------------
  12410. /** specify the alignment of the value of the input */
  12411. this.alignment = "start";
  12412. /** should the input autofocus */
  12413. this.autofocus = false;
  12414. /** optionally display a clear button that displays when field has a value
  12415. * shows by default for search, time, date
  12416. * will not display for type="textarea" */
  12417. this.clearable = false;
  12418. /** is the input disabled */
  12419. this.disabled = false;
  12420. /** for number values, displays the locale's group separator */
  12421. this.groupSeparator = false;
  12422. /** when true, the component will not be visible */
  12423. this.hidden = false;
  12424. /**
  12425. * string to override English loading text
  12426. * @default "Loading"
  12427. */
  12428. this.intlLoading = TEXT$s.loading;
  12429. /** flip the icon in rtl */
  12430. this.iconFlipRtl = false;
  12431. /** specify if the input is in loading state */
  12432. this.loading = false;
  12433. /** BCP 47 language tag for desired language and country format */
  12434. this.locale = document.documentElement.lang || "en";
  12435. /**
  12436. * Toggles locale formatting for numbers.
  12437. * @internal
  12438. */
  12439. this.localeFormat = false;
  12440. /** specify the placement of the number buttons */
  12441. this.numberButtonType = "vertical";
  12442. /** When true, a field cannot be modified. */
  12443. this.readOnly = false;
  12444. /** is the input required */
  12445. this.required = false;
  12446. /** specify the scale of the input, defaults to m */
  12447. this.scale = "m";
  12448. /** specify the status of the input field, determines message and icons */
  12449. this.status = "idle";
  12450. /** @internal adds inline styles for text input when slotted in calcite-inline-editable */
  12451. this.editingEnabled = false;
  12452. /**
  12453. * specify the input type
  12454. *
  12455. * Note that the following types add type-specific icons by default: `date`, `email`, `password`, `search`, `tel`, `time`
  12456. */
  12457. this.type = "text";
  12458. /** input value */
  12459. this.value = "";
  12460. /** keep track of the rendered child type */
  12461. this.childElType = "input";
  12462. this.previousValueOrigin = "initial";
  12463. this.mutationObserver = createObserver("mutation", () => this.setDisabledAction());
  12464. this.userChangedValue = false;
  12465. //--------------------------------------------------------------------------
  12466. //
  12467. // Private Methods
  12468. //
  12469. //--------------------------------------------------------------------------
  12470. this.keyDownHandler = (event) => {
  12471. if (this.readOnly || this.disabled) {
  12472. return;
  12473. }
  12474. if (this.isClearable && event.key === "Escape") {
  12475. this.clearInputValue(event);
  12476. event.preventDefault();
  12477. }
  12478. if (event.key === "Enter" && !event.defaultPrevented) {
  12479. submitForm(this);
  12480. }
  12481. };
  12482. this.clearInputValue = (nativeEvent) => {
  12483. this.setValue({
  12484. committing: true,
  12485. nativeEvent,
  12486. origin: "user",
  12487. value: ""
  12488. });
  12489. };
  12490. this.emitChangeIfUserModified = () => {
  12491. if (this.previousValueOrigin === "user" && this.value !== this.previousEmittedValue) {
  12492. this.calciteInputChange.emit();
  12493. }
  12494. this.previousEmittedValue = this.value;
  12495. };
  12496. this.inputBlurHandler = () => {
  12497. this.calciteInputBlur.emit({
  12498. element: this.childEl,
  12499. value: this.value
  12500. });
  12501. this.emitChangeIfUserModified();
  12502. };
  12503. this.inputFocusHandler = (event) => {
  12504. const slottedActionEl = getSlotted(this.el, "action");
  12505. if (event.target !== slottedActionEl) {
  12506. this.setFocus();
  12507. }
  12508. this.calciteInputFocus.emit({
  12509. element: this.childEl,
  12510. value: this.value
  12511. });
  12512. };
  12513. this.inputInputHandler = (nativeEvent) => {
  12514. if (this.disabled || this.readOnly) {
  12515. return;
  12516. }
  12517. this.setValue({
  12518. nativeEvent,
  12519. origin: "user",
  12520. value: nativeEvent.target.value
  12521. });
  12522. };
  12523. this.inputKeyDownHandler = (event) => {
  12524. if (this.disabled || this.readOnly) {
  12525. return;
  12526. }
  12527. if (event.key === "Enter") {
  12528. this.emitChangeIfUserModified();
  12529. }
  12530. };
  12531. this.inputNumberInputHandler = (nativeEvent) => {
  12532. if (this.disabled || this.readOnly) {
  12533. return;
  12534. }
  12535. const value = nativeEvent.target.value;
  12536. const delocalizedValue = delocalizeNumberString(value, this.locale);
  12537. if (nativeEvent.inputType === "insertFromPaste") {
  12538. if (!isValidNumber(delocalizedValue)) {
  12539. nativeEvent.preventDefault();
  12540. }
  12541. this.setValue({
  12542. nativeEvent,
  12543. origin: "user",
  12544. value: parseNumberString(delocalizedValue)
  12545. });
  12546. this.childNumberEl.value = this.localizedValue;
  12547. }
  12548. else {
  12549. this.setValue({
  12550. nativeEvent,
  12551. origin: "user",
  12552. value: delocalizedValue
  12553. });
  12554. }
  12555. };
  12556. this.inputNumberKeyDownHandler = (event) => {
  12557. if (this.type !== "number" || this.disabled || this.readOnly) {
  12558. return;
  12559. }
  12560. if (event.key === "ArrowUp") {
  12561. /* prevent default behavior of moving cursor to the beginning of the input when holding down ArrowUp */
  12562. event.preventDefault();
  12563. this.nudgeNumberValue("up", event);
  12564. return;
  12565. }
  12566. if (event.key === "ArrowDown") {
  12567. this.nudgeNumberValue("down", event);
  12568. return;
  12569. }
  12570. const supportedKeys = [
  12571. ...numberKeys,
  12572. "ArrowLeft",
  12573. "ArrowRight",
  12574. "Backspace",
  12575. "Delete",
  12576. "Enter",
  12577. "Escape",
  12578. "Tab"
  12579. ];
  12580. if (event.altKey || event.ctrlKey || event.metaKey) {
  12581. return;
  12582. }
  12583. const isShiftTabEvent = event.shiftKey && event.key === "Tab";
  12584. if (supportedKeys.includes(event.key) && (!event.shiftKey || isShiftTabEvent)) {
  12585. if (event.key === "Enter") {
  12586. this.emitChangeIfUserModified();
  12587. }
  12588. return;
  12589. }
  12590. const decimalSeparator = getDecimalSeparator(this.locale);
  12591. if (event.key === decimalSeparator) {
  12592. if (!this.value && !this.childNumberEl.value) {
  12593. return;
  12594. }
  12595. if (this.value && this.childNumberEl.value.indexOf(decimalSeparator) === -1) {
  12596. return;
  12597. }
  12598. }
  12599. if (/[eE]/.test(event.key)) {
  12600. if (!this.value && !this.childNumberEl.value) {
  12601. return;
  12602. }
  12603. if (this.value && !/[eE]/.test(this.childNumberEl.value)) {
  12604. return;
  12605. }
  12606. }
  12607. if (event.key === "-") {
  12608. if (!this.value && !this.childNumberEl.value) {
  12609. return;
  12610. }
  12611. if (this.value && this.childNumberEl.value.split("-").length <= 2) {
  12612. return;
  12613. }
  12614. }
  12615. event.preventDefault();
  12616. };
  12617. this.nudgeNumberValue = (direction, nativeEvent) => {
  12618. if ((nativeEvent instanceof KeyboardEvent && nativeEvent.repeat) || this.type !== "number") {
  12619. return;
  12620. }
  12621. const inputMax = this.maxString ? parseFloat(this.maxString) : null;
  12622. const inputMin = this.minString ? parseFloat(this.minString) : null;
  12623. const valueNudgeDelayInMs = 100;
  12624. this.incrementOrDecrementNumberValue(direction, inputMax, inputMin, nativeEvent);
  12625. if (this.nudgeNumberValueIntervalId) {
  12626. window.clearInterval(this.nudgeNumberValueIntervalId);
  12627. }
  12628. let firstValueNudge = true;
  12629. this.nudgeNumberValueIntervalId = window.setInterval(() => {
  12630. if (firstValueNudge) {
  12631. firstValueNudge = false;
  12632. return;
  12633. }
  12634. this.incrementOrDecrementNumberValue(direction, inputMax, inputMin, nativeEvent);
  12635. }, valueNudgeDelayInMs);
  12636. };
  12637. this.numberButtonMouseUpAndMouseOutHandler = () => {
  12638. window.clearInterval(this.nudgeNumberValueIntervalId);
  12639. };
  12640. this.numberButtonMouseDownHandler = (event) => {
  12641. event.preventDefault();
  12642. const direction = event.target.dataset.adjustment;
  12643. this.nudgeNumberValue(direction, event);
  12644. };
  12645. this.setChildElRef = (el) => {
  12646. this.childEl = el;
  12647. };
  12648. this.setChildNumberElRef = (el) => {
  12649. this.childNumberEl = el;
  12650. };
  12651. this.setInputValue = (newInputValue) => {
  12652. if (this.type === "text" && !this.childEl) {
  12653. return;
  12654. }
  12655. if (this.type === "number" && !this.childNumberEl) {
  12656. return;
  12657. }
  12658. this[`child${this.type === "number" ? "Number" : ""}El`].value = newInputValue;
  12659. };
  12660. this.setPreviousEmittedValue = (newPreviousEmittedValue) => {
  12661. this.previousEmittedValue =
  12662. this.type === "number"
  12663. ? isValidNumber(newPreviousEmittedValue)
  12664. ? newPreviousEmittedValue
  12665. : ""
  12666. : newPreviousEmittedValue;
  12667. };
  12668. this.setPreviousValue = (newPreviousValue) => {
  12669. this.previousValue =
  12670. this.type === "number"
  12671. ? isValidNumber(newPreviousValue)
  12672. ? newPreviousValue
  12673. : ""
  12674. : newPreviousValue;
  12675. };
  12676. this.setValue = ({ committing = false, nativeEvent, origin, previousValue, value }) => {
  12677. const previousLocalizedValue = this.type === "number"
  12678. ? localizeNumberString(this.previousValue, this.locale, this.groupSeparator)
  12679. : "";
  12680. const sanitizedValue = this.type === "number" ? sanitizeNumberString(value) : value;
  12681. const newValue = this.type === "number" && value && !sanitizedValue
  12682. ? isValidNumber(this.previousValue)
  12683. ? this.previousValue
  12684. : ""
  12685. : sanitizedValue;
  12686. const newLocalizedValue = this.type === "number"
  12687. ? localizeNumberString(newValue, this.locale, this.groupSeparator)
  12688. : "";
  12689. this.setPreviousValue(previousValue || this.value);
  12690. this.previousValueOrigin = origin;
  12691. this.userChangedValue = origin === "user" && this.value !== newValue;
  12692. this.value = newValue;
  12693. if (this.type === "number") {
  12694. this.localizedValue = newLocalizedValue;
  12695. }
  12696. if (origin === "direct") {
  12697. this.setInputValue(this.type === "number" ? newLocalizedValue : newValue);
  12698. }
  12699. if (nativeEvent) {
  12700. const calciteInputInputEvent = this.calciteInputInput.emit({
  12701. element: this.childEl,
  12702. nativeEvent,
  12703. value: this.value
  12704. });
  12705. if (calciteInputInputEvent.defaultPrevented) {
  12706. this.value = this.previousValue;
  12707. this.localizedValue = previousLocalizedValue;
  12708. }
  12709. else if (committing) {
  12710. this.emitChangeIfUserModified();
  12711. }
  12712. }
  12713. };
  12714. this.inputKeyUpHandler = () => {
  12715. window.clearInterval(this.nudgeNumberValueIntervalId);
  12716. };
  12717. }
  12718. disabledWatcher() {
  12719. this.setDisabledAction();
  12720. }
  12721. /** watcher to update number-to-string for max */
  12722. maxWatcher() {
  12723. var _a;
  12724. this.maxString = ((_a = this.max) === null || _a === void 0 ? void 0 : _a.toString()) || null;
  12725. }
  12726. /** watcher to update number-to-string for min */
  12727. minWatcher() {
  12728. var _a;
  12729. this.minString = ((_a = this.min) === null || _a === void 0 ? void 0 : _a.toString()) || null;
  12730. }
  12731. valueWatcher(newValue, previousValue) {
  12732. if (!this.userChangedValue) {
  12733. this.setValue({
  12734. origin: "direct",
  12735. previousValue,
  12736. value: newValue == null || newValue == ""
  12737. ? ""
  12738. : this.type === "number"
  12739. ? isValidNumber(newValue)
  12740. ? newValue
  12741. : this.previousValue || ""
  12742. : newValue
  12743. });
  12744. this.warnAboutInvalidNumberValue(newValue);
  12745. }
  12746. this.userChangedValue = false;
  12747. }
  12748. updateRequestedIcon() {
  12749. this.requestedIcon = setRequestedIcon(INPUT_TYPE_ICONS, this.icon, this.type);
  12750. }
  12751. get isClearable() {
  12752. return !this.isTextarea && (this.clearable || this.type === "search") && this.value.length > 0;
  12753. }
  12754. get isTextarea() {
  12755. return this.childElType === "textarea";
  12756. }
  12757. //--------------------------------------------------------------------------
  12758. //
  12759. // Lifecycle
  12760. //
  12761. //--------------------------------------------------------------------------
  12762. connectedCallback() {
  12763. var _a;
  12764. this.scale = getElementProp(this.el, "scale", this.scale);
  12765. this.status = getElementProp(this.el, "status", this.status);
  12766. this.inlineEditableEl = this.el.closest("calcite-inline-editable");
  12767. if (this.inlineEditableEl) {
  12768. this.editingEnabled = this.inlineEditableEl.editingEnabled || false;
  12769. }
  12770. this.setPreviousEmittedValue(this.value);
  12771. this.setPreviousValue(this.value);
  12772. if (this.type === "number") {
  12773. this.warnAboutInvalidNumberValue(this.value);
  12774. this.setValue({
  12775. origin: "connected",
  12776. value: isValidNumber(this.value) ? this.value : ""
  12777. });
  12778. }
  12779. connectLabel(this);
  12780. connectForm(this);
  12781. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true });
  12782. this.setDisabledAction();
  12783. }
  12784. disconnectedCallback() {
  12785. var _a;
  12786. disconnectLabel(this);
  12787. disconnectForm(this);
  12788. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  12789. }
  12790. componentWillLoad() {
  12791. var _a, _b;
  12792. this.childElType = this.type === "textarea" ? "textarea" : "input";
  12793. this.maxString = (_a = this.max) === null || _a === void 0 ? void 0 : _a.toString();
  12794. this.minString = (_b = this.min) === null || _b === void 0 ? void 0 : _b.toString();
  12795. this.requestedIcon = setRequestedIcon(INPUT_TYPE_ICONS, this.icon, this.type);
  12796. }
  12797. componentShouldUpdate(newValue, oldValue, property) {
  12798. if (this.type === "number" && property === "value" && newValue && !isValidNumber(newValue)) {
  12799. this.setValue({
  12800. origin: "reset",
  12801. value: oldValue
  12802. });
  12803. return false;
  12804. }
  12805. return true;
  12806. }
  12807. componentDidRender() {
  12808. updateHostInteraction(this);
  12809. }
  12810. //--------------------------------------------------------------------------
  12811. //
  12812. // Public Methods
  12813. //
  12814. //--------------------------------------------------------------------------
  12815. /** Sets focus on the component. */
  12816. async setFocus() {
  12817. var _a, _b;
  12818. if (this.type === "number") {
  12819. (_a = this.childNumberEl) === null || _a === void 0 ? void 0 : _a.focus();
  12820. }
  12821. else {
  12822. (_b = this.childEl) === null || _b === void 0 ? void 0 : _b.focus();
  12823. }
  12824. }
  12825. onLabelClick() {
  12826. this.setFocus();
  12827. }
  12828. incrementOrDecrementNumberValue(direction, inputMax, inputMin, nativeEvent) {
  12829. const { value } = this;
  12830. const inputStep = this.step === "any" ? 1 : Math.abs(this.step || 1);
  12831. const inputVal = value && value !== "" ? parseFloat(value) : 0;
  12832. const adjustment = direction === "up" ? 1 : -1;
  12833. const nudgedValue = inputVal + inputStep * adjustment;
  12834. const finalValue = (typeof inputMin === "number" && !isNaN(inputMin) && nudgedValue < inputMin) ||
  12835. (typeof inputMax === "number" && !isNaN(inputMax) && nudgedValue > inputMax)
  12836. ? inputVal
  12837. : nudgedValue;
  12838. const inputValPlaces = decimalPlaces(inputVal);
  12839. const inputStepPlaces = decimalPlaces(inputStep);
  12840. this.setValue({
  12841. committing: true,
  12842. nativeEvent,
  12843. origin: "user",
  12844. value: finalValue.toFixed(Math.max(inputValPlaces, inputStepPlaces))
  12845. });
  12846. }
  12847. onFormReset() {
  12848. this.setValue({
  12849. origin: "reset",
  12850. value: this.defaultValue
  12851. });
  12852. }
  12853. syncHiddenFormInput(input) {
  12854. var _a, _b, _c, _d;
  12855. if (this.type === "number") {
  12856. input.type = "number";
  12857. input.min = (_b = (_a = this.min) === null || _a === void 0 ? void 0 : _a.toString(10)) !== null && _b !== void 0 ? _b : "";
  12858. input.max = (_d = (_c = this.max) === null || _c === void 0 ? void 0 : _c.toString(10)) !== null && _d !== void 0 ? _d : "";
  12859. }
  12860. else if (this.type === "text") {
  12861. input.type = "text";
  12862. if (this.minLength != null) {
  12863. input.minLength = this.minLength;
  12864. }
  12865. if (this.maxLength != null) {
  12866. input.maxLength = this.maxLength;
  12867. }
  12868. }
  12869. else if (this.type === "password") {
  12870. input.type = "password";
  12871. }
  12872. }
  12873. setDisabledAction() {
  12874. const slottedActionEl = getSlotted(this.el, "action");
  12875. if (!slottedActionEl) {
  12876. return;
  12877. }
  12878. this.disabled
  12879. ? slottedActionEl.setAttribute("disabled", "")
  12880. : slottedActionEl.removeAttribute("disabled");
  12881. }
  12882. warnAboutInvalidNumberValue(value) {
  12883. if (this.type === "number" && value && !isValidNumber(value)) {
  12884. console.warn(`The specified value "${value}" cannot be parsed, or is out of range.`);
  12885. }
  12886. }
  12887. // --------------------------------------------------------------------------
  12888. //
  12889. // Render Methods
  12890. //
  12891. // --------------------------------------------------------------------------
  12892. render() {
  12893. const dir = getElementDir(this.el);
  12894. const loader = (h("div", { class: CSS$s.loader }, h("calcite-progress", { label: this.intlLoading, type: "indeterminate" })));
  12895. 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" })));
  12896. const iconEl = (h("calcite-icon", { class: CSS$s.inputIcon, flipRtl: this.iconFlipRtl, icon: this.requestedIcon, scale: "s" }));
  12897. const isHorizontalNumberButton = this.numberButtonType === "horizontal";
  12898. const numberButtonsHorizontalUp = (h("button", { class: {
  12899. [CSS$s.numberButtonItem]: true,
  12900. [CSS$s.buttonItemHorizontal]: isHorizontalNumberButton
  12901. }, "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" })));
  12902. const numberButtonsHorizontalDown = (h("button", { class: {
  12903. [CSS$s.numberButtonItem]: true,
  12904. [CSS$s.buttonItemHorizontal]: isHorizontalNumberButton
  12905. }, "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" })));
  12906. const numberButtonsVertical = (h("div", { class: CSS$s.numberButtonWrapper }, numberButtonsHorizontalUp, numberButtonsHorizontalDown));
  12907. const prefixText = h("div", { class: CSS$s.prefix }, this.prefixText);
  12908. const suffixText = h("div", { class: CSS$s.suffix }, this.suffixText);
  12909. 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;
  12910. const childEl = this.type !== "number"
  12911. ? [
  12912. h(this.childElType, { "aria-label": getLabelText(this), autofocus: this.autofocus ? true : null, class: {
  12913. [CSS$s.editingEnabled]: this.editingEnabled,
  12914. [CSS$s.inlineChild]: !!this.inlineEditableEl
  12915. }, 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 }),
  12916. this.isTextarea ? (h("div", { class: CSS$s.resizeIconWrapper }, h("calcite-icon", { icon: "chevron-down", scale: "s" }))) : null
  12917. ]
  12918. : null;
  12919. 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
  12920. ? numberButtonsHorizontalDown
  12921. : 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
  12922. ? numberButtonsVertical
  12923. : null, this.suffixText ? suffixText : null, this.type === "number" && this.numberButtonType === "horizontal" && !this.readOnly
  12924. ? numberButtonsHorizontalUp
  12925. : null, h(HiddenFormInputSlot, { component: this }))));
  12926. }
  12927. get el() { return this; }
  12928. static get watchers() { return {
  12929. "disabled": ["disabledWatcher"],
  12930. "max": ["maxWatcher"],
  12931. "min": ["minWatcher"],
  12932. "value": ["valueWatcher"],
  12933. "icon": ["updateRequestedIcon"],
  12934. "type": ["updateRequestedIcon"]
  12935. }; }
  12936. static get style() { return inputCss; }
  12937. };
  12938. 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}";
  12939. const InputDatePicker = class extends HTMLElement$1 {
  12940. constructor() {
  12941. super();
  12942. this.__registerHost();
  12943. this.__attachShadow();
  12944. this.calciteDatePickerChange = createEvent(this, "calciteDatePickerChange", 7);
  12945. this.calciteDatePickerRangeChange = createEvent(this, "calciteDatePickerRangeChange", 7);
  12946. this.calciteInputDatePickerChange = createEvent(this, "calciteInputDatePickerChange", 7);
  12947. this.calciteInputDatePickerOpen = createEvent(this, "calciteInputDatePickerOpen", 7);
  12948. this.calciteInputDatePickerClose = createEvent(this, "calciteInputDatePickerClose", 7);
  12949. //--------------------------------------------------------------------------
  12950. //
  12951. // Public Properties
  12952. //
  12953. //--------------------------------------------------------------------------
  12954. /**
  12955. * When false, the component won't be interactive.
  12956. */
  12957. this.disabled = false;
  12958. /** Expand or collapse when calendar does not have input */
  12959. this.active = false;
  12960. /** Localized string for "previous month" (used for aria label)
  12961. * @default "Previous month"
  12962. */
  12963. this.intlPrevMonth = TEXT$f.prevMonth;
  12964. /** Localized string for "next month" (used for aria label)
  12965. * @default "Next month"
  12966. */
  12967. this.intlNextMonth = TEXT$f.nextMonth;
  12968. /** Localized string for "year" (used for aria label)
  12969. * @default "Year"
  12970. */
  12971. this.intlYear = TEXT$f.year;
  12972. /** BCP 47 language tag for desired language and country format */
  12973. this.locale = document.documentElement.lang || "en";
  12974. /** specify the scale of the date picker */
  12975. this.scale = "m";
  12976. /**
  12977. * Determines where the date-picker component will be positioned relative to the input.
  12978. * @default "bottom-leading"
  12979. */
  12980. this.placement = defaultMenuPlacement;
  12981. /** Range mode activation */
  12982. this.range = false;
  12983. /**
  12984. * When true, makes the component required for form-submission.
  12985. *
  12986. * @internal
  12987. */
  12988. this.required = false;
  12989. /** Describes the type of positioning to use for the overlaid content. If your element is in a fixed container, use the 'fixed' value. */
  12990. this.overlayPositioning = "absolute";
  12991. /** Disables the default behaviour on the third click of narrowing or extending the range and instead starts a new range. */
  12992. this.proximitySelectionDisabled = false;
  12993. /** Layout */
  12994. this.layout = "horizontal";
  12995. this.focusedInput = "start";
  12996. this.activeTransitionProp = "opacity";
  12997. //--------------------------------------------------------------------------
  12998. //
  12999. // Private Methods
  13000. //
  13001. //--------------------------------------------------------------------------
  13002. this.setFilteredPlacements = () => {
  13003. const { el, flipPlacements } = this;
  13004. this.filteredFlipPlacements = flipPlacements
  13005. ? filterComputedPlacements(flipPlacements, el)
  13006. : null;
  13007. };
  13008. this.transitionEnd = (event) => {
  13009. if (event.propertyName === this.activeTransitionProp) {
  13010. this.active
  13011. ? this.calciteInputDatePickerOpen.emit()
  13012. : this.calciteInputDatePickerClose.emit();
  13013. }
  13014. };
  13015. this.setStartInput = (el) => {
  13016. this.startInput = el;
  13017. };
  13018. this.setEndInput = (el) => {
  13019. this.endInput = el;
  13020. };
  13021. this.deactivate = () => {
  13022. this.active = false;
  13023. };
  13024. this.keyDownHandler = (event) => {
  13025. if (event.key === "Enter" && !event.defaultPrevented) {
  13026. submitForm(this);
  13027. }
  13028. };
  13029. this.keyUpHandler = (e) => {
  13030. if (e.key === "Escape") {
  13031. this.active = false;
  13032. }
  13033. };
  13034. this.inputBlur = (e) => {
  13035. this.blur(e.detail);
  13036. };
  13037. this.startInputFocus = () => {
  13038. this.active = true;
  13039. this.focusedInput = "start";
  13040. };
  13041. this.endInputFocus = () => {
  13042. this.active = true;
  13043. this.focusedInput = "end";
  13044. };
  13045. this.inputInput = (e) => {
  13046. this.input(e.detail.value);
  13047. };
  13048. this.setMenuEl = (el) => {
  13049. if (el) {
  13050. this.menuEl = el;
  13051. this.createPopper();
  13052. }
  13053. };
  13054. this.setStartWrapper = (el) => {
  13055. this.startWrapper = el;
  13056. this.setReferenceEl();
  13057. };
  13058. this.setEndWrapper = (el) => {
  13059. this.endWrapper = el;
  13060. this.setReferenceEl();
  13061. };
  13062. /**
  13063. * Event handler for when the selected date changes
  13064. */
  13065. this.handleDateChange = (event) => {
  13066. if (this.range) {
  13067. return;
  13068. }
  13069. this.value = dateToISO(event.detail);
  13070. };
  13071. this.handleDateRangeChange = (event) => {
  13072. var _a, _b;
  13073. if (!this.range || !event.detail) {
  13074. return;
  13075. }
  13076. const { startDate, endDate } = event.detail;
  13077. this.start = dateToISO(startDate);
  13078. this.end = dateToISO(endDate);
  13079. this.value = [this.start, this.end];
  13080. if (this.shouldFocusRangeEnd()) {
  13081. (_a = this.endInput) === null || _a === void 0 ? void 0 : _a.setFocus();
  13082. }
  13083. else if (this.shouldFocusRangeStart()) {
  13084. (_b = this.startInput) === null || _b === void 0 ? void 0 : _b.setFocus();
  13085. }
  13086. };
  13087. }
  13088. handleDisabledChange(value) {
  13089. if (!value) {
  13090. this.active = false;
  13091. }
  13092. }
  13093. valueHandler(value) {
  13094. if (Array.isArray(value)) {
  13095. this.valueAsDate = value.map((v) => dateFromISO(v));
  13096. this.start = value[0];
  13097. this.end = value[1];
  13098. }
  13099. else if (value) {
  13100. this.valueAsDate = dateFromISO(value);
  13101. this.start = "";
  13102. this.end = "";
  13103. }
  13104. else {
  13105. this.valueAsDate = undefined;
  13106. this.start = undefined;
  13107. this.end = undefined;
  13108. }
  13109. }
  13110. flipPlacementsHandler() {
  13111. this.setFilteredPlacements();
  13112. }
  13113. onMinChanged(min) {
  13114. if (min) {
  13115. this.minAsDate = dateFromISO(min);
  13116. }
  13117. }
  13118. onMaxChanged(max) {
  13119. if (max) {
  13120. this.maxAsDate = dateFromISO(max);
  13121. }
  13122. }
  13123. activeHandler() {
  13124. if (!this.disabled) {
  13125. this.reposition();
  13126. return;
  13127. }
  13128. this.active = false;
  13129. }
  13130. //--------------------------------------------------------------------------
  13131. //
  13132. // Event Listeners
  13133. //
  13134. //--------------------------------------------------------------------------
  13135. handleDateOrRangeChange() {
  13136. this.calciteInputDatePickerChange.emit();
  13137. }
  13138. calciteDaySelectHandler() {
  13139. if (this.shouldFocusRangeStart() || this.shouldFocusRangeEnd()) {
  13140. return;
  13141. }
  13142. this.active = false;
  13143. }
  13144. // --------------------------------------------------------------------------
  13145. //
  13146. // Public Methods
  13147. //
  13148. // --------------------------------------------------------------------------
  13149. /** Updates the position of the component. */
  13150. async setFocus() {
  13151. var _a;
  13152. (_a = this.startInput) === null || _a === void 0 ? void 0 : _a.setFocus();
  13153. }
  13154. /** Updates the position of the component. */
  13155. async reposition() {
  13156. const { placement, popper, menuEl } = this;
  13157. const modifiers = this.getModifiers();
  13158. popper
  13159. ? await updatePopper({
  13160. el: menuEl,
  13161. modifiers,
  13162. placement,
  13163. popper
  13164. })
  13165. : this.createPopper();
  13166. }
  13167. // --------------------------------------------------------------------------
  13168. //
  13169. // Lifecycle
  13170. //
  13171. // --------------------------------------------------------------------------
  13172. connectedCallback() {
  13173. if (Array.isArray(this.value)) {
  13174. this.valueAsDate = this.value.map((v) => dateFromISO(v));
  13175. this.start = this.value[0];
  13176. this.end = this.value[1];
  13177. }
  13178. else if (this.value) {
  13179. this.valueAsDate = dateFromISO(this.value);
  13180. this.start = "";
  13181. this.end = "";
  13182. }
  13183. if (this.start) {
  13184. this.startAsDate = dateFromISO(this.start);
  13185. }
  13186. if (this.end) {
  13187. this.endAsDate = dateFromISO(this.end);
  13188. }
  13189. if (this.min) {
  13190. this.minAsDate = dateFromISO(this.min);
  13191. }
  13192. if (this.max) {
  13193. this.maxAsDate = dateFromISO(this.max);
  13194. }
  13195. this.createPopper();
  13196. connectLabel(this);
  13197. connectForm(this);
  13198. this.setFilteredPlacements();
  13199. }
  13200. async componentWillLoad() {
  13201. await this.loadLocaleData();
  13202. this.onMinChanged(this.min);
  13203. this.onMaxChanged(this.max);
  13204. }
  13205. disconnectedCallback() {
  13206. this.destroyPopper();
  13207. disconnectLabel(this);
  13208. disconnectForm(this);
  13209. }
  13210. componentDidRender() {
  13211. updateHostInteraction(this);
  13212. }
  13213. render() {
  13214. var _a, _b;
  13215. const { disabled } = this;
  13216. const date = dateFromRange(this.range ? this.startAsDate : this.valueAsDate, this.minAsDate, this.maxAsDate);
  13217. const endDate = this.range
  13218. ? dateFromRange(this.endAsDate, this.minAsDate, this.maxAsDate)
  13219. : null;
  13220. const formattedEndDate = endDate ? endDate.toLocaleDateString(this.locale) : "";
  13221. const formattedDate = date ? date.toLocaleDateString(this.locale) : "";
  13222. 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: {
  13223. "menu-container": true,
  13224. "menu-container--active": this.active
  13225. }, ref: this.setMenuEl }, h("div", { class: {
  13226. ["calendar-picker-wrapper"]: true,
  13227. ["calendar-picker-wrapper--end"]: this.focusedInput === "end",
  13228. [CSS$D.animation]: true,
  13229. [CSS$D.animationActive]: this.active
  13230. }, 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: {
  13231. input: true,
  13232. "border-top-color-one": this.layout === "vertical" && this.range
  13233. }, 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 })));
  13234. }
  13235. setReferenceEl() {
  13236. const { focusedInput, layout, endWrapper, startWrapper } = this;
  13237. this.referenceEl =
  13238. focusedInput === "end" || layout === "vertical"
  13239. ? endWrapper || startWrapper
  13240. : startWrapper || endWrapper;
  13241. this.createPopper();
  13242. }
  13243. onLabelClick() {
  13244. this.setFocus();
  13245. }
  13246. getModifiers() {
  13247. const flipModifier = {
  13248. name: "flip",
  13249. enabled: true
  13250. };
  13251. flipModifier.options = {
  13252. fallbackPlacements: this.filteredFlipPlacements || popperMenuComputedPlacements
  13253. };
  13254. const eventListenerModifier = {
  13255. name: "eventListeners",
  13256. enabled: this.active
  13257. };
  13258. return [flipModifier, eventListenerModifier];
  13259. }
  13260. createPopper() {
  13261. this.destroyPopper();
  13262. const { menuEl, placement, referenceEl, overlayPositioning } = this;
  13263. if (!menuEl || !referenceEl) {
  13264. return;
  13265. }
  13266. const modifiers = this.getModifiers();
  13267. this.popper = createPopper({
  13268. el: menuEl,
  13269. modifiers,
  13270. overlayPositioning,
  13271. placement,
  13272. referenceEl
  13273. });
  13274. }
  13275. destroyPopper() {
  13276. const { popper } = this;
  13277. if (popper) {
  13278. popper.destroy();
  13279. }
  13280. this.popper = null;
  13281. }
  13282. startWatcher(start) {
  13283. this.startAsDate = dateFromISO(start);
  13284. }
  13285. endWatcher(end) {
  13286. this.endAsDate = dateFromISO(end);
  13287. }
  13288. async loadLocaleData() {
  13289. if (!Build.isBrowser) {
  13290. return;
  13291. }
  13292. const { locale } = this;
  13293. this.localeData = await getLocaleData(locale);
  13294. }
  13295. clearCurrentValue() {
  13296. if (!this.range) {
  13297. if (typeof this.value === "string" && this.value) {
  13298. this.calciteDatePickerChange.emit();
  13299. }
  13300. this.value = "";
  13301. return;
  13302. }
  13303. const { focusedInput } = this;
  13304. if (focusedInput === "start") {
  13305. if (this.start) {
  13306. this.calciteDatePickerRangeChange.emit();
  13307. }
  13308. this.value = Array.isArray(this.value) ? ["", this.value[1] || ""] : [""];
  13309. this.start = undefined;
  13310. }
  13311. else if (focusedInput === "end") {
  13312. if (this.end) {
  13313. this.calciteDatePickerRangeChange.emit();
  13314. }
  13315. this.value = Array.isArray(this.value) ? [this.value[0] || "", ""] : ["", ""];
  13316. this.end = undefined;
  13317. }
  13318. }
  13319. /**
  13320. * If inputted string is a valid date, update value/active
  13321. */
  13322. input(value) {
  13323. const date = this.getDateFromInput(value);
  13324. if (!date) {
  13325. this.clearCurrentValue();
  13326. return;
  13327. }
  13328. if (!this.range) {
  13329. this.value = dateToISO(date);
  13330. this.calciteDatePickerChange.emit(date);
  13331. return;
  13332. }
  13333. const { focusedInput } = this;
  13334. if (focusedInput === "start") {
  13335. if (!this.startAsDate || !sameDate(date, this.startAsDate)) {
  13336. const startDateISO = dateToISO(date);
  13337. this.value = Array.isArray(this.value)
  13338. ? [startDateISO, this.value[1] || ""]
  13339. : [startDateISO];
  13340. this.start = startDateISO;
  13341. this.calciteDatePickerRangeChange.emit({
  13342. startDate: date,
  13343. endDate: this.endAsDate
  13344. });
  13345. }
  13346. }
  13347. else if (focusedInput === "end") {
  13348. if (!this.endAsDate || !sameDate(date, this.endAsDate)) {
  13349. const endDateISO = dateToISO(date);
  13350. this.value = Array.isArray(this.value)
  13351. ? [this.value[0] || "", endDateISO]
  13352. : ["", endDateISO];
  13353. this.end = endDateISO;
  13354. this.calciteDatePickerRangeChange.emit({
  13355. startDate: this.startAsDate,
  13356. endDate: date
  13357. });
  13358. }
  13359. }
  13360. }
  13361. /**
  13362. * Clean up invalid date from input on blur
  13363. */
  13364. blur(target) {
  13365. const { locale, focusedInput, endAsDate, range, startAsDate, valueAsDate } = this;
  13366. const date = this.getDateFromInput(target.value);
  13367. if (!date) {
  13368. if (!range && valueAsDate) {
  13369. target.value = Array.isArray(valueAsDate)
  13370. ? valueAsDate[focusedInput === "end" ? 1 : 0].toLocaleDateString(locale)
  13371. : valueAsDate.toLocaleDateString(locale);
  13372. }
  13373. else if (focusedInput === "start" && startAsDate) {
  13374. target.value = startAsDate.toLocaleDateString(locale);
  13375. }
  13376. else if (focusedInput === "end" && endAsDate) {
  13377. target.value = endAsDate.toLocaleDateString(locale);
  13378. }
  13379. }
  13380. }
  13381. shouldFocusRangeStart() {
  13382. return !!(this.endAsDate &&
  13383. !this.startAsDate &&
  13384. this.focusedInput === "end" &&
  13385. this.startInput);
  13386. }
  13387. shouldFocusRangeEnd() {
  13388. return !!(this.startAsDate &&
  13389. !this.endAsDate &&
  13390. this.focusedInput === "start" &&
  13391. this.endInput);
  13392. }
  13393. /**
  13394. * Find a date from input string
  13395. * return false if date is invalid, or out of range
  13396. */
  13397. getDateFromInput(value) {
  13398. if (!this.localeData) {
  13399. return false;
  13400. }
  13401. const { separator } = this.localeData;
  13402. const { day, month, year } = parseDateString(value, this.localeData);
  13403. const validDay = day > 0;
  13404. const validMonth = month > -1;
  13405. const date = new Date(year, month, day);
  13406. date.setFullYear(year);
  13407. const validDate = !isNaN(date.getTime());
  13408. const validLength = value.split(separator).filter((c) => c).length > 2;
  13409. const validYear = year.toString().length > 0;
  13410. if (validDay &&
  13411. validMonth &&
  13412. validDate &&
  13413. validLength &&
  13414. validYear &&
  13415. inRange(date, this.min, this.max)) {
  13416. return date;
  13417. }
  13418. return false;
  13419. }
  13420. get el() { return this; }
  13421. static get watchers() { return {
  13422. "disabled": ["handleDisabledChange"],
  13423. "value": ["valueHandler"],
  13424. "flipPlacements": ["flipPlacementsHandler"],
  13425. "min": ["onMinChanged"],
  13426. "max": ["onMaxChanged"],
  13427. "active": ["activeHandler"],
  13428. "layout": ["setReferenceEl"],
  13429. "focusedInput": ["setReferenceEl"],
  13430. "start": ["startWatcher"],
  13431. "end": ["endWatcher"],
  13432. "locale": ["loadLocaleData"]
  13433. }; }
  13434. static get style() { return inputDatePickerCss; }
  13435. };
  13436. var StatusIconDefaults;
  13437. (function (StatusIconDefaults) {
  13438. StatusIconDefaults["valid"] = "check-circle";
  13439. StatusIconDefaults["invalid"] = "exclamation-mark-triangle";
  13440. StatusIconDefaults["idle"] = "information";
  13441. })(StatusIconDefaults || (StatusIconDefaults = {}));
  13442. 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}";
  13443. const InputMessage = class extends HTMLElement$1 {
  13444. constructor() {
  13445. super();
  13446. this.__registerHost();
  13447. this.__attachShadow();
  13448. //--------------------------------------------------------------------------
  13449. //
  13450. // Properties
  13451. //
  13452. //--------------------------------------------------------------------------
  13453. /** Indicates whether the message is displayed. */
  13454. this.active = false;
  13455. /** specify the scale of the input, defaults to m */
  13456. this.scale = "m";
  13457. /** specify the status of the input field, determines message and icons */
  13458. this.status = "idle";
  13459. }
  13460. handleIconEl() {
  13461. this.requestedIcon = setRequestedIcon(StatusIconDefaults, this.icon, this.status);
  13462. }
  13463. //--------------------------------------------------------------------------
  13464. //
  13465. // Lifecycle
  13466. //
  13467. //--------------------------------------------------------------------------
  13468. connectedCallback() {
  13469. this.status = getElementProp(this.el, "status", this.status);
  13470. this.scale = getElementProp(this.el, "scale", this.scale);
  13471. this.requestedIcon = setRequestedIcon(StatusIconDefaults, this.icon, this.status);
  13472. }
  13473. render() {
  13474. const hidden = !this.active;
  13475. return (h(Host, { "calcite-hydrated-hidden": hidden }, this.renderIcon(this.requestedIcon), h("slot", null)));
  13476. }
  13477. //--------------------------------------------------------------------------
  13478. //
  13479. // Private Methods
  13480. //
  13481. //--------------------------------------------------------------------------
  13482. renderIcon(iconName) {
  13483. if (iconName) {
  13484. return h("calcite-icon", { class: "calcite-input-message-icon", icon: iconName, scale: "s" });
  13485. }
  13486. }
  13487. get el() { return this; }
  13488. static get watchers() { return {
  13489. "status": ["handleIconEl"],
  13490. "icon": ["handleIconEl"]
  13491. }; }
  13492. static get style() { return inputMessageCss; }
  13493. };
  13494. const maxTenthForMinuteAndSecond = 5;
  13495. function createLocaleDateTimeFormatter(locale, includeSeconds = true) {
  13496. try {
  13497. const options = {
  13498. hour: "2-digit",
  13499. minute: "2-digit",
  13500. timeZone: "UTC"
  13501. };
  13502. if (includeSeconds) {
  13503. options.second = "2-digit";
  13504. }
  13505. return new Intl.DateTimeFormat(locale, options);
  13506. }
  13507. catch (e) {
  13508. throw new Error(`Invalid locale supplied while attempting to create a DateTime formatter: ${locale}`);
  13509. }
  13510. }
  13511. function formatTimePart(number) {
  13512. const numberAsString = number.toString();
  13513. return number >= 0 && number <= 9 ? numberAsString.padStart(2, "0") : numberAsString;
  13514. }
  13515. function formatTimeString(value) {
  13516. if (!isValidTime(value)) {
  13517. return null;
  13518. }
  13519. const [hourString, minuteString, secondString] = value.split(":");
  13520. const hour = formatTimePart(parseInt(hourString));
  13521. const minute = formatTimePart(parseInt(minuteString));
  13522. if (secondString) {
  13523. const second = formatTimePart(parseInt(secondString));
  13524. return `${hour}:${minute}:${second}`;
  13525. }
  13526. return `${hour}:${minute}`;
  13527. }
  13528. function getLocaleHourCycle(locale) {
  13529. const formatter = createLocaleDateTimeFormatter(locale);
  13530. const parts = formatter.formatToParts(new Date(Date.UTC(0, 0, 0, 0, 0, 0)));
  13531. return getLocalizedTimePart("meridiem", parts) ? "12" : "24";
  13532. }
  13533. function getLocalizedTimePart(part, parts) {
  13534. var _a, _b, _c, _d;
  13535. if (!part || !parts) {
  13536. return null;
  13537. }
  13538. if (part === "hourSuffix") {
  13539. const hourIndex = parts.indexOf(parts.find(({ type }) => type === "hour"));
  13540. const minuteIndex = parts.indexOf(parts.find(({ type }) => type === "minute"));
  13541. const hourSuffix = parts[hourIndex + 1];
  13542. return hourSuffix && hourSuffix.type === "literal" && minuteIndex - hourIndex === 2
  13543. ? ((_a = hourSuffix.value) === null || _a === void 0 ? void 0 : _a.trim()) || null
  13544. : null;
  13545. }
  13546. if (part === "minuteSuffix") {
  13547. const minuteIndex = parts.indexOf(parts.find(({ type }) => type === "minute"));
  13548. const secondIndex = parts.indexOf(parts.find(({ type }) => type === "second"));
  13549. const minuteSuffix = parts[minuteIndex + 1];
  13550. return minuteSuffix && minuteSuffix.type === "literal" && secondIndex - minuteIndex === 2
  13551. ? ((_b = minuteSuffix.value) === null || _b === void 0 ? void 0 : _b.trim()) || null
  13552. : null;
  13553. }
  13554. if (part === "secondSuffix") {
  13555. const secondIndex = parts.indexOf(parts.find(({ type }) => type === "second"));
  13556. const secondSuffix = parts[secondIndex + 1];
  13557. return secondSuffix && secondSuffix.type === "literal" ? ((_c = secondSuffix.value) === null || _c === void 0 ? void 0 : _c.trim()) || null : null;
  13558. }
  13559. return ((_d = parts.find(({ type }) => (part == "meridiem" ? type === "dayPeriod" : type === part))) === null || _d === void 0 ? void 0 : _d.value) || null;
  13560. }
  13561. function getMeridiem(hour) {
  13562. if (!isValidNumber(hour)) {
  13563. return null;
  13564. }
  13565. const hourAsNumber = parseInt(hour);
  13566. return hourAsNumber >= 0 && hourAsNumber <= 11 ? "AM" : "PM";
  13567. }
  13568. function isValidTime(value) {
  13569. if (!value || value.startsWith(":") || value.endsWith(":")) {
  13570. return false;
  13571. }
  13572. const splitValue = value.split(":");
  13573. const validLength = splitValue.length > 1 && splitValue.length < 4;
  13574. if (!validLength) {
  13575. return false;
  13576. }
  13577. const [hour, minute, second] = splitValue;
  13578. const hourAsNumber = parseInt(splitValue[0]);
  13579. const minuteAsNumber = parseInt(splitValue[1]);
  13580. const secondAsNumber = parseInt(splitValue[2]);
  13581. const hourValid = isValidNumber(hour) && hourAsNumber >= 0 && hourAsNumber < 24;
  13582. const minuteValid = isValidNumber(minute) && minuteAsNumber >= 0 && minuteAsNumber < 60;
  13583. const secondValid = isValidNumber(second) && secondAsNumber >= 0 && secondAsNumber < 60;
  13584. if ((hourValid && minuteValid && !second) || (hourValid && minuteValid && secondValid)) {
  13585. return true;
  13586. }
  13587. }
  13588. function isValidTimePart(value, part) {
  13589. if (part === "meridiem") {
  13590. return value === "AM" || value === "PM";
  13591. }
  13592. if (!isValidNumber(value)) {
  13593. return false;
  13594. }
  13595. const valueAsNumber = Number(value);
  13596. return part === "hour" ? valueAsNumber >= 0 && valueAsNumber < 24 : valueAsNumber >= 0 && valueAsNumber < 60;
  13597. }
  13598. function localizeTimePart(value, part, locale) {
  13599. if (!isValidTimePart(value, part)) {
  13600. return;
  13601. }
  13602. const valueAsNumber = parseInt(value);
  13603. 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));
  13604. if (!date) {
  13605. return;
  13606. }
  13607. const formatter = createLocaleDateTimeFormatter(locale);
  13608. const parts = formatter.formatToParts(date);
  13609. return getLocalizedTimePart(part, parts);
  13610. }
  13611. function localizeTimeString(value, locale = "en", includeSeconds = true) {
  13612. if (!isValidTime(value)) {
  13613. return null;
  13614. }
  13615. const { hour, minute, second = "0" } = parseTimeString(value);
  13616. const dateFromTimeString = new Date(Date.UTC(0, 0, 0, parseInt(hour), parseInt(minute), parseInt(second)));
  13617. const formatter = createLocaleDateTimeFormatter(locale, includeSeconds);
  13618. return (formatter === null || formatter === void 0 ? void 0 : formatter.format(dateFromTimeString)) || null;
  13619. }
  13620. function localizeTimeStringToParts(value, locale = "en") {
  13621. if (!isValidTime(value)) {
  13622. return null;
  13623. }
  13624. const { hour, minute, second = "0" } = parseTimeString(value);
  13625. const dateFromTimeString = new Date(Date.UTC(0, 0, 0, parseInt(hour), parseInt(minute), parseInt(second)));
  13626. if (dateFromTimeString) {
  13627. const formatter = createLocaleDateTimeFormatter(locale);
  13628. const parts = formatter.formatToParts(dateFromTimeString);
  13629. return {
  13630. localizedHour: getLocalizedTimePart("hour", parts),
  13631. localizedHourSuffix: getLocalizedTimePart("hourSuffix", parts),
  13632. localizedMinute: getLocalizedTimePart("minute", parts),
  13633. localizedMinuteSuffix: getLocalizedTimePart("minuteSuffix", parts),
  13634. localizedSecond: getLocalizedTimePart("second", parts),
  13635. localizedSecondSuffix: getLocalizedTimePart("secondSuffix", parts),
  13636. localizedMeridiem: getLocalizedTimePart("meridiem", parts)
  13637. };
  13638. }
  13639. return null;
  13640. }
  13641. function getTimeParts(value, locale = "en") {
  13642. if (!isValidTime(value)) {
  13643. return null;
  13644. }
  13645. const { hour, minute, second = "0" } = parseTimeString(value);
  13646. const dateFromTimeString = new Date(Date.UTC(0, 0, 0, parseInt(hour), parseInt(minute), parseInt(second)));
  13647. if (dateFromTimeString) {
  13648. const formatter = createLocaleDateTimeFormatter(locale);
  13649. const parts = formatter.formatToParts(dateFromTimeString);
  13650. return parts;
  13651. }
  13652. return null;
  13653. }
  13654. function parseTimeString(value) {
  13655. if (isValidTime(value)) {
  13656. const [hour, minute, second] = value.split(":");
  13657. return {
  13658. hour,
  13659. minute,
  13660. second
  13661. };
  13662. }
  13663. return {
  13664. hour: null,
  13665. minute: null,
  13666. second: null
  13667. };
  13668. }
  13669. 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}";
  13670. const InputTimePicker = class extends HTMLElement$1 {
  13671. constructor() {
  13672. super();
  13673. this.__registerHost();
  13674. this.__attachShadow();
  13675. this.calciteInputTimePickerChange = createEvent(this, "calciteInputTimePickerChange", 7);
  13676. //--------------------------------------------------------------------------
  13677. //
  13678. // Properties
  13679. //
  13680. //--------------------------------------------------------------------------
  13681. /** The active state of the time input */
  13682. this.active = false;
  13683. /** The disabled state of the time input */
  13684. this.disabled = false;
  13685. /**
  13686. * BCP 47 language tag for desired language and country format
  13687. * @internal
  13688. */
  13689. this.locale = document.documentElement.lang || navigator.language || "en";
  13690. /**
  13691. * When true, makes the component required for form-submission.
  13692. *
  13693. * @internal
  13694. */
  13695. this.required = false;
  13696. /** The scale (size) of the time input */
  13697. this.scale = "m";
  13698. /**
  13699. * Determines where the popover will be positioned relative to the input.
  13700. * @see [PopperPlacement](https://github.com/Esri/calcite-components/blob/master/src/utils/popper.ts#L25)
  13701. */
  13702. this.placement = "auto";
  13703. /** number (seconds) that specifies the granularity that the value must adhere to */
  13704. this.step = 60;
  13705. /** The selected time in UTC (always 24-hour format) */
  13706. this.value = null;
  13707. /** whether the value of the input was changed as a result of user typing or not */
  13708. this.internalValueChange = false;
  13709. this.previousValidValue = null;
  13710. this.referenceElementId = `input-time-picker-${guid()}`;
  13711. //--------------------------------------------------------------------------
  13712. //
  13713. // Event Listeners
  13714. //
  13715. //--------------------------------------------------------------------------
  13716. this.calciteInputBlurHandler = () => {
  13717. this.active = false;
  13718. const shouldIncludeSeconds = this.shouldIncludeSeconds();
  13719. const localizedInputValue = localizeTimeString(this.calciteInputEl.value, this.locale, shouldIncludeSeconds);
  13720. this.setInputValue(localizedInputValue || localizeTimeString(this.value, this.locale, shouldIncludeSeconds));
  13721. };
  13722. this.calciteInputFocusHandler = () => {
  13723. this.active = true;
  13724. };
  13725. this.calciteInputInputHandler = (event) => {
  13726. const target = event.target;
  13727. this.setValue({ value: target.value });
  13728. };
  13729. this.timePickerChangeHandler = (event) => {
  13730. event.stopPropagation();
  13731. const target = event.target;
  13732. const value = target.value;
  13733. this.setValue({ value, origin: "time-picker" });
  13734. };
  13735. // --------------------------------------------------------------------------
  13736. //
  13737. // Private Methods
  13738. //
  13739. // --------------------------------------------------------------------------
  13740. this.keyDownHandler = (event) => {
  13741. if (event.key === "Enter" && !event.defaultPrevented) {
  13742. submitForm(this);
  13743. }
  13744. };
  13745. this.setCalcitePopoverEl = (el) => {
  13746. this.popoverEl = el;
  13747. };
  13748. this.setCalciteInputEl = (el) => {
  13749. this.calciteInputEl = el;
  13750. };
  13751. this.setCalciteTimePickerEl = (el) => {
  13752. this.calciteTimePickerEl = el;
  13753. };
  13754. this.setInputValue = (newInputValue) => {
  13755. if (!this.calciteInputEl) {
  13756. return;
  13757. }
  13758. this.calciteInputEl.value = newInputValue;
  13759. };
  13760. this.setValue = ({ value, origin = "input" }) => {
  13761. const previousValue = this.value;
  13762. const newValue = formatTimeString(value);
  13763. const newLocalizedValue = localizeTimeString(newValue, this.locale, this.shouldIncludeSeconds());
  13764. this.internalValueChange = origin !== "external" && origin !== "loading";
  13765. const shouldEmit = origin !== "loading" &&
  13766. origin !== "external" &&
  13767. ((value !== this.previousValidValue && !value) ||
  13768. !!(!this.previousValidValue && newValue) ||
  13769. (newValue !== this.previousValidValue && newValue));
  13770. if (value) {
  13771. if (shouldEmit) {
  13772. this.previousValidValue = newValue;
  13773. }
  13774. if (newValue && newValue !== this.value) {
  13775. this.value = newValue;
  13776. }
  13777. this.localizedValue = newLocalizedValue;
  13778. }
  13779. else {
  13780. this.value = value;
  13781. this.localizedValue = null;
  13782. }
  13783. if (origin === "time-picker" || origin === "external") {
  13784. this.setInputValue(newLocalizedValue);
  13785. }
  13786. if (shouldEmit) {
  13787. const changeEvent = this.calciteInputTimePickerChange.emit();
  13788. if (changeEvent.defaultPrevented) {
  13789. this.internalValueChange = false;
  13790. this.value = previousValue;
  13791. this.setInputValue(previousValue);
  13792. this.previousValidValue = previousValue;
  13793. }
  13794. else {
  13795. this.previousValidValue = newValue;
  13796. }
  13797. }
  13798. };
  13799. }
  13800. activeHandler() {
  13801. if (this.disabled) {
  13802. this.active = false;
  13803. return;
  13804. }
  13805. this.reposition();
  13806. }
  13807. handleDisabledChange(value) {
  13808. if (!value) {
  13809. this.active = false;
  13810. }
  13811. }
  13812. localeWatcher(newLocale) {
  13813. this.setInputValue(localizeTimeString(this.value, newLocale, this.shouldIncludeSeconds()));
  13814. }
  13815. valueWatcher(newValue) {
  13816. if (!this.internalValueChange) {
  13817. this.setValue({ value: newValue, origin: "external" });
  13818. }
  13819. this.internalValueChange = false;
  13820. }
  13821. clickHandler(event) {
  13822. if (event.composedPath().includes(this.calciteTimePickerEl)) {
  13823. return;
  13824. }
  13825. this.setFocus();
  13826. }
  13827. keyUpHandler(event) {
  13828. if (event.key === "Escape" && this.active) {
  13829. this.active = false;
  13830. }
  13831. }
  13832. timePickerBlurHandler(event) {
  13833. event.preventDefault();
  13834. event.stopPropagation();
  13835. this.active = false;
  13836. }
  13837. timePickerFocusHandler(event) {
  13838. event.preventDefault();
  13839. event.stopPropagation();
  13840. this.active = true;
  13841. }
  13842. // --------------------------------------------------------------------------
  13843. //
  13844. // Public Methods
  13845. //
  13846. // --------------------------------------------------------------------------
  13847. /** Sets focus on the component. */
  13848. async setFocus() {
  13849. this.calciteInputEl.setFocus();
  13850. }
  13851. /** Updates the position of the component. */
  13852. async reposition() {
  13853. var _a;
  13854. (_a = this.popoverEl) === null || _a === void 0 ? void 0 : _a.reposition();
  13855. }
  13856. onLabelClick() {
  13857. this.setFocus();
  13858. }
  13859. shouldIncludeSeconds() {
  13860. return this.step < 60;
  13861. }
  13862. //--------------------------------------------------------------------------
  13863. //
  13864. // Lifecycle
  13865. //
  13866. //--------------------------------------------------------------------------
  13867. connectedCallback() {
  13868. if (this.value) {
  13869. this.setValue({ value: isValidTime(this.value) ? this.value : undefined, origin: "loading" });
  13870. }
  13871. connectLabel(this);
  13872. connectForm(this);
  13873. }
  13874. componentDidLoad() {
  13875. this.setInputValue(this.localizedValue);
  13876. }
  13877. disconnectedCallback() {
  13878. disconnectLabel(this);
  13879. disconnectForm(this);
  13880. }
  13881. componentDidRender() {
  13882. updateHostInteraction(this);
  13883. }
  13884. // --------------------------------------------------------------------------
  13885. //
  13886. // Render Methods
  13887. //
  13888. // --------------------------------------------------------------------------
  13889. render() {
  13890. const popoverId = `${this.referenceElementId}-popover`;
  13891. 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 })));
  13892. }
  13893. get el() { return this; }
  13894. static get watchers() { return {
  13895. "active": ["activeHandler"],
  13896. "disabled": ["handleDisabledChange"],
  13897. "locale": ["localeWatcher"],
  13898. "value": ["valueWatcher"]
  13899. }; }
  13900. static get style() { return inputTimePickerCss; }
  13901. };
  13902. const CSS$r = {
  13903. container: "container"
  13904. };
  13905. 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}";
  13906. const Label = class extends HTMLElement$1 {
  13907. constructor() {
  13908. super();
  13909. this.__registerHost();
  13910. this.__attachShadow();
  13911. this.calciteInternalLabelClick = createEvent(this, "calciteInternalLabelClick", 3);
  13912. //--------------------------------------------------------------------------
  13913. //
  13914. // Properties
  13915. //
  13916. //--------------------------------------------------------------------------
  13917. /** specify the text alignment of the label */
  13918. this.alignment = "start";
  13919. /**
  13920. * specify the status of the label and any child input / input messages
  13921. * @deprecated set directly on child element instead
  13922. */
  13923. this.status = "idle";
  13924. /** specify the scale of the label, defaults to m */
  13925. this.scale = "m";
  13926. /** is the wrapped element positioned inline with the label slotted text */
  13927. this.layout = "default";
  13928. /** eliminates any space around the label */
  13929. this.disableSpacing = false;
  13930. /**
  13931. * is the label disabled
  13932. *
  13933. * @deprecated use the `disabled` property on the interactive components instead
  13934. */
  13935. this.disabled = false;
  13936. //--------------------------------------------------------------------------
  13937. //
  13938. // Private Methods
  13939. //
  13940. //--------------------------------------------------------------------------
  13941. this.labelClickHandler = (event) => {
  13942. this.calciteInternalLabelClick.emit({
  13943. sourceEvent: event
  13944. });
  13945. };
  13946. }
  13947. //--------------------------------------------------------------------------
  13948. //
  13949. // Lifecycle
  13950. //
  13951. //--------------------------------------------------------------------------
  13952. connectedCallback() {
  13953. document.dispatchEvent(new CustomEvent(labelConnectedEvent));
  13954. }
  13955. disconnectedCallback() {
  13956. document.dispatchEvent(new CustomEvent(labelDisconnectedEvent));
  13957. }
  13958. render() {
  13959. return (h(Host, { onClick: this.labelClickHandler }, h("div", { class: CSS$r.container }, h("slot", null))));
  13960. }
  13961. get el() { return this; }
  13962. static get style() { return labelCss; }
  13963. };
  13964. 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}";
  13965. const Link = class extends HTMLElement$1 {
  13966. constructor() {
  13967. super();
  13968. this.__registerHost();
  13969. this.__attachShadow();
  13970. //--------------------------------------------------------------------------
  13971. //
  13972. // Properties
  13973. //
  13974. //--------------------------------------------------------------------------
  13975. /** is the link disabled */
  13976. this.disabled = false;
  13977. /** Prompts the user to save the linked URL instead of navigating to it. Can be used with or without a value:
  13978. * Without a value, the browser will suggest a filename/extension
  13979. * See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download
  13980. */
  13981. this.download = false;
  13982. //--------------------------------------------------------------------------
  13983. //
  13984. // Private Methods
  13985. //
  13986. //--------------------------------------------------------------------------
  13987. this.storeTagRef = (el) => {
  13988. this.childEl = el;
  13989. };
  13990. }
  13991. //--------------------------------------------------------------------------
  13992. //
  13993. // Lifecycle
  13994. //
  13995. //--------------------------------------------------------------------------
  13996. componentDidRender() {
  13997. updateHostInteraction(this);
  13998. }
  13999. render() {
  14000. const { download, el } = this;
  14001. const dir = getElementDir(el);
  14002. const childElType = this.href ? "a" : "span";
  14003. const iconStartEl = (h("calcite-icon", { class: "calcite-link--icon icon-start", flipRtl: this.iconFlipRtl === "start" || this.iconFlipRtl === "both", icon: this.iconStart, scale: "s" }));
  14004. const iconEndEl = (h("calcite-icon", { class: "calcite-link--icon icon-end", flipRtl: this.iconFlipRtl === "end" || this.iconFlipRtl === "both", icon: this.iconEnd, scale: "s" }));
  14005. const Tag = childElType;
  14006. const role = childElType === "span" ? "link" : null;
  14007. const tabIndex = childElType === "span" ? 0 : null;
  14008. return (h(Host, { role: "presentation" }, h(Tag, { class: { [CSS_UTILITY.rtl]: dir === "rtl" },
  14009. /*
  14010. When the 'download' property of type 'boolean | string' is set to true, the value is "".
  14011. This works around that issue for now.
  14012. */
  14013. 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)));
  14014. }
  14015. //--------------------------------------------------------------------------
  14016. //
  14017. // Public Methods
  14018. //
  14019. //--------------------------------------------------------------------------
  14020. /** Sets focus on the component. */
  14021. async setFocus() {
  14022. focusElement(this.childEl);
  14023. }
  14024. get el() { return this; }
  14025. static get style() { return linkCss; }
  14026. };
  14027. const CSS$q = {
  14028. container: "container"
  14029. };
  14030. 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)}";
  14031. const List$1 = class extends HTMLElement$1 {
  14032. constructor() {
  14033. super();
  14034. this.__registerHost();
  14035. this.__attachShadow();
  14036. // --------------------------------------------------------------------------
  14037. //
  14038. // Properties
  14039. //
  14040. // --------------------------------------------------------------------------
  14041. /**
  14042. * When true, disabled prevents user interaction.
  14043. */
  14044. this.disabled = false;
  14045. }
  14046. //--------------------------------------------------------------------------
  14047. //
  14048. // Lifecycle
  14049. //
  14050. //--------------------------------------------------------------------------
  14051. componentDidRender() {
  14052. updateHostInteraction(this);
  14053. }
  14054. // --------------------------------------------------------------------------
  14055. //
  14056. // Public Methods
  14057. //
  14058. // --------------------------------------------------------------------------
  14059. /** Sets focus on the component. */
  14060. async setFocus() {
  14061. const firstListItem = this.el.querySelector(`calcite-list-item:not([non-interactive])`);
  14062. firstListItem === null || firstListItem === void 0 ? void 0 : firstListItem.setFocus();
  14063. }
  14064. // --------------------------------------------------------------------------
  14065. //
  14066. // Render Methods
  14067. //
  14068. // --------------------------------------------------------------------------
  14069. render() {
  14070. return (h(Host, { role: "list" }, h("div", { class: CSS$q.container }, h("slot", null))));
  14071. }
  14072. get el() { return this; }
  14073. static get style() { return listCss; }
  14074. };
  14075. const CSS$p = {
  14076. container: "container",
  14077. contentContainer: "content-container",
  14078. nestedContainer: "nested-container",
  14079. contentContainerButton: "content-container--button",
  14080. content: "content",
  14081. actionsStart: "actions-start",
  14082. contentStart: "content-start",
  14083. label: "label",
  14084. description: "description",
  14085. contentEnd: "content-end",
  14086. actionsEnd: "actions-end",
  14087. hasCenterContent: "has-center-content"
  14088. };
  14089. const SLOTS$f = {
  14090. actionsStart: "actions-start",
  14091. contentStart: "content-start",
  14092. contentEnd: "content-end",
  14093. actionsEnd: "actions-end"
  14094. };
  14095. 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}";
  14096. const ListItem = class extends HTMLElement$1 {
  14097. constructor() {
  14098. super();
  14099. this.__registerHost();
  14100. this.__attachShadow();
  14101. // --------------------------------------------------------------------------
  14102. //
  14103. // Properties
  14104. //
  14105. // --------------------------------------------------------------------------
  14106. /**
  14107. * When true, prevents the content of the list item from user interaction.
  14108. */
  14109. this.nonInteractive = false;
  14110. /**
  14111. * When true, disabled prevents interaction.
  14112. */
  14113. this.disabled = false;
  14114. }
  14115. //--------------------------------------------------------------------------
  14116. //
  14117. // Lifecycle
  14118. //
  14119. //--------------------------------------------------------------------------
  14120. componentDidRender() {
  14121. updateHostInteraction(this);
  14122. }
  14123. // --------------------------------------------------------------------------
  14124. //
  14125. // Lifecycle
  14126. //
  14127. // --------------------------------------------------------------------------
  14128. connectedCallback() {
  14129. connectConditionalSlotComponent(this);
  14130. }
  14131. disconnectedCallback() {
  14132. disconnectConditionalSlotComponent(this);
  14133. }
  14134. // --------------------------------------------------------------------------
  14135. //
  14136. // Public Methods
  14137. //
  14138. // --------------------------------------------------------------------------
  14139. /** Sets focus on the component. */
  14140. async setFocus() {
  14141. var _a;
  14142. (_a = this.focusEl) === null || _a === void 0 ? void 0 : _a.focus();
  14143. }
  14144. // --------------------------------------------------------------------------
  14145. //
  14146. // Render Methods
  14147. //
  14148. // --------------------------------------------------------------------------
  14149. renderActionsStart() {
  14150. const { el } = this;
  14151. return getSlotted(el, SLOTS$f.actionsStart) ? (h("div", { class: CSS$p.actionsStart }, h("slot", { name: SLOTS$f.actionsStart }))) : null;
  14152. }
  14153. renderActionsEnd() {
  14154. const { el } = this;
  14155. return getSlotted(el, SLOTS$f.actionsEnd) ? (h("div", { class: CSS$p.actionsEnd }, h("slot", { name: SLOTS$f.actionsEnd }))) : null;
  14156. }
  14157. renderContentStart() {
  14158. const { el } = this;
  14159. return getSlotted(el, SLOTS$f.contentStart) ? (h("div", { class: CSS$p.contentStart }, h("slot", { name: SLOTS$f.contentStart }))) : null;
  14160. }
  14161. renderContentEnd() {
  14162. const { el } = this;
  14163. return getSlotted(el, SLOTS$f.contentEnd) ? (h("div", { class: CSS$p.contentEnd }, h("slot", { name: SLOTS$f.contentEnd }))) : null;
  14164. }
  14165. renderContent() {
  14166. const { label, description } = this;
  14167. 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;
  14168. }
  14169. renderContentContainer() {
  14170. const { description, disabled, label, nonInteractive } = this;
  14171. const hasCenterContent = !!label || !!description;
  14172. const content = [this.renderContentStart(), this.renderContent(), this.renderContentEnd()];
  14173. return !nonInteractive ? (h("button", { class: {
  14174. [CSS$p.contentContainer]: true,
  14175. [CSS$p.contentContainerButton]: true,
  14176. [CSS$p.hasCenterContent]: hasCenterContent
  14177. }, disabled: disabled, ref: (focusEl) => (this.focusEl = focusEl) }, content)) : (h("div", { class: { [CSS$p.contentContainer]: true, [CSS$p.hasCenterContent]: hasCenterContent }, ref: () => (this.focusEl = null) }, content));
  14178. }
  14179. render() {
  14180. 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))));
  14181. }
  14182. get el() { return this; }
  14183. static get style() { return listItemCss; }
  14184. };
  14185. const CSS$o = {
  14186. heading: "heading",
  14187. container: "container"
  14188. };
  14189. const HEADING_LEVEL$5 = 3;
  14190. 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}";
  14191. const ListItemGroup = class extends HTMLElement$1 {
  14192. constructor() {
  14193. super();
  14194. this.__registerHost();
  14195. this.__attachShadow();
  14196. }
  14197. // --------------------------------------------------------------------------
  14198. //
  14199. // Render Methods
  14200. //
  14201. // --------------------------------------------------------------------------
  14202. render() {
  14203. var _a;
  14204. const { el, heading, headingLevel } = this;
  14205. const parentLevel = (_a = el.closest("calcite-list, calcite-list-item-group")) === null || _a === void 0 ? void 0 : _a.headingLevel;
  14206. const relativeLevel = parentLevel ? constrainHeadingLevel(parentLevel + 1) : null;
  14207. const level = headingLevel || relativeLevel || HEADING_LEVEL$5;
  14208. 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))));
  14209. }
  14210. get el() { return this; }
  14211. static get style() { return listItemGroupCss; }
  14212. };
  14213. 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)}}";
  14214. const Loader = class extends HTMLElement$1 {
  14215. constructor() {
  14216. super();
  14217. this.__registerHost();
  14218. this.__attachShadow();
  14219. //--------------------------------------------------------------------------
  14220. //
  14221. // Properties
  14222. //
  14223. //--------------------------------------------------------------------------
  14224. /** Show the loader */
  14225. this.active = false;
  14226. /** Inline loaders are smaller and will appear to the left of the text */
  14227. this.inline = false;
  14228. /** Speficy the scale of the loader. Defaults to "m" */
  14229. this.scale = "m";
  14230. /** Percent complete of 100, only valid for determinate indicators */
  14231. this.value = 0;
  14232. /** Text which should appear under the loading indicator (optional) */
  14233. this.text = "";
  14234. /** Turn off spacing around the loader */
  14235. this.noPadding = false;
  14236. }
  14237. //--------------------------------------------------------------------------
  14238. //
  14239. // Lifecycle
  14240. //
  14241. //--------------------------------------------------------------------------
  14242. render() {
  14243. const { el, inline, label, scale, text, type, value } = this;
  14244. const id = el.id || guid();
  14245. const radiusRatio = 0.45;
  14246. const size = inline ? this.getInlineSize(scale) : this.getSize(scale);
  14247. const radius = size * radiusRatio;
  14248. const viewbox = `0 0 ${size} ${size}`;
  14249. const isDeterminate = type === "determinate";
  14250. const circumference = 2 * radius * Math.PI;
  14251. const progress = (value / 100) * circumference;
  14252. const remaining = circumference - progress;
  14253. const valueNow = Math.floor(value);
  14254. const hostAttributes = {
  14255. "aria-valuenow": valueNow,
  14256. "aria-valuemin": 0,
  14257. "aria-valuemax": 100,
  14258. complete: valueNow === 100
  14259. };
  14260. const svgAttributes = { r: radius, cx: size / 2, cy: size / 2 };
  14261. const determinateStyle = { "stroke-dasharray": `${progress} ${remaining}` };
  14262. 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)));
  14263. }
  14264. //--------------------------------------------------------------------------
  14265. //
  14266. // Private Methods
  14267. //
  14268. //--------------------------------------------------------------------------
  14269. /**
  14270. * Return the proper sizes based on the scale property
  14271. */
  14272. getSize(scale) {
  14273. return {
  14274. s: 32,
  14275. m: 56,
  14276. l: 80
  14277. }[scale];
  14278. }
  14279. getInlineSize(scale) {
  14280. return {
  14281. s: 12,
  14282. m: 16,
  14283. l: 20
  14284. }[scale];
  14285. }
  14286. get el() { return this; }
  14287. static get style() { return loaderCss; }
  14288. };
  14289. /**
  14290. * Traverses the slots of the open shadowroots and returns all children matching the query.
  14291. * @param {ShadowRoot | HTMLElement} root
  14292. * @param skipNode
  14293. * @param isMatch
  14294. * @param {number} maxDepth
  14295. * @param {number} depth
  14296. * @returns {HTMLElement[]}
  14297. */
  14298. function queryShadowRoot(root, skipNode, isMatch, maxDepth = 20, depth = 0) {
  14299. let matches = [];
  14300. // If the depth is above the max depth, abort the searching here.
  14301. if (depth >= maxDepth) {
  14302. return matches;
  14303. }
  14304. // Traverses a slot element
  14305. const traverseSlot = ($slot) => {
  14306. // Only check nodes that are of the type Node.ELEMENT_NODE
  14307. // Read more here https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
  14308. const assignedNodes = $slot.assignedNodes().filter(node => node.nodeType === 1);
  14309. if (assignedNodes.length > 0) {
  14310. return queryShadowRoot(assignedNodes[0].parentElement, skipNode, isMatch, maxDepth, depth + 1);
  14311. }
  14312. return [];
  14313. };
  14314. // Go through each child and continue the traversing if necessary
  14315. // Even though the typing says that children can't be undefined, Edge 15 sometimes gives an undefined value.
  14316. // Therefore we fallback to an empty array if it is undefined.
  14317. const children = Array.from(root.children || []);
  14318. for (const $child of children) {
  14319. // Check if the node and its descendants should be skipped
  14320. if (skipNode($child)) {
  14321. continue;
  14322. }
  14323. // If the child matches we always add it
  14324. if (isMatch($child)) {
  14325. matches.push($child);
  14326. }
  14327. if ($child.shadowRoot != null) {
  14328. matches.push(...queryShadowRoot($child.shadowRoot, skipNode, isMatch, maxDepth, depth + 1));
  14329. }
  14330. else if ($child.tagName === "SLOT") {
  14331. matches.push(...traverseSlot($child));
  14332. }
  14333. else {
  14334. matches.push(...queryShadowRoot($child, skipNode, isMatch, maxDepth, depth + 1));
  14335. }
  14336. }
  14337. return matches;
  14338. }
  14339. /**
  14340. * Returns whether the element is hidden.
  14341. * @param $elem
  14342. */
  14343. function isHidden($elem) {
  14344. return $elem.hasAttribute("hidden")
  14345. || ($elem.hasAttribute("aria-hidden") && $elem.getAttribute("aria-hidden") !== "false")
  14346. // A quick and dirty way to check whether the element is hidden.
  14347. // For a more fine-grained check we could use "window.getComputedStyle" but we don't because of bad performance.
  14348. // If the element has visibility set to "hidden" or "collapse", display set to "none" or opacity set to "0" through CSS
  14349. // we won't be able to catch it here. We accept it due to the huge performance benefits.
  14350. || $elem.style.display === `none`
  14351. || $elem.style.opacity === `0`
  14352. || $elem.style.visibility === `hidden`
  14353. || $elem.style.visibility === `collapse`;
  14354. // If offsetParent is null we can assume that the element is hidden
  14355. // https://stackoverflow.com/questions/306305/what-would-make-offsetparent-null
  14356. //|| $elem.offsetParent == null;
  14357. }
  14358. /**
  14359. * Returns whether the element is disabled.
  14360. * @param $elem
  14361. */
  14362. function isDisabled($elem) {
  14363. return $elem.hasAttribute("disabled")
  14364. || ($elem.hasAttribute("aria-disabled") && $elem.getAttribute("aria-disabled") !== "false");
  14365. }
  14366. /**
  14367. * Determines whether an element is focusable.
  14368. * Read more here: https://stackoverflow.com/questions/1599660/which-html-elements-can-receive-focus/1600194#1600194
  14369. * Or here: https://stackoverflow.com/questions/18261595/how-to-check-if-a-dom-element-is-focusable
  14370. * @param $elem
  14371. */
  14372. function isFocusable($elem) {
  14373. // Discard elements that are removed from the tab order.
  14374. if ($elem.getAttribute("tabindex") === "-1" || isHidden($elem) || isDisabled($elem)) {
  14375. return false;
  14376. }
  14377. return (
  14378. // At this point we know that the element can have focus (eg. won't be -1) if the tabindex attribute exists
  14379. $elem.hasAttribute("tabindex")
  14380. // Anchor tags or area tags with a href set
  14381. || ($elem instanceof HTMLAnchorElement || $elem instanceof HTMLAreaElement) && $elem.hasAttribute("href")
  14382. // Form elements which are not disabled
  14383. || ($elem instanceof HTMLButtonElement
  14384. || $elem instanceof HTMLInputElement
  14385. || $elem instanceof HTMLTextAreaElement
  14386. || $elem instanceof HTMLSelectElement)
  14387. // IFrames
  14388. || $elem instanceof HTMLIFrameElement);
  14389. }
  14390. const CSS$n = {
  14391. title: "title",
  14392. header: "header",
  14393. footer: "footer",
  14394. scrim: "scrim",
  14395. back: "back",
  14396. close: "close",
  14397. secondary: "secondary",
  14398. primary: "primary",
  14399. overflowHidden: "overflow-hidden"
  14400. };
  14401. const ICONS$6 = {
  14402. close: "x"
  14403. };
  14404. const SLOTS$e = {
  14405. content: "content",
  14406. header: "header",
  14407. back: "back",
  14408. secondary: "secondary",
  14409. primary: "primary"
  14410. };
  14411. const TEXT$b = {
  14412. close: "Close"
  14413. };
  14414. 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}}";
  14415. const isFocusableExtended = (el) => {
  14416. return isCalciteFocusable(el) || isFocusable(el);
  14417. };
  14418. const getFocusableElements = (el) => {
  14419. return queryShadowRoot(el, isHidden, isFocusableExtended);
  14420. };
  14421. const Modal = class extends HTMLElement$1 {
  14422. constructor() {
  14423. super();
  14424. this.__registerHost();
  14425. this.__attachShadow();
  14426. this.calciteModalOpen = createEvent(this, "calciteModalOpen", 7);
  14427. this.calciteModalClose = createEvent(this, "calciteModalClose", 7);
  14428. //--------------------------------------------------------------------------
  14429. //
  14430. // Properties
  14431. //
  14432. //--------------------------------------------------------------------------
  14433. /** Add the active attribute to open the modal */
  14434. this.active = false;
  14435. /** Optionally pass a function to run before close */
  14436. this.beforeClose = () => Promise.resolve();
  14437. /** Disables the display a close button within the Modal */
  14438. this.disableCloseButton = false;
  14439. /** Disables the closing of the Modal when clicked outside. */
  14440. this.disableOutsideClose = false;
  14441. /** Aria label for the close button */
  14442. this.intlClose = TEXT$b.close;
  14443. /** Flag to disable the default close on escape behavior */
  14444. this.disableEscape = false;
  14445. /** specify the scale of modal, defaults to m */
  14446. this.scale = "m";
  14447. /** Set the width of the modal. Can use stock sizes or pass a number (in pixels) */
  14448. this.width = "m";
  14449. /** Background color of modal content */
  14450. this.backgroundColor = "white";
  14451. /** Turn off spacing around the content area slot */
  14452. this.noPadding = false;
  14453. //--------------------------------------------------------------------------
  14454. //
  14455. // Variables
  14456. //
  14457. //--------------------------------------------------------------------------
  14458. this.hasFooter = true;
  14459. this.mutationObserver = createObserver("mutation", () => this.updateFooterVisibility());
  14460. this.activeTransitionProp = "opacity";
  14461. //--------------------------------------------------------------------------
  14462. //
  14463. // Private Methods
  14464. //
  14465. //--------------------------------------------------------------------------
  14466. this.transitionEnd = (event) => {
  14467. if (event.propertyName === this.activeTransitionProp) {
  14468. this.active ? this.calciteModalOpen.emit() : this.calciteModalClose.emit();
  14469. }
  14470. };
  14471. this.openEnd = () => {
  14472. this.setFocus();
  14473. this.el.removeEventListener("calciteModalOpen", this.openEnd);
  14474. };
  14475. this.handleOutsideClose = () => {
  14476. if (this.disableOutsideClose) {
  14477. return;
  14478. }
  14479. this.close();
  14480. };
  14481. /** Close the modal, first running the `beforeClose` method */
  14482. this.close = () => {
  14483. return this.beforeClose(this.el).then(() => {
  14484. this.active = false;
  14485. focusElement(this.previousActiveElement);
  14486. this.removeOverflowHiddenClass();
  14487. });
  14488. };
  14489. this.focusFirstElement = () => {
  14490. focusElement(this.disableCloseButton ? getFocusableElements(this.el)[0] : this.closeButtonEl);
  14491. };
  14492. this.focusLastElement = () => {
  14493. const focusableElements = getFocusableElements(this.el).filter((el) => !el.getAttribute("data-focus-fence"));
  14494. if (focusableElements.length > 0) {
  14495. focusElement(focusableElements[focusableElements.length - 1]);
  14496. }
  14497. else {
  14498. focusElement(this.closeButtonEl);
  14499. }
  14500. };
  14501. this.updateFooterVisibility = () => {
  14502. this.hasFooter = !!getSlotted(this.el, [SLOTS$e.back, SLOTS$e.primary, SLOTS$e.secondary]);
  14503. };
  14504. }
  14505. //--------------------------------------------------------------------------
  14506. //
  14507. // Lifecycle
  14508. //
  14509. //--------------------------------------------------------------------------
  14510. componentWillLoad() {
  14511. // when modal initially renders, if active was set we need to open as watcher doesn't fire
  14512. if (this.active) {
  14513. this.open();
  14514. }
  14515. }
  14516. connectedCallback() {
  14517. var _a;
  14518. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
  14519. this.updateFooterVisibility();
  14520. connectConditionalSlotComponent(this);
  14521. }
  14522. disconnectedCallback() {
  14523. var _a;
  14524. this.removeOverflowHiddenClass();
  14525. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  14526. disconnectConditionalSlotComponent(this);
  14527. }
  14528. render() {
  14529. 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: {
  14530. content: true,
  14531. "content--spaced": !this.noPadding,
  14532. "content--no-footer": !this.hasFooter
  14533. }, ref: (el) => (this.modalContent = el) }, h("slot", { name: SLOTS$e.content })), this.renderFooter(), h("div", { "data-focus-fence": true, onFocus: this.focusFirstElement, tabindex: "0" }))));
  14534. }
  14535. renderFooter() {
  14536. 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;
  14537. }
  14538. renderCloseButton() {
  14539. 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;
  14540. }
  14541. renderStyle() {
  14542. const hasCustomWidth = !isNaN(parseInt(`${this.width}`));
  14543. return hasCustomWidth ? (h("style", null, `
  14544. .modal {
  14545. max-width: ${this.width}px !important;
  14546. }
  14547. @media screen and (max-width: ${this.width}px) {
  14548. .modal {
  14549. height: 100% !important;
  14550. max-height: 100% !important;
  14551. width: 100% !important;
  14552. max-width: 100% !important;
  14553. margin: 0 !important;
  14554. border-radius: 0 !important;
  14555. }
  14556. .content {
  14557. flex: 1 1 auto !important;
  14558. max-height: unset !important;
  14559. }
  14560. }
  14561. `)) : null;
  14562. }
  14563. //--------------------------------------------------------------------------
  14564. //
  14565. // Event Listeners
  14566. //
  14567. //--------------------------------------------------------------------------
  14568. handleEscape(e) {
  14569. if (this.active && !this.disableEscape && e.key === "Escape") {
  14570. this.close();
  14571. }
  14572. }
  14573. //--------------------------------------------------------------------------
  14574. //
  14575. // Public Methods
  14576. //
  14577. //--------------------------------------------------------------------------
  14578. /**
  14579. * Focus first interactive element
  14580. * @deprecated use `setFocus` instead.
  14581. */
  14582. async focusElement(el) {
  14583. if (el) {
  14584. el.focus();
  14585. }
  14586. return this.setFocus();
  14587. }
  14588. /**
  14589. * Sets focus on the component.
  14590. *
  14591. * By default, will try to focus on any focusable content. If there is none, it will focus on the close button.
  14592. * If you want to focus on the close button, you can use the `close-button` focus ID.
  14593. */
  14594. async setFocus(focusId) {
  14595. const closeButton = this.closeButtonEl;
  14596. return focusElement(focusId === "close-button" ? closeButton : getFocusableElements(this.el)[0] || closeButton);
  14597. }
  14598. /** Set the scroll top of the modal content */
  14599. async scrollContent(top = 0, left = 0) {
  14600. if (this.modalContent) {
  14601. if (this.modalContent.scrollTo) {
  14602. this.modalContent.scrollTo({ top, left, behavior: "smooth" });
  14603. }
  14604. else {
  14605. this.modalContent.scrollTop = top;
  14606. this.modalContent.scrollLeft = left;
  14607. }
  14608. }
  14609. }
  14610. async toggleModal(value, oldValue) {
  14611. if (value !== oldValue) {
  14612. if (value) {
  14613. this.open();
  14614. }
  14615. else if (!value) {
  14616. this.close();
  14617. }
  14618. }
  14619. }
  14620. /** Open the modal */
  14621. open() {
  14622. this.previousActiveElement = document.activeElement;
  14623. this.el.addEventListener("calciteModalOpen", this.openEnd);
  14624. this.active = true;
  14625. const titleEl = getSlotted(this.el, SLOTS$e.header);
  14626. const contentEl = getSlotted(this.el, SLOTS$e.content);
  14627. this.titleId = ensureId(titleEl);
  14628. this.contentId = ensureId(contentEl);
  14629. document.documentElement.classList.add(CSS$n.overflowHidden);
  14630. }
  14631. removeOverflowHiddenClass() {
  14632. document.documentElement.classList.remove(CSS$n.overflowHidden);
  14633. }
  14634. get el() { return this; }
  14635. static get watchers() { return {
  14636. "active": ["toggleModal"]
  14637. }; }
  14638. static get style() { return modalCss; }
  14639. };
  14640. const TEXT$a = {
  14641. close: "Close"
  14642. };
  14643. const SLOTS$d = {
  14644. title: "title",
  14645. message: "message",
  14646. link: "link",
  14647. actionsEnd: "actions-end"
  14648. };
  14649. const CSS$m = {
  14650. actionsEnd: "actions-end",
  14651. close: "notice-close",
  14652. container: "container",
  14653. content: "notice-content",
  14654. icon: "notice-icon"
  14655. };
  14656. 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)}";
  14657. const Notice = class extends HTMLElement$1 {
  14658. constructor() {
  14659. super();
  14660. this.__registerHost();
  14661. this.__attachShadow();
  14662. this.calciteNoticeClose = createEvent(this, "calciteNoticeClose", 7);
  14663. this.calciteNoticeOpen = createEvent(this, "calciteNoticeOpen", 7);
  14664. //--------------------------------------------------------------------------
  14665. //
  14666. // Properties
  14667. //
  14668. //---------------------------------------------------------------------------
  14669. /** Is the notice currently active or not */
  14670. this.active = false;
  14671. /** Color for the notice (will apply to top border and icon) */
  14672. this.color = "blue";
  14673. /** Optionally show a button the user can click to dismiss the notice */
  14674. this.dismissible = false;
  14675. /** String for the close button.
  14676. * @default "Close"
  14677. */
  14678. this.intlClose = TEXT$a.close;
  14679. /** specify the scale of the notice, defaults to m */
  14680. this.scale = "m";
  14681. /** specify the width of the notice, defaults to auto */
  14682. this.width = "auto";
  14683. //--------------------------------------------------------------------------
  14684. //
  14685. // Private Methods
  14686. //
  14687. //--------------------------------------------------------------------------
  14688. this.close = () => {
  14689. this.active = false;
  14690. this.calciteNoticeClose.emit();
  14691. };
  14692. }
  14693. updateRequestedIcon() {
  14694. this.requestedIcon = setRequestedIcon(StatusIcons, this.icon, this.color);
  14695. }
  14696. //--------------------------------------------------------------------------
  14697. //
  14698. // Lifecycle
  14699. //
  14700. //--------------------------------------------------------------------------
  14701. connectedCallback() {
  14702. connectConditionalSlotComponent(this);
  14703. }
  14704. disconnectedCallback() {
  14705. disconnectConditionalSlotComponent(this);
  14706. }
  14707. componentWillLoad() {
  14708. this.requestedIcon = setRequestedIcon(StatusIcons, this.icon, this.color);
  14709. }
  14710. render() {
  14711. const { el } = this;
  14712. 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" })));
  14713. const hasActionEnd = getSlotted(el, SLOTS$d.actionsEnd);
  14714. 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));
  14715. }
  14716. //--------------------------------------------------------------------------
  14717. //
  14718. // Public Methods
  14719. //
  14720. //--------------------------------------------------------------------------
  14721. /** Sets focus on the component. */
  14722. async setFocus() {
  14723. const noticeLinkEl = this.el.querySelector("calcite-link");
  14724. if (!this.closeButton && !noticeLinkEl) {
  14725. return;
  14726. }
  14727. if (noticeLinkEl) {
  14728. noticeLinkEl.setFocus();
  14729. }
  14730. else if (this.closeButton) {
  14731. this.closeButton.focus();
  14732. }
  14733. }
  14734. get el() { return this; }
  14735. static get watchers() { return {
  14736. "icon": ["updateRequestedIcon"],
  14737. "color": ["updateRequestedIcon"]
  14738. }; }
  14739. static get style() { return noticeCss; }
  14740. };
  14741. 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}";
  14742. const Option = class extends HTMLElement$1 {
  14743. constructor() {
  14744. super();
  14745. this.__registerHost();
  14746. this.__attachShadow();
  14747. this.calciteOptionChange = createEvent(this, "calciteOptionChange", 7);
  14748. //--------------------------------------------------------------------------
  14749. //
  14750. // Properties
  14751. //
  14752. //--------------------------------------------------------------------------
  14753. /**
  14754. * When true, it prevents the option from being selected.
  14755. */
  14756. this.disabled = false;
  14757. this.mutationObserver = createObserver("mutation", () => {
  14758. this.ensureTextContentDependentProps();
  14759. this.calciteOptionChange.emit();
  14760. });
  14761. }
  14762. handlePropChange(_newValue, _oldValue, propName) {
  14763. if (propName === "label" || propName === "value") {
  14764. this.ensureTextContentDependentProps();
  14765. }
  14766. this.calciteOptionChange.emit();
  14767. }
  14768. //--------------------------------------------------------------------------
  14769. //
  14770. // Private Methods
  14771. //
  14772. //--------------------------------------------------------------------------
  14773. ensureTextContentDependentProps() {
  14774. const { el: { textContent } } = this;
  14775. if (!this.label || this.label === this.internallySetLabel) {
  14776. this.label = textContent;
  14777. this.internallySetLabel = textContent;
  14778. }
  14779. if (!this.value || this.value === this.internallySetValue) {
  14780. this.value = textContent;
  14781. this.internallySetValue = textContent;
  14782. }
  14783. }
  14784. //--------------------------------------------------------------------------
  14785. //
  14786. // Lifecycle
  14787. //
  14788. //--------------------------------------------------------------------------
  14789. connectedCallback() {
  14790. var _a;
  14791. this.ensureTextContentDependentProps();
  14792. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, {
  14793. attributeFilter: ["label", "value"],
  14794. characterData: true,
  14795. childList: true,
  14796. subtree: true
  14797. });
  14798. }
  14799. disconnectedCallback() {
  14800. var _a;
  14801. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  14802. }
  14803. //--------------------------------------------------------------------------
  14804. //
  14805. // Render Methods
  14806. //
  14807. //--------------------------------------------------------------------------
  14808. render() {
  14809. return h("slot", null, this.label);
  14810. }
  14811. get el() { return this; }
  14812. static get watchers() { return {
  14813. "disabled": ["handlePropChange"],
  14814. "label": ["handlePropChange"],
  14815. "selected": ["handlePropChange"],
  14816. "value": ["handlePropChange"]
  14817. }; }
  14818. static get style() { return optionCss; }
  14819. };
  14820. 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}";
  14821. const OptionGroup = class extends HTMLElement$1 {
  14822. constructor() {
  14823. super();
  14824. this.__registerHost();
  14825. this.__attachShadow();
  14826. this.calciteOptionGroupChange = createEvent(this, "calciteOptionGroupChange", 7);
  14827. //--------------------------------------------------------------------------
  14828. //
  14829. // Properties
  14830. //
  14831. //--------------------------------------------------------------------------
  14832. /**
  14833. * When true, it prevents selection from any of its associated options.
  14834. */
  14835. this.disabled = false;
  14836. }
  14837. handlePropChange() {
  14838. this.calciteOptionGroupChange.emit();
  14839. }
  14840. //--------------------------------------------------------------------------
  14841. //
  14842. // Render Methods
  14843. //
  14844. //--------------------------------------------------------------------------
  14845. render() {
  14846. return (h(Fragment, null, h("div", null, this.label), h("slot", null)));
  14847. }
  14848. static get watchers() { return {
  14849. "disabled": ["handlePropChange"],
  14850. "label": ["handlePropChange"]
  14851. }; }
  14852. static get style() { return optionGroupCss; }
  14853. };
  14854. const CSS$l = {
  14855. page: "page",
  14856. selected: "is-selected",
  14857. previous: "previous",
  14858. next: "next",
  14859. disabled: "is-disabled",
  14860. ellipsis: "ellipsis",
  14861. ellipsisStart: "ellipsis--start",
  14862. ellipsisEnd: "ellipsis--end"
  14863. };
  14864. const TEXT$9 = {
  14865. nextLabel: "Next",
  14866. previousLabel: "Previous"
  14867. };
  14868. 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)}";
  14869. const maxPagesDisplayed = 5;
  14870. const Pagination = class extends HTMLElement$1 {
  14871. constructor() {
  14872. super();
  14873. this.__registerHost();
  14874. this.__attachShadow();
  14875. this.calcitePaginationUpdate = createEvent(this, "calcitePaginationUpdate", 7);
  14876. this.calcitePaginationChange = createEvent(this, "calcitePaginationChange", 7);
  14877. //--------------------------------------------------------------------------
  14878. //
  14879. // Public Properties
  14880. //
  14881. //--------------------------------------------------------------------------
  14882. /** number of items per page */
  14883. this.num = 20;
  14884. /** index of item that should begin the page */
  14885. this.start = 1;
  14886. /** total number of items */
  14887. this.total = 0;
  14888. /** Used as an accessible label (aria-label) for the next button
  14889. * @default "Next"
  14890. */
  14891. this.textLabelNext = TEXT$9.nextLabel;
  14892. /** Used as an accessible label (aria-label) of the previous button
  14893. * @default "Previous"
  14894. */
  14895. this.textLabelPrevious = TEXT$9.previousLabel;
  14896. /** The scale of the pagination */
  14897. this.scale = "m";
  14898. this.previousClicked = () => {
  14899. this.previousPage().then();
  14900. this.emitUpdate();
  14901. };
  14902. this.nextClicked = () => {
  14903. this.nextPage();
  14904. this.emitUpdate();
  14905. };
  14906. }
  14907. // --------------------------------------------------------------------------
  14908. //
  14909. // Public Methods
  14910. //
  14911. // --------------------------------------------------------------------------
  14912. /** Go to the next page of results */
  14913. async nextPage() {
  14914. this.start = Math.min(this.getLastStart(), this.start + this.num);
  14915. }
  14916. /** Go to the previous page of results */
  14917. async previousPage() {
  14918. this.start = Math.max(1, this.start - this.num);
  14919. }
  14920. // --------------------------------------------------------------------------
  14921. //
  14922. // Private Methods
  14923. //
  14924. // --------------------------------------------------------------------------
  14925. getLastStart() {
  14926. const { total, num } = this;
  14927. const lastStart = total % num === 0 ? total - num : Math.floor(total / num) * num;
  14928. return lastStart + 1;
  14929. }
  14930. showLeftEllipsis() {
  14931. return Math.floor(this.start / this.num) > 3;
  14932. }
  14933. showRightEllipsis() {
  14934. return (this.total - this.start) / this.num > 3;
  14935. }
  14936. emitUpdate() {
  14937. const changePayload = {
  14938. start: this.start,
  14939. total: this.total,
  14940. num: this.num
  14941. };
  14942. this.calcitePaginationChange.emit(changePayload);
  14943. this.calcitePaginationUpdate.emit(changePayload);
  14944. }
  14945. //--------------------------------------------------------------------------
  14946. //
  14947. // Render Methods
  14948. //
  14949. //--------------------------------------------------------------------------
  14950. renderPages() {
  14951. const lastStart = this.getLastStart();
  14952. let end;
  14953. let nextStart;
  14954. // if we don't need ellipses render the whole set
  14955. if (this.total / this.num <= maxPagesDisplayed) {
  14956. nextStart = 1 + this.num;
  14957. end = lastStart - this.num;
  14958. }
  14959. else {
  14960. // if we're within max pages of page 1
  14961. if (this.start / this.num < maxPagesDisplayed - 1) {
  14962. nextStart = 1 + this.num;
  14963. end = 1 + 4 * this.num;
  14964. }
  14965. else {
  14966. // if we're within max pages of last page
  14967. if (this.start + 3 * this.num >= this.total) {
  14968. nextStart = lastStart - 4 * this.num;
  14969. end = lastStart - this.num;
  14970. }
  14971. else {
  14972. nextStart = this.start - this.num;
  14973. end = this.start + this.num;
  14974. }
  14975. }
  14976. }
  14977. const pages = [];
  14978. while (nextStart <= end) {
  14979. pages.push(nextStart);
  14980. nextStart = nextStart + this.num;
  14981. }
  14982. return pages.map((page) => this.renderPage(page));
  14983. }
  14984. renderPage(start) {
  14985. const page = Math.floor(start / this.num) + (this.num === 1 ? 0 : 1);
  14986. return (h("button", { class: {
  14987. [CSS$l.page]: true,
  14988. [CSS$l.selected]: start === this.start
  14989. }, onClick: () => {
  14990. this.start = start;
  14991. this.emitUpdate();
  14992. } }, page));
  14993. }
  14994. renderLeftEllipsis() {
  14995. if (this.total / this.num > maxPagesDisplayed && this.showLeftEllipsis()) {
  14996. return h("span", { class: `${CSS$l.ellipsis} ${CSS$l.ellipsisStart}` }, "\u2026");
  14997. }
  14998. }
  14999. renderRightEllipsis() {
  15000. if (this.total / this.num > maxPagesDisplayed && this.showRightEllipsis()) {
  15001. return h("span", { class: `${CSS$l.ellipsis} ${CSS$l.ellipsisEnd}` }, "\u2026");
  15002. }
  15003. }
  15004. render() {
  15005. const { total, num, start } = this;
  15006. const prevDisabled = num === 1 ? start <= num : start < num;
  15007. const nextDisabled = num === 1 ? start + num > total : start + num > total;
  15008. return (h(Fragment, null, h("button", { "aria-label": this.textLabelPrevious, class: {
  15009. [CSS$l.previous]: true,
  15010. [CSS$l.disabled]: prevDisabled
  15011. }, 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: {
  15012. [CSS$l.next]: true,
  15013. [CSS$l.disabled]: nextDisabled
  15014. }, disabled: nextDisabled, onClick: this.nextClicked }, h("calcite-icon", { flipRtl: true, icon: "chevronRight", scale: "s" }))));
  15015. }
  15016. get el() { return this; }
  15017. static get style() { return paginationCss; }
  15018. };
  15019. const CSS$k = {
  15020. backButton: "back-button",
  15021. container: "container",
  15022. header: "header",
  15023. heading: "heading",
  15024. summary: "summary",
  15025. headerContent: "header-content",
  15026. headerActions: "header-actions",
  15027. headerActionsEnd: "header-actions--end",
  15028. headerActionsStart: "header-actions--start",
  15029. contentWrapper: "content-wrapper",
  15030. contentContainer: "content-container",
  15031. contentHeight: "content-height",
  15032. fabContainer: "fab-container",
  15033. footer: "footer",
  15034. menuContainer: "menu-container",
  15035. menuButton: "menu-button",
  15036. menu: "menu",
  15037. menuOpen: "menu--open"
  15038. };
  15039. const ICONS$5 = {
  15040. close: "x",
  15041. menu: "ellipsis",
  15042. backLeft: "chevron-left",
  15043. backRight: "chevron-right"
  15044. };
  15045. const SLOTS$c = {
  15046. headerActionsStart: "header-actions-start",
  15047. headerActionsEnd: "header-actions-end",
  15048. headerMenuActions: "header-menu-actions",
  15049. headerContent: "header-content",
  15050. fab: "fab",
  15051. footer: "footer",
  15052. footerActions: "footer-actions"
  15053. };
  15054. const TEXT$8 = {
  15055. back: "Back",
  15056. close: "Close",
  15057. open: "Open",
  15058. options: "Options"
  15059. };
  15060. const HEADING_LEVEL$4 = 3;
  15061. 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}";
  15062. const Panel = class extends HTMLElement$1 {
  15063. constructor() {
  15064. super();
  15065. this.__registerHost();
  15066. this.__attachShadow();
  15067. this.calcitePanelDismiss = createEvent(this, "calcitePanelDismiss", 7);
  15068. this.calcitePanelDismissedChange = createEvent(this, "calcitePanelDismissedChange", 7);
  15069. this.calcitePanelScroll = createEvent(this, "calcitePanelScroll", 7);
  15070. this.calcitePanelBackClick = createEvent(this, "calcitePanelBackClick", 7);
  15071. // --------------------------------------------------------------------------
  15072. //
  15073. // Properties
  15074. //
  15075. // --------------------------------------------------------------------------
  15076. /**
  15077. * Hides the panel.
  15078. */
  15079. this.dismissed = false;
  15080. /**
  15081. * When true, disabled prevents interaction. This state shows items with lower opacity/grayed.
  15082. */
  15083. this.disabled = false;
  15084. /**
  15085. * Displays a close button in the trailing side of the header.
  15086. */
  15087. this.dismissible = false;
  15088. /**
  15089. * Shows a back button in the header.
  15090. */
  15091. this.showBackButton = false;
  15092. /**
  15093. * When true, content is waiting to be loaded. This state shows a busy indicator.
  15094. */
  15095. this.loading = false;
  15096. /**
  15097. * Opens the action menu.
  15098. */
  15099. this.menuOpen = false;
  15100. this.resizeObserver = createObserver("resize", () => this.resizeHandler());
  15101. // --------------------------------------------------------------------------
  15102. //
  15103. // Private Methods
  15104. //
  15105. // --------------------------------------------------------------------------
  15106. this.resizeHandler = () => {
  15107. const { panelScrollEl } = this;
  15108. if (!panelScrollEl ||
  15109. typeof panelScrollEl.scrollHeight !== "number" ||
  15110. typeof panelScrollEl.offsetHeight !== "number") {
  15111. return;
  15112. }
  15113. panelScrollEl.tabIndex = panelScrollEl.scrollHeight > panelScrollEl.offsetHeight ? 0 : -1;
  15114. };
  15115. this.setContainerRef = (node) => {
  15116. this.containerEl = node;
  15117. };
  15118. this.setDismissRef = (node) => {
  15119. this.dismissButtonEl = node;
  15120. };
  15121. this.setBackRef = (node) => {
  15122. this.backButtonEl = node;
  15123. };
  15124. this.panelKeyDownHandler = (event) => {
  15125. if (event.key === "Escape") {
  15126. this.dismiss();
  15127. }
  15128. };
  15129. this.dismiss = () => {
  15130. this.dismissed = true;
  15131. this.calcitePanelDismiss.emit();
  15132. };
  15133. this.panelScrollHandler = () => {
  15134. this.calcitePanelScroll.emit();
  15135. };
  15136. this.backButtonClick = () => {
  15137. this.calcitePanelBackClick.emit();
  15138. };
  15139. this.setPanelScrollEl = (el) => {
  15140. var _a, _b;
  15141. this.panelScrollEl = el;
  15142. (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  15143. if (el) {
  15144. (_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.observe(el);
  15145. this.resizeHandler();
  15146. }
  15147. };
  15148. }
  15149. dismissedHandler() {
  15150. this.calcitePanelDismissedChange.emit();
  15151. }
  15152. //--------------------------------------------------------------------------
  15153. //
  15154. // Lifecycle
  15155. //
  15156. //--------------------------------------------------------------------------
  15157. componentDidRender() {
  15158. updateHostInteraction(this);
  15159. }
  15160. // --------------------------------------------------------------------------
  15161. //
  15162. // Lifecycle
  15163. //
  15164. // --------------------------------------------------------------------------
  15165. connectedCallback() {
  15166. connectConditionalSlotComponent(this);
  15167. }
  15168. disconnectedCallback() {
  15169. var _a;
  15170. disconnectConditionalSlotComponent(this);
  15171. (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  15172. }
  15173. // --------------------------------------------------------------------------
  15174. //
  15175. // Methods
  15176. //
  15177. // --------------------------------------------------------------------------
  15178. /** Sets focus on the component. */
  15179. async setFocus(focusId) {
  15180. var _a, _b, _c;
  15181. if (focusId === "dismiss-button") {
  15182. (_a = this.dismissButtonEl) === null || _a === void 0 ? void 0 : _a.setFocus();
  15183. return;
  15184. }
  15185. if (focusId === "back-button") {
  15186. (_b = this.backButtonEl) === null || _b === void 0 ? void 0 : _b.setFocus();
  15187. return;
  15188. }
  15189. (_c = this.containerEl) === null || _c === void 0 ? void 0 : _c.focus();
  15190. }
  15191. /** Scrolls panel content to a particular set of coordinates.
  15192. *
  15193. * ```
  15194. * myCalcitePanel.scrollContentTo({
  15195. * left: 0, // Specifies the number of pixels along the X axis to scroll the window or element.
  15196. * top: 0, // Specifies the number of pixels along the Y axis to scroll the window or element
  15197. * behavior: "auto" // Specifies whether the scrolling should animate smoothly (smooth), or happen instantly in a single jump (auto, the default value).
  15198. * });
  15199. * ```
  15200. */
  15201. async scrollContentTo(options) {
  15202. var _a;
  15203. (_a = this.panelScrollEl) === null || _a === void 0 ? void 0 : _a.scrollTo(options);
  15204. }
  15205. // --------------------------------------------------------------------------
  15206. //
  15207. // Render Methods
  15208. //
  15209. // --------------------------------------------------------------------------
  15210. renderBackButton() {
  15211. const { el } = this;
  15212. const rtl = getElementDir(el) === "rtl";
  15213. const { showBackButton, intlBack, backButtonClick } = this;
  15214. const label = intlBack || TEXT$8.back;
  15215. const icon = rtl ? ICONS$5.backRight : ICONS$5.backLeft;
  15216. 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;
  15217. }
  15218. renderHeaderContent() {
  15219. const { heading, headingLevel, summary } = this;
  15220. const headingNode = heading ? (h(Heading, { class: CSS$k.heading, level: headingLevel || HEADING_LEVEL$4 }, heading)) : null;
  15221. const summaryNode = summary ? h("span", { class: CSS$k.summary }, summary) : null;
  15222. return headingNode || summaryNode ? (h("div", { class: CSS$k.headerContent, key: "header-content" }, headingNode, summaryNode)) : null;
  15223. }
  15224. /**
  15225. * Allows user to override the entire header-content node.
  15226. */
  15227. renderHeaderSlottedContent() {
  15228. return (h("div", { class: CSS$k.headerContent, key: "slotted-header-content" }, h("slot", { name: SLOTS$c.headerContent })));
  15229. }
  15230. renderHeaderStartActions() {
  15231. const { el } = this;
  15232. const hasStartActions = getSlotted(el, SLOTS$c.headerActionsStart);
  15233. return hasStartActions ? (h("div", { class: { [CSS$k.headerActionsStart]: true, [CSS$k.headerActions]: true }, key: "header-actions-start" }, h("slot", { name: SLOTS$c.headerActionsStart }))) : null;
  15234. }
  15235. renderHeaderActionsEnd() {
  15236. const { dismiss, dismissible, el, intlClose } = this;
  15237. const text = intlClose || TEXT$8.close;
  15238. const dismissibleNode = dismissible ? (h("calcite-action", { "aria-label": text, icon: ICONS$5.close, onClick: dismiss, ref: this.setDismissRef, text: text })) : null;
  15239. const slotNode = h("slot", { name: SLOTS$c.headerActionsEnd });
  15240. const hasEndActions = getSlotted(el, SLOTS$c.headerActionsEnd);
  15241. return hasEndActions || dismissibleNode ? (h("div", { class: { [CSS$k.headerActionsEnd]: true, [CSS$k.headerActions]: true }, key: "header-actions-end" }, slotNode, dismissibleNode)) : null;
  15242. }
  15243. renderMenu() {
  15244. const { el, intlOptions, menuOpen } = this;
  15245. const hasMenuItems = getSlotted(el, SLOTS$c.headerMenuActions);
  15246. 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;
  15247. }
  15248. renderHeaderNode() {
  15249. const { el, showBackButton } = this;
  15250. const backButtonNode = this.renderBackButton();
  15251. const hasHeaderSlottedContent = getSlotted(el, SLOTS$c.headerContent);
  15252. const headerContentNode = hasHeaderSlottedContent
  15253. ? this.renderHeaderSlottedContent()
  15254. : this.renderHeaderContent();
  15255. const actionsNodeStart = this.renderHeaderStartActions();
  15256. const actionsNodeEnd = this.renderHeaderActionsEnd();
  15257. const headerMenuNode = this.renderMenu();
  15258. return actionsNodeStart ||
  15259. headerContentNode ||
  15260. actionsNodeEnd ||
  15261. headerMenuNode ||
  15262. showBackButton ? (h("header", { class: CSS$k.header }, backButtonNode, actionsNodeStart, headerContentNode, actionsNodeEnd, headerMenuNode)) : null;
  15263. }
  15264. renderFooterNode() {
  15265. const { el } = this;
  15266. const hasFooterSlottedContent = getSlotted(el, SLOTS$c.footer);
  15267. const hasFooterActions = getSlotted(el, SLOTS$c.footerActions);
  15268. 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;
  15269. }
  15270. renderContent() {
  15271. const { el } = this;
  15272. const hasFab = getSlotted(el, SLOTS$c.fab);
  15273. const defaultSlotNode = h("slot", { key: "default-slot" });
  15274. const contentWrapperKey = "content-wrapper";
  15275. 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));
  15276. }
  15277. renderFab() {
  15278. return (h("div", { class: CSS$k.fabContainer }, h("slot", { name: SLOTS$c.fab })));
  15279. }
  15280. render() {
  15281. const { dismissed, dismissible, loading, panelKeyDownHandler } = this;
  15282. 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()));
  15283. return (h(Fragment, null, loading ? h("calcite-scrim", { loading: loading }) : null, panelNode));
  15284. }
  15285. get el() { return this; }
  15286. static get watchers() { return {
  15287. "dismissed": ["dismissedHandler"]
  15288. }; }
  15289. static get style() { return panelCss; }
  15290. };
  15291. const CSS$j = {
  15292. sticky: "sticky-pos"
  15293. };
  15294. var ICON_TYPES$1;
  15295. (function (ICON_TYPES) {
  15296. ICON_TYPES["circle"] = "circle";
  15297. ICON_TYPES["square"] = "square";
  15298. ICON_TYPES["grip"] = "grip";
  15299. })(ICON_TYPES$1 || (ICON_TYPES$1 = {}));
  15300. const SLOTS$b = {
  15301. menuActions: "menu-actions"
  15302. };
  15303. const CSS$i = {
  15304. heading: "heading",
  15305. container: "container",
  15306. indented: "container--indented"
  15307. };
  15308. const SLOTS$a = {
  15309. parentItem: "parent-item"
  15310. };
  15311. const HEADING_LEVEL$3 = 3;
  15312. function mutationObserverCallback() {
  15313. this.setUpItems();
  15314. this.setUpFilter();
  15315. this.deselectRemovedItems();
  15316. }
  15317. const SUPPORTED_ARROW_KEYS = ["ArrowUp", "ArrowDown"];
  15318. // --------------------------------------------------------------------------
  15319. //
  15320. // Lifecycle
  15321. //
  15322. // --------------------------------------------------------------------------
  15323. function initialize() {
  15324. this.setUpItems();
  15325. this.setUpFilter();
  15326. this.emitCalciteListChange = debounce$1(internalCalciteListChangeEvent.bind(this), 0);
  15327. }
  15328. function initializeObserver() {
  15329. var _a;
  15330. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
  15331. }
  15332. function cleanUpObserver() {
  15333. var _a;
  15334. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  15335. }
  15336. // --------------------------------------------------------------------------
  15337. //
  15338. // Listeners
  15339. //
  15340. // --------------------------------------------------------------------------
  15341. function calciteListItemChangeHandler(event) {
  15342. const { selectedValues } = this;
  15343. const { item, value, selected, shiftPressed } = event.detail;
  15344. if (selected) {
  15345. if (this.multiple && shiftPressed) {
  15346. this.selectSiblings(item);
  15347. }
  15348. if (!this.multiple) {
  15349. this.deselectSiblingItems(item);
  15350. }
  15351. selectedValues.set(value, item);
  15352. }
  15353. else {
  15354. selectedValues.delete(value);
  15355. if (this.multiple && shiftPressed) {
  15356. this.selectSiblings(item, true);
  15357. }
  15358. }
  15359. if (!this.multiple) {
  15360. toggleSingleSelectItemTabbing(item, selected);
  15361. if (selected) {
  15362. focusElement(item);
  15363. }
  15364. }
  15365. this.lastSelectedItem = item;
  15366. this.emitCalciteListChange();
  15367. }
  15368. function calciteListItemValueChangeHandler(event) {
  15369. event.stopPropagation();
  15370. const oldValue = event.detail.oldValue;
  15371. const selectedValues = this.selectedValues;
  15372. if (selectedValues.has(oldValue)) {
  15373. const item = selectedValues.get(oldValue);
  15374. selectedValues.delete(oldValue);
  15375. selectedValues.set(event.detail.newValue, item);
  15376. }
  15377. }
  15378. // --------------------------------------------------------------------------
  15379. //
  15380. // Private Methods
  15381. //
  15382. // --------------------------------------------------------------------------
  15383. function isValidNavigationKey(key) {
  15384. return !!SUPPORTED_ARROW_KEYS.find((k) => k === key);
  15385. }
  15386. function calciteListFocusOutHandler(event) {
  15387. const { el, items, multiple, selectedValues } = this;
  15388. if (multiple) {
  15389. return;
  15390. }
  15391. const focusedInside = el.contains(event.relatedTarget);
  15392. if (focusedInside) {
  15393. return;
  15394. }
  15395. filterOutDisabled(items).forEach((item) => {
  15396. toggleSingleSelectItemTabbing(item, selectedValues.size === 0 ? item.contains(event.target) || event.target === item : item.selected);
  15397. });
  15398. }
  15399. function keyDownHandler(event) {
  15400. const { key, target } = event;
  15401. if (!isValidNavigationKey(key)) {
  15402. return;
  15403. }
  15404. const { items, multiple, selectionFollowsFocus } = this;
  15405. const { length: totalItems } = items;
  15406. const currentIndex = items.indexOf(target);
  15407. if (!totalItems || currentIndex === -1) {
  15408. return;
  15409. }
  15410. event.preventDefault();
  15411. const index = moveItemIndex(this, target, key === "ArrowUp" ? "up" : "down");
  15412. const item = items[index];
  15413. items.forEach((i) => toggleSingleSelectItemTabbing(i, i === item));
  15414. if (!multiple && selectionFollowsFocus) {
  15415. item.selected = true;
  15416. }
  15417. focusElement(item);
  15418. }
  15419. function moveItemIndex(list, item, direction) {
  15420. const { items } = list;
  15421. const { length: totalItems } = items;
  15422. const currentIndex = items.indexOf(item);
  15423. const directionFactor = direction === "up" ? -1 : 1;
  15424. let moveOffset = 1;
  15425. let index = getRoundRobinIndex(currentIndex + directionFactor * moveOffset++, totalItems);
  15426. const firstMovedIndex = index;
  15427. while (items[index].disabled) {
  15428. index = getRoundRobinIndex(currentIndex + directionFactor * moveOffset++, totalItems);
  15429. if (index === firstMovedIndex) {
  15430. break;
  15431. }
  15432. }
  15433. return index;
  15434. }
  15435. function filterOutDisabled(items) {
  15436. return items.filter((item) => !item.disabled);
  15437. }
  15438. function internalCalciteListChangeEvent() {
  15439. this.calciteListChange.emit(this.selectedValues);
  15440. }
  15441. function removeItem(event) {
  15442. if (event.defaultPrevented) {
  15443. return;
  15444. }
  15445. const item = event.target;
  15446. const selectedValues = this.selectedValues;
  15447. if (item.parentElement.tagName === "CALCITE-PICK-LIST-GROUP" && item.slot === SLOTS$a.parentItem) {
  15448. item.parentElement.remove();
  15449. Array.from(item.parentElement.children).forEach((item) => selectedValues.delete(item.value));
  15450. }
  15451. else {
  15452. item.remove();
  15453. selectedValues.delete(item.value);
  15454. }
  15455. this.emitCalciteListChange();
  15456. }
  15457. function toggleSingleSelectItemTabbing(item, selectable) {
  15458. if (item.disabled) {
  15459. return;
  15460. }
  15461. // using attribute intentionally
  15462. if (selectable) {
  15463. item.removeAttribute("tabindex");
  15464. }
  15465. else {
  15466. item.setAttribute("tabindex", "-1");
  15467. }
  15468. }
  15469. async function setFocus(focusId) {
  15470. var _a;
  15471. if (this.filterEnabled && focusId === "filter") {
  15472. await focusElement(this.filterEl);
  15473. return;
  15474. }
  15475. const { items, multiple, selectionFollowsFocus } = this;
  15476. if (items.length === 0) {
  15477. return;
  15478. }
  15479. if (multiple) {
  15480. return (_a = filterOutDisabled(items)[0]) === null || _a === void 0 ? void 0 : _a.setFocus();
  15481. }
  15482. const filtered = filterOutDisabled(items);
  15483. const focusTarget = filtered.find((item) => item.selected) || filtered[0];
  15484. if (selectionFollowsFocus && focusTarget) {
  15485. focusTarget.selected = true;
  15486. }
  15487. return focusTarget.setFocus();
  15488. }
  15489. function setUpItems(tagName) {
  15490. this.items = Array.from(this.el.querySelectorAll(tagName));
  15491. let hasSelected = false;
  15492. const { items } = this;
  15493. items.forEach((item) => {
  15494. item.icon = this.getIconType();
  15495. if (!this.multiple) {
  15496. item.disableDeselect = true;
  15497. toggleSingleSelectItemTabbing(item, false);
  15498. }
  15499. if (item.selected) {
  15500. hasSelected = true;
  15501. toggleSingleSelectItemTabbing(item, true);
  15502. this.selectedValues.set(item.value, item);
  15503. }
  15504. });
  15505. const [first] = items;
  15506. if (!hasSelected && first && !first.disabled) {
  15507. toggleSingleSelectItemTabbing(first, true);
  15508. }
  15509. }
  15510. function deselectRemovedItems() {
  15511. const selectedValues = this.selectedValues;
  15512. const itemValues = this.items.map(({ value }) => value);
  15513. selectedValues.forEach((selectedItem) => {
  15514. if (!itemValues.includes(selectedItem.value)) {
  15515. this.selectedValues.delete(selectedItem.value);
  15516. }
  15517. });
  15518. }
  15519. function deselectSiblingItems(item) {
  15520. this.items.forEach((currentItem) => {
  15521. if (currentItem.value !== item.value) {
  15522. currentItem.toggleSelected(false);
  15523. if (this.selectedValues.has(currentItem.value)) {
  15524. this.selectedValues.delete(currentItem.value);
  15525. }
  15526. }
  15527. });
  15528. }
  15529. function selectSiblings(item, deselect = false) {
  15530. if (!this.lastSelectedItem) {
  15531. return;
  15532. }
  15533. const { items } = this;
  15534. const start = items.findIndex((currentItem) => {
  15535. return currentItem.value === this.lastSelectedItem.value;
  15536. });
  15537. const end = items.findIndex((currentItem) => {
  15538. return currentItem.value === item.value;
  15539. });
  15540. items.slice(Math.min(start, end), Math.max(start, end)).forEach((currentItem) => {
  15541. currentItem.toggleSelected(!deselect);
  15542. if (!deselect) {
  15543. this.selectedValues.set(currentItem.value, currentItem);
  15544. }
  15545. else {
  15546. this.selectedValues.delete(currentItem.value);
  15547. }
  15548. });
  15549. }
  15550. let groups;
  15551. function handleFilter(event) {
  15552. const { filteredItems } = event.currentTarget;
  15553. const values = filteredItems.map((item) => item.value);
  15554. let hasSelectedMatch = false;
  15555. if (!groups) {
  15556. groups = new Set();
  15557. }
  15558. const matchedItems = this.items.filter((item) => {
  15559. const parent = item.parentElement;
  15560. const grouped = parent.matches("calcite-pick-list-group");
  15561. if (grouped) {
  15562. groups.add(parent);
  15563. }
  15564. const matches = values.includes(item.value);
  15565. item.hidden = !matches;
  15566. if (!hasSelectedMatch) {
  15567. hasSelectedMatch = matches && item.selected;
  15568. }
  15569. return matches;
  15570. });
  15571. groups.forEach((group) => {
  15572. const hasAtLeastOneMatch = matchedItems.some((item) => group.contains(item));
  15573. group.hidden = !hasAtLeastOneMatch;
  15574. if (!hasAtLeastOneMatch) {
  15575. return;
  15576. }
  15577. const parentItem = getSlotted(group, "parent-item");
  15578. if (parentItem) {
  15579. parentItem.hidden = false;
  15580. if (matchedItems.includes(parentItem)) {
  15581. Array.from(group.children).forEach((child) => (child.hidden = false));
  15582. }
  15583. }
  15584. });
  15585. groups.clear();
  15586. if (matchedItems.length > 0 && !hasSelectedMatch && !this.multiple) {
  15587. toggleSingleSelectItemTabbing(matchedItems[0], true);
  15588. }
  15589. }
  15590. function getItemData() {
  15591. return this.items.map((item) => ({
  15592. label: item.label,
  15593. description: item.description,
  15594. metadata: item.metadata,
  15595. value: item.value
  15596. }));
  15597. }
  15598. var __rest = (undefined && undefined.__rest) || function (s, e) {
  15599. var t = {};
  15600. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  15601. t[p] = s[p];
  15602. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  15603. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  15604. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  15605. t[p[i]] = s[p[i]];
  15606. }
  15607. return t;
  15608. };
  15609. const List = (_a) => {
  15610. var { props: { disabled, loading, filterEnabled, dataForFilter, handleFilter, filterPlaceholder, setFilterEl } } = _a, rest = __rest(_a, ["props"]);
  15611. const defaultSlot = h("slot", null);
  15612. return (h(Host, Object.assign({ "aria-busy": toAriaBoolean(loading), role: "menu" }, rest),
  15613. h("section", null,
  15614. h("header", { class: { [CSS$j.sticky]: true } },
  15615. filterEnabled ? (h("calcite-filter", { "aria-label": filterPlaceholder, disabled: loading || disabled, items: dataForFilter, onCalciteFilterChange: handleFilter, placeholder: filterPlaceholder, ref: setFilterEl })) : null,
  15616. h("slot", { name: SLOTS$b.menuActions })),
  15617. loading ? h("calcite-scrim", { loading: loading }) : null,
  15618. defaultSlot)));
  15619. };
  15620. 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}";
  15621. const PickList = class extends HTMLElement$1 {
  15622. constructor() {
  15623. super();
  15624. this.__registerHost();
  15625. this.__attachShadow();
  15626. this.calciteListChange = createEvent(this, "calciteListChange", 7);
  15627. // --------------------------------------------------------------------------
  15628. //
  15629. // Properties
  15630. //
  15631. // --------------------------------------------------------------------------
  15632. /**
  15633. * When true, disabled prevents interaction. This state shows items with lower opacity/grayed.
  15634. */
  15635. this.disabled = false;
  15636. /**
  15637. * When true, an input appears at the top of the list that can be used by end users to filter items in the list.
  15638. */
  15639. this.filterEnabled = false;
  15640. /**
  15641. * When true, content is waiting to be loaded. This state shows a busy indicator.
  15642. */
  15643. this.loading = false;
  15644. /**
  15645. * Multiple works similar to standard radio buttons and checkboxes.
  15646. * When true, a user can select multiple items at a time.
  15647. * When false, only a single item can be selected at a time
  15648. * and selecting a new item will deselect any other selected items.
  15649. */
  15650. this.multiple = false;
  15651. /**
  15652. * When true and single-selection is enabled, the selection will change when navigating items via the keyboard.
  15653. */
  15654. this.selectionFollowsFocus = false;
  15655. // --------------------------------------------------------------------------
  15656. //
  15657. // Private Properties
  15658. //
  15659. // --------------------------------------------------------------------------
  15660. this.selectedValues = new Map();
  15661. this.dataForFilter = [];
  15662. this.lastSelectedItem = null;
  15663. this.mutationObserver = createObserver("mutation", mutationObserverCallback.bind(this));
  15664. this.setFilterEl = (el) => {
  15665. this.filterEl = el;
  15666. };
  15667. this.deselectRemovedItems = deselectRemovedItems.bind(this);
  15668. this.deselectSiblingItems = deselectSiblingItems.bind(this);
  15669. this.selectSiblings = selectSiblings.bind(this);
  15670. this.handleFilter = handleFilter.bind(this);
  15671. this.getItemData = getItemData.bind(this);
  15672. this.keyDownHandler = keyDownHandler.bind(this);
  15673. }
  15674. // --------------------------------------------------------------------------
  15675. //
  15676. // Lifecycle
  15677. //
  15678. // --------------------------------------------------------------------------
  15679. connectedCallback() {
  15680. initialize.call(this);
  15681. initializeObserver.call(this);
  15682. }
  15683. disconnectedCallback() {
  15684. cleanUpObserver.call(this);
  15685. }
  15686. componentDidRender() {
  15687. updateHostInteraction(this);
  15688. }
  15689. calciteListItemRemoveHandler(event) {
  15690. removeItem.call(this, event);
  15691. }
  15692. calciteListItemChangeHandler(event) {
  15693. calciteListItemChangeHandler.call(this, event);
  15694. }
  15695. calciteListItemPropsChangeHandler(event) {
  15696. event.stopPropagation();
  15697. this.setUpFilter();
  15698. }
  15699. calciteListItemValueChangeHandler(event) {
  15700. calciteListItemValueChangeHandler.call(this, event);
  15701. }
  15702. calciteListFocusOutHandler(event) {
  15703. calciteListFocusOutHandler.call(this, event);
  15704. }
  15705. // --------------------------------------------------------------------------
  15706. //
  15707. // Private Methods
  15708. //
  15709. // --------------------------------------------------------------------------
  15710. setUpItems() {
  15711. setUpItems.call(this, "calcite-pick-list-item");
  15712. }
  15713. setUpFilter() {
  15714. if (this.filterEnabled) {
  15715. this.dataForFilter = this.getItemData();
  15716. }
  15717. }
  15718. // --------------------------------------------------------------------------
  15719. //
  15720. // Public Methods
  15721. //
  15722. // --------------------------------------------------------------------------
  15723. /** Returns the currently selected items */
  15724. async getSelectedItems() {
  15725. return this.selectedValues;
  15726. }
  15727. /** Sets focus on the component. */
  15728. async setFocus(focusId) {
  15729. return setFocus.call(this, focusId);
  15730. }
  15731. // --------------------------------------------------------------------------
  15732. //
  15733. // Render Methods
  15734. //
  15735. // --------------------------------------------------------------------------
  15736. getIconType() {
  15737. return this.multiple ? ICON_TYPES$1.square : ICON_TYPES$1.circle;
  15738. }
  15739. render() {
  15740. return h(List, { onKeyDown: this.keyDownHandler, props: this });
  15741. }
  15742. get el() { return this; }
  15743. static get style() { return pickListCss; }
  15744. };
  15745. 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}";
  15746. const PickListGroup = class extends HTMLElement$1 {
  15747. constructor() {
  15748. super();
  15749. this.__registerHost();
  15750. this.__attachShadow();
  15751. }
  15752. // --------------------------------------------------------------------------
  15753. //
  15754. // Lifecycle
  15755. //
  15756. // --------------------------------------------------------------------------
  15757. connectedCallback() {
  15758. connectConditionalSlotComponent(this);
  15759. }
  15760. disconnectedCallback() {
  15761. disconnectConditionalSlotComponent(this);
  15762. }
  15763. // --------------------------------------------------------------------------
  15764. //
  15765. // Render Methods
  15766. //
  15767. // --------------------------------------------------------------------------
  15768. render() {
  15769. var _a;
  15770. const { el, groupTitle, headingLevel } = this;
  15771. const hasParentItem = getSlotted(el, SLOTS$a.parentItem) !== null;
  15772. const sectionClasses = {
  15773. [CSS$i.container]: true,
  15774. [CSS$i.indented]: hasParentItem
  15775. };
  15776. const title = groupTitle;
  15777. const parentLevel = (_a = el.closest("calcite-pick-list")) === null || _a === void 0 ? void 0 : _a.headingLevel;
  15778. const relativeLevel = parentLevel ? constrainHeadingLevel(parentLevel + 1) : null;
  15779. const level = headingLevel || relativeLevel || HEADING_LEVEL$3;
  15780. 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))));
  15781. }
  15782. get el() { return this; }
  15783. static get style() { return pickListGroupCss; }
  15784. };
  15785. const CSS$h = {
  15786. actions: "actions",
  15787. actionsEnd: "actions--end",
  15788. actionsStart: "actions--start",
  15789. description: "description",
  15790. handle: "handle",
  15791. handleActivated: "handle--activated",
  15792. highlight: "highlight",
  15793. icon: "icon",
  15794. iconDot: "icon-dot",
  15795. label: "label",
  15796. remove: "remove",
  15797. title: "title",
  15798. textContainer: "text-container"
  15799. };
  15800. const ICONS$4 = {
  15801. checked: "check",
  15802. remove: "x"
  15803. };
  15804. const SLOTS$9 = {
  15805. actionsEnd: "actions-end",
  15806. actionsStart: "actions-start"
  15807. };
  15808. const TEXT$7 = {
  15809. remove: "Remove"
  15810. };
  15811. 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}";
  15812. const PickListItem = class extends HTMLElement$1 {
  15813. constructor() {
  15814. super();
  15815. this.__registerHost();
  15816. this.__attachShadow();
  15817. this.calciteListItemChange = createEvent(this, "calciteListItemChange", 7);
  15818. this.calciteListItemRemove = createEvent(this, "calciteListItemRemove", 7);
  15819. this.calciteListItemPropsChange = createEvent(this, "calciteListItemPropsChange", 7);
  15820. this.calciteListItemValueChange = createEvent(this, "calciteListItemValueChange", 7);
  15821. /**
  15822. * When true, the item cannot be clicked and is visually muted.
  15823. */
  15824. this.disabled = false;
  15825. /**
  15826. * When false, the item cannot be deselected by user interaction.
  15827. */
  15828. this.disableDeselect = false;
  15829. /**
  15830. * @internal When true, the item cannot be selected by user interaction.
  15831. */
  15832. this.nonInteractive = false;
  15833. /**
  15834. * Determines the icon SVG symbol that will be shown. Options are circle, square, grip or null.
  15835. * @see [ICON_TYPES](https://github.com/Esri/calcite-components/blob/master/src/components/pick-list/resources.ts#L5)
  15836. */
  15837. this.icon = null;
  15838. /**
  15839. * Set this to true to display a remove action that removes the item from the list.
  15840. */
  15841. this.removable = false;
  15842. /**
  15843. * Set this to true to pre-select an item. Toggles when an item is checked/unchecked.
  15844. */
  15845. this.selected = false;
  15846. /**
  15847. * Used as an accessible label (aria-label) for the "remove item" action. Only applicable if removable is true.
  15848. * @default "Remove"
  15849. */
  15850. this.intlRemove = TEXT$7.remove;
  15851. // --------------------------------------------------------------------------
  15852. //
  15853. // Private Methods
  15854. //
  15855. // --------------------------------------------------------------------------
  15856. this.pickListClickHandler = (event) => {
  15857. if (this.disabled || (this.disableDeselect && this.selected) || this.nonInteractive) {
  15858. return;
  15859. }
  15860. this.shiftPressed = event.shiftKey;
  15861. this.selected = !this.selected;
  15862. };
  15863. this.pickListKeyDownHandler = (event) => {
  15864. if (event.key === " ") {
  15865. event.preventDefault();
  15866. if ((this.disableDeselect && this.selected) || this.nonInteractive) {
  15867. return;
  15868. }
  15869. this.selected = !this.selected;
  15870. }
  15871. };
  15872. this.removeClickHandler = () => {
  15873. this.calciteListItemRemove.emit();
  15874. };
  15875. }
  15876. descriptionWatchHandler() {
  15877. this.calciteListItemPropsChange.emit();
  15878. }
  15879. labelWatchHandler() {
  15880. this.calciteListItemPropsChange.emit();
  15881. }
  15882. metadataWatchHandler() {
  15883. this.calciteListItemPropsChange.emit();
  15884. }
  15885. selectedWatchHandler() {
  15886. this.calciteListItemChange.emit({
  15887. item: this.el,
  15888. value: this.value,
  15889. selected: this.selected,
  15890. shiftPressed: this.shiftPressed
  15891. });
  15892. this.shiftPressed = false;
  15893. }
  15894. valueWatchHandler(newValue, oldValue) {
  15895. this.calciteListItemValueChange.emit({ oldValue, newValue });
  15896. }
  15897. // --------------------------------------------------------------------------
  15898. //
  15899. // Lifecycle
  15900. //
  15901. // --------------------------------------------------------------------------
  15902. connectedCallback() {
  15903. connectConditionalSlotComponent(this);
  15904. }
  15905. disconnectedCallback() {
  15906. disconnectConditionalSlotComponent(this);
  15907. }
  15908. componentDidRender() {
  15909. updateHostInteraction(this, this.el.closest("calcite-pick-list") ? "managed" : false);
  15910. }
  15911. // --------------------------------------------------------------------------
  15912. //
  15913. // Public Methods
  15914. //
  15915. // --------------------------------------------------------------------------
  15916. /**
  15917. * Used to toggle the selection state. By default this won't trigger an event.
  15918. * The first argument allows the value to be coerced, rather than swapping values.
  15919. */
  15920. async toggleSelected(coerce) {
  15921. this.selected = typeof coerce === "boolean" ? coerce : !this.selected;
  15922. }
  15923. /** Sets focus on the component. */
  15924. async setFocus() {
  15925. var _a;
  15926. (_a = this.focusEl) === null || _a === void 0 ? void 0 : _a.focus();
  15927. }
  15928. // --------------------------------------------------------------------------
  15929. //
  15930. // Render Methods
  15931. //
  15932. // --------------------------------------------------------------------------
  15933. renderIcon() {
  15934. const { icon } = this;
  15935. if (!icon) {
  15936. return null;
  15937. }
  15938. return (h("span", { class: {
  15939. [CSS$h.icon]: true,
  15940. [CSS$h.iconDot]: icon === ICON_TYPES$1.circle
  15941. }, onClick: this.pickListClickHandler }, icon === ICON_TYPES$1.square ? h("calcite-icon", { icon: ICONS$4.checked, scale: "s" }) : null));
  15942. }
  15943. renderRemoveAction() {
  15944. 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;
  15945. }
  15946. renderActionsStart() {
  15947. const { el } = this;
  15948. const hasActionsStart = getSlotted(el, SLOTS$9.actionsStart);
  15949. return hasActionsStart ? (h("div", { class: { [CSS$h.actions]: true, [CSS$h.actionsStart]: true } }, h("slot", { name: SLOTS$9.actionsStart }))) : null;
  15950. }
  15951. renderActionsEnd() {
  15952. const { el, removable } = this;
  15953. const hasActionsEnd = getSlotted(el, SLOTS$9.actionsEnd);
  15954. return hasActionsEnd || removable ? (h("div", { class: { [CSS$h.actions]: true, [CSS$h.actionsEnd]: true } }, h("slot", { name: SLOTS$9.actionsEnd }), this.renderRemoveAction())) : null;
  15955. }
  15956. render() {
  15957. const { description, label } = this;
  15958. 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()));
  15959. }
  15960. get el() { return this; }
  15961. static get watchers() { return {
  15962. "description": ["descriptionWatchHandler"],
  15963. "label": ["labelWatchHandler"],
  15964. "metadata": ["metadataWatchHandler"],
  15965. "selected": ["selectedWatchHandler"],
  15966. "value": ["valueWatchHandler"]
  15967. }; }
  15968. static get style() { return pickListItemCss; }
  15969. };
  15970. const CSS$g = {
  15971. container: "container",
  15972. arrow: "arrow",
  15973. imageContainer: "image-container",
  15974. closeButtonContainer: "close-button-container",
  15975. closeButton: "close-button",
  15976. content: "content",
  15977. hasHeader: "has-header",
  15978. header: "header",
  15979. headerContent: "header-content",
  15980. heading: "heading"
  15981. };
  15982. const TEXT$6 = {
  15983. close: "Close"
  15984. };
  15985. const defaultPopoverPlacement = "auto";
  15986. const ARIA_CONTROLS = "aria-controls";
  15987. const ARIA_EXPANDED = "aria-expanded";
  15988. const HEADING_LEVEL$2 = 2;
  15989. class PopoverManager$1 {
  15990. constructor() {
  15991. // --------------------------------------------------------------------------
  15992. //
  15993. // Private Properties
  15994. //
  15995. // --------------------------------------------------------------------------
  15996. this.registeredElements = new WeakMap();
  15997. this.registeredElementCount = 0;
  15998. // --------------------------------------------------------------------------
  15999. //
  16000. // Private Methods
  16001. //
  16002. // --------------------------------------------------------------------------
  16003. this.queryPopover = (composedPath) => {
  16004. const { registeredElements } = this;
  16005. const registeredElement = composedPath.find((pathEl) => registeredElements.has(pathEl));
  16006. return registeredElements.get(registeredElement);
  16007. };
  16008. this.clickHandler = (event) => {
  16009. const composedPath = event.composedPath();
  16010. const popover = this.queryPopover(composedPath);
  16011. if (popover) {
  16012. popover.toggle();
  16013. return;
  16014. }
  16015. queryElementsRoots(event.target, "calcite-popover")
  16016. .filter((popover) => popover.autoClose && popover.open && !composedPath.includes(popover))
  16017. .forEach((popover) => popover.toggle(false));
  16018. };
  16019. }
  16020. // --------------------------------------------------------------------------
  16021. //
  16022. // Public Methods
  16023. //
  16024. // --------------------------------------------------------------------------
  16025. registerElement(referenceEl, popover) {
  16026. this.registeredElementCount++;
  16027. this.registeredElements.set(referenceEl, popover);
  16028. if (this.registeredElementCount === 1) {
  16029. this.addListeners();
  16030. }
  16031. }
  16032. unregisterElement(referenceEl) {
  16033. if (this.registeredElements.delete(referenceEl)) {
  16034. this.registeredElementCount--;
  16035. }
  16036. if (this.registeredElementCount === 0) {
  16037. this.removeListeners();
  16038. }
  16039. }
  16040. addListeners() {
  16041. document.addEventListener("pointerdown", this.clickHandler, { capture: true });
  16042. }
  16043. removeListeners() {
  16044. document.removeEventListener("pointerdown", this.clickHandler, { capture: true });
  16045. }
  16046. }
  16047. 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%}";
  16048. const manager$1 = new PopoverManager$1();
  16049. const Popover = class extends HTMLElement$1 {
  16050. constructor() {
  16051. super();
  16052. this.__registerHost();
  16053. this.__attachShadow();
  16054. this.calcitePopoverClose = createEvent(this, "calcitePopoverClose", 7);
  16055. this.calcitePopoverOpen = createEvent(this, "calcitePopoverOpen", 7);
  16056. // --------------------------------------------------------------------------
  16057. //
  16058. // Properties
  16059. //
  16060. // --------------------------------------------------------------------------
  16061. /**
  16062. * Automatically closes any currently open popovers when clicking outside of a popover.
  16063. */
  16064. this.autoClose = false;
  16065. /**
  16066. * Display a close button within the Popover.
  16067. * @deprecated use dismissible instead.
  16068. */
  16069. this.closeButton = false;
  16070. /**
  16071. * Display a close button within the Popover.
  16072. */
  16073. this.dismissible = false;
  16074. /**
  16075. * Prevents flipping the popover's placement when it starts to overlap its reference element.
  16076. */
  16077. this.disableFlip = false;
  16078. /**
  16079. * Removes the caret pointer.
  16080. */
  16081. this.disablePointer = false;
  16082. /**
  16083. * Offset the position of the popover away from the reference element.
  16084. * @default 6
  16085. */
  16086. this.offsetDistance = defaultOffsetDistance;
  16087. /**
  16088. * Offset the position of the popover along the reference element.
  16089. */
  16090. this.offsetSkidding = 0;
  16091. /**
  16092. * Display and position the component.
  16093. */
  16094. this.open = false;
  16095. /** Describes the type of positioning to use for the overlaid content. If your element is in a fixed container, use the 'fixed' value. */
  16096. this.overlayPositioning = "absolute";
  16097. /**
  16098. * Determines where the component will be positioned relative to the referenceElement.
  16099. * @see [PopperPlacement](https://github.com/Esri/calcite-components/blob/master/src/utils/popper.ts#L25)
  16100. */
  16101. this.placement = defaultPopoverPlacement;
  16102. /** Text for close button.
  16103. * @default "Close"
  16104. */
  16105. this.intlClose = TEXT$6.close;
  16106. this.guid = `calcite-popover-${guid()}`;
  16107. this.activeTransitionProp = "opacity";
  16108. // --------------------------------------------------------------------------
  16109. //
  16110. // Private Methods
  16111. //
  16112. // --------------------------------------------------------------------------
  16113. this.setFilteredPlacements = () => {
  16114. const { el, flipPlacements } = this;
  16115. this.filteredFlipPlacements = flipPlacements
  16116. ? filterComputedPlacements(flipPlacements, el)
  16117. : null;
  16118. };
  16119. this.setUpReferenceElement = () => {
  16120. this.removeReferences();
  16121. this.effectiveReferenceElement = this.getReferenceElement();
  16122. const { el, referenceElement, effectiveReferenceElement } = this;
  16123. if (referenceElement && !effectiveReferenceElement) {
  16124. console.warn(`${el.tagName}: reference-element id "${referenceElement}" was not found.`, {
  16125. el
  16126. });
  16127. }
  16128. this.addReferences();
  16129. this.createPopper();
  16130. };
  16131. this.getId = () => {
  16132. return this.el.id || this.guid;
  16133. };
  16134. this.setExpandedAttr = () => {
  16135. const { effectiveReferenceElement, open } = this;
  16136. if (!effectiveReferenceElement) {
  16137. return;
  16138. }
  16139. effectiveReferenceElement.setAttribute(ARIA_EXPANDED, toAriaBoolean(open));
  16140. };
  16141. this.addReferences = () => {
  16142. const { effectiveReferenceElement } = this;
  16143. if (!effectiveReferenceElement) {
  16144. return;
  16145. }
  16146. const id = this.getId();
  16147. effectiveReferenceElement.setAttribute(ARIA_CONTROLS, id);
  16148. manager$1.registerElement(effectiveReferenceElement, this.el);
  16149. this.setExpandedAttr();
  16150. };
  16151. this.removeReferences = () => {
  16152. const { effectiveReferenceElement } = this;
  16153. if (!effectiveReferenceElement) {
  16154. return;
  16155. }
  16156. effectiveReferenceElement.removeAttribute(ARIA_CONTROLS);
  16157. effectiveReferenceElement.removeAttribute(ARIA_EXPANDED);
  16158. manager$1.unregisterElement(effectiveReferenceElement);
  16159. };
  16160. this.hide = () => {
  16161. this.open = false;
  16162. };
  16163. this.transitionEnd = (event) => {
  16164. if (event.propertyName === this.activeTransitionProp) {
  16165. this.open ? this.calcitePopoverOpen.emit() : this.calcitePopoverClose.emit();
  16166. }
  16167. };
  16168. }
  16169. flipPlacementsHandler() {
  16170. this.setFilteredPlacements();
  16171. }
  16172. offsetDistanceOffsetHandler() {
  16173. this.reposition();
  16174. }
  16175. offsetSkiddingHandler() {
  16176. this.reposition();
  16177. }
  16178. openHandler() {
  16179. this.reposition();
  16180. this.setExpandedAttr();
  16181. }
  16182. placementHandler() {
  16183. this.reposition();
  16184. }
  16185. referenceElementHandler() {
  16186. this.setUpReferenceElement();
  16187. }
  16188. // --------------------------------------------------------------------------
  16189. //
  16190. // Lifecycle
  16191. //
  16192. // --------------------------------------------------------------------------
  16193. connectedCallback() {
  16194. this.setFilteredPlacements();
  16195. }
  16196. componentWillLoad() {
  16197. this.setUpReferenceElement();
  16198. }
  16199. componentDidLoad() {
  16200. this.reposition();
  16201. }
  16202. disconnectedCallback() {
  16203. this.removeReferences();
  16204. this.destroyPopper();
  16205. }
  16206. // --------------------------------------------------------------------------
  16207. //
  16208. // Public Methods
  16209. //
  16210. // --------------------------------------------------------------------------
  16211. /** Updates the position of the component. */
  16212. async reposition() {
  16213. const { popper, el, placement } = this;
  16214. const modifiers = this.getModifiers();
  16215. popper
  16216. ? await updatePopper({
  16217. el,
  16218. modifiers,
  16219. placement,
  16220. popper
  16221. })
  16222. : this.createPopper();
  16223. }
  16224. /** Sets focus on the component. */
  16225. async setFocus(focusId) {
  16226. var _a;
  16227. const { closeButtonEl } = this;
  16228. if (focusId === "close-button" && closeButtonEl) {
  16229. forceUpdate(closeButtonEl);
  16230. closeButtonEl.setFocus();
  16231. return;
  16232. }
  16233. (_a = this.el) === null || _a === void 0 ? void 0 : _a.focus();
  16234. }
  16235. /** Toggles the popover's open property. */
  16236. async toggle(value = !this.open) {
  16237. this.open = value;
  16238. }
  16239. getReferenceElement() {
  16240. const { referenceElement, el } = this;
  16241. return ((typeof referenceElement === "string"
  16242. ? queryElementRoots(el, { id: referenceElement })
  16243. : referenceElement) || null);
  16244. }
  16245. getModifiers() {
  16246. const { arrowEl, disableFlip, disablePointer, offsetDistance, offsetSkidding, filteredFlipPlacements } = this;
  16247. const flipModifier = {
  16248. name: "flip",
  16249. enabled: !disableFlip
  16250. };
  16251. if (filteredFlipPlacements) {
  16252. flipModifier.options = {
  16253. fallbackPlacements: filteredFlipPlacements
  16254. };
  16255. }
  16256. const arrowModifier = {
  16257. name: "arrow",
  16258. enabled: !disablePointer
  16259. };
  16260. if (arrowEl) {
  16261. arrowModifier.options = {
  16262. element: arrowEl
  16263. };
  16264. }
  16265. const offsetModifier = {
  16266. name: "offset",
  16267. enabled: true,
  16268. options: {
  16269. offset: [offsetSkidding, offsetDistance]
  16270. }
  16271. };
  16272. const eventListenerModifier = {
  16273. name: "eventListeners",
  16274. enabled: this.open
  16275. };
  16276. return [arrowModifier, flipModifier, offsetModifier, eventListenerModifier];
  16277. }
  16278. createPopper() {
  16279. this.destroyPopper();
  16280. const { el, placement, effectiveReferenceElement: referenceEl, overlayPositioning } = this;
  16281. const modifiers = this.getModifiers();
  16282. this.popper = createPopper({
  16283. el,
  16284. modifiers,
  16285. overlayPositioning,
  16286. placement,
  16287. referenceEl
  16288. });
  16289. }
  16290. destroyPopper() {
  16291. const { popper } = this;
  16292. if (popper) {
  16293. popper.destroy();
  16294. }
  16295. this.popper = null;
  16296. }
  16297. // --------------------------------------------------------------------------
  16298. //
  16299. // Render Methods
  16300. //
  16301. // --------------------------------------------------------------------------
  16302. renderCloseButton() {
  16303. const { dismissible, closeButton, intlClose } = this;
  16304. 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;
  16305. }
  16306. renderHeader() {
  16307. const { heading, headingLevel } = this;
  16308. const headingNode = heading ? (h(Heading, { class: CSS$g.heading, level: headingLevel || HEADING_LEVEL$2 }, heading)) : null;
  16309. return headingNode ? (h("div", { class: CSS$g.header }, headingNode, this.renderCloseButton())) : null;
  16310. }
  16311. render() {
  16312. const { effectiveReferenceElement, heading, label, open, disablePointer } = this;
  16313. const displayed = effectiveReferenceElement && open;
  16314. const hidden = !displayed;
  16315. const arrowNode = !disablePointer ? (h("div", { class: CSS$g.arrow, ref: (arrowEl) => (this.arrowEl = arrowEl) })) : null;
  16316. return (h(Host, { "aria-hidden": toAriaBoolean(hidden), "aria-label": label, "calcite-hydrated-hidden": hidden, id: this.getId(), role: "dialog" }, h("div", { class: {
  16317. [CSS$D.animation]: true,
  16318. [CSS$D.animationActive]: displayed
  16319. }, onTransitionEnd: this.transitionEnd }, arrowNode, h("div", { class: {
  16320. [CSS$g.hasHeader]: !!heading,
  16321. [CSS$g.container]: true
  16322. } }, this.renderHeader(), h("div", { class: CSS$g.content }, h("slot", null)), !heading ? this.renderCloseButton() : null))));
  16323. }
  16324. get el() { return this; }
  16325. static get watchers() { return {
  16326. "flipPlacements": ["flipPlacementsHandler"],
  16327. "offsetDistance": ["offsetDistanceOffsetHandler"],
  16328. "offsetSkidding": ["offsetSkiddingHandler"],
  16329. "open": ["openHandler"],
  16330. "placement": ["placementHandler"],
  16331. "referenceElement": ["referenceElementHandler"]
  16332. }; }
  16333. static get style() { return popoverCss; }
  16334. };
  16335. 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}";
  16336. const PopoverManager = class extends HTMLElement$1 {
  16337. constructor() {
  16338. super();
  16339. this.__registerHost();
  16340. this.__attachShadow();
  16341. this.mutationObserver = createObserver("mutation", () => this.setAutoClose());
  16342. // --------------------------------------------------------------------------
  16343. //
  16344. // Properties
  16345. //
  16346. // --------------------------------------------------------------------------
  16347. /**
  16348. * CSS Selector to match reference elements for popovers. Reference elements will be identified by this selector in order to open their associated popover.
  16349. * @default `[data-calcite-popover-reference]`
  16350. */
  16351. this.selector = "[data-calcite-popover-reference]";
  16352. /**
  16353. * Automatically closes any currently open popovers when clicking outside of a popover.
  16354. */
  16355. this.autoClose = false;
  16356. }
  16357. autoCloseHandler() {
  16358. this.setAutoClose();
  16359. }
  16360. // --------------------------------------------------------------------------
  16361. //
  16362. // Lifecycle
  16363. //
  16364. // --------------------------------------------------------------------------
  16365. connectedCallback() {
  16366. var _a;
  16367. this.setAutoClose();
  16368. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
  16369. }
  16370. disconnectedCallback() {
  16371. var _a;
  16372. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  16373. }
  16374. // --------------------------------------------------------------------------
  16375. //
  16376. // Render Methods
  16377. //
  16378. // --------------------------------------------------------------------------
  16379. render() {
  16380. return h("slot", null);
  16381. }
  16382. // --------------------------------------------------------------------------
  16383. //
  16384. // Private Methods
  16385. //
  16386. // --------------------------------------------------------------------------
  16387. setAutoClose() {
  16388. const { autoClose, el } = this;
  16389. el.querySelectorAll("calcite-popover").forEach((popover) => (popover.autoClose = autoClose));
  16390. }
  16391. get el() { return this; }
  16392. static get watchers() { return {
  16393. "autoClose": ["autoCloseHandler"]
  16394. }; }
  16395. static get style() { return popoverManagerCss; }
  16396. };
  16397. 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)}}";
  16398. const Progress = class extends HTMLElement$1 {
  16399. constructor() {
  16400. super();
  16401. this.__registerHost();
  16402. this.__attachShadow();
  16403. /** Use indeterminate if finding actual progress value is impossible */
  16404. this.type = "determinate";
  16405. /** Fraction completed, in the range of 0 - 1.0 */
  16406. this.value = 0;
  16407. /** For indeterminate progress bars, reverse the animation direction */
  16408. this.reversed = false;
  16409. }
  16410. render() {
  16411. const isDeterminate = this.type === "determinate";
  16412. const barStyles = isDeterminate ? { width: `${this.value * 100}%` } : {};
  16413. 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: {
  16414. bar: true,
  16415. indeterminate: this.type === "indeterminate",
  16416. reversed: this.reversed
  16417. }, style: barStyles })), this.text ? h("div", { class: "text" }, this.text) : null));
  16418. }
  16419. get el() { return this; }
  16420. static get style() { return progressCss; }
  16421. };
  16422. const CSS$f = {
  16423. container: "container"
  16424. };
  16425. 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}";
  16426. const RadioButton = class extends HTMLElement$1 {
  16427. constructor() {
  16428. super();
  16429. this.__registerHost();
  16430. this.__attachShadow();
  16431. this.calciteInternalRadioButtonBlur = createEvent(this, "calciteInternalRadioButtonBlur", 7);
  16432. this.calciteRadioButtonChange = createEvent(this, "calciteRadioButtonChange", 7);
  16433. this.calciteInternalRadioButtonCheckedChange = createEvent(this, "calciteInternalRadioButtonCheckedChange", 7);
  16434. this.calciteInternalRadioButtonFocus = createEvent(this, "calciteInternalRadioButtonFocus", 7);
  16435. //--------------------------------------------------------------------------
  16436. //
  16437. // Properties
  16438. //
  16439. //--------------------------------------------------------------------------
  16440. /** The checked state of the radio button. */
  16441. this.checked = false;
  16442. /** The disabled state of the radio button. */
  16443. this.disabled = false;
  16444. /**
  16445. * The focused state of the radio button.
  16446. * @internal
  16447. */
  16448. this.focused = false;
  16449. /** The radio button's hidden status. When a radio button is hidden it is not focusable or checkable. */
  16450. this.hidden = false;
  16451. /**
  16452. * The hovered state of the radio button.
  16453. * @internal
  16454. */
  16455. this.hovered = false;
  16456. /** Requires that a value is selected for the radio button group before the parent form will submit. */
  16457. this.required = false;
  16458. /** The scale (size) of the radio button. `scale` is passed as a property automatically from `calcite-radio-button-group`. */
  16459. this.scale = "m";
  16460. //--------------------------------------------------------------------------
  16461. //
  16462. // Private Methods
  16463. //
  16464. //--------------------------------------------------------------------------
  16465. this.selectItem = (items, selectedIndex) => {
  16466. items[selectedIndex].click();
  16467. };
  16468. this.queryButtons = () => {
  16469. return Array.from(this.rootNode.querySelectorAll("calcite-radio-button:not([hidden])")).filter((radioButton) => radioButton.name === this.name);
  16470. };
  16471. this.isDefaultSelectable = () => {
  16472. const radioButtons = this.queryButtons();
  16473. return !radioButtons.some((radioButton) => radioButton.checked) && radioButtons[0] === this.el;
  16474. };
  16475. this.check = () => {
  16476. if (this.disabled) {
  16477. return;
  16478. }
  16479. this.uncheckAllRadioButtonsInGroup();
  16480. this.checked = true;
  16481. this.calciteRadioButtonChange.emit();
  16482. this.setFocus();
  16483. };
  16484. this.clickHandler = () => {
  16485. this.check();
  16486. };
  16487. this.setContainerEl = (el) => {
  16488. this.containerEl = el;
  16489. };
  16490. this.handleKeyDown = (event) => {
  16491. const keys = ["ArrowLeft", "ArrowUp", "ArrowRight", "ArrowDown", " "];
  16492. const key = event.key;
  16493. const { el } = this;
  16494. if (keys.indexOf(key) === -1) {
  16495. return;
  16496. }
  16497. if (key === " ") {
  16498. this.check();
  16499. return;
  16500. }
  16501. let adjustedKey = key;
  16502. if (getElementDir(el) === "rtl") {
  16503. if (key === "ArrowRight") {
  16504. adjustedKey = "ArrowLeft";
  16505. }
  16506. if (key === "ArrowLeft") {
  16507. adjustedKey = "ArrowRight";
  16508. }
  16509. }
  16510. const radioButtons = Array.from(this.rootNode.querySelectorAll("calcite-radio-button:not([hidden]")).filter((radioButton) => radioButton.name === this.name);
  16511. let currentIndex = 0;
  16512. const radioButtonsLength = radioButtons.length;
  16513. radioButtons.some((item, index) => {
  16514. if (item.checked) {
  16515. currentIndex = index;
  16516. return true;
  16517. }
  16518. });
  16519. switch (adjustedKey) {
  16520. case "ArrowLeft":
  16521. case "ArrowUp":
  16522. event.preventDefault();
  16523. this.selectItem(radioButtons, getRoundRobinIndex(Math.max(currentIndex - 1, -1), radioButtonsLength));
  16524. return;
  16525. case "ArrowRight":
  16526. case "ArrowDown":
  16527. event.preventDefault();
  16528. this.selectItem(radioButtons, getRoundRobinIndex(currentIndex + 1, radioButtonsLength));
  16529. return;
  16530. default:
  16531. return;
  16532. }
  16533. };
  16534. this.onContainerBlur = () => {
  16535. this.focused = false;
  16536. this.calciteInternalRadioButtonBlur.emit();
  16537. };
  16538. this.onContainerFocus = () => {
  16539. if (!this.disabled) {
  16540. this.focused = true;
  16541. this.calciteInternalRadioButtonFocus.emit();
  16542. }
  16543. };
  16544. }
  16545. checkedChanged(newChecked) {
  16546. if (newChecked) {
  16547. this.uncheckOtherRadioButtonsInGroup();
  16548. }
  16549. this.calciteInternalRadioButtonCheckedChange.emit(newChecked);
  16550. }
  16551. nameChanged() {
  16552. this.checkLastRadioButton();
  16553. }
  16554. //--------------------------------------------------------------------------
  16555. //
  16556. // Public Methods
  16557. //
  16558. //--------------------------------------------------------------------------
  16559. /** Sets focus on the component. */
  16560. async setFocus() {
  16561. if (!this.disabled) {
  16562. focusElement(this.containerEl);
  16563. }
  16564. }
  16565. onLabelClick(event) {
  16566. if (!this.disabled && !this.hidden) {
  16567. this.uncheckOtherRadioButtonsInGroup();
  16568. const label = event.currentTarget;
  16569. const radioButton = label.for
  16570. ? this.rootNode.querySelector(`calcite-radio-button[id="${label.for}"]`)
  16571. : label.querySelector(`calcite-radio-button[name="${this.name}"]`);
  16572. if (radioButton) {
  16573. radioButton.checked = true;
  16574. radioButton.focused = true;
  16575. }
  16576. this.calciteRadioButtonChange.emit();
  16577. this.setFocus();
  16578. }
  16579. }
  16580. checkLastRadioButton() {
  16581. const radioButtons = this.queryButtons();
  16582. const checkedRadioButtons = radioButtons.filter((radioButton) => radioButton.checked);
  16583. if ((checkedRadioButtons === null || checkedRadioButtons === void 0 ? void 0 : checkedRadioButtons.length) > 1) {
  16584. const lastCheckedRadioButton = checkedRadioButtons[checkedRadioButtons.length - 1];
  16585. checkedRadioButtons
  16586. .filter((checkedRadioButton) => checkedRadioButton !== lastCheckedRadioButton)
  16587. .forEach((checkedRadioButton) => {
  16588. checkedRadioButton.checked = false;
  16589. checkedRadioButton.emitCheckedChange();
  16590. });
  16591. }
  16592. }
  16593. /** @internal */
  16594. async emitCheckedChange() {
  16595. this.calciteInternalRadioButtonCheckedChange.emit();
  16596. }
  16597. uncheckAllRadioButtonsInGroup() {
  16598. const radioButtons = this.queryButtons();
  16599. radioButtons.forEach((radioButton) => {
  16600. if (radioButton.checked) {
  16601. radioButton.checked = false;
  16602. radioButton.focused = false;
  16603. }
  16604. });
  16605. }
  16606. uncheckOtherRadioButtonsInGroup() {
  16607. const radioButtons = this.queryButtons();
  16608. const otherRadioButtons = radioButtons.filter((radioButton) => radioButton.guid !== this.guid);
  16609. otherRadioButtons.forEach((otherRadioButton) => {
  16610. if (otherRadioButton.checked) {
  16611. otherRadioButton.checked = false;
  16612. otherRadioButton.focused = false;
  16613. }
  16614. });
  16615. }
  16616. getTabIndex() {
  16617. if (this.disabled) {
  16618. return undefined;
  16619. }
  16620. return this.checked || this.isDefaultSelectable() ? 0 : -1;
  16621. }
  16622. //--------------------------------------------------------------------------
  16623. //
  16624. // Event Listeners
  16625. //
  16626. //--------------------------------------------------------------------------
  16627. mouseenter() {
  16628. this.hovered = true;
  16629. }
  16630. mouseleave() {
  16631. this.hovered = false;
  16632. }
  16633. //--------------------------------------------------------------------------
  16634. //
  16635. // Lifecycle
  16636. //
  16637. //--------------------------------------------------------------------------
  16638. connectedCallback() {
  16639. this.rootNode = this.el.getRootNode();
  16640. this.guid = this.el.id || `calcite-radio-button-${guid()}`;
  16641. if (this.name) {
  16642. this.checkLastRadioButton();
  16643. }
  16644. connectLabel(this);
  16645. connectForm(this);
  16646. }
  16647. componentDidLoad() {
  16648. if (this.focused && !this.disabled) {
  16649. this.setFocus();
  16650. }
  16651. }
  16652. disconnectedCallback() {
  16653. disconnectLabel(this);
  16654. disconnectForm(this);
  16655. }
  16656. componentDidRender() {
  16657. updateHostInteraction(this);
  16658. }
  16659. // --------------------------------------------------------------------------
  16660. //
  16661. // Render Methods
  16662. //
  16663. // --------------------------------------------------------------------------
  16664. render() {
  16665. const tabIndex = this.getTabIndex();
  16666. 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 })));
  16667. }
  16668. get el() { return this; }
  16669. static get watchers() { return {
  16670. "checked": ["checkedChanged"],
  16671. "name": ["nameChanged"]
  16672. }; }
  16673. static get style() { return radioButtonCss; }
  16674. };
  16675. 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}";
  16676. const RadioButtonGroup = class extends HTMLElement$1 {
  16677. constructor() {
  16678. super();
  16679. this.__registerHost();
  16680. this.__attachShadow();
  16681. this.calciteRadioButtonGroupChange = createEvent(this, "calciteRadioButtonGroupChange", 7);
  16682. //--------------------------------------------------------------------------
  16683. //
  16684. // Properties
  16685. //
  16686. //--------------------------------------------------------------------------
  16687. /** The disabled state of the radio button group. */
  16688. this.disabled = false;
  16689. /** The radio button group's hidden status. When a radio button group is hidden none of its options are focusable or checkable. */
  16690. this.hidden = false;
  16691. /** The layout direction of the radio buttons in a group. */
  16692. this.layout = "horizontal";
  16693. /** Requires that a value is selected for the radio button group before the parent form will submit. */
  16694. this.required = false;
  16695. /** The scale (size) of the radio button group. */
  16696. this.scale = "m";
  16697. // --------------------------------------------------------------------------
  16698. //
  16699. // Private Properties
  16700. //
  16701. // --------------------------------------------------------------------------
  16702. this.mutationObserver = createObserver("mutation", () => this.passPropsToRadioButtons());
  16703. //--------------------------------------------------------------------------
  16704. //
  16705. // Private Methods
  16706. //
  16707. //--------------------------------------------------------------------------
  16708. this.passPropsToRadioButtons = () => {
  16709. const radioButtons = this.el.querySelectorAll("calcite-radio-button");
  16710. if (radioButtons.length > 0) {
  16711. radioButtons.forEach((radioButton) => {
  16712. radioButton.disabled = this.disabled || radioButton.disabled;
  16713. radioButton.hidden = this.hidden;
  16714. radioButton.name = this.name;
  16715. radioButton.required = this.required;
  16716. radioButton.scale = this.scale;
  16717. });
  16718. }
  16719. };
  16720. }
  16721. onDisabledChange() {
  16722. this.passPropsToRadioButtons();
  16723. }
  16724. onHiddenChange() {
  16725. this.passPropsToRadioButtons();
  16726. }
  16727. onLayoutChange() {
  16728. this.passPropsToRadioButtons();
  16729. }
  16730. onScaleChange() {
  16731. this.passPropsToRadioButtons();
  16732. }
  16733. //--------------------------------------------------------------------------
  16734. //
  16735. // Lifecycle
  16736. //
  16737. //--------------------------------------------------------------------------
  16738. connectedCallback() {
  16739. var _a;
  16740. this.passPropsToRadioButtons();
  16741. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
  16742. }
  16743. disconnectedCallback() {
  16744. var _a;
  16745. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  16746. }
  16747. //--------------------------------------------------------------------------
  16748. //
  16749. // Event Listeners
  16750. //
  16751. //--------------------------------------------------------------------------
  16752. radioButtonChangeHandler(event) {
  16753. this.calciteRadioButtonGroupChange.emit(event.target.value);
  16754. }
  16755. // --------------------------------------------------------------------------
  16756. //
  16757. // Render Methods
  16758. //
  16759. // --------------------------------------------------------------------------
  16760. render() {
  16761. return (h(Host, { role: "radiogroup" }, h("slot", null)));
  16762. }
  16763. get el() { return this; }
  16764. static get watchers() { return {
  16765. "disabled": ["onDisabledChange"],
  16766. "hidden": ["onHiddenChange"],
  16767. "layout": ["onLayoutChange"],
  16768. "scale": ["onScaleChange"]
  16769. }; }
  16770. static get style() { return radioButtonGroupCss; }
  16771. };
  16772. 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}";
  16773. const RadioGroup = class extends HTMLElement$1 {
  16774. constructor() {
  16775. super();
  16776. this.__registerHost();
  16777. this.__attachShadow();
  16778. this.calciteRadioGroupChange = createEvent(this, "calciteRadioGroupChange", 7);
  16779. //--------------------------------------------------------------------------
  16780. //
  16781. // Properties
  16782. //
  16783. //--------------------------------------------------------------------------
  16784. /** specify the appearance style of the radio group, defaults to solid. */
  16785. this.appearance = "solid";
  16786. /** is the radio group disabled */
  16787. this.disabled = false;
  16788. /**
  16789. * When true, makes the component required for form-submission.
  16790. *
  16791. * @internal
  16792. */
  16793. this.required = false;
  16794. /** specify the layout of the radio group, defaults to horizontal */
  16795. this.layout = "horizontal";
  16796. /** The scale of the radio group */
  16797. this.scale = "m";
  16798. /** The value of the selectedItem */
  16799. this.value = null;
  16800. /** specify the width of the group, defaults to auto */
  16801. this.width = "auto";
  16802. //--------------------------------------------------------------------------
  16803. //
  16804. // Event Listeners
  16805. //
  16806. //--------------------------------------------------------------------------
  16807. this.handleClick = (event) => {
  16808. if (event.target.localName === "calcite-radio-group-item") {
  16809. this.selectItem(event.target, true);
  16810. }
  16811. };
  16812. }
  16813. valueHandler(value) {
  16814. const items = this.getItems();
  16815. items.forEach((item) => (item.checked = item.value === value));
  16816. }
  16817. handleSelectedItemChange(newItem, oldItem) {
  16818. this.value = newItem === null || newItem === void 0 ? void 0 : newItem.value;
  16819. if (newItem === oldItem) {
  16820. return;
  16821. }
  16822. const items = this.getItems();
  16823. const match = Array.from(items)
  16824. .filter((item) => item === newItem)
  16825. .pop();
  16826. if (match) {
  16827. this.selectItem(match);
  16828. }
  16829. else if (items[0]) {
  16830. items[0].tabIndex = 0;
  16831. }
  16832. }
  16833. //--------------------------------------------------------------------------
  16834. //
  16835. // Lifecycle
  16836. //
  16837. //--------------------------------------------------------------------------
  16838. componentWillLoad() {
  16839. const items = this.getItems();
  16840. const lastChecked = Array.from(items)
  16841. .filter((item) => item.checked)
  16842. .pop();
  16843. if (lastChecked) {
  16844. this.selectItem(lastChecked);
  16845. }
  16846. else if (items[0]) {
  16847. items[0].tabIndex = 0;
  16848. }
  16849. }
  16850. connectedCallback() {
  16851. connectLabel(this);
  16852. connectForm(this);
  16853. }
  16854. disconnectedCallback() {
  16855. disconnectLabel(this);
  16856. disconnectForm(this);
  16857. }
  16858. componentDidRender() {
  16859. updateHostInteraction(this);
  16860. }
  16861. render() {
  16862. return (h(Host, { onClick: this.handleClick, role: "radiogroup" }, h("slot", null), h(HiddenFormInputSlot, { component: this })));
  16863. }
  16864. handleSelected(event) {
  16865. event.stopPropagation();
  16866. event.preventDefault();
  16867. this.selectItem(event.target);
  16868. }
  16869. handleKeyDown(event) {
  16870. const keys = ["ArrowLeft", "ArrowUp", "ArrowRight", "ArrowDown", " "];
  16871. const key = event.key;
  16872. const { el, selectedItem } = this;
  16873. if (keys.indexOf(key) === -1) {
  16874. return;
  16875. }
  16876. let adjustedKey = key;
  16877. if (getElementDir(el) === "rtl") {
  16878. if (key === "ArrowRight") {
  16879. adjustedKey = "ArrowLeft";
  16880. }
  16881. if (key === "ArrowLeft") {
  16882. adjustedKey = "ArrowRight";
  16883. }
  16884. }
  16885. const items = this.getItems();
  16886. let selectedIndex = -1;
  16887. items.forEach((item, index) => {
  16888. if (item === selectedItem) {
  16889. selectedIndex = index;
  16890. }
  16891. });
  16892. switch (adjustedKey) {
  16893. case "ArrowLeft":
  16894. case "ArrowUp":
  16895. event.preventDefault();
  16896. const previous = selectedIndex < 1 ? items.item(items.length - 1) : items.item(selectedIndex - 1);
  16897. this.selectItem(previous, true);
  16898. return;
  16899. case "ArrowRight":
  16900. case "ArrowDown":
  16901. event.preventDefault();
  16902. const next = selectedIndex === -1 ? items.item(1) : items.item(selectedIndex + 1) || items.item(0);
  16903. this.selectItem(next, true);
  16904. return;
  16905. case " ":
  16906. event.preventDefault();
  16907. this.selectItem(event.target, true);
  16908. return;
  16909. default:
  16910. return;
  16911. }
  16912. }
  16913. // --------------------------------------------------------------------------
  16914. //
  16915. // Methods
  16916. //
  16917. // --------------------------------------------------------------------------
  16918. /** Sets focus on the component. */
  16919. async setFocus() {
  16920. var _a;
  16921. (_a = (this.selectedItem || this.getItems()[0])) === null || _a === void 0 ? void 0 : _a.focus();
  16922. }
  16923. //--------------------------------------------------------------------------
  16924. //
  16925. // Private Methods
  16926. //
  16927. //--------------------------------------------------------------------------
  16928. onLabelClick() {
  16929. this.setFocus();
  16930. }
  16931. getItems() {
  16932. return this.el.querySelectorAll("calcite-radio-group-item");
  16933. }
  16934. selectItem(selected, emit = false) {
  16935. if (selected === this.selectedItem) {
  16936. return;
  16937. }
  16938. const items = this.getItems();
  16939. let match = null;
  16940. items.forEach((item) => {
  16941. const matches = item.value === selected.value;
  16942. if ((matches && !item.checked) || (!matches && item.checked)) {
  16943. item.checked = matches;
  16944. }
  16945. item.tabIndex = matches ? 0 : -1;
  16946. if (matches) {
  16947. match = item;
  16948. if (emit) {
  16949. this.calciteRadioGroupChange.emit(match.value);
  16950. }
  16951. }
  16952. });
  16953. this.selectedItem = match;
  16954. if (Build.isBrowser && match) {
  16955. match.focus();
  16956. }
  16957. }
  16958. get el() { return this; }
  16959. static get watchers() { return {
  16960. "value": ["valueHandler"],
  16961. "selectedItem": ["handleSelectedItemChange"]
  16962. }; }
  16963. static get style() { return radioGroupCss; }
  16964. };
  16965. const SLOTS$8 = {
  16966. input: "input"
  16967. };
  16968. const CSS$e = {
  16969. radioGroupItemIcon: "radio-group-item-icon"
  16970. };
  16971. 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}";
  16972. const RadioGroupItem = class extends HTMLElement$1 {
  16973. constructor() {
  16974. super();
  16975. this.__registerHost();
  16976. this.__attachShadow();
  16977. this.calciteRadioGroupItemChange = createEvent(this, "calciteRadioGroupItemChange", 7);
  16978. //--------------------------------------------------------------------------
  16979. //
  16980. // Properties
  16981. //
  16982. //--------------------------------------------------------------------------
  16983. /** Indicates whether the control is checked. */
  16984. this.checked = false;
  16985. /** flip the icon in rtl */
  16986. this.iconFlipRtl = false;
  16987. /** optionally used with icon, select where to position the icon */
  16988. this.iconPosition = "start";
  16989. }
  16990. handleCheckedChange() {
  16991. this.calciteRadioGroupItemChange.emit();
  16992. }
  16993. render() {
  16994. const { checked, value } = this;
  16995. const scale = getElementProp(this.el, "scale", "m");
  16996. const appearance = getElementProp(this.el, "appearance", "solid");
  16997. const layout = getElementProp(this.el, "layout", "horizontal");
  16998. const iconEl = (h("calcite-icon", { class: CSS$e.radioGroupItemIcon, flipRtl: this.iconFlipRtl, icon: this.icon, scale: "s" }));
  16999. return (h(Host, { "aria-checked": toAriaBoolean(checked), role: "radio" }, h("label", { class: {
  17000. "label--scale-s": scale === "s",
  17001. "label--scale-m": scale === "m",
  17002. "label--scale-l": scale === "l",
  17003. "label--horizontal": layout === "horizontal",
  17004. "label--outline": appearance === "outline"
  17005. } }, this.icon && this.iconPosition === "start" ? iconEl : null, h("slot", null, value), h("slot", { name: SLOTS$8.input }), this.icon && this.iconPosition === "end" ? iconEl : null)));
  17006. }
  17007. get el() { return this; }
  17008. static get watchers() { return {
  17009. "checked": ["handleCheckedChange"]
  17010. }; }
  17011. static get style() { return radioGroupItemCss; }
  17012. };
  17013. const TEXT$5 = {
  17014. rating: "Rating",
  17015. stars: "Stars: ${num}"
  17016. };
  17017. 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}";
  17018. const Rating = class extends HTMLElement$1 {
  17019. constructor() {
  17020. super();
  17021. this.__registerHost();
  17022. this.__attachShadow();
  17023. this.calciteRatingChange = createEvent(this, "calciteRatingChange", 7);
  17024. // --------------------------------------------------------------------------
  17025. //
  17026. // Properties
  17027. //
  17028. // --------------------------------------------------------------------------
  17029. /** specify the scale of the component, defaults to m */
  17030. this.scale = "m";
  17031. /** the value of the rating component */
  17032. this.value = 0;
  17033. /** is the rating component in a selectable mode */
  17034. this.readOnly = false;
  17035. /** is the rating component in a selectable mode */
  17036. this.disabled = false;
  17037. /** Show average and count data summary chip (if available) */
  17038. this.showChip = false;
  17039. /** Localized string for "Rating" (used for aria label)
  17040. * @default "Rating"
  17041. */
  17042. this.intlRating = TEXT$5.rating;
  17043. /** Localized string for labelling each star, `${num}` in the string will be replaced by the number
  17044. * @default "Stars: ${num}"
  17045. */
  17046. this.intlStars = TEXT$5.stars;
  17047. /**
  17048. * When true, makes the component required for form-submission.
  17049. *
  17050. * @internal
  17051. */
  17052. this.required = false;
  17053. this.guid = `calcite-ratings-${guid()}`;
  17054. }
  17055. //--------------------------------------------------------------------------
  17056. //
  17057. // Lifecycle
  17058. //
  17059. //--------------------------------------------------------------------------
  17060. connectedCallback() {
  17061. connectLabel(this);
  17062. connectForm(this);
  17063. }
  17064. disconnectedCallback() {
  17065. disconnectLabel(this);
  17066. disconnectForm(this);
  17067. }
  17068. componentDidRender() {
  17069. updateHostInteraction(this);
  17070. }
  17071. //--------------------------------------------------------------------------
  17072. //
  17073. // Event Listeners
  17074. //
  17075. //--------------------------------------------------------------------------
  17076. blurHandler() {
  17077. this.hasFocus = false;
  17078. }
  17079. // --------------------------------------------------------------------------
  17080. //
  17081. // Render Methods
  17082. //
  17083. // --------------------------------------------------------------------------
  17084. renderStars() {
  17085. return [1, 2, 3, 4, 5].map((i) => {
  17086. const selected = this.value >= i;
  17087. const average = this.average && !this.value && i <= this.average;
  17088. const hovered = i <= this.hoverValue;
  17089. const fraction = this.average && this.average + 1 - i;
  17090. const partial = !this.value && !hovered && fraction > 0 && fraction < 1;
  17091. const focused = this.hasFocus && this.focusValue === i;
  17092. return (h("span", { class: { wrapper: true } }, h("label", { class: { star: true, focused, selected, average, hovered, partial }, htmlFor: `${this.guid}-${i}`, onMouseOver: () => {
  17093. this.hoverValue = i;
  17094. } }, 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) =>
  17095. // click is fired from the the component's label, so we treat this as an internal event
  17096. event.stopPropagation(), onFocus: () => {
  17097. this.hasFocus = true;
  17098. this.focusValue = i;
  17099. }, ref: (el) => (i === 1 || i === this.value) && (this.inputFocusRef = el), type: "radio", value: i })));
  17100. });
  17101. }
  17102. render() {
  17103. const { disabled, intlRating, showChip, scale, count, average } = this;
  17104. 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 :
  17105. count.toString(), ")"))) : null, h(HiddenFormInputSlot, { component: this })));
  17106. }
  17107. //--------------------------------------------------------------------------
  17108. //
  17109. // Private Methods
  17110. //
  17111. //--------------------------------------------------------------------------
  17112. onLabelClick() {
  17113. this.setFocus();
  17114. }
  17115. updateValue(value) {
  17116. this.value = value;
  17117. this.calciteRatingChange.emit({ value });
  17118. }
  17119. //--------------------------------------------------------------------------
  17120. //
  17121. // Public Methods
  17122. //
  17123. //--------------------------------------------------------------------------
  17124. /** Sets focus on the component. */
  17125. async setFocus() {
  17126. this.inputFocusRef.focus();
  17127. }
  17128. get el() { return this; }
  17129. static get style() { return ratingCss; }
  17130. };
  17131. const CSS$d = {
  17132. scrim: "scrim",
  17133. content: "content"
  17134. };
  17135. const TEXT$4 = {
  17136. loading: "Loading"
  17137. };
  17138. 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}";
  17139. const Scrim = class extends HTMLElement$1 {
  17140. constructor() {
  17141. super();
  17142. this.__registerHost();
  17143. this.__attachShadow();
  17144. // --------------------------------------------------------------------------
  17145. //
  17146. // Properties
  17147. //
  17148. // --------------------------------------------------------------------------
  17149. /** string to override English loading text
  17150. * @default "Loading"
  17151. */
  17152. this.intlLoading = TEXT$4.loading;
  17153. /**
  17154. * Determines if the component will have the loader overlay.
  17155. * Otherwise, will render opaque disabled state.
  17156. */
  17157. this.loading = false;
  17158. }
  17159. // --------------------------------------------------------------------------
  17160. //
  17161. // Render Method
  17162. //
  17163. // --------------------------------------------------------------------------
  17164. render() {
  17165. const { el, loading, intlLoading } = this;
  17166. const hasContent = el.innerHTML.trim().length > 0;
  17167. const loaderNode = loading ? h("calcite-loader", { active: true, label: intlLoading }) : null;
  17168. const contentNode = hasContent ? (h("div", { class: CSS$d.content }, h("slot", null))) : null;
  17169. return (h("div", { class: CSS$d.scrim }, loaderNode, contentNode));
  17170. }
  17171. get el() { return this; }
  17172. static get style() { return scrimCss; }
  17173. };
  17174. const CSS$c = {
  17175. icon: "icon",
  17176. iconContainer: "icon-container",
  17177. select: "select"
  17178. };
  17179. 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}";
  17180. function isOption(optionOrGroup) {
  17181. return optionOrGroup.tagName === "CALCITE-OPTION";
  17182. }
  17183. function isOptionGroup(optionOrGroup) {
  17184. return optionOrGroup.tagName === "CALCITE-OPTION-GROUP";
  17185. }
  17186. const Select = class extends HTMLElement$1 {
  17187. constructor() {
  17188. super();
  17189. this.__registerHost();
  17190. this.__attachShadow();
  17191. this.calciteSelectChange = createEvent(this, "calciteSelectChange", 7);
  17192. //--------------------------------------------------------------------------
  17193. //
  17194. // Properties
  17195. //
  17196. //--------------------------------------------------------------------------
  17197. /**
  17198. * When true, it prevents the option from being selected.
  17199. */
  17200. this.disabled = false;
  17201. /**
  17202. * When true, makes the component required for form-submission.
  17203. *
  17204. * @internal
  17205. */
  17206. this.required = false;
  17207. /**
  17208. * The component scale.
  17209. */
  17210. this.scale = "m";
  17211. /** The value of the selectedOption */
  17212. this.value = null;
  17213. /**
  17214. * The component width.
  17215. */
  17216. this.width = "auto";
  17217. this.componentToNativeEl = new Map();
  17218. this.mutationObserver = createObserver("mutation", () => this.populateInternalSelect());
  17219. this.handleInternalSelectChange = () => {
  17220. const selected = this.selectEl.selectedOptions[0];
  17221. this.selectFromNativeOption(selected);
  17222. requestAnimationFrame(() => this.emitChangeEvent());
  17223. };
  17224. this.populateInternalSelect = () => {
  17225. const optionsAndGroups = Array.from(this.el.children).filter((child) => child.tagName === "CALCITE-OPTION" || child.tagName === "CALCITE-OPTION-GROUP");
  17226. this.clearInternalSelect();
  17227. optionsAndGroups.forEach((optionOrGroup) => { var _a; return (_a = this.selectEl) === null || _a === void 0 ? void 0 : _a.append(this.toNativeElement(optionOrGroup)); });
  17228. };
  17229. this.storeSelectRef = (node) => {
  17230. this.selectEl = node;
  17231. this.populateInternalSelect();
  17232. const selected = this.selectEl.selectedOptions[0];
  17233. this.selectFromNativeOption(selected);
  17234. };
  17235. this.emitChangeEvent = () => {
  17236. this.calciteSelectChange.emit();
  17237. };
  17238. }
  17239. valueHandler(value) {
  17240. const items = this.el.querySelectorAll("calcite-option");
  17241. items.forEach((item) => (item.selected = item.value === value));
  17242. }
  17243. selectedOptionHandler(selectedOption) {
  17244. this.value = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value;
  17245. }
  17246. //--------------------------------------------------------------------------
  17247. //
  17248. // Lifecycle
  17249. //
  17250. //--------------------------------------------------------------------------
  17251. connectedCallback() {
  17252. var _a;
  17253. const { el } = this;
  17254. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(el, {
  17255. subtree: true,
  17256. childList: true
  17257. });
  17258. connectLabel(this);
  17259. connectForm(this);
  17260. }
  17261. disconnectedCallback() {
  17262. var _a;
  17263. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  17264. disconnectLabel(this);
  17265. disconnectForm(this);
  17266. }
  17267. componentDidLoad() {
  17268. var _a, _b;
  17269. afterConnectDefaultValueSet(this, (_b = (_a = this.selectedOption) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : "");
  17270. }
  17271. componentDidRender() {
  17272. updateHostInteraction(this);
  17273. }
  17274. //--------------------------------------------------------------------------
  17275. //
  17276. // Public Methods
  17277. //
  17278. //--------------------------------------------------------------------------
  17279. /** Sets focus on the component. */
  17280. async setFocus() {
  17281. focusElement(this.selectEl);
  17282. }
  17283. handleOptionOrGroupChange(event) {
  17284. event.stopPropagation();
  17285. const optionOrGroup = event.target;
  17286. const nativeEl = this.componentToNativeEl.get(optionOrGroup);
  17287. if (!nativeEl) {
  17288. return;
  17289. }
  17290. this.updateNativeElement(optionOrGroup, nativeEl);
  17291. if (isOption(optionOrGroup) && optionOrGroup.selected) {
  17292. this.deselectAllExcept(optionOrGroup);
  17293. this.selectedOption = optionOrGroup;
  17294. }
  17295. }
  17296. //--------------------------------------------------------------------------
  17297. //
  17298. // Private Methods
  17299. //
  17300. //--------------------------------------------------------------------------
  17301. onLabelClick() {
  17302. this.setFocus();
  17303. }
  17304. updateNativeElement(optionOrGroup, nativeOptionOrGroup) {
  17305. nativeOptionOrGroup.disabled = optionOrGroup.disabled;
  17306. nativeOptionOrGroup.label = optionOrGroup.label;
  17307. if (isOption(optionOrGroup)) {
  17308. const option = nativeOptionOrGroup;
  17309. option.selected = optionOrGroup.selected;
  17310. option.value = optionOrGroup.value;
  17311. // need to set innerText for mobile
  17312. // see https://stackoverflow.com/questions/35021620/ios-safari-not-showing-all-options-for-select-menu/41749701
  17313. option.innerText = optionOrGroup.label;
  17314. }
  17315. }
  17316. clearInternalSelect() {
  17317. this.componentToNativeEl.forEach((value) => value.remove());
  17318. this.componentToNativeEl.clear();
  17319. }
  17320. selectFromNativeOption(nativeOption) {
  17321. if (!nativeOption) {
  17322. return;
  17323. }
  17324. let futureSelected;
  17325. this.componentToNativeEl.forEach((nativeOptionOrGroup, optionOrGroup) => {
  17326. if (isOption(optionOrGroup) && nativeOptionOrGroup === nativeOption) {
  17327. optionOrGroup.selected = true;
  17328. futureSelected = optionOrGroup;
  17329. this.deselectAllExcept(optionOrGroup);
  17330. }
  17331. });
  17332. if (futureSelected) {
  17333. this.selectedOption = futureSelected;
  17334. }
  17335. }
  17336. toNativeElement(optionOrGroup) {
  17337. if (isOption(optionOrGroup)) {
  17338. const option = document.createElement("option");
  17339. this.updateNativeElement(optionOrGroup, option);
  17340. this.componentToNativeEl.set(optionOrGroup, option);
  17341. return option;
  17342. }
  17343. if (isOptionGroup(optionOrGroup)) {
  17344. const group = document.createElement("optgroup");
  17345. this.updateNativeElement(optionOrGroup, group);
  17346. Array.from(optionOrGroup.children).forEach((option) => {
  17347. const nativeOption = this.toNativeElement(option);
  17348. group.append(nativeOption);
  17349. this.componentToNativeEl.set(optionOrGroup, nativeOption);
  17350. });
  17351. this.componentToNativeEl.set(optionOrGroup, group);
  17352. return group;
  17353. }
  17354. throw new Error("unsupported element child provided");
  17355. }
  17356. deselectAllExcept(except) {
  17357. this.el.querySelectorAll("calcite-option").forEach((option) => {
  17358. if (option === except) {
  17359. return;
  17360. }
  17361. option.selected = false;
  17362. });
  17363. }
  17364. //--------------------------------------------------------------------------
  17365. //
  17366. // Render Methods
  17367. //
  17368. //--------------------------------------------------------------------------
  17369. renderChevron() {
  17370. return (h("div", { class: CSS$c.iconContainer }, h("calcite-icon", { class: CSS$c.icon, icon: "chevron-down", scale: "s" })));
  17371. }
  17372. render() {
  17373. 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 })));
  17374. }
  17375. get el() { return this; }
  17376. static get watchers() { return {
  17377. "value": ["valueHandler"],
  17378. "selectedOption": ["selectedOptionHandler"]
  17379. }; }
  17380. static get style() { return selectCss; }
  17381. };
  17382. const CSS$b = {
  17383. main: "main",
  17384. mainReversed: "main--reversed",
  17385. content: "content",
  17386. contentBehind: "content--behind",
  17387. footer: "footer"
  17388. };
  17389. const SLOTS$7 = {
  17390. centerRow: "center-row",
  17391. primaryPanel: "primary-panel",
  17392. contextualPanel: "contextual-panel",
  17393. header: "header",
  17394. footer: "footer"
  17395. };
  17396. 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}";
  17397. const Shell = class extends HTMLElement$1 {
  17398. constructor() {
  17399. super();
  17400. this.__registerHost();
  17401. this.__attachShadow();
  17402. // --------------------------------------------------------------------------
  17403. //
  17404. // Properties
  17405. //
  17406. // --------------------------------------------------------------------------
  17407. /**
  17408. * Positions the center content behind any calcite-shell-panels.
  17409. */
  17410. this.contentBehind = false;
  17411. }
  17412. // --------------------------------------------------------------------------
  17413. //
  17414. // Lifecycle
  17415. //
  17416. // --------------------------------------------------------------------------
  17417. connectedCallback() {
  17418. connectConditionalSlotComponent(this);
  17419. }
  17420. disconnectedCallback() {
  17421. disconnectConditionalSlotComponent(this);
  17422. }
  17423. // --------------------------------------------------------------------------
  17424. //
  17425. // Render Methods
  17426. //
  17427. // --------------------------------------------------------------------------
  17428. renderHeader() {
  17429. const hasHeader = !!getSlotted(this.el, SLOTS$7.header);
  17430. return hasHeader ? h("slot", { key: "header", name: SLOTS$7.header }) : null;
  17431. }
  17432. renderContent() {
  17433. const defaultSlotNode = h("slot", { key: "default-slot" });
  17434. const centerRowSlotNode = h("slot", { key: "center-row-slot", name: SLOTS$7.centerRow });
  17435. const contentContainerKey = "content-container";
  17436. const content = !!this.contentBehind
  17437. ? [
  17438. h("div", { class: {
  17439. [CSS$b.content]: true,
  17440. [CSS$b.contentBehind]: true
  17441. }, key: contentContainerKey }, defaultSlotNode),
  17442. centerRowSlotNode
  17443. ]
  17444. : [
  17445. h("div", { class: CSS$b.content, key: contentContainerKey }, defaultSlotNode, centerRowSlotNode)
  17446. ];
  17447. return content;
  17448. }
  17449. renderFooter() {
  17450. const hasFooter = !!getSlotted(this.el, SLOTS$7.footer);
  17451. return hasFooter ? (h("div", { class: CSS$b.footer, key: "footer" }, h("slot", { name: SLOTS$7.footer }))) : null;
  17452. }
  17453. renderMain() {
  17454. const primaryPanel = getSlotted(this.el, SLOTS$7.primaryPanel);
  17455. const mainClasses = {
  17456. [CSS$b.main]: true,
  17457. [CSS$b.mainReversed]: (primaryPanel === null || primaryPanel === void 0 ? void 0 : primaryPanel.position) === "end"
  17458. };
  17459. return (h("div", { class: mainClasses }, h("slot", { name: SLOTS$7.primaryPanel }), this.renderContent(), h("slot", { name: SLOTS$7.contextualPanel })));
  17460. }
  17461. render() {
  17462. return (h(Fragment, null, this.renderHeader(), this.renderMain(), this.renderFooter()));
  17463. }
  17464. get el() { return this; }
  17465. static get style() { return shellCss; }
  17466. };
  17467. const CSS$a = {
  17468. actionBarContainer: "action-bar-container",
  17469. content: "content"
  17470. };
  17471. const SLOTS$6 = {
  17472. actionBar: "action-bar"
  17473. };
  17474. 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)}";
  17475. const ShellCenterRow = class extends HTMLElement$1 {
  17476. constructor() {
  17477. super();
  17478. this.__registerHost();
  17479. this.__attachShadow();
  17480. // --------------------------------------------------------------------------
  17481. //
  17482. // Properties
  17483. //
  17484. // --------------------------------------------------------------------------
  17485. /**
  17486. * This property makes the content area appear like a "floating" panel.
  17487. */
  17488. this.detached = false;
  17489. /**
  17490. * Specifies the maximum height of the row.
  17491. */
  17492. this.heightScale = "s";
  17493. /**
  17494. * Arranges the component depending on the elements 'dir' property.
  17495. */
  17496. this.position = "end";
  17497. }
  17498. // --------------------------------------------------------------------------
  17499. //
  17500. // Lifecycle
  17501. //
  17502. // --------------------------------------------------------------------------
  17503. connectedCallback() {
  17504. connectConditionalSlotComponent(this);
  17505. }
  17506. disconnectedCallback() {
  17507. disconnectConditionalSlotComponent(this);
  17508. }
  17509. // --------------------------------------------------------------------------
  17510. //
  17511. // Render Methods
  17512. //
  17513. // --------------------------------------------------------------------------
  17514. render() {
  17515. const { el } = this;
  17516. const contentNode = (h("div", { class: CSS$a.content }, h("slot", null)));
  17517. const actionBar = getSlotted(el, SLOTS$6.actionBar);
  17518. const actionBarNode = actionBar ? (h("div", { class: CSS$a.actionBarContainer, key: "action-bar" }, h("slot", { name: SLOTS$6.actionBar }))) : null;
  17519. const children = [actionBarNode, contentNode];
  17520. if ((actionBar === null || actionBar === void 0 ? void 0 : actionBar.position) === "end") {
  17521. children.reverse();
  17522. }
  17523. return h(Fragment, null, children);
  17524. }
  17525. get el() { return this; }
  17526. static get style() { return shellCenterRowCss; }
  17527. };
  17528. const CSS$9 = {
  17529. container: "container",
  17530. content: "content",
  17531. contentHeader: "content__header",
  17532. contentBody: "content__body",
  17533. contentDetached: "content--detached",
  17534. separator: "separator"
  17535. };
  17536. const SLOTS$5 = {
  17537. actionBar: "action-bar",
  17538. header: "header"
  17539. };
  17540. const TEXT$3 = {
  17541. resize: "Resize"
  17542. };
  17543. 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}";
  17544. const ShellPanel = class extends HTMLElement$1 {
  17545. constructor() {
  17546. super();
  17547. this.__registerHost();
  17548. this.__attachShadow();
  17549. this.calciteShellPanelToggle = createEvent(this, "calciteShellPanelToggle", 7);
  17550. // --------------------------------------------------------------------------
  17551. //
  17552. // Properties
  17553. //
  17554. // --------------------------------------------------------------------------
  17555. /**
  17556. * Hide the content panel.
  17557. */
  17558. this.collapsed = false;
  17559. /**
  17560. * This property makes the content area appear like a "floating" panel.
  17561. */
  17562. this.detached = false;
  17563. /**
  17564. * Specifies the maximum height of the contents when detached.
  17565. */
  17566. this.detachedHeightScale = "l";
  17567. /**
  17568. * This sets width of the content area.
  17569. */
  17570. this.widthScale = "m";
  17571. /**
  17572. * Accessible label for resize separator.
  17573. * @default "Resize"
  17574. */
  17575. this.intlResize = TEXT$3.resize;
  17576. /**
  17577. * This property makes the content area resizable if the calcite-shell-panel is not 'detached'.
  17578. */
  17579. this.resizable = false;
  17580. this.contentWidth = null;
  17581. this.initialContentWidth = null;
  17582. this.initialClientX = null;
  17583. this.contentWidthMax = null;
  17584. this.contentWidthMin = null;
  17585. this.step = 1;
  17586. this.stepMultiplier = 10;
  17587. this.storeContentEl = (contentEl) => {
  17588. this.contentEl = contentEl;
  17589. };
  17590. this.getKeyAdjustedWidth = (event) => {
  17591. const { key } = event;
  17592. const { el, step, stepMultiplier, contentWidthMin, contentWidthMax, initialContentWidth, position } = this;
  17593. const multipliedStep = step * stepMultiplier;
  17594. const MOVEMENT_KEYS = [
  17595. "ArrowUp",
  17596. "ArrowDown",
  17597. "ArrowLeft",
  17598. "ArrowRight",
  17599. "Home",
  17600. "End",
  17601. "PageUp",
  17602. "PageDown"
  17603. ];
  17604. if (MOVEMENT_KEYS.indexOf(key) > -1) {
  17605. event.preventDefault();
  17606. }
  17607. const dir = getElementDir(el);
  17608. const directionKeys = ["ArrowLeft", "ArrowRight"];
  17609. const directionFactor = dir === "rtl" && directionKeys.includes(key) ? -1 : 1;
  17610. const increaseKeys = key === "ArrowUp" ||
  17611. (position === "end" ? key === directionKeys[0] : key === directionKeys[1]);
  17612. if (increaseKeys) {
  17613. const stepValue = event.shiftKey ? multipliedStep : step;
  17614. return initialContentWidth + directionFactor * stepValue;
  17615. }
  17616. const decreaseKeys = key === "ArrowDown" ||
  17617. (position === "end" ? key === directionKeys[1] : key === directionKeys[0]);
  17618. if (decreaseKeys) {
  17619. const stepValue = event.shiftKey ? multipliedStep : step;
  17620. return initialContentWidth - directionFactor * stepValue;
  17621. }
  17622. if (typeof contentWidthMin === "number" && key === "Home") {
  17623. return contentWidthMin;
  17624. }
  17625. if (typeof contentWidthMax === "number" && key === "End") {
  17626. return contentWidthMax;
  17627. }
  17628. if (key === "PageDown") {
  17629. return initialContentWidth - multipliedStep;
  17630. }
  17631. if (key === "PageUp") {
  17632. return initialContentWidth + multipliedStep;
  17633. }
  17634. return null;
  17635. };
  17636. this.separatorKeyDown = (event) => {
  17637. this.setInitialContentWidth();
  17638. const width = this.getKeyAdjustedWidth(event);
  17639. if (typeof width === "number") {
  17640. this.setContentWidth(width);
  17641. }
  17642. };
  17643. this.separatorPointerMove = (event) => {
  17644. event.preventDefault();
  17645. const { el, initialContentWidth, position, initialClientX } = this;
  17646. const offset = event.clientX - initialClientX;
  17647. const dir = getElementDir(el);
  17648. const adjustmentDirection = dir === "rtl" ? -1 : 1;
  17649. const adjustedOffset = position === "end" ? -adjustmentDirection * offset : adjustmentDirection * offset;
  17650. const width = initialContentWidth + adjustedOffset;
  17651. this.setContentWidth(width);
  17652. };
  17653. this.separatorPointerUp = (event) => {
  17654. event.preventDefault();
  17655. document.removeEventListener("pointerup", this.separatorPointerUp);
  17656. document.removeEventListener("pointermove", this.separatorPointerMove);
  17657. };
  17658. this.setInitialContentWidth = () => {
  17659. var _a;
  17660. this.initialContentWidth = (_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width;
  17661. };
  17662. this.separatorPointerDown = (event) => {
  17663. event.preventDefault();
  17664. const { separatorEl } = this;
  17665. separatorEl && document.activeElement !== separatorEl && separatorEl.focus();
  17666. this.setInitialContentWidth();
  17667. this.initialClientX = event.clientX;
  17668. document.addEventListener("pointerup", this.separatorPointerUp);
  17669. document.addEventListener("pointermove", this.separatorPointerMove);
  17670. };
  17671. this.connectSeparator = (separatorEl) => {
  17672. this.disconnectSeparator();
  17673. this.separatorEl = separatorEl;
  17674. separatorEl.addEventListener("pointerdown", this.separatorPointerDown);
  17675. };
  17676. this.disconnectSeparator = () => {
  17677. var _a;
  17678. (_a = this.separatorEl) === null || _a === void 0 ? void 0 : _a.removeEventListener("pointerdown", this.separatorPointerDown);
  17679. };
  17680. }
  17681. watchHandler() {
  17682. this.calciteShellPanelToggle.emit();
  17683. }
  17684. //--------------------------------------------------------------------------
  17685. //
  17686. // Lifecycle
  17687. //
  17688. //--------------------------------------------------------------------------
  17689. connectedCallback() {
  17690. connectConditionalSlotComponent(this);
  17691. }
  17692. disconnectedCallback() {
  17693. disconnectConditionalSlotComponent(this);
  17694. this.disconnectSeparator();
  17695. }
  17696. componentDidLoad() {
  17697. this.updateAriaValues();
  17698. }
  17699. // --------------------------------------------------------------------------
  17700. //
  17701. // Render Methods
  17702. //
  17703. // --------------------------------------------------------------------------
  17704. renderHeader() {
  17705. const { el } = this;
  17706. const hasHeader = getSlotted(el, SLOTS$5.header);
  17707. return hasHeader ? (h("div", { class: CSS$9.contentHeader, key: "header" }, h("slot", { name: SLOTS$5.header }))) : null;
  17708. }
  17709. render() {
  17710. const { collapsed, detached, position, initialContentWidth, contentWidth, contentWidthMax, contentWidthMin, intlResize, resizable } = this;
  17711. const allowResizing = !detached && resizable;
  17712. 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))));
  17713. 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;
  17714. const actionBarNode = h("slot", { key: "action-bar", name: SLOTS$5.actionBar });
  17715. const mainNodes = [actionBarNode, contentNode, separatorNode];
  17716. if (position === "end") {
  17717. mainNodes.reverse();
  17718. }
  17719. return h("div", { class: { [CSS$9.container]: true } }, mainNodes);
  17720. }
  17721. // --------------------------------------------------------------------------
  17722. //
  17723. // private Methods
  17724. //
  17725. // --------------------------------------------------------------------------
  17726. setContentWidth(width) {
  17727. const { contentWidthMax, contentWidthMin } = this;
  17728. const roundedWidth = Math.round(width);
  17729. this.contentWidth =
  17730. typeof contentWidthMax === "number" && typeof contentWidthMin === "number"
  17731. ? clamp(roundedWidth, contentWidthMin, contentWidthMax)
  17732. : roundedWidth;
  17733. }
  17734. updateAriaValues() {
  17735. const { contentEl } = this;
  17736. const computedStyle = contentEl && getComputedStyle(contentEl);
  17737. if (!computedStyle) {
  17738. return;
  17739. }
  17740. const max = parseInt(computedStyle.getPropertyValue("max-width"), 10);
  17741. const min = parseInt(computedStyle.getPropertyValue("min-width"), 10);
  17742. const valueNow = parseInt(computedStyle.getPropertyValue("width"), 10);
  17743. if (typeof valueNow === "number" && !isNaN(valueNow)) {
  17744. this.initialContentWidth = valueNow;
  17745. }
  17746. if (typeof max === "number" && !isNaN(max)) {
  17747. this.contentWidthMax = max;
  17748. }
  17749. if (typeof min === "number" && !isNaN(min)) {
  17750. this.contentWidthMin = min;
  17751. }
  17752. forceUpdate(this);
  17753. }
  17754. get el() { return this; }
  17755. static get watchers() { return {
  17756. "collapsed": ["watchHandler"]
  17757. }; }
  17758. static get style() { return shellPanelCss; }
  17759. };
  17760. 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}";
  17761. function isRange(value) {
  17762. return Array.isArray(value);
  17763. }
  17764. const Slider = class extends HTMLElement$1 {
  17765. constructor() {
  17766. super();
  17767. this.__registerHost();
  17768. this.__attachShadow();
  17769. this.calciteSliderInput = createEvent(this, "calciteSliderInput", 7);
  17770. this.calciteSliderChange = createEvent(this, "calciteSliderChange", 7);
  17771. this.calciteSliderUpdate = createEvent(this, "calciteSliderUpdate", 7);
  17772. //--------------------------------------------------------------------------
  17773. //
  17774. // Properties
  17775. //
  17776. //--------------------------------------------------------------------------
  17777. /** Disable and gray out the slider */
  17778. this.disabled = false;
  17779. /** Indicates if a histogram is present */
  17780. this.hasHistogram = false;
  17781. /** Label handles with their numeric value */
  17782. this.labelHandles = false;
  17783. /** Label tick marks with their numeric value. */
  17784. this.labelTicks = false;
  17785. /** Maximum selectable value */
  17786. this.max = 100;
  17787. /** Minimum selectable value */
  17788. this.min = 0;
  17789. /**
  17790. * When true, the slider will display values from high to low.
  17791. *
  17792. * Note that this value will be ignored if the slider has an associated histogram.
  17793. */
  17794. this.mirrored = false;
  17795. /** Use finer point for handles */
  17796. this.precise = false;
  17797. /**
  17798. * When true, makes the component required for form-submission.
  17799. */
  17800. this.required = false;
  17801. /** When true, enables snap selection along the step interval */
  17802. this.snap = false;
  17803. /** Interval to move on up/down keys */
  17804. this.step = 1;
  17805. /** Currently selected number (if single select) */
  17806. this.value = 0;
  17807. /**
  17808. * Specify the scale of the slider, defaults to m
  17809. */
  17810. this.scale = "m";
  17811. this.guid = `calcite-slider-${guid()}`;
  17812. this.activeProp = "value";
  17813. this.minMaxValueRange = null;
  17814. this.minValueDragRange = null;
  17815. this.maxValueDragRange = null;
  17816. this.tickValues = [];
  17817. this.dragUpdate = (event) => {
  17818. event.preventDefault();
  17819. if (this.dragProp) {
  17820. const value = this.translate(event.clientX || event.pageX);
  17821. if (isRange(this.value) && this.dragProp === "minMaxValue") {
  17822. if (this.minValueDragRange && this.maxValueDragRange && this.minMaxValueRange) {
  17823. const newMinValue = value - this.minValueDragRange;
  17824. const newMaxValue = value + this.maxValueDragRange;
  17825. if (newMaxValue <= this.max &&
  17826. newMinValue >= this.min &&
  17827. newMaxValue - newMinValue === this.minMaxValueRange) {
  17828. this.minValue = this.clamp(newMinValue, "minValue");
  17829. this.maxValue = this.clamp(newMaxValue, "maxValue");
  17830. }
  17831. }
  17832. else {
  17833. this.minValueDragRange = value - this.minValue;
  17834. this.maxValueDragRange = this.maxValue - value;
  17835. this.minMaxValueRange = this.maxValue - this.minValue;
  17836. }
  17837. }
  17838. else {
  17839. this.setValue(this.dragProp, this.clamp(value, this.dragProp));
  17840. }
  17841. }
  17842. };
  17843. this.dragEnd = (event) => {
  17844. this.removeDragListeners();
  17845. this.focusActiveHandle(event.clientX);
  17846. if (this.lastDragPropValue != this[this.dragProp]) {
  17847. this.emitChange();
  17848. }
  17849. this.dragProp = null;
  17850. this.lastDragPropValue = null;
  17851. this.minValueDragRange = null;
  17852. this.maxValueDragRange = null;
  17853. this.minMaxValueRange = null;
  17854. };
  17855. /**
  17856. * Set the reference of the track Element
  17857. * @internal
  17858. * @param node
  17859. */
  17860. this.storeTrackRef = (node) => {
  17861. this.trackEl = node;
  17862. };
  17863. }
  17864. histogramWatcher(newHistogram) {
  17865. this.hasHistogram = !!newHistogram;
  17866. }
  17867. valueHandler() {
  17868. this.setMinMaxFromValue();
  17869. }
  17870. minMaxValueHandler() {
  17871. this.setValueFromMinMax();
  17872. }
  17873. //--------------------------------------------------------------------------
  17874. //
  17875. // Lifecycle
  17876. //
  17877. //--------------------------------------------------------------------------
  17878. connectedCallback() {
  17879. this.setMinMaxFromValue();
  17880. this.setValueFromMinMax();
  17881. connectLabel(this);
  17882. connectForm(this);
  17883. }
  17884. disconnectedCallback() {
  17885. disconnectLabel(this);
  17886. disconnectForm(this);
  17887. this.removeDragListeners();
  17888. }
  17889. componentWillLoad() {
  17890. this.tickValues = this.generateTickValues();
  17891. if (!isRange(this.value)) {
  17892. this.value = this.clamp(this.value);
  17893. }
  17894. afterConnectDefaultValueSet(this, this.value);
  17895. if (this.snap && !isRange(this.value)) {
  17896. this.value = this.getClosestStep(this.value);
  17897. }
  17898. if (this.histogram) {
  17899. this.hasHistogram = true;
  17900. }
  17901. }
  17902. componentDidRender() {
  17903. if (this.labelHandles) {
  17904. this.adjustHostObscuredHandleLabel("value");
  17905. if (isRange(this.value)) {
  17906. this.adjustHostObscuredHandleLabel("minValue");
  17907. if (!(this.precise && !this.hasHistogram)) {
  17908. this.hyphenateCollidingRangeHandleLabels();
  17909. }
  17910. }
  17911. }
  17912. this.hideObscuredBoundingTickLabels();
  17913. updateHostInteraction(this);
  17914. }
  17915. render() {
  17916. const id = this.el.id || this.guid;
  17917. const maxProp = isRange(this.value) ? "maxValue" : "value";
  17918. const value = isRange(this.value) ? this.maxValue : this.value;
  17919. const min = this.minValue || this.min;
  17920. const useMinValue = this.shouldUseMinValue();
  17921. const minInterval = this.getUnitInterval(useMinValue ? this.minValue : min) * 100;
  17922. const maxInterval = this.getUnitInterval(value) * 100;
  17923. const mirror = this.shouldMirror();
  17924. const leftThumbOffset = `${mirror ? 100 - minInterval : minInterval}%`;
  17925. const rightThumbOffset = `${mirror ? maxInterval : 100 - maxInterval}%`;
  17926. const valueIsRange = isRange(this.value);
  17927. 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: {
  17928. thumb: true,
  17929. "thumb--value": true,
  17930. "thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp
  17931. }, 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" })));
  17932. 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: {
  17933. thumb: true,
  17934. "thumb--value": true,
  17935. "thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp
  17936. }, 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" })));
  17937. 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: {
  17938. thumb: true,
  17939. "thumb--value": true,
  17940. "thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp
  17941. }, 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)));
  17942. 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: {
  17943. thumb: true,
  17944. "thumb--value": true,
  17945. "thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp,
  17946. "thumb--precise": true
  17947. }, 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" })));
  17948. 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: {
  17949. thumb: true,
  17950. "thumb--value": true,
  17951. "thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp,
  17952. "thumb--precise": true
  17953. }, 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" })));
  17954. 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: {
  17955. thumb: true,
  17956. "thumb--value": true,
  17957. "thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp,
  17958. "thumb--precise": true
  17959. }, 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" })));
  17960. 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: {
  17961. thumb: true,
  17962. "thumb--value": true,
  17963. "thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp,
  17964. "thumb--precise": true
  17965. }, 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)));
  17966. 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: {
  17967. thumb: true,
  17968. "thumb--minValue": true,
  17969. "thumb--active": this.dragProp === "minValue"
  17970. }, 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" })));
  17971. 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: {
  17972. thumb: true,
  17973. "thumb--minValue": true,
  17974. "thumb--active": this.dragProp === "minValue"
  17975. }, 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" })));
  17976. 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: {
  17977. thumb: true,
  17978. "thumb--minValue": true,
  17979. "thumb--active": this.dragProp === "minValue"
  17980. }, 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())));
  17981. 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: {
  17982. thumb: true,
  17983. "thumb--minValue": true,
  17984. "thumb--active": this.dragProp === "minValue",
  17985. "thumb--precise": true
  17986. }, 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" })));
  17987. 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: {
  17988. thumb: true,
  17989. "thumb--minValue": true,
  17990. "thumb--active": this.dragProp === "minValue",
  17991. "thumb--precise": true
  17992. }, 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())));
  17993. return (h(Host, { id: id, onTouchStart: this.handleTouchStart }, h("div", { class: {
  17994. ["container"]: true,
  17995. ["container--range"]: valueIsRange,
  17996. [`scale--${this.scale}`]: true
  17997. } }, this.renderGraph(), h("div", { class: "track", ref: this.storeTrackRef }, h("div", { class: "track__range", onPointerDown: () => this.dragStart("minMaxValue"), style: {
  17998. left: `${mirror ? 100 - maxInterval : minInterval}%`,
  17999. right: `${mirror ? minInterval : 100 - maxInterval}%`
  18000. } }), h("div", { class: "ticks" }, this.tickValues.map((tick) => {
  18001. const tickOffset = `${this.getUnitInterval(tick) * 100}%`;
  18002. let activeTicks = tick >= min && tick <= value;
  18003. if (useMinValue) {
  18004. activeTicks = tick >= this.minValue && tick <= this.maxValue;
  18005. }
  18006. return (h("span", { class: {
  18007. tick: true,
  18008. "tick--active": activeTicks
  18009. }, style: {
  18010. left: mirror ? "" : tickOffset,
  18011. right: mirror ? tickOffset : ""
  18012. } }, this.renderTickLabel(tick)));
  18013. }))), h("div", { class: "thumb-container" }, !this.precise && !this.labelHandles && valueIsRange && minHandle, !this.hasHistogram &&
  18014. !this.precise &&
  18015. this.labelHandles &&
  18016. valueIsRange &&
  18017. minLabeledHandle, this.precise && !this.labelHandles && valueIsRange && minPreciseHandle, this.precise && this.labelHandles && valueIsRange && minLabeledPreciseHandle, this.hasHistogram &&
  18018. !this.precise &&
  18019. this.labelHandles &&
  18020. valueIsRange &&
  18021. 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 &&
  18022. this.precise &&
  18023. this.labelHandles &&
  18024. histogramLabeledPreciseHandle, h(HiddenFormInputSlot, { component: this })))));
  18025. }
  18026. renderGraph() {
  18027. 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;
  18028. }
  18029. renderTickLabel(tick) {
  18030. const valueIsRange = isRange(this.value);
  18031. const isMinTickLabel = tick === this.min;
  18032. const isMaxTickLabel = tick === this.max;
  18033. const tickLabel = (h("span", { class: {
  18034. tick__label: true,
  18035. "tick__label--min": isMinTickLabel,
  18036. "tick__label--max": isMaxTickLabel
  18037. } }, tick.toLocaleString()));
  18038. if (this.labelTicks && !this.hasHistogram && !valueIsRange) {
  18039. return tickLabel;
  18040. }
  18041. if (this.labelTicks &&
  18042. !this.hasHistogram &&
  18043. valueIsRange &&
  18044. !this.precise &&
  18045. !this.labelHandles) {
  18046. return tickLabel;
  18047. }
  18048. if (this.labelTicks &&
  18049. !this.hasHistogram &&
  18050. valueIsRange &&
  18051. !this.precise &&
  18052. this.labelHandles) {
  18053. return tickLabel;
  18054. }
  18055. if (this.labelTicks &&
  18056. !this.hasHistogram &&
  18057. valueIsRange &&
  18058. this.precise &&
  18059. (isMinTickLabel || isMaxTickLabel)) {
  18060. return tickLabel;
  18061. }
  18062. if (this.labelTicks && this.hasHistogram && !this.precise && !this.labelHandles) {
  18063. return tickLabel;
  18064. }
  18065. if (this.labelTicks &&
  18066. this.hasHistogram &&
  18067. this.precise &&
  18068. !this.labelHandles &&
  18069. (isMinTickLabel || isMaxTickLabel)) {
  18070. return tickLabel;
  18071. }
  18072. if (this.labelTicks &&
  18073. this.hasHistogram &&
  18074. !this.precise &&
  18075. this.labelHandles &&
  18076. (isMinTickLabel || isMaxTickLabel)) {
  18077. return tickLabel;
  18078. }
  18079. if (this.labelTicks &&
  18080. this.hasHistogram &&
  18081. this.precise &&
  18082. this.labelHandles &&
  18083. (isMinTickLabel || isMaxTickLabel)) {
  18084. return tickLabel;
  18085. }
  18086. return null;
  18087. }
  18088. //--------------------------------------------------------------------------
  18089. //
  18090. // Event Listeners
  18091. //
  18092. //--------------------------------------------------------------------------
  18093. keyDownHandler(event) {
  18094. const mirror = this.shouldMirror();
  18095. const { activeProp, max, min, pageStep, step } = this;
  18096. const value = this[activeProp];
  18097. const key = event.key;
  18098. if (key === "Enter" || key === " ") {
  18099. event.preventDefault();
  18100. return;
  18101. }
  18102. let adjustment;
  18103. if (key === "ArrowUp" || key === "ArrowRight") {
  18104. const directionFactor = mirror && key === "ArrowRight" ? -1 : 1;
  18105. adjustment = value + step * directionFactor;
  18106. }
  18107. else if (key === "ArrowDown" || key === "ArrowLeft") {
  18108. const directionFactor = mirror && key === "ArrowLeft" ? -1 : 1;
  18109. adjustment = value - step * directionFactor;
  18110. }
  18111. else if (key === "PageUp") {
  18112. if (pageStep) {
  18113. adjustment = value + pageStep;
  18114. }
  18115. }
  18116. else if (key === "PageDown") {
  18117. if (pageStep) {
  18118. adjustment = value - pageStep;
  18119. }
  18120. }
  18121. else if (key === "Home") {
  18122. adjustment = min;
  18123. }
  18124. else if (key === "End") {
  18125. adjustment = max;
  18126. }
  18127. if (isNaN(adjustment)) {
  18128. return;
  18129. }
  18130. event.preventDefault();
  18131. const fixedDecimalAdjustment = Number(adjustment.toFixed(decimalPlaces(step)));
  18132. this.setValue(activeProp, this.clamp(fixedDecimalAdjustment, activeProp));
  18133. }
  18134. clickHandler(event) {
  18135. this.focusActiveHandle(event.clientX);
  18136. }
  18137. pointerDownHandler(event) {
  18138. const x = event.clientX || event.pageX;
  18139. const position = this.translate(x);
  18140. let prop = "value";
  18141. if (isRange(this.value)) {
  18142. const inRange = position >= this.minValue && position <= this.maxValue;
  18143. if (inRange && this.lastDragProp === "minMaxValue") {
  18144. prop = "minMaxValue";
  18145. }
  18146. else {
  18147. const closerToMax = Math.abs(this.maxValue - position) < Math.abs(this.minValue - position);
  18148. prop = closerToMax || position > this.maxValue ? "maxValue" : "minValue";
  18149. }
  18150. }
  18151. this.lastDragPropValue = this[prop];
  18152. this.dragStart(prop);
  18153. const isThumbActive = this.el.shadowRoot.querySelector(".thumb:active");
  18154. if (!isThumbActive) {
  18155. this.setValue(prop, this.clamp(position, prop));
  18156. }
  18157. }
  18158. handleTouchStart(event) {
  18159. // needed to prevent extra click at the end of a handle drag
  18160. event.preventDefault();
  18161. }
  18162. //--------------------------------------------------------------------------
  18163. //
  18164. // Public Methods
  18165. //
  18166. //--------------------------------------------------------------------------
  18167. /** Sets focus on the component. */
  18168. async setFocus() {
  18169. const handle = this.minHandle ? this.minHandle : this.maxHandle;
  18170. handle.focus();
  18171. }
  18172. //--------------------------------------------------------------------------
  18173. //
  18174. // Private Methods
  18175. //
  18176. //--------------------------------------------------------------------------
  18177. setValueFromMinMax() {
  18178. const { minValue, maxValue } = this;
  18179. if (typeof minValue === "number" && typeof maxValue === "number") {
  18180. this.value = [minValue, maxValue];
  18181. }
  18182. }
  18183. setMinMaxFromValue() {
  18184. const { value } = this;
  18185. if (isRange(value)) {
  18186. this.minValue = value[0];
  18187. this.maxValue = value[1];
  18188. }
  18189. }
  18190. onLabelClick() {
  18191. this.setFocus();
  18192. }
  18193. shouldMirror() {
  18194. return this.mirrored && !this.hasHistogram;
  18195. }
  18196. shouldUseMinValue() {
  18197. if (!isRange(this.value)) {
  18198. return false;
  18199. }
  18200. return ((this.hasHistogram && this.maxValue === 0) || (!this.hasHistogram && this.minValue === 0));
  18201. }
  18202. generateTickValues() {
  18203. const ticks = [];
  18204. let current = this.min;
  18205. while (this.ticks && current < this.max + this.ticks) {
  18206. ticks.push(Math.min(current, this.max));
  18207. current = current + this.ticks;
  18208. }
  18209. return ticks;
  18210. }
  18211. dragStart(prop) {
  18212. this.dragProp = prop;
  18213. this.lastDragProp = this.dragProp;
  18214. this.activeProp = prop;
  18215. document.addEventListener("pointermove", this.dragUpdate);
  18216. document.addEventListener("pointerup", this.dragEnd);
  18217. document.addEventListener("pointercancel", this.dragEnd);
  18218. }
  18219. focusActiveHandle(valueX) {
  18220. switch (this.dragProp) {
  18221. case "minValue":
  18222. this.minHandle.focus();
  18223. break;
  18224. case "maxValue":
  18225. this.maxHandle.focus();
  18226. break;
  18227. case "minMaxValue":
  18228. this.getClosestHandle(valueX).focus();
  18229. break;
  18230. }
  18231. }
  18232. emitInput() {
  18233. this.calciteSliderInput.emit();
  18234. this.calciteSliderUpdate.emit();
  18235. }
  18236. emitChange() {
  18237. this.calciteSliderChange.emit();
  18238. }
  18239. removeDragListeners() {
  18240. document.removeEventListener("pointermove", this.dragUpdate);
  18241. document.removeEventListener("pointerup", this.dragEnd);
  18242. document.removeEventListener("pointercancel", this.dragEnd);
  18243. }
  18244. /**
  18245. * Set the prop value if changed at the component level
  18246. * @param valueProp
  18247. * @param value
  18248. */
  18249. setValue(valueProp, value) {
  18250. const oldValue = this[valueProp];
  18251. const valueChanged = oldValue !== value;
  18252. if (!valueChanged) {
  18253. return;
  18254. }
  18255. this[valueProp] = value;
  18256. const dragging = this.dragProp;
  18257. if (!dragging) {
  18258. this.emitChange();
  18259. }
  18260. this.emitInput();
  18261. }
  18262. /**
  18263. * If number is outside range, constrain to min or max
  18264. * @internal
  18265. */
  18266. clamp(value, prop) {
  18267. value = clamp(value, this.min, this.max);
  18268. // ensure that maxValue and minValue don't swap positions
  18269. if (prop === "maxValue") {
  18270. value = Math.max(value, this.minValue);
  18271. }
  18272. if (prop === "minValue") {
  18273. value = Math.min(value, this.maxValue);
  18274. }
  18275. return value;
  18276. }
  18277. /**
  18278. * Translate a pixel position to value along the range
  18279. * @internal
  18280. */
  18281. translate(x) {
  18282. const range = this.max - this.min;
  18283. const { left, width } = this.trackEl.getBoundingClientRect();
  18284. const percent = (x - left) / width;
  18285. const mirror = this.shouldMirror();
  18286. const clampedValue = this.clamp(this.min + range * (mirror ? 1 - percent : percent));
  18287. let value = Number(clampedValue.toFixed(decimalPlaces(this.step)));
  18288. if (this.snap && this.step) {
  18289. value = this.getClosestStep(value);
  18290. }
  18291. return value;
  18292. }
  18293. /**
  18294. * Get closest allowed value along stepped values
  18295. * @internal
  18296. */
  18297. getClosestStep(num) {
  18298. num = Number(this.clamp(num).toFixed(decimalPlaces(this.step)));
  18299. if (this.step) {
  18300. const step = Math.round(num / this.step) * this.step;
  18301. num = Number(this.clamp(step).toFixed(decimalPlaces(this.step)));
  18302. }
  18303. return num;
  18304. }
  18305. getClosestHandle(valueX) {
  18306. return this.getDistanceX(this.maxHandle, valueX) > this.getDistanceX(this.minHandle, valueX)
  18307. ? this.minHandle
  18308. : this.maxHandle;
  18309. }
  18310. getDistanceX(el, valueX) {
  18311. return Math.abs(el.getBoundingClientRect().left - valueX);
  18312. }
  18313. getFontSizeForElement(element) {
  18314. return Number(window.getComputedStyle(element).getPropertyValue("font-size").match(/\d+/)[0]);
  18315. }
  18316. /**
  18317. * Get position of value along range as fractional value
  18318. * @return {number} number in the unit interval [0,1]
  18319. * @internal
  18320. */
  18321. getUnitInterval(num) {
  18322. num = this.clamp(num);
  18323. const range = this.max - this.min;
  18324. return (num - this.min) / range;
  18325. }
  18326. adjustHostObscuredHandleLabel(name) {
  18327. const label = this.el.shadowRoot.querySelector(`.handle__label--${name}`);
  18328. const labelStatic = this.el.shadowRoot.querySelector(`.handle__label--${name}.static`);
  18329. const labelTransformed = this.el.shadowRoot.querySelector(`.handle__label--${name}.transformed`);
  18330. const labelStaticBounds = labelStatic.getBoundingClientRect();
  18331. const labelStaticOffset = this.getHostOffset(labelStaticBounds.left, labelStaticBounds.right);
  18332. label.style.transform = `translateX(${labelStaticOffset}px)`;
  18333. labelTransformed.style.transform = `translateX(${labelStaticOffset}px)`;
  18334. }
  18335. hyphenateCollidingRangeHandleLabels() {
  18336. const { shadowRoot } = this.el;
  18337. const mirror = this.shouldMirror();
  18338. const leftModifier = mirror ? "value" : "minValue";
  18339. const rightModifier = mirror ? "minValue" : "value";
  18340. const leftValueLabel = shadowRoot.querySelector(`.handle__label--${leftModifier}`);
  18341. const leftValueLabelStatic = shadowRoot.querySelector(`.handle__label--${leftModifier}.static`);
  18342. const leftValueLabelTransformed = shadowRoot.querySelector(`.handle__label--${leftModifier}.transformed`);
  18343. const leftValueLabelStaticHostOffset = this.getHostOffset(leftValueLabelStatic.getBoundingClientRect().left, leftValueLabelStatic.getBoundingClientRect().right);
  18344. const rightValueLabel = shadowRoot.querySelector(`.handle__label--${rightModifier}`);
  18345. const rightValueLabelStatic = shadowRoot.querySelector(`.handle__label--${rightModifier}.static`);
  18346. const rightValueLabelTransformed = shadowRoot.querySelector(`.handle__label--${rightModifier}.transformed`);
  18347. const rightValueLabelStaticHostOffset = this.getHostOffset(rightValueLabelStatic.getBoundingClientRect().left, rightValueLabelStatic.getBoundingClientRect().right);
  18348. const labelFontSize = this.getFontSizeForElement(leftValueLabel);
  18349. const labelTransformedOverlap = this.getRangeLabelOverlap(leftValueLabelTransformed, rightValueLabelTransformed);
  18350. const hyphenLabel = leftValueLabel;
  18351. const labelOffset = labelFontSize / 2;
  18352. if (labelTransformedOverlap > 0) {
  18353. hyphenLabel.classList.add("hyphen", "hyphen--wrap");
  18354. if (rightValueLabelStaticHostOffset === 0 && leftValueLabelStaticHostOffset === 0) {
  18355. // Neither handle overlaps the host boundary
  18356. let leftValueLabelTranslate = labelTransformedOverlap / 2 - labelOffset;
  18357. leftValueLabelTranslate =
  18358. Math.sign(leftValueLabelTranslate) === -1
  18359. ? Math.abs(leftValueLabelTranslate)
  18360. : -leftValueLabelTranslate;
  18361. const leftValueLabelTransformedHostOffset = this.getHostOffset(leftValueLabelTransformed.getBoundingClientRect().left +
  18362. leftValueLabelTranslate -
  18363. labelOffset, leftValueLabelTransformed.getBoundingClientRect().right +
  18364. leftValueLabelTranslate -
  18365. labelOffset);
  18366. let rightValueLabelTranslate = labelTransformedOverlap / 2;
  18367. const rightValueLabelTransformedHostOffset = this.getHostOffset(rightValueLabelTransformed.getBoundingClientRect().left + rightValueLabelTranslate, rightValueLabelTransformed.getBoundingClientRect().right + rightValueLabelTranslate);
  18368. if (leftValueLabelTransformedHostOffset !== 0) {
  18369. leftValueLabelTranslate += leftValueLabelTransformedHostOffset;
  18370. rightValueLabelTranslate += leftValueLabelTransformedHostOffset;
  18371. }
  18372. if (rightValueLabelTransformedHostOffset !== 0) {
  18373. leftValueLabelTranslate += rightValueLabelTransformedHostOffset;
  18374. rightValueLabelTranslate += rightValueLabelTransformedHostOffset;
  18375. }
  18376. leftValueLabel.style.transform = `translateX(${leftValueLabelTranslate}px)`;
  18377. leftValueLabelTransformed.style.transform = `translateX(${leftValueLabelTranslate - labelOffset}px)`;
  18378. rightValueLabel.style.transform = `translateX(${rightValueLabelTranslate}px)`;
  18379. rightValueLabelTransformed.style.transform = `translateX(${rightValueLabelTranslate}px)`;
  18380. }
  18381. else if (leftValueLabelStaticHostOffset > 0 || rightValueLabelStaticHostOffset > 0) {
  18382. // labels overlap host boundary on the left side
  18383. leftValueLabel.style.transform = `translateX(${leftValueLabelStaticHostOffset + labelOffset}px)`;
  18384. rightValueLabel.style.transform = `translateX(${labelTransformedOverlap + rightValueLabelStaticHostOffset}px)`;
  18385. rightValueLabelTransformed.style.transform = `translateX(${labelTransformedOverlap + rightValueLabelStaticHostOffset}px)`;
  18386. }
  18387. else if (leftValueLabelStaticHostOffset < 0 || rightValueLabelStaticHostOffset < 0) {
  18388. // labels overlap host boundary on the right side
  18389. let leftValueLabelTranslate = Math.abs(leftValueLabelStaticHostOffset) + labelTransformedOverlap - labelOffset;
  18390. leftValueLabelTranslate =
  18391. Math.sign(leftValueLabelTranslate) === -1
  18392. ? Math.abs(leftValueLabelTranslate)
  18393. : -leftValueLabelTranslate;
  18394. leftValueLabel.style.transform = `translateX(${leftValueLabelTranslate}px)`;
  18395. leftValueLabelTransformed.style.transform = `translateX(${leftValueLabelTranslate - labelOffset}px)`;
  18396. }
  18397. }
  18398. else {
  18399. hyphenLabel.classList.remove("hyphen", "hyphen--wrap");
  18400. leftValueLabel.style.transform = `translateX(${leftValueLabelStaticHostOffset}px)`;
  18401. leftValueLabelTransformed.style.transform = `translateX(${leftValueLabelStaticHostOffset}px)`;
  18402. rightValueLabel.style.transform = `translateX(${rightValueLabelStaticHostOffset}px)`;
  18403. rightValueLabelTransformed.style.transform = `translateX(${rightValueLabelStaticHostOffset}px)`;
  18404. }
  18405. }
  18406. /**
  18407. * Hides bounding tick labels that are obscured by either handle.
  18408. */
  18409. hideObscuredBoundingTickLabels() {
  18410. const valueIsRange = isRange(this.value);
  18411. if (!this.hasHistogram && !valueIsRange && !this.labelHandles && !this.precise) {
  18412. return;
  18413. }
  18414. if (!this.hasHistogram && !valueIsRange && this.labelHandles && !this.precise) {
  18415. return;
  18416. }
  18417. if (!this.hasHistogram && !valueIsRange && !this.labelHandles && this.precise) {
  18418. return;
  18419. }
  18420. if (!this.hasHistogram && !valueIsRange && this.labelHandles && this.precise) {
  18421. return;
  18422. }
  18423. if (!this.hasHistogram && valueIsRange && !this.precise) {
  18424. return;
  18425. }
  18426. if (this.hasHistogram && !this.precise && !this.labelHandles) {
  18427. return;
  18428. }
  18429. const minHandle = this.el.shadowRoot.querySelector(".thumb--minValue");
  18430. const maxHandle = this.el.shadowRoot.querySelector(".thumb--value");
  18431. const minTickLabel = this.el.shadowRoot.querySelector(".tick__label--min");
  18432. const maxTickLabel = this.el.shadowRoot.querySelector(".tick__label--max");
  18433. if (!minHandle && maxHandle && minTickLabel && maxTickLabel) {
  18434. minTickLabel.style.opacity = this.isMinTickLabelObscured(minTickLabel, maxHandle) ? "0" : "1";
  18435. maxTickLabel.style.opacity = this.isMaxTickLabelObscured(maxTickLabel, maxHandle) ? "0" : "1";
  18436. }
  18437. if (minHandle && maxHandle && minTickLabel && maxTickLabel) {
  18438. minTickLabel.style.opacity =
  18439. this.isMinTickLabelObscured(minTickLabel, minHandle) ||
  18440. this.isMinTickLabelObscured(minTickLabel, maxHandle)
  18441. ? "0"
  18442. : "1";
  18443. maxTickLabel.style.opacity =
  18444. this.isMaxTickLabelObscured(maxTickLabel, minHandle) ||
  18445. (this.isMaxTickLabelObscured(maxTickLabel, maxHandle) && this.hasHistogram)
  18446. ? "0"
  18447. : "1";
  18448. }
  18449. }
  18450. /**
  18451. * Returns an integer representing the number of pixels to offset on the left or right side based on desired position behavior.
  18452. * @internal
  18453. */
  18454. getHostOffset(leftBounds, rightBounds) {
  18455. const hostBounds = this.el.getBoundingClientRect();
  18456. const buffer = 7;
  18457. if (leftBounds + buffer < hostBounds.left) {
  18458. return hostBounds.left - leftBounds - buffer;
  18459. }
  18460. if (rightBounds - buffer > hostBounds.right) {
  18461. return -(rightBounds - hostBounds.right) + buffer;
  18462. }
  18463. return 0;
  18464. }
  18465. /**
  18466. * Returns an integer representing the number of pixels that the two given span elements are overlapping, taking into account
  18467. * 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.
  18468. * @param leftLabel
  18469. * @param rightLabel
  18470. */
  18471. getRangeLabelOverlap(leftLabel, rightLabel) {
  18472. const leftLabelBounds = leftLabel.getBoundingClientRect();
  18473. const rightLabelBounds = rightLabel.getBoundingClientRect();
  18474. const leftLabelFontSize = this.getFontSizeForElement(leftLabel);
  18475. const rangeLabelOverlap = leftLabelBounds.right + leftLabelFontSize - rightLabelBounds.left;
  18476. return Math.max(rangeLabelOverlap, 0);
  18477. }
  18478. /**
  18479. * Returns a boolean value representing if the minLabel span element is obscured (being overlapped) by the given handle div element.
  18480. * @param minLabel
  18481. * @param handle
  18482. */
  18483. isMinTickLabelObscured(minLabel, handle) {
  18484. const minLabelBounds = minLabel.getBoundingClientRect();
  18485. const handleBounds = handle.getBoundingClientRect();
  18486. return intersects(minLabelBounds, handleBounds);
  18487. }
  18488. /**
  18489. * Returns a boolean value representing if the maxLabel span element is obscured (being overlapped) by the given handle div element.
  18490. * @param maxLabel
  18491. * @param handle
  18492. */
  18493. isMaxTickLabelObscured(maxLabel, handle) {
  18494. const maxLabelBounds = maxLabel.getBoundingClientRect();
  18495. const handleBounds = handle.getBoundingClientRect();
  18496. return intersects(maxLabelBounds, handleBounds);
  18497. }
  18498. get el() { return this; }
  18499. static get watchers() { return {
  18500. "histogram": ["histogramWatcher"],
  18501. "value": ["valueHandler"],
  18502. "minValue": ["minMaxValueHandler"],
  18503. "maxValue": ["minMaxValueHandler"]
  18504. }; }
  18505. static get style() { return sliderCss; }
  18506. };
  18507. /**!
  18508. * Sortable 1.15.0
  18509. * @author RubaXa <trash@rubaxa.org>
  18510. * @author owenm <owen23355@gmail.com>
  18511. * @license MIT
  18512. */
  18513. function ownKeys(object, enumerableOnly) {
  18514. var keys = Object.keys(object);
  18515. if (Object.getOwnPropertySymbols) {
  18516. var symbols = Object.getOwnPropertySymbols(object);
  18517. if (enumerableOnly) {
  18518. symbols = symbols.filter(function (sym) {
  18519. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  18520. });
  18521. }
  18522. keys.push.apply(keys, symbols);
  18523. }
  18524. return keys;
  18525. }
  18526. function _objectSpread2(target) {
  18527. for (var i = 1; i < arguments.length; i++) {
  18528. var source = arguments[i] != null ? arguments[i] : {};
  18529. if (i % 2) {
  18530. ownKeys(Object(source), true).forEach(function (key) {
  18531. _defineProperty(target, key, source[key]);
  18532. });
  18533. } else if (Object.getOwnPropertyDescriptors) {
  18534. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  18535. } else {
  18536. ownKeys(Object(source)).forEach(function (key) {
  18537. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  18538. });
  18539. }
  18540. }
  18541. return target;
  18542. }
  18543. function _typeof(obj) {
  18544. "@babel/helpers - typeof";
  18545. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  18546. _typeof = function (obj) {
  18547. return typeof obj;
  18548. };
  18549. } else {
  18550. _typeof = function (obj) {
  18551. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  18552. };
  18553. }
  18554. return _typeof(obj);
  18555. }
  18556. function _defineProperty(obj, key, value) {
  18557. if (key in obj) {
  18558. Object.defineProperty(obj, key, {
  18559. value: value,
  18560. enumerable: true,
  18561. configurable: true,
  18562. writable: true
  18563. });
  18564. } else {
  18565. obj[key] = value;
  18566. }
  18567. return obj;
  18568. }
  18569. function _extends() {
  18570. _extends = Object.assign || function (target) {
  18571. for (var i = 1; i < arguments.length; i++) {
  18572. var source = arguments[i];
  18573. for (var key in source) {
  18574. if (Object.prototype.hasOwnProperty.call(source, key)) {
  18575. target[key] = source[key];
  18576. }
  18577. }
  18578. }
  18579. return target;
  18580. };
  18581. return _extends.apply(this, arguments);
  18582. }
  18583. function _objectWithoutPropertiesLoose(source, excluded) {
  18584. if (source == null) return {};
  18585. var target = {};
  18586. var sourceKeys = Object.keys(source);
  18587. var key, i;
  18588. for (i = 0; i < sourceKeys.length; i++) {
  18589. key = sourceKeys[i];
  18590. if (excluded.indexOf(key) >= 0) continue;
  18591. target[key] = source[key];
  18592. }
  18593. return target;
  18594. }
  18595. function _objectWithoutProperties(source, excluded) {
  18596. if (source == null) return {};
  18597. var target = _objectWithoutPropertiesLoose(source, excluded);
  18598. var key, i;
  18599. if (Object.getOwnPropertySymbols) {
  18600. var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
  18601. for (i = 0; i < sourceSymbolKeys.length; i++) {
  18602. key = sourceSymbolKeys[i];
  18603. if (excluded.indexOf(key) >= 0) continue;
  18604. if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
  18605. target[key] = source[key];
  18606. }
  18607. }
  18608. return target;
  18609. }
  18610. var version = "1.15.0";
  18611. function userAgent(pattern) {
  18612. if (typeof window !== 'undefined' && window.navigator) {
  18613. return !! /*@__PURE__*/navigator.userAgent.match(pattern);
  18614. }
  18615. }
  18616. var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);
  18617. var Edge = userAgent(/Edge/i);
  18618. var FireFox = userAgent(/firefox/i);
  18619. var Safari = userAgent(/safari/i) && !userAgent(/chrome/i) && !userAgent(/android/i);
  18620. var IOS = userAgent(/iP(ad|od|hone)/i);
  18621. var ChromeForAndroid = userAgent(/chrome/i) && userAgent(/android/i);
  18622. var captureMode = {
  18623. capture: false,
  18624. passive: false
  18625. };
  18626. function on(el, event, fn) {
  18627. el.addEventListener(event, fn, !IE11OrLess && captureMode);
  18628. }
  18629. function off(el, event, fn) {
  18630. el.removeEventListener(event, fn, !IE11OrLess && captureMode);
  18631. }
  18632. function matches(
  18633. /**HTMLElement*/
  18634. el,
  18635. /**String*/
  18636. selector) {
  18637. if (!selector) return;
  18638. selector[0] === '>' && (selector = selector.substring(1));
  18639. if (el) {
  18640. try {
  18641. if (el.matches) {
  18642. return el.matches(selector);
  18643. } else if (el.msMatchesSelector) {
  18644. return el.msMatchesSelector(selector);
  18645. } else if (el.webkitMatchesSelector) {
  18646. return el.webkitMatchesSelector(selector);
  18647. }
  18648. } catch (_) {
  18649. return false;
  18650. }
  18651. }
  18652. return false;
  18653. }
  18654. function getParentOrHost(el) {
  18655. return el.host && el !== document && el.host.nodeType ? el.host : el.parentNode;
  18656. }
  18657. function closest(
  18658. /**HTMLElement*/
  18659. el,
  18660. /**String*/
  18661. selector,
  18662. /**HTMLElement*/
  18663. ctx, includeCTX) {
  18664. if (el) {
  18665. ctx = ctx || document;
  18666. do {
  18667. if (selector != null && (selector[0] === '>' ? el.parentNode === ctx && matches(el, selector) : matches(el, selector)) || includeCTX && el === ctx) {
  18668. return el;
  18669. }
  18670. if (el === ctx) break;
  18671. /* jshint boss:true */
  18672. } while (el = getParentOrHost(el));
  18673. }
  18674. return null;
  18675. }
  18676. var R_SPACE = /\s+/g;
  18677. function toggleClass(el, name, state) {
  18678. if (el && name) {
  18679. if (el.classList) {
  18680. el.classList[state ? 'add' : 'remove'](name);
  18681. } else {
  18682. var className = (' ' + el.className + ' ').replace(R_SPACE, ' ').replace(' ' + name + ' ', ' ');
  18683. el.className = (className + (state ? ' ' + name : '')).replace(R_SPACE, ' ');
  18684. }
  18685. }
  18686. }
  18687. function css(el, prop, val) {
  18688. var style = el && el.style;
  18689. if (style) {
  18690. if (val === void 0) {
  18691. if (document.defaultView && document.defaultView.getComputedStyle) {
  18692. val = document.defaultView.getComputedStyle(el, '');
  18693. } else if (el.currentStyle) {
  18694. val = el.currentStyle;
  18695. }
  18696. return prop === void 0 ? val : val[prop];
  18697. } else {
  18698. if (!(prop in style) && prop.indexOf('webkit') === -1) {
  18699. prop = '-webkit-' + prop;
  18700. }
  18701. style[prop] = val + (typeof val === 'string' ? '' : 'px');
  18702. }
  18703. }
  18704. }
  18705. function matrix(el, selfOnly) {
  18706. var appliedTransforms = '';
  18707. if (typeof el === 'string') {
  18708. appliedTransforms = el;
  18709. } else {
  18710. do {
  18711. var transform = css(el, 'transform');
  18712. if (transform && transform !== 'none') {
  18713. appliedTransforms = transform + ' ' + appliedTransforms;
  18714. }
  18715. /* jshint boss:true */
  18716. } while (!selfOnly && (el = el.parentNode));
  18717. }
  18718. var matrixFn = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix;
  18719. /*jshint -W056 */
  18720. return matrixFn && new matrixFn(appliedTransforms);
  18721. }
  18722. function find(ctx, tagName, iterator) {
  18723. if (ctx) {
  18724. var list = ctx.getElementsByTagName(tagName),
  18725. i = 0,
  18726. n = list.length;
  18727. if (iterator) {
  18728. for (; i < n; i++) {
  18729. iterator(list[i], i);
  18730. }
  18731. }
  18732. return list;
  18733. }
  18734. return [];
  18735. }
  18736. function getWindowScrollingElement() {
  18737. var scrollingElement = document.scrollingElement;
  18738. if (scrollingElement) {
  18739. return scrollingElement;
  18740. } else {
  18741. return document.documentElement;
  18742. }
  18743. }
  18744. /**
  18745. * Returns the "bounding client rect" of given element
  18746. * @param {HTMLElement} el The element whose boundingClientRect is wanted
  18747. * @param {[Boolean]} relativeToContainingBlock Whether the rect should be relative to the containing block of (including) the container
  18748. * @param {[Boolean]} relativeToNonStaticParent Whether the rect should be relative to the relative parent of (including) the contaienr
  18749. * @param {[Boolean]} undoScale Whether the container's scale() should be undone
  18750. * @param {[HTMLElement]} container The parent the element will be placed in
  18751. * @return {Object} The boundingClientRect of el, with specified adjustments
  18752. */
  18753. function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container) {
  18754. if (!el.getBoundingClientRect && el !== window) return;
  18755. var elRect, top, left, bottom, right, height, width;
  18756. if (el !== window && el.parentNode && el !== getWindowScrollingElement()) {
  18757. elRect = el.getBoundingClientRect();
  18758. top = elRect.top;
  18759. left = elRect.left;
  18760. bottom = elRect.bottom;
  18761. right = elRect.right;
  18762. height = elRect.height;
  18763. width = elRect.width;
  18764. } else {
  18765. top = 0;
  18766. left = 0;
  18767. bottom = window.innerHeight;
  18768. right = window.innerWidth;
  18769. height = window.innerHeight;
  18770. width = window.innerWidth;
  18771. }
  18772. if ((relativeToContainingBlock || relativeToNonStaticParent) && el !== window) {
  18773. // Adjust for translate()
  18774. container = container || el.parentNode; // solves #1123 (see: https://stackoverflow.com/a/37953806/6088312)
  18775. // Not needed on <= IE11
  18776. if (!IE11OrLess) {
  18777. do {
  18778. if (container && container.getBoundingClientRect && (css(container, 'transform') !== 'none' || relativeToNonStaticParent && css(container, 'position') !== 'static')) {
  18779. var containerRect = container.getBoundingClientRect(); // Set relative to edges of padding box of container
  18780. top -= containerRect.top + parseInt(css(container, 'border-top-width'));
  18781. left -= containerRect.left + parseInt(css(container, 'border-left-width'));
  18782. bottom = top + elRect.height;
  18783. right = left + elRect.width;
  18784. break;
  18785. }
  18786. /* jshint boss:true */
  18787. } while (container = container.parentNode);
  18788. }
  18789. }
  18790. if (undoScale && el !== window) {
  18791. // Adjust for scale()
  18792. var elMatrix = matrix(container || el),
  18793. scaleX = elMatrix && elMatrix.a,
  18794. scaleY = elMatrix && elMatrix.d;
  18795. if (elMatrix) {
  18796. top /= scaleY;
  18797. left /= scaleX;
  18798. width /= scaleX;
  18799. height /= scaleY;
  18800. bottom = top + height;
  18801. right = left + width;
  18802. }
  18803. }
  18804. return {
  18805. top: top,
  18806. left: left,
  18807. bottom: bottom,
  18808. right: right,
  18809. width: width,
  18810. height: height
  18811. };
  18812. }
  18813. /**
  18814. * Checks if a side of an element is scrolled past a side of its parents
  18815. * @param {HTMLElement} el The element who's side being scrolled out of view is in question
  18816. * @param {String} elSide Side of the element in question ('top', 'left', 'right', 'bottom')
  18817. * @param {String} parentSide Side of the parent in question ('top', 'left', 'right', 'bottom')
  18818. * @return {HTMLElement} The parent scroll element that the el's side is scrolled past, or null if there is no such element
  18819. */
  18820. function isScrolledPast(el, elSide, parentSide) {
  18821. var parent = getParentAutoScrollElement(el, true),
  18822. elSideVal = getRect(el)[elSide];
  18823. /* jshint boss:true */
  18824. while (parent) {
  18825. var parentSideVal = getRect(parent)[parentSide],
  18826. visible = void 0;
  18827. if (parentSide === 'top' || parentSide === 'left') {
  18828. visible = elSideVal >= parentSideVal;
  18829. } else {
  18830. visible = elSideVal <= parentSideVal;
  18831. }
  18832. if (!visible) return parent;
  18833. if (parent === getWindowScrollingElement()) break;
  18834. parent = getParentAutoScrollElement(parent, false);
  18835. }
  18836. return false;
  18837. }
  18838. /**
  18839. * Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible)
  18840. * and non-draggable elements
  18841. * @param {HTMLElement} el The parent element
  18842. * @param {Number} childNum The index of the child
  18843. * @param {Object} options Parent Sortable's options
  18844. * @return {HTMLElement} The child at index childNum, or null if not found
  18845. */
  18846. function getChild(el, childNum, options, includeDragEl) {
  18847. var currentChild = 0,
  18848. i = 0,
  18849. children = el.children;
  18850. while (i < children.length) {
  18851. if (children[i].style.display !== 'none' && children[i] !== Sortable.ghost && (includeDragEl || children[i] !== Sortable.dragged) && closest(children[i], options.draggable, el, false)) {
  18852. if (currentChild === childNum) {
  18853. return children[i];
  18854. }
  18855. currentChild++;
  18856. }
  18857. i++;
  18858. }
  18859. return null;
  18860. }
  18861. /**
  18862. * Gets the last child in the el, ignoring ghostEl or invisible elements (clones)
  18863. * @param {HTMLElement} el Parent element
  18864. * @param {selector} selector Any other elements that should be ignored
  18865. * @return {HTMLElement} The last child, ignoring ghostEl
  18866. */
  18867. function lastChild(el, selector) {
  18868. var last = el.lastElementChild;
  18869. while (last && (last === Sortable.ghost || css(last, 'display') === 'none' || selector && !matches(last, selector))) {
  18870. last = last.previousElementSibling;
  18871. }
  18872. return last || null;
  18873. }
  18874. /**
  18875. * Returns the index of an element within its parent for a selected set of
  18876. * elements
  18877. * @param {HTMLElement} el
  18878. * @param {selector} selector
  18879. * @return {number}
  18880. */
  18881. function index(el, selector) {
  18882. var index = 0;
  18883. if (!el || !el.parentNode) {
  18884. return -1;
  18885. }
  18886. /* jshint boss:true */
  18887. while (el = el.previousElementSibling) {
  18888. if (el.nodeName.toUpperCase() !== 'TEMPLATE' && el !== Sortable.clone && (!selector || matches(el, selector))) {
  18889. index++;
  18890. }
  18891. }
  18892. return index;
  18893. }
  18894. /**
  18895. * Returns the scroll offset of the given element, added with all the scroll offsets of parent elements.
  18896. * The value is returned in real pixels.
  18897. * @param {HTMLElement} el
  18898. * @return {Array} Offsets in the format of [left, top]
  18899. */
  18900. function getRelativeScrollOffset(el) {
  18901. var offsetLeft = 0,
  18902. offsetTop = 0,
  18903. winScroller = getWindowScrollingElement();
  18904. if (el) {
  18905. do {
  18906. var elMatrix = matrix(el),
  18907. scaleX = elMatrix.a,
  18908. scaleY = elMatrix.d;
  18909. offsetLeft += el.scrollLeft * scaleX;
  18910. offsetTop += el.scrollTop * scaleY;
  18911. } while (el !== winScroller && (el = el.parentNode));
  18912. }
  18913. return [offsetLeft, offsetTop];
  18914. }
  18915. /**
  18916. * Returns the index of the object within the given array
  18917. * @param {Array} arr Array that may or may not hold the object
  18918. * @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
  18919. * @return {Number} The index of the object in the array, or -1
  18920. */
  18921. function indexOfObject(arr, obj) {
  18922. for (var i in arr) {
  18923. if (!arr.hasOwnProperty(i)) continue;
  18924. for (var key in obj) {
  18925. if (obj.hasOwnProperty(key) && obj[key] === arr[i][key]) return Number(i);
  18926. }
  18927. }
  18928. return -1;
  18929. }
  18930. function getParentAutoScrollElement(el, includeSelf) {
  18931. // skip to window
  18932. if (!el || !el.getBoundingClientRect) return getWindowScrollingElement();
  18933. var elem = el;
  18934. var gotSelf = false;
  18935. do {
  18936. // we don't need to get elem css if it isn't even overflowing in the first place (performance)
  18937. if (elem.clientWidth < elem.scrollWidth || elem.clientHeight < elem.scrollHeight) {
  18938. var elemCSS = css(elem);
  18939. if (elem.clientWidth < elem.scrollWidth && (elemCSS.overflowX == 'auto' || elemCSS.overflowX == 'scroll') || elem.clientHeight < elem.scrollHeight && (elemCSS.overflowY == 'auto' || elemCSS.overflowY == 'scroll')) {
  18940. if (!elem.getBoundingClientRect || elem === document.body) return getWindowScrollingElement();
  18941. if (gotSelf || includeSelf) return elem;
  18942. gotSelf = true;
  18943. }
  18944. }
  18945. /* jshint boss:true */
  18946. } while (elem = elem.parentNode);
  18947. return getWindowScrollingElement();
  18948. }
  18949. function extend(dst, src) {
  18950. if (dst && src) {
  18951. for (var key in src) {
  18952. if (src.hasOwnProperty(key)) {
  18953. dst[key] = src[key];
  18954. }
  18955. }
  18956. }
  18957. return dst;
  18958. }
  18959. function isRectEqual(rect1, rect2) {
  18960. 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);
  18961. }
  18962. var _throttleTimeout;
  18963. function throttle(callback, ms) {
  18964. return function () {
  18965. if (!_throttleTimeout) {
  18966. var args = arguments,
  18967. _this = this;
  18968. if (args.length === 1) {
  18969. callback.call(_this, args[0]);
  18970. } else {
  18971. callback.apply(_this, args);
  18972. }
  18973. _throttleTimeout = setTimeout(function () {
  18974. _throttleTimeout = void 0;
  18975. }, ms);
  18976. }
  18977. };
  18978. }
  18979. function cancelThrottle() {
  18980. clearTimeout(_throttleTimeout);
  18981. _throttleTimeout = void 0;
  18982. }
  18983. function scrollBy(el, x, y) {
  18984. el.scrollLeft += x;
  18985. el.scrollTop += y;
  18986. }
  18987. function clone(el) {
  18988. var Polymer = window.Polymer;
  18989. var $ = window.jQuery || window.Zepto;
  18990. if (Polymer && Polymer.dom) {
  18991. return Polymer.dom(el).cloneNode(true);
  18992. } else if ($) {
  18993. return $(el).clone(true)[0];
  18994. } else {
  18995. return el.cloneNode(true);
  18996. }
  18997. }
  18998. var expando = 'Sortable' + new Date().getTime();
  18999. function AnimationStateManager() {
  19000. var animationStates = [],
  19001. animationCallbackId;
  19002. return {
  19003. captureAnimationState: function captureAnimationState() {
  19004. animationStates = [];
  19005. if (!this.options.animation) return;
  19006. var children = [].slice.call(this.el.children);
  19007. children.forEach(function (child) {
  19008. if (css(child, 'display') === 'none' || child === Sortable.ghost) return;
  19009. animationStates.push({
  19010. target: child,
  19011. rect: getRect(child)
  19012. });
  19013. var fromRect = _objectSpread2({}, animationStates[animationStates.length - 1].rect); // If animating: compensate for current animation
  19014. if (child.thisAnimationDuration) {
  19015. var childMatrix = matrix(child, true);
  19016. if (childMatrix) {
  19017. fromRect.top -= childMatrix.f;
  19018. fromRect.left -= childMatrix.e;
  19019. }
  19020. }
  19021. child.fromRect = fromRect;
  19022. });
  19023. },
  19024. addAnimationState: function addAnimationState(state) {
  19025. animationStates.push(state);
  19026. },
  19027. removeAnimationState: function removeAnimationState(target) {
  19028. animationStates.splice(indexOfObject(animationStates, {
  19029. target: target
  19030. }), 1);
  19031. },
  19032. animateAll: function animateAll(callback) {
  19033. var _this = this;
  19034. if (!this.options.animation) {
  19035. clearTimeout(animationCallbackId);
  19036. if (typeof callback === 'function') callback();
  19037. return;
  19038. }
  19039. var animating = false,
  19040. animationTime = 0;
  19041. animationStates.forEach(function (state) {
  19042. var time = 0,
  19043. target = state.target,
  19044. fromRect = target.fromRect,
  19045. toRect = getRect(target),
  19046. prevFromRect = target.prevFromRect,
  19047. prevToRect = target.prevToRect,
  19048. animatingRect = state.rect,
  19049. targetMatrix = matrix(target, true);
  19050. if (targetMatrix) {
  19051. // Compensate for current animation
  19052. toRect.top -= targetMatrix.f;
  19053. toRect.left -= targetMatrix.e;
  19054. }
  19055. target.toRect = toRect;
  19056. if (target.thisAnimationDuration) {
  19057. // Could also check if animatingRect is between fromRect and toRect
  19058. if (isRectEqual(prevFromRect, toRect) && !isRectEqual(fromRect, toRect) && // Make sure animatingRect is on line between toRect & fromRect
  19059. (animatingRect.top - toRect.top) / (animatingRect.left - toRect.left) === (fromRect.top - toRect.top) / (fromRect.left - toRect.left)) {
  19060. // If returning to same place as started from animation and on same axis
  19061. time = calculateRealTime(animatingRect, prevFromRect, prevToRect, _this.options);
  19062. }
  19063. } // if fromRect != toRect: animate
  19064. if (!isRectEqual(toRect, fromRect)) {
  19065. target.prevFromRect = fromRect;
  19066. target.prevToRect = toRect;
  19067. if (!time) {
  19068. time = _this.options.animation;
  19069. }
  19070. _this.animate(target, animatingRect, toRect, time);
  19071. }
  19072. if (time) {
  19073. animating = true;
  19074. animationTime = Math.max(animationTime, time);
  19075. clearTimeout(target.animationResetTimer);
  19076. target.animationResetTimer = setTimeout(function () {
  19077. target.animationTime = 0;
  19078. target.prevFromRect = null;
  19079. target.fromRect = null;
  19080. target.prevToRect = null;
  19081. target.thisAnimationDuration = null;
  19082. }, time);
  19083. target.thisAnimationDuration = time;
  19084. }
  19085. });
  19086. clearTimeout(animationCallbackId);
  19087. if (!animating) {
  19088. if (typeof callback === 'function') callback();
  19089. } else {
  19090. animationCallbackId = setTimeout(function () {
  19091. if (typeof callback === 'function') callback();
  19092. }, animationTime);
  19093. }
  19094. animationStates = [];
  19095. },
  19096. animate: function animate(target, currentRect, toRect, duration) {
  19097. if (duration) {
  19098. css(target, 'transition', '');
  19099. css(target, 'transform', '');
  19100. var elMatrix = matrix(this.el),
  19101. scaleX = elMatrix && elMatrix.a,
  19102. scaleY = elMatrix && elMatrix.d,
  19103. translateX = (currentRect.left - toRect.left) / (scaleX || 1),
  19104. translateY = (currentRect.top - toRect.top) / (scaleY || 1);
  19105. target.animatingX = !!translateX;
  19106. target.animatingY = !!translateY;
  19107. css(target, 'transform', 'translate3d(' + translateX + 'px,' + translateY + 'px,0)');
  19108. this.forRepaintDummy = repaint(target); // repaint
  19109. css(target, 'transition', 'transform ' + duration + 'ms' + (this.options.easing ? ' ' + this.options.easing : ''));
  19110. css(target, 'transform', 'translate3d(0,0,0)');
  19111. typeof target.animated === 'number' && clearTimeout(target.animated);
  19112. target.animated = setTimeout(function () {
  19113. css(target, 'transition', '');
  19114. css(target, 'transform', '');
  19115. target.animated = false;
  19116. target.animatingX = false;
  19117. target.animatingY = false;
  19118. }, duration);
  19119. }
  19120. }
  19121. };
  19122. }
  19123. function repaint(target) {
  19124. return target.offsetWidth;
  19125. }
  19126. function calculateRealTime(animatingRect, fromRect, toRect, options) {
  19127. 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;
  19128. }
  19129. var plugins = [];
  19130. var defaults = {
  19131. initializeByDefault: true
  19132. };
  19133. var PluginManager = {
  19134. mount: function mount(plugin) {
  19135. // Set default static properties
  19136. for (var option in defaults) {
  19137. if (defaults.hasOwnProperty(option) && !(option in plugin)) {
  19138. plugin[option] = defaults[option];
  19139. }
  19140. }
  19141. plugins.forEach(function (p) {
  19142. if (p.pluginName === plugin.pluginName) {
  19143. throw "Sortable: Cannot mount plugin ".concat(plugin.pluginName, " more than once");
  19144. }
  19145. });
  19146. plugins.push(plugin);
  19147. },
  19148. pluginEvent: function pluginEvent(eventName, sortable, evt) {
  19149. var _this = this;
  19150. this.eventCanceled = false;
  19151. evt.cancel = function () {
  19152. _this.eventCanceled = true;
  19153. };
  19154. var eventNameGlobal = eventName + 'Global';
  19155. plugins.forEach(function (plugin) {
  19156. if (!sortable[plugin.pluginName]) return; // Fire global events if it exists in this sortable
  19157. if (sortable[plugin.pluginName][eventNameGlobal]) {
  19158. sortable[plugin.pluginName][eventNameGlobal](_objectSpread2({
  19159. sortable: sortable
  19160. }, evt));
  19161. } // Only fire plugin event if plugin is enabled in this sortable,
  19162. // and plugin has event defined
  19163. if (sortable.options[plugin.pluginName] && sortable[plugin.pluginName][eventName]) {
  19164. sortable[plugin.pluginName][eventName](_objectSpread2({
  19165. sortable: sortable
  19166. }, evt));
  19167. }
  19168. });
  19169. },
  19170. initializePlugins: function initializePlugins(sortable, el, defaults, options) {
  19171. plugins.forEach(function (plugin) {
  19172. var pluginName = plugin.pluginName;
  19173. if (!sortable.options[pluginName] && !plugin.initializeByDefault) return;
  19174. var initialized = new plugin(sortable, el, sortable.options);
  19175. initialized.sortable = sortable;
  19176. initialized.options = sortable.options;
  19177. sortable[pluginName] = initialized; // Add default options from plugin
  19178. _extends(defaults, initialized.defaults);
  19179. });
  19180. for (var option in sortable.options) {
  19181. if (!sortable.options.hasOwnProperty(option)) continue;
  19182. var modified = this.modifyOption(sortable, option, sortable.options[option]);
  19183. if (typeof modified !== 'undefined') {
  19184. sortable.options[option] = modified;
  19185. }
  19186. }
  19187. },
  19188. getEventProperties: function getEventProperties(name, sortable) {
  19189. var eventProperties = {};
  19190. plugins.forEach(function (plugin) {
  19191. if (typeof plugin.eventProperties !== 'function') return;
  19192. _extends(eventProperties, plugin.eventProperties.call(sortable[plugin.pluginName], name));
  19193. });
  19194. return eventProperties;
  19195. },
  19196. modifyOption: function modifyOption(sortable, name, value) {
  19197. var modifiedValue;
  19198. plugins.forEach(function (plugin) {
  19199. // Plugin must exist on the Sortable
  19200. 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
  19201. if (plugin.optionListeners && typeof plugin.optionListeners[name] === 'function') {
  19202. modifiedValue = plugin.optionListeners[name].call(sortable[plugin.pluginName], value);
  19203. }
  19204. });
  19205. return modifiedValue;
  19206. }
  19207. };
  19208. function dispatchEvent(_ref) {
  19209. var sortable = _ref.sortable,
  19210. rootEl = _ref.rootEl,
  19211. name = _ref.name,
  19212. targetEl = _ref.targetEl,
  19213. cloneEl = _ref.cloneEl,
  19214. toEl = _ref.toEl,
  19215. fromEl = _ref.fromEl,
  19216. oldIndex = _ref.oldIndex,
  19217. newIndex = _ref.newIndex,
  19218. oldDraggableIndex = _ref.oldDraggableIndex,
  19219. newDraggableIndex = _ref.newDraggableIndex,
  19220. originalEvent = _ref.originalEvent,
  19221. putSortable = _ref.putSortable,
  19222. extraEventProperties = _ref.extraEventProperties;
  19223. sortable = sortable || rootEl && rootEl[expando];
  19224. if (!sortable) return;
  19225. var evt,
  19226. options = sortable.options,
  19227. onName = 'on' + name.charAt(0).toUpperCase() + name.substr(1); // Support for new CustomEvent feature
  19228. if (window.CustomEvent && !IE11OrLess && !Edge) {
  19229. evt = new CustomEvent(name, {
  19230. bubbles: true,
  19231. cancelable: true
  19232. });
  19233. } else {
  19234. evt = document.createEvent('Event');
  19235. evt.initEvent(name, true, true);
  19236. }
  19237. evt.to = toEl || rootEl;
  19238. evt.from = fromEl || rootEl;
  19239. evt.item = targetEl || rootEl;
  19240. evt.clone = cloneEl;
  19241. evt.oldIndex = oldIndex;
  19242. evt.newIndex = newIndex;
  19243. evt.oldDraggableIndex = oldDraggableIndex;
  19244. evt.newDraggableIndex = newDraggableIndex;
  19245. evt.originalEvent = originalEvent;
  19246. evt.pullMode = putSortable ? putSortable.lastPutMode : undefined;
  19247. var allEventProperties = _objectSpread2(_objectSpread2({}, extraEventProperties), PluginManager.getEventProperties(name, sortable));
  19248. for (var option in allEventProperties) {
  19249. evt[option] = allEventProperties[option];
  19250. }
  19251. if (rootEl) {
  19252. rootEl.dispatchEvent(evt);
  19253. }
  19254. if (options[onName]) {
  19255. options[onName].call(sortable, evt);
  19256. }
  19257. }
  19258. var _excluded = ["evt"];
  19259. var pluginEvent = function pluginEvent(eventName, sortable) {
  19260. var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
  19261. originalEvent = _ref.evt,
  19262. data = _objectWithoutProperties(_ref, _excluded);
  19263. PluginManager.pluginEvent.bind(Sortable)(eventName, sortable, _objectSpread2({
  19264. dragEl: dragEl,
  19265. parentEl: parentEl,
  19266. ghostEl: ghostEl,
  19267. rootEl: rootEl,
  19268. nextEl: nextEl,
  19269. lastDownEl: lastDownEl,
  19270. cloneEl: cloneEl,
  19271. cloneHidden: cloneHidden,
  19272. dragStarted: moved,
  19273. putSortable: putSortable,
  19274. activeSortable: Sortable.active,
  19275. originalEvent: originalEvent,
  19276. oldIndex: oldIndex,
  19277. oldDraggableIndex: oldDraggableIndex,
  19278. newIndex: newIndex,
  19279. newDraggableIndex: newDraggableIndex,
  19280. hideGhostForTarget: _hideGhostForTarget,
  19281. unhideGhostForTarget: _unhideGhostForTarget,
  19282. cloneNowHidden: function cloneNowHidden() {
  19283. cloneHidden = true;
  19284. },
  19285. cloneNowShown: function cloneNowShown() {
  19286. cloneHidden = false;
  19287. },
  19288. dispatchSortableEvent: function dispatchSortableEvent(name) {
  19289. _dispatchEvent({
  19290. sortable: sortable,
  19291. name: name,
  19292. originalEvent: originalEvent
  19293. });
  19294. }
  19295. }, data));
  19296. };
  19297. function _dispatchEvent(info) {
  19298. dispatchEvent(_objectSpread2({
  19299. putSortable: putSortable,
  19300. cloneEl: cloneEl,
  19301. targetEl: dragEl,
  19302. rootEl: rootEl,
  19303. oldIndex: oldIndex,
  19304. oldDraggableIndex: oldDraggableIndex,
  19305. newIndex: newIndex,
  19306. newDraggableIndex: newDraggableIndex
  19307. }, info));
  19308. }
  19309. var dragEl,
  19310. parentEl,
  19311. ghostEl,
  19312. rootEl,
  19313. nextEl,
  19314. lastDownEl,
  19315. cloneEl,
  19316. cloneHidden,
  19317. oldIndex,
  19318. newIndex,
  19319. oldDraggableIndex,
  19320. newDraggableIndex,
  19321. activeGroup,
  19322. putSortable,
  19323. awaitingDragStarted = false,
  19324. ignoreNextClick = false,
  19325. sortables = [],
  19326. tapEvt,
  19327. touchEvt,
  19328. lastDx,
  19329. lastDy,
  19330. tapDistanceLeft,
  19331. tapDistanceTop,
  19332. moved,
  19333. lastTarget,
  19334. lastDirection,
  19335. pastFirstInvertThresh = false,
  19336. isCircumstantialInvert = false,
  19337. targetMoveDistance,
  19338. // For positioning ghost absolutely
  19339. ghostRelativeParent,
  19340. ghostRelativeParentInitialScroll = [],
  19341. // (left, top)
  19342. _silent = false,
  19343. savedInputChecked = [];
  19344. /** @const */
  19345. var documentExists = typeof document !== 'undefined',
  19346. PositionGhostAbsolutely = IOS,
  19347. CSSFloatProperty = Edge || IE11OrLess ? 'cssFloat' : 'float',
  19348. // This will not pass for IE9, because IE9 DnD only works on anchors
  19349. supportDraggable = documentExists && !ChromeForAndroid && !IOS && 'draggable' in document.createElement('div'),
  19350. supportCssPointerEvents = function () {
  19351. if (!documentExists) return; // false when <= IE11
  19352. if (IE11OrLess) {
  19353. return false;
  19354. }
  19355. var el = document.createElement('x');
  19356. el.style.cssText = 'pointer-events:auto';
  19357. return el.style.pointerEvents === 'auto';
  19358. }(),
  19359. _detectDirection = function _detectDirection(el, options) {
  19360. var elCSS = css(el),
  19361. elWidth = parseInt(elCSS.width) - parseInt(elCSS.paddingLeft) - parseInt(elCSS.paddingRight) - parseInt(elCSS.borderLeftWidth) - parseInt(elCSS.borderRightWidth),
  19362. child1 = getChild(el, 0, options),
  19363. child2 = getChild(el, 1, options),
  19364. firstChildCSS = child1 && css(child1),
  19365. secondChildCSS = child2 && css(child2),
  19366. firstChildWidth = firstChildCSS && parseInt(firstChildCSS.marginLeft) + parseInt(firstChildCSS.marginRight) + getRect(child1).width,
  19367. secondChildWidth = secondChildCSS && parseInt(secondChildCSS.marginLeft) + parseInt(secondChildCSS.marginRight) + getRect(child2).width;
  19368. if (elCSS.display === 'flex') {
  19369. return elCSS.flexDirection === 'column' || elCSS.flexDirection === 'column-reverse' ? 'vertical' : 'horizontal';
  19370. }
  19371. if (elCSS.display === 'grid') {
  19372. return elCSS.gridTemplateColumns.split(' ').length <= 1 ? 'vertical' : 'horizontal';
  19373. }
  19374. if (child1 && firstChildCSS["float"] && firstChildCSS["float"] !== 'none') {
  19375. var touchingSideChild2 = firstChildCSS["float"] === 'left' ? 'left' : 'right';
  19376. return child2 && (secondChildCSS.clear === 'both' || secondChildCSS.clear === touchingSideChild2) ? 'vertical' : 'horizontal';
  19377. }
  19378. 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';
  19379. },
  19380. _dragElInRowColumn = function _dragElInRowColumn(dragRect, targetRect, vertical) {
  19381. var dragElS1Opp = vertical ? dragRect.left : dragRect.top,
  19382. dragElS2Opp = vertical ? dragRect.right : dragRect.bottom,
  19383. dragElOppLength = vertical ? dragRect.width : dragRect.height,
  19384. targetS1Opp = vertical ? targetRect.left : targetRect.top,
  19385. targetS2Opp = vertical ? targetRect.right : targetRect.bottom,
  19386. targetOppLength = vertical ? targetRect.width : targetRect.height;
  19387. return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2;
  19388. },
  19389. /**
  19390. * Detects first nearest empty sortable to X and Y position using emptyInsertThreshold.
  19391. * @param {Number} x X position
  19392. * @param {Number} y Y position
  19393. * @return {HTMLElement} Element of the first found nearest Sortable
  19394. */
  19395. _detectNearestEmptySortable = function _detectNearestEmptySortable(x, y) {
  19396. var ret;
  19397. sortables.some(function (sortable) {
  19398. var threshold = sortable[expando].options.emptyInsertThreshold;
  19399. if (!threshold || lastChild(sortable)) return;
  19400. var rect = getRect(sortable),
  19401. insideHorizontally = x >= rect.left - threshold && x <= rect.right + threshold,
  19402. insideVertically = y >= rect.top - threshold && y <= rect.bottom + threshold;
  19403. if (insideHorizontally && insideVertically) {
  19404. return ret = sortable;
  19405. }
  19406. });
  19407. return ret;
  19408. },
  19409. _prepareGroup = function _prepareGroup(options) {
  19410. function toFn(value, pull) {
  19411. return function (to, from, dragEl, evt) {
  19412. var sameGroup = to.options.group.name && from.options.group.name && to.options.group.name === from.options.group.name;
  19413. if (value == null && (pull || sameGroup)) {
  19414. // Default pull value
  19415. // Default pull and put value if same group
  19416. return true;
  19417. } else if (value == null || value === false) {
  19418. return false;
  19419. } else if (pull && value === 'clone') {
  19420. return value;
  19421. } else if (typeof value === 'function') {
  19422. return toFn(value(to, from, dragEl, evt), pull)(to, from, dragEl, evt);
  19423. } else {
  19424. var otherGroup = (pull ? to : from).options.group.name;
  19425. return value === true || typeof value === 'string' && value === otherGroup || value.join && value.indexOf(otherGroup) > -1;
  19426. }
  19427. };
  19428. }
  19429. var group = {};
  19430. var originalGroup = options.group;
  19431. if (!originalGroup || _typeof(originalGroup) != 'object') {
  19432. originalGroup = {
  19433. name: originalGroup
  19434. };
  19435. }
  19436. group.name = originalGroup.name;
  19437. group.checkPull = toFn(originalGroup.pull, true);
  19438. group.checkPut = toFn(originalGroup.put);
  19439. group.revertClone = originalGroup.revertClone;
  19440. options.group = group;
  19441. },
  19442. _hideGhostForTarget = function _hideGhostForTarget() {
  19443. if (!supportCssPointerEvents && ghostEl) {
  19444. css(ghostEl, 'display', 'none');
  19445. }
  19446. },
  19447. _unhideGhostForTarget = function _unhideGhostForTarget() {
  19448. if (!supportCssPointerEvents && ghostEl) {
  19449. css(ghostEl, 'display', '');
  19450. }
  19451. }; // #1184 fix - Prevent click event on fallback if dragged but item not changed position
  19452. if (documentExists && !ChromeForAndroid) {
  19453. document.addEventListener('click', function (evt) {
  19454. if (ignoreNextClick) {
  19455. evt.preventDefault();
  19456. evt.stopPropagation && evt.stopPropagation();
  19457. evt.stopImmediatePropagation && evt.stopImmediatePropagation();
  19458. ignoreNextClick = false;
  19459. return false;
  19460. }
  19461. }, true);
  19462. }
  19463. var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent(evt) {
  19464. if (dragEl) {
  19465. evt = evt.touches ? evt.touches[0] : evt;
  19466. var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);
  19467. if (nearest) {
  19468. // Create imitation event
  19469. var event = {};
  19470. for (var i in evt) {
  19471. if (evt.hasOwnProperty(i)) {
  19472. event[i] = evt[i];
  19473. }
  19474. }
  19475. event.target = event.rootEl = nearest;
  19476. event.preventDefault = void 0;
  19477. event.stopPropagation = void 0;
  19478. nearest[expando]._onDragOver(event);
  19479. }
  19480. }
  19481. };
  19482. var _checkOutsideTargetEl = function _checkOutsideTargetEl(evt) {
  19483. if (dragEl) {
  19484. dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
  19485. }
  19486. };
  19487. /**
  19488. * @class Sortable
  19489. * @param {HTMLElement} el
  19490. * @param {Object} [options]
  19491. */
  19492. function Sortable(el, options) {
  19493. if (!(el && el.nodeType && el.nodeType === 1)) {
  19494. throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(el));
  19495. }
  19496. this.el = el; // root element
  19497. this.options = options = _extends({}, options); // Export instance
  19498. el[expando] = this;
  19499. var defaults = {
  19500. group: null,
  19501. sort: true,
  19502. disabled: false,
  19503. store: null,
  19504. handle: null,
  19505. draggable: /^[uo]l$/i.test(el.nodeName) ? '>li' : '>*',
  19506. swapThreshold: 1,
  19507. // percentage; 0 <= x <= 1
  19508. invertSwap: false,
  19509. // invert always
  19510. invertedSwapThreshold: null,
  19511. // will be set to same as swapThreshold if default
  19512. removeCloneOnHide: true,
  19513. direction: function direction() {
  19514. return _detectDirection(el, this.options);
  19515. },
  19516. ghostClass: 'sortable-ghost',
  19517. chosenClass: 'sortable-chosen',
  19518. dragClass: 'sortable-drag',
  19519. ignore: 'a, img',
  19520. filter: null,
  19521. preventOnFilter: true,
  19522. animation: 0,
  19523. easing: null,
  19524. setData: function setData(dataTransfer, dragEl) {
  19525. dataTransfer.setData('Text', dragEl.textContent);
  19526. },
  19527. dropBubble: false,
  19528. dragoverBubble: false,
  19529. dataIdAttr: 'data-id',
  19530. delay: 0,
  19531. delayOnTouchOnly: false,
  19532. touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
  19533. forceFallback: false,
  19534. fallbackClass: 'sortable-fallback',
  19535. fallbackOnBody: false,
  19536. fallbackTolerance: 0,
  19537. fallbackOffset: {
  19538. x: 0,
  19539. y: 0
  19540. },
  19541. supportPointer: Sortable.supportPointer !== false && 'PointerEvent' in window && !Safari,
  19542. emptyInsertThreshold: 5
  19543. };
  19544. PluginManager.initializePlugins(this, el, defaults); // Set default options
  19545. for (var name in defaults) {
  19546. !(name in options) && (options[name] = defaults[name]);
  19547. }
  19548. _prepareGroup(options); // Bind all private methods
  19549. for (var fn in this) {
  19550. if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
  19551. this[fn] = this[fn].bind(this);
  19552. }
  19553. } // Setup drag mode
  19554. this.nativeDraggable = options.forceFallback ? false : supportDraggable;
  19555. if (this.nativeDraggable) {
  19556. // Touch start threshold cannot be greater than the native dragstart threshold
  19557. this.options.touchStartThreshold = 1;
  19558. } // Bind events
  19559. if (options.supportPointer) {
  19560. on(el, 'pointerdown', this._onTapStart);
  19561. } else {
  19562. on(el, 'mousedown', this._onTapStart);
  19563. on(el, 'touchstart', this._onTapStart);
  19564. }
  19565. if (this.nativeDraggable) {
  19566. on(el, 'dragover', this);
  19567. on(el, 'dragenter', this);
  19568. }
  19569. sortables.push(this.el); // Restore sorting
  19570. options.store && options.store.get && this.sort(options.store.get(this) || []); // Add animation state manager
  19571. _extends(this, AnimationStateManager());
  19572. }
  19573. Sortable.prototype =
  19574. /** @lends Sortable.prototype */
  19575. {
  19576. constructor: Sortable,
  19577. _isOutsideThisEl: function _isOutsideThisEl(target) {
  19578. if (!this.el.contains(target) && target !== this.el) {
  19579. lastTarget = null;
  19580. }
  19581. },
  19582. _getDirection: function _getDirection(evt, target) {
  19583. return typeof this.options.direction === 'function' ? this.options.direction.call(this, evt, target, dragEl) : this.options.direction;
  19584. },
  19585. _onTapStart: function _onTapStart(
  19586. /** Event|TouchEvent */
  19587. evt) {
  19588. if (!evt.cancelable) return;
  19589. var _this = this,
  19590. el = this.el,
  19591. options = this.options,
  19592. preventOnFilter = options.preventOnFilter,
  19593. type = evt.type,
  19594. touch = evt.touches && evt.touches[0] || evt.pointerType && evt.pointerType === 'touch' && evt,
  19595. target = (touch || evt).target,
  19596. originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0] || evt.composedPath && evt.composedPath()[0]) || target,
  19597. filter = options.filter;
  19598. _saveInputCheckedState(el); // Don't trigger start event when an element is been dragged, otherwise the evt.oldindex always wrong when set option.group.
  19599. if (dragEl) {
  19600. return;
  19601. }
  19602. if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) {
  19603. return; // only left button and enabled
  19604. } // cancel dnd if original target is content editable
  19605. if (originalTarget.isContentEditable) {
  19606. return;
  19607. } // Safari ignores further event handling after mousedown
  19608. if (!this.nativeDraggable && Safari && target && target.tagName.toUpperCase() === 'SELECT') {
  19609. return;
  19610. }
  19611. target = closest(target, options.draggable, el, false);
  19612. if (target && target.animated) {
  19613. return;
  19614. }
  19615. if (lastDownEl === target) {
  19616. // Ignoring duplicate `down`
  19617. return;
  19618. } // Get the index of the dragged element within its parent
  19619. oldIndex = index(target);
  19620. oldDraggableIndex = index(target, options.draggable); // Check filter
  19621. if (typeof filter === 'function') {
  19622. if (filter.call(this, evt, target, this)) {
  19623. _dispatchEvent({
  19624. sortable: _this,
  19625. rootEl: originalTarget,
  19626. name: 'filter',
  19627. targetEl: target,
  19628. toEl: el,
  19629. fromEl: el
  19630. });
  19631. pluginEvent('filter', _this, {
  19632. evt: evt
  19633. });
  19634. preventOnFilter && evt.cancelable && evt.preventDefault();
  19635. return; // cancel dnd
  19636. }
  19637. } else if (filter) {
  19638. filter = filter.split(',').some(function (criteria) {
  19639. criteria = closest(originalTarget, criteria.trim(), el, false);
  19640. if (criteria) {
  19641. _dispatchEvent({
  19642. sortable: _this,
  19643. rootEl: criteria,
  19644. name: 'filter',
  19645. targetEl: target,
  19646. fromEl: el,
  19647. toEl: el
  19648. });
  19649. pluginEvent('filter', _this, {
  19650. evt: evt
  19651. });
  19652. return true;
  19653. }
  19654. });
  19655. if (filter) {
  19656. preventOnFilter && evt.cancelable && evt.preventDefault();
  19657. return; // cancel dnd
  19658. }
  19659. }
  19660. if (options.handle && !closest(originalTarget, options.handle, el, false)) {
  19661. return;
  19662. } // Prepare `dragstart`
  19663. this._prepareDragStart(evt, touch, target);
  19664. },
  19665. _prepareDragStart: function _prepareDragStart(
  19666. /** Event */
  19667. evt,
  19668. /** Touch */
  19669. touch,
  19670. /** HTMLElement */
  19671. target) {
  19672. var _this = this,
  19673. el = _this.el,
  19674. options = _this.options,
  19675. ownerDocument = el.ownerDocument,
  19676. dragStartFn;
  19677. if (target && !dragEl && target.parentNode === el) {
  19678. var dragRect = getRect(target);
  19679. rootEl = el;
  19680. dragEl = target;
  19681. parentEl = dragEl.parentNode;
  19682. nextEl = dragEl.nextSibling;
  19683. lastDownEl = target;
  19684. activeGroup = options.group;
  19685. Sortable.dragged = dragEl;
  19686. tapEvt = {
  19687. target: dragEl,
  19688. clientX: (touch || evt).clientX,
  19689. clientY: (touch || evt).clientY
  19690. };
  19691. tapDistanceLeft = tapEvt.clientX - dragRect.left;
  19692. tapDistanceTop = tapEvt.clientY - dragRect.top;
  19693. this._lastX = (touch || evt).clientX;
  19694. this._lastY = (touch || evt).clientY;
  19695. dragEl.style['will-change'] = 'all';
  19696. dragStartFn = function dragStartFn() {
  19697. pluginEvent('delayEnded', _this, {
  19698. evt: evt
  19699. });
  19700. if (Sortable.eventCanceled) {
  19701. _this._onDrop();
  19702. return;
  19703. } // Delayed drag has been triggered
  19704. // we can re-enable the events: touchmove/mousemove
  19705. _this._disableDelayedDragEvents();
  19706. if (!FireFox && _this.nativeDraggable) {
  19707. dragEl.draggable = true;
  19708. } // Bind the events: dragstart/dragend
  19709. _this._triggerDragStart(evt, touch); // Drag start event
  19710. _dispatchEvent({
  19711. sortable: _this,
  19712. name: 'choose',
  19713. originalEvent: evt
  19714. }); // Chosen item
  19715. toggleClass(dragEl, options.chosenClass, true);
  19716. }; // Disable "draggable"
  19717. options.ignore.split(',').forEach(function (criteria) {
  19718. find(dragEl, criteria.trim(), _disableDraggable);
  19719. });
  19720. on(ownerDocument, 'dragover', nearestEmptyInsertDetectEvent);
  19721. on(ownerDocument, 'mousemove', nearestEmptyInsertDetectEvent);
  19722. on(ownerDocument, 'touchmove', nearestEmptyInsertDetectEvent);
  19723. on(ownerDocument, 'mouseup', _this._onDrop);
  19724. on(ownerDocument, 'touchend', _this._onDrop);
  19725. on(ownerDocument, 'touchcancel', _this._onDrop); // Make dragEl draggable (must be before delay for FireFox)
  19726. if (FireFox && this.nativeDraggable) {
  19727. this.options.touchStartThreshold = 4;
  19728. dragEl.draggable = true;
  19729. }
  19730. pluginEvent('delayStart', this, {
  19731. evt: evt
  19732. }); // Delay is impossible for native DnD in Edge or IE
  19733. if (options.delay && (!options.delayOnTouchOnly || touch) && (!this.nativeDraggable || !(Edge || IE11OrLess))) {
  19734. if (Sortable.eventCanceled) {
  19735. this._onDrop();
  19736. return;
  19737. } // If the user moves the pointer or let go the click or touch
  19738. // before the delay has been reached:
  19739. // disable the delayed drag
  19740. on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
  19741. on(ownerDocument, 'touchend', _this._disableDelayedDrag);
  19742. on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
  19743. on(ownerDocument, 'mousemove', _this._delayedDragTouchMoveHandler);
  19744. on(ownerDocument, 'touchmove', _this._delayedDragTouchMoveHandler);
  19745. options.supportPointer && on(ownerDocument, 'pointermove', _this._delayedDragTouchMoveHandler);
  19746. _this._dragStartTimer = setTimeout(dragStartFn, options.delay);
  19747. } else {
  19748. dragStartFn();
  19749. }
  19750. }
  19751. },
  19752. _delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler(
  19753. /** TouchEvent|PointerEvent **/
  19754. e) {
  19755. var touch = e.touches ? e.touches[0] : e;
  19756. 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))) {
  19757. this._disableDelayedDrag();
  19758. }
  19759. },
  19760. _disableDelayedDrag: function _disableDelayedDrag() {
  19761. dragEl && _disableDraggable(dragEl);
  19762. clearTimeout(this._dragStartTimer);
  19763. this._disableDelayedDragEvents();
  19764. },
  19765. _disableDelayedDragEvents: function _disableDelayedDragEvents() {
  19766. var ownerDocument = this.el.ownerDocument;
  19767. off(ownerDocument, 'mouseup', this._disableDelayedDrag);
  19768. off(ownerDocument, 'touchend', this._disableDelayedDrag);
  19769. off(ownerDocument, 'touchcancel', this._disableDelayedDrag);
  19770. off(ownerDocument, 'mousemove', this._delayedDragTouchMoveHandler);
  19771. off(ownerDocument, 'touchmove', this._delayedDragTouchMoveHandler);
  19772. off(ownerDocument, 'pointermove', this._delayedDragTouchMoveHandler);
  19773. },
  19774. _triggerDragStart: function _triggerDragStart(
  19775. /** Event */
  19776. evt,
  19777. /** Touch */
  19778. touch) {
  19779. touch = touch || evt.pointerType == 'touch' && evt;
  19780. if (!this.nativeDraggable || touch) {
  19781. if (this.options.supportPointer) {
  19782. on(document, 'pointermove', this._onTouchMove);
  19783. } else if (touch) {
  19784. on(document, 'touchmove', this._onTouchMove);
  19785. } else {
  19786. on(document, 'mousemove', this._onTouchMove);
  19787. }
  19788. } else {
  19789. on(dragEl, 'dragend', this);
  19790. on(rootEl, 'dragstart', this._onDragStart);
  19791. }
  19792. try {
  19793. if (document.selection) {
  19794. // Timeout neccessary for IE9
  19795. _nextTick(function () {
  19796. document.selection.empty();
  19797. });
  19798. } else {
  19799. window.getSelection().removeAllRanges();
  19800. }
  19801. } catch (err) {}
  19802. },
  19803. _dragStarted: function _dragStarted(fallback, evt) {
  19804. awaitingDragStarted = false;
  19805. if (rootEl && dragEl) {
  19806. pluginEvent('dragStarted', this, {
  19807. evt: evt
  19808. });
  19809. if (this.nativeDraggable) {
  19810. on(document, 'dragover', _checkOutsideTargetEl);
  19811. }
  19812. var options = this.options; // Apply effect
  19813. !fallback && toggleClass(dragEl, options.dragClass, false);
  19814. toggleClass(dragEl, options.ghostClass, true);
  19815. Sortable.active = this;
  19816. fallback && this._appendGhost(); // Drag start event
  19817. _dispatchEvent({
  19818. sortable: this,
  19819. name: 'start',
  19820. originalEvent: evt
  19821. });
  19822. } else {
  19823. this._nulling();
  19824. }
  19825. },
  19826. _emulateDragOver: function _emulateDragOver() {
  19827. if (touchEvt) {
  19828. this._lastX = touchEvt.clientX;
  19829. this._lastY = touchEvt.clientY;
  19830. _hideGhostForTarget();
  19831. var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
  19832. var parent = target;
  19833. while (target && target.shadowRoot) {
  19834. target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
  19835. if (target === parent) break;
  19836. parent = target;
  19837. }
  19838. dragEl.parentNode[expando]._isOutsideThisEl(target);
  19839. if (parent) {
  19840. do {
  19841. if (parent[expando]) {
  19842. var inserted = void 0;
  19843. inserted = parent[expando]._onDragOver({
  19844. clientX: touchEvt.clientX,
  19845. clientY: touchEvt.clientY,
  19846. target: target,
  19847. rootEl: parent
  19848. });
  19849. if (inserted && !this.options.dragoverBubble) {
  19850. break;
  19851. }
  19852. }
  19853. target = parent; // store last element
  19854. }
  19855. /* jshint boss:true */
  19856. while (parent = parent.parentNode);
  19857. }
  19858. _unhideGhostForTarget();
  19859. }
  19860. },
  19861. _onTouchMove: function _onTouchMove(
  19862. /**TouchEvent*/
  19863. evt) {
  19864. if (tapEvt) {
  19865. var options = this.options,
  19866. fallbackTolerance = options.fallbackTolerance,
  19867. fallbackOffset = options.fallbackOffset,
  19868. touch = evt.touches ? evt.touches[0] : evt,
  19869. ghostMatrix = ghostEl && matrix(ghostEl, true),
  19870. scaleX = ghostEl && ghostMatrix && ghostMatrix.a,
  19871. scaleY = ghostEl && ghostMatrix && ghostMatrix.d,
  19872. relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset(ghostRelativeParent),
  19873. dx = (touch.clientX - tapEvt.clientX + fallbackOffset.x) / (scaleX || 1) + (relativeScrollOffset ? relativeScrollOffset[0] - ghostRelativeParentInitialScroll[0] : 0) / (scaleX || 1),
  19874. 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
  19875. if (!Sortable.active && !awaitingDragStarted) {
  19876. if (fallbackTolerance && Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < fallbackTolerance) {
  19877. return;
  19878. }
  19879. this._onDragStart(evt, true);
  19880. }
  19881. if (ghostEl) {
  19882. if (ghostMatrix) {
  19883. ghostMatrix.e += dx - (lastDx || 0);
  19884. ghostMatrix.f += dy - (lastDy || 0);
  19885. } else {
  19886. ghostMatrix = {
  19887. a: 1,
  19888. b: 0,
  19889. c: 0,
  19890. d: 1,
  19891. e: dx,
  19892. f: dy
  19893. };
  19894. }
  19895. var cssMatrix = "matrix(".concat(ghostMatrix.a, ",").concat(ghostMatrix.b, ",").concat(ghostMatrix.c, ",").concat(ghostMatrix.d, ",").concat(ghostMatrix.e, ",").concat(ghostMatrix.f, ")");
  19896. css(ghostEl, 'webkitTransform', cssMatrix);
  19897. css(ghostEl, 'mozTransform', cssMatrix);
  19898. css(ghostEl, 'msTransform', cssMatrix);
  19899. css(ghostEl, 'transform', cssMatrix);
  19900. lastDx = dx;
  19901. lastDy = dy;
  19902. touchEvt = touch;
  19903. }
  19904. evt.cancelable && evt.preventDefault();
  19905. }
  19906. },
  19907. _appendGhost: function _appendGhost() {
  19908. // Bug if using scale(): https://stackoverflow.com/questions/2637058
  19909. // Not being adjusted for
  19910. if (!ghostEl) {
  19911. var container = this.options.fallbackOnBody ? document.body : rootEl,
  19912. rect = getRect(dragEl, true, PositionGhostAbsolutely, true, container),
  19913. options = this.options; // Position absolutely
  19914. if (PositionGhostAbsolutely) {
  19915. // Get relatively positioned parent
  19916. ghostRelativeParent = container;
  19917. while (css(ghostRelativeParent, 'position') === 'static' && css(ghostRelativeParent, 'transform') === 'none' && ghostRelativeParent !== document) {
  19918. ghostRelativeParent = ghostRelativeParent.parentNode;
  19919. }
  19920. if (ghostRelativeParent !== document.body && ghostRelativeParent !== document.documentElement) {
  19921. if (ghostRelativeParent === document) ghostRelativeParent = getWindowScrollingElement();
  19922. rect.top += ghostRelativeParent.scrollTop;
  19923. rect.left += ghostRelativeParent.scrollLeft;
  19924. } else {
  19925. ghostRelativeParent = getWindowScrollingElement();
  19926. }
  19927. ghostRelativeParentInitialScroll = getRelativeScrollOffset(ghostRelativeParent);
  19928. }
  19929. ghostEl = dragEl.cloneNode(true);
  19930. toggleClass(ghostEl, options.ghostClass, false);
  19931. toggleClass(ghostEl, options.fallbackClass, true);
  19932. toggleClass(ghostEl, options.dragClass, true);
  19933. css(ghostEl, 'transition', '');
  19934. css(ghostEl, 'transform', '');
  19935. css(ghostEl, 'box-sizing', 'border-box');
  19936. css(ghostEl, 'margin', 0);
  19937. css(ghostEl, 'top', rect.top);
  19938. css(ghostEl, 'left', rect.left);
  19939. css(ghostEl, 'width', rect.width);
  19940. css(ghostEl, 'height', rect.height);
  19941. css(ghostEl, 'opacity', '0.8');
  19942. css(ghostEl, 'position', PositionGhostAbsolutely ? 'absolute' : 'fixed');
  19943. css(ghostEl, 'zIndex', '100000');
  19944. css(ghostEl, 'pointerEvents', 'none');
  19945. Sortable.ghost = ghostEl;
  19946. container.appendChild(ghostEl); // Set transform-origin
  19947. css(ghostEl, 'transform-origin', tapDistanceLeft / parseInt(ghostEl.style.width) * 100 + '% ' + tapDistanceTop / parseInt(ghostEl.style.height) * 100 + '%');
  19948. }
  19949. },
  19950. _onDragStart: function _onDragStart(
  19951. /**Event*/
  19952. evt,
  19953. /**boolean*/
  19954. fallback) {
  19955. var _this = this;
  19956. var dataTransfer = evt.dataTransfer;
  19957. var options = _this.options;
  19958. pluginEvent('dragStart', this, {
  19959. evt: evt
  19960. });
  19961. if (Sortable.eventCanceled) {
  19962. this._onDrop();
  19963. return;
  19964. }
  19965. pluginEvent('setupClone', this);
  19966. if (!Sortable.eventCanceled) {
  19967. cloneEl = clone(dragEl);
  19968. cloneEl.removeAttribute("id");
  19969. cloneEl.draggable = false;
  19970. cloneEl.style['will-change'] = '';
  19971. this._hideClone();
  19972. toggleClass(cloneEl, this.options.chosenClass, false);
  19973. Sortable.clone = cloneEl;
  19974. } // #1143: IFrame support workaround
  19975. _this.cloneId = _nextTick(function () {
  19976. pluginEvent('clone', _this);
  19977. if (Sortable.eventCanceled) return;
  19978. if (!_this.options.removeCloneOnHide) {
  19979. rootEl.insertBefore(cloneEl, dragEl);
  19980. }
  19981. _this._hideClone();
  19982. _dispatchEvent({
  19983. sortable: _this,
  19984. name: 'clone'
  19985. });
  19986. });
  19987. !fallback && toggleClass(dragEl, options.dragClass, true); // Set proper drop events
  19988. if (fallback) {
  19989. ignoreNextClick = true;
  19990. _this._loopId = setInterval(_this._emulateDragOver, 50);
  19991. } else {
  19992. // Undo what was set in _prepareDragStart before drag started
  19993. off(document, 'mouseup', _this._onDrop);
  19994. off(document, 'touchend', _this._onDrop);
  19995. off(document, 'touchcancel', _this._onDrop);
  19996. if (dataTransfer) {
  19997. dataTransfer.effectAllowed = 'move';
  19998. options.setData && options.setData.call(_this, dataTransfer, dragEl);
  19999. }
  20000. on(document, 'drop', _this); // #1276 fix:
  20001. css(dragEl, 'transform', 'translateZ(0)');
  20002. }
  20003. awaitingDragStarted = true;
  20004. _this._dragStartId = _nextTick(_this._dragStarted.bind(_this, fallback, evt));
  20005. on(document, 'selectstart', _this);
  20006. moved = true;
  20007. if (Safari) {
  20008. css(document.body, 'user-select', 'none');
  20009. }
  20010. },
  20011. // Returns true - if no further action is needed (either inserted or another condition)
  20012. _onDragOver: function _onDragOver(
  20013. /**Event*/
  20014. evt) {
  20015. var el = this.el,
  20016. target = evt.target,
  20017. dragRect,
  20018. targetRect,
  20019. revert,
  20020. options = this.options,
  20021. group = options.group,
  20022. activeSortable = Sortable.active,
  20023. isOwner = activeGroup === group,
  20024. canSort = options.sort,
  20025. fromSortable = putSortable || activeSortable,
  20026. vertical,
  20027. _this = this,
  20028. completedFired = false;
  20029. if (_silent) return;
  20030. function dragOverEvent(name, extra) {
  20031. pluginEvent(name, _this, _objectSpread2({
  20032. evt: evt,
  20033. isOwner: isOwner,
  20034. axis: vertical ? 'vertical' : 'horizontal',
  20035. revert: revert,
  20036. dragRect: dragRect,
  20037. targetRect: targetRect,
  20038. canSort: canSort,
  20039. fromSortable: fromSortable,
  20040. target: target,
  20041. completed: completed,
  20042. onMove: function onMove(target, after) {
  20043. return _onMove(rootEl, el, dragEl, dragRect, target, getRect(target), evt, after);
  20044. },
  20045. changed: changed
  20046. }, extra));
  20047. } // Capture animation state
  20048. function capture() {
  20049. dragOverEvent('dragOverAnimationCapture');
  20050. _this.captureAnimationState();
  20051. if (_this !== fromSortable) {
  20052. fromSortable.captureAnimationState();
  20053. }
  20054. } // Return invocation when dragEl is inserted (or completed)
  20055. function completed(insertion) {
  20056. dragOverEvent('dragOverCompleted', {
  20057. insertion: insertion
  20058. });
  20059. if (insertion) {
  20060. // Clones must be hidden before folding animation to capture dragRectAbsolute properly
  20061. if (isOwner) {
  20062. activeSortable._hideClone();
  20063. } else {
  20064. activeSortable._showClone(_this);
  20065. }
  20066. if (_this !== fromSortable) {
  20067. // Set ghost class to new sortable's ghost class
  20068. toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false);
  20069. toggleClass(dragEl, options.ghostClass, true);
  20070. }
  20071. if (putSortable !== _this && _this !== Sortable.active) {
  20072. putSortable = _this;
  20073. } else if (_this === Sortable.active && putSortable) {
  20074. putSortable = null;
  20075. } // Animation
  20076. if (fromSortable === _this) {
  20077. _this._ignoreWhileAnimating = target;
  20078. }
  20079. _this.animateAll(function () {
  20080. dragOverEvent('dragOverAnimationComplete');
  20081. _this._ignoreWhileAnimating = null;
  20082. });
  20083. if (_this !== fromSortable) {
  20084. fromSortable.animateAll();
  20085. fromSortable._ignoreWhileAnimating = null;
  20086. }
  20087. } // Null lastTarget if it is not inside a previously swapped element
  20088. if (target === dragEl && !dragEl.animated || target === el && !target.animated) {
  20089. lastTarget = null;
  20090. } // no bubbling and not fallback
  20091. if (!options.dragoverBubble && !evt.rootEl && target !== document) {
  20092. dragEl.parentNode[expando]._isOutsideThisEl(evt.target); // Do not detect for empty insert if already inserted
  20093. !insertion && nearestEmptyInsertDetectEvent(evt);
  20094. }
  20095. !options.dragoverBubble && evt.stopPropagation && evt.stopPropagation();
  20096. return completedFired = true;
  20097. } // Call when dragEl has been inserted
  20098. function changed() {
  20099. newIndex = index(dragEl);
  20100. newDraggableIndex = index(dragEl, options.draggable);
  20101. _dispatchEvent({
  20102. sortable: _this,
  20103. name: 'change',
  20104. toEl: el,
  20105. newIndex: newIndex,
  20106. newDraggableIndex: newDraggableIndex,
  20107. originalEvent: evt
  20108. });
  20109. }
  20110. if (evt.preventDefault !== void 0) {
  20111. evt.cancelable && evt.preventDefault();
  20112. }
  20113. target = closest(target, options.draggable, el, true);
  20114. dragOverEvent('dragOver');
  20115. if (Sortable.eventCanceled) return completedFired;
  20116. if (dragEl.contains(evt.target) || target.animated && target.animatingX && target.animatingY || _this._ignoreWhileAnimating === target) {
  20117. return completed(false);
  20118. }
  20119. ignoreNextClick = false;
  20120. if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = parentEl !== rootEl) // Reverting item into the original list
  20121. : putSortable === this || (this.lastPutMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && group.checkPut(this, activeSortable, dragEl, evt))) {
  20122. vertical = this._getDirection(evt, target) === 'vertical';
  20123. dragRect = getRect(dragEl);
  20124. dragOverEvent('dragOverValid');
  20125. if (Sortable.eventCanceled) return completedFired;
  20126. if (revert) {
  20127. parentEl = rootEl; // actualization
  20128. capture();
  20129. this._hideClone();
  20130. dragOverEvent('revert');
  20131. if (!Sortable.eventCanceled) {
  20132. if (nextEl) {
  20133. rootEl.insertBefore(dragEl, nextEl);
  20134. } else {
  20135. rootEl.appendChild(dragEl);
  20136. }
  20137. }
  20138. return completed(true);
  20139. }
  20140. var elLastChild = lastChild(el, options.draggable);
  20141. if (!elLastChild || _ghostIsLast(evt, vertical, this) && !elLastChild.animated) {
  20142. // Insert to end of list
  20143. // If already at end of list: Do not insert
  20144. if (elLastChild === dragEl) {
  20145. return completed(false);
  20146. } // if there is a last element, it is the target
  20147. if (elLastChild && el === evt.target) {
  20148. target = elLastChild;
  20149. }
  20150. if (target) {
  20151. targetRect = getRect(target);
  20152. }
  20153. if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, !!target) !== false) {
  20154. capture();
  20155. if (elLastChild && elLastChild.nextSibling) {
  20156. // the last draggable element is not the last node
  20157. el.insertBefore(dragEl, elLastChild.nextSibling);
  20158. } else {
  20159. el.appendChild(dragEl);
  20160. }
  20161. parentEl = el; // actualization
  20162. changed();
  20163. return completed(true);
  20164. }
  20165. } else if (elLastChild && _ghostIsFirst(evt, vertical, this)) {
  20166. // Insert to start of list
  20167. var firstChild = getChild(el, 0, options, true);
  20168. if (firstChild === dragEl) {
  20169. return completed(false);
  20170. }
  20171. target = firstChild;
  20172. targetRect = getRect(target);
  20173. if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, false) !== false) {
  20174. capture();
  20175. el.insertBefore(dragEl, firstChild);
  20176. parentEl = el; // actualization
  20177. changed();
  20178. return completed(true);
  20179. }
  20180. } else if (target.parentNode === el) {
  20181. targetRect = getRect(target);
  20182. var direction = 0,
  20183. targetBeforeFirstSwap,
  20184. differentLevel = dragEl.parentNode !== el,
  20185. differentRowCol = !_dragElInRowColumn(dragEl.animated && dragEl.toRect || dragRect, target.animated && target.toRect || targetRect, vertical),
  20186. side1 = vertical ? 'top' : 'left',
  20187. scrolledPastTop = isScrolledPast(target, 'top', 'top') || isScrolledPast(dragEl, 'top', 'top'),
  20188. scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0;
  20189. if (lastTarget !== target) {
  20190. targetBeforeFirstSwap = targetRect[side1];
  20191. pastFirstInvertThresh = false;
  20192. isCircumstantialInvert = !differentRowCol && options.invertSwap || differentLevel;
  20193. }
  20194. direction = _getSwapDirection(evt, target, targetRect, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target);
  20195. var sibling;
  20196. if (direction !== 0) {
  20197. // Check if target is beside dragEl in respective direction (ignoring hidden elements)
  20198. var dragIndex = index(dragEl);
  20199. do {
  20200. dragIndex -= direction;
  20201. sibling = parentEl.children[dragIndex];
  20202. } while (sibling && (css(sibling, 'display') === 'none' || sibling === ghostEl));
  20203. } // If dragEl is already beside target: Do not insert
  20204. if (direction === 0 || sibling === target) {
  20205. return completed(false);
  20206. }
  20207. lastTarget = target;
  20208. lastDirection = direction;
  20209. var nextSibling = target.nextElementSibling,
  20210. after = false;
  20211. after = direction === 1;
  20212. var moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after);
  20213. if (moveVector !== false) {
  20214. if (moveVector === 1 || moveVector === -1) {
  20215. after = moveVector === 1;
  20216. }
  20217. _silent = true;
  20218. setTimeout(_unsilent, 30);
  20219. capture();
  20220. if (after && !nextSibling) {
  20221. el.appendChild(dragEl);
  20222. } else {
  20223. target.parentNode.insertBefore(dragEl, after ? nextSibling : target);
  20224. } // Undo chrome's scroll adjustment (has no effect on other browsers)
  20225. if (scrolledPastTop) {
  20226. scrollBy(scrolledPastTop, 0, scrollBefore - scrolledPastTop.scrollTop);
  20227. }
  20228. parentEl = dragEl.parentNode; // actualization
  20229. // must be done before animation
  20230. if (targetBeforeFirstSwap !== undefined && !isCircumstantialInvert) {
  20231. targetMoveDistance = Math.abs(targetBeforeFirstSwap - getRect(target)[side1]);
  20232. }
  20233. changed();
  20234. return completed(true);
  20235. }
  20236. }
  20237. if (el.contains(dragEl)) {
  20238. return completed(false);
  20239. }
  20240. }
  20241. return false;
  20242. },
  20243. _ignoreWhileAnimating: null,
  20244. _offMoveEvents: function _offMoveEvents() {
  20245. off(document, 'mousemove', this._onTouchMove);
  20246. off(document, 'touchmove', this._onTouchMove);
  20247. off(document, 'pointermove', this._onTouchMove);
  20248. off(document, 'dragover', nearestEmptyInsertDetectEvent);
  20249. off(document, 'mousemove', nearestEmptyInsertDetectEvent);
  20250. off(document, 'touchmove', nearestEmptyInsertDetectEvent);
  20251. },
  20252. _offUpEvents: function _offUpEvents() {
  20253. var ownerDocument = this.el.ownerDocument;
  20254. off(ownerDocument, 'mouseup', this._onDrop);
  20255. off(ownerDocument, 'touchend', this._onDrop);
  20256. off(ownerDocument, 'pointerup', this._onDrop);
  20257. off(ownerDocument, 'touchcancel', this._onDrop);
  20258. off(document, 'selectstart', this);
  20259. },
  20260. _onDrop: function _onDrop(
  20261. /**Event*/
  20262. evt) {
  20263. var el = this.el,
  20264. options = this.options; // Get the index of the dragged element within its parent
  20265. newIndex = index(dragEl);
  20266. newDraggableIndex = index(dragEl, options.draggable);
  20267. pluginEvent('drop', this, {
  20268. evt: evt
  20269. });
  20270. parentEl = dragEl && dragEl.parentNode; // Get again after plugin event
  20271. newIndex = index(dragEl);
  20272. newDraggableIndex = index(dragEl, options.draggable);
  20273. if (Sortable.eventCanceled) {
  20274. this._nulling();
  20275. return;
  20276. }
  20277. awaitingDragStarted = false;
  20278. isCircumstantialInvert = false;
  20279. pastFirstInvertThresh = false;
  20280. clearInterval(this._loopId);
  20281. clearTimeout(this._dragStartTimer);
  20282. _cancelNextTick(this.cloneId);
  20283. _cancelNextTick(this._dragStartId); // Unbind events
  20284. if (this.nativeDraggable) {
  20285. off(document, 'drop', this);
  20286. off(el, 'dragstart', this._onDragStart);
  20287. }
  20288. this._offMoveEvents();
  20289. this._offUpEvents();
  20290. if (Safari) {
  20291. css(document.body, 'user-select', '');
  20292. }
  20293. css(dragEl, 'transform', '');
  20294. if (evt) {
  20295. if (moved) {
  20296. evt.cancelable && evt.preventDefault();
  20297. !options.dropBubble && evt.stopPropagation();
  20298. }
  20299. ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl);
  20300. if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') {
  20301. // Remove clone(s)
  20302. cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl);
  20303. }
  20304. if (dragEl) {
  20305. if (this.nativeDraggable) {
  20306. off(dragEl, 'dragend', this);
  20307. }
  20308. _disableDraggable(dragEl);
  20309. dragEl.style['will-change'] = ''; // Remove classes
  20310. // ghostClass is added in dragStarted
  20311. if (moved && !awaitingDragStarted) {
  20312. toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : this.options.ghostClass, false);
  20313. }
  20314. toggleClass(dragEl, this.options.chosenClass, false); // Drag stop event
  20315. _dispatchEvent({
  20316. sortable: this,
  20317. name: 'unchoose',
  20318. toEl: parentEl,
  20319. newIndex: null,
  20320. newDraggableIndex: null,
  20321. originalEvent: evt
  20322. });
  20323. if (rootEl !== parentEl) {
  20324. if (newIndex >= 0) {
  20325. // Add event
  20326. _dispatchEvent({
  20327. rootEl: parentEl,
  20328. name: 'add',
  20329. toEl: parentEl,
  20330. fromEl: rootEl,
  20331. originalEvent: evt
  20332. }); // Remove event
  20333. _dispatchEvent({
  20334. sortable: this,
  20335. name: 'remove',
  20336. toEl: parentEl,
  20337. originalEvent: evt
  20338. }); // drag from one list and drop into another
  20339. _dispatchEvent({
  20340. rootEl: parentEl,
  20341. name: 'sort',
  20342. toEl: parentEl,
  20343. fromEl: rootEl,
  20344. originalEvent: evt
  20345. });
  20346. _dispatchEvent({
  20347. sortable: this,
  20348. name: 'sort',
  20349. toEl: parentEl,
  20350. originalEvent: evt
  20351. });
  20352. }
  20353. putSortable && putSortable.save();
  20354. } else {
  20355. if (newIndex !== oldIndex) {
  20356. if (newIndex >= 0) {
  20357. // drag & drop within the same list
  20358. _dispatchEvent({
  20359. sortable: this,
  20360. name: 'update',
  20361. toEl: parentEl,
  20362. originalEvent: evt
  20363. });
  20364. _dispatchEvent({
  20365. sortable: this,
  20366. name: 'sort',
  20367. toEl: parentEl,
  20368. originalEvent: evt
  20369. });
  20370. }
  20371. }
  20372. }
  20373. if (Sortable.active) {
  20374. /* jshint eqnull:true */
  20375. if (newIndex == null || newIndex === -1) {
  20376. newIndex = oldIndex;
  20377. newDraggableIndex = oldDraggableIndex;
  20378. }
  20379. _dispatchEvent({
  20380. sortable: this,
  20381. name: 'end',
  20382. toEl: parentEl,
  20383. originalEvent: evt
  20384. }); // Save sorting
  20385. this.save();
  20386. }
  20387. }
  20388. }
  20389. this._nulling();
  20390. },
  20391. _nulling: function _nulling() {
  20392. pluginEvent('nulling', this);
  20393. 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;
  20394. savedInputChecked.forEach(function (el) {
  20395. el.checked = true;
  20396. });
  20397. savedInputChecked.length = lastDx = lastDy = 0;
  20398. },
  20399. handleEvent: function handleEvent(
  20400. /**Event*/
  20401. evt) {
  20402. switch (evt.type) {
  20403. case 'drop':
  20404. case 'dragend':
  20405. this._onDrop(evt);
  20406. break;
  20407. case 'dragenter':
  20408. case 'dragover':
  20409. if (dragEl) {
  20410. this._onDragOver(evt);
  20411. _globalDragOver(evt);
  20412. }
  20413. break;
  20414. case 'selectstart':
  20415. evt.preventDefault();
  20416. break;
  20417. }
  20418. },
  20419. /**
  20420. * Serializes the item into an array of string.
  20421. * @returns {String[]}
  20422. */
  20423. toArray: function toArray() {
  20424. var order = [],
  20425. el,
  20426. children = this.el.children,
  20427. i = 0,
  20428. n = children.length,
  20429. options = this.options;
  20430. for (; i < n; i++) {
  20431. el = children[i];
  20432. if (closest(el, options.draggable, this.el, false)) {
  20433. order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
  20434. }
  20435. }
  20436. return order;
  20437. },
  20438. /**
  20439. * Sorts the elements according to the array.
  20440. * @param {String[]} order order of the items
  20441. */
  20442. sort: function sort(order, useAnimation) {
  20443. var items = {},
  20444. rootEl = this.el;
  20445. this.toArray().forEach(function (id, i) {
  20446. var el = rootEl.children[i];
  20447. if (closest(el, this.options.draggable, rootEl, false)) {
  20448. items[id] = el;
  20449. }
  20450. }, this);
  20451. useAnimation && this.captureAnimationState();
  20452. order.forEach(function (id) {
  20453. if (items[id]) {
  20454. rootEl.removeChild(items[id]);
  20455. rootEl.appendChild(items[id]);
  20456. }
  20457. });
  20458. useAnimation && this.animateAll();
  20459. },
  20460. /**
  20461. * Save the current sorting
  20462. */
  20463. save: function save() {
  20464. var store = this.options.store;
  20465. store && store.set && store.set(this);
  20466. },
  20467. /**
  20468. * 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.
  20469. * @param {HTMLElement} el
  20470. * @param {String} [selector] default: `options.draggable`
  20471. * @returns {HTMLElement|null}
  20472. */
  20473. closest: function closest$1(el, selector) {
  20474. return closest(el, selector || this.options.draggable, this.el, false);
  20475. },
  20476. /**
  20477. * Set/get option
  20478. * @param {string} name
  20479. * @param {*} [value]
  20480. * @returns {*}
  20481. */
  20482. option: function option(name, value) {
  20483. var options = this.options;
  20484. if (value === void 0) {
  20485. return options[name];
  20486. } else {
  20487. var modifiedValue = PluginManager.modifyOption(this, name, value);
  20488. if (typeof modifiedValue !== 'undefined') {
  20489. options[name] = modifiedValue;
  20490. } else {
  20491. options[name] = value;
  20492. }
  20493. if (name === 'group') {
  20494. _prepareGroup(options);
  20495. }
  20496. }
  20497. },
  20498. /**
  20499. * Destroy
  20500. */
  20501. destroy: function destroy() {
  20502. pluginEvent('destroy', this);
  20503. var el = this.el;
  20504. el[expando] = null;
  20505. off(el, 'mousedown', this._onTapStart);
  20506. off(el, 'touchstart', this._onTapStart);
  20507. off(el, 'pointerdown', this._onTapStart);
  20508. if (this.nativeDraggable) {
  20509. off(el, 'dragover', this);
  20510. off(el, 'dragenter', this);
  20511. } // Remove draggable attributes
  20512. Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function (el) {
  20513. el.removeAttribute('draggable');
  20514. });
  20515. this._onDrop();
  20516. this._disableDelayedDragEvents();
  20517. sortables.splice(sortables.indexOf(this.el), 1);
  20518. this.el = el = null;
  20519. },
  20520. _hideClone: function _hideClone() {
  20521. if (!cloneHidden) {
  20522. pluginEvent('hideClone', this);
  20523. if (Sortable.eventCanceled) return;
  20524. css(cloneEl, 'display', 'none');
  20525. if (this.options.removeCloneOnHide && cloneEl.parentNode) {
  20526. cloneEl.parentNode.removeChild(cloneEl);
  20527. }
  20528. cloneHidden = true;
  20529. }
  20530. },
  20531. _showClone: function _showClone(putSortable) {
  20532. if (putSortable.lastPutMode !== 'clone') {
  20533. this._hideClone();
  20534. return;
  20535. }
  20536. if (cloneHidden) {
  20537. pluginEvent('showClone', this);
  20538. if (Sortable.eventCanceled) return; // show clone at dragEl or original position
  20539. if (dragEl.parentNode == rootEl && !this.options.group.revertClone) {
  20540. rootEl.insertBefore(cloneEl, dragEl);
  20541. } else if (nextEl) {
  20542. rootEl.insertBefore(cloneEl, nextEl);
  20543. } else {
  20544. rootEl.appendChild(cloneEl);
  20545. }
  20546. if (this.options.group.revertClone) {
  20547. this.animate(dragEl, cloneEl);
  20548. }
  20549. css(cloneEl, 'display', '');
  20550. cloneHidden = false;
  20551. }
  20552. }
  20553. };
  20554. function _globalDragOver(
  20555. /**Event*/
  20556. evt) {
  20557. if (evt.dataTransfer) {
  20558. evt.dataTransfer.dropEffect = 'move';
  20559. }
  20560. evt.cancelable && evt.preventDefault();
  20561. }
  20562. function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvent, willInsertAfter) {
  20563. var evt,
  20564. sortable = fromEl[expando],
  20565. onMoveFn = sortable.options.onMove,
  20566. retVal; // Support for new CustomEvent feature
  20567. if (window.CustomEvent && !IE11OrLess && !Edge) {
  20568. evt = new CustomEvent('move', {
  20569. bubbles: true,
  20570. cancelable: true
  20571. });
  20572. } else {
  20573. evt = document.createEvent('Event');
  20574. evt.initEvent('move', true, true);
  20575. }
  20576. evt.to = toEl;
  20577. evt.from = fromEl;
  20578. evt.dragged = dragEl;
  20579. evt.draggedRect = dragRect;
  20580. evt.related = targetEl || toEl;
  20581. evt.relatedRect = targetRect || getRect(toEl);
  20582. evt.willInsertAfter = willInsertAfter;
  20583. evt.originalEvent = originalEvent;
  20584. fromEl.dispatchEvent(evt);
  20585. if (onMoveFn) {
  20586. retVal = onMoveFn.call(sortable, evt, originalEvent);
  20587. }
  20588. return retVal;
  20589. }
  20590. function _disableDraggable(el) {
  20591. el.draggable = false;
  20592. }
  20593. function _unsilent() {
  20594. _silent = false;
  20595. }
  20596. function _ghostIsFirst(evt, vertical, sortable) {
  20597. var rect = getRect(getChild(sortable.el, 0, sortable.options, true));
  20598. var spacer = 10;
  20599. 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;
  20600. }
  20601. function _ghostIsLast(evt, vertical, sortable) {
  20602. var rect = getRect(lastChild(sortable.el, sortable.options.draggable));
  20603. var spacer = 10;
  20604. 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;
  20605. }
  20606. function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
  20607. var mouseOnAxis = vertical ? evt.clientY : evt.clientX,
  20608. targetLength = vertical ? targetRect.height : targetRect.width,
  20609. targetS1 = vertical ? targetRect.top : targetRect.left,
  20610. targetS2 = vertical ? targetRect.bottom : targetRect.right,
  20611. invert = false;
  20612. if (!invertSwap) {
  20613. // Never invert or create dragEl shadow when target movemenet causes mouse to move past the end of regular swapThreshold
  20614. if (isLastTarget && targetMoveDistance < targetLength * swapThreshold) {
  20615. // multiplied only by swapThreshold because mouse will already be inside target by (1 - threshold) * targetLength / 2
  20616. // check if past first invert threshold on side opposite of lastDirection
  20617. if (!pastFirstInvertThresh && (lastDirection === 1 ? mouseOnAxis > targetS1 + targetLength * invertedSwapThreshold / 2 : mouseOnAxis < targetS2 - targetLength * invertedSwapThreshold / 2)) {
  20618. // past first invert threshold, do not restrict inverted threshold to dragEl shadow
  20619. pastFirstInvertThresh = true;
  20620. }
  20621. if (!pastFirstInvertThresh) {
  20622. // dragEl shadow (target move distance shadow)
  20623. if (lastDirection === 1 ? mouseOnAxis < targetS1 + targetMoveDistance // over dragEl shadow
  20624. : mouseOnAxis > targetS2 - targetMoveDistance) {
  20625. return -lastDirection;
  20626. }
  20627. } else {
  20628. invert = true;
  20629. }
  20630. } else {
  20631. // Regular
  20632. if (mouseOnAxis > targetS1 + targetLength * (1 - swapThreshold) / 2 && mouseOnAxis < targetS2 - targetLength * (1 - swapThreshold) / 2) {
  20633. return _getInsertDirection(target);
  20634. }
  20635. }
  20636. }
  20637. invert = invert || invertSwap;
  20638. if (invert) {
  20639. // Invert of regular
  20640. if (mouseOnAxis < targetS1 + targetLength * invertedSwapThreshold / 2 || mouseOnAxis > targetS2 - targetLength * invertedSwapThreshold / 2) {
  20641. return mouseOnAxis > targetS1 + targetLength / 2 ? 1 : -1;
  20642. }
  20643. }
  20644. return 0;
  20645. }
  20646. /**
  20647. * Gets the direction dragEl must be swapped relative to target in order to make it
  20648. * seem that dragEl has been "inserted" into that element's position
  20649. * @param {HTMLElement} target The target whose position dragEl is being inserted at
  20650. * @return {Number} Direction dragEl must be swapped
  20651. */
  20652. function _getInsertDirection(target) {
  20653. if (index(dragEl) < index(target)) {
  20654. return 1;
  20655. } else {
  20656. return -1;
  20657. }
  20658. }
  20659. /**
  20660. * Generate id
  20661. * @param {HTMLElement} el
  20662. * @returns {String}
  20663. * @private
  20664. */
  20665. function _generateId(el) {
  20666. var str = el.tagName + el.className + el.src + el.href + el.textContent,
  20667. i = str.length,
  20668. sum = 0;
  20669. while (i--) {
  20670. sum += str.charCodeAt(i);
  20671. }
  20672. return sum.toString(36);
  20673. }
  20674. function _saveInputCheckedState(root) {
  20675. savedInputChecked.length = 0;
  20676. var inputs = root.getElementsByTagName('input');
  20677. var idx = inputs.length;
  20678. while (idx--) {
  20679. var el = inputs[idx];
  20680. el.checked && savedInputChecked.push(el);
  20681. }
  20682. }
  20683. function _nextTick(fn) {
  20684. return setTimeout(fn, 0);
  20685. }
  20686. function _cancelNextTick(id) {
  20687. return clearTimeout(id);
  20688. } // Fixed #973:
  20689. if (documentExists) {
  20690. on(document, 'touchmove', function (evt) {
  20691. if ((Sortable.active || awaitingDragStarted) && evt.cancelable) {
  20692. evt.preventDefault();
  20693. }
  20694. });
  20695. } // Export utils
  20696. Sortable.utils = {
  20697. on: on,
  20698. off: off,
  20699. css: css,
  20700. find: find,
  20701. is: function is(el, selector) {
  20702. return !!closest(el, selector, el, false);
  20703. },
  20704. extend: extend,
  20705. throttle: throttle,
  20706. closest: closest,
  20707. toggleClass: toggleClass,
  20708. clone: clone,
  20709. index: index,
  20710. nextTick: _nextTick,
  20711. cancelNextTick: _cancelNextTick,
  20712. detectDirection: _detectDirection,
  20713. getChild: getChild
  20714. };
  20715. /**
  20716. * Get the Sortable instance of an element
  20717. * @param {HTMLElement} element The element
  20718. * @return {Sortable|undefined} The instance of Sortable
  20719. */
  20720. Sortable.get = function (element) {
  20721. return element[expando];
  20722. };
  20723. /**
  20724. * Mount a plugin to Sortable
  20725. * @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted
  20726. */
  20727. Sortable.mount = function () {
  20728. for (var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++) {
  20729. plugins[_key] = arguments[_key];
  20730. }
  20731. if (plugins[0].constructor === Array) plugins = plugins[0];
  20732. plugins.forEach(function (plugin) {
  20733. if (!plugin.prototype || !plugin.prototype.constructor) {
  20734. throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(plugin));
  20735. }
  20736. if (plugin.utils) Sortable.utils = _objectSpread2(_objectSpread2({}, Sortable.utils), plugin.utils);
  20737. PluginManager.mount(plugin);
  20738. });
  20739. };
  20740. /**
  20741. * Create sortable instance
  20742. * @param {HTMLElement} el
  20743. * @param {Object} [options]
  20744. */
  20745. Sortable.create = function (el, options) {
  20746. return new Sortable(el, options);
  20747. }; // Export
  20748. Sortable.version = version;
  20749. var autoScrolls = [],
  20750. scrollEl,
  20751. scrollRootEl,
  20752. scrolling = false,
  20753. lastAutoScrollX,
  20754. lastAutoScrollY,
  20755. touchEvt$1,
  20756. pointerElemChangedInterval;
  20757. function AutoScrollPlugin() {
  20758. function AutoScroll() {
  20759. this.defaults = {
  20760. scroll: true,
  20761. forceAutoScrollFallback: false,
  20762. scrollSensitivity: 30,
  20763. scrollSpeed: 10,
  20764. bubbleScroll: true
  20765. }; // Bind all private methods
  20766. for (var fn in this) {
  20767. if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
  20768. this[fn] = this[fn].bind(this);
  20769. }
  20770. }
  20771. }
  20772. AutoScroll.prototype = {
  20773. dragStarted: function dragStarted(_ref) {
  20774. var originalEvent = _ref.originalEvent;
  20775. if (this.sortable.nativeDraggable) {
  20776. on(document, 'dragover', this._handleAutoScroll);
  20777. } else {
  20778. if (this.options.supportPointer) {
  20779. on(document, 'pointermove', this._handleFallbackAutoScroll);
  20780. } else if (originalEvent.touches) {
  20781. on(document, 'touchmove', this._handleFallbackAutoScroll);
  20782. } else {
  20783. on(document, 'mousemove', this._handleFallbackAutoScroll);
  20784. }
  20785. }
  20786. },
  20787. dragOverCompleted: function dragOverCompleted(_ref2) {
  20788. var originalEvent = _ref2.originalEvent;
  20789. // For when bubbling is canceled and using fallback (fallback 'touchmove' always reached)
  20790. if (!this.options.dragOverBubble && !originalEvent.rootEl) {
  20791. this._handleAutoScroll(originalEvent);
  20792. }
  20793. },
  20794. drop: function drop() {
  20795. if (this.sortable.nativeDraggable) {
  20796. off(document, 'dragover', this._handleAutoScroll);
  20797. } else {
  20798. off(document, 'pointermove', this._handleFallbackAutoScroll);
  20799. off(document, 'touchmove', this._handleFallbackAutoScroll);
  20800. off(document, 'mousemove', this._handleFallbackAutoScroll);
  20801. }
  20802. clearPointerElemChangedInterval();
  20803. clearAutoScrolls();
  20804. cancelThrottle();
  20805. },
  20806. nulling: function nulling() {
  20807. touchEvt$1 = scrollRootEl = scrollEl = scrolling = pointerElemChangedInterval = lastAutoScrollX = lastAutoScrollY = null;
  20808. autoScrolls.length = 0;
  20809. },
  20810. _handleFallbackAutoScroll: function _handleFallbackAutoScroll(evt) {
  20811. this._handleAutoScroll(evt, true);
  20812. },
  20813. _handleAutoScroll: function _handleAutoScroll(evt, fallback) {
  20814. var _this = this;
  20815. var x = (evt.touches ? evt.touches[0] : evt).clientX,
  20816. y = (evt.touches ? evt.touches[0] : evt).clientY,
  20817. elem = document.elementFromPoint(x, y);
  20818. touchEvt$1 = evt; // IE does not seem to have native autoscroll,
  20819. // Edge's autoscroll seems too conditional,
  20820. // MACOS Safari does not have autoscroll,
  20821. // Firefox and Chrome are good
  20822. if (fallback || this.options.forceAutoScrollFallback || Edge || IE11OrLess || Safari) {
  20823. autoScroll(evt, this.options, elem, fallback); // Listener for pointer element change
  20824. var ogElemScroller = getParentAutoScrollElement(elem, true);
  20825. if (scrolling && (!pointerElemChangedInterval || x !== lastAutoScrollX || y !== lastAutoScrollY)) {
  20826. pointerElemChangedInterval && clearPointerElemChangedInterval(); // Detect for pointer elem change, emulating native DnD behaviour
  20827. pointerElemChangedInterval = setInterval(function () {
  20828. var newElem = getParentAutoScrollElement(document.elementFromPoint(x, y), true);
  20829. if (newElem !== ogElemScroller) {
  20830. ogElemScroller = newElem;
  20831. clearAutoScrolls();
  20832. }
  20833. autoScroll(evt, _this.options, newElem, fallback);
  20834. }, 10);
  20835. lastAutoScrollX = x;
  20836. lastAutoScrollY = y;
  20837. }
  20838. } else {
  20839. // if DnD is enabled (and browser has good autoscrolling), first autoscroll will already scroll, so get parent autoscroll of first autoscroll
  20840. if (!this.options.bubbleScroll || getParentAutoScrollElement(elem, true) === getWindowScrollingElement()) {
  20841. clearAutoScrolls();
  20842. return;
  20843. }
  20844. autoScroll(evt, this.options, getParentAutoScrollElement(elem, false), false);
  20845. }
  20846. }
  20847. };
  20848. return _extends(AutoScroll, {
  20849. pluginName: 'scroll',
  20850. initializeByDefault: true
  20851. });
  20852. }
  20853. function clearAutoScrolls() {
  20854. autoScrolls.forEach(function (autoScroll) {
  20855. clearInterval(autoScroll.pid);
  20856. });
  20857. autoScrolls = [];
  20858. }
  20859. function clearPointerElemChangedInterval() {
  20860. clearInterval(pointerElemChangedInterval);
  20861. }
  20862. var autoScroll = throttle(function (evt, options, rootEl, isFallback) {
  20863. // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521
  20864. if (!options.scroll) return;
  20865. var x = (evt.touches ? evt.touches[0] : evt).clientX,
  20866. y = (evt.touches ? evt.touches[0] : evt).clientY,
  20867. sens = options.scrollSensitivity,
  20868. speed = options.scrollSpeed,
  20869. winScroller = getWindowScrollingElement();
  20870. var scrollThisInstance = false,
  20871. scrollCustomFn; // New scroll root, set scrollEl
  20872. if (scrollRootEl !== rootEl) {
  20873. scrollRootEl = rootEl;
  20874. clearAutoScrolls();
  20875. scrollEl = options.scroll;
  20876. scrollCustomFn = options.scrollFn;
  20877. if (scrollEl === true) {
  20878. scrollEl = getParentAutoScrollElement(rootEl, true);
  20879. }
  20880. }
  20881. var layersOut = 0;
  20882. var currentParent = scrollEl;
  20883. do {
  20884. var el = currentParent,
  20885. rect = getRect(el),
  20886. top = rect.top,
  20887. bottom = rect.bottom,
  20888. left = rect.left,
  20889. right = rect.right,
  20890. width = rect.width,
  20891. height = rect.height,
  20892. canScrollX = void 0,
  20893. canScrollY = void 0,
  20894. scrollWidth = el.scrollWidth,
  20895. scrollHeight = el.scrollHeight,
  20896. elCSS = css(el),
  20897. scrollPosX = el.scrollLeft,
  20898. scrollPosY = el.scrollTop;
  20899. if (el === winScroller) {
  20900. canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll' || elCSS.overflowX === 'visible');
  20901. canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll' || elCSS.overflowY === 'visible');
  20902. } else {
  20903. canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll');
  20904. canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll');
  20905. }
  20906. var vx = canScrollX && (Math.abs(right - x) <= sens && scrollPosX + width < scrollWidth) - (Math.abs(left - x) <= sens && !!scrollPosX);
  20907. var vy = canScrollY && (Math.abs(bottom - y) <= sens && scrollPosY + height < scrollHeight) - (Math.abs(top - y) <= sens && !!scrollPosY);
  20908. if (!autoScrolls[layersOut]) {
  20909. for (var i = 0; i <= layersOut; i++) {
  20910. if (!autoScrolls[i]) {
  20911. autoScrolls[i] = {};
  20912. }
  20913. }
  20914. }
  20915. if (autoScrolls[layersOut].vx != vx || autoScrolls[layersOut].vy != vy || autoScrolls[layersOut].el !== el) {
  20916. autoScrolls[layersOut].el = el;
  20917. autoScrolls[layersOut].vx = vx;
  20918. autoScrolls[layersOut].vy = vy;
  20919. clearInterval(autoScrolls[layersOut].pid);
  20920. if (vx != 0 || vy != 0) {
  20921. scrollThisInstance = true;
  20922. /* jshint loopfunc:true */
  20923. autoScrolls[layersOut].pid = setInterval(function () {
  20924. // emulate drag over during autoscroll (fallback), emulating native DnD behaviour
  20925. if (isFallback && this.layer === 0) {
  20926. Sortable.active._onTouchMove(touchEvt$1); // To move ghost if it is positioned absolutely
  20927. }
  20928. var scrollOffsetY = autoScrolls[this.layer].vy ? autoScrolls[this.layer].vy * speed : 0;
  20929. var scrollOffsetX = autoScrolls[this.layer].vx ? autoScrolls[this.layer].vx * speed : 0;
  20930. if (typeof scrollCustomFn === 'function') {
  20931. if (scrollCustomFn.call(Sortable.dragged.parentNode[expando], scrollOffsetX, scrollOffsetY, evt, touchEvt$1, autoScrolls[this.layer].el) !== 'continue') {
  20932. return;
  20933. }
  20934. }
  20935. scrollBy(autoScrolls[this.layer].el, scrollOffsetX, scrollOffsetY);
  20936. }.bind({
  20937. layer: layersOut
  20938. }), 24);
  20939. }
  20940. }
  20941. layersOut++;
  20942. } while (options.bubbleScroll && currentParent !== winScroller && (currentParent = getParentAutoScrollElement(currentParent, false)));
  20943. scrolling = scrollThisInstance; // in case another function catches scrolling as false in between when it is not
  20944. }, 30);
  20945. var drop = function drop(_ref) {
  20946. var originalEvent = _ref.originalEvent,
  20947. putSortable = _ref.putSortable,
  20948. dragEl = _ref.dragEl,
  20949. activeSortable = _ref.activeSortable,
  20950. dispatchSortableEvent = _ref.dispatchSortableEvent,
  20951. hideGhostForTarget = _ref.hideGhostForTarget,
  20952. unhideGhostForTarget = _ref.unhideGhostForTarget;
  20953. if (!originalEvent) return;
  20954. var toSortable = putSortable || activeSortable;
  20955. hideGhostForTarget();
  20956. var touch = originalEvent.changedTouches && originalEvent.changedTouches.length ? originalEvent.changedTouches[0] : originalEvent;
  20957. var target = document.elementFromPoint(touch.clientX, touch.clientY);
  20958. unhideGhostForTarget();
  20959. if (toSortable && !toSortable.el.contains(target)) {
  20960. dispatchSortableEvent('spill');
  20961. this.onSpill({
  20962. dragEl: dragEl,
  20963. putSortable: putSortable
  20964. });
  20965. }
  20966. };
  20967. function Revert() {}
  20968. Revert.prototype = {
  20969. startIndex: null,
  20970. dragStart: function dragStart(_ref2) {
  20971. var oldDraggableIndex = _ref2.oldDraggableIndex;
  20972. this.startIndex = oldDraggableIndex;
  20973. },
  20974. onSpill: function onSpill(_ref3) {
  20975. var dragEl = _ref3.dragEl,
  20976. putSortable = _ref3.putSortable;
  20977. this.sortable.captureAnimationState();
  20978. if (putSortable) {
  20979. putSortable.captureAnimationState();
  20980. }
  20981. var nextSibling = getChild(this.sortable.el, this.startIndex, this.options);
  20982. if (nextSibling) {
  20983. this.sortable.el.insertBefore(dragEl, nextSibling);
  20984. } else {
  20985. this.sortable.el.appendChild(dragEl);
  20986. }
  20987. this.sortable.animateAll();
  20988. if (putSortable) {
  20989. putSortable.animateAll();
  20990. }
  20991. },
  20992. drop: drop
  20993. };
  20994. _extends(Revert, {
  20995. pluginName: 'revertOnSpill'
  20996. });
  20997. function Remove() {}
  20998. Remove.prototype = {
  20999. onSpill: function onSpill(_ref4) {
  21000. var dragEl = _ref4.dragEl,
  21001. putSortable = _ref4.putSortable;
  21002. var parentSortable = putSortable || this.sortable;
  21003. parentSortable.captureAnimationState();
  21004. dragEl.parentNode && dragEl.parentNode.removeChild(dragEl);
  21005. parentSortable.animateAll();
  21006. },
  21007. drop: drop
  21008. };
  21009. _extends(Remove, {
  21010. pluginName: 'removeOnSpill'
  21011. });
  21012. Sortable.mount(new AutoScrollPlugin());
  21013. Sortable.mount(Remove, Revert);
  21014. const CSS$8 = {
  21015. sortItem: "sort-item",
  21016. container: "container",
  21017. containerHorizontal: "container--horizontal",
  21018. containerVertical: "container--vertical"
  21019. };
  21020. 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}";
  21021. const SortableList = class extends HTMLElement$1 {
  21022. constructor() {
  21023. super();
  21024. this.__registerHost();
  21025. this.__attachShadow();
  21026. this.calciteListOrderChange = createEvent(this, "calciteListOrderChange", 7);
  21027. /**
  21028. * The selector for the handle elements.
  21029. */
  21030. this.handleSelector = "calcite-handle";
  21031. /**
  21032. * Indicates the horizontal or vertical orientation of the component.
  21033. */
  21034. this.layout = "vertical";
  21035. /**
  21036. * When true, disabled prevents interaction. This state shows items with lower opacity/grayed.
  21037. */
  21038. this.disabled = false;
  21039. /**
  21040. * When true, content is waiting to be loaded. This state shows a busy indicator.
  21041. */
  21042. this.loading = false;
  21043. this.handleActivated = false;
  21044. this.items = [];
  21045. this.mutationObserver = createObserver("mutation", () => {
  21046. this.cleanUpDragAndDrop();
  21047. this.items = Array.from(this.el.children);
  21048. this.setUpDragAndDrop();
  21049. });
  21050. }
  21051. // --------------------------------------------------------------------------
  21052. //
  21053. // Lifecycle
  21054. //
  21055. // --------------------------------------------------------------------------
  21056. connectedCallback() {
  21057. this.items = Array.from(this.el.children);
  21058. this.setUpDragAndDrop();
  21059. this.beginObserving();
  21060. }
  21061. disconnectedCallback() {
  21062. var _a;
  21063. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  21064. this.cleanUpDragAndDrop();
  21065. }
  21066. componentDidRender() {
  21067. updateHostInteraction(this);
  21068. }
  21069. calciteHandleNudgeHandler(event) {
  21070. var _a;
  21071. const sortItem = this.items.find((item) => {
  21072. return item.contains(event.detail.handle) || event.composedPath().includes(item);
  21073. });
  21074. const lastIndex = this.items.length - 1;
  21075. const startingIndex = this.items.indexOf(sortItem);
  21076. let appendInstead = false;
  21077. let buddyIndex;
  21078. switch (event.detail.direction) {
  21079. case "up":
  21080. event.preventDefault();
  21081. if (startingIndex === 0) {
  21082. appendInstead = true;
  21083. }
  21084. else {
  21085. buddyIndex = startingIndex - 1;
  21086. }
  21087. break;
  21088. case "down":
  21089. event.preventDefault();
  21090. if (startingIndex === lastIndex) {
  21091. buddyIndex = 0;
  21092. }
  21093. else if (startingIndex === lastIndex - 1) {
  21094. appendInstead = true;
  21095. }
  21096. else {
  21097. buddyIndex = startingIndex + 2;
  21098. }
  21099. break;
  21100. default:
  21101. return;
  21102. }
  21103. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  21104. if (appendInstead) {
  21105. sortItem.parentElement.appendChild(sortItem);
  21106. }
  21107. else {
  21108. sortItem.parentElement.insertBefore(sortItem, this.items[buddyIndex]);
  21109. }
  21110. this.items = Array.from(this.el.children);
  21111. event.detail.handle.activated = true;
  21112. event.detail.handle.setFocus();
  21113. this.beginObserving();
  21114. }
  21115. // --------------------------------------------------------------------------
  21116. //
  21117. // Private Methods
  21118. //
  21119. // --------------------------------------------------------------------------
  21120. setUpDragAndDrop() {
  21121. this.cleanUpDragAndDrop();
  21122. const options = {
  21123. dataIdAttr: "id",
  21124. group: this.group,
  21125. handle: this.handleSelector,
  21126. // Changed sorting within list
  21127. onUpdate: () => {
  21128. this.items = Array.from(this.el.children);
  21129. this.calciteListOrderChange.emit();
  21130. },
  21131. // Element dragging started
  21132. onStart: () => {
  21133. var _a;
  21134. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  21135. },
  21136. // Element dragging ended
  21137. onEnd: () => {
  21138. this.beginObserving();
  21139. }
  21140. };
  21141. if (this.dragSelector) {
  21142. options.draggable = this.dragSelector;
  21143. }
  21144. this.sortable = Sortable.create(this.el, options);
  21145. }
  21146. cleanUpDragAndDrop() {
  21147. var _a;
  21148. (_a = this.sortable) === null || _a === void 0 ? void 0 : _a.destroy();
  21149. this.sortable = null;
  21150. }
  21151. beginObserving() {
  21152. var _a;
  21153. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
  21154. }
  21155. // --------------------------------------------------------------------------
  21156. //
  21157. // Render Methods
  21158. //
  21159. // --------------------------------------------------------------------------
  21160. render() {
  21161. const { layout } = this;
  21162. const horizontal = layout === "horizontal" || false;
  21163. return (h("div", { class: {
  21164. [CSS$8.container]: true,
  21165. [CSS$8.containerVertical]: !horizontal,
  21166. [CSS$8.containerHorizontal]: horizontal
  21167. } }, h("slot", null)));
  21168. }
  21169. get el() { return this; }
  21170. static get style() { return sortableListCss; }
  21171. };
  21172. const CSS$7 = {
  21173. container: "split-button__container",
  21174. dividerContainer: "split-button__divider-container",
  21175. divider: "split-button__divider",
  21176. widthAuto: "width-auto",
  21177. widthHalf: "width-half",
  21178. widthFull: "width-full"
  21179. };
  21180. 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}";
  21181. const SplitButton = class extends HTMLElement$1 {
  21182. constructor() {
  21183. super();
  21184. this.__registerHost();
  21185. this.__attachShadow();
  21186. this.calciteSplitButtonPrimaryClick = createEvent(this, "calciteSplitButtonPrimaryClick", 7);
  21187. this.calciteSplitButtonSecondaryClick = createEvent(this, "calciteSplitButtonSecondaryClick", 7);
  21188. /** specify the appearance style of the button, defaults to solid. */
  21189. this.appearance = "solid";
  21190. /** specify the color of the control, defaults to blue */
  21191. this.color = "blue";
  21192. /** is the control disabled */
  21193. this.disabled = false;
  21194. /**
  21195. * Is the dropdown currently active or not
  21196. * @internal
  21197. */
  21198. this.active = false;
  21199. /** specify the icon used for the dropdown menu, defaults to chevron */
  21200. this.dropdownIconType = "chevron";
  21201. /** optionally add a calcite-loader component to the control,
  21202. disabling interaction. with the primary button */
  21203. this.loading = false;
  21204. /** Describes the type of positioning to use for the dropdown. If your element is in a fixed container, use the 'fixed' value. */
  21205. this.overlayPositioning = "absolute";
  21206. /** specify the scale of the control, defaults to m */
  21207. this.scale = "m";
  21208. /** specify the width of the button, defaults to auto */
  21209. this.width = "auto";
  21210. this.calciteSplitButtonPrimaryClickHandler = (e) => this.calciteSplitButtonPrimaryClick.emit(e);
  21211. this.calciteSplitButtonSecondaryClickHandler = (e) => this.calciteSplitButtonSecondaryClick.emit(e);
  21212. }
  21213. handleDisabledChange(value) {
  21214. if (!value) {
  21215. this.active = false;
  21216. }
  21217. }
  21218. activeHandler() {
  21219. if (this.disabled) {
  21220. this.active = false;
  21221. }
  21222. }
  21223. //--------------------------------------------------------------------------
  21224. //
  21225. // Lifecycle
  21226. //
  21227. //--------------------------------------------------------------------------
  21228. componentDidRender() {
  21229. updateHostInteraction(this);
  21230. }
  21231. render() {
  21232. const widthClasses = {
  21233. [CSS$7.container]: true,
  21234. [CSS$7.widthAuto]: this.width === "auto",
  21235. [CSS$7.widthHalf]: this.width === "half",
  21236. [CSS$7.widthFull]: this.width === "full"
  21237. };
  21238. const buttonWidth = this.width === "auto" ? "auto" : "full";
  21239. 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))));
  21240. }
  21241. get dropdownIcon() {
  21242. return this.dropdownIconType === "chevron"
  21243. ? "chevronDown"
  21244. : this.dropdownIconType === "caret"
  21245. ? "caretDown"
  21246. : this.dropdownIconType === "ellipsis"
  21247. ? "ellipsis"
  21248. : "handle-vertical";
  21249. }
  21250. get el() { return this; }
  21251. static get watchers() { return {
  21252. "disabled": ["handleDisabledChange"],
  21253. "active": ["activeHandler"]
  21254. }; }
  21255. static get style() { return splitButtonCss; }
  21256. };
  21257. 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}";
  21258. const Stepper = class extends HTMLElement$1 {
  21259. constructor() {
  21260. super();
  21261. this.__registerHost();
  21262. this.__attachShadow();
  21263. this.calciteStepperItemChange = createEvent(this, "calciteStepperItemChange", 7);
  21264. //--------------------------------------------------------------------------
  21265. //
  21266. // Public Properties
  21267. //
  21268. //--------------------------------------------------------------------------
  21269. /** optionally display a status icon next to the step title */
  21270. this.icon = false;
  21271. /** specify the layout of stepper, defaults to horizontal */
  21272. this.layout = "horizontal";
  21273. /** optionally display the number next to the step title */
  21274. this.numbered = false;
  21275. /** specify the scale of stepper, defaults to m */
  21276. this.scale = "m";
  21277. //--------------------------------------------------------------------------
  21278. //
  21279. // Private State/Props
  21280. //
  21281. //--------------------------------------------------------------------------
  21282. this.itemMap = new Map();
  21283. /** list of sorted Stepper items */
  21284. this.items = [];
  21285. /** list of enabled Stepper items */
  21286. this.enabledItems = [];
  21287. }
  21288. // watch for removal of disabled to register step
  21289. contentWatcher() {
  21290. if (this.layout === "horizontal") {
  21291. if (!this.stepperContentContainer && this.requestedContent) {
  21292. this.addHorizontalContentContainer();
  21293. }
  21294. this.updateContent(this.requestedContent);
  21295. }
  21296. }
  21297. //--------------------------------------------------------------------------
  21298. //
  21299. // Lifecycle
  21300. //
  21301. //--------------------------------------------------------------------------
  21302. componentDidLoad() {
  21303. // if no stepper items are set as active, default to the first one
  21304. if (!this.currentPosition) {
  21305. this.calciteStepperItemChange.emit({
  21306. position: 0
  21307. });
  21308. }
  21309. }
  21310. componentWillLoad() {
  21311. if (this.layout === "horizontal" && !this.stepperContentContainer) {
  21312. this.addHorizontalContentContainer();
  21313. }
  21314. }
  21315. render() {
  21316. return h("slot", null);
  21317. }
  21318. //--------------------------------------------------------------------------
  21319. //
  21320. // Event Listeners
  21321. //
  21322. //--------------------------------------------------------------------------
  21323. calciteStepperItemKeyEvent(e) {
  21324. const item = e.detail.item;
  21325. const itemToFocus = e.target;
  21326. const isFirstItem = this.itemIndex(itemToFocus) === 0;
  21327. const isLastItem = this.itemIndex(itemToFocus) === this.enabledItems.length - 1;
  21328. switch (item.key) {
  21329. case "ArrowDown":
  21330. case "ArrowRight":
  21331. if (isLastItem) {
  21332. this.focusFirstItem();
  21333. }
  21334. else {
  21335. this.focusNextItem(itemToFocus);
  21336. }
  21337. break;
  21338. case "ArrowUp":
  21339. case "ArrowLeft":
  21340. if (isFirstItem) {
  21341. this.focusLastItem();
  21342. }
  21343. else {
  21344. this.focusPrevItem(itemToFocus);
  21345. }
  21346. break;
  21347. case "Home":
  21348. this.focusFirstItem();
  21349. break;
  21350. case "End":
  21351. this.focusLastItem();
  21352. break;
  21353. }
  21354. }
  21355. registerItem(event) {
  21356. const item = event.target;
  21357. const { content, position } = event.detail;
  21358. if (content && item.active) {
  21359. this.requestedContent = content;
  21360. }
  21361. this.itemMap.set(item, position);
  21362. this.items = this.sortItems();
  21363. this.enabledItems = this.filterItems();
  21364. }
  21365. updateItem(event) {
  21366. if (event.detail.content) {
  21367. this.requestedContent = event.detail.content;
  21368. }
  21369. this.currentPosition = event.detail.position;
  21370. this.calciteStepperItemChange.emit({
  21371. position: this.currentPosition
  21372. });
  21373. }
  21374. //--------------------------------------------------------------------------
  21375. //
  21376. // Public Methods
  21377. //
  21378. //--------------------------------------------------------------------------
  21379. /** set the next step as active */
  21380. async nextStep() {
  21381. const enabledStepIndex = this.getEnabledStepIndex(this.currentPosition + 1, "next");
  21382. if (typeof enabledStepIndex !== "number") {
  21383. return;
  21384. }
  21385. this.emitChangedItem(enabledStepIndex);
  21386. }
  21387. /** set the previous step as active */
  21388. async prevStep() {
  21389. const enabledStepIndex = this.getEnabledStepIndex(this.currentPosition - 1, "previous");
  21390. if (typeof enabledStepIndex !== "number") {
  21391. return;
  21392. }
  21393. this.emitChangedItem(enabledStepIndex);
  21394. }
  21395. /** set the requested step as active */
  21396. async goToStep(step) {
  21397. const position = step - 1;
  21398. if (this.currentPosition !== position) {
  21399. this.emitChangedItem(position);
  21400. }
  21401. }
  21402. /** set the first step as active */
  21403. async startStep() {
  21404. const enabledStepIndex = this.getEnabledStepIndex(0, "next");
  21405. if (typeof enabledStepIndex !== "number") {
  21406. return;
  21407. }
  21408. this.emitChangedItem(enabledStepIndex);
  21409. }
  21410. /** set the last step as active */
  21411. async endStep() {
  21412. const enabledStepIndex = this.getEnabledStepIndex(this.items.length - 1, "previous");
  21413. if (typeof enabledStepIndex !== "number") {
  21414. return;
  21415. }
  21416. this.emitChangedItem(enabledStepIndex);
  21417. }
  21418. //--------------------------------------------------------------------------
  21419. //
  21420. // Private Methods
  21421. //
  21422. //--------------------------------------------------------------------------
  21423. getEnabledStepIndex(startIndex, direction = "next") {
  21424. var _a;
  21425. const { items, currentPosition } = this;
  21426. let newIndex = startIndex;
  21427. while ((_a = items[newIndex]) === null || _a === void 0 ? void 0 : _a.disabled) {
  21428. newIndex = newIndex + (direction === "previous" ? -1 : 1);
  21429. }
  21430. return newIndex !== currentPosition && newIndex < items.length && newIndex >= 0
  21431. ? newIndex
  21432. : null;
  21433. }
  21434. addHorizontalContentContainer() {
  21435. this.stepperContentContainer = document.createElement("div");
  21436. this.stepperContentContainer.classList.add("calcite-stepper-content");
  21437. this.el.insertAdjacentElement("beforeend", this.stepperContentContainer);
  21438. }
  21439. emitChangedItem(position) {
  21440. this.currentPosition = position;
  21441. this.calciteStepperItemChange.emit({
  21442. position
  21443. });
  21444. }
  21445. focusFirstItem() {
  21446. const firstItem = this.enabledItems[0];
  21447. this.focusElement(firstItem);
  21448. }
  21449. focusLastItem() {
  21450. const lastItem = this.enabledItems[this.enabledItems.length - 1];
  21451. this.focusElement(lastItem);
  21452. }
  21453. focusNextItem(e) {
  21454. const index = this.itemIndex(e);
  21455. const nextItem = this.enabledItems[index + 1] || this.enabledItems[0];
  21456. this.focusElement(nextItem);
  21457. }
  21458. focusPrevItem(e) {
  21459. const index = this.itemIndex(e);
  21460. const prevItem = this.enabledItems[index - 1] || this.enabledItems[this.enabledItems.length - 1];
  21461. this.focusElement(prevItem);
  21462. }
  21463. itemIndex(e) {
  21464. return this.enabledItems.indexOf(e);
  21465. }
  21466. focusElement(item) {
  21467. item.focus();
  21468. }
  21469. sortItems() {
  21470. const { itemMap } = this;
  21471. return Array.from(itemMap.keys()).sort((a, b) => itemMap.get(a) - itemMap.get(b));
  21472. }
  21473. filterItems() {
  21474. return this.items.filter((item) => !item.disabled);
  21475. }
  21476. updateContent(content) {
  21477. this.stepperContentContainer.innerHTML = "";
  21478. this.stepperContentContainer.append(...content);
  21479. }
  21480. get el() { return this; }
  21481. static get watchers() { return {
  21482. "requestedContent": ["contentWatcher"]
  21483. }; }
  21484. static get style() { return stepperCss; }
  21485. };
  21486. 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)}";
  21487. const StepperItem = class extends HTMLElement$1 {
  21488. constructor() {
  21489. super();
  21490. this.__registerHost();
  21491. this.__attachShadow();
  21492. this.calciteStepperItemKeyEvent = createEvent(this, "calciteStepperItemKeyEvent", 7);
  21493. this.calciteStepperItemSelect = createEvent(this, "calciteStepperItemSelect", 7);
  21494. this.calciteStepperItemRegister = createEvent(this, "calciteStepperItemRegister", 7);
  21495. //--------------------------------------------------------------------------
  21496. //
  21497. // Public Properties
  21498. //
  21499. //--------------------------------------------------------------------------
  21500. /** is the step active */
  21501. this.active = false;
  21502. /** has the step been completed */
  21503. this.complete = false;
  21504. /** does the step contain an error that needs to be resolved by the user */
  21505. this.error = false;
  21506. /** is the step disabled and not navigable to by a user */
  21507. this.disabled = false;
  21508. /** should the items display an icon based on status */
  21509. /** @internal */
  21510. this.icon = false;
  21511. /** optionally display the step number next to the title and subtitle */
  21512. /** @internal */
  21513. this.numbered = false;
  21514. /** the scale of the item */
  21515. /** @internal */
  21516. this.scale = "m";
  21517. //--------------------------------------------------------------------------
  21518. //
  21519. // Private Methods
  21520. //
  21521. //--------------------------------------------------------------------------
  21522. this.keyDownHandler = (e) => {
  21523. if (!this.disabled && e.target === this.el) {
  21524. switch (e.key) {
  21525. case " ":
  21526. case "Enter":
  21527. this.emitRequestedItem();
  21528. e.preventDefault();
  21529. break;
  21530. case "ArrowUp":
  21531. case "ArrowDown":
  21532. case "ArrowLeft":
  21533. case "ArrowRight":
  21534. case "Home":
  21535. case "End":
  21536. this.calciteStepperItemKeyEvent.emit({ item: e });
  21537. e.preventDefault();
  21538. break;
  21539. }
  21540. }
  21541. };
  21542. this.emitRequestedItem = () => {
  21543. if (!this.disabled) {
  21544. this.calciteStepperItemSelect.emit({
  21545. position: this.itemPosition,
  21546. content: this.itemContent
  21547. });
  21548. }
  21549. };
  21550. this.setItemContent = (event) => {
  21551. this.itemPosition = this.getItemPosition();
  21552. const itemContent = event.target.assignedNodes({ flatten: true });
  21553. if (itemContent.length) {
  21554. this.itemContent = itemContent;
  21555. }
  21556. this.registerStepperItem();
  21557. if (this.active) {
  21558. this.emitRequestedItem();
  21559. }
  21560. };
  21561. }
  21562. // watch for removal of disabled to register step
  21563. disabledWatcher() {
  21564. this.registerStepperItem();
  21565. }
  21566. //--------------------------------------------------------------------------
  21567. //
  21568. // Lifecycle
  21569. //
  21570. //--------------------------------------------------------------------------
  21571. componentWillLoad() {
  21572. this.icon = getElementProp(this.el, "icon", false);
  21573. this.numbered = getElementProp(this.el, "numbered", false);
  21574. this.layout = getElementProp(this.el, "layout", false);
  21575. this.scale = getElementProp(this.el, "scale", "m");
  21576. this.parentStepperEl = this.el.parentElement;
  21577. }
  21578. componentDidRender() {
  21579. updateHostInteraction(this, true);
  21580. }
  21581. render() {
  21582. 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 })))));
  21583. }
  21584. //--------------------------------------------------------------------------
  21585. //
  21586. // Event Listeners
  21587. //
  21588. //--------------------------------------------------------------------------
  21589. updateActiveItemOnChange(event) {
  21590. if (event.target === this.parentStepperEl ||
  21591. event.composedPath().includes(this.parentStepperEl)) {
  21592. this.activePosition = event.detail.position;
  21593. this.determineActiveItem();
  21594. }
  21595. }
  21596. renderIcon() {
  21597. const path = this.active
  21598. ? "circleF"
  21599. : this.error
  21600. ? "exclamationMarkCircleF"
  21601. : this.complete
  21602. ? "checkCircleF"
  21603. : "circle";
  21604. return h("calcite-icon", { class: "stepper-item-icon", icon: path, scale: "s" });
  21605. }
  21606. determineActiveItem() {
  21607. this.active = !this.disabled && this.itemPosition === this.activePosition;
  21608. }
  21609. registerStepperItem() {
  21610. this.calciteStepperItemRegister.emit({
  21611. position: this.itemPosition,
  21612. content: this.itemContent
  21613. });
  21614. }
  21615. getItemPosition() {
  21616. return Array.prototype.indexOf.call(this.parentStepperEl.querySelectorAll("calcite-stepper-item"), this.el);
  21617. }
  21618. get el() { return this; }
  21619. static get watchers() { return {
  21620. "disabled": ["disabledWatcher"]
  21621. }; }
  21622. static get style() { return stepperItemCss; }
  21623. };
  21624. 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}";
  21625. const Switch = class extends HTMLElement$1 {
  21626. constructor() {
  21627. super();
  21628. this.__registerHost();
  21629. this.__attachShadow();
  21630. this.calciteSwitchChange = createEvent(this, "calciteSwitchChange", 7);
  21631. //--------------------------------------------------------------------------
  21632. //
  21633. // Properties
  21634. //
  21635. //--------------------------------------------------------------------------
  21636. /** True if the switch is disabled */
  21637. this.disabled = false;
  21638. /** The scale of the switch */
  21639. this.scale = "m";
  21640. /** True if the switch is initially on
  21641. * @deprecated use 'checked' instead.
  21642. */
  21643. this.switched = false;
  21644. /** True if the switch is initially on */
  21645. this.checked = false;
  21646. //--------------------------------------------------------------------------
  21647. //
  21648. // Private Methods
  21649. //
  21650. //--------------------------------------------------------------------------
  21651. this.keyDownHandler = (e) => {
  21652. const key = e.key;
  21653. if (!this.disabled && (key === " " || key === "Enter")) {
  21654. this.toggle();
  21655. e.preventDefault();
  21656. }
  21657. };
  21658. this.clickHandler = () => {
  21659. this.toggle();
  21660. };
  21661. this.setSwitchEl = (el) => {
  21662. this.switchEl = el;
  21663. };
  21664. }
  21665. switchedWatcher(switched) {
  21666. this.checked = switched;
  21667. }
  21668. //--------------------------------------------------------------------------
  21669. //
  21670. // Public Methods
  21671. //
  21672. //--------------------------------------------------------------------------
  21673. /** Sets focus on the component. */
  21674. async setFocus() {
  21675. focusElement(this.switchEl);
  21676. }
  21677. onLabelClick() {
  21678. if (!this.disabled) {
  21679. this.toggle();
  21680. this.setFocus();
  21681. }
  21682. }
  21683. toggle() {
  21684. this.checked = !this.checked;
  21685. this.calciteSwitchChange.emit({
  21686. // todo: We should remove emmitting redudant props in event payload.
  21687. // https://github.com/Esri/calcite-components/issues/3163
  21688. switched: this.checked
  21689. });
  21690. }
  21691. //--------------------------------------------------------------------------
  21692. //
  21693. // Lifecycle
  21694. //
  21695. //--------------------------------------------------------------------------
  21696. connectedCallback() {
  21697. const initiallyChecked = this.checked || this.switched;
  21698. if (initiallyChecked) {
  21699. // if either prop is set, we ensure both are synced initially
  21700. this.switched = this.checked = initiallyChecked;
  21701. }
  21702. connectLabel(this);
  21703. connectForm(this);
  21704. }
  21705. disconnectedCallback() {
  21706. disconnectLabel(this);
  21707. disconnectForm(this);
  21708. }
  21709. componentDidRender() {
  21710. updateHostInteraction(this);
  21711. }
  21712. // --------------------------------------------------------------------------
  21713. //
  21714. // Render Methods
  21715. //
  21716. // --------------------------------------------------------------------------
  21717. render() {
  21718. 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 }))));
  21719. }
  21720. get el() { return this; }
  21721. static get watchers() { return {
  21722. "switched": ["switchedWatcher"]
  21723. }; }
  21724. static get style() { return switchCss; }
  21725. };
  21726. 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}";
  21727. const Tab = class extends HTMLElement$1 {
  21728. constructor() {
  21729. super();
  21730. this.__registerHost();
  21731. this.__attachShadow();
  21732. this.calciteTabRegister = createEvent(this, "calciteTabRegister", 7);
  21733. /**
  21734. * Show this tab
  21735. */
  21736. this.active = false;
  21737. /** @internal Parent tabs component scale value */
  21738. this.scale = "m";
  21739. this.guid = `calcite-tab-title-${guid()}`;
  21740. }
  21741. //--------------------------------------------------------------------------
  21742. //
  21743. // Lifecycle
  21744. //
  21745. //--------------------------------------------------------------------------
  21746. render() {
  21747. const id = this.el.id || this.guid;
  21748. return (h(Host, { "aria-expanded": toAriaBoolean(this.active), "aria-labelledby": this.labeledBy, id: id, role: "tabpanel" }, h("section", null, h("slot", null))));
  21749. }
  21750. connectedCallback() {
  21751. this.parentTabsEl = this.el.closest("calcite-tabs");
  21752. }
  21753. componentDidLoad() {
  21754. this.calciteTabRegister.emit();
  21755. }
  21756. componentWillRender() {
  21757. var _a;
  21758. this.scale = (_a = this.parentTabsEl) === null || _a === void 0 ? void 0 : _a.scale;
  21759. }
  21760. disconnectedCallback() {
  21761. var _a;
  21762. // Dispatching to body in order to be listened by other elements that are still connected to the DOM.
  21763. (_a = document.body) === null || _a === void 0 ? void 0 : _a.dispatchEvent(new CustomEvent("calciteTabUnregister", {
  21764. detail: this.el
  21765. }));
  21766. }
  21767. //--------------------------------------------------------------------------
  21768. //
  21769. // Event Listeners
  21770. //
  21771. //--------------------------------------------------------------------------
  21772. internalTabChangeHandler(event) {
  21773. const targetTabsEl = event
  21774. .composedPath()
  21775. .find((el) => el.tagName === "CALCITE-TABS");
  21776. // to allow `<calcite-tabs>` to be nested we need to make sure this
  21777. // `calciteTabChange` event was actually fired from a within the same
  21778. // `<calcite-tabs>` that is the a parent of this tab.
  21779. if (targetTabsEl !== this.parentTabsEl) {
  21780. return;
  21781. }
  21782. if (this.tab) {
  21783. this.active = this.tab === event.detail.tab;
  21784. }
  21785. else {
  21786. this.getTabIndex().then((index) => {
  21787. this.active = index === event.detail.tab;
  21788. });
  21789. }
  21790. }
  21791. //--------------------------------------------------------------------------
  21792. //
  21793. // Public Methods
  21794. //
  21795. //--------------------------------------------------------------------------
  21796. /**
  21797. * Return the index of this tab within the tab array
  21798. */
  21799. async getTabIndex() {
  21800. return Array.prototype.indexOf.call(nodeListToArray(this.el.parentElement.children).filter((e) => e.matches("calcite-tab")), this.el);
  21801. }
  21802. //--------------------------------------------------------------------------
  21803. //
  21804. // Private Methods
  21805. //
  21806. //--------------------------------------------------------------------------
  21807. /**
  21808. * @internal
  21809. */
  21810. async updateAriaInfo(tabIds = [], titleIds = []) {
  21811. this.labeledBy = titleIds[tabIds.indexOf(this.el.id)] || null;
  21812. }
  21813. get el() { return this; }
  21814. static get style() { return tabCss; }
  21815. };
  21816. 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}";
  21817. const TabNav = class extends HTMLElement$1 {
  21818. constructor() {
  21819. super();
  21820. this.__registerHost();
  21821. this.__attachShadow();
  21822. this.calciteTabChange = createEvent(this, "calciteTabChange", 7);
  21823. this.calciteInternalTabChange = createEvent(this, "calciteInternalTabChange", 7);
  21824. /** @internal Parent tabs component scale value */
  21825. this.scale = "m";
  21826. /** @internal Parent tabs component layout value */
  21827. this.layout = "inline";
  21828. /** @internal Parent tabs component position value */
  21829. this.position = "below";
  21830. /** @internal Parent tabs component bordered value when layout is "inline" */
  21831. this.bordered = false;
  21832. this.animationActiveDuration = 0.3;
  21833. this.resizeObserver = createObserver("resize", () => {
  21834. // remove active indicator transition duration during resize to prevent wobble
  21835. this.activeIndicatorEl.style.transitionDuration = "0s";
  21836. this.updateActiveWidth();
  21837. this.updateOffsetPosition();
  21838. });
  21839. //--------------------------------------------------------------------------
  21840. //
  21841. // Private Methods
  21842. //
  21843. //--------------------------------------------------------------------------
  21844. this.handleContainerScroll = () => {
  21845. // remove active indicator transition duration while container is scrolling to prevent wobble
  21846. this.activeIndicatorEl.style.transitionDuration = "0s";
  21847. this.updateOffsetPosition();
  21848. };
  21849. }
  21850. async selectedTabChanged() {
  21851. if (localStorage &&
  21852. this.storageId &&
  21853. this.selectedTab !== undefined &&
  21854. this.selectedTab !== null) {
  21855. localStorage.setItem(`calcite-tab-nav-${this.storageId}`, JSON.stringify(this.selectedTab));
  21856. }
  21857. this.calciteInternalTabChange.emit({
  21858. tab: this.selectedTab
  21859. });
  21860. this.selectedTabEl = await this.getTabTitleById(this.selectedTab);
  21861. }
  21862. selectedTabElChanged() {
  21863. this.updateOffsetPosition();
  21864. this.updateActiveWidth();
  21865. // reset the animation time on tab selection
  21866. this.activeIndicatorEl.style.transitionDuration = `${this.animationActiveDuration}s`;
  21867. }
  21868. //--------------------------------------------------------------------------
  21869. //
  21870. // Lifecycle
  21871. //
  21872. //--------------------------------------------------------------------------
  21873. connectedCallback() {
  21874. var _a;
  21875. this.parentTabsEl = this.el.closest("calcite-tabs");
  21876. (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el);
  21877. }
  21878. disconnectedCallback() {
  21879. var _a;
  21880. (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  21881. }
  21882. componentWillLoad() {
  21883. const storageKey = `calcite-tab-nav-${this.storageId}`;
  21884. if (localStorage && this.storageId && localStorage.getItem(storageKey)) {
  21885. const storedTab = JSON.parse(localStorage.getItem(storageKey));
  21886. this.selectedTab = storedTab;
  21887. }
  21888. }
  21889. componentWillRender() {
  21890. const { parentTabsEl } = this;
  21891. this.layout = parentTabsEl === null || parentTabsEl === void 0 ? void 0 : parentTabsEl.layout;
  21892. this.position = parentTabsEl === null || parentTabsEl === void 0 ? void 0 : parentTabsEl.position;
  21893. this.scale = parentTabsEl === null || parentTabsEl === void 0 ? void 0 : parentTabsEl.scale;
  21894. this.bordered = parentTabsEl === null || parentTabsEl === void 0 ? void 0 : parentTabsEl.bordered;
  21895. // fix issue with active tab-title not lining up with blue indicator
  21896. if (this.selectedTabEl) {
  21897. this.updateOffsetPosition();
  21898. }
  21899. }
  21900. componentDidRender() {
  21901. // if every tab title is active select the first tab.
  21902. if (this.tabTitles.length &&
  21903. this.tabTitles.every((title) => !title.active) &&
  21904. !this.selectedTab) {
  21905. this.tabTitles[0].getTabIdentifier().then((tab) => {
  21906. this.calciteInternalTabChange.emit({
  21907. tab
  21908. });
  21909. });
  21910. }
  21911. }
  21912. render() {
  21913. const dir = getElementDir(this.el);
  21914. const width = `${this.indicatorWidth}px`;
  21915. const offset = `${this.indicatorOffset}px`;
  21916. const indicatorStyle = dir !== "rtl" ? { width, left: offset } : { width, right: offset };
  21917. 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))));
  21918. }
  21919. //--------------------------------------------------------------------------
  21920. //
  21921. // Event Listeners
  21922. //
  21923. //--------------------------------------------------------------------------
  21924. focusPreviousTabHandler(e) {
  21925. const currentIndex = this.getIndexOfTabTitle(e.target, this.enabledTabTitles);
  21926. const previousTab = this.enabledTabTitles[currentIndex - 1] ||
  21927. this.enabledTabTitles[this.enabledTabTitles.length - 1];
  21928. previousTab.focus();
  21929. e.stopPropagation();
  21930. e.preventDefault();
  21931. }
  21932. focusNextTabHandler(e) {
  21933. const currentIndex = this.getIndexOfTabTitle(e.target, this.enabledTabTitles);
  21934. const nextTab = this.enabledTabTitles[currentIndex + 1] || this.enabledTabTitles[0];
  21935. nextTab.focus();
  21936. e.stopPropagation();
  21937. e.preventDefault();
  21938. }
  21939. internalActivateTabHandler(e) {
  21940. this.selectedTab = e.detail.tab
  21941. ? e.detail.tab
  21942. : this.getIndexOfTabTitle(e.target);
  21943. e.stopPropagation();
  21944. e.preventDefault();
  21945. }
  21946. activateTabHandler(e) {
  21947. this.calciteTabChange.emit({
  21948. tab: this.selectedTab
  21949. });
  21950. e.stopPropagation();
  21951. e.preventDefault();
  21952. }
  21953. /**
  21954. * Check for active tabs on register and update selected
  21955. */
  21956. updateTabTitles(e) {
  21957. if (e.target.active) {
  21958. this.selectedTab = e.detail;
  21959. }
  21960. }
  21961. globalInternalTabChangeHandler(e) {
  21962. if (this.syncId &&
  21963. e.target !== this.el &&
  21964. e.target.syncId === this.syncId &&
  21965. this.selectedTab !== e.detail.tab) {
  21966. this.selectedTab = e.detail.tab;
  21967. e.stopPropagation();
  21968. }
  21969. }
  21970. updateOffsetPosition() {
  21971. var _a, _b, _c, _d, _e;
  21972. const dir = getElementDir(this.el);
  21973. const navWidth = (_a = this.activeIndicatorContainerEl) === null || _a === void 0 ? void 0 : _a.offsetWidth;
  21974. const tabLeft = (_b = this.selectedTabEl) === null || _b === void 0 ? void 0 : _b.offsetLeft;
  21975. const tabWidth = (_c = this.selectedTabEl) === null || _c === void 0 ? void 0 : _c.offsetWidth;
  21976. const offsetRight = navWidth - (tabLeft + tabWidth);
  21977. this.indicatorOffset =
  21978. 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);
  21979. }
  21980. updateActiveWidth() {
  21981. var _a;
  21982. this.indicatorWidth = (_a = this.selectedTabEl) === null || _a === void 0 ? void 0 : _a.offsetWidth;
  21983. }
  21984. getIndexOfTabTitle(el, tabTitles = this.tabTitles) {
  21985. // In most cases, since these indexes correlate with tab contents, we want to consider all tab titles.
  21986. // However, when doing relative index operations, it makes sense to pass in this.enabledTabTitles as the 2nd arg.
  21987. return tabTitles.indexOf(el);
  21988. }
  21989. async getTabTitleById(id) {
  21990. return Promise.all(this.tabTitles.map((el) => el.getTabIdentifier())).then((ids) => {
  21991. return this.tabTitles[ids.indexOf(id)];
  21992. });
  21993. }
  21994. get tabTitles() {
  21995. return filterDirectChildren(this.el, "calcite-tab-title");
  21996. }
  21997. get enabledTabTitles() {
  21998. return filterDirectChildren(this.el, "calcite-tab-title:not([disabled])");
  21999. }
  22000. get el() { return this; }
  22001. static get watchers() { return {
  22002. "selectedTab": ["selectedTabChanged"],
  22003. "selectedTabEl": ["selectedTabElChanged"]
  22004. }; }
  22005. static get style() { return tabNavCss; }
  22006. };
  22007. 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}";
  22008. const TabTitle = class extends HTMLElement$1 {
  22009. constructor() {
  22010. super();
  22011. this.__registerHost();
  22012. this.__attachShadow();
  22013. this.calciteTabsActivate = createEvent(this, "calciteTabsActivate", 7);
  22014. this.calciteInternalTabsActivate = createEvent(this, "calciteInternalTabsActivate", 7);
  22015. this.calciteTabsFocusNext = createEvent(this, "calciteTabsFocusNext", 7);
  22016. this.calciteTabsFocusPrevious = createEvent(this, "calciteTabsFocusPrevious", 7);
  22017. this.calciteTabTitleRegister = createEvent(this, "calciteTabTitleRegister", 7);
  22018. //--------------------------------------------------------------------------
  22019. //
  22020. // Properties
  22021. //
  22022. //--------------------------------------------------------------------------
  22023. /** Show this tab title as selected */
  22024. this.active = false;
  22025. /** Disable this tab title */
  22026. this.disabled = false;
  22027. /** @internal Parent tabs component bordered value */
  22028. this.bordered = false;
  22029. //--------------------------------------------------------------------------
  22030. //
  22031. // Private State/Props
  22032. //
  22033. //--------------------------------------------------------------------------
  22034. /** watches for changing text content **/
  22035. this.mutationObserver = createObserver("mutation", () => this.updateHasText());
  22036. /** determine if there is slotted text for styling purposes */
  22037. this.hasText = false;
  22038. this.guid = `calcite-tab-title-${guid()}`;
  22039. }
  22040. activeTabChanged() {
  22041. if (this.active) {
  22042. this.emitActiveTab(false);
  22043. }
  22044. }
  22045. //--------------------------------------------------------------------------
  22046. //
  22047. // Lifecycle
  22048. //
  22049. //--------------------------------------------------------------------------
  22050. connectedCallback() {
  22051. this.setupTextContentObserver();
  22052. this.parentTabNavEl = this.el.closest("calcite-tab-nav");
  22053. this.parentTabsEl = this.el.closest("calcite-tabs");
  22054. }
  22055. disconnectedCallback() {
  22056. var _a, _b;
  22057. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  22058. // Dispatching to body in order to be listened by other elements that are still connected to the DOM.
  22059. (_b = document.body) === null || _b === void 0 ? void 0 : _b.dispatchEvent(new CustomEvent("calciteTabTitleUnregister", {
  22060. detail: this.el
  22061. }));
  22062. }
  22063. componentWillLoad() {
  22064. if (Build.isBrowser) {
  22065. this.updateHasText();
  22066. }
  22067. if (this.tab && this.active) {
  22068. this.emitActiveTab(false);
  22069. }
  22070. }
  22071. componentWillRender() {
  22072. if (this.parentTabsEl) {
  22073. this.layout = this.parentTabsEl.layout;
  22074. this.position = this.parentTabsEl.position;
  22075. this.scale = this.parentTabsEl.scale;
  22076. this.bordered = this.parentTabsEl.bordered;
  22077. }
  22078. // handle case when tab-nav is only parent
  22079. if (!this.parentTabsEl && this.parentTabNavEl) {
  22080. this.position = getElementProp(this.parentTabNavEl, "position", this.position);
  22081. this.scale = getElementProp(this.parentTabNavEl, "scale", this.scale);
  22082. }
  22083. }
  22084. render() {
  22085. const id = this.el.id || this.guid;
  22086. const showSideBorders = this.bordered && !this.disabled && this.layout !== "center";
  22087. const iconStartEl = (h("calcite-icon", { class: "calcite-tab-title--icon icon-start", flipRtl: this.iconFlipRtl === "start" || this.iconFlipRtl === "both", icon: this.iconStart, scale: "s" }));
  22088. const iconEndEl = (h("calcite-icon", { class: "calcite-tab-title--icon icon-end", flipRtl: this.iconFlipRtl === "end" || this.iconFlipRtl === "both", icon: this.iconEnd, scale: "s" }));
  22089. return (h(Host, { "aria-controls": this.controls, "aria-expanded": toAriaBoolean(this.active), id: id, role: "tab" }, h("a", { class: {
  22090. container: true,
  22091. "container--has-text": this.hasText
  22092. }, style: showSideBorders && { width: `${this.parentTabNavEl.indicatorWidth}px` } }, this.iconStart ? iconStartEl : null, h("slot", null), this.iconEnd ? iconEndEl : null)));
  22093. }
  22094. async componentDidLoad() {
  22095. this.calciteTabTitleRegister.emit(await this.getTabIdentifier());
  22096. }
  22097. componentDidRender() {
  22098. updateHostInteraction(this, true);
  22099. }
  22100. //--------------------------------------------------------------------------
  22101. //
  22102. // Event Listeners
  22103. //
  22104. //--------------------------------------------------------------------------
  22105. internalTabChangeHandler(event) {
  22106. const targetTabsEl = event
  22107. .composedPath()
  22108. .find((el) => el.tagName === "CALCITE-TABS");
  22109. if (targetTabsEl !== this.parentTabsEl) {
  22110. return;
  22111. }
  22112. if (this.tab) {
  22113. this.active = this.tab === event.detail.tab;
  22114. }
  22115. else {
  22116. this.getTabIndex().then((index) => {
  22117. this.active = index === event.detail.tab;
  22118. });
  22119. }
  22120. event.stopPropagation();
  22121. }
  22122. onClick() {
  22123. this.emitActiveTab();
  22124. }
  22125. keyDownHandler(e) {
  22126. switch (e.key) {
  22127. case " ":
  22128. case "Enter":
  22129. this.emitActiveTab();
  22130. e.preventDefault();
  22131. break;
  22132. case "ArrowRight":
  22133. if (getElementDir(this.el) === "ltr") {
  22134. this.calciteTabsFocusNext.emit();
  22135. }
  22136. else {
  22137. this.calciteTabsFocusPrevious.emit();
  22138. }
  22139. break;
  22140. case "ArrowLeft":
  22141. if (getElementDir(this.el) === "ltr") {
  22142. this.calciteTabsFocusPrevious.emit();
  22143. }
  22144. else {
  22145. this.calciteTabsFocusNext.emit();
  22146. }
  22147. break;
  22148. }
  22149. }
  22150. //--------------------------------------------------------------------------
  22151. //
  22152. // Public Methods
  22153. //
  22154. //--------------------------------------------------------------------------
  22155. /**
  22156. * Return the index of this title within the nav
  22157. */
  22158. async getTabIndex() {
  22159. return Array.prototype.indexOf.call(this.el.parentElement.querySelectorAll("calcite-tab-title"), this.el);
  22160. }
  22161. /**
  22162. * @internal
  22163. */
  22164. async getTabIdentifier() {
  22165. return this.tab ? this.tab : this.getTabIndex();
  22166. }
  22167. /**
  22168. * @internal
  22169. */
  22170. async updateAriaInfo(tabIds = [], titleIds = []) {
  22171. this.controls = tabIds[titleIds.indexOf(this.el.id)] || null;
  22172. }
  22173. updateHasText() {
  22174. this.hasText = this.el.textContent.trim().length > 0;
  22175. }
  22176. setupTextContentObserver() {
  22177. var _a;
  22178. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
  22179. }
  22180. emitActiveTab(userTriggered = true) {
  22181. if (this.disabled) {
  22182. return;
  22183. }
  22184. const payload = { tab: this.tab };
  22185. this.calciteInternalTabsActivate.emit(payload);
  22186. if (userTriggered) {
  22187. this.calciteTabsActivate.emit(payload);
  22188. }
  22189. }
  22190. get el() { return this; }
  22191. static get watchers() { return {
  22192. "active": ["activeTabChanged"]
  22193. }; }
  22194. static get style() { return tabTitleCss; }
  22195. };
  22196. const SLOTS$4 = {
  22197. tabNav: "tab-nav"
  22198. };
  22199. 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}";
  22200. const Tabs = class extends HTMLElement$1 {
  22201. constructor() {
  22202. super();
  22203. this.__registerHost();
  22204. this.__attachShadow();
  22205. //--------------------------------------------------------------------------
  22206. //
  22207. // Public Properties
  22208. //
  22209. //--------------------------------------------------------------------------
  22210. /**
  22211. * Align tab titles to the edge or fully justify them across the tab nav ("center")
  22212. */
  22213. this.layout = "inline";
  22214. /**
  22215. * Display the tabs above (default) or below the tab content
  22216. */
  22217. this.position = "above";
  22218. /**
  22219. * Specify the scale of the tabs component, defaults to m
  22220. */
  22221. this.scale = "m";
  22222. /**
  22223. * Optionally enable tabs to appear like a folder-style menu when its layout is "inline"
  22224. */
  22225. this.bordered = false;
  22226. //--------------------------------------------------------------------------
  22227. //
  22228. // Events
  22229. //
  22230. //--------------------------------------------------------------------------
  22231. //--------------------------------------------------------------------------
  22232. //
  22233. // Private State/Props
  22234. //
  22235. //--------------------------------------------------------------------------
  22236. /**
  22237. *
  22238. * Stores an array of ids of `<calcite-tab-titles>`s to match up ARIA
  22239. * attributes.
  22240. */
  22241. this.titles = [];
  22242. /**
  22243. *
  22244. * Stores an array of ids of `<calcite-tab>`s to match up ARIA attributes.
  22245. */
  22246. this.tabs = [];
  22247. }
  22248. //--------------------------------------------------------------------------
  22249. //
  22250. // Lifecycle
  22251. //
  22252. //--------------------------------------------------------------------------
  22253. connectedCallback() {
  22254. if (this.layout === "center") {
  22255. this.bordered = false;
  22256. }
  22257. }
  22258. render() {
  22259. return (h(Fragment, null, h("slot", { name: SLOTS$4.tabNav }), h("section", null, h("slot", null))));
  22260. }
  22261. //--------------------------------------------------------------------------
  22262. //
  22263. // Event Listeners
  22264. //
  22265. //--------------------------------------------------------------------------
  22266. /**
  22267. * @internal
  22268. */
  22269. calciteTabTitleRegister(e) {
  22270. this.titles = [...this.titles, e.target];
  22271. this.registryHandler();
  22272. e.stopPropagation();
  22273. }
  22274. /**
  22275. * @internal
  22276. */
  22277. calciteTabTitleUnregister(e) {
  22278. this.titles = this.titles.filter((el) => el !== e.detail);
  22279. this.registryHandler();
  22280. e.stopPropagation();
  22281. }
  22282. /**
  22283. * @internal
  22284. */
  22285. calciteTabRegister(e) {
  22286. this.tabs = [...this.tabs, e.target];
  22287. this.registryHandler();
  22288. e.stopPropagation();
  22289. }
  22290. /**
  22291. * @internal
  22292. */
  22293. calciteTabUnregister(e) {
  22294. this.tabs = this.tabs.filter((el) => el !== e.detail);
  22295. this.registryHandler();
  22296. e.stopPropagation();
  22297. }
  22298. //--------------------------------------------------------------------------
  22299. //
  22300. // Private Methods
  22301. //
  22302. //--------------------------------------------------------------------------
  22303. /**
  22304. *
  22305. * Matches up elements from the internal `tabs` and `titles` to automatically
  22306. * update the ARIA attributes and link `<calcite-tab>` and
  22307. * `<calcite-tab-title>` components.
  22308. */
  22309. async registryHandler() {
  22310. let tabIds;
  22311. let titleIds;
  22312. // determine if we are using `tab` based or `index` based tab identifiers.
  22313. if (this.tabs.some((e) => e.tab) || this.titles.some((e) => e.tab)) {
  22314. // if we are using `tab` based identifiers sort by `tab` to account for
  22315. // possible out of order tabs and get the id of each tab
  22316. tabIds = this.tabs.sort((a, b) => a.tab.localeCompare(b.tab)).map((e) => e.id);
  22317. titleIds = this.titles.sort((a, b) => a.tab.localeCompare(b.tab)).map((e) => e.id);
  22318. }
  22319. else {
  22320. // if we are using index based tabs then the `<calcite-tab>` and
  22321. // `<calcite-tab-title>` might have been rendered out of order so the
  22322. // order of `this.tabs` and `this.titles` might not reflect the DOM state,
  22323. // and might not match each other so we need to get the index of all the
  22324. // tabs and titles in the DOM order to match them up as a source of truth
  22325. const tabDomIndexes = await Promise.all(this.tabs.map((el) => el.getTabIndex()));
  22326. const titleDomIndexes = await Promise.all(this.titles.map((el) => el.getTabIndex()));
  22327. // once we have the DOM order as a source of truth we can build the
  22328. // matching tabIds and titleIds arrays
  22329. tabIds = tabDomIndexes.reduce((ids, indexInDOM, registryIndex) => {
  22330. ids[indexInDOM] = this.tabs[registryIndex].id;
  22331. return ids;
  22332. }, []);
  22333. titleIds = titleDomIndexes.reduce((ids, indexInDOM, registryIndex) => {
  22334. ids[indexInDOM] = this.titles[registryIndex].id;
  22335. return ids;
  22336. }, []);
  22337. }
  22338. // pass all our new aria information to each `<calcite-tab>` and
  22339. // `<calcite-tab-title>` which will check if they can update their internal
  22340. // `controlled` or `labeledBy` states and re-render if necessary
  22341. this.tabs.forEach((el) => el.updateAriaInfo(tabIds, titleIds));
  22342. this.titles.forEach((el) => el.updateAriaInfo(tabIds, titleIds));
  22343. }
  22344. get el() { return this; }
  22345. static get style() { return tabsCss; }
  22346. };
  22347. const SLOTS$3 = {
  22348. contentStart: "content-start",
  22349. contentEnd: "content-end"
  22350. };
  22351. 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)}";
  22352. const Tile = class extends HTMLElement$1 {
  22353. constructor() {
  22354. super();
  22355. this.__registerHost();
  22356. this.__attachShadow();
  22357. //--------------------------------------------------------------------------
  22358. //
  22359. // Properties
  22360. //
  22361. //--------------------------------------------------------------------------
  22362. /** The active state of the tile. */
  22363. this.active = false;
  22364. /**
  22365. * When true, prevents interaction.
  22366. */
  22367. this.disabled = false;
  22368. /** The embed mode of the tile. When true, renders without a border and padding for use by other components. */
  22369. this.embed = false;
  22370. /**
  22371. * The focused state of the tile.
  22372. * @internal
  22373. */
  22374. this.focused = false;
  22375. /** The hidden state of the tile. */
  22376. this.hidden = false;
  22377. }
  22378. // --------------------------------------------------------------------------
  22379. //
  22380. // Lifecycle
  22381. //
  22382. // --------------------------------------------------------------------------
  22383. connectedCallback() {
  22384. connectConditionalSlotComponent(this);
  22385. }
  22386. disconnectedCallback() {
  22387. disconnectConditionalSlotComponent(this);
  22388. }
  22389. componentDidRender() {
  22390. updateHostInteraction(this);
  22391. }
  22392. // --------------------------------------------------------------------------
  22393. //
  22394. // Render Methods
  22395. //
  22396. // --------------------------------------------------------------------------
  22397. renderTile() {
  22398. const { icon, el, heading, description } = this;
  22399. const isLargeVisual = heading && icon && !description;
  22400. const iconStyle = isLargeVisual
  22401. ? {
  22402. height: "64px",
  22403. width: "64px"
  22404. }
  22405. : undefined;
  22406. 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)));
  22407. }
  22408. render() {
  22409. return (h(Fragment, null, this.href ? (h("calcite-link", { disabled: this.disabled, href: this.href }, this.renderTile())) : (this.renderTile())));
  22410. }
  22411. get el() { return this; }
  22412. static get style() { return tileCss; }
  22413. };
  22414. const CSS$6 = {
  22415. checked: "checked",
  22416. description: "description",
  22417. descriptionOnly: "description-only",
  22418. disabled: "disabled",
  22419. heading: "heading",
  22420. headingOnly: "heading-only",
  22421. icon: "icon",
  22422. iconOnly: "icon-only",
  22423. inputAlignmentEnd: "input-alignment-end",
  22424. inputAlignmentStart: "input-alignment-start",
  22425. inputEnabled: "input-enabled",
  22426. largeVisual: "large-visual",
  22427. widthAuto: "width-auto",
  22428. widthFull: "width-full"
  22429. };
  22430. 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}";
  22431. const TileSelect = class extends HTMLElement$1 {
  22432. constructor() {
  22433. super();
  22434. this.__registerHost();
  22435. this.__attachShadow();
  22436. this.calciteTileSelectChange = createEvent(this, "calciteTileSelectChange", 7);
  22437. //--------------------------------------------------------------------------
  22438. //
  22439. // Properties
  22440. //
  22441. //--------------------------------------------------------------------------
  22442. /** The checked state of the tile select. */
  22443. this.checked = false;
  22444. /** The disabled state of the tile select. */
  22445. this.disabled = false;
  22446. /** The hidden state of the tile select. */
  22447. this.hidden = false;
  22448. /** Display an interactive radio or checkbox. */
  22449. this.inputEnabled = false;
  22450. /** The side of the tile that the radio or checkbox appears on when inputEnabled is true. */
  22451. this.inputAlignment = "start";
  22452. /** The selection mode of the tile select: radio (single) or checkbox (multiple). */
  22453. this.type = "radio";
  22454. /** specify the width of the tile, defaults to auto */
  22455. this.width = "auto";
  22456. this.guid = `calcite-tile-select-${guid()}`;
  22457. //--------------------------------------------------------------------------
  22458. //
  22459. // State
  22460. //
  22461. //--------------------------------------------------------------------------
  22462. /** The focused state of the tile-select. */
  22463. this.focused = false;
  22464. }
  22465. checkedChanged(newChecked) {
  22466. this.input.checked = newChecked;
  22467. }
  22468. nameChanged(newName) {
  22469. this.input.name = newName;
  22470. }
  22471. //--------------------------------------------------------------------------
  22472. //
  22473. // Public Methods
  22474. //
  22475. //--------------------------------------------------------------------------
  22476. /** Sets focus on the component. */
  22477. async setFocus() {
  22478. this.input.setFocus();
  22479. }
  22480. //--------------------------------------------------------------------------
  22481. //
  22482. // Event Listeners
  22483. //
  22484. //--------------------------------------------------------------------------
  22485. checkboxChangeHandler(event) {
  22486. const checkbox = event.target;
  22487. if (checkbox === this.input) {
  22488. this.checked = checkbox.checked;
  22489. }
  22490. event.stopPropagation();
  22491. this.calciteTileSelectChange.emit();
  22492. }
  22493. checkboxFocusBlurHandler(event) {
  22494. const checkbox = event.target;
  22495. if (checkbox === this.input) {
  22496. this.focused = event.detail;
  22497. }
  22498. event.stopPropagation();
  22499. }
  22500. radioButtonChangeHandler(event) {
  22501. const radioButton = event.target;
  22502. if (radioButton === this.input) {
  22503. this.checked = radioButton.checked;
  22504. }
  22505. event.stopPropagation();
  22506. this.calciteTileSelectChange.emit();
  22507. }
  22508. radioButtonCheckedChangeHandler(event) {
  22509. const radioButton = event.target;
  22510. if (radioButton === this.input) {
  22511. this.checked = radioButton.checked;
  22512. }
  22513. event.stopPropagation();
  22514. }
  22515. radioButtonFocusBlurHandler(event) {
  22516. const radioButton = event.target;
  22517. if (radioButton === this.input) {
  22518. this.focused = radioButton.focused;
  22519. }
  22520. event.stopPropagation();
  22521. }
  22522. click(event) {
  22523. const target = event.target;
  22524. const targets = ["calcite-tile", "calcite-tile-select"];
  22525. if (targets.includes(target.localName)) {
  22526. this.input.click();
  22527. }
  22528. }
  22529. mouseenter() {
  22530. if (this.input.localName === "calcite-radio-button") {
  22531. this.input.hovered = true;
  22532. }
  22533. if (this.input.localName === "calcite-checkbox") {
  22534. this.input.hovered = true;
  22535. }
  22536. }
  22537. mouseleave() {
  22538. if (this.input.localName === "calcite-radio-button") {
  22539. this.input.hovered = false;
  22540. }
  22541. if (this.input.localName === "calcite-checkbox") {
  22542. this.input.hovered = false;
  22543. }
  22544. }
  22545. //--------------------------------------------------------------------------
  22546. //
  22547. // Lifecycle
  22548. //
  22549. //--------------------------------------------------------------------------
  22550. connectedCallback() {
  22551. this.renderInput();
  22552. }
  22553. disconnectedCallback() {
  22554. this.input.parentNode.removeChild(this.input);
  22555. }
  22556. componentDidRender() {
  22557. updateHostInteraction(this);
  22558. }
  22559. // --------------------------------------------------------------------------
  22560. //
  22561. // Render Methods
  22562. //
  22563. // --------------------------------------------------------------------------
  22564. renderInput() {
  22565. this.input = document.createElement(this.type === "radio" ? "calcite-radio-button" : "calcite-checkbox");
  22566. this.input.checked = this.checked;
  22567. this.input.disabled = this.disabled;
  22568. this.input.hidden = this.hidden;
  22569. this.input.id = this.guid;
  22570. this.input.label = this.heading || this.name || "";
  22571. if (this.name) {
  22572. this.input.name = this.name;
  22573. }
  22574. if (this.value) {
  22575. this.input.value = this.value != null ? this.value.toString() : "";
  22576. }
  22577. this.el.insertAdjacentElement("beforeend", this.input);
  22578. }
  22579. render() {
  22580. const { checked, description, disabled, focused, heading, icon, inputAlignment, inputEnabled, width } = this;
  22581. return (h("div", { class: {
  22582. checked,
  22583. container: true,
  22584. [CSS$6.description]: Boolean(description),
  22585. [CSS$6.descriptionOnly]: Boolean(!heading && !icon && description),
  22586. disabled,
  22587. focused,
  22588. [CSS$6.heading]: Boolean(heading),
  22589. [CSS$6.headingOnly]: heading && !icon && !description,
  22590. [CSS$6.icon]: Boolean(icon),
  22591. [CSS$6.iconOnly]: !heading && icon && !description,
  22592. [CSS$6.inputAlignmentEnd]: inputAlignment === "end",
  22593. [CSS$6.inputAlignmentStart]: inputAlignment === "start",
  22594. [CSS$6.inputEnabled]: inputEnabled,
  22595. [CSS$6.largeVisual]: heading && icon && !description,
  22596. [CSS$6.widthAuto]: width === "auto",
  22597. [CSS$6.widthFull]: width === "full"
  22598. } }, h("calcite-tile", { active: checked, description: description, embed: true, heading: heading, icon: icon }), h("slot", null)));
  22599. }
  22600. get el() { return this; }
  22601. static get watchers() { return {
  22602. "checked": ["checkedChanged"],
  22603. "name": ["nameChanged"]
  22604. }; }
  22605. static get style() { return tileSelectCss; }
  22606. };
  22607. 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}";
  22608. const TileSelectGroup = class extends HTMLElement$1 {
  22609. constructor() {
  22610. super();
  22611. this.__registerHost();
  22612. this.__attachShadow();
  22613. //--------------------------------------------------------------------------
  22614. //
  22615. // Properties
  22616. //
  22617. //--------------------------------------------------------------------------
  22618. /** The disabled state of the tile select. */
  22619. this.disabled = false;
  22620. /** Tiles by default move horizontally, stacking with each row, vertical allows single-column layouts */
  22621. this.layout = "horizontal";
  22622. }
  22623. //--------------------------------------------------------------------------
  22624. //
  22625. // Lifecycle
  22626. //
  22627. //--------------------------------------------------------------------------
  22628. componentDidRender() {
  22629. updateHostInteraction(this);
  22630. }
  22631. render() {
  22632. return h("slot", null);
  22633. }
  22634. get el() { return this; }
  22635. static get style() { return tileSelectGroupCss; }
  22636. };
  22637. const CSS$5 = {
  22638. button: "button",
  22639. buttonBottomLeft: "button--bottom-left",
  22640. buttonBottomRight: "button--bottom-right",
  22641. buttonHourDown: "button--hour-down",
  22642. buttonHourUp: "button--hour-up",
  22643. buttonMeridiemDown: "button--meridiem-down",
  22644. buttonMeridiemUp: "button--meridiem-up",
  22645. buttonMinuteDown: "button--minute-down",
  22646. buttonMinuteUp: "button--minute-up",
  22647. buttonSecondDown: "button--second-down",
  22648. buttonSecondUp: "button--second-up",
  22649. buttonTopLeft: "button--top-left",
  22650. buttonTopRight: "button--top-right",
  22651. column: "column",
  22652. delimiter: "delimiter",
  22653. hour: "hour",
  22654. input: "input",
  22655. meridiem: "meridiem",
  22656. minute: "minute",
  22657. second: "second",
  22658. showMeridiem: "show-meridiem",
  22659. showSecond: "show-second",
  22660. "scale-s": "scale-s",
  22661. "scale-m": "scale-m",
  22662. "scale-l": "scale-l",
  22663. timePicker: "time-picker",
  22664. meridiemStart: "meridiem--start"
  22665. };
  22666. const TEXT$2 = {
  22667. hour: "Hour",
  22668. hourDown: "Decrease hour",
  22669. hourUp: "Increase hour",
  22670. meridiem: "AM/PM",
  22671. meridiemDown: "Decrease AM/PM",
  22672. meridiemUp: "Increase AM/PM",
  22673. minute: "Minute",
  22674. minuteDown: "Decrease minute",
  22675. minuteUp: "Increase minute",
  22676. second: "Second",
  22677. secondDown: "Decrease second",
  22678. secondUp: "Increase second"
  22679. };
  22680. 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}";
  22681. function capitalize(str) {
  22682. return str.charAt(0).toUpperCase() + str.slice(1);
  22683. }
  22684. const TimePicker = class extends HTMLElement$1 {
  22685. constructor() {
  22686. super();
  22687. this.__registerHost();
  22688. this.__attachShadow();
  22689. this.calciteTimePickerBlur = createEvent(this, "calciteTimePickerBlur", 7);
  22690. this.calciteTimePickerChange = createEvent(this, "calciteTimePickerChange", 7);
  22691. this.calciteTimePickerFocus = createEvent(this, "calciteTimePickerFocus", 7);
  22692. //--------------------------------------------------------------------------
  22693. //
  22694. // Properties
  22695. //
  22696. //--------------------------------------------------------------------------
  22697. /** aria-label for the hour input
  22698. * @default "Hour"
  22699. */
  22700. this.intlHour = TEXT$2.hour;
  22701. /** aria-label for the hour down button
  22702. * @default "Decrease hour"
  22703. */
  22704. this.intlHourDown = TEXT$2.hourDown;
  22705. /** aria-label for the hour up button
  22706. * @default "Increase hour"
  22707. */
  22708. this.intlHourUp = TEXT$2.hourUp;
  22709. /** aria-label for the meridiem (am/pm) input
  22710. * @default "AM/PM"
  22711. */
  22712. this.intlMeridiem = TEXT$2.meridiem;
  22713. /** aria-label for the meridiem (am/pm) down button
  22714. * @default "Decrease AM/PM"
  22715. */
  22716. this.intlMeridiemDown = TEXT$2.meridiemDown;
  22717. /** aria-label for the meridiem (am/pm) up button
  22718. * @default "Increase AM/PM"
  22719. */
  22720. this.intlMeridiemUp = TEXT$2.meridiemUp;
  22721. /** aria-label for the minute input
  22722. * @default "Minute"
  22723. */
  22724. this.intlMinute = TEXT$2.minute;
  22725. /** aria-label for the minute down button
  22726. * @default "Decrease minute"
  22727. */
  22728. this.intlMinuteDown = TEXT$2.minuteDown;
  22729. /** aria-label for the minute up button
  22730. * @default "Increase minute"
  22731. */
  22732. this.intlMinuteUp = TEXT$2.minuteUp;
  22733. /** aria-label for the second input
  22734. * @default "Second"
  22735. */
  22736. this.intlSecond = TEXT$2.second;
  22737. /** aria-label for the second down button
  22738. * @default "Decrease second"
  22739. */
  22740. this.intlSecondDown = TEXT$2.secondDown;
  22741. /** aria-label for the second up button
  22742. * @default "Increase second"
  22743. */
  22744. this.intlSecondUp = TEXT$2.secondUp;
  22745. /**
  22746. * BCP 47 language tag for desired language and country format
  22747. * @internal
  22748. */
  22749. this.locale = document.documentElement.lang || navigator.language || "en";
  22750. /** The scale (size) of the time picker */
  22751. this.scale = "m";
  22752. /** number (seconds) that specifies the granularity that the value must adhere to */
  22753. this.step = 60;
  22754. /** The selected time in UTC (always 24-hour format) */
  22755. this.value = null;
  22756. this.showSecond = this.step < 60;
  22757. this.decrementHour = () => {
  22758. const newHour = !this.hour ? 0 : this.hour === "00" ? 23 : parseInt(this.hour) - 1;
  22759. this.setValuePart("hour", newHour);
  22760. };
  22761. this.decrementMeridiem = () => {
  22762. const newMeridiem = this.meridiem === "PM" ? "AM" : "PM";
  22763. this.setValuePart("meridiem", newMeridiem);
  22764. };
  22765. this.decrementMinuteOrSecond = (key) => {
  22766. let newValue;
  22767. if (isValidNumber(this[key])) {
  22768. const valueAsNumber = parseInt(this[key]);
  22769. newValue = valueAsNumber === 0 ? 59 : valueAsNumber - 1;
  22770. }
  22771. else {
  22772. newValue = 59;
  22773. }
  22774. this.setValuePart(key, newValue);
  22775. };
  22776. this.decrementMinute = () => {
  22777. this.decrementMinuteOrSecond("minute");
  22778. };
  22779. this.decrementSecond = () => {
  22780. this.decrementMinuteOrSecond("second");
  22781. };
  22782. this.focusHandler = (event) => {
  22783. this.activeEl = event.currentTarget;
  22784. };
  22785. this.hourDownButtonKeyDownHandler = (event) => {
  22786. if (this.buttonActivated(event)) {
  22787. this.decrementHour();
  22788. }
  22789. };
  22790. this.hourKeyDownHandler = (event) => {
  22791. const key = event.key;
  22792. if (numberKeys.includes(key)) {
  22793. const keyAsNumber = parseInt(key);
  22794. let newHour;
  22795. if (isValidNumber(this.hour)) {
  22796. switch (this.hourCycle) {
  22797. case "12":
  22798. newHour =
  22799. this.hour === "01" && keyAsNumber >= 0 && keyAsNumber <= 2
  22800. ? `1${keyAsNumber}`
  22801. : keyAsNumber;
  22802. break;
  22803. case "24":
  22804. if (this.hour === "01") {
  22805. newHour = `1${keyAsNumber}`;
  22806. }
  22807. else if (this.hour === "02" && keyAsNumber >= 0 && keyAsNumber <= 3) {
  22808. newHour = `2${keyAsNumber}`;
  22809. }
  22810. else {
  22811. newHour = keyAsNumber;
  22812. }
  22813. break;
  22814. }
  22815. }
  22816. else {
  22817. newHour = keyAsNumber;
  22818. }
  22819. this.setValuePart("hour", newHour);
  22820. }
  22821. else {
  22822. switch (key) {
  22823. case "Backspace":
  22824. case "Delete":
  22825. this.setValuePart("hour", null);
  22826. break;
  22827. case "ArrowDown":
  22828. event.preventDefault();
  22829. this.decrementHour();
  22830. break;
  22831. case "ArrowUp":
  22832. event.preventDefault();
  22833. this.incrementHour();
  22834. break;
  22835. case " ":
  22836. case "Spacebar":
  22837. event.preventDefault();
  22838. break;
  22839. }
  22840. }
  22841. };
  22842. this.hourUpButtonKeyDownHandler = (event) => {
  22843. if (this.buttonActivated(event)) {
  22844. this.incrementHour();
  22845. }
  22846. };
  22847. this.incrementMeridiem = () => {
  22848. const newMeridiem = this.meridiem === "AM" ? "PM" : "AM";
  22849. this.setValuePart("meridiem", newMeridiem);
  22850. };
  22851. this.incrementHour = () => {
  22852. const newHour = isValidNumber(this.hour)
  22853. ? this.hour === "23"
  22854. ? 0
  22855. : parseInt(this.hour) + 1
  22856. : 1;
  22857. this.setValuePart("hour", newHour);
  22858. };
  22859. this.incrementMinuteOrSecond = (key) => {
  22860. const newValue = isValidNumber(this[key])
  22861. ? this[key] === "59"
  22862. ? 0
  22863. : parseInt(this[key]) + 1
  22864. : 0;
  22865. this.setValuePart(key, newValue);
  22866. };
  22867. this.incrementMinute = () => {
  22868. this.incrementMinuteOrSecond("minute");
  22869. };
  22870. this.incrementSecond = () => {
  22871. this.incrementMinuteOrSecond("second");
  22872. };
  22873. this.meridiemDownButtonKeyDownHandler = (event) => {
  22874. if (this.buttonActivated(event)) {
  22875. this.decrementMeridiem();
  22876. }
  22877. };
  22878. this.meridiemKeyDownHandler = (event) => {
  22879. switch (event.key) {
  22880. case "a":
  22881. this.setValuePart("meridiem", "AM");
  22882. break;
  22883. case "p":
  22884. this.setValuePart("meridiem", "PM");
  22885. break;
  22886. case "Backspace":
  22887. case "Delete":
  22888. this.setValuePart("meridiem", null);
  22889. break;
  22890. case "ArrowUp":
  22891. event.preventDefault();
  22892. this.incrementMeridiem();
  22893. break;
  22894. case "ArrowDown":
  22895. event.preventDefault();
  22896. this.decrementMeridiem();
  22897. break;
  22898. case " ":
  22899. case "Spacebar":
  22900. event.preventDefault();
  22901. break;
  22902. }
  22903. };
  22904. this.meridiemUpButtonKeyDownHandler = (event) => {
  22905. if (this.buttonActivated(event)) {
  22906. this.incrementMeridiem();
  22907. }
  22908. };
  22909. this.minuteDownButtonKeyDownHandler = (event) => {
  22910. if (this.buttonActivated(event)) {
  22911. this.decrementMinute();
  22912. }
  22913. };
  22914. this.minuteKeyDownHandler = (event) => {
  22915. const key = event.key;
  22916. if (numberKeys.includes(key)) {
  22917. const keyAsNumber = parseInt(key);
  22918. let newMinute;
  22919. if (isValidNumber(this.minute) && this.minute.startsWith("0")) {
  22920. const minuteAsNumber = parseInt(this.minute);
  22921. newMinute =
  22922. minuteAsNumber > maxTenthForMinuteAndSecond
  22923. ? keyAsNumber
  22924. : `${minuteAsNumber}${keyAsNumber}`;
  22925. }
  22926. else {
  22927. newMinute = keyAsNumber;
  22928. }
  22929. this.setValuePart("minute", newMinute);
  22930. }
  22931. else {
  22932. switch (key) {
  22933. case "Backspace":
  22934. case "Delete":
  22935. this.setValuePart("minute", null);
  22936. break;
  22937. case "ArrowDown":
  22938. event.preventDefault();
  22939. this.decrementMinute();
  22940. break;
  22941. case "ArrowUp":
  22942. event.preventDefault();
  22943. this.incrementMinute();
  22944. break;
  22945. case " ":
  22946. case "Spacebar":
  22947. event.preventDefault();
  22948. break;
  22949. }
  22950. }
  22951. };
  22952. this.minuteUpButtonKeyDownHandler = (event) => {
  22953. if (this.buttonActivated(event)) {
  22954. this.incrementMinute();
  22955. }
  22956. };
  22957. this.secondDownButtonKeyDownHandler = (event) => {
  22958. if (this.buttonActivated(event)) {
  22959. this.decrementSecond();
  22960. }
  22961. };
  22962. this.secondKeyDownHandler = (event) => {
  22963. const key = event.key;
  22964. if (numberKeys.includes(key)) {
  22965. const keyAsNumber = parseInt(key);
  22966. let newSecond;
  22967. if (isValidNumber(this.second) && this.second.startsWith("0")) {
  22968. const secondAsNumber = parseInt(this.second);
  22969. newSecond =
  22970. secondAsNumber > maxTenthForMinuteAndSecond
  22971. ? keyAsNumber
  22972. : `${secondAsNumber}${keyAsNumber}`;
  22973. }
  22974. else {
  22975. newSecond = keyAsNumber;
  22976. }
  22977. this.setValuePart("second", newSecond);
  22978. }
  22979. else {
  22980. switch (key) {
  22981. case "Backspace":
  22982. case "Delete":
  22983. this.setValuePart("second", null);
  22984. break;
  22985. case "ArrowDown":
  22986. event.preventDefault();
  22987. this.decrementSecond();
  22988. break;
  22989. case "ArrowUp":
  22990. event.preventDefault();
  22991. this.incrementSecond();
  22992. break;
  22993. case " ":
  22994. case "Spacebar":
  22995. event.preventDefault();
  22996. break;
  22997. }
  22998. }
  22999. };
  23000. this.secondUpButtonKeyDownHandler = (event) => {
  23001. if (this.buttonActivated(event)) {
  23002. this.incrementSecond();
  23003. }
  23004. };
  23005. this.setHourEl = (el) => (this.hourEl = el);
  23006. this.setMeridiemEl = (el) => (this.meridiemEl = el);
  23007. this.setMinuteEl = (el) => (this.minuteEl = el);
  23008. this.setSecondEl = (el) => (this.secondEl = el);
  23009. this.setValue = (value, emit = true) => {
  23010. if (isValidTime(value)) {
  23011. const { hour, minute, second } = parseTimeString(value);
  23012. const { localizedHour, localizedHourSuffix, localizedMinute, localizedMinuteSuffix, localizedSecond, localizedSecondSuffix, localizedMeridiem } = localizeTimeStringToParts(value, this.locale);
  23013. this.localizedHour = localizedHour;
  23014. this.localizedHourSuffix = localizedHourSuffix;
  23015. this.localizedMinute = localizedMinute;
  23016. this.localizedMinuteSuffix = localizedMinuteSuffix;
  23017. this.localizedSecond = localizedSecond;
  23018. this.localizedSecondSuffix = localizedSecondSuffix;
  23019. this.hour = hour;
  23020. this.minute = minute;
  23021. this.second = second;
  23022. if (localizedMeridiem) {
  23023. this.localizedMeridiem = localizedMeridiem;
  23024. this.meridiem = getMeridiem(this.hour);
  23025. const formatParts = getTimeParts(value, this.locale);
  23026. this.meridiemOrder = this.getMeridiemOrder(formatParts);
  23027. }
  23028. }
  23029. else {
  23030. this.hour = null;
  23031. this.localizedHour = null;
  23032. this.localizedHourSuffix = null;
  23033. this.localizedMeridiem = null;
  23034. this.localizedMinute = null;
  23035. this.localizedMinuteSuffix = null;
  23036. this.localizedSecond = null;
  23037. this.localizedSecondSuffix = null;
  23038. this.meridiem = null;
  23039. this.minute = null;
  23040. this.second = null;
  23041. this.value = null;
  23042. }
  23043. if (emit) {
  23044. this.calciteTimePickerChange.emit();
  23045. }
  23046. };
  23047. this.setValuePart = (key, value, emit = true) => {
  23048. var _a;
  23049. if (key === "meridiem") {
  23050. this.meridiem = value;
  23051. if (isValidNumber(this.hour)) {
  23052. const hourAsNumber = parseInt(this.hour);
  23053. switch (value) {
  23054. case "AM":
  23055. if (hourAsNumber >= 12) {
  23056. this.hour = formatTimePart(hourAsNumber - 12);
  23057. }
  23058. break;
  23059. case "PM":
  23060. if (hourAsNumber < 12) {
  23061. this.hour = formatTimePart(hourAsNumber + 12);
  23062. }
  23063. break;
  23064. }
  23065. this.localizedHour = localizeTimePart(this.hour, "hour", this.locale);
  23066. }
  23067. }
  23068. else {
  23069. this[key] = typeof value === "number" ? formatTimePart(value) : value;
  23070. this[`localized${capitalize(key)}`] = localizeTimePart(this[key], key, this.locale);
  23071. }
  23072. if (this.hour && this.minute) {
  23073. const showSeconds = this.second && this.showSecond;
  23074. this.value = `${this.hour}:${this.minute}:${showSeconds ? this.second : "00"}`;
  23075. }
  23076. else {
  23077. this.value = null;
  23078. }
  23079. this.localizedMeridiem = this.value
  23080. ? ((_a = localizeTimeStringToParts(this.value, this.locale)) === null || _a === void 0 ? void 0 : _a.localizedMeridiem) || null
  23081. : localizeTimePart(this.meridiem, "meridiem", this.locale);
  23082. if (emit) {
  23083. this.calciteTimePickerChange.emit();
  23084. }
  23085. };
  23086. }
  23087. localeWatcher(newLocale) {
  23088. this.hourCycle = getLocaleHourCycle(newLocale);
  23089. this.setValue(this.value, false);
  23090. }
  23091. valueWatcher(newValue) {
  23092. this.setValue(newValue, false);
  23093. }
  23094. //--------------------------------------------------------------------------
  23095. //
  23096. // Event Listeners
  23097. //
  23098. //--------------------------------------------------------------------------
  23099. hostBlurHandler() {
  23100. this.calciteTimePickerBlur.emit();
  23101. }
  23102. hostFocusHandler() {
  23103. this.calciteTimePickerFocus.emit();
  23104. }
  23105. keyDownHandler(event) {
  23106. const key = event.key;
  23107. switch (this.activeEl) {
  23108. case this.hourEl:
  23109. if (key === "ArrowRight") {
  23110. this.setFocus("minute");
  23111. }
  23112. break;
  23113. case this.minuteEl:
  23114. switch (key) {
  23115. case "ArrowLeft":
  23116. this.setFocus("hour");
  23117. break;
  23118. case "ArrowRight":
  23119. if (this.step !== 60) {
  23120. this.setFocus("second");
  23121. }
  23122. else if (this.hourCycle === "12") {
  23123. this.setFocus("meridiem");
  23124. }
  23125. break;
  23126. }
  23127. break;
  23128. case this.secondEl:
  23129. switch (key) {
  23130. case "ArrowLeft":
  23131. this.setFocus("minute");
  23132. break;
  23133. case "ArrowRight":
  23134. if (this.hourCycle === "12") {
  23135. this.setFocus("meridiem");
  23136. }
  23137. break;
  23138. }
  23139. break;
  23140. case this.meridiemEl:
  23141. switch (key) {
  23142. case "ArrowLeft":
  23143. if (this.step !== 60) {
  23144. this.setFocus("second");
  23145. }
  23146. else {
  23147. this.setFocus("minute");
  23148. }
  23149. break;
  23150. }
  23151. break;
  23152. }
  23153. }
  23154. //--------------------------------------------------------------------------
  23155. //
  23156. // Public Methods
  23157. //
  23158. //--------------------------------------------------------------------------
  23159. /** Sets focus on the component. */
  23160. async setFocus(target) {
  23161. var _a;
  23162. (_a = this[`${target || "hour"}El`]) === null || _a === void 0 ? void 0 : _a.focus();
  23163. }
  23164. // --------------------------------------------------------------------------
  23165. //
  23166. // Private Methods
  23167. //
  23168. // --------------------------------------------------------------------------
  23169. buttonActivated(event) {
  23170. const key = event.key;
  23171. if (key === " ") {
  23172. event.preventDefault();
  23173. }
  23174. return isActivationKey(key);
  23175. }
  23176. getMeridiemOrder(formatParts) {
  23177. const isRTLKind = this.locale === "ar" || this.locale === "he";
  23178. if (formatParts && !isRTLKind) {
  23179. const index = formatParts.findIndex((parts) => {
  23180. return parts.value === this.localizedMeridiem;
  23181. });
  23182. return index;
  23183. }
  23184. return 0;
  23185. }
  23186. // --------------------------------------------------------------------------
  23187. //
  23188. // Lifecycle
  23189. //
  23190. // --------------------------------------------------------------------------
  23191. connectedCallback() {
  23192. this.setValue(this.value, false);
  23193. this.hourCycle = getLocaleHourCycle(this.locale);
  23194. }
  23195. // --------------------------------------------------------------------------
  23196. //
  23197. // Render Methods
  23198. //
  23199. // --------------------------------------------------------------------------
  23200. render() {
  23201. const hourIsNumber = isValidNumber(this.hour);
  23202. const iconScale = this.scale === "s" || this.scale === "m" ? "s" : "m";
  23203. const minuteIsNumber = isValidNumber(this.minute);
  23204. const secondIsNumber = isValidNumber(this.second);
  23205. const showMeridiem = this.hourCycle === "12";
  23206. return (h("div", { class: {
  23207. [CSS$5.timePicker]: true,
  23208. [CSS$5.showMeridiem]: showMeridiem,
  23209. [CSS$5.showSecond]: this.showSecond,
  23210. [CSS$5[`scale-${this.scale}`]]: true
  23211. }, dir: "ltr" }, h("div", { class: CSS$5.column, role: "group" }, h("span", { "aria-label": this.intlHourUp, class: {
  23212. [CSS$5.button]: true,
  23213. [CSS$5.buttonHourUp]: true,
  23214. [CSS$5.buttonTopLeft]: true
  23215. }, 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: {
  23216. [CSS$5.input]: true,
  23217. [CSS$5.hour]: true
  23218. }, onFocus: this.focusHandler, onKeyDown: this.hourKeyDownHandler, ref: this.setHourEl, role: "spinbutton", tabIndex: 0 }, this.localizedHour || "--"), h("span", { "aria-label": this.intlHourDown, class: {
  23219. [CSS$5.button]: true,
  23220. [CSS$5.buttonHourDown]: true,
  23221. [CSS$5.buttonBottomLeft]: true
  23222. }, 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: {
  23223. [CSS$5.button]: true,
  23224. [CSS$5.buttonMinuteUp]: true
  23225. }, 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: {
  23226. [CSS$5.input]: true,
  23227. [CSS$5.minute]: true
  23228. }, onFocus: this.focusHandler, onKeyDown: this.minuteKeyDownHandler, ref: this.setMinuteEl, role: "spinbutton", tabIndex: 0 }, this.localizedMinute || "--"), h("span", { "aria-label": this.intlMinuteDown, class: {
  23229. [CSS$5.button]: true,
  23230. [CSS$5.buttonMinuteDown]: true
  23231. }, 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: {
  23232. [CSS$5.button]: true,
  23233. [CSS$5.buttonSecondUp]: true
  23234. }, 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: {
  23235. [CSS$5.input]: true,
  23236. [CSS$5.second]: true
  23237. }, onFocus: this.focusHandler, onKeyDown: this.secondKeyDownHandler, ref: this.setSecondEl, role: "spinbutton", tabIndex: 0 }, this.localizedSecond || "--"), h("span", { "aria-label": this.intlSecondDown, class: {
  23238. [CSS$5.button]: true,
  23239. [CSS$5.buttonSecondDown]: true
  23240. }, 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: {
  23241. [CSS$5.column]: true,
  23242. [CSS$5.meridiemStart]: this.meridiemOrder === 0
  23243. }, role: "group" }, h("span", { "aria-label": this.intlMeridiemUp, class: {
  23244. [CSS$5.button]: true,
  23245. [CSS$5.buttonMeridiemUp]: true,
  23246. [CSS$5.buttonTopRight]: true
  23247. }, 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: {
  23248. [CSS$5.input]: true,
  23249. [CSS$5.meridiem]: true
  23250. }, onFocus: this.focusHandler, onKeyDown: this.meridiemKeyDownHandler, ref: this.setMeridiemEl, role: "spinbutton", tabIndex: 0 }, this.localizedMeridiem || "--"), h("span", { "aria-label": this.intlMeridiemDown, class: {
  23251. [CSS$5.button]: true,
  23252. [CSS$5.buttonMeridiemDown]: true,
  23253. [CSS$5.buttonBottomRight]: true
  23254. }, onClick: this.decrementMeridiem, onKeyDown: this.meridiemDownButtonKeyDownHandler, role: "button", tabIndex: -1 }, h("calcite-icon", { icon: "chevron-down", scale: iconScale }))))));
  23255. }
  23256. get el() { return this; }
  23257. static get watchers() { return {
  23258. "locale": ["localeWatcher"],
  23259. "value": ["valueWatcher"]
  23260. }; }
  23261. static get style() { return timePickerCss; }
  23262. };
  23263. const CSS$4 = {
  23264. header: "header",
  23265. heading: "heading",
  23266. close: "close",
  23267. container: "container",
  23268. tipContainer: "tip-container",
  23269. tipContainerAdvancing: "tip-container--advancing",
  23270. tipContainerRetreating: "tip-container--retreating",
  23271. pagination: "pagination",
  23272. pagePosition: "page-position",
  23273. pageNext: "page-next",
  23274. pagePrevious: "page-previous"
  23275. };
  23276. const ICONS$3 = {
  23277. chevronLeft: "chevron-left",
  23278. chevronRight: "chevron-right",
  23279. close: "x"
  23280. };
  23281. const TEXT$1 = {
  23282. defaultGroupTitle: "Tips",
  23283. defaultPaginationLabel: "Tip",
  23284. close: "Close",
  23285. previous: "Previous",
  23286. next: "Next"
  23287. };
  23288. const HEADING_LEVEL$1 = 2;
  23289. const CSS$3 = {
  23290. container: "container",
  23291. header: "header",
  23292. heading: "heading",
  23293. close: "close",
  23294. imageFrame: "image-frame",
  23295. content: "content",
  23296. info: "info"
  23297. };
  23298. const ICONS$2 = {
  23299. close: "x"
  23300. };
  23301. const SLOTS$2 = {
  23302. thumbnail: "thumbnail"
  23303. };
  23304. const TEXT = {
  23305. close: "Close"
  23306. };
  23307. const HEADING_LEVEL = (HEADING_LEVEL$1 + 1);
  23308. 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%}";
  23309. const Tip = class extends HTMLElement$1 {
  23310. constructor() {
  23311. super();
  23312. this.__registerHost();
  23313. this.__attachShadow();
  23314. this.calciteTipDismiss = createEvent(this, "calciteTipDismiss", 7);
  23315. // --------------------------------------------------------------------------
  23316. //
  23317. // Properties
  23318. //
  23319. // --------------------------------------------------------------------------
  23320. /**
  23321. * No longer displays the tip.
  23322. */
  23323. this.dismissed = false;
  23324. /**
  23325. * Indicates whether the tip can be dismissed.
  23326. */
  23327. this.nonDismissible = false;
  23328. /**
  23329. * The selected state of the tip if it is being used inside a `calcite-tip-manager`.
  23330. */
  23331. this.selected = false;
  23332. // --------------------------------------------------------------------------
  23333. //
  23334. // Private Methods
  23335. //
  23336. // --------------------------------------------------------------------------
  23337. this.hideTip = () => {
  23338. this.dismissed = true;
  23339. this.calciteTipDismiss.emit();
  23340. };
  23341. }
  23342. // --------------------------------------------------------------------------
  23343. //
  23344. // Lifecycle
  23345. //
  23346. // --------------------------------------------------------------------------
  23347. connectedCallback() {
  23348. connectConditionalSlotComponent(this);
  23349. }
  23350. disconnectedCallback() {
  23351. disconnectConditionalSlotComponent(this);
  23352. }
  23353. // --------------------------------------------------------------------------
  23354. //
  23355. // Render Methods
  23356. //
  23357. // --------------------------------------------------------------------------
  23358. renderHeader() {
  23359. var _a;
  23360. const { heading, headingLevel, el } = this;
  23361. const parentLevel = (_a = el.closest("calcite-tip-manager")) === null || _a === void 0 ? void 0 : _a.headingLevel;
  23362. const relativeLevel = parentLevel ? constrainHeadingLevel(parentLevel + 1) : null;
  23363. const level = headingLevel || relativeLevel || HEADING_LEVEL;
  23364. return heading ? (h("header", { class: CSS$3.header }, h(Heading, { class: CSS$3.heading, level: level }, heading))) : null;
  23365. }
  23366. renderDismissButton() {
  23367. const { nonDismissible, hideTip, intlClose } = this;
  23368. const text = intlClose || TEXT.close;
  23369. return !nonDismissible ? (h("calcite-action", { class: CSS$3.close, icon: ICONS$2.close, onClick: hideTip, scale: "l", text: text })) : null;
  23370. }
  23371. renderImageFrame() {
  23372. const { el } = this;
  23373. return getSlotted(el, SLOTS$2.thumbnail) ? (h("div", { class: CSS$3.imageFrame, key: "thumbnail" }, h("slot", { name: SLOTS$2.thumbnail }))) : null;
  23374. }
  23375. renderInfoNode() {
  23376. return (h("div", { class: CSS$3.info }, h("slot", null)));
  23377. }
  23378. renderContent() {
  23379. return (h("div", { class: CSS$3.content }, this.renderImageFrame(), this.renderInfoNode()));
  23380. }
  23381. render() {
  23382. return (h(Fragment, null, h("article", { class: CSS$3.container }, this.renderHeader(), this.renderContent()), this.renderDismissButton()));
  23383. }
  23384. get el() { return this; }
  23385. static get style() { return tipCss; }
  23386. };
  23387. 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}";
  23388. const TipGroup = class extends HTMLElement$1 {
  23389. constructor() {
  23390. super();
  23391. this.__registerHost();
  23392. this.__attachShadow();
  23393. }
  23394. render() {
  23395. return h("slot", null);
  23396. }
  23397. static get style() { return tipGroupCss; }
  23398. };
  23399. 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)}}";
  23400. const TipManager = class extends HTMLElement$1 {
  23401. constructor() {
  23402. super();
  23403. this.__registerHost();
  23404. this.__attachShadow();
  23405. this.calciteTipManagerToggle = createEvent(this, "calciteTipManagerToggle", 7);
  23406. this.calciteTipManagerClose = createEvent(this, "calciteTipManagerClose", 7);
  23407. // --------------------------------------------------------------------------
  23408. //
  23409. // Properties
  23410. //
  23411. // --------------------------------------------------------------------------
  23412. /**
  23413. * Closed state of the `calcite-tip-manager`.
  23414. */
  23415. this.closed = false;
  23416. this.mutationObserver = createObserver("mutation", () => this.setUpTips());
  23417. this.hideTipManager = () => {
  23418. this.closed = true;
  23419. this.calciteTipManagerToggle.emit();
  23420. this.calciteTipManagerClose.emit();
  23421. };
  23422. this.previousClicked = () => {
  23423. this.previousTip();
  23424. };
  23425. this.nextClicked = () => {
  23426. this.nextTip();
  23427. };
  23428. this.tipManagerKeyUpHandler = (event) => {
  23429. if (event.target !== this.container) {
  23430. return;
  23431. }
  23432. switch (event.key) {
  23433. case "ArrowRight":
  23434. event.preventDefault();
  23435. this.nextTip();
  23436. break;
  23437. case "ArrowLeft":
  23438. event.preventDefault();
  23439. this.previousTip();
  23440. break;
  23441. case "Home":
  23442. event.preventDefault();
  23443. this.selectedIndex = 0;
  23444. break;
  23445. case "End":
  23446. event.preventDefault();
  23447. this.selectedIndex = this.total - 1;
  23448. break;
  23449. }
  23450. };
  23451. this.storeContainerRef = (el) => {
  23452. this.container = el;
  23453. };
  23454. }
  23455. closedChangeHandler() {
  23456. this.direction = null;
  23457. this.calciteTipManagerToggle.emit();
  23458. }
  23459. selectedChangeHandler() {
  23460. this.showSelectedTip();
  23461. this.updateGroupTitle();
  23462. }
  23463. // --------------------------------------------------------------------------
  23464. //
  23465. // Lifecycle
  23466. //
  23467. // --------------------------------------------------------------------------
  23468. connectedCallback() {
  23469. var _a;
  23470. this.setUpTips();
  23471. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
  23472. }
  23473. disconnectedCallback() {
  23474. var _a;
  23475. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  23476. }
  23477. // --------------------------------------------------------------------------
  23478. //
  23479. // Public Methods
  23480. //
  23481. // --------------------------------------------------------------------------
  23482. /** Selects the next tip to display */
  23483. async nextTip() {
  23484. this.direction = "advancing";
  23485. const nextIndex = this.selectedIndex + 1;
  23486. this.selectedIndex = (nextIndex + this.total) % this.total;
  23487. }
  23488. /** Selects the previous tip to display */
  23489. async previousTip() {
  23490. this.direction = "retreating";
  23491. const previousIndex = this.selectedIndex - 1;
  23492. this.selectedIndex = (previousIndex + this.total) % this.total;
  23493. }
  23494. // --------------------------------------------------------------------------
  23495. //
  23496. // Private Methods
  23497. //
  23498. // --------------------------------------------------------------------------
  23499. setUpTips() {
  23500. const tips = Array.from(this.el.querySelectorAll("calcite-tip"));
  23501. this.total = tips.length;
  23502. if (this.total === 0) {
  23503. return;
  23504. }
  23505. const selectedTip = this.el.querySelector("calcite-tip[selected]");
  23506. this.tips = tips;
  23507. this.selectedIndex = selectedTip ? tips.indexOf(selectedTip) : 0;
  23508. tips.forEach((tip) => {
  23509. tip.nonDismissible = true;
  23510. });
  23511. this.showSelectedTip();
  23512. this.updateGroupTitle();
  23513. }
  23514. showSelectedTip() {
  23515. this.tips.forEach((tip, index) => {
  23516. const isSelected = this.selectedIndex === index;
  23517. tip.selected = isSelected;
  23518. tip.hidden = !isSelected;
  23519. });
  23520. }
  23521. updateGroupTitle() {
  23522. const selectedTip = this.tips[this.selectedIndex];
  23523. const tipParent = selectedTip.closest("calcite-tip-group");
  23524. this.groupTitle = (tipParent === null || tipParent === void 0 ? void 0 : tipParent.groupTitle) || this.intlDefaultTitle || TEXT$1.defaultGroupTitle;
  23525. }
  23526. // --------------------------------------------------------------------------
  23527. //
  23528. // Render Methods
  23529. //
  23530. // --------------------------------------------------------------------------
  23531. renderPagination() {
  23532. const dir = getElementDir(this.el);
  23533. const { selectedIndex, tips, total, intlNext, intlPrevious, intlPaginationLabel } = this;
  23534. const nextLabel = intlNext || TEXT$1.next;
  23535. const previousLabel = intlPrevious || TEXT$1.previous;
  23536. const paginationLabel = intlPaginationLabel || TEXT$1.defaultPaginationLabel;
  23537. 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;
  23538. }
  23539. render() {
  23540. const { closed, direction, headingLevel, groupTitle, selectedIndex, intlClose, total } = this;
  23541. const closeLabel = intlClose || TEXT$1.close;
  23542. if (total === 0) {
  23543. return null;
  23544. }
  23545. 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: {
  23546. [CSS$4.tipContainer]: true,
  23547. [CSS$4.tipContainerAdvancing]: !closed && direction === "advancing",
  23548. [CSS$4.tipContainerRetreating]: !closed && direction === "retreating"
  23549. }, key: selectedIndex, tabIndex: 0 }, h("slot", null)), this.renderPagination()));
  23550. }
  23551. get el() { return this; }
  23552. static get watchers() { return {
  23553. "closed": ["closedChangeHandler"],
  23554. "selectedIndex": ["selectedChangeHandler"]
  23555. }; }
  23556. static get style() { return tipManagerCss; }
  23557. };
  23558. const CSS$2 = {
  23559. container: "container",
  23560. arrow: "arrow"
  23561. };
  23562. const TOOLTIP_DELAY_MS = 500;
  23563. const ARIA_DESCRIBED_BY = "aria-describedby";
  23564. class TooltipManager$1 {
  23565. constructor() {
  23566. // --------------------------------------------------------------------------
  23567. //
  23568. // Private Properties
  23569. //
  23570. // --------------------------------------------------------------------------
  23571. this.registeredElements = new WeakMap();
  23572. this.hoverTimeouts = new WeakMap();
  23573. this.registeredElementCount = 0;
  23574. // --------------------------------------------------------------------------
  23575. //
  23576. // Private Methods
  23577. //
  23578. // --------------------------------------------------------------------------
  23579. this.queryTooltip = (composedPath) => {
  23580. const { registeredElements } = this;
  23581. const registeredElement = composedPath.find((pathEl) => registeredElements.has(pathEl));
  23582. return registeredElements.get(registeredElement);
  23583. };
  23584. this.keyDownHandler = (event) => {
  23585. if (event.key === "Escape") {
  23586. const { activeTooltipEl } = this;
  23587. if (activeTooltipEl) {
  23588. this.clearHoverTimeout(activeTooltipEl);
  23589. this.toggleTooltip(activeTooltipEl, false);
  23590. }
  23591. }
  23592. };
  23593. this.mouseEnterShow = (event) => {
  23594. this.hoverEvent(event, true);
  23595. };
  23596. this.mouseLeaveHide = (event) => {
  23597. this.hoverEvent(event, false);
  23598. };
  23599. this.clickHandler = (event) => {
  23600. this.clickedTooltip = this.queryTooltip(event.composedPath());
  23601. };
  23602. this.focusShow = (event) => {
  23603. this.focusEvent(event, true);
  23604. };
  23605. this.blurHide = (event) => {
  23606. this.focusEvent(event, false);
  23607. };
  23608. this.hoverToggle = (tooltip, value) => {
  23609. const { hoverTimeouts } = this;
  23610. hoverTimeouts.delete(tooltip);
  23611. if (value) {
  23612. this.closeExistingTooltip();
  23613. }
  23614. this.toggleTooltip(tooltip, value);
  23615. };
  23616. }
  23617. // --------------------------------------------------------------------------
  23618. //
  23619. // Public Methods
  23620. //
  23621. // --------------------------------------------------------------------------
  23622. registerElement(referenceEl, tooltip) {
  23623. this.registeredElementCount++;
  23624. this.registeredElements.set(referenceEl, tooltip);
  23625. if (this.registeredElementCount === 1) {
  23626. this.addListeners();
  23627. }
  23628. }
  23629. unregisterElement(referenceEl) {
  23630. if (this.registeredElements.delete(referenceEl)) {
  23631. this.registeredElementCount--;
  23632. }
  23633. if (this.registeredElementCount === 0) {
  23634. this.removeListeners();
  23635. }
  23636. }
  23637. addListeners() {
  23638. document.addEventListener("keydown", this.keyDownHandler);
  23639. document.addEventListener("mouseover", this.mouseEnterShow, { capture: true });
  23640. document.addEventListener("mouseout", this.mouseLeaveHide, { capture: true });
  23641. document.addEventListener("pointerdown", this.clickHandler, { capture: true });
  23642. document.addEventListener("focusin", this.focusShow), { capture: true };
  23643. document.addEventListener("focusout", this.blurHide, { capture: true });
  23644. }
  23645. removeListeners() {
  23646. document.removeEventListener("keydown", this.keyDownHandler);
  23647. document.removeEventListener("mouseover", this.mouseEnterShow, { capture: true });
  23648. document.removeEventListener("mouseout", this.mouseLeaveHide, { capture: true });
  23649. document.removeEventListener("pointerdown", this.clickHandler, { capture: true });
  23650. document.removeEventListener("focusin", this.focusShow, { capture: true });
  23651. document.removeEventListener("focusout", this.blurHide, { capture: true });
  23652. }
  23653. clearHoverTimeout(tooltip) {
  23654. const { hoverTimeouts } = this;
  23655. if (hoverTimeouts.has(tooltip)) {
  23656. window.clearTimeout(hoverTimeouts.get(tooltip));
  23657. hoverTimeouts.delete(tooltip);
  23658. }
  23659. }
  23660. closeExistingTooltip() {
  23661. const { activeTooltipEl } = this;
  23662. if (activeTooltipEl) {
  23663. this.toggleTooltip(activeTooltipEl, false);
  23664. }
  23665. }
  23666. focusTooltip(tooltip, value) {
  23667. this.closeExistingTooltip();
  23668. if (value) {
  23669. this.clearHoverTimeout(tooltip);
  23670. }
  23671. this.toggleTooltip(tooltip, value);
  23672. }
  23673. toggleTooltip(tooltip, value) {
  23674. tooltip.open = value;
  23675. if (value) {
  23676. this.activeTooltipEl = tooltip;
  23677. }
  23678. }
  23679. hoverTooltip(tooltip, value) {
  23680. this.clearHoverTimeout(tooltip);
  23681. const { hoverTimeouts } = this;
  23682. const timeoutId = window.setTimeout(() => this.hoverToggle(tooltip, value), TOOLTIP_DELAY_MS );
  23683. hoverTimeouts.set(tooltip, timeoutId);
  23684. }
  23685. activeTooltipHover(event) {
  23686. const { activeTooltipEl, hoverTimeouts } = this;
  23687. const { type } = event;
  23688. if (!activeTooltipEl) {
  23689. return;
  23690. }
  23691. if (type === "mouseover" && event.composedPath().includes(activeTooltipEl)) {
  23692. this.clearHoverTimeout(activeTooltipEl);
  23693. }
  23694. else if (type === "mouseout" && !hoverTimeouts.has(activeTooltipEl)) {
  23695. this.hoverTooltip(activeTooltipEl, false);
  23696. }
  23697. }
  23698. hoverEvent(event, value) {
  23699. const tooltip = this.queryTooltip(event.composedPath());
  23700. this.activeTooltipHover(event);
  23701. if (!tooltip) {
  23702. return;
  23703. }
  23704. this.hoverTooltip(tooltip, value);
  23705. }
  23706. focusEvent(event, value) {
  23707. const tooltip = this.queryTooltip(event.composedPath());
  23708. if (!tooltip || tooltip === this.clickedTooltip) {
  23709. this.clickedTooltip = null;
  23710. return;
  23711. }
  23712. this.focusTooltip(tooltip, value);
  23713. }
  23714. }
  23715. 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)}";
  23716. const manager = new TooltipManager$1();
  23717. const Tooltip = class extends HTMLElement$1 {
  23718. constructor() {
  23719. super();
  23720. this.__registerHost();
  23721. this.__attachShadow();
  23722. /**
  23723. * Offset the position of the tooltip away from the reference element.
  23724. * @default 6
  23725. */
  23726. this.offsetDistance = defaultOffsetDistance;
  23727. /**
  23728. * Offset the position of the tooltip along the reference element.
  23729. */
  23730. this.offsetSkidding = 0;
  23731. /**
  23732. * Display and position the component.
  23733. */
  23734. this.open = false;
  23735. /** Describes the type of positioning to use for the overlaid content. If your element is in a fixed container, use the 'fixed' value. */
  23736. this.overlayPositioning = "absolute";
  23737. /**
  23738. * Determines where the component will be positioned relative to the referenceElement.
  23739. * @see [PopperPlacement](https://github.com/Esri/calcite-components/blob/master/src/utils/popper.ts#L25)
  23740. */
  23741. this.placement = "auto";
  23742. this.guid = `calcite-tooltip-${guid()}`;
  23743. // --------------------------------------------------------------------------
  23744. //
  23745. // Private Methods
  23746. //
  23747. // --------------------------------------------------------------------------
  23748. this.setUpReferenceElement = () => {
  23749. this.removeReferences();
  23750. this.effectiveReferenceElement = this.getReferenceElement();
  23751. const { el, referenceElement, effectiveReferenceElement } = this;
  23752. if (referenceElement && !effectiveReferenceElement) {
  23753. console.warn(`${el.tagName}: reference-element id "${referenceElement}" was not found.`, {
  23754. el
  23755. });
  23756. }
  23757. this.addReferences();
  23758. this.createPopper();
  23759. };
  23760. this.getId = () => {
  23761. return this.el.id || this.guid;
  23762. };
  23763. this.addReferences = () => {
  23764. const { effectiveReferenceElement } = this;
  23765. if (!effectiveReferenceElement) {
  23766. return;
  23767. }
  23768. const id = this.getId();
  23769. effectiveReferenceElement.setAttribute(ARIA_DESCRIBED_BY, id);
  23770. manager.registerElement(effectiveReferenceElement, this.el);
  23771. };
  23772. this.removeReferences = () => {
  23773. const { effectiveReferenceElement } = this;
  23774. if (!effectiveReferenceElement) {
  23775. return;
  23776. }
  23777. effectiveReferenceElement.removeAttribute(ARIA_DESCRIBED_BY);
  23778. manager.unregisterElement(effectiveReferenceElement);
  23779. };
  23780. }
  23781. offsetDistanceOffsetHandler() {
  23782. this.reposition();
  23783. }
  23784. offsetSkiddingHandler() {
  23785. this.reposition();
  23786. }
  23787. openHandler() {
  23788. this.reposition();
  23789. }
  23790. placementHandler() {
  23791. this.reposition();
  23792. }
  23793. referenceElementHandler() {
  23794. this.setUpReferenceElement();
  23795. }
  23796. // --------------------------------------------------------------------------
  23797. //
  23798. // Lifecycle
  23799. //
  23800. // --------------------------------------------------------------------------
  23801. componentWillLoad() {
  23802. this.setUpReferenceElement();
  23803. }
  23804. componentDidLoad() {
  23805. this.reposition();
  23806. }
  23807. disconnectedCallback() {
  23808. this.removeReferences();
  23809. this.destroyPopper();
  23810. }
  23811. // --------------------------------------------------------------------------
  23812. //
  23813. // Public Methods
  23814. //
  23815. // --------------------------------------------------------------------------
  23816. /** Updates the position of the component. */
  23817. async reposition() {
  23818. const { popper, el, placement } = this;
  23819. const modifiers = this.getModifiers();
  23820. popper
  23821. ? await updatePopper({
  23822. el,
  23823. modifiers,
  23824. placement,
  23825. popper
  23826. })
  23827. : this.createPopper();
  23828. }
  23829. getReferenceElement() {
  23830. const { referenceElement, el } = this;
  23831. return ((typeof referenceElement === "string"
  23832. ? queryElementRoots(el, { id: referenceElement })
  23833. : referenceElement) || null);
  23834. }
  23835. getModifiers() {
  23836. const { arrowEl, offsetDistance, offsetSkidding } = this;
  23837. const arrowModifier = {
  23838. name: "arrow",
  23839. enabled: true,
  23840. options: {
  23841. element: arrowEl
  23842. }
  23843. };
  23844. const offsetModifier = {
  23845. name: "offset",
  23846. enabled: true,
  23847. options: {
  23848. offset: [offsetSkidding, offsetDistance]
  23849. }
  23850. };
  23851. const eventListenerModifier = {
  23852. name: "eventListeners",
  23853. enabled: this.open
  23854. };
  23855. return [arrowModifier, offsetModifier, eventListenerModifier];
  23856. }
  23857. createPopper() {
  23858. this.destroyPopper();
  23859. const { el, placement, effectiveReferenceElement: referenceEl, overlayPositioning } = this;
  23860. const modifiers = this.getModifiers();
  23861. this.popper = createPopper({
  23862. el,
  23863. modifiers,
  23864. placement,
  23865. overlayPositioning,
  23866. referenceEl
  23867. });
  23868. }
  23869. destroyPopper() {
  23870. const { popper } = this;
  23871. if (popper) {
  23872. popper.destroy();
  23873. }
  23874. this.popper = null;
  23875. }
  23876. // --------------------------------------------------------------------------
  23877. //
  23878. // Render Methods
  23879. //
  23880. // --------------------------------------------------------------------------
  23881. render() {
  23882. const { effectiveReferenceElement, label, open } = this;
  23883. const displayed = effectiveReferenceElement && open;
  23884. const hidden = !displayed;
  23885. return (h(Host, { "aria-hidden": toAriaBoolean(hidden), "aria-label": label, "calcite-hydrated-hidden": hidden, id: this.getId(), role: "tooltip" }, h("div", { class: {
  23886. [CSS$D.animation]: true,
  23887. [CSS$D.animationActive]: displayed
  23888. } }, h("div", { class: CSS$2.arrow, ref: (arrowEl) => (this.arrowEl = arrowEl) }), h("div", { class: CSS$2.container }, h("slot", null)))));
  23889. }
  23890. get el() { return this; }
  23891. static get watchers() { return {
  23892. "offsetDistance": ["offsetDistanceOffsetHandler"],
  23893. "offsetSkidding": ["offsetSkiddingHandler"],
  23894. "open": ["openHandler"],
  23895. "placement": ["placementHandler"],
  23896. "referenceElement": ["referenceElementHandler"]
  23897. }; }
  23898. static get style() { return tooltipCss; }
  23899. };
  23900. 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}";
  23901. const TooltipManager = class extends HTMLElement$1 {
  23902. constructor() {
  23903. super();
  23904. this.__registerHost();
  23905. this.__attachShadow();
  23906. // --------------------------------------------------------------------------
  23907. //
  23908. // Properties
  23909. //
  23910. // --------------------------------------------------------------------------
  23911. /**
  23912. * CSS Selector to match reference elements for tooltips. Reference elements will be identified by this selector in order to open their associated tooltip.
  23913. * @default `[data-calcite-tooltip-reference]`
  23914. */
  23915. this.selector = "[data-calcite-tooltip-reference]";
  23916. }
  23917. // --------------------------------------------------------------------------
  23918. //
  23919. // Render Methods
  23920. //
  23921. // --------------------------------------------------------------------------
  23922. render() {
  23923. return h("slot", null);
  23924. }
  23925. static get style() { return tooltipManagerCss; }
  23926. };
  23927. var TreeSelectionMode;
  23928. (function (TreeSelectionMode) {
  23929. TreeSelectionMode["Single"] = "single";
  23930. TreeSelectionMode["Multi"] = "multi";
  23931. TreeSelectionMode["Children"] = "children";
  23932. TreeSelectionMode["MultiChildren"] = "multi-children";
  23933. TreeSelectionMode["Ancestors"] = "ancestors";
  23934. })(TreeSelectionMode || (TreeSelectionMode = {}));
  23935. 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}";
  23936. const Tree = class extends HTMLElement$1 {
  23937. constructor() {
  23938. super();
  23939. this.__registerHost();
  23940. this.__attachShadow();
  23941. this.calciteTreeSelect = createEvent(this, "calciteTreeSelect", 7);
  23942. //--------------------------------------------------------------------------
  23943. //
  23944. // Properties
  23945. //
  23946. //--------------------------------------------------------------------------
  23947. /** Display indentation guide lines. */
  23948. this.lines = false;
  23949. /** Display input
  23950. * @deprecated Use "ancestors" selection-mode for checkbox input.
  23951. */
  23952. this.inputEnabled = false;
  23953. /** Specify the scale of the tree. */
  23954. this.scale = "m";
  23955. /** Customize how tree selection works.
  23956. * @default "single"
  23957. * @see [TreeSelectionMode](https://github.com/Esri/calcite-components/blob/master/src/components/tree/interfaces.ts#L5)
  23958. */
  23959. this.selectionMode = TreeSelectionMode.Single;
  23960. }
  23961. //--------------------------------------------------------------------------
  23962. //
  23963. // Lifecycle
  23964. //
  23965. //--------------------------------------------------------------------------
  23966. componentWillRender() {
  23967. const parent = this.el.parentElement.closest("calcite-tree");
  23968. this.lines = parent ? parent.lines : this.lines;
  23969. this.scale = parent ? parent.scale : this.scale;
  23970. this.selectionMode = parent ? parent.selectionMode : this.selectionMode;
  23971. this.child = !!parent;
  23972. }
  23973. render() {
  23974. return (h(Host, { "aria-multiselectable": this.child
  23975. ? undefined
  23976. : (this.selectionMode === TreeSelectionMode.Multi ||
  23977. this.selectionMode === TreeSelectionMode.MultiChildren).toString(), role: !this.child ? "tree" : undefined, tabIndex: this.getRootTabIndex() }, h("slot", null)));
  23978. }
  23979. //--------------------------------------------------------------------------
  23980. //
  23981. // Event Listeners
  23982. //
  23983. //--------------------------------------------------------------------------
  23984. onFocus() {
  23985. if (!this.child) {
  23986. const focusTarget = this.el.querySelector("calcite-tree-item[selected]") ||
  23987. this.el.querySelector("calcite-tree-item");
  23988. focusElement(focusTarget);
  23989. }
  23990. }
  23991. onFocusIn(event) {
  23992. const focusedFromRootOrOutsideTree = event.relatedTarget === this.el || !this.el.contains(event.relatedTarget);
  23993. if (focusedFromRootOrOutsideTree) {
  23994. // gives user the ability to tab into external elements (modifying tabindex property will not work in firefox)
  23995. this.el.removeAttribute("tabindex");
  23996. }
  23997. }
  23998. onFocusOut(event) {
  23999. const willFocusOutsideTree = !this.el.contains(event.relatedTarget);
  24000. if (willFocusOutsideTree) {
  24001. this.el.tabIndex = this.getRootTabIndex();
  24002. }
  24003. }
  24004. onClick(e) {
  24005. const target = e.target;
  24006. const childItems = nodeListToArray(target.querySelectorAll("calcite-tree-item"));
  24007. if (this.child) {
  24008. return;
  24009. }
  24010. if (!this.child) {
  24011. e.preventDefault();
  24012. e.stopPropagation();
  24013. }
  24014. if (this.selectionMode === TreeSelectionMode.Ancestors && !this.child) {
  24015. this.updateAncestorTree(e);
  24016. return;
  24017. }
  24018. const shouldSelect = this.selectionMode !== null &&
  24019. (!target.hasChildren ||
  24020. (target.hasChildren &&
  24021. (this.selectionMode === TreeSelectionMode.Children ||
  24022. this.selectionMode === TreeSelectionMode.MultiChildren)));
  24023. const shouldModifyToCurrentSelection = e.detail.modifyCurrentSelection &&
  24024. (this.selectionMode === TreeSelectionMode.Multi ||
  24025. this.selectionMode === TreeSelectionMode.MultiChildren);
  24026. const shouldSelectChildren = this.selectionMode === TreeSelectionMode.MultiChildren ||
  24027. this.selectionMode === TreeSelectionMode.Children;
  24028. const shouldClearCurrentSelection = !shouldModifyToCurrentSelection &&
  24029. (((this.selectionMode === TreeSelectionMode.Single ||
  24030. this.selectionMode === TreeSelectionMode.Multi) &&
  24031. childItems.length <= 0) ||
  24032. this.selectionMode === TreeSelectionMode.Children ||
  24033. this.selectionMode === TreeSelectionMode.MultiChildren);
  24034. const shouldExpandTarget = this.selectionMode === TreeSelectionMode.Children ||
  24035. this.selectionMode === TreeSelectionMode.MultiChildren;
  24036. if (!this.child) {
  24037. const targetItems = [];
  24038. if (shouldSelect) {
  24039. targetItems.push(target);
  24040. }
  24041. if (shouldSelectChildren) {
  24042. childItems.forEach((treeItem) => {
  24043. targetItems.push(treeItem);
  24044. });
  24045. }
  24046. if (shouldClearCurrentSelection) {
  24047. const selectedItems = nodeListToArray(this.el.querySelectorAll("calcite-tree-item[selected]"));
  24048. selectedItems.forEach((treeItem) => {
  24049. if (!targetItems.includes(treeItem)) {
  24050. treeItem.selected = false;
  24051. }
  24052. });
  24053. }
  24054. if (shouldExpandTarget && !e.detail.forceToggle) {
  24055. target.expanded = true;
  24056. }
  24057. if (shouldModifyToCurrentSelection) {
  24058. window.getSelection().removeAllRanges();
  24059. }
  24060. if ((shouldModifyToCurrentSelection && target.selected) ||
  24061. (shouldSelectChildren && e.detail.forceToggle)) {
  24062. targetItems.forEach((treeItem) => {
  24063. treeItem.selected = false;
  24064. });
  24065. }
  24066. else {
  24067. targetItems.forEach((treeItem) => {
  24068. treeItem.selected = true;
  24069. });
  24070. }
  24071. }
  24072. this.calciteTreeSelect.emit({
  24073. selected: nodeListToArray(this.el.querySelectorAll("calcite-tree-item")).filter((i) => i.selected)
  24074. });
  24075. }
  24076. keyDownHandler(event) {
  24077. var _a;
  24078. const root = this.el.closest("calcite-tree:not([child])");
  24079. const target = event.target;
  24080. if (root === this.el && target.tagName === "CALCITE-TREE-ITEM" && this.el.contains(target)) {
  24081. switch (event.key) {
  24082. case "ArrowDown":
  24083. const next = target.nextElementSibling;
  24084. if (next && next.matches("calcite-tree-item")) {
  24085. next.focus();
  24086. event.preventDefault();
  24087. }
  24088. break;
  24089. case "ArrowLeft":
  24090. // When focus is on an open node, closes the node.
  24091. if (target.hasChildren && target.expanded) {
  24092. target.expanded = false;
  24093. event.preventDefault();
  24094. break;
  24095. }
  24096. // When focus is on a child node that is also either an end node or a closed node, moves focus to its parent node.
  24097. const parentItem = target.parentElement.closest("calcite-tree-item");
  24098. if (parentItem && (!target.hasChildren || target.expanded === false)) {
  24099. parentItem.focus();
  24100. event.preventDefault();
  24101. break;
  24102. }
  24103. // When focus is on a root node that is also either an end node or a closed node, does nothing.
  24104. break;
  24105. case "ArrowRight":
  24106. if (!target.hasChildren) {
  24107. break;
  24108. }
  24109. if (target.expanded && document.activeElement === target) {
  24110. // When focus is on an open node, moves focus to the first child node.
  24111. (_a = target.querySelector("calcite-tree-item")) === null || _a === void 0 ? void 0 : _a.focus();
  24112. event.preventDefault();
  24113. }
  24114. else {
  24115. // When focus is on a closed node, opens the node; focus does not move.
  24116. target.expanded = true;
  24117. event.preventDefault();
  24118. }
  24119. // When focus is on an end node, does nothing.
  24120. break;
  24121. case "ArrowUp":
  24122. const previous = target.previousElementSibling;
  24123. if (previous && previous.matches("calcite-tree-item")) {
  24124. previous.focus();
  24125. event.preventDefault();
  24126. }
  24127. break;
  24128. }
  24129. }
  24130. }
  24131. updateAncestorTree(e) {
  24132. const item = e.target;
  24133. const children = item.querySelectorAll("calcite-tree-item");
  24134. const ancestors = [];
  24135. let parent = item.parentElement.closest("calcite-tree-item");
  24136. while (parent) {
  24137. ancestors.push(parent);
  24138. parent = parent.parentElement.closest("calcite-tree-item");
  24139. }
  24140. item.selected = !item.selected;
  24141. item.indeterminate = false;
  24142. if (children === null || children === void 0 ? void 0 : children.length) {
  24143. children.forEach((el) => {
  24144. el.selected = item.selected;
  24145. el.indeterminate = false;
  24146. });
  24147. }
  24148. if (ancestors) {
  24149. ancestors.forEach((ancestor) => {
  24150. const descendants = nodeListToArray(ancestor.querySelectorAll("calcite-tree-item"));
  24151. const activeDescendants = descendants.filter((el) => el.selected);
  24152. if (activeDescendants.length === 0) {
  24153. ancestor.selected = false;
  24154. ancestor.indeterminate = false;
  24155. return;
  24156. }
  24157. const indeterminate = activeDescendants.length < descendants.length;
  24158. ancestor.indeterminate = indeterminate;
  24159. ancestor.selected = !indeterminate;
  24160. });
  24161. }
  24162. this.calciteTreeSelect.emit({
  24163. selected: nodeListToArray(this.el.querySelectorAll("calcite-tree-item")).filter((i) => i.selected)
  24164. });
  24165. }
  24166. // --------------------------------------------------------------------------
  24167. //
  24168. // Private Methods
  24169. //
  24170. //--------------------------------------------------------------------------
  24171. getRootTabIndex() {
  24172. return !this.child ? 0 : -1;
  24173. }
  24174. get el() { return this; }
  24175. static get style() { return treeCss; }
  24176. };
  24177. const CSS$1 = {
  24178. checkboxLabel: "checkbox-label",
  24179. checkbox: "checkbox",
  24180. chevron: "chevron",
  24181. nodeContainer: "node-container",
  24182. childrenContainer: "children-container",
  24183. bulletPointIcon: "bullet-point",
  24184. checkmarkIcon: "checkmark"
  24185. };
  24186. const SLOTS$1 = {
  24187. children: "children"
  24188. };
  24189. const ICONS$1 = {
  24190. bulletPoint: "bullet-point",
  24191. checkmark: "check",
  24192. chevronRight: "chevron-right"
  24193. };
  24194. 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)}";
  24195. const TreeItem = class extends HTMLElement$1 {
  24196. constructor() {
  24197. super();
  24198. this.__registerHost();
  24199. this.__attachShadow();
  24200. this.calciteTreeItemSelect = createEvent(this, "calciteTreeItemSelect", 7);
  24201. //--------------------------------------------------------------------------
  24202. //
  24203. // Properties
  24204. //
  24205. //--------------------------------------------------------------------------
  24206. /** Selected state of the item. */
  24207. this.selected = false;
  24208. /** Expanded state of the item. */
  24209. this.expanded = false;
  24210. /** @internal Expanded state of the parent. */
  24211. this.parentExpanded = false;
  24212. /** @internal Level of depth of the item. */
  24213. this.depth = -1;
  24214. /** @internal Does this tree item have a tree inside it? */
  24215. this.hasChildren = null;
  24216. this.iconClickHandler = (event) => {
  24217. event.stopPropagation();
  24218. this.expanded = !this.expanded;
  24219. };
  24220. this.childrenClickHandler = (event) => event.stopPropagation();
  24221. //--------------------------------------------------------------------------
  24222. //
  24223. // Private Methods
  24224. //
  24225. //--------------------------------------------------------------------------
  24226. this.updateParentIsExpanded = (el, expanded) => {
  24227. const items = getSlotted(el, SLOTS$1.children, {
  24228. all: true,
  24229. selector: "calcite-tree-item"
  24230. });
  24231. items.forEach((item) => (item.parentExpanded = expanded));
  24232. };
  24233. this.updateAncestorTree = () => {
  24234. if (this.selected && this.selectionMode === TreeSelectionMode.Ancestors) {
  24235. const ancestors = [];
  24236. let parent = this.parentTreeItem;
  24237. while (parent) {
  24238. ancestors.push(parent);
  24239. parent = parent.parentElement.closest("calcite-tree-item");
  24240. }
  24241. ancestors.forEach((item) => (item.indeterminate = true));
  24242. return;
  24243. }
  24244. };
  24245. }
  24246. expandedHandler(newValue) {
  24247. this.updateParentIsExpanded(this.el, newValue);
  24248. }
  24249. getselectionMode() {
  24250. this.isSelectionMultiLike =
  24251. this.selectionMode === TreeSelectionMode.Multi ||
  24252. this.selectionMode === TreeSelectionMode.MultiChildren;
  24253. }
  24254. //--------------------------------------------------------------------------
  24255. //
  24256. // Lifecycle
  24257. //
  24258. //--------------------------------------------------------------------------
  24259. connectedCallback() {
  24260. this.parentTreeItem = this.el.parentElement.closest("calcite-tree-item");
  24261. if (this.parentTreeItem) {
  24262. const { expanded } = this.parentTreeItem;
  24263. this.updateParentIsExpanded(this.parentTreeItem, expanded);
  24264. }
  24265. connectConditionalSlotComponent(this);
  24266. }
  24267. disconnectedCallback() {
  24268. disconnectConditionalSlotComponent(this);
  24269. }
  24270. componentWillRender() {
  24271. this.hasChildren = !!this.el.querySelector("calcite-tree");
  24272. this.depth = 0;
  24273. let parentTree = this.el.closest("calcite-tree");
  24274. if (!parentTree) {
  24275. return;
  24276. }
  24277. this.selectionMode = parentTree.selectionMode;
  24278. this.scale = parentTree.scale || "m";
  24279. this.lines = parentTree.lines;
  24280. let nextParentTree;
  24281. while (parentTree) {
  24282. nextParentTree = parentTree.parentElement.closest("calcite-tree");
  24283. if (nextParentTree === parentTree) {
  24284. break;
  24285. }
  24286. else {
  24287. parentTree = nextParentTree;
  24288. this.depth = this.depth + 1;
  24289. }
  24290. }
  24291. }
  24292. componentDidLoad() {
  24293. this.updateAncestorTree();
  24294. }
  24295. render() {
  24296. const rtl = getElementDir(this.el) === "rtl";
  24297. const showBulletPoint = this.selectionMode === TreeSelectionMode.Single ||
  24298. this.selectionMode === TreeSelectionMode.Children;
  24299. const showCheckmark = this.selectionMode === TreeSelectionMode.Multi ||
  24300. this.selectionMode === TreeSelectionMode.MultiChildren;
  24301. const chevron = this.hasChildren ? (h("calcite-icon", { class: {
  24302. [CSS$1.chevron]: true,
  24303. [CSS_UTILITY.rtl]: rtl
  24304. }, "data-test-id": "icon", icon: ICONS$1.chevronRight, onClick: this.iconClickHandler, scale: "s" })) : null;
  24305. const defaultSlotNode = h("slot", { key: "default-slot" });
  24306. 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;
  24307. const selectedIcon = showBulletPoint
  24308. ? ICONS$1.bulletPoint
  24309. : showCheckmark
  24310. ? ICONS$1.checkmark
  24311. : null;
  24312. const bulletOrCheckIcon = selectedIcon ? (h("calcite-icon", { class: {
  24313. [CSS$1.bulletPointIcon]: selectedIcon === ICONS$1.bulletPoint,
  24314. [CSS$1.checkmarkIcon]: selectedIcon === ICONS$1.checkmark,
  24315. [CSS_UTILITY.rtl]: rtl
  24316. }, icon: selectedIcon, scale: "s" })) : null;
  24317. const hidden = !(this.parentExpanded || this.depth === 1);
  24318. 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: {
  24319. [CSS$1.nodeContainer]: true,
  24320. [CSS_UTILITY.rtl]: rtl
  24321. }, "data-selection-mode": this.selectionMode, ref: (el) => (this.defaultSlotWrapper = el) }, chevron, bulletOrCheckIcon, checkbox ? checkbox : defaultSlotNode), h("div", { class: {
  24322. [CSS$1.childrenContainer]: true,
  24323. [CSS_UTILITY.rtl]: rtl
  24324. }, "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 }))));
  24325. }
  24326. //--------------------------------------------------------------------------
  24327. //
  24328. // Event Listeners
  24329. //
  24330. //--------------------------------------------------------------------------
  24331. onClick(e) {
  24332. // Solve for if the item is clicked somewhere outside the slotted anchor.
  24333. // Anchor is triggered anywhere you click
  24334. const [link] = filterDirectChildren(this.el, "a");
  24335. if (link && e.composedPath()[0].tagName.toLowerCase() !== "a") {
  24336. const target = link.target === "" ? "_self" : link.target;
  24337. window.open(link.href, target);
  24338. }
  24339. this.calciteTreeItemSelect.emit({
  24340. modifyCurrentSelection: this.selectionMode === TreeSelectionMode.Ancestors || this.isSelectionMultiLike,
  24341. forceToggle: false
  24342. });
  24343. }
  24344. keyDownHandler(e) {
  24345. let root;
  24346. switch (e.key) {
  24347. case " ":
  24348. this.calciteTreeItemSelect.emit({
  24349. modifyCurrentSelection: this.isSelectionMultiLike,
  24350. forceToggle: false
  24351. });
  24352. e.preventDefault();
  24353. break;
  24354. case "Enter":
  24355. // 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.
  24356. const link = nodeListToArray(this.el.children).find((e) => e.matches("a"));
  24357. if (link) {
  24358. link.click();
  24359. this.selected = true;
  24360. }
  24361. else {
  24362. this.calciteTreeItemSelect.emit({
  24363. modifyCurrentSelection: this.isSelectionMultiLike,
  24364. forceToggle: false
  24365. });
  24366. }
  24367. e.preventDefault();
  24368. break;
  24369. case "Home":
  24370. root = this.el.closest("calcite-tree:not([child])");
  24371. const firstNode = root.querySelector("calcite-tree-item");
  24372. firstNode.focus();
  24373. break;
  24374. case "End":
  24375. root = this.el.closest("calcite-tree:not([child])");
  24376. let currentNode = root.children[root.children.length - 1]; // last child
  24377. let currentTree = nodeListToArray(currentNode.children).find((e) => e.matches("calcite-tree"));
  24378. while (currentTree) {
  24379. currentNode = currentTree.children[root.children.length - 1];
  24380. currentTree = nodeListToArray(currentNode.children).find((e) => e.matches("calcite-tree"));
  24381. }
  24382. currentNode.focus();
  24383. break;
  24384. }
  24385. }
  24386. get el() { return this; }
  24387. static get watchers() { return {
  24388. "expanded": ["expandedHandler"],
  24389. "selectionMode": ["getselectionMode"]
  24390. }; }
  24391. static get style() { return treeItemCss; }
  24392. };
  24393. const CSS = {
  24394. container: "container",
  24395. handle: "handle"
  24396. };
  24397. var ICON_TYPES;
  24398. (function (ICON_TYPES) {
  24399. ICON_TYPES["grip"] = "grip";
  24400. })(ICON_TYPES || (ICON_TYPES = {}));
  24401. 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}";
  24402. const ValueList = class extends HTMLElement$1 {
  24403. constructor() {
  24404. super();
  24405. this.__registerHost();
  24406. this.__attachShadow();
  24407. this.calciteListChange = createEvent(this, "calciteListChange", 7);
  24408. this.calciteListOrderChange = createEvent(this, "calciteListOrderChange", 7);
  24409. // --------------------------------------------------------------------------
  24410. //
  24411. // Properties
  24412. //
  24413. // --------------------------------------------------------------------------
  24414. /**
  24415. * When true, prevents user interaction. This state shows list items grayed out and with lower opacity.
  24416. */
  24417. this.disabled = false;
  24418. /**
  24419. * When true, list items are sortable via a draggable button.
  24420. */
  24421. this.dragEnabled = false;
  24422. /**
  24423. * When true, an input appears at the top of the list that can be used by end users to filter list items.
  24424. */
  24425. this.filterEnabled = false;
  24426. /**
  24427. * When true, content is waiting to be loaded. This state shows a busy indicator.
  24428. */
  24429. this.loading = false;
  24430. /**
  24431. * Similar to standard radio buttons and checkboxes.
  24432. * When true, a user can select multiple list items at a time.
  24433. * When false, only a single list item can be selected at a time,
  24434. * and selecting a new list item will deselect any other selected list items.
  24435. */
  24436. this.multiple = false;
  24437. /**
  24438. * When true and single-selection is enabled, the selection changes when navigating list items via the keyboard.
  24439. */
  24440. this.selectionFollowsFocus = false;
  24441. // --------------------------------------------------------------------------
  24442. //
  24443. // Private Properties
  24444. //
  24445. // --------------------------------------------------------------------------
  24446. this.selectedValues = new Map();
  24447. this.dataForFilter = [];
  24448. this.lastSelectedItem = null;
  24449. this.mutationObserver = createObserver("mutation", mutationObserverCallback.bind(this));
  24450. this.setFilterEl = (el) => {
  24451. this.filterEl = el;
  24452. };
  24453. this.deselectRemovedItems = deselectRemovedItems.bind(this);
  24454. this.deselectSiblingItems = deselectSiblingItems.bind(this);
  24455. this.selectSiblings = selectSiblings.bind(this);
  24456. this.handleFilter = handleFilter.bind(this);
  24457. this.getItemData = getItemData.bind(this);
  24458. this.keyDownHandler = (event) => {
  24459. const handleElement = event
  24460. .composedPath()
  24461. .find((item) => { var _a; return ((_a = item.dataset) === null || _a === void 0 ? void 0 : _a.jsHandle) !== undefined; });
  24462. const item = event
  24463. .composedPath()
  24464. .find((item) => { var _a; return ((_a = item.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "calcite-value-list-item"; });
  24465. // Only trigger keyboard sorting when the internal drag handle is focused and activated
  24466. if (!handleElement || !item.handleActivated) {
  24467. keyDownHandler.call(this, event);
  24468. return;
  24469. }
  24470. const { items } = this;
  24471. if ((event.key !== "ArrowUp" && event.key !== "ArrowDown") || items.length <= 1) {
  24472. return;
  24473. }
  24474. event.preventDefault();
  24475. const { el } = this;
  24476. const nextIndex = moveItemIndex(this, item, event.key === "ArrowUp" ? "up" : "down");
  24477. if (nextIndex === items.length - 1) {
  24478. el.appendChild(item);
  24479. }
  24480. else {
  24481. const itemAtNextIndex = el.children[nextIndex];
  24482. const insertionReferenceItem = itemAtNextIndex === item.nextElementSibling
  24483. ? itemAtNextIndex.nextElementSibling
  24484. : itemAtNextIndex;
  24485. el.insertBefore(item, insertionReferenceItem);
  24486. }
  24487. this.items = this.getItems();
  24488. this.calciteListOrderChange.emit(this.items.map(({ value }) => value));
  24489. requestAnimationFrame(() => handleElement.focus());
  24490. item.handleActivated = true;
  24491. };
  24492. }
  24493. // --------------------------------------------------------------------------
  24494. //
  24495. // Lifecycle
  24496. //
  24497. // --------------------------------------------------------------------------
  24498. connectedCallback() {
  24499. initialize.call(this);
  24500. initializeObserver.call(this);
  24501. }
  24502. componentDidLoad() {
  24503. this.setUpDragAndDrop();
  24504. }
  24505. componentDidRender() {
  24506. updateHostInteraction(this);
  24507. }
  24508. disconnectedCallback() {
  24509. cleanUpObserver.call(this);
  24510. this.cleanUpDragAndDrop();
  24511. }
  24512. calciteListFocusOutHandler(event) {
  24513. calciteListFocusOutHandler.call(this, event);
  24514. }
  24515. calciteListItemRemoveHandler(event) {
  24516. removeItem.call(this, event);
  24517. }
  24518. calciteListItemChangeHandler(event) {
  24519. calciteListItemChangeHandler.call(this, event);
  24520. }
  24521. calciteListItemPropsChangeHandler(event) {
  24522. event.stopPropagation();
  24523. this.setUpFilter();
  24524. }
  24525. calciteListItemValueChangeHandler(event) {
  24526. calciteListItemValueChangeHandler.call(this, event);
  24527. }
  24528. // --------------------------------------------------------------------------
  24529. //
  24530. // Private Methods
  24531. //
  24532. // --------------------------------------------------------------------------
  24533. getItems() {
  24534. return Array.from(this.el.querySelectorAll("calcite-value-list-item"));
  24535. }
  24536. setUpItems() {
  24537. setUpItems.call(this, "calcite-value-list-item");
  24538. }
  24539. setUpFilter() {
  24540. if (this.filterEnabled) {
  24541. this.dataForFilter = this.getItemData();
  24542. }
  24543. }
  24544. setUpDragAndDrop() {
  24545. this.cleanUpDragAndDrop();
  24546. if (!this.dragEnabled) {
  24547. return;
  24548. }
  24549. this.sortable = Sortable.create(this.el, {
  24550. dataIdAttr: "id",
  24551. handle: `.${CSS.handle}`,
  24552. draggable: "calcite-value-list-item",
  24553. group: this.group,
  24554. onSort: () => {
  24555. this.items = Array.from(this.el.querySelectorAll("calcite-value-list-item"));
  24556. const values = this.items.map((item) => item.value);
  24557. this.calciteListOrderChange.emit(values);
  24558. }
  24559. });
  24560. }
  24561. cleanUpDragAndDrop() {
  24562. var _a;
  24563. (_a = this.sortable) === null || _a === void 0 ? void 0 : _a.destroy();
  24564. this.sortable = null;
  24565. }
  24566. // --------------------------------------------------------------------------
  24567. //
  24568. // Public Methods
  24569. //
  24570. // --------------------------------------------------------------------------
  24571. /** Returns the currently selected items */
  24572. async getSelectedItems() {
  24573. return this.selectedValues;
  24574. }
  24575. /** Sets focus on the component. */
  24576. async setFocus(focusId) {
  24577. return setFocus.call(this, focusId);
  24578. }
  24579. // --------------------------------------------------------------------------
  24580. //
  24581. // Render Methods
  24582. //
  24583. // --------------------------------------------------------------------------
  24584. getIconType() {
  24585. let type = null;
  24586. if (this.dragEnabled) {
  24587. type = ICON_TYPES.grip;
  24588. }
  24589. return type;
  24590. }
  24591. render() {
  24592. return h(List, { onKeyDown: this.keyDownHandler, props: this });
  24593. }
  24594. get el() { return this; }
  24595. static get style() { return valueListCss; }
  24596. };
  24597. const ICONS = {
  24598. drag: "drag"
  24599. };
  24600. const SLOTS = {
  24601. actionsEnd: "actions-end",
  24602. actionsStart: "actions-start"
  24603. };
  24604. 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}";
  24605. const ValueListItem = class extends HTMLElement$1 {
  24606. constructor() {
  24607. super();
  24608. this.__registerHost();
  24609. this.__attachShadow();
  24610. this.calciteListItemRemove = createEvent(this, "calciteListItemRemove", 7);
  24611. /**
  24612. * When true, the list item cannot be clicked and is visually muted.
  24613. */
  24614. this.disabled = false;
  24615. /**
  24616. * @internal When false, the list item cannot be deselected by user interaction.
  24617. */
  24618. this.disableDeselect = false;
  24619. /**
  24620. * When true, prevents the content of the list item from user interaction.
  24621. */
  24622. this.nonInteractive = false;
  24623. /**
  24624. * @internal - Stores the activated state of the drag handle.
  24625. */
  24626. this.handleActivated = false;
  24627. /**
  24628. * Determines the icon SVG symbol that will be shown. Options are circle, square, grip or null.
  24629. * @see [ICON_TYPES](https://github.com/Esri/calcite-components/blob/master/src/components/pick-list/resources.ts#L5)
  24630. */
  24631. this.icon = null;
  24632. /**
  24633. * When true, adds an action to remove the list item.
  24634. */
  24635. this.removable = false;
  24636. /**
  24637. * When true, preselects the list item. Toggles when an item is checked/unchecked.
  24638. */
  24639. this.selected = false;
  24640. this.pickListItem = null;
  24641. this.guid = `calcite-value-list-item-${guid()}`;
  24642. // --------------------------------------------------------------------------
  24643. //
  24644. // Private Methods
  24645. //
  24646. // --------------------------------------------------------------------------
  24647. this.getPickListRef = (el) => (this.pickListItem = el);
  24648. this.handleKeyDown = (event) => {
  24649. if (event.key === " ") {
  24650. this.handleActivated = !this.handleActivated;
  24651. }
  24652. };
  24653. this.handleBlur = () => {
  24654. this.handleActivated = false;
  24655. };
  24656. this.handleSelectChange = (event) => {
  24657. this.selected = event.detail.selected;
  24658. };
  24659. }
  24660. // --------------------------------------------------------------------------
  24661. //
  24662. // Lifecycle
  24663. //
  24664. // --------------------------------------------------------------------------
  24665. connectedCallback() {
  24666. connectConditionalSlotComponent(this);
  24667. }
  24668. disconnectedCallback() {
  24669. disconnectConditionalSlotComponent(this);
  24670. }
  24671. componentDidRender() {
  24672. updateHostInteraction(this, this.el.closest("calcite-value-list") ? "managed" : false);
  24673. }
  24674. // --------------------------------------------------------------------------
  24675. //
  24676. // Public Methods
  24677. //
  24678. // --------------------------------------------------------------------------
  24679. /**
  24680. * Toggle the selection state. By default this won't trigger an event.
  24681. * The first argument allows the value to be coerced, rather than swapping values.
  24682. */
  24683. async toggleSelected(coerce) {
  24684. this.pickListItem.toggleSelected(coerce);
  24685. }
  24686. /** Set focus on the component. */
  24687. async setFocus() {
  24688. var _a;
  24689. (_a = this.pickListItem) === null || _a === void 0 ? void 0 : _a.setFocus();
  24690. }
  24691. calciteListItemChangeHandler(event) {
  24692. // adjust item payload from wrapped item before bubbling
  24693. event.detail.item = this.el;
  24694. }
  24695. // --------------------------------------------------------------------------
  24696. //
  24697. // Render Methods
  24698. //
  24699. // --------------------------------------------------------------------------
  24700. renderActionsEnd() {
  24701. const { el } = this;
  24702. const hasActionsEnd = getSlotted(el, SLOTS.actionsEnd);
  24703. return hasActionsEnd ? (h("slot", { name: SLOTS.actionsEnd, slot: SLOTS$9.actionsEnd })) : null;
  24704. }
  24705. renderActionsStart() {
  24706. const { el } = this;
  24707. const hasActionsStart = getSlotted(el, SLOTS.actionsStart);
  24708. return hasActionsStart ? (h("slot", { name: SLOTS.actionsStart, slot: SLOTS$9.actionsStart })) : null;
  24709. }
  24710. renderHandle() {
  24711. const { icon } = this;
  24712. if (icon === ICON_TYPES$1.grip) {
  24713. return (h("span", { "aria-pressed": toAriaBoolean(this.handleActivated), class: {
  24714. [CSS$h.handle]: true,
  24715. [CSS$h.handleActivated]: this.handleActivated
  24716. }, "data-js-handle": true, onBlur: this.handleBlur, onKeyDown: this.handleKeyDown, role: "button", tabindex: "0" }, h("calcite-icon", { icon: ICONS.drag, scale: "s" })));
  24717. }
  24718. }
  24719. render() {
  24720. 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())));
  24721. }
  24722. get el() { return this; }
  24723. static get style() { return valueListItemCss; }
  24724. };
  24725. 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"]]]);
  24726. 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"]]]);
  24727. 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"]}]);
  24728. 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]}]);
  24729. 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]}]);
  24730. 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"]]]);
  24731. 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]}]);
  24732. 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"]]]);
  24733. const CalciteAvatar = /*@__PURE__*/proxyCustomElement(Avatar, [1,"calcite-avatar",{"scale":[513],"thumbnail":[1],"fullName":[1,"full-name"],"username":[1],"userId":[1,"user-id"],"error":[32]}]);
  24734. 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]}]);
  24735. 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"]}]);
  24736. 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]}]);
  24737. 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"]}]);
  24738. 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]}]);
  24739. 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]}]);
  24740. 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"]]]);
  24741. 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"]]]);
  24742. const CalciteColorPickerSwatch = /*@__PURE__*/proxyCustomElement(ColorPickerSwatch, [1,"calcite-color-picker-swatch",{"active":[516],"color":[1],"scale":[513]}]);
  24743. 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"]]]);
  24744. 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]}]);
  24745. const CalciteComboboxItemGroup = /*@__PURE__*/proxyCustomElement(ComboboxItemGroup, [1,"calcite-combobox-item-group",{"ancestors":[1040],"label":[1]}]);
  24746. 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]}]);
  24747. 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"]]]);
  24748. 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"]]]);
  24749. 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]}]);
  24750. 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"]]]);
  24751. const CalciteDropdownGroup = /*@__PURE__*/proxyCustomElement(DropdownGroup, [1,"calcite-dropdown-group",{"groupTitle":[513,"group-title"],"selectionMode":[513,"selection-mode"],"scale":[513]},[[0,"calciteDropdownItemSelect","updateActiveItemOnChange"]]]);
  24752. 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"]]]);
  24753. 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"]}]);
  24754. 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]}]);
  24755. const CalciteFlow = /*@__PURE__*/proxyCustomElement(Flow, [1,"calcite-flow",{"panelCount":[32],"flowDirection":[32],"panels":[32]},[[0,"calcitePanelBackClick","handleCalcitePanelBackClick"]]]);
  24756. const CalciteGraph = /*@__PURE__*/proxyCustomElement(Graph, [1,"calcite-graph",{"data":[16],"colorStops":[16],"highlightMin":[2,"highlight-min"],"highlightMax":[2,"highlight-max"],"min":[2],"max":[2]}]);
  24757. const CalciteHandle = /*@__PURE__*/proxyCustomElement(Handle, [1,"calcite-handle",{"activated":[1540],"textTitle":[513,"text-title"]}]);
  24758. const CalciteIcon = /*@__PURE__*/proxyCustomElement(Icon, [1,"calcite-icon",{"icon":[513],"flipRtl":[516,"flip-rtl"],"scale":[513],"textLabel":[1,"text-label"],"pathData":[32],"visible":[32]}]);
  24759. 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"]]]);
  24760. 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]}]);
  24761. 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"]]]);
  24762. const CalciteInputMessage = /*@__PURE__*/proxyCustomElement(InputMessage, [1,"calcite-input-message",{"active":[516],"icon":[520],"scale":[1537],"status":[1537],"type":[513]}]);
  24763. 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"]]]);
  24764. const CalciteLabel = /*@__PURE__*/proxyCustomElement(Label, [1,"calcite-label",{"alignment":[513],"status":[513],"for":[513],"scale":[513],"layout":[513],"disableSpacing":[4,"disable-spacing"],"disabled":[516]}]);
  24765. 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]}]);
  24766. const CalciteList = /*@__PURE__*/proxyCustomElement(List$1, [1,"calcite-list",{"disabled":[516],"headingLevel":[2,"heading-level"]}]);
  24767. const CalciteListItem = /*@__PURE__*/proxyCustomElement(ListItem, [1,"calcite-list-item",{"nonInteractive":[516,"non-interactive"],"description":[1],"disabled":[516],"label":[1]}]);
  24768. const CalciteListItemGroup = /*@__PURE__*/proxyCustomElement(ListItemGroup, [1,"calcite-list-item-group",{"heading":[513],"headingLevel":[2,"heading-level"]}]);
  24769. 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"]}]);
  24770. 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"]]]);
  24771. const CalciteNotice = /*@__PURE__*/proxyCustomElement(Notice, [1,"calcite-notice",{"active":[1540],"color":[513],"dismissible":[516],"icon":[520],"intlClose":[1,"intl-close"],"scale":[513],"width":[513]}]);
  24772. const CalciteOption = /*@__PURE__*/proxyCustomElement(Option, [1,"calcite-option",{"disabled":[516],"label":[1025],"selected":[516],"value":[1032]}]);
  24773. const CalciteOptionGroup = /*@__PURE__*/proxyCustomElement(OptionGroup, [1,"calcite-option-group",{"disabled":[516],"label":[1]}]);
  24774. 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]}]);
  24775. 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"]}]);
  24776. 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"]]]);
  24777. const CalcitePickListGroup = /*@__PURE__*/proxyCustomElement(PickListGroup, [1,"calcite-pick-list-group",{"groupTitle":[513,"group-title"],"headingLevel":[2,"heading-level"]}]);
  24778. 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]}]);
  24779. 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]}]);
  24780. const CalcitePopoverManager = /*@__PURE__*/proxyCustomElement(PopoverManager, [1,"calcite-popover-manager",{"selector":[1],"autoClose":[516,"auto-close"]}]);
  24781. const CalciteProgress = /*@__PURE__*/proxyCustomElement(Progress, [1,"calcite-progress",{"type":[1],"value":[2],"label":[1],"text":[1],"reversed":[4]}]);
  24782. 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"]]]);
  24783. 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"]]]);
  24784. 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"]]]);
  24785. 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]}]);
  24786. 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"]]]);
  24787. const CalciteScrim = /*@__PURE__*/proxyCustomElement(Scrim, [1,"calcite-scrim",{"intlLoading":[1,"intl-loading"],"loading":[516]}]);
  24788. 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"]]]);
  24789. const CalciteShell = /*@__PURE__*/proxyCustomElement(Shell, [1,"calcite-shell",{"contentBehind":[516,"content-behind"]}]);
  24790. const CalciteShellCenterRow = /*@__PURE__*/proxyCustomElement(ShellCenterRow, [1,"calcite-shell-center-row",{"detached":[516],"heightScale":[513,"height-scale"],"position":[513]}]);
  24791. 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]}]);
  24792. 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"]]]);
  24793. 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"]]]);
  24794. 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]}]);
  24795. 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"]]]);
  24796. 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"]]]);
  24797. const CalciteSwitch = /*@__PURE__*/proxyCustomElement(Switch, [1,"calcite-switch",{"disabled":[516],"label":[1],"name":[513],"scale":[513],"switched":[1028],"checked":[1540],"value":[8]}]);
  24798. const CalciteTab = /*@__PURE__*/proxyCustomElement(Tab, [1,"calcite-tab",{"tab":[513],"active":[1540],"scale":[1537],"labeledBy":[32]},[[16,"calciteInternalTabChange","internalTabChangeHandler"]]]);
  24799. 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"]]]);
  24800. 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"]]]);
  24801. 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"]]]);
  24802. 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]}]);
  24803. 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"]]]);
  24804. const CalciteTileSelectGroup = /*@__PURE__*/proxyCustomElement(TileSelectGroup, [1,"calcite-tile-select-group",{"disabled":[516],"layout":[513]}]);
  24805. 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"]]]);
  24806. 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"]}]);
  24807. const CalciteTipGroup = /*@__PURE__*/proxyCustomElement(TipGroup, [1,"calcite-tip-group",{"groupTitle":[1,"group-title"]}]);
  24808. 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]}]);
  24809. 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]}]);
  24810. const CalciteTooltipManager = /*@__PURE__*/proxyCustomElement(TooltipManager, [1,"calcite-tooltip-manager",{"selector":[1]}]);
  24811. 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"]]]);
  24812. 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"]]]);
  24813. 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"]]]);
  24814. 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"]]]);
  24815. const defineCustomElements = (opts) => {
  24816. if (typeof customElements !== 'undefined') {
  24817. [
  24818. CalciteAccordion,
  24819. CalciteAccordionItem,
  24820. CalciteAction,
  24821. CalciteActionBar,
  24822. CalciteActionGroup,
  24823. CalciteActionMenu,
  24824. CalciteActionPad,
  24825. CalciteAlert,
  24826. CalciteAvatar,
  24827. CalciteBlock,
  24828. CalciteBlockSection,
  24829. CalciteButton,
  24830. CalciteCard,
  24831. CalciteCheckbox,
  24832. CalciteChip,
  24833. CalciteColorPicker,
  24834. CalciteColorPickerHexInput,
  24835. CalciteColorPickerSwatch,
  24836. CalciteCombobox,
  24837. CalciteComboboxItem,
  24838. CalciteComboboxItemGroup,
  24839. CalciteDatePicker,
  24840. CalciteDatePickerDay,
  24841. CalciteDatePickerMonth,
  24842. CalciteDatePickerMonthHeader,
  24843. CalciteDropdown,
  24844. CalciteDropdownGroup,
  24845. CalciteDropdownItem,
  24846. CalciteFab,
  24847. CalciteFilter,
  24848. CalciteFlow,
  24849. CalciteGraph,
  24850. CalciteHandle,
  24851. CalciteIcon,
  24852. CalciteInlineEditable,
  24853. CalciteInput,
  24854. CalciteInputDatePicker,
  24855. CalciteInputMessage,
  24856. CalciteInputTimePicker,
  24857. CalciteLabel,
  24858. CalciteLink,
  24859. CalciteList,
  24860. CalciteListItem,
  24861. CalciteListItemGroup,
  24862. CalciteLoader,
  24863. CalciteModal,
  24864. CalciteNotice,
  24865. CalciteOption,
  24866. CalciteOptionGroup,
  24867. CalcitePagination,
  24868. CalcitePanel,
  24869. CalcitePickList,
  24870. CalcitePickListGroup,
  24871. CalcitePickListItem,
  24872. CalcitePopover,
  24873. CalcitePopoverManager,
  24874. CalciteProgress,
  24875. CalciteRadioButton,
  24876. CalciteRadioButtonGroup,
  24877. CalciteRadioGroup,
  24878. CalciteRadioGroupItem,
  24879. CalciteRating,
  24880. CalciteScrim,
  24881. CalciteSelect,
  24882. CalciteShell,
  24883. CalciteShellCenterRow,
  24884. CalciteShellPanel,
  24885. CalciteSlider,
  24886. CalciteSortableList,
  24887. CalciteSplitButton,
  24888. CalciteStepper,
  24889. CalciteStepperItem,
  24890. CalciteSwitch,
  24891. CalciteTab,
  24892. CalciteTabNav,
  24893. CalciteTabTitle,
  24894. CalciteTabs,
  24895. CalciteTile,
  24896. CalciteTileSelect,
  24897. CalciteTileSelectGroup,
  24898. CalciteTimePicker,
  24899. CalciteTip,
  24900. CalciteTipGroup,
  24901. CalciteTipManager,
  24902. CalciteTooltip,
  24903. CalciteTooltipManager,
  24904. CalciteTree,
  24905. CalciteTreeItem,
  24906. CalciteValueList,
  24907. CalciteValueListItem
  24908. ].forEach(cmp => {
  24909. if (!customElements.get(cmp.is)) {
  24910. customElements.define(cmp.is, cmp, opts);
  24911. }
  24912. });
  24913. }
  24914. };
  24915. 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 };