handsontable.full.js 1.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582
  1. /*!
  2. * (The MIT License)
  3. *
  4. * Copyright (c) 2012-2014 Marcin Warpechowski
  5. * Copyright (c) 2015 Handsoncode sp. z o.o. <[email protected]>
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining
  8. * a copy of this software and associated documentation files (the
  9. * 'Software'), to deal in the Software without restriction, including
  10. * without limitation the rights to use, copy, modify, merge, publish,
  11. * distribute, sublicense, and/or sell copies of the Software, and to
  12. * permit persons to whom the Software is furnished to do so, subject to
  13. * the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be
  16. * included in all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
  19. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  21. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  22. * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  23. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  24. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. *
  26. * Version: 2.0.0
  27. * Release date: 11/04/2018 (built at 10/04/2018 11:38:33)
  28. */
  29. (function webpackUniversalModuleDefinition(root, factory) {
  30. if(typeof exports === 'object' && typeof module === 'object')
  31. module.exports = factory();
  32. else if(typeof define === 'function' && define.amd)
  33. define("Handsontable", [], factory);
  34. else if(typeof exports === 'object')
  35. exports["Handsontable"] = factory();
  36. else
  37. root["Handsontable"] = factory();
  38. })(typeof self !== 'undefined' ? self : this, function() {
  39. return /******/ (function(modules) { // webpackBootstrap
  40. /******/ // The module cache
  41. /******/ var installedModules = {};
  42. /******/
  43. /******/ // The require function
  44. /******/ function __webpack_require__(moduleId) {
  45. /******/
  46. /******/ // Check if module is in cache
  47. /******/ if(installedModules[moduleId]) {
  48. /******/ return installedModules[moduleId].exports;
  49. /******/ }
  50. /******/ // Create a new module (and put it into the cache)
  51. /******/ var module = installedModules[moduleId] = {
  52. /******/ i: moduleId,
  53. /******/ l: false,
  54. /******/ exports: {}
  55. /******/ };
  56. /******/
  57. /******/ // Execute the module function
  58. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  59. /******/
  60. /******/ // Flag the module as loaded
  61. /******/ module.l = true;
  62. /******/
  63. /******/ // Return the exports of the module
  64. /******/ return module.exports;
  65. /******/ }
  66. /******/
  67. /******/
  68. /******/ // expose the modules object (__webpack_modules__)
  69. /******/ __webpack_require__.m = modules;
  70. /******/
  71. /******/ // expose the module cache
  72. /******/ __webpack_require__.c = installedModules;
  73. /******/
  74. /******/ // define getter function for harmony exports
  75. /******/ __webpack_require__.d = function(exports, name, getter) {
  76. /******/ if(!__webpack_require__.o(exports, name)) {
  77. /******/ Object.defineProperty(exports, name, {
  78. /******/ configurable: false,
  79. /******/ enumerable: true,
  80. /******/ get: getter
  81. /******/ });
  82. /******/ }
  83. /******/ };
  84. /******/
  85. /******/ // getDefaultExport function for compatibility with non-harmony modules
  86. /******/ __webpack_require__.n = function(module) {
  87. /******/ var getter = module && module.__esModule ?
  88. /******/ function getDefault() { return module['default']; } :
  89. /******/ function getModuleExports() { return module; };
  90. /******/ __webpack_require__.d(getter, 'a', getter);
  91. /******/ return getter;
  92. /******/ };
  93. /******/
  94. /******/ // Object.prototype.hasOwnProperty.call
  95. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  96. /******/
  97. /******/ // __webpack_public_path__
  98. /******/ __webpack_require__.p = "";
  99. /******/
  100. /******/ // Load entry module and return exports
  101. /******/ return __webpack_require__(__webpack_require__.s = 326);
  102. /******/ })
  103. /************************************************************************/
  104. /******/ ([
  105. /* 0 */
  106. /***/ (function(module, exports, __webpack_require__) {
  107. "use strict";
  108. exports.__esModule = true;
  109. exports.HTML_CHARACTERS = undefined;
  110. exports.getParent = getParent;
  111. exports.closest = closest;
  112. exports.closestDown = closestDown;
  113. exports.isChildOf = isChildOf;
  114. exports.isChildOfWebComponentTable = isChildOfWebComponentTable;
  115. exports.polymerWrap = polymerWrap;
  116. exports.polymerUnwrap = polymerUnwrap;
  117. exports.index = index;
  118. exports.overlayContainsElement = overlayContainsElement;
  119. exports.hasClass = hasClass;
  120. exports.addClass = addClass;
  121. exports.removeClass = removeClass;
  122. exports.removeTextNodes = removeTextNodes;
  123. exports.empty = empty;
  124. exports.fastInnerHTML = fastInnerHTML;
  125. exports.fastInnerText = fastInnerText;
  126. exports.isVisible = isVisible;
  127. exports.offset = offset;
  128. exports.getWindowScrollTop = getWindowScrollTop;
  129. exports.getWindowScrollLeft = getWindowScrollLeft;
  130. exports.getScrollTop = getScrollTop;
  131. exports.getScrollLeft = getScrollLeft;
  132. exports.getScrollableElement = getScrollableElement;
  133. exports.getTrimmingContainer = getTrimmingContainer;
  134. exports.getStyle = getStyle;
  135. exports.getComputedStyle = getComputedStyle;
  136. exports.outerWidth = outerWidth;
  137. exports.outerHeight = outerHeight;
  138. exports.innerHeight = innerHeight;
  139. exports.innerWidth = innerWidth;
  140. exports.addEvent = addEvent;
  141. exports.removeEvent = removeEvent;
  142. exports.getCaretPosition = getCaretPosition;
  143. exports.getSelectionEndPosition = getSelectionEndPosition;
  144. exports.getSelectionText = getSelectionText;
  145. exports.setCaretPosition = setCaretPosition;
  146. exports.getScrollbarWidth = getScrollbarWidth;
  147. exports.hasVerticalScrollbar = hasVerticalScrollbar;
  148. exports.hasHorizontalScrollbar = hasHorizontalScrollbar;
  149. exports.setOverlayPosition = setOverlayPosition;
  150. exports.getCssTransform = getCssTransform;
  151. exports.resetCssTransform = resetCssTransform;
  152. exports.isInput = isInput;
  153. exports.isOutsideInput = isOutsideInput;
  154. var _browser = __webpack_require__(27);
  155. var _feature = __webpack_require__(40);
  156. /**
  157. * Get the parent of the specified node in the DOM tree.
  158. *
  159. * @param {HTMLElement} element Element from which traversing is started.
  160. * @param {Number} [level=0] Traversing deep level.
  161. * @return {HTMLElement|null}
  162. */
  163. function getParent(element) {
  164. var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  165. var iteration = -1;
  166. var parent = null;
  167. while (element != null) {
  168. if (iteration === level) {
  169. parent = element;
  170. break;
  171. }
  172. if (element.host && element.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
  173. element = element.host;
  174. } else {
  175. iteration++;
  176. element = element.parentNode;
  177. }
  178. }
  179. return parent;
  180. }
  181. /**
  182. * Goes up the DOM tree (including given element) until it finds an element that matches the nodes or nodes name.
  183. * This method goes up through web components.
  184. *
  185. * @param {HTMLElement} element Element from which traversing is started
  186. * @param {Array} nodes Array of elements or Array of elements name
  187. * @param {HTMLElement} [until]
  188. * @returns {HTMLElement|null}
  189. */
  190. function closest(element, nodes, until) {
  191. while (element != null && element !== until) {
  192. if (element.nodeType === Node.ELEMENT_NODE && (nodes.indexOf(element.nodeName) > -1 || nodes.indexOf(element) > -1)) {
  193. return element;
  194. }
  195. if (element.host && element.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
  196. element = element.host;
  197. } else {
  198. element = element.parentNode;
  199. }
  200. }
  201. return null;
  202. }
  203. /**
  204. * Goes "down" the DOM tree (including given element) until it finds an element that matches the nodes or nodes name.
  205. *
  206. * @param {HTMLElement} element Element from which traversing is started
  207. * @param {Array} nodes Array of elements or Array of elements name
  208. * @param {HTMLElement} [until]
  209. * @returns {HTMLElement|null}
  210. */
  211. function closestDown(element, nodes, until) {
  212. var matched = [];
  213. while (element) {
  214. element = closest(element, nodes, until);
  215. if (!element || until && !until.contains(element)) {
  216. break;
  217. }
  218. matched.push(element);
  219. if (element.host && element.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
  220. element = element.host;
  221. } else {
  222. element = element.parentNode;
  223. }
  224. }
  225. var length = matched.length;
  226. return length ? matched[length - 1] : null;
  227. }
  228. /**
  229. * Goes up the DOM tree and checks if element is child of another element.
  230. *
  231. * @param child Child element
  232. * @param {Object|String} parent Parent element OR selector of the parent element.
  233. * If string provided, function returns `true` for the first occurrence of element with that class.
  234. * @returns {Boolean}
  235. */
  236. function isChildOf(child, parent) {
  237. var node = child.parentNode;
  238. var queriedParents = [];
  239. if (typeof parent === 'string') {
  240. queriedParents = Array.prototype.slice.call(document.querySelectorAll(parent), 0);
  241. } else {
  242. queriedParents.push(parent);
  243. }
  244. while (node != null) {
  245. if (queriedParents.indexOf(node) > -1) {
  246. return true;
  247. }
  248. node = node.parentNode;
  249. }
  250. return false;
  251. }
  252. /**
  253. * Check if an element is part of `hot-table` web component.
  254. *
  255. * @param {Element} element
  256. * @returns {Boolean}
  257. */
  258. function isChildOfWebComponentTable(element) {
  259. var hotTableName = 'hot-table',
  260. result = false,
  261. parentNode;
  262. parentNode = polymerWrap(element);
  263. function isHotTable(element) {
  264. return element.nodeType === Node.ELEMENT_NODE && element.nodeName === hotTableName.toUpperCase();
  265. }
  266. while (parentNode != null) {
  267. if (isHotTable(parentNode)) {
  268. result = true;
  269. break;
  270. } else if (parentNode.host && parentNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
  271. result = isHotTable(parentNode.host);
  272. if (result) {
  273. break;
  274. }
  275. parentNode = parentNode.host;
  276. }
  277. parentNode = parentNode.parentNode;
  278. }
  279. return result;
  280. }
  281. /**
  282. * Wrap element into polymer/webcomponent container if exists
  283. *
  284. * @param element
  285. * @returns {*}
  286. */
  287. function polymerWrap(element) {
  288. /* global Polymer */
  289. return typeof Polymer !== 'undefined' && typeof wrap === 'function' ? wrap(element) : element;
  290. }
  291. /**
  292. * Unwrap element from polymer/webcomponent container if exists
  293. *
  294. * @param element
  295. * @returns {*}
  296. */
  297. function polymerUnwrap(element) {
  298. /* global Polymer */
  299. return typeof Polymer !== 'undefined' && typeof unwrap === 'function' ? unwrap(element) : element;
  300. }
  301. /**
  302. * Counts index of element within its parent
  303. * WARNING: for performance reasons, assumes there are only element nodes (no text nodes). This is true for Walkotnable
  304. * Otherwise would need to check for nodeType or use previousElementSibling
  305. *
  306. * @see http://jsperf.com/sibling-index/10
  307. * @param {Element} element
  308. * @return {Number}
  309. */
  310. function index(element) {
  311. var i = 0;
  312. if (element.previousSibling) {
  313. /* eslint-disable no-cond-assign */
  314. while (element = element.previousSibling) {
  315. ++i;
  316. }
  317. }
  318. return i;
  319. }
  320. /**
  321. * Check if the provided overlay contains the provided element
  322. *
  323. * @param {String} overlay
  324. * @param {HTMLElement} element
  325. * @returns {boolean}
  326. */
  327. function overlayContainsElement(overlayType, element) {
  328. var overlayElement = document.querySelector('.ht_clone_' + overlayType);
  329. return overlayElement ? overlayElement.contains(element) : null;
  330. }
  331. var classListSupport = !!document.documentElement.classList;
  332. var _hasClass, _addClass, _removeClass;
  333. function filterEmptyClassNames(classNames) {
  334. var result = [];
  335. if (!classNames || !classNames.length) {
  336. return result;
  337. }
  338. var len = 0;
  339. while (classNames[len]) {
  340. result.push(classNames[len]);
  341. len++;
  342. }
  343. return result;
  344. }
  345. if (classListSupport) {
  346. var isSupportMultipleClassesArg = function () {
  347. var element = document.createElement('div');
  348. element.classList.add('test', 'test2');
  349. return element.classList.contains('test2');
  350. }();
  351. _hasClass = function _hasClass(element, className) {
  352. if (element.classList === void 0 || typeof className !== 'string' || className === '') {
  353. return false;
  354. }
  355. return element.classList.contains(className);
  356. };
  357. _addClass = function _addClass(element, className) {
  358. if (typeof className === 'string') {
  359. className = className.split(' ');
  360. }
  361. className = filterEmptyClassNames(className);
  362. if (className.length > 0) {
  363. if (isSupportMultipleClassesArg) {
  364. element.classList.add.apply(element.classList, className);
  365. } else {
  366. var len = 0;
  367. while (className && className[len]) {
  368. element.classList.add(className[len]);
  369. len++;
  370. }
  371. }
  372. }
  373. };
  374. _removeClass = function _removeClass(element, className) {
  375. if (typeof className === 'string') {
  376. className = className.split(' ');
  377. }
  378. className = filterEmptyClassNames(className);
  379. if (className.length > 0) {
  380. if (isSupportMultipleClassesArg) {
  381. element.classList.remove.apply(element.classList, className);
  382. } else {
  383. var len = 0;
  384. while (className && className[len]) {
  385. element.classList.remove(className[len]);
  386. len++;
  387. }
  388. }
  389. }
  390. };
  391. } else {
  392. var createClassNameRegExp = function createClassNameRegExp(className) {
  393. return new RegExp('(\\s|^)' + className + '(\\s|$)');
  394. };
  395. _hasClass = function _hasClass(element, className) {
  396. // http://snipplr.com/view/3561/addclass-removeclass-hasclass/
  397. return element.className !== void 0 && createClassNameRegExp(className).test(element.className);
  398. };
  399. _addClass = function _addClass(element, className) {
  400. var len = 0,
  401. _className = element.className;
  402. if (typeof className === 'string') {
  403. className = className.split(' ');
  404. }
  405. if (_className === '') {
  406. _className = className.join(' ');
  407. } else {
  408. while (className && className[len]) {
  409. if (!createClassNameRegExp(className[len]).test(_className)) {
  410. _className += ' ' + className[len];
  411. }
  412. len++;
  413. }
  414. }
  415. element.className = _className;
  416. };
  417. _removeClass = function _removeClass(element, className) {
  418. var len = 0,
  419. _className = element.className;
  420. if (typeof className === 'string') {
  421. className = className.split(' ');
  422. }
  423. while (className && className[len]) {
  424. // String.prototype.trim is defined in polyfill.js
  425. _className = _className.replace(createClassNameRegExp(className[len]), ' ').trim();
  426. len++;
  427. }
  428. if (element.className !== _className) {
  429. element.className = _className;
  430. }
  431. };
  432. }
  433. /**
  434. * Checks if element has class name
  435. *
  436. * @param {HTMLElement} element
  437. * @param {String} className Class name to check
  438. * @returns {Boolean}
  439. */
  440. function hasClass(element, className) {
  441. return _hasClass(element, className);
  442. }
  443. /**
  444. * Add class name to an element
  445. *
  446. * @param {HTMLElement} element
  447. * @param {String|Array} className Class name as string or array of strings
  448. */
  449. function addClass(element, className) {
  450. return _addClass(element, className);
  451. }
  452. /**
  453. * Remove class name from an element
  454. *
  455. * @param {HTMLElement} element
  456. * @param {String|Array} className Class name as string or array of strings
  457. */
  458. function removeClass(element, className) {
  459. return _removeClass(element, className);
  460. }
  461. function removeTextNodes(element, parent) {
  462. if (element.nodeType === 3) {
  463. parent.removeChild(element); // bye text nodes!
  464. } else if (['TABLE', 'THEAD', 'TBODY', 'TFOOT', 'TR'].indexOf(element.nodeName) > -1) {
  465. var childs = element.childNodes;
  466. for (var i = childs.length - 1; i >= 0; i--) {
  467. removeTextNodes(childs[i], element);
  468. }
  469. }
  470. }
  471. /**
  472. * Remove childs function
  473. * WARNING - this doesn't unload events and data attached by jQuery
  474. * http://jsperf.com/jquery-html-vs-empty-vs-innerhtml/9
  475. * http://jsperf.com/jquery-html-vs-empty-vs-innerhtml/11 - no siginificant improvement with Chrome remove() method
  476. *
  477. * @param element
  478. * @returns {void}
  479. */
  480. //
  481. function empty(element) {
  482. var child;
  483. /* eslint-disable no-cond-assign */
  484. while (child = element.lastChild) {
  485. element.removeChild(child);
  486. }
  487. }
  488. var HTML_CHARACTERS = exports.HTML_CHARACTERS = /(<(.*)>|&(.*);)/;
  489. /**
  490. * Insert content into element trying avoid innerHTML method.
  491. * @return {void}
  492. */
  493. function fastInnerHTML(element, content) {
  494. if (HTML_CHARACTERS.test(content)) {
  495. element.innerHTML = content;
  496. } else {
  497. fastInnerText(element, content);
  498. }
  499. }
  500. /**
  501. * Insert text content into element
  502. * @return {void}
  503. */
  504. var textContextSupport = !!document.createTextNode('test').textContent;
  505. function fastInnerText(element, content) {
  506. var child = element.firstChild;
  507. if (child && child.nodeType === 3 && child.nextSibling === null) {
  508. // fast lane - replace existing text node
  509. if (textContextSupport) {
  510. // http://jsperf.com/replace-text-vs-reuse
  511. child.textContent = content;
  512. } else {
  513. // http://jsperf.com/replace-text-vs-reuse
  514. child.data = content;
  515. }
  516. } else {
  517. // slow lane - empty element and insert a text node
  518. empty(element);
  519. element.appendChild(document.createTextNode(content));
  520. }
  521. }
  522. /**
  523. * Returns true if element is attached to the DOM and visible, false otherwise
  524. * @param elem
  525. * @returns {boolean}
  526. */
  527. function isVisible(elem) {
  528. var next = elem;
  529. while (polymerUnwrap(next) !== document.documentElement) {
  530. // until <html> reached
  531. if (next === null) {
  532. // parent detached from DOM
  533. return false;
  534. } else if (next.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
  535. if (next.host) {
  536. // this is Web Components Shadow DOM
  537. // see: http://w3c.github.io/webcomponents/spec/shadow/#encapsulation
  538. // according to spec, should be if (next.ownerDocument !== window.document), but that doesn't work yet
  539. if (next.host.impl) {
  540. // Chrome 33.0.1723.0 canary (2013-11-29) Web Platform features disabled
  541. return isVisible(next.host.impl);
  542. } else if (next.host) {
  543. // Chrome 33.0.1723.0 canary (2013-11-29) Web Platform features enabled
  544. return isVisible(next.host);
  545. }
  546. throw new Error('Lost in Web Components world');
  547. } else {
  548. return false; // this is a node detached from document in IE8
  549. }
  550. } else if (next.style.display === 'none') {
  551. return false;
  552. }
  553. next = next.parentNode;
  554. }
  555. return true;
  556. }
  557. /**
  558. * Returns elements top and left offset relative to the document. Function is not compatible with jQuery offset.
  559. *
  560. * @param {HTMLElement} elem
  561. * @return {Object} Returns object with `top` and `left` props
  562. */
  563. function offset(elem) {
  564. var offsetLeft, offsetTop, lastElem, docElem, box;
  565. docElem = document.documentElement;
  566. if ((0, _feature.hasCaptionProblem)() && elem.firstChild && elem.firstChild.nodeName === 'CAPTION') {
  567. // fixes problem with Firefox ignoring <caption> in TABLE offset (see also export outerHeight)
  568. // http://jsperf.com/offset-vs-getboundingclientrect/8
  569. box = elem.getBoundingClientRect();
  570. return {
  571. top: box.top + (window.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0),
  572. left: box.left + (window.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0)
  573. };
  574. }
  575. offsetLeft = elem.offsetLeft;
  576. offsetTop = elem.offsetTop;
  577. lastElem = elem;
  578. /* eslint-disable no-cond-assign */
  579. while (elem = elem.offsetParent) {
  580. // from my observation, document.body always has scrollLeft/scrollTop == 0
  581. if (elem === document.body) {
  582. break;
  583. }
  584. offsetLeft += elem.offsetLeft;
  585. offsetTop += elem.offsetTop;
  586. lastElem = elem;
  587. }
  588. // slow - http://jsperf.com/offset-vs-getboundingclientrect/6
  589. if (lastElem && lastElem.style.position === 'fixed') {
  590. // if(lastElem !== document.body) { //faster but does gives false positive in Firefox
  591. offsetLeft += window.pageXOffset || docElem.scrollLeft;
  592. offsetTop += window.pageYOffset || docElem.scrollTop;
  593. }
  594. return {
  595. left: offsetLeft,
  596. top: offsetTop
  597. };
  598. }
  599. /**
  600. * Returns the document's scrollTop property.
  601. *
  602. * @returns {Number}
  603. */
  604. function getWindowScrollTop() {
  605. var res = window.scrollY;
  606. if (res === void 0) {
  607. // IE8-11
  608. res = document.documentElement.scrollTop;
  609. }
  610. return res;
  611. }
  612. /**
  613. * Returns the document's scrollLeft property.
  614. *
  615. * @returns {Number}
  616. */
  617. function getWindowScrollLeft() {
  618. var res = window.scrollX;
  619. if (res === void 0) {
  620. // IE8-11
  621. res = document.documentElement.scrollLeft;
  622. }
  623. return res;
  624. }
  625. /**
  626. * Returns the provided element's scrollTop property.
  627. *
  628. * @param element
  629. * @returns {Number}
  630. */
  631. function getScrollTop(element) {
  632. if (element === window) {
  633. return getWindowScrollTop();
  634. }
  635. return element.scrollTop;
  636. }
  637. /**
  638. * Returns the provided element's scrollLeft property.
  639. *
  640. * @param element
  641. * @returns {Number}
  642. */
  643. function getScrollLeft(element) {
  644. if (element === window) {
  645. return getWindowScrollLeft();
  646. }
  647. return element.scrollLeft;
  648. }
  649. /**
  650. * Returns a DOM element responsible for scrolling of the provided element.
  651. *
  652. * @param {HTMLElement} element
  653. * @returns {HTMLElement} Element's scrollable parent
  654. */
  655. function getScrollableElement(element) {
  656. var el = element.parentNode,
  657. props = ['auto', 'scroll'],
  658. overflow,
  659. overflowX,
  660. overflowY,
  661. computedStyle = '',
  662. computedOverflow = '',
  663. computedOverflowY = '',
  664. computedOverflowX = '';
  665. while (el && el.style && document.body !== el) {
  666. overflow = el.style.overflow;
  667. overflowX = el.style.overflowX;
  668. overflowY = el.style.overflowY;
  669. if (overflow == 'scroll' || overflowX == 'scroll' || overflowY == 'scroll') {
  670. return el;
  671. } else if (window.getComputedStyle) {
  672. computedStyle = window.getComputedStyle(el);
  673. computedOverflow = computedStyle.getPropertyValue('overflow');
  674. computedOverflowY = computedStyle.getPropertyValue('overflow-y');
  675. computedOverflowX = computedStyle.getPropertyValue('overflow-x');
  676. if (computedOverflow === 'scroll' || computedOverflowX === 'scroll' || computedOverflowY === 'scroll') {
  677. return el;
  678. }
  679. }
  680. // The '+ 1' after the scrollHeight/scrollWidth is to prevent problems with zoomed out Chrome.
  681. if (el.clientHeight <= el.scrollHeight + 1 && (props.indexOf(overflowY) !== -1 || props.indexOf(overflow) !== -1 || props.indexOf(computedOverflow) !== -1 || props.indexOf(computedOverflowY) !== -1)) {
  682. return el;
  683. }
  684. if (el.clientWidth <= el.scrollWidth + 1 && (props.indexOf(overflowX) !== -1 || props.indexOf(overflow) !== -1 || props.indexOf(computedOverflow) !== -1 || props.indexOf(computedOverflowX) !== -1)) {
  685. return el;
  686. }
  687. el = el.parentNode;
  688. }
  689. return window;
  690. }
  691. /**
  692. * Returns a DOM element responsible for trimming the provided element.
  693. *
  694. * @param {HTMLElement} base Base element
  695. * @returns {HTMLElement} Base element's trimming parent
  696. */
  697. function getTrimmingContainer(base) {
  698. var el = base.parentNode;
  699. while (el && el.style && document.body !== el) {
  700. if (el.style.overflow !== 'visible' && el.style.overflow !== '') {
  701. return el;
  702. } else if (window.getComputedStyle) {
  703. var computedStyle = window.getComputedStyle(el);
  704. if (computedStyle.getPropertyValue('overflow') !== 'visible' && computedStyle.getPropertyValue('overflow') !== '') {
  705. return el;
  706. }
  707. }
  708. el = el.parentNode;
  709. }
  710. return window;
  711. }
  712. /**
  713. * Returns a style property for the provided element. (Be it an inline or external style).
  714. *
  715. * @param {HTMLElement} element
  716. * @param {String} prop Wanted property
  717. * @returns {String|undefined} Element's style property
  718. */
  719. function getStyle(element, prop) {
  720. /* eslint-disable */
  721. if (!element) {
  722. return;
  723. } else if (element === window) {
  724. if (prop === 'width') {
  725. return window.innerWidth + 'px';
  726. } else if (prop === 'height') {
  727. return window.innerHeight + 'px';
  728. }
  729. return;
  730. }
  731. var styleProp = element.style[prop],
  732. computedStyle;
  733. if (styleProp !== '' && styleProp !== void 0) {
  734. return styleProp;
  735. } else {
  736. computedStyle = getComputedStyle(element);
  737. if (computedStyle[prop] !== '' && computedStyle[prop] !== void 0) {
  738. return computedStyle[prop];
  739. }
  740. }
  741. }
  742. /**
  743. * Returns a computed style object for the provided element. (Needed if style is declared in external stylesheet).
  744. *
  745. * @param element
  746. * @returns {IEElementStyle|CssStyle} Elements computed style object
  747. */
  748. function getComputedStyle(element) {
  749. return element.currentStyle || document.defaultView.getComputedStyle(element);
  750. }
  751. /**
  752. * Returns the element's outer width.
  753. *
  754. * @param element
  755. * @returns {number} Element's outer width
  756. */
  757. function outerWidth(element) {
  758. return element.offsetWidth;
  759. }
  760. /**
  761. * Returns the element's outer height
  762. *
  763. * @param elem
  764. * @returns {number} Element's outer height
  765. */
  766. function outerHeight(elem) {
  767. if ((0, _feature.hasCaptionProblem)() && elem.firstChild && elem.firstChild.nodeName === 'CAPTION') {
  768. // fixes problem with Firefox ignoring <caption> in TABLE.offsetHeight
  769. // jQuery (1.10.1) still has this unsolved
  770. // may be better to just switch to getBoundingClientRect
  771. // http://bililite.com/blog/2009/03/27/finding-the-size-of-a-table/
  772. // http://lists.w3.org/Archives/Public/www-style/2009Oct/0089.html
  773. // http://bugs.jquery.com/ticket/2196
  774. // http://lists.w3.org/Archives/Public/www-style/2009Oct/0140.html#start140
  775. return elem.offsetHeight + elem.firstChild.offsetHeight;
  776. }
  777. return elem.offsetHeight;
  778. }
  779. /**
  780. * Returns the element's inner height.
  781. *
  782. * @param element
  783. * @returns {number} Element's inner height
  784. */
  785. function innerHeight(element) {
  786. return element.clientHeight || element.innerHeight;
  787. }
  788. /**
  789. * Returns the element's inner width.
  790. *
  791. * @param element
  792. * @returns {number} Element's inner width
  793. */
  794. function innerWidth(element) {
  795. return element.clientWidth || element.innerWidth;
  796. }
  797. function addEvent(element, event, callback) {
  798. if (window.addEventListener) {
  799. element.addEventListener(event, callback, false);
  800. } else {
  801. element.attachEvent('on' + event, callback);
  802. }
  803. }
  804. function removeEvent(element, event, callback) {
  805. if (window.removeEventListener) {
  806. element.removeEventListener(event, callback, false);
  807. } else {
  808. element.detachEvent('on' + event, callback);
  809. }
  810. }
  811. /**
  812. * Returns caret position in text input
  813. *
  814. * @author http://stackoverflow.com/questions/263743/how-to-get-caret-position-in-textarea
  815. * @return {Number}
  816. */
  817. function getCaretPosition(el) {
  818. if (el.selectionStart) {
  819. return el.selectionStart;
  820. } else if (document.selection) {
  821. // IE8
  822. el.focus();
  823. var r = document.selection.createRange();
  824. if (r == null) {
  825. return 0;
  826. }
  827. var re = el.createTextRange();
  828. var rc = re.duplicate();
  829. re.moveToBookmark(r.getBookmark());
  830. rc.setEndPoint('EndToStart', re);
  831. return rc.text.length;
  832. }
  833. return 0;
  834. }
  835. /**
  836. * Returns end of the selection in text input
  837. *
  838. * @return {Number}
  839. */
  840. function getSelectionEndPosition(el) {
  841. if (el.selectionEnd) {
  842. return el.selectionEnd;
  843. } else if (document.selection) {
  844. // IE8
  845. var r = document.selection.createRange();
  846. if (r == null) {
  847. return 0;
  848. }
  849. var re = el.createTextRange();
  850. return re.text.indexOf(r.text) + r.text.length;
  851. }
  852. return 0;
  853. }
  854. /**
  855. * Returns text under selection.
  856. *
  857. * @returns {String}
  858. */
  859. function getSelectionText() {
  860. var text = '';
  861. if (window.getSelection) {
  862. text = window.getSelection().toString();
  863. } else if (document.selection && document.selection.type !== 'Control') {
  864. text = document.selection.createRange().text;
  865. }
  866. return text;
  867. }
  868. /**
  869. * Sets caret position in text input.
  870. *
  871. * @author http://blog.vishalon.net/index.php/javascript-getting-and-setting-caret-position-in-textarea/
  872. * @param {Element} element
  873. * @param {Number} pos
  874. * @param {Number} endPos
  875. */
  876. function setCaretPosition(element, pos, endPos) {
  877. if (endPos === void 0) {
  878. endPos = pos;
  879. }
  880. if (element.setSelectionRange) {
  881. element.focus();
  882. try {
  883. element.setSelectionRange(pos, endPos);
  884. } catch (err) {
  885. var elementParent = element.parentNode;
  886. var parentDisplayValue = elementParent.style.display;
  887. elementParent.style.display = 'block';
  888. element.setSelectionRange(pos, endPos);
  889. elementParent.style.display = parentDisplayValue;
  890. }
  891. } else if (element.createTextRange) {
  892. // IE8
  893. var range = element.createTextRange();
  894. range.collapse(true);
  895. range.moveEnd('character', endPos);
  896. range.moveStart('character', pos);
  897. range.select();
  898. }
  899. }
  900. var cachedScrollbarWidth;
  901. // http://stackoverflow.com/questions/986937/how-can-i-get-the-browsers-scrollbar-sizes
  902. function walkontableCalculateScrollbarWidth() {
  903. var inner = document.createElement('div');
  904. inner.style.height = '200px';
  905. inner.style.width = '100%';
  906. var outer = document.createElement('div');
  907. outer.style.boxSizing = 'content-box';
  908. outer.style.height = '150px';
  909. outer.style.left = '0px';
  910. outer.style.overflow = 'hidden';
  911. outer.style.position = 'absolute';
  912. outer.style.top = '0px';
  913. outer.style.width = '200px';
  914. outer.style.visibility = 'hidden';
  915. outer.appendChild(inner);
  916. (document.body || document.documentElement).appendChild(outer);
  917. var w1 = inner.offsetWidth;
  918. outer.style.overflow = 'scroll';
  919. var w2 = inner.offsetWidth;
  920. if (w1 == w2) {
  921. w2 = outer.clientWidth;
  922. }
  923. (document.body || document.documentElement).removeChild(outer);
  924. return w1 - w2;
  925. }
  926. /**
  927. * Returns the computed width of the native browser scroll bar.
  928. *
  929. * @return {Number} width
  930. */
  931. function getScrollbarWidth() {
  932. if (cachedScrollbarWidth === void 0) {
  933. cachedScrollbarWidth = walkontableCalculateScrollbarWidth();
  934. }
  935. return cachedScrollbarWidth;
  936. }
  937. /**
  938. * Checks if the provided element has a vertical scrollbar.
  939. *
  940. * @param {HTMLElement} element
  941. * @returns {Boolean}
  942. */
  943. function hasVerticalScrollbar(element) {
  944. return element.offsetWidth !== element.clientWidth;
  945. }
  946. /**
  947. * Checks if the provided element has a vertical scrollbar.
  948. *
  949. * @param {HTMLElement} element
  950. * @returns {Boolean}
  951. */
  952. function hasHorizontalScrollbar(element) {
  953. return element.offsetHeight !== element.clientHeight;
  954. }
  955. /**
  956. * Sets overlay position depending on it's type and used browser
  957. */
  958. function setOverlayPosition(overlayElem, left, top) {
  959. if ((0, _browser.isIE8)() || (0, _browser.isIE9)()) {
  960. overlayElem.style.top = top;
  961. overlayElem.style.left = left;
  962. } else if ((0, _browser.isSafari)()) {
  963. overlayElem.style['-webkit-transform'] = 'translate3d(' + left + ',' + top + ',0)';
  964. } else {
  965. overlayElem.style.transform = 'translate3d(' + left + ',' + top + ',0)';
  966. }
  967. }
  968. function getCssTransform(element) {
  969. var transform;
  970. if (element.style.transform && (transform = element.style.transform) !== '') {
  971. return ['transform', transform];
  972. } else if (element.style['-webkit-transform'] && (transform = element.style['-webkit-transform']) !== '') {
  973. return ['-webkit-transform', transform];
  974. }
  975. return -1;
  976. }
  977. function resetCssTransform(element) {
  978. if (element.style.transform && element.style.transform !== '') {
  979. element.style.transform = '';
  980. } else if (element.style['-webkit-transform'] && element.style['-webkit-transform'] !== '') {
  981. element.style['-webkit-transform'] = '';
  982. }
  983. }
  984. /**
  985. * Determines if the given DOM element is an input field.
  986. * Notice: By 'input' we mean input, textarea and select nodes
  987. *
  988. * @param {HTMLElement} element - DOM element
  989. * @returns {Boolean}
  990. */
  991. function isInput(element) {
  992. var inputs = ['INPUT', 'SELECT', 'TEXTAREA'];
  993. return element && (inputs.indexOf(element.nodeName) > -1 || element.contentEditable === 'true');
  994. }
  995. /**
  996. * Determines if the given DOM element is an input field placed OUTSIDE of HOT.
  997. * Notice: By 'input' we mean input, textarea and select nodes
  998. *
  999. * @param {HTMLElement} element - DOM element
  1000. * @returns {Boolean}
  1001. */
  1002. function isOutsideInput(element) {
  1003. return isInput(element) && element.className.indexOf('handsontableInput') == -1 && element.className.indexOf('copyPaste') == -1;
  1004. }
  1005. /***/ }),
  1006. /* 1 */
  1007. /***/ (function(module, exports, __webpack_require__) {
  1008. "use strict";
  1009. exports.__esModule = true;
  1010. exports.to2dArray = to2dArray;
  1011. exports.extendArray = extendArray;
  1012. exports.pivot = pivot;
  1013. exports.arrayReduce = arrayReduce;
  1014. exports.arrayFilter = arrayFilter;
  1015. exports.arrayMap = arrayMap;
  1016. exports.arrayEach = arrayEach;
  1017. exports.arraySum = arraySum;
  1018. exports.arrayMax = arrayMax;
  1019. exports.arrayMin = arrayMin;
  1020. exports.arrayAvg = arrayAvg;
  1021. exports.arrayFlatten = arrayFlatten;
  1022. exports.arrayUnique = arrayUnique;
  1023. function to2dArray(arr) {
  1024. var i = 0,
  1025. ilen = arr.length;
  1026. while (i < ilen) {
  1027. arr[i] = [arr[i]];
  1028. i++;
  1029. }
  1030. }
  1031. function extendArray(arr, extension) {
  1032. var i = 0,
  1033. ilen = extension.length;
  1034. while (i < ilen) {
  1035. arr.push(extension[i]);
  1036. i++;
  1037. }
  1038. }
  1039. function pivot(arr) {
  1040. var pivotedArr = [];
  1041. if (!arr || arr.length === 0 || !arr[0] || arr[0].length === 0) {
  1042. return pivotedArr;
  1043. }
  1044. var rowCount = arr.length;
  1045. var colCount = arr[0].length;
  1046. for (var i = 0; i < rowCount; i++) {
  1047. for (var j = 0; j < colCount; j++) {
  1048. if (!pivotedArr[j]) {
  1049. pivotedArr[j] = [];
  1050. }
  1051. pivotedArr[j][i] = arr[i][j];
  1052. }
  1053. }
  1054. return pivotedArr;
  1055. }
  1056. /**
  1057. * A specialized version of `.reduce` for arrays without support for callback
  1058. * shorthands and `this` binding.
  1059. *
  1060. * {@link https://github.com/lodash/lodash/blob/master/lodash.js}
  1061. *
  1062. * @param {Array} array The array to iterate over.
  1063. * @param {Function} iteratee The function invoked per iteration.
  1064. * @param {*} [accumulator] The initial value.
  1065. * @param {Boolean} [initFromArray] Specify using the first element of `array` as the initial value.
  1066. * @returns {*} Returns the accumulated value.
  1067. */
  1068. function arrayReduce(array, iteratee, accumulator, initFromArray) {
  1069. var index = -1;
  1070. var iterable = array;
  1071. if (!Array.isArray(array)) {
  1072. iterable = Array.from(array);
  1073. }
  1074. var length = iterable.length;
  1075. if (initFromArray && length) {
  1076. accumulator = iterable[++index];
  1077. }
  1078. while (++index < length) {
  1079. accumulator = iteratee(accumulator, iterable[index], index, iterable);
  1080. }
  1081. return accumulator;
  1082. }
  1083. /**
  1084. * A specialized version of `.filter` for arrays without support for callback
  1085. * shorthands and `this` binding.
  1086. *
  1087. * {@link https://github.com/lodash/lodash/blob/master/lodash.js}
  1088. *
  1089. * @param {Array} array The array to iterate over.
  1090. * @param {Function} predicate The function invoked per iteration.
  1091. * @returns {Array} Returns the new filtered array.
  1092. */
  1093. function arrayFilter(array, predicate) {
  1094. var index = -1;
  1095. var iterable = array;
  1096. if (!Array.isArray(array)) {
  1097. iterable = Array.from(array);
  1098. }
  1099. var length = iterable.length;
  1100. var result = [];
  1101. var resIndex = -1;
  1102. while (++index < length) {
  1103. var value = iterable[index];
  1104. if (predicate(value, index, iterable)) {
  1105. result[++resIndex] = value;
  1106. }
  1107. }
  1108. return result;
  1109. }
  1110. /**
  1111. * A specialized version of `.map` for arrays without support for callback
  1112. * shorthands and `this` binding.
  1113. *
  1114. * @param {Array} array The array to iterate over.
  1115. * @param {Function} iteratee The function invoked per iteration.
  1116. * @returns {Array} Returns the new filtered array.
  1117. */
  1118. function arrayMap(array, iteratee) {
  1119. var index = -1;
  1120. var iterable = array;
  1121. if (!Array.isArray(array)) {
  1122. iterable = Array.from(array);
  1123. }
  1124. var length = iterable.length;
  1125. var result = [];
  1126. var resIndex = -1;
  1127. while (++index < length) {
  1128. var value = iterable[index];
  1129. result[++resIndex] = iteratee(value, index, iterable);
  1130. }
  1131. return result;
  1132. }
  1133. /**
  1134. * A specialized version of `.forEach` for arrays without support for callback
  1135. * shorthands and `this` binding.
  1136. *
  1137. * {@link https://github.com/lodash/lodash/blob/master/lodash.js}
  1138. *
  1139. * @param {Array|*} array The array to iterate over or an any element with implemented iterator protocol.
  1140. * @param {Function} iteratee The function invoked per iteration.
  1141. * @returns {Array} Returns `array`.
  1142. */
  1143. function arrayEach(array, iteratee) {
  1144. var index = -1;
  1145. var iterable = array;
  1146. if (!Array.isArray(array)) {
  1147. iterable = Array.from(array);
  1148. }
  1149. var length = iterable.length;
  1150. while (++index < length) {
  1151. if (iteratee(iterable[index], index, iterable) === false) {
  1152. break;
  1153. }
  1154. }
  1155. return array;
  1156. }
  1157. /**
  1158. * Calculate sum value for each item of the array.
  1159. *
  1160. * @param {Array} array The array to process.
  1161. * @returns {Number} Returns calculated sum value.
  1162. */
  1163. function arraySum(array) {
  1164. return arrayReduce(array, function (a, b) {
  1165. return a + b;
  1166. }, 0);
  1167. }
  1168. /**
  1169. * Returns the highest value from an array. Can be array of numbers or array of strings.
  1170. * NOTICE: Mixed values is not supported.
  1171. *
  1172. * @param {Array} array The array to process.
  1173. * @returns {Number} Returns the highest value from an array.
  1174. */
  1175. function arrayMax(array) {
  1176. return arrayReduce(array, function (a, b) {
  1177. return a > b ? a : b;
  1178. }, Array.isArray(array) ? array[0] : void 0);
  1179. }
  1180. /**
  1181. * Returns the lowest value from an array. Can be array of numbers or array of strings.
  1182. * NOTICE: Mixed values is not supported.
  1183. *
  1184. * @param {Array} array The array to process.
  1185. * @returns {Number} Returns the lowest value from an array.
  1186. */
  1187. function arrayMin(array) {
  1188. return arrayReduce(array, function (a, b) {
  1189. return a < b ? a : b;
  1190. }, Array.isArray(array) ? array[0] : void 0);
  1191. }
  1192. /**
  1193. * Calculate average value for each item of the array.
  1194. *
  1195. * @param {Array} array The array to process.
  1196. * @returns {Number} Returns calculated average value.
  1197. */
  1198. function arrayAvg(array) {
  1199. if (!array.length) {
  1200. return 0;
  1201. }
  1202. return arraySum(array) / array.length;
  1203. }
  1204. /**
  1205. * Flatten multidimensional array.
  1206. *
  1207. * @param {Array} array Array of Arrays
  1208. * @returns {Array}
  1209. */
  1210. function arrayFlatten(array) {
  1211. return arrayReduce(array, function (initial, value) {
  1212. return initial.concat(Array.isArray(value) ? arrayFlatten(value) : value);
  1213. }, []);
  1214. }
  1215. /**
  1216. * Unique values in the array.
  1217. *
  1218. * @param {Array} array The array to process.
  1219. * @returns {Array}
  1220. */
  1221. function arrayUnique(array) {
  1222. var unique = [];
  1223. arrayEach(array, function (value) {
  1224. if (unique.indexOf(value) === -1) {
  1225. unique.push(value);
  1226. }
  1227. });
  1228. return unique;
  1229. }
  1230. /***/ }),
  1231. /* 2 */
  1232. /***/ (function(module, exports, __webpack_require__) {
  1233. "use strict";
  1234. exports.__esModule = true;
  1235. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  1236. exports.duckSchema = duckSchema;
  1237. exports.inherit = inherit;
  1238. exports.extend = extend;
  1239. exports.deepExtend = deepExtend;
  1240. exports.deepClone = deepClone;
  1241. exports.clone = clone;
  1242. exports.mixin = mixin;
  1243. exports.isObjectEqual = isObjectEqual;
  1244. exports.isObject = isObject;
  1245. exports.defineGetter = defineGetter;
  1246. exports.objectEach = objectEach;
  1247. exports.getProperty = getProperty;
  1248. exports.deepObjectSize = deepObjectSize;
  1249. exports.createObjectPropListener = createObjectPropListener;
  1250. exports.hasOwnProperty = hasOwnProperty;
  1251. var _array = __webpack_require__(1);
  1252. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  1253. /**
  1254. * Generate schema for passed object.
  1255. *
  1256. * @param {Array|Object} object
  1257. * @returns {Array|Object}
  1258. */
  1259. function duckSchema(object) {
  1260. var schema;
  1261. if (Array.isArray(object)) {
  1262. schema = [];
  1263. } else {
  1264. schema = {};
  1265. objectEach(object, function (value, key) {
  1266. if (key === '__children') {
  1267. return;
  1268. }
  1269. if (value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && !Array.isArray(value)) {
  1270. schema[key] = duckSchema(value);
  1271. } else if (Array.isArray(value)) {
  1272. if (value.length && _typeof(value[0]) === 'object' && !Array.isArray(value[0])) {
  1273. schema[key] = [duckSchema(value[0])];
  1274. } else {
  1275. schema[key] = [];
  1276. }
  1277. } else {
  1278. schema[key] = null;
  1279. }
  1280. });
  1281. }
  1282. return schema;
  1283. }
  1284. /**
  1285. * Inherit without without calling parent constructor, and setting `Child.prototype.constructor` to `Child` instead of `Parent`.
  1286. * Creates temporary dummy function to call it as constructor.
  1287. * Described in ticket: https://github.com/handsontable/handsontable/pull/516
  1288. *
  1289. * @param {Object} Child child class
  1290. * @param {Object} Parent parent class
  1291. * @return {Object} extended Child
  1292. */
  1293. function inherit(Child, Parent) {
  1294. Parent.prototype.constructor = Parent;
  1295. Child.prototype = new Parent();
  1296. Child.prototype.constructor = Child;
  1297. return Child;
  1298. }
  1299. /**
  1300. * Perform shallow extend of a target object with extension's own properties.
  1301. *
  1302. * @param {Object} target An object that will receive the new properties.
  1303. * @param {Object} extension An object containing additional properties to merge into the target.
  1304. */
  1305. function extend(target, extension) {
  1306. objectEach(extension, function (value, key) {
  1307. target[key] = value;
  1308. });
  1309. return target;
  1310. }
  1311. /**
  1312. * Perform deep extend of a target object with extension's own properties.
  1313. *
  1314. * @param {Object} target An object that will receive the new properties.
  1315. * @param {Object} extension An object containing additional properties to merge into the target.
  1316. */
  1317. function deepExtend(target, extension) {
  1318. objectEach(extension, function (value, key) {
  1319. if (extension[key] && _typeof(extension[key]) === 'object') {
  1320. if (!target[key]) {
  1321. if (Array.isArray(extension[key])) {
  1322. target[key] = [];
  1323. } else if (Object.prototype.toString.call(extension[key]) === '[object Date]') {
  1324. target[key] = extension[key];
  1325. } else {
  1326. target[key] = {};
  1327. }
  1328. }
  1329. deepExtend(target[key], extension[key]);
  1330. } else {
  1331. target[key] = extension[key];
  1332. }
  1333. });
  1334. }
  1335. /**
  1336. * Perform deep clone of an object.
  1337. * WARNING! Only clones JSON properties. Will cause error when `obj` contains a function, Date, etc.
  1338. *
  1339. * @param {Object} obj An object that will be cloned
  1340. * @return {Object}
  1341. */
  1342. function deepClone(obj) {
  1343. if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object') {
  1344. return JSON.parse(JSON.stringify(obj));
  1345. }
  1346. return obj;
  1347. }
  1348. /**
  1349. * Shallow clone object.
  1350. *
  1351. * @param {Object} object
  1352. * @returns {Object}
  1353. */
  1354. function clone(object) {
  1355. var result = {};
  1356. objectEach(object, function (value, key) {
  1357. result[key] = value;
  1358. });
  1359. return result;
  1360. }
  1361. /**
  1362. * Extend the Base object (usually prototype) of the functionality the `mixins` objects.
  1363. *
  1364. * @param {Object} Base Base object which will be extended.
  1365. * @param {Object} mixins The object of the functionality will be "copied".
  1366. * @returns {Object}
  1367. */
  1368. function mixin(Base) {
  1369. if (!Base.MIXINS) {
  1370. Base.MIXINS = [];
  1371. }
  1372. for (var _len = arguments.length, mixins = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1373. mixins[_key - 1] = arguments[_key];
  1374. }
  1375. (0, _array.arrayEach)(mixins, function (mixin) {
  1376. Base.MIXINS.push(mixin.MIXIN_NAME);
  1377. objectEach(mixin, function (value, key) {
  1378. if (Base.prototype[key] !== void 0) {
  1379. throw new Error('Mixin conflict. Property \'' + key + '\' already exist and cannot be overwritten.');
  1380. }
  1381. if (typeof value === 'function') {
  1382. Base.prototype[key] = value;
  1383. } else {
  1384. var getter = function _getter(propertyName, initialValue) {
  1385. propertyName = '_' + propertyName;
  1386. var initValue = function initValue(value) {
  1387. if (Array.isArray(value) || isObject(value)) {
  1388. value = deepClone(value);
  1389. }
  1390. return value;
  1391. };
  1392. return function () {
  1393. if (this[propertyName] === void 0) {
  1394. this[propertyName] = initValue(initialValue);
  1395. }
  1396. return this[propertyName];
  1397. };
  1398. };
  1399. var setter = function _setter(propertyName) {
  1400. propertyName = '_' + propertyName;
  1401. return function (value) {
  1402. this[propertyName] = value;
  1403. };
  1404. };
  1405. Object.defineProperty(Base.prototype, key, {
  1406. get: getter(key, value),
  1407. set: setter(key),
  1408. configurable: true
  1409. });
  1410. }
  1411. });
  1412. });
  1413. return Base;
  1414. }
  1415. /**
  1416. * Checks if two objects or arrays are (deep) equal
  1417. *
  1418. * @param {Object|Array} object1
  1419. * @param {Object|Array} object2
  1420. * @returns {Boolean}
  1421. */
  1422. function isObjectEqual(object1, object2) {
  1423. return JSON.stringify(object1) === JSON.stringify(object2);
  1424. }
  1425. /**
  1426. * Determines whether given object is a plain Object.
  1427. * Note: String and Array are not plain Objects
  1428. * @param {*} obj
  1429. * @returns {boolean}
  1430. */
  1431. function isObject(obj) {
  1432. return Object.prototype.toString.call(obj) == '[object Object]';
  1433. }
  1434. function defineGetter(object, property, value, options) {
  1435. options.value = value;
  1436. options.writable = options.writable !== false;
  1437. options.enumerable = options.enumerable !== false;
  1438. options.configurable = options.configurable !== false;
  1439. Object.defineProperty(object, property, options);
  1440. }
  1441. /**
  1442. * A specialized version of `.forEach` for objects.
  1443. *
  1444. * @param {Object} object The object to iterate over.
  1445. * @param {Function} iteratee The function invoked per iteration.
  1446. * @returns {Object} Returns `object`.
  1447. */
  1448. function objectEach(object, iteratee) {
  1449. for (var key in object) {
  1450. if (!object.hasOwnProperty || object.hasOwnProperty && Object.prototype.hasOwnProperty.call(object, key)) {
  1451. if (iteratee(object[key], key, object) === false) {
  1452. break;
  1453. }
  1454. }
  1455. }
  1456. return object;
  1457. }
  1458. /**
  1459. * Get object property by its name. Access to sub properties can be achieved by dot notation (e.q. `'foo.bar.baz'`).
  1460. *
  1461. * @param {Object} object Object which value will be exported.
  1462. * @param {String} name Object property name.
  1463. * @returns {*}
  1464. */
  1465. function getProperty(object, name) {
  1466. var names = name.split('.');
  1467. var result = object;
  1468. objectEach(names, function (name) {
  1469. result = result[name];
  1470. if (result === void 0) {
  1471. result = void 0;
  1472. return false;
  1473. }
  1474. });
  1475. return result;
  1476. }
  1477. /**
  1478. * Return object length (recursively).
  1479. *
  1480. * @param {*} object Object for which we want get length.
  1481. * @returns {Number}
  1482. */
  1483. function deepObjectSize(object) {
  1484. if (!isObject(object)) {
  1485. return 0;
  1486. }
  1487. var recursObjLen = function recursObjLen(obj) {
  1488. var result = 0;
  1489. if (isObject(obj)) {
  1490. objectEach(obj, function (key) {
  1491. result += recursObjLen(key);
  1492. });
  1493. } else {
  1494. result++;
  1495. }
  1496. return result;
  1497. };
  1498. return recursObjLen(object);
  1499. }
  1500. /**
  1501. * Create object with property where its value change will be observed.
  1502. *
  1503. * @param {*} [defaultValue=undefined] Default value.
  1504. * @param {String} [propertyToListen='value'] Property to listen.
  1505. * @returns {Object}
  1506. */
  1507. function createObjectPropListener(defaultValue) {
  1508. var _holder;
  1509. var propertyToListen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'value';
  1510. var privateProperty = '_' + propertyToListen;
  1511. var holder = (_holder = {
  1512. _touched: false
  1513. }, _defineProperty(_holder, privateProperty, defaultValue), _defineProperty(_holder, 'isTouched', function isTouched() {
  1514. return this._touched;
  1515. }), _holder);
  1516. Object.defineProperty(holder, propertyToListen, {
  1517. get: function get() {
  1518. return this[privateProperty];
  1519. },
  1520. set: function set(value) {
  1521. this._touched = true;
  1522. this[privateProperty] = value;
  1523. },
  1524. enumerable: true,
  1525. configurable: true
  1526. });
  1527. return holder;
  1528. }
  1529. /**
  1530. * Check if at specified `key` there is any value for `object`.
  1531. *
  1532. * @param {Object} object Object to search value at specyfic key.
  1533. * @param {String} key String key to check.
  1534. */
  1535. function hasOwnProperty(object, key) {
  1536. return Object.prototype.hasOwnProperty.call(object, key);
  1537. }
  1538. /***/ }),
  1539. /* 3 */
  1540. /***/ (function(module, exports, __webpack_require__) {
  1541. var global = __webpack_require__(14);
  1542. var core = __webpack_require__(45);
  1543. var hide = __webpack_require__(31);
  1544. var redefine = __webpack_require__(30);
  1545. var ctx = __webpack_require__(32);
  1546. var PROTOTYPE = 'prototype';
  1547. var $export = function (type, name, source) {
  1548. var IS_FORCED = type & $export.F;
  1549. var IS_GLOBAL = type & $export.G;
  1550. var IS_STATIC = type & $export.S;
  1551. var IS_PROTO = type & $export.P;
  1552. var IS_BIND = type & $export.B;
  1553. var target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE];
  1554. var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
  1555. var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
  1556. var key, own, out, exp;
  1557. if (IS_GLOBAL) source = name;
  1558. for (key in source) {
  1559. // contains in native
  1560. own = !IS_FORCED && target && target[key] !== undefined;
  1561. // export native or passed
  1562. out = (own ? target : source)[key];
  1563. // bind timers to global for call from export context
  1564. exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
  1565. // extend global
  1566. if (target) redefine(target, key, out, type & $export.U);
  1567. // export
  1568. if (exports[key] != out) hide(exports, key, exp);
  1569. if (IS_PROTO && expProto[key] != out) expProto[key] = out;
  1570. }
  1571. };
  1572. global.core = core;
  1573. // type bitmap
  1574. $export.F = 1; // forced
  1575. $export.G = 2; // global
  1576. $export.S = 4; // static
  1577. $export.P = 8; // proto
  1578. $export.B = 16; // bind
  1579. $export.W = 32; // wrap
  1580. $export.U = 64; // safe
  1581. $export.R = 128; // real proto method for `library`
  1582. module.exports = $export;
  1583. /***/ }),
  1584. /* 4 */
  1585. /***/ (function(module, exports, __webpack_require__) {
  1586. "use strict";
  1587. exports.__esModule = true;
  1588. exports.Viewport = exports.TableRenderer = exports.Table = exports.Settings = exports.Selection = exports.Scroll = exports.Overlays = exports.Event = exports.Core = exports.default = exports.Border = exports.TopLeftCornerOverlay = exports.TopOverlay = exports.LeftOverlay = exports.DebugOverlay = exports.RowFilter = exports.ColumnFilter = exports.CellRange = exports.CellCoords = exports.ViewportRowsCalculator = exports.ViewportColumnsCalculator = undefined;
  1589. __webpack_require__(96);
  1590. __webpack_require__(111);
  1591. __webpack_require__(112);
  1592. __webpack_require__(116);
  1593. __webpack_require__(117);
  1594. __webpack_require__(119);
  1595. __webpack_require__(122);
  1596. __webpack_require__(123);
  1597. __webpack_require__(124);
  1598. __webpack_require__(125);
  1599. __webpack_require__(126);
  1600. __webpack_require__(127);
  1601. __webpack_require__(128);
  1602. __webpack_require__(129);
  1603. __webpack_require__(130);
  1604. __webpack_require__(131);
  1605. __webpack_require__(132);
  1606. __webpack_require__(133);
  1607. __webpack_require__(134);
  1608. __webpack_require__(135);
  1609. __webpack_require__(136);
  1610. __webpack_require__(137);
  1611. __webpack_require__(138);
  1612. __webpack_require__(139);
  1613. __webpack_require__(141);
  1614. __webpack_require__(143);
  1615. __webpack_require__(144);
  1616. __webpack_require__(145);
  1617. __webpack_require__(146);
  1618. __webpack_require__(147);
  1619. __webpack_require__(148);
  1620. __webpack_require__(149);
  1621. __webpack_require__(150);
  1622. __webpack_require__(151);
  1623. __webpack_require__(152);
  1624. __webpack_require__(153);
  1625. __webpack_require__(154);
  1626. __webpack_require__(155);
  1627. __webpack_require__(85);
  1628. __webpack_require__(156);
  1629. __webpack_require__(157);
  1630. __webpack_require__(159);
  1631. __webpack_require__(160);
  1632. __webpack_require__(161);
  1633. __webpack_require__(162);
  1634. __webpack_require__(163);
  1635. __webpack_require__(164);
  1636. __webpack_require__(165);
  1637. __webpack_require__(167);
  1638. __webpack_require__(168);
  1639. __webpack_require__(169);
  1640. __webpack_require__(172);
  1641. __webpack_require__(173);
  1642. __webpack_require__(174);
  1643. var _viewportColumns = __webpack_require__(175);
  1644. var _viewportColumns2 = _interopRequireDefault(_viewportColumns);
  1645. var _viewportRows = __webpack_require__(176);
  1646. var _viewportRows2 = _interopRequireDefault(_viewportRows);
  1647. var _coords = __webpack_require__(55);
  1648. var _coords2 = _interopRequireDefault(_coords);
  1649. var _range = __webpack_require__(86);
  1650. var _range2 = _interopRequireDefault(_range);
  1651. var _column = __webpack_require__(177);
  1652. var _column2 = _interopRequireDefault(_column);
  1653. var _row = __webpack_require__(178);
  1654. var _row2 = _interopRequireDefault(_row);
  1655. var _debug = __webpack_require__(348);
  1656. var _debug2 = _interopRequireDefault(_debug);
  1657. var _left = __webpack_require__(351);
  1658. var _left2 = _interopRequireDefault(_left);
  1659. var _top = __webpack_require__(352);
  1660. var _top2 = _interopRequireDefault(_top);
  1661. var _topLeftCorner = __webpack_require__(353);
  1662. var _topLeftCorner2 = _interopRequireDefault(_topLeftCorner);
  1663. var _border = __webpack_require__(306);
  1664. var _border2 = _interopRequireDefault(_border);
  1665. var _core = __webpack_require__(179);
  1666. var _core2 = _interopRequireDefault(_core);
  1667. var _event = __webpack_require__(299);
  1668. var _event2 = _interopRequireDefault(_event);
  1669. var _overlays = __webpack_require__(300);
  1670. var _overlays2 = _interopRequireDefault(_overlays);
  1671. var _scroll = __webpack_require__(301);
  1672. var _scroll2 = _interopRequireDefault(_scroll);
  1673. var _selection = __webpack_require__(354);
  1674. var _selection2 = _interopRequireDefault(_selection);
  1675. var _settings = __webpack_require__(302);
  1676. var _settings2 = _interopRequireDefault(_settings);
  1677. var _table = __webpack_require__(303);
  1678. var _table2 = _interopRequireDefault(_table);
  1679. var _tableRenderer = __webpack_require__(304);
  1680. var _tableRenderer2 = _interopRequireDefault(_tableRenderer);
  1681. var _viewport = __webpack_require__(305);
  1682. var _viewport2 = _interopRequireDefault(_viewport);
  1683. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1684. exports.ViewportColumnsCalculator = _viewportColumns2.default;
  1685. exports.ViewportRowsCalculator = _viewportRows2.default;
  1686. exports.CellCoords = _coords2.default;
  1687. exports.CellRange = _range2.default;
  1688. exports.ColumnFilter = _column2.default;
  1689. exports.RowFilter = _row2.default;
  1690. exports.DebugOverlay = _debug2.default;
  1691. exports.LeftOverlay = _left2.default;
  1692. exports.TopOverlay = _top2.default;
  1693. exports.TopLeftCornerOverlay = _topLeftCorner2.default;
  1694. exports.Border = _border2.default;
  1695. exports.default = _core2.default;
  1696. exports.Core = _core2.default;
  1697. exports.Event = _event2.default;
  1698. exports.Overlays = _overlays2.default;
  1699. exports.Scroll = _scroll2.default;
  1700. exports.Selection = _selection2.default;
  1701. exports.Settings = _settings2.default;
  1702. exports.Table = _table2.default;
  1703. exports.TableRenderer = _tableRenderer2.default;
  1704. exports.Viewport = _viewport2.default;
  1705. /***/ }),
  1706. /* 5 */
  1707. /***/ (function(module, exports, __webpack_require__) {
  1708. "use strict";
  1709. exports.__esModule = true;
  1710. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  1711. exports.isNumeric = isNumeric;
  1712. exports.rangeEach = rangeEach;
  1713. exports.rangeEachReverse = rangeEachReverse;
  1714. exports.valueAccordingPercent = valueAccordingPercent;
  1715. /**
  1716. * Checks if value of n is a numeric one
  1717. * http://jsperf.com/isnan-vs-isnumeric/4
  1718. * @param n
  1719. * @returns {boolean}
  1720. */
  1721. function isNumeric(n) {
  1722. /* eslint-disable */
  1723. var t = typeof n === 'undefined' ? 'undefined' : _typeof(n);
  1724. return t == 'number' ? !isNaN(n) && isFinite(n) : t == 'string' ? !n.length ? false : n.length == 1 ? /\d/.test(n) : /^\s*[+-]?\s*(?:(?:\d+(?:\.\d+)?(?:e[+-]?\d+)?)|(?:0x[a-f\d]+))\s*$/i.test(n) : t == 'object' ? !!n && typeof n.valueOf() == 'number' && !(n instanceof Date) : false;
  1725. }
  1726. /**
  1727. * A specialized version of `.forEach` defined by ranges.
  1728. *
  1729. * @param {Number} rangeFrom The number from start iterate.
  1730. * @param {Number|Function} rangeTo The number where finish iterate or function as a iteratee.
  1731. * @param {Function} [iteratee] The function invoked per iteration.
  1732. */
  1733. function rangeEach(rangeFrom, rangeTo, iteratee) {
  1734. var index = -1;
  1735. if (typeof rangeTo === 'function') {
  1736. iteratee = rangeTo;
  1737. rangeTo = rangeFrom;
  1738. } else {
  1739. index = rangeFrom - 1;
  1740. }
  1741. while (++index <= rangeTo) {
  1742. if (iteratee(index) === false) {
  1743. break;
  1744. }
  1745. }
  1746. }
  1747. /**
  1748. * A specialized version of `.forEach` defined by ranges iterable in reverse order.
  1749. *
  1750. * @param {Number} rangeFrom The number from start iterate.
  1751. * @param {Number|Function} rangeTo The number where finish iterate or function as a iteratee.
  1752. * @param {Function} [iteratee] The function invoked per iteration.
  1753. */
  1754. function rangeEachReverse(rangeFrom, rangeTo, iteratee) {
  1755. var index = rangeFrom + 1;
  1756. if (typeof rangeTo === 'function') {
  1757. iteratee = rangeTo;
  1758. rangeTo = 0;
  1759. }
  1760. while (--index >= rangeTo) {
  1761. if (iteratee(index) === false) {
  1762. break;
  1763. }
  1764. }
  1765. }
  1766. /**
  1767. * Calculate value from percent.
  1768. *
  1769. * @param {Number} value Base value from percent will be calculated.
  1770. * @param {String|Number} percent Can be Number or String (eq. `'33%'`).
  1771. * @returns {Number}
  1772. */
  1773. function valueAccordingPercent(value, percent) {
  1774. percent = parseInt(percent.toString().replace('%', ''), 10);
  1775. percent = parseInt(value * percent / 100, 10);
  1776. return percent;
  1777. }
  1778. /***/ }),
  1779. /* 6 */
  1780. /***/ (function(module, exports, __webpack_require__) {
  1781. "use strict";
  1782. exports.__esModule = true;
  1783. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1784. exports.getListenersCounter = getListenersCounter;
  1785. var _element = __webpack_require__(0);
  1786. var _object = __webpack_require__(2);
  1787. var _feature = __webpack_require__(40);
  1788. var _event = __webpack_require__(12);
  1789. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1790. /**
  1791. * Counter which tracks unregistered listeners (useful for detecting memory leaks).
  1792. *
  1793. * @type {Number}
  1794. */
  1795. var listenersCounter = 0;
  1796. /**
  1797. * Event DOM manager for internal use in Handsontable.
  1798. *
  1799. * @class EventManager
  1800. * @util
  1801. */
  1802. var EventManager = function () {
  1803. /**
  1804. * @param {Object} [context=null]
  1805. * @private
  1806. */
  1807. function EventManager() {
  1808. var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  1809. _classCallCheck(this, EventManager);
  1810. this.context = context || this;
  1811. if (!this.context.eventListeners) {
  1812. this.context.eventListeners = [];
  1813. }
  1814. }
  1815. /**
  1816. * Register specified listener (`eventName`) to the element.
  1817. *
  1818. * @param {Element} element Target element.
  1819. * @param {String} eventName Event name.
  1820. * @param {Function} callback Function which will be called after event occur.
  1821. * @returns {Function} Returns function which you can easily call to remove that event
  1822. */
  1823. _createClass(EventManager, [{
  1824. key: 'addEventListener',
  1825. value: function addEventListener(element, eventName, callback) {
  1826. var _this = this;
  1827. var context = this.context;
  1828. function callbackProxy(event) {
  1829. event = extendEvent(context, event);
  1830. callback.call(this, event);
  1831. }
  1832. this.context.eventListeners.push({
  1833. element: element,
  1834. event: eventName,
  1835. callback: callback,
  1836. callbackProxy: callbackProxy
  1837. });
  1838. if (window.addEventListener) {
  1839. element.addEventListener(eventName, callbackProxy, false);
  1840. } else {
  1841. element.attachEvent('on' + eventName, callbackProxy);
  1842. }
  1843. listenersCounter++;
  1844. return function () {
  1845. _this.removeEventListener(element, eventName, callback);
  1846. };
  1847. }
  1848. /**
  1849. * Remove the event listener previously registered.
  1850. *
  1851. * @param {Element} element Target element.
  1852. * @param {String} eventName Event name.
  1853. * @param {Function} callback Function to remove from the event target. It must be the same as during registration listener.
  1854. */
  1855. }, {
  1856. key: 'removeEventListener',
  1857. value: function removeEventListener(element, eventName, callback) {
  1858. var len = this.context.eventListeners.length;
  1859. var tmpEvent = void 0;
  1860. while (len--) {
  1861. tmpEvent = this.context.eventListeners[len];
  1862. if (tmpEvent.event == eventName && tmpEvent.element == element) {
  1863. if (callback && callback != tmpEvent.callback) {
  1864. /* eslint-disable no-continue */
  1865. continue;
  1866. }
  1867. this.context.eventListeners.splice(len, 1);
  1868. if (tmpEvent.element.removeEventListener) {
  1869. tmpEvent.element.removeEventListener(tmpEvent.event, tmpEvent.callbackProxy, false);
  1870. } else {
  1871. tmpEvent.element.detachEvent('on' + tmpEvent.event, tmpEvent.callbackProxy);
  1872. }
  1873. listenersCounter--;
  1874. }
  1875. }
  1876. }
  1877. /**
  1878. * Clear all previously registered events.
  1879. *
  1880. * @private
  1881. * @since 0.15.0-beta3
  1882. */
  1883. }, {
  1884. key: 'clearEvents',
  1885. value: function clearEvents() {
  1886. if (!this.context) {
  1887. return;
  1888. }
  1889. var len = this.context.eventListeners.length;
  1890. while (len--) {
  1891. var event = this.context.eventListeners[len];
  1892. if (event) {
  1893. this.removeEventListener(event.element, event.event, event.callback);
  1894. }
  1895. }
  1896. }
  1897. /**
  1898. * Clear all previously registered events.
  1899. */
  1900. }, {
  1901. key: 'clear',
  1902. value: function clear() {
  1903. this.clearEvents();
  1904. }
  1905. /**
  1906. * Destroy instance of EventManager.
  1907. */
  1908. }, {
  1909. key: 'destroy',
  1910. value: function destroy() {
  1911. this.clearEvents();
  1912. this.context = null;
  1913. }
  1914. /**
  1915. * Trigger event at the specified target element.
  1916. *
  1917. * @param {Element} element Target element.
  1918. * @param {String} eventName Event name.
  1919. */
  1920. }, {
  1921. key: 'fireEvent',
  1922. value: function fireEvent(element, eventName) {
  1923. var options = {
  1924. bubbles: true,
  1925. cancelable: eventName !== 'mousemove',
  1926. view: window,
  1927. detail: 0,
  1928. screenX: 0,
  1929. screenY: 0,
  1930. clientX: 1,
  1931. clientY: 1,
  1932. ctrlKey: false,
  1933. altKey: false,
  1934. shiftKey: false,
  1935. metaKey: false,
  1936. button: 0,
  1937. relatedTarget: undefined
  1938. };
  1939. var event;
  1940. if (document.createEvent) {
  1941. event = document.createEvent('MouseEvents');
  1942. event.initMouseEvent(eventName, options.bubbles, options.cancelable, options.view, options.detail, options.screenX, options.screenY, options.clientX, options.clientY, options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.button, options.relatedTarget || document.body.parentNode);
  1943. } else {
  1944. event = document.createEventObject();
  1945. }
  1946. if (element.dispatchEvent) {
  1947. element.dispatchEvent(event);
  1948. } else {
  1949. element.fireEvent('on' + eventName, event);
  1950. }
  1951. }
  1952. }]);
  1953. return EventManager;
  1954. }();
  1955. /**
  1956. * @param {Object} context
  1957. * @param {Event} event
  1958. * @private
  1959. * @returns {*}
  1960. */
  1961. function extendEvent(context, event) {
  1962. var componentName = 'HOT-TABLE';
  1963. var isHotTableSpotted = void 0;
  1964. var fromElement = void 0;
  1965. var realTarget = void 0;
  1966. var target = void 0;
  1967. var len = void 0;
  1968. var nativeStopImmediatePropagation = void 0;
  1969. event.isTargetWebComponent = false;
  1970. event.realTarget = event.target;
  1971. nativeStopImmediatePropagation = event.stopImmediatePropagation;
  1972. event.stopImmediatePropagation = function () {
  1973. nativeStopImmediatePropagation.apply(this);
  1974. (0, _event.stopImmediatePropagation)(this);
  1975. };
  1976. if (!EventManager.isHotTableEnv) {
  1977. return event;
  1978. }
  1979. event = (0, _element.polymerWrap)(event);
  1980. len = event.path ? event.path.length : 0;
  1981. while (len--) {
  1982. if (event.path[len].nodeName === componentName) {
  1983. isHotTableSpotted = true;
  1984. } else if (isHotTableSpotted && event.path[len].shadowRoot) {
  1985. target = event.path[len];
  1986. break;
  1987. }
  1988. if (len === 0 && !target) {
  1989. target = event.path[len];
  1990. }
  1991. }
  1992. if (!target) {
  1993. target = event.target;
  1994. }
  1995. event.isTargetWebComponent = true;
  1996. if ((0, _feature.isWebComponentSupportedNatively)()) {
  1997. event.realTarget = event.srcElement || event.toElement;
  1998. } else if ((0, _object.hasOwnProperty)(context, 'hot') || context.isHotTableEnv || context.wtTable) {
  1999. // Polymer doesn't support `event.target` property properly we must emulate it ourselves
  2000. if ((0, _object.hasOwnProperty)(context, 'hot')) {
  2001. // Custom element
  2002. fromElement = context.hot ? context.hot.view.wt.wtTable.TABLE : null;
  2003. } else if (context.isHotTableEnv) {
  2004. // Handsontable.Core
  2005. fromElement = context.view.activeWt.wtTable.TABLE.parentNode.parentNode;
  2006. } else if (context.wtTable) {
  2007. // Walkontable
  2008. fromElement = context.wtTable.TABLE.parentNode.parentNode;
  2009. }
  2010. realTarget = (0, _element.closest)(event.target, [componentName], fromElement);
  2011. if (realTarget) {
  2012. event.realTarget = fromElement.querySelector(componentName) || event.target;
  2013. } else {
  2014. event.realTarget = event.target;
  2015. }
  2016. }
  2017. Object.defineProperty(event, 'target', {
  2018. get: function get() {
  2019. return (0, _element.polymerWrap)(target);
  2020. },
  2021. enumerable: true,
  2022. configurable: true
  2023. });
  2024. return event;
  2025. }
  2026. exports.default = EventManager;
  2027. function getListenersCounter() {
  2028. return listenersCounter;
  2029. };
  2030. /***/ }),
  2031. /* 7 */
  2032. /***/ (function(module, exports, __webpack_require__) {
  2033. "use strict";
  2034. exports.__esModule = true;
  2035. /**
  2036. * Constants for parts of translation.
  2037. */
  2038. var CONTEXT_MENU_ITEMS_NAMESPACE = exports.CONTEXT_MENU_ITEMS_NAMESPACE = 'ContextMenu:items';
  2039. var CONTEXTMENU_ITEMS_ROW_ABOVE = exports.CONTEXTMENU_ITEMS_ROW_ABOVE = CONTEXT_MENU_ITEMS_NAMESPACE + '.insertRowAbove';
  2040. var CONTEXTMENU_ITEMS_ROW_BELOW = exports.CONTEXTMENU_ITEMS_ROW_BELOW = CONTEXT_MENU_ITEMS_NAMESPACE + '.insertRowBelow';
  2041. var CONTEXTMENU_ITEMS_INSERT_LEFT = exports.CONTEXTMENU_ITEMS_INSERT_LEFT = CONTEXT_MENU_ITEMS_NAMESPACE + '.insertColumnOnTheLeft';
  2042. var CONTEXTMENU_ITEMS_INSERT_RIGHT = exports.CONTEXTMENU_ITEMS_INSERT_RIGHT = CONTEXT_MENU_ITEMS_NAMESPACE + '.insertColumnOnTheRight';
  2043. var CONTEXTMENU_ITEMS_REMOVE_ROW = exports.CONTEXTMENU_ITEMS_REMOVE_ROW = CONTEXT_MENU_ITEMS_NAMESPACE + '.removeRow';
  2044. var CONTEXTMENU_ITEMS_REMOVE_COLUMN = exports.CONTEXTMENU_ITEMS_REMOVE_COLUMN = CONTEXT_MENU_ITEMS_NAMESPACE + '.removeColumn';
  2045. var CONTEXTMENU_ITEMS_UNDO = exports.CONTEXTMENU_ITEMS_UNDO = CONTEXT_MENU_ITEMS_NAMESPACE + '.undo';
  2046. var CONTEXTMENU_ITEMS_REDO = exports.CONTEXTMENU_ITEMS_REDO = CONTEXT_MENU_ITEMS_NAMESPACE + '.redo';
  2047. var CONTEXTMENU_ITEMS_READ_ONLY = exports.CONTEXTMENU_ITEMS_READ_ONLY = CONTEXT_MENU_ITEMS_NAMESPACE + '.readOnly';
  2048. var CONTEXTMENU_ITEMS_CLEAR_COLUMN = exports.CONTEXTMENU_ITEMS_CLEAR_COLUMN = CONTEXT_MENU_ITEMS_NAMESPACE + '.clearColumn';
  2049. var CONTEXTMENU_ITEMS_COPY = exports.CONTEXTMENU_ITEMS_COPY = CONTEXT_MENU_ITEMS_NAMESPACE + '.copy';
  2050. var CONTEXTMENU_ITEMS_CUT = exports.CONTEXTMENU_ITEMS_CUT = CONTEXT_MENU_ITEMS_NAMESPACE + '.cut';
  2051. var CONTEXTMENU_ITEMS_FREEZE_COLUMN = exports.CONTEXTMENU_ITEMS_FREEZE_COLUMN = CONTEXT_MENU_ITEMS_NAMESPACE + '.freezeColumn';
  2052. var CONTEXTMENU_ITEMS_UNFREEZE_COLUMN = exports.CONTEXTMENU_ITEMS_UNFREEZE_COLUMN = CONTEXT_MENU_ITEMS_NAMESPACE + '.unfreezeColumn';
  2053. var CONTEXTMENU_ITEMS_MERGE_CELLS = exports.CONTEXTMENU_ITEMS_MERGE_CELLS = CONTEXT_MENU_ITEMS_NAMESPACE + '.mergeCells';
  2054. var CONTEXTMENU_ITEMS_UNMERGE_CELLS = exports.CONTEXTMENU_ITEMS_UNMERGE_CELLS = CONTEXT_MENU_ITEMS_NAMESPACE + '.unmergeCells';
  2055. var CONTEXTMENU_ITEMS_ADD_COMMENT = exports.CONTEXTMENU_ITEMS_ADD_COMMENT = CONTEXT_MENU_ITEMS_NAMESPACE + '.addComment';
  2056. var CONTEXTMENU_ITEMS_EDIT_COMMENT = exports.CONTEXTMENU_ITEMS_EDIT_COMMENT = CONTEXT_MENU_ITEMS_NAMESPACE + '.editComment';
  2057. var CONTEXTMENU_ITEMS_REMOVE_COMMENT = exports.CONTEXTMENU_ITEMS_REMOVE_COMMENT = CONTEXT_MENU_ITEMS_NAMESPACE + '.removeComment';
  2058. var CONTEXTMENU_ITEMS_READ_ONLY_COMMENT = exports.CONTEXTMENU_ITEMS_READ_ONLY_COMMENT = CONTEXT_MENU_ITEMS_NAMESPACE + '.readOnlyComment';
  2059. var CONTEXTMENU_ITEMS_ALIGNMENT = exports.CONTEXTMENU_ITEMS_ALIGNMENT = CONTEXT_MENU_ITEMS_NAMESPACE + '.align';
  2060. var CONTEXTMENU_ITEMS_ALIGNMENT_LEFT = exports.CONTEXTMENU_ITEMS_ALIGNMENT_LEFT = CONTEXT_MENU_ITEMS_NAMESPACE + '.align.left';
  2061. var CONTEXTMENU_ITEMS_ALIGNMENT_CENTER = exports.CONTEXTMENU_ITEMS_ALIGNMENT_CENTER = CONTEXT_MENU_ITEMS_NAMESPACE + '.align.center';
  2062. var CONTEXTMENU_ITEMS_ALIGNMENT_RIGHT = exports.CONTEXTMENU_ITEMS_ALIGNMENT_RIGHT = CONTEXT_MENU_ITEMS_NAMESPACE + '.align.right';
  2063. var CONTEXTMENU_ITEMS_ALIGNMENT_JUSTIFY = exports.CONTEXTMENU_ITEMS_ALIGNMENT_JUSTIFY = CONTEXT_MENU_ITEMS_NAMESPACE + '.align.justify';
  2064. var CONTEXTMENU_ITEMS_ALIGNMENT_TOP = exports.CONTEXTMENU_ITEMS_ALIGNMENT_TOP = CONTEXT_MENU_ITEMS_NAMESPACE + '.align.top';
  2065. var CONTEXTMENU_ITEMS_ALIGNMENT_MIDDLE = exports.CONTEXTMENU_ITEMS_ALIGNMENT_MIDDLE = CONTEXT_MENU_ITEMS_NAMESPACE + '.align.middle';
  2066. var CONTEXTMENU_ITEMS_ALIGNMENT_BOTTOM = exports.CONTEXTMENU_ITEMS_ALIGNMENT_BOTTOM = CONTEXT_MENU_ITEMS_NAMESPACE + '.align.bottom';
  2067. var CONTEXTMENU_ITEMS_BORDERS = exports.CONTEXTMENU_ITEMS_BORDERS = CONTEXT_MENU_ITEMS_NAMESPACE + '.borders';
  2068. var CONTEXTMENU_ITEMS_BORDERS_TOP = exports.CONTEXTMENU_ITEMS_BORDERS_TOP = CONTEXT_MENU_ITEMS_NAMESPACE + '.borders.top';
  2069. var CONTEXTMENU_ITEMS_BORDERS_RIGHT = exports.CONTEXTMENU_ITEMS_BORDERS_RIGHT = CONTEXT_MENU_ITEMS_NAMESPACE + '.borders.right';
  2070. var CONTEXTMENU_ITEMS_BORDERS_BOTTOM = exports.CONTEXTMENU_ITEMS_BORDERS_BOTTOM = CONTEXT_MENU_ITEMS_NAMESPACE + '.borders.bottom';
  2071. var CONTEXTMENU_ITEMS_BORDERS_LEFT = exports.CONTEXTMENU_ITEMS_BORDERS_LEFT = CONTEXT_MENU_ITEMS_NAMESPACE + '.borders.left';
  2072. var CONTEXTMENU_ITEMS_REMOVE_BORDERS = exports.CONTEXTMENU_ITEMS_REMOVE_BORDERS = CONTEXT_MENU_ITEMS_NAMESPACE + '.borders.remove';
  2073. var CONTEXTMENU_ITEMS_NESTED_ROWS_INSERT_CHILD = exports.CONTEXTMENU_ITEMS_NESTED_ROWS_INSERT_CHILD = CONTEXT_MENU_ITEMS_NAMESPACE + '.nestedHeaders.insertChildRow';
  2074. var CONTEXTMENU_ITEMS_NESTED_ROWS_DETACH_CHILD = exports.CONTEXTMENU_ITEMS_NESTED_ROWS_DETACH_CHILD = CONTEXT_MENU_ITEMS_NAMESPACE + '.nestedHeaders.detachFromParent';
  2075. var CONTEXTMENU_ITEMS_HIDE_COLUMN = exports.CONTEXTMENU_ITEMS_HIDE_COLUMN = CONTEXT_MENU_ITEMS_NAMESPACE + '.hideColumn';
  2076. var CONTEXTMENU_ITEMS_SHOW_COLUMN = exports.CONTEXTMENU_ITEMS_SHOW_COLUMN = CONTEXT_MENU_ITEMS_NAMESPACE + '.showColumn';
  2077. var CONTEXTMENU_ITEMS_HIDE_ROW = exports.CONTEXTMENU_ITEMS_HIDE_ROW = CONTEXT_MENU_ITEMS_NAMESPACE + '.hideRow';
  2078. var CONTEXTMENU_ITEMS_SHOW_ROW = exports.CONTEXTMENU_ITEMS_SHOW_ROW = CONTEXT_MENU_ITEMS_NAMESPACE + '.showRow';
  2079. var FILTERS_NAMESPACE = exports.FILTERS_NAMESPACE = 'Filters:';
  2080. var FILTERS_CONDITIONS_NAMESPACE = exports.FILTERS_CONDITIONS_NAMESPACE = FILTERS_NAMESPACE + 'conditions';
  2081. var FILTERS_CONDITIONS_NONE = exports.FILTERS_CONDITIONS_NONE = FILTERS_CONDITIONS_NAMESPACE + '.none';
  2082. var FILTERS_CONDITIONS_EMPTY = exports.FILTERS_CONDITIONS_EMPTY = FILTERS_CONDITIONS_NAMESPACE + '.isEmpty';
  2083. var FILTERS_CONDITIONS_NOT_EMPTY = exports.FILTERS_CONDITIONS_NOT_EMPTY = FILTERS_CONDITIONS_NAMESPACE + '.isNotEmpty';
  2084. var FILTERS_CONDITIONS_EQUAL = exports.FILTERS_CONDITIONS_EQUAL = FILTERS_CONDITIONS_NAMESPACE + '.isEqualTo';
  2085. var FILTERS_CONDITIONS_NOT_EQUAL = exports.FILTERS_CONDITIONS_NOT_EQUAL = FILTERS_CONDITIONS_NAMESPACE + '.isNotEqualTo';
  2086. var FILTERS_CONDITIONS_BEGINS_WITH = exports.FILTERS_CONDITIONS_BEGINS_WITH = FILTERS_CONDITIONS_NAMESPACE + '.beginsWith';
  2087. var FILTERS_CONDITIONS_ENDS_WITH = exports.FILTERS_CONDITIONS_ENDS_WITH = FILTERS_CONDITIONS_NAMESPACE + '.endsWith';
  2088. var FILTERS_CONDITIONS_CONTAINS = exports.FILTERS_CONDITIONS_CONTAINS = FILTERS_CONDITIONS_NAMESPACE + '.contains';
  2089. var FILTERS_CONDITIONS_NOT_CONTAIN = exports.FILTERS_CONDITIONS_NOT_CONTAIN = FILTERS_CONDITIONS_NAMESPACE + '.doesNotContain';
  2090. var FILTERS_CONDITIONS_BY_VALUE = exports.FILTERS_CONDITIONS_BY_VALUE = FILTERS_CONDITIONS_NAMESPACE + '.byValue';
  2091. var FILTERS_CONDITIONS_GREATER_THAN = exports.FILTERS_CONDITIONS_GREATER_THAN = FILTERS_CONDITIONS_NAMESPACE + '.greaterThan';
  2092. var FILTERS_CONDITIONS_GREATER_THAN_OR_EQUAL = exports.FILTERS_CONDITIONS_GREATER_THAN_OR_EQUAL = FILTERS_CONDITIONS_NAMESPACE + '.greaterThanOrEqualTo';
  2093. var FILTERS_CONDITIONS_LESS_THAN = exports.FILTERS_CONDITIONS_LESS_THAN = FILTERS_CONDITIONS_NAMESPACE + '.lessThan';
  2094. var FILTERS_CONDITIONS_LESS_THAN_OR_EQUAL = exports.FILTERS_CONDITIONS_LESS_THAN_OR_EQUAL = FILTERS_CONDITIONS_NAMESPACE + '.lessThanOrEqualTo';
  2095. var FILTERS_CONDITIONS_BETWEEN = exports.FILTERS_CONDITIONS_BETWEEN = FILTERS_CONDITIONS_NAMESPACE + '.isBetween';
  2096. var FILTERS_CONDITIONS_NOT_BETWEEN = exports.FILTERS_CONDITIONS_NOT_BETWEEN = FILTERS_CONDITIONS_NAMESPACE + '.isNotBetween';
  2097. var FILTERS_CONDITIONS_AFTER = exports.FILTERS_CONDITIONS_AFTER = FILTERS_CONDITIONS_NAMESPACE + '.after';
  2098. var FILTERS_CONDITIONS_BEFORE = exports.FILTERS_CONDITIONS_BEFORE = FILTERS_CONDITIONS_NAMESPACE + '.before';
  2099. var FILTERS_CONDITIONS_TODAY = exports.FILTERS_CONDITIONS_TODAY = FILTERS_CONDITIONS_NAMESPACE + '.today';
  2100. var FILTERS_CONDITIONS_TOMORROW = exports.FILTERS_CONDITIONS_TOMORROW = FILTERS_CONDITIONS_NAMESPACE + '.tomorrow';
  2101. var FILTERS_CONDITIONS_YESTERDAY = exports.FILTERS_CONDITIONS_YESTERDAY = FILTERS_CONDITIONS_NAMESPACE + '.yesterday';
  2102. var FILTERS_DIVS_FILTER_BY_CONDITION = exports.FILTERS_DIVS_FILTER_BY_CONDITION = FILTERS_NAMESPACE + 'labels.filterByCondition';
  2103. var FILTERS_DIVS_FILTER_BY_VALUE = exports.FILTERS_DIVS_FILTER_BY_VALUE = FILTERS_NAMESPACE + 'labels.filterByValue';
  2104. var FILTERS_LABELS_CONJUNCTION = exports.FILTERS_LABELS_CONJUNCTION = FILTERS_NAMESPACE + 'labels.conjunction';
  2105. var FILTERS_LABELS_DISJUNCTION = exports.FILTERS_LABELS_DISJUNCTION = FILTERS_NAMESPACE + 'labels.disjunction';
  2106. var FILTERS_VALUES_BLANK_CELLS = exports.FILTERS_VALUES_BLANK_CELLS = FILTERS_NAMESPACE + 'values.blankCells';
  2107. var FILTERS_BUTTONS_SELECT_ALL = exports.FILTERS_BUTTONS_SELECT_ALL = FILTERS_NAMESPACE + 'buttons.selectAll';
  2108. var FILTERS_BUTTONS_CLEAR = exports.FILTERS_BUTTONS_CLEAR = FILTERS_NAMESPACE + 'buttons.clear';
  2109. var FILTERS_BUTTONS_OK = exports.FILTERS_BUTTONS_OK = FILTERS_NAMESPACE + 'buttons.ok';
  2110. var FILTERS_BUTTONS_CANCEL = exports.FILTERS_BUTTONS_CANCEL = FILTERS_NAMESPACE + 'buttons.cancel';
  2111. var FILTERS_BUTTONS_PLACEHOLDER_SEARCH = exports.FILTERS_BUTTONS_PLACEHOLDER_SEARCH = FILTERS_NAMESPACE + 'buttons.placeholder.search';
  2112. var FILTERS_BUTTONS_PLACEHOLDER_VALUE = exports.FILTERS_BUTTONS_PLACEHOLDER_VALUE = FILTERS_NAMESPACE + 'buttons.placeholder.value';
  2113. var FILTERS_BUTTONS_PLACEHOLDER_SECOND_VALUE = exports.FILTERS_BUTTONS_PLACEHOLDER_SECOND_VALUE = FILTERS_NAMESPACE + 'buttons.placeholder.secondValue';
  2114. /***/ }),
  2115. /* 8 */
  2116. /***/ (function(module, exports, __webpack_require__) {
  2117. "use strict";
  2118. exports.__esModule = true;
  2119. exports.getPluginName = exports.getRegistredPluginNames = exports.getPlugin = exports.registerPlugin = undefined;
  2120. var _pluginHooks = __webpack_require__(15);
  2121. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  2122. var _object = __webpack_require__(2);
  2123. var _string = __webpack_require__(36);
  2124. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2125. var registeredPlugins = new WeakMap();
  2126. /**
  2127. * Registers plugin under given name
  2128. *
  2129. * @param {String} pluginName
  2130. * @param {Function} PluginClass
  2131. */
  2132. /**
  2133. * Utility to register plugins and common namespace for keeping reference to all plugins classes
  2134. */
  2135. function registerPlugin(pluginName, PluginClass) {
  2136. pluginName = (0, _string.toUpperCaseFirst)(pluginName);
  2137. _pluginHooks2.default.getSingleton().add('construct', function () {
  2138. var holder = void 0;
  2139. if (!registeredPlugins.has(this)) {
  2140. registeredPlugins.set(this, {});
  2141. }
  2142. holder = registeredPlugins.get(this);
  2143. if (!holder[pluginName]) {
  2144. holder[pluginName] = new PluginClass(this);
  2145. }
  2146. });
  2147. _pluginHooks2.default.getSingleton().add('afterDestroy', function () {
  2148. if (registeredPlugins.has(this)) {
  2149. var pluginsHolder = registeredPlugins.get(this);
  2150. (0, _object.objectEach)(pluginsHolder, function (plugin) {
  2151. return plugin.destroy();
  2152. });
  2153. registeredPlugins.delete(this);
  2154. }
  2155. });
  2156. }
  2157. /**
  2158. * @param {Object} instance
  2159. * @param {String|Function} pluginName
  2160. * @returns {Function} pluginClass Returns plugin instance if exists or `undefined` if not exists.
  2161. */
  2162. function getPlugin(instance, pluginName) {
  2163. if (typeof pluginName != 'string') {
  2164. throw Error('Only strings can be passed as "plugin" parameter');
  2165. }
  2166. var _pluginName = (0, _string.toUpperCaseFirst)(pluginName);
  2167. if (!registeredPlugins.has(instance) || !registeredPlugins.get(instance)[_pluginName]) {
  2168. return void 0;
  2169. }
  2170. return registeredPlugins.get(instance)[_pluginName];
  2171. }
  2172. /**
  2173. * Get all registred plugins names for concrete Handsontable instance.
  2174. *
  2175. * @param {Object} hotInstance
  2176. * @returns {Array}
  2177. */
  2178. function getRegistredPluginNames(hotInstance) {
  2179. return registeredPlugins.has(hotInstance) ? Object.keys(registeredPlugins.get(hotInstance)) : [];
  2180. }
  2181. /**
  2182. * Get plugin name.
  2183. *
  2184. * @param {Object} hotInstance
  2185. * @param {Object} plugin
  2186. * @returns {String|null}
  2187. */
  2188. function getPluginName(hotInstance, plugin) {
  2189. var pluginName = null;
  2190. if (registeredPlugins.has(hotInstance)) {
  2191. (0, _object.objectEach)(registeredPlugins.get(hotInstance), function (pluginInstance, name) {
  2192. if (pluginInstance === plugin) {
  2193. pluginName = name;
  2194. }
  2195. });
  2196. }
  2197. return pluginName;
  2198. }
  2199. exports.registerPlugin = registerPlugin;
  2200. exports.getPlugin = getPlugin;
  2201. exports.getRegistredPluginNames = getRegistredPluginNames;
  2202. exports.getPluginName = getPluginName;
  2203. /***/ }),
  2204. /* 9 */
  2205. /***/ (function(module, exports) {
  2206. module.exports = function (it) {
  2207. return typeof it === 'object' ? it !== null : typeof it === 'function';
  2208. };
  2209. /***/ }),
  2210. /* 10 */
  2211. /***/ (function(module, exports, __webpack_require__) {
  2212. "use strict";
  2213. exports.__esModule = true;
  2214. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2215. var _object = __webpack_require__(2);
  2216. var _array = __webpack_require__(1);
  2217. var _recordTranslator = __webpack_require__(313);
  2218. var _plugins = __webpack_require__(8);
  2219. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2220. var privatePool = new WeakMap();
  2221. var initializedPlugins = null;
  2222. /**
  2223. * @private
  2224. */
  2225. var BasePlugin = function () {
  2226. /**
  2227. * @param {Object} hotInstance Handsontable instance.
  2228. */
  2229. function BasePlugin(hotInstance) {
  2230. var _this = this;
  2231. _classCallCheck(this, BasePlugin);
  2232. /**
  2233. * Handsontable instance.
  2234. *
  2235. * @type {Core}
  2236. */
  2237. (0, _object.defineGetter)(this, 'hot', hotInstance, {
  2238. writable: false
  2239. });
  2240. (0, _object.defineGetter)(this, 't', (0, _recordTranslator.getTranslator)(hotInstance), {
  2241. writable: false
  2242. });
  2243. privatePool.set(this, { hooks: {} });
  2244. initializedPlugins = null;
  2245. this.pluginName = null;
  2246. this.pluginsInitializedCallbacks = [];
  2247. this.isPluginsReady = false;
  2248. this.enabled = false;
  2249. this.initialized = false;
  2250. this.hot.addHook('afterPluginsInitialized', function () {
  2251. return _this.onAfterPluginsInitialized();
  2252. });
  2253. this.hot.addHook('afterUpdateSettings', function () {
  2254. return _this.onUpdateSettings();
  2255. });
  2256. this.hot.addHook('beforeInit', function () {
  2257. return _this.init();
  2258. });
  2259. }
  2260. _createClass(BasePlugin, [{
  2261. key: 'init',
  2262. value: function init() {
  2263. this.pluginName = (0, _plugins.getPluginName)(this.hot, this);
  2264. if (this.isEnabled && this.isEnabled()) {
  2265. this.enablePlugin();
  2266. }
  2267. if (!initializedPlugins) {
  2268. initializedPlugins = (0, _plugins.getRegistredPluginNames)(this.hot);
  2269. }
  2270. if (initializedPlugins.indexOf(this.pluginName) >= 0) {
  2271. initializedPlugins.splice(initializedPlugins.indexOf(this.pluginName), 1);
  2272. }
  2273. if (!initializedPlugins.length) {
  2274. this.hot.runHooks('afterPluginsInitialized');
  2275. }
  2276. this.initialized = true;
  2277. }
  2278. /**
  2279. * Enable plugin for this Handsontable instance.
  2280. */
  2281. }, {
  2282. key: 'enablePlugin',
  2283. value: function enablePlugin() {
  2284. this.enabled = true;
  2285. }
  2286. /**
  2287. * Disable plugin for this Handsontable instance.
  2288. */
  2289. }, {
  2290. key: 'disablePlugin',
  2291. value: function disablePlugin() {
  2292. if (this.eventManager) {
  2293. this.eventManager.clear();
  2294. }
  2295. this.clearHooks();
  2296. this.enabled = false;
  2297. }
  2298. /**
  2299. * Add listener to plugin hooks system.
  2300. *
  2301. * @param {String} name
  2302. * @param {Function} callback
  2303. */
  2304. }, {
  2305. key: 'addHook',
  2306. value: function addHook(name, callback) {
  2307. privatePool.get(this).hooks[name] = privatePool.get(this).hooks[name] || [];
  2308. var hooks = privatePool.get(this).hooks[name];
  2309. this.hot.addHook(name, callback);
  2310. hooks.push(callback);
  2311. privatePool.get(this).hooks[name] = hooks;
  2312. }
  2313. /**
  2314. * Remove all hooks listeners by hook name.
  2315. *
  2316. * @param {String} name
  2317. */
  2318. }, {
  2319. key: 'removeHooks',
  2320. value: function removeHooks(name) {
  2321. var _this2 = this;
  2322. (0, _array.arrayEach)(privatePool.get(this).hooks[name] || [], function (callback) {
  2323. _this2.hot.removeHook(name, callback);
  2324. });
  2325. }
  2326. /**
  2327. * Clear all hooks.
  2328. */
  2329. }, {
  2330. key: 'clearHooks',
  2331. value: function clearHooks() {
  2332. var _this3 = this;
  2333. var hooks = privatePool.get(this).hooks;
  2334. (0, _object.objectEach)(hooks, function (callbacks, name) {
  2335. return _this3.removeHooks(name);
  2336. });
  2337. hooks.length = 0;
  2338. }
  2339. /**
  2340. * Register function which will be immediately called after all plugins initialized.
  2341. *
  2342. * @param {Function} callback
  2343. */
  2344. }, {
  2345. key: 'callOnPluginsReady',
  2346. value: function callOnPluginsReady(callback) {
  2347. if (this.isPluginsReady) {
  2348. callback();
  2349. } else {
  2350. this.pluginsInitializedCallbacks.push(callback);
  2351. }
  2352. }
  2353. /**
  2354. * On after plugins initialized listener.
  2355. *
  2356. * @private
  2357. */
  2358. }, {
  2359. key: 'onAfterPluginsInitialized',
  2360. value: function onAfterPluginsInitialized() {
  2361. (0, _array.arrayEach)(this.pluginsInitializedCallbacks, function (callback) {
  2362. return callback();
  2363. });
  2364. this.pluginsInitializedCallbacks.length = 0;
  2365. this.isPluginsReady = true;
  2366. }
  2367. /**
  2368. * On update settings listener.
  2369. *
  2370. * @private
  2371. */
  2372. }, {
  2373. key: 'onUpdateSettings',
  2374. value: function onUpdateSettings() {
  2375. if (this.isEnabled) {
  2376. if (this.enabled && !this.isEnabled()) {
  2377. this.disablePlugin();
  2378. }
  2379. if (!this.enabled && this.isEnabled()) {
  2380. this.enablePlugin();
  2381. }
  2382. if (this.enabled && this.isEnabled()) {
  2383. this.updatePlugin();
  2384. }
  2385. }
  2386. }
  2387. /**
  2388. * Updates the plugin to use the latest options you have specified.
  2389. *
  2390. * @private
  2391. */
  2392. }, {
  2393. key: 'updatePlugin',
  2394. value: function updatePlugin() {}
  2395. /**
  2396. * Destroy plugin.
  2397. */
  2398. }, {
  2399. key: 'destroy',
  2400. value: function destroy() {
  2401. var _this4 = this;
  2402. if (this.eventManager) {
  2403. this.eventManager.destroy();
  2404. }
  2405. this.clearHooks();
  2406. (0, _object.objectEach)(this, function (value, property) {
  2407. if (property !== 'hot' && property !== 't') {
  2408. _this4[property] = null;
  2409. }
  2410. });
  2411. delete this.t;
  2412. delete this.hot;
  2413. }
  2414. }]);
  2415. return BasePlugin;
  2416. }();
  2417. exports.default = BasePlugin;
  2418. /***/ }),
  2419. /* 11 */
  2420. /***/ (function(module, exports, __webpack_require__) {
  2421. var store = __webpack_require__(77)('wks');
  2422. var uid = __webpack_require__(49);
  2423. var Symbol = __webpack_require__(14).Symbol;
  2424. var USE_SYMBOL = typeof Symbol == 'function';
  2425. var $exports = module.exports = function (name) {
  2426. return store[name] || (store[name] =
  2427. USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
  2428. };
  2429. $exports.store = store;
  2430. /***/ }),
  2431. /* 12 */
  2432. /***/ (function(module, exports, __webpack_require__) {
  2433. "use strict";
  2434. exports.__esModule = true;
  2435. exports.stopImmediatePropagation = stopImmediatePropagation;
  2436. exports.isImmediatePropagationStopped = isImmediatePropagationStopped;
  2437. exports.stopPropagation = stopPropagation;
  2438. exports.pageX = pageX;
  2439. exports.pageY = pageY;
  2440. exports.isRightClick = isRightClick;
  2441. exports.isLeftClick = isLeftClick;
  2442. var _element = __webpack_require__(0);
  2443. /**
  2444. * Prevent other listeners of the same event from being called.
  2445. *
  2446. * @param {Event} event
  2447. */
  2448. function stopImmediatePropagation(event) {
  2449. event.isImmediatePropagationEnabled = false;
  2450. event.cancelBubble = true;
  2451. }
  2452. /**
  2453. * Check if event was stopped by `stopImmediatePropagation`.
  2454. *
  2455. * @param event {Event}
  2456. * @returns {Boolean}
  2457. */
  2458. function isImmediatePropagationStopped(event) {
  2459. return event.isImmediatePropagationEnabled === false;
  2460. }
  2461. /**
  2462. * Prevent further propagation of the current event (prevent bubbling).
  2463. *
  2464. * @param event {Event}
  2465. */
  2466. function stopPropagation(event) {
  2467. // ie8
  2468. // http://msdn.microsoft.com/en-us/library/ie/ff975462(v=vs.85).aspx
  2469. if (typeof event.stopPropagation === 'function') {
  2470. event.stopPropagation();
  2471. } else {
  2472. event.cancelBubble = true;
  2473. }
  2474. }
  2475. /**
  2476. * Get horizontal coordinate of the event object relative to the whole document.
  2477. *
  2478. * @param {Event} event
  2479. * @returns {Number}
  2480. */
  2481. function pageX(event) {
  2482. if (event.pageX) {
  2483. return event.pageX;
  2484. }
  2485. return event.clientX + (0, _element.getWindowScrollLeft)();
  2486. }
  2487. /**
  2488. * Get vertical coordinate of the event object relative to the whole document.
  2489. *
  2490. * @param {Event} event
  2491. * @returns {Number}
  2492. */
  2493. function pageY(event) {
  2494. if (event.pageY) {
  2495. return event.pageY;
  2496. }
  2497. return event.clientY + (0, _element.getWindowScrollTop)();
  2498. }
  2499. /**
  2500. * Check if provided event was triggered by clicking the right mouse button.
  2501. *
  2502. * @param {Event} event DOM Event.
  2503. * @returns {Boolean}
  2504. */
  2505. function isRightClick(event) {
  2506. return event.button === 2;
  2507. }
  2508. /**
  2509. * Check if provided event was triggered by clicking the left mouse button.
  2510. *
  2511. * @param {Event} event DOM Event.
  2512. * @returns {Boolean}
  2513. */
  2514. function isLeftClick(event) {
  2515. return event.button === 0;
  2516. }
  2517. /***/ }),
  2518. /* 13 */
  2519. /***/ (function(module, exports, __webpack_require__) {
  2520. "use strict";
  2521. exports.__esModule = true;
  2522. exports.getRegisteredRenderers = exports.getRegisteredRendererNames = exports.hasRenderer = exports.getRenderer = exports.registerRenderer = undefined;
  2523. var _staticRegister2 = __webpack_require__(39);
  2524. var _staticRegister3 = _interopRequireDefault(_staticRegister2);
  2525. var _cellDecorator = __webpack_require__(364);
  2526. var _cellDecorator2 = _interopRequireDefault(_cellDecorator);
  2527. var _autocompleteRenderer = __webpack_require__(365);
  2528. var _autocompleteRenderer2 = _interopRequireDefault(_autocompleteRenderer);
  2529. var _checkboxRenderer = __webpack_require__(366);
  2530. var _checkboxRenderer2 = _interopRequireDefault(_checkboxRenderer);
  2531. var _htmlRenderer = __webpack_require__(367);
  2532. var _htmlRenderer2 = _interopRequireDefault(_htmlRenderer);
  2533. var _numericRenderer = __webpack_require__(368);
  2534. var _numericRenderer2 = _interopRequireDefault(_numericRenderer);
  2535. var _passwordRenderer = __webpack_require__(370);
  2536. var _passwordRenderer2 = _interopRequireDefault(_passwordRenderer);
  2537. var _textRenderer = __webpack_require__(371);
  2538. var _textRenderer2 = _interopRequireDefault(_textRenderer);
  2539. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2540. var _staticRegister = (0, _staticRegister3.default)('renderers'),
  2541. register = _staticRegister.register,
  2542. getItem = _staticRegister.getItem,
  2543. hasItem = _staticRegister.hasItem,
  2544. getNames = _staticRegister.getNames,
  2545. getValues = _staticRegister.getValues;
  2546. register('base', _cellDecorator2.default);
  2547. register('autocomplete', _autocompleteRenderer2.default);
  2548. register('checkbox', _checkboxRenderer2.default);
  2549. register('html', _htmlRenderer2.default);
  2550. register('numeric', _numericRenderer2.default);
  2551. register('password', _passwordRenderer2.default);
  2552. register('text', _textRenderer2.default);
  2553. /**
  2554. * Retrieve renderer function.
  2555. *
  2556. * @param {String} name Renderer identification.
  2557. * @returns {Function} Returns renderer function.
  2558. */
  2559. function _getItem(name) {
  2560. if (typeof name === 'function') {
  2561. return name;
  2562. }
  2563. if (!hasItem(name)) {
  2564. throw Error('No registered renderer found under "' + name + '" name');
  2565. }
  2566. return getItem(name);
  2567. }
  2568. exports.registerRenderer = register;
  2569. exports.getRenderer = _getItem;
  2570. exports.hasRenderer = hasItem;
  2571. exports.getRegisteredRendererNames = getNames;
  2572. exports.getRegisteredRenderers = getValues;
  2573. /***/ }),
  2574. /* 14 */
  2575. /***/ (function(module, exports) {
  2576. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  2577. var global = module.exports = typeof window != 'undefined' && window.Math == Math
  2578. ? window : typeof self != 'undefined' && self.Math == Math ? self
  2579. // eslint-disable-next-line no-new-func
  2580. : Function('return this')();
  2581. if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
  2582. /***/ }),
  2583. /* 15 */
  2584. /***/ (function(module, exports, __webpack_require__) {
  2585. "use strict";
  2586. exports.__esModule = true;
  2587. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2588. var _array = __webpack_require__(1);
  2589. var _object = __webpack_require__(2);
  2590. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2591. /**
  2592. * @description
  2593. * Handsontable events are the common interface that function in 2 ways: as __callbacks__ and as __hooks__.
  2594. *
  2595. * @example
  2596. *
  2597. * ```js
  2598. * // Using events as callbacks:
  2599. * ...
  2600. * var hot1 = new Handsontable(document.getElementById('example1'), {
  2601. * afterChange: function(changes, source) {
  2602. * $.ajax({
  2603. * url: "save.php',
  2604. * data: change
  2605. * });
  2606. * }
  2607. * });
  2608. * ...
  2609. * ```
  2610. *
  2611. * ```js
  2612. * // Using events as plugin hooks:
  2613. * ...
  2614. * var hot1 = new Handsontable(document.getElementById('example1'), {
  2615. * myPlugin: true
  2616. * });
  2617. *
  2618. * var hot2 = new Handsontable(document.getElementById('example2'), {
  2619. * myPlugin: false
  2620. * });
  2621. *
  2622. * // global hook
  2623. * Handsontable.hooks.add('afterChange', function() {
  2624. * // Fired twice - for hot1 and hot2
  2625. * if (this.getSettings().myPlugin) {
  2626. * // function body - will only run for hot1
  2627. * }
  2628. * });
  2629. *
  2630. * // local hook (has same effect as a callback)
  2631. * hot2.addHook('afterChange', function() {
  2632. * // function body - will only run in #example2
  2633. * });
  2634. * ```
  2635. * ...
  2636. */
  2637. // @TODO: Move plugin description hooks to plugin?
  2638. var REGISTERED_HOOKS = [
  2639. /**
  2640. * Callback fired after resetting a cell's meta.
  2641. *
  2642. * @event Hooks#afterCellMetaReset
  2643. * @since 0.11
  2644. */
  2645. 'afterCellMetaReset',
  2646. /**
  2647. * @description
  2648. * Callback fired after one or more cells has been changed. Its main use case is to save the input.
  2649. *
  2650. * __Note:__ For performance reasons, the `changes` array is null for `"loadData"` source.
  2651. *
  2652. * @event Hooks#afterChange
  2653. * @param {Array} changes 2D array containing information about each of the edited cells `[[row, prop, oldVal, newVal], ...]`.
  2654. * @param {String} [source] String that identifies source of hook call
  2655. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  2656. */
  2657. 'afterChange',
  2658. /**
  2659. * @description
  2660. * Fired after observing changes.
  2661. *
  2662. * @event Hooks#afterChangesObserved
  2663. */
  2664. 'afterChangesObserved',
  2665. /**
  2666. * @description
  2667. * Fired after setting up the Context Menu's default options. These options are a collection which user can select by setting
  2668. * an array of keys or an array of objects in `contextMenu` option.
  2669. *
  2670. * @event Hooks#afterContextMenuDefaultOptions
  2671. * @param {Array} predefinedItems Array of objects containing information about the pre-defined Context Menu items.
  2672. */
  2673. 'afterContextMenuDefaultOptions',
  2674. /**
  2675. * @description
  2676. * Fired before setting up the Context Menu's items but after filtering these options by user (`contextMenu` option). This hook
  2677. * can by helpful to determine if user use specified menu item or to set up one of the menu item to by always visible.
  2678. *
  2679. * @event Hooks#beforeContextMenuSetItems
  2680. * @param {Array} menuItems Array of objects containing information about to generated Context Menu items.
  2681. */
  2682. 'beforeContextMenuSetItems',
  2683. /**
  2684. * @description
  2685. * Fired after setting up the Context Menu's default options. These options are a collection which user can select by setting
  2686. * an array of keys or an array of objects in `contextMenu` option.
  2687. *
  2688. * @pro
  2689. * @event Hooks#afterDropdownMenuDefaultOptions
  2690. * @param {Array} predefinedItems Array of objects containing information about the pre-defined Context Menu items.
  2691. */
  2692. 'afterDropdownMenuDefaultOptions',
  2693. /**
  2694. * @description
  2695. * Fired before setting up the Dropdown Menu's items but after filtering these options by user (`dropdownMenu` option). This hook
  2696. * can by helpful to determine if user use specified menu item or to set up one of the menu item to by always visible.
  2697. *
  2698. * @pro
  2699. * @event Hooks#beforeDropdownMenuSetItems
  2700. * @param {Array} menuItems Array of objects containing information about to generated Dropdown Menu items.
  2701. */
  2702. 'beforeDropdownMenuSetItems',
  2703. /**
  2704. * @description
  2705. * Fired after hiding the Context Menu.
  2706. *
  2707. * @event Hooks#afterContextMenuHide
  2708. * @param {Object} context The Context menu instance.
  2709. */
  2710. 'afterContextMenuHide',
  2711. /**
  2712. * @description
  2713. * Fired before opening the Context Menu.
  2714. *
  2715. * @event Hooks#beforeContextMenuShow
  2716. * @param {Object} context The Context Menu instance.
  2717. */
  2718. 'beforeContextMenuShow',
  2719. /**
  2720. * @description
  2721. * Fired after opening the Context Menu.
  2722. *
  2723. * @event Hooks#afterContextMenuShow
  2724. * @param {Object} context The Context Menu instance.
  2725. */
  2726. 'afterContextMenuShow',
  2727. /**
  2728. * @description
  2729. * Fired after reaching the copy limit while copying data.
  2730. *
  2731. * @event Hooks#afterCopyLimit
  2732. * @param {Number} selectedRows Count of selected copyable rows.
  2733. * @param {Number} selectedColumns Count of selected copyable columns.
  2734. * @param {Number} copyRowsLimit Current copy rows limit.
  2735. * @param {Number} copyColumnsLimit Current copy columns limit.
  2736. */
  2737. 'afterCopyLimit',
  2738. /**
  2739. * Callback is fired before a new column was created.
  2740. *
  2741. * @since 0.28.0
  2742. * @event Hooks#beforeCreateCol
  2743. * @param {Number} index Represents the visual index of first newly created column in the data source array.
  2744. * @param {Number} amount Number of newly created columns in the data source array.
  2745. * @param {String} [source] String that identifies source of hook call
  2746. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  2747. */
  2748. 'beforeCreateCol',
  2749. /**
  2750. * Callback is fired after a new column was created.
  2751. *
  2752. * @event Hooks#afterCreateCol
  2753. * @param {Number} index Represents the visual index of first newly created column in the data source array.
  2754. * @param {Number} amount Number of newly created columns in the data source array.
  2755. * @param {String} [source] String that identifies source of hook call
  2756. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  2757. */
  2758. 'afterCreateCol',
  2759. /**
  2760. * Callback is fired before a new row was created.
  2761. *
  2762. * @since 0.28.0
  2763. * @event Hooks#beforeCreateRow
  2764. * @param {Number} index Represents the visual index of first newly created row in the data source array.
  2765. * @param {Number} amount Number of newly created rows in the data source array.
  2766. * @param {String} [source] String that identifies source of hook call
  2767. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  2768. */
  2769. 'beforeCreateRow',
  2770. /**
  2771. * Callback is fired after a new row was created.
  2772. *
  2773. * @event Hooks#afterCreateRow
  2774. * @param {Number} index Represents the visual index of first newly created row in the data source array.
  2775. * @param {Number} amount Number of newly created rows in the data source array.
  2776. * @param {String} [source] String that identifies source of hook call
  2777. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  2778. */
  2779. 'afterCreateRow',
  2780. /**
  2781. * Fired after the current cell is deselected.
  2782. *
  2783. * @event Hooks#afterDeselect
  2784. */
  2785. 'afterDeselect',
  2786. /**
  2787. * Fired after destroying the Handsontable instance.
  2788. *
  2789. * @event Hooks#afterDestroy
  2790. */
  2791. 'afterDestroy',
  2792. /**
  2793. * Fired on a `keydown` event on the document body.
  2794. *
  2795. * @event Hooks#afterDocumentKeyDown
  2796. * @param {Event} event A `keydown` event.
  2797. */
  2798. 'afterDocumentKeyDown',
  2799. /**
  2800. * Fired inside the Walkontable's selection `draw` method. Can be used to add additional class names to cells, depending on the current selection.
  2801. *
  2802. * @event Hooks#afterDrawSelection
  2803. * @param {Number} currentRow Row index of the currently processed cell.
  2804. * @param {Number} currentColumn Column index of the currently cell.
  2805. * @param {Array} cornersOfSelection Array of the current selection in a form of `[startRow, startColumn, endRow, endColumn]`.
  2806. * @param {Number|undefined} layerLevel Number indicating which layer of selection is currently processed.
  2807. * @since 0.38.1
  2808. * @returns {String|undefined} Can return a `String`, which will act as an additional `className` to be added to the currently processed cell.
  2809. */
  2810. 'afterDrawSelection',
  2811. /**
  2812. * Fired inside the Walkontable's `refreshSelections` method. Can be used to remove additional class names from all cells in the table.
  2813. *
  2814. * @event Hooks#beforeRemoveCellClassNames
  2815. * @since 0.38.1
  2816. * @returns {String[]|undefined} Can return an `Array` of `String`s. Each of these strings will act like class names to be removed from all the cells in the table.
  2817. */
  2818. 'beforeRemoveCellClassNames',
  2819. /**
  2820. * Callback fired after getting the cell settings.
  2821. *
  2822. * @event Hooks#afterGetCellMeta
  2823. * @param {Number} row Visual row index.
  2824. * @param {Number} col Visual column index.
  2825. * @param {Object} cellProperties Object containing the cell properties.
  2826. */
  2827. 'afterGetCellMeta',
  2828. /**
  2829. * Callback fired after retrieving information about a column header and appending it to the table header.
  2830. *
  2831. * @event Hooks#afterGetColHeader
  2832. * @param {Number} col Visual column index.
  2833. * @param {Element} TH Header's TH element.
  2834. */
  2835. 'afterGetColHeader',
  2836. /**
  2837. * Callback fired after retrieving information about a column header and appending it to the table header.
  2838. *
  2839. * @event Hooks#afterGetRowHeader
  2840. * @param {Number} row Visual row index.
  2841. * @param {Element} TH Header's TH element.
  2842. */
  2843. 'afterGetRowHeader',
  2844. /**
  2845. * Callback fired after Handsontable instance is initiated.
  2846. *
  2847. * @event Hooks#afterInit
  2848. */
  2849. 'afterInit',
  2850. /**
  2851. * Callback fired after new data is loaded (by `loadData` method) into the data source array.
  2852. *
  2853. * @event Hooks#afterLoadData
  2854. * @param {Boolean} firstTime flag that determines whether the data has been loaded during the initialization.
  2855. */
  2856. 'afterLoadData',
  2857. /**
  2858. * Fired after a scroll event, which is identified as a momentum scroll (e.g. on an iPad).
  2859. *
  2860. * @event Hooks#afterMomentumScroll
  2861. */
  2862. 'afterMomentumScroll',
  2863. /**
  2864. * Fired after a `mousedown` event is triggered on the cell corner (the drag handle).
  2865. *
  2866. * @event Hooks#afterOnCellCornerMouseDown
  2867. * @since 0.11
  2868. * @param {Object} event `mousedown` event object.
  2869. */
  2870. 'afterOnCellCornerMouseDown',
  2871. /**
  2872. * Fired after a `dblclick` event is triggered on the cell corner (the drag handle).
  2873. *
  2874. * @event Hooks#afterOnCellCornerDblClick
  2875. * @since 0.30.0
  2876. * @param {Object} event `dblclick` event object.
  2877. */
  2878. 'afterOnCellCornerDblClick',
  2879. /**
  2880. * Callback fired after clicking on a cell or row/column header.
  2881. * In case the row/column header was clicked, the index is negative.
  2882. * For example clicking on the row header of cell (0, 0) results with `afterOnCellMouseDown` called
  2883. * with coords `{row: 0, col: -1}`.
  2884. *
  2885. * @event Hooks#afterOnCellMouseDown
  2886. * @since 0.11
  2887. * @param {Object} event `mousedown` event object.
  2888. * @param {Object} coords Coordinates object containing the visual row and visual column indexes of the clicked cell.
  2889. * @param {Element} TD Cell's TD (or TH) element.
  2890. */
  2891. 'afterOnCellMouseDown',
  2892. /**
  2893. * Callback fired after hovering a cell or row/column header with the mouse cursor.
  2894. * In case the row/column header was hovered, the index is negative.
  2895. * For example, hovering over the row header of cell (0, 0) results with `afterOnCellMouseOver` called
  2896. * with coords `{row: 0, col: -1}`.
  2897. *
  2898. * @event Hooks#afterOnCellMouseOver
  2899. * @since 0.11
  2900. * @param {Object} event `mouseover` event object.
  2901. * @param {Object} coords Hovered cell's visual coordinate object.
  2902. * @param {Element} TD Cell's TD (or TH) element.
  2903. */
  2904. 'afterOnCellMouseOver',
  2905. /**
  2906. * Callback fired after leaving a cell or row/column header with the mouse cursor.
  2907. *
  2908. * @event Hooks#afterOnCellMouseOut
  2909. * @since 0.31.1
  2910. * @param {Object} event `mouseout` event object.
  2911. * @param {Object} coords Leaved cell's visual coordinate object.
  2912. * @param {Element} TD Cell's TD (or TH) element.
  2913. */
  2914. 'afterOnCellMouseOut',
  2915. /**
  2916. * Callback is fired when one or more columns are removed.
  2917. *
  2918. * @event Hooks#afterRemoveCol
  2919. * @param {Number} index Is an visual index of starter column.
  2920. * @param {Number} amount Is an amount of removed columns.
  2921. */
  2922. 'afterRemoveCol',
  2923. /**
  2924. * Callback is fired when one or more rows are removed.
  2925. *
  2926. * @event Hooks#afterRemoveRow
  2927. * @param {Number} index Is an visual index of starter row.
  2928. * @param {Number} amount Is an amount of removed rows.
  2929. */
  2930. 'afterRemoveRow',
  2931. /**
  2932. * Callback fired after the Handsontable table is rendered.
  2933. *
  2934. * @event Hooks#afterRender
  2935. * @param {Boolean} isForced Is `true` if rendering was triggered by a change of settings or data; or `false` if
  2936. * rendering was triggered by scrolling or moving selection.
  2937. */
  2938. 'afterRender',
  2939. /**
  2940. * Fired before starting rendering the cell.
  2941. *
  2942. * @event Hooks#beforeRenderer
  2943. * @since 0.24.2
  2944. * @param {Element} TD Currently rendered cell's TD element.
  2945. * @param {Number} row Visual row index.
  2946. * @param {Number} col Visual column index.
  2947. * @param {String|Number} prop Column property name or a column index, if datasource is an array of arrays.
  2948. * @param {String} value Value of the rendered cell.
  2949. * @param {Object} cellProperties Object containing the cell's properties.
  2950. */
  2951. 'beforeRenderer',
  2952. /**
  2953. * Fired after finishing rendering the cell (after the renderer finishes).
  2954. *
  2955. * @event Hooks#afterRenderer
  2956. * @since 0.11.0
  2957. * @param {Element} TD Currently rendered cell's TD element.
  2958. * @param {Number} row Visual row index.
  2959. * @param {Number} col Visual column index.
  2960. * @param {String|Number} prop Column property name or a column index, if datasource is an array of arrays.
  2961. * @param {String} value Value of the rendered cell.
  2962. * @param {Object} cellProperties Object containing the cell's properties.
  2963. */
  2964. 'afterRenderer',
  2965. /**
  2966. * Fired after the horizontal scroll event.
  2967. *
  2968. * @event Hooks#afterScrollHorizontally
  2969. * @since 0.11
  2970. */
  2971. 'afterScrollHorizontally',
  2972. /**
  2973. * Fired after the vertical scroll event.
  2974. *
  2975. * @event Hooks#afterScrollVertically
  2976. * @since 0.11
  2977. */
  2978. 'afterScrollVertically',
  2979. /**
  2980. * Callback fired after one or more cells are selected (e.g. during mouse move).
  2981. *
  2982. * @event Hooks#afterSelection
  2983. * @param {Number} r Selection start visual row index.
  2984. * @param {Number} c Selection start visual column index.
  2985. * @param {Number} r2 Selection end visual row index.
  2986. * @param {Number} c2 Selection end visual column index.
  2987. * @param {Object} preventScrolling Object with `value` property where its value change will be observed.
  2988. * @param {Number} selectionLayerLevel The number which indicates what selection layer is currently modified.
  2989. * @example
  2990. * ```js
  2991. * handsontable({
  2992. * afterSelection: function (r, c, r2, c2, preventScrolling, selectionLayerLevel) {
  2993. * // setting if prevent scrolling after selection
  2994. * preventScrolling.value = true;
  2995. * }
  2996. * })
  2997. * ```
  2998. */
  2999. 'afterSelection',
  3000. /**
  3001. * Callback fired after one or more cells are selected. The `p` argument represents the source object property name instead of the column number.
  3002. *
  3003. * @event Hooks#afterSelectionByProp
  3004. * @param {Number} r Selection start visual row index.
  3005. * @param {String} p Selection start data source object property name.
  3006. * @param {Number} r2 Selection end visual row index.
  3007. * @param {String} p2 Selection end data source object property name.
  3008. * @param {Object} preventScrolling Object with `value` property where its value change will be observed.
  3009. * @param {Number} selectionLayerLevel The number which indicates what selection layer is currently modified.
  3010. * @example
  3011. * ```js
  3012. * handsontable({
  3013. * afterSelectionByProp: function (r, c, r2, c2, preventScrolling, selectionLayerLevel) {
  3014. * // setting if prevent scrolling after selection
  3015. * preventScrolling.value = true;
  3016. * }
  3017. * })
  3018. * ```
  3019. */
  3020. 'afterSelectionByProp',
  3021. /**
  3022. * Callback fired after one or more cells are selected (e.g. on mouse up).
  3023. *
  3024. * @event Hooks#afterSelectionEnd
  3025. * @param {Number} r Selection start visual row index.
  3026. * @param {Number} c Selection start visual column index.
  3027. * @param {Number} r2 Selection end visual row index.
  3028. * @param {Number} c2 Selection end visual column index.
  3029. * @param {Number} selectionLayerLevel The number which indicates what selection layer is currently modified.
  3030. */
  3031. 'afterSelectionEnd',
  3032. /**
  3033. * Callback fired after one or more cells are selected (e.g. on mouse up). The `p` argument represents the data source object
  3034. * property name instead of the column number.
  3035. *
  3036. * @event Hooks#afterSelectionEndByProp
  3037. * @param {Number} r Selection start visual row index.
  3038. * @param {String} p Selection start data source object property index.
  3039. * @param {Number} r2 Selection end visual row index.
  3040. * @param {String} p2 Selection end data source object property index.
  3041. * @param {Number} selectionLayerLevel The number which indicates what selection layer is currently modified.
  3042. */
  3043. 'afterSelectionEndByProp',
  3044. /**
  3045. * Called after cell meta is changed.
  3046. *
  3047. * @event Hooks#afterSetCellMeta
  3048. * @since 0.11.0
  3049. * @param {Number} row Visual row index.
  3050. * @param {Number} col Visual column index.
  3051. * @param {String} key The updated meta key.
  3052. * @param {*} value The updated meta value.
  3053. */
  3054. 'afterSetCellMeta',
  3055. /**
  3056. * Called after cell meta is removed.
  3057. *
  3058. * @event Hooks#afterRemoveCellMeta
  3059. * @since 0.33.1
  3060. * @param {Number} row Visual row index.
  3061. * @param {Number} col Visual column index.
  3062. * @param {String} key The removed meta key.
  3063. * @param {*} value Value which was under removed key of cell meta.
  3064. */
  3065. 'afterRemoveCellMeta',
  3066. /**
  3067. * Called after cell data was changed.
  3068. *
  3069. * @event Hooks#afterSetDataAtCell
  3070. * @since 0.28.0
  3071. * @param {Array} changes An array of changes in format `[[row, col, oldValue, value], ...]`.
  3072. * @param {String} [source] String that identifies source of hook call
  3073. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  3074. */
  3075. 'afterSetDataAtCell',
  3076. /**
  3077. * Called after cell data was changed.
  3078. *
  3079. * @event Hooks#afterSetDataAtRowProp
  3080. * @since 0.28.0
  3081. * @param {Array} changes An array of changes in format `[[row, prop, oldValue, value], ...]`.
  3082. * @param {String} [source] String that identifies source of hook call
  3083. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  3084. */
  3085. 'afterSetDataAtRowProp',
  3086. /**
  3087. * Fired after calling the `updateSettings` method.
  3088. *
  3089. * @event Hooks#afterUpdateSettings
  3090. * @param {Object} settings New settings object.
  3091. */
  3092. 'afterUpdateSettings',
  3093. /**
  3094. * @description
  3095. * A plugin hook executed after validator function, only if validator function is defined.
  3096. * Validation result is the first parameter. This can be used to determinate if validation passed successfully or not.
  3097. *
  3098. * __Returning false from the callback will mark the cell as invalid.__
  3099. *
  3100. * @event Hooks#afterValidate
  3101. * @since 0.9.5
  3102. * @param {Boolean} isValid `true` if valid, `false` if not.
  3103. * @param {*} value The value in question.
  3104. * @param {Number} row Row index.
  3105. * @param {String|Number} prop Property name / column index.
  3106. * @param {String} [source] String that identifies source of hook call
  3107. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  3108. */
  3109. 'afterValidate',
  3110. /**
  3111. * Fired before successful change of language (when proper language code was set)
  3112. *
  3113. * @event Hooks#beforeLanguageChange
  3114. * @since 0.35.0
  3115. * @param {String} languageCode New language code.
  3116. */
  3117. 'beforeLanguageChange',
  3118. /**
  3119. * Fired after successful change of language (when proper language code was set)
  3120. *
  3121. * @event Hooks#afterLanguageChange
  3122. * @since 0.35.0
  3123. * @param {String} languageCode New language code.
  3124. */
  3125. 'afterLanguageChange',
  3126. /**
  3127. * Fired before populating the data in the autofill feature.
  3128. *
  3129. * @event Hooks#beforeAutofill
  3130. * @param {Object} start Object containing information about first filled cell: `{row: 2, col: 0}`.
  3131. * @param {Object} end Object containing information about last filled cell: `{row: 4, col: 1}`.
  3132. * @param {Array} data 2D array containing information about fill pattern: `[["1", "Ted"], ["1", "John"]]`.
  3133. * @param {Array} baseRange The coordinates of the base area for autofill.
  3134. */
  3135. 'beforeAutofill',
  3136. /**
  3137. * Fired before aligning the cell contents.
  3138. *
  3139. * @event Hooks#beforeCellAlignment
  3140. * @param stateBefore
  3141. * @param range
  3142. * @param {String} type Type of the alignment - either `horizontal` or `vertical`
  3143. * @param {String} alignmentClass String defining the alignment class added to the cell.
  3144. * Possible values:
  3145. * * `htLeft`,
  3146. * * `htCenter`,
  3147. * * `htRight`,
  3148. * * `htJustify`
  3149. * for horizontal alignment,
  3150. *
  3151. *
  3152. * * `htTop`,
  3153. * * `htMiddle`,
  3154. * * `htBottom`
  3155. * for vertical alignment.
  3156. */
  3157. 'beforeCellAlignment',
  3158. /**
  3159. * Callback fired before one or more cells is changed. Its main purpose is to alter changes silently before input.
  3160. *
  3161. * @event Hooks#beforeChange
  3162. * @param {Array} changes 2D array containing information about each of the edited cells.
  3163. * @param {String} [source] String that identifies source of hook call
  3164. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  3165. * @example
  3166. * ```js
  3167. * // To disregard a single change, set changes[i] to null or remove it from array using changes.splice(i, 1).
  3168. * ...
  3169. * new Handsontable(document.getElementById('example'), {
  3170. * beforeChange: function(changes, source) {
  3171. * // [[row, prop, oldVal, newVal], ...]
  3172. * changes[0] = null;
  3173. * }
  3174. * });
  3175. * ...
  3176. *
  3177. * // To alter a single change, overwrite the desired value to changes[i][3].
  3178. * ...
  3179. * new Handsontable(document.getElementById('example'), {
  3180. * beforeChange: function(changes, source) {
  3181. * // [[row, prop, oldVal, newVal], ...]
  3182. * changes[0][3] = 10;
  3183. * }
  3184. * });
  3185. * ...
  3186. *
  3187. * // To cancel all edit, return false from the callback or set array length to 0 (changes.length = 0).
  3188. * ...
  3189. * new Handsontable(document.getElementById('example'), {
  3190. * beforeChange: function(changes, source) {
  3191. * // [[row, prop, oldVal, newVal], ...]
  3192. * return false;
  3193. * }
  3194. * });
  3195. * ...
  3196. * ```
  3197. */
  3198. 'beforeChange',
  3199. /**
  3200. * Fired right before rendering the changes.
  3201. *
  3202. * @event Hooks#beforeChangeRender
  3203. * @since 0.11
  3204. * @param {Array} changes Array in form of [row, prop, oldValue, newValue].
  3205. * @param {String} [source] String that identifies source of hook call
  3206. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  3207. */
  3208. 'beforeChangeRender',
  3209. /**
  3210. * Fired before drawing the borders.
  3211. *
  3212. * @event Hooks#beforeDrawBorders
  3213. * @param {Array} corners Array specifying the current selection borders.
  3214. * @param {String} borderClassName Specifies the border class name.
  3215. */
  3216. 'beforeDrawBorders',
  3217. /**
  3218. * Callback fired before getting cell settings.
  3219. *
  3220. * @event Hooks#beforeGetCellMeta
  3221. * @param {Number} row Visual row index.
  3222. * @param {Number} col Visual column index.
  3223. * @param {Object} cellProperties Object containing the cell's properties.
  3224. */
  3225. 'beforeGetCellMeta',
  3226. /**
  3227. * Called before cell meta is removed.
  3228. *
  3229. * @event Hooks#beforeRemoveCellMeta
  3230. * @since 0.33.1
  3231. * @param {Number} row Visual row index.
  3232. * @param {Number} col Visual column index.
  3233. * @param {String} key The removed meta key.
  3234. * @param {*} value Value which is under removed key of cell meta.
  3235. */
  3236. 'beforeRemoveCellMeta',
  3237. /**
  3238. * @description
  3239. * Callback fired before Handsontable instance is initiated.
  3240. *
  3241. * @event Hooks#beforeInit
  3242. */
  3243. 'beforeInit',
  3244. /**
  3245. * Callback fired before Walkontable instance is initiated.
  3246. *
  3247. * @since 0.11
  3248. * @event Hooks#beforeInitWalkontable
  3249. * @param {Object} walkontableConfig Walkontable configuration object.
  3250. */
  3251. 'beforeInitWalkontable',
  3252. /**
  3253. * Callback fired before keydown event is handled. It can be used to overwrite default key bindings.
  3254. * Caution - in your `beforeKeyDown` handler you need to call `event.stopImmediatePropagation()` to prevent default key behavior.
  3255. *
  3256. * @event Hooks#beforeKeyDown
  3257. * @since 0.9.0
  3258. * @param {Event} event Original DOM event.
  3259. */
  3260. 'beforeKeyDown',
  3261. /**
  3262. * Fired after the user clicked a cell, but before all the calculations related with it.
  3263. *
  3264. * @event Hooks#beforeOnCellMouseDown
  3265. * @param {Event} event The `mousedown` event object.
  3266. * @param {CellCoords} coords Cell coords object containing the visual coordinates of the clicked cell.
  3267. * @param {Element} TD TD element.
  3268. */
  3269. 'beforeOnCellMouseDown',
  3270. /**
  3271. * Fired after the user moved cursor over a cell, but before all the calculations related with it.
  3272. *
  3273. * @event Hooks#beforeOnCellMouseOver
  3274. * @param {Event} event The `mouseover` event object.
  3275. * @param {CellCoords} coords CellCoords object containing the visual coordinates of the clicked cell.
  3276. * @param {Element} TD TD element.
  3277. * @param {Object} blockCalculations Contain keys 'row' and 'column' with boolean value.
  3278. */
  3279. 'beforeOnCellMouseOver',
  3280. /**
  3281. * Fired after the user moved cursor out from a cell, but before all the calculations related with it.
  3282. *
  3283. * @event Hooks#beforeOnCellMouseOut
  3284. * @since 0.31.1
  3285. * @param {Event} event The `mouseout` event object.
  3286. * @param {WalkontableCellCoords} coords WalkontableCellCoords object containing the visual coordinates of the leaved cell.
  3287. * @param {Element} TD TD element.
  3288. */
  3289. 'beforeOnCellMouseOut',
  3290. /**
  3291. * Callback is fired when one or more columns are about to be removed.
  3292. *
  3293. * @event Hooks#beforeRemoveCol
  3294. * @param {Number} index Visual index of starter column.
  3295. * @param {Number} amount Amount of columns to be removed.
  3296. * @param {Array} [visualCols] Consists of visual indexes of processed columns.
  3297. */
  3298. 'beforeRemoveCol',
  3299. /**
  3300. * Callback is fired when one or more rows are about to be removed.
  3301. *
  3302. * @event Hooks#beforeRemoveRow
  3303. * @param {Number} index Visual index of starter column.
  3304. * @param {Number} amount Amount of columns to be removed.
  3305. * @param {Array} [visualRows] Consists of visual indexes of processed rows.
  3306. */
  3307. 'beforeRemoveRow',
  3308. /**
  3309. * Callback fired before Handsontable table is rendered.
  3310. *
  3311. * @event Hooks#beforeRender
  3312. * @param {Boolean} isForced If `true` rendering was triggered by a change of settings or data; or `false` if
  3313. * rendering was triggered by scrolling or moving selection.
  3314. */
  3315. 'beforeRender',
  3316. /**
  3317. * Callback fired before setting range is started but not finished yet.
  3318. *
  3319. * @event Hooks#beforeSetRangeStartOnly
  3320. * @param {CellCoords} coords CellCoords instance.
  3321. */
  3322. 'beforeSetRangeStartOnly',
  3323. /**
  3324. * Callback fired before setting range is started.
  3325. *
  3326. * @event Hooks#beforeSetRangeStart
  3327. * @param {CellCoords} coords CellCoords instance.
  3328. */
  3329. 'beforeSetRangeStart',
  3330. /**
  3331. * Callback fired before setting range is ended.
  3332. *
  3333. * @event Hooks#beforeSetRangeEnd
  3334. * @param {CellCoords} coords CellCoords instance.
  3335. */
  3336. 'beforeSetRangeEnd',
  3337. /**
  3338. * Fired before the logic of handling a touch scroll, when user started scrolling on a touch-enabled device.
  3339. *
  3340. * @event Hooks#beforeTouchScroll
  3341. */
  3342. 'beforeTouchScroll',
  3343. /**
  3344. * @description
  3345. * A plugin hook executed before validator function, only if validator function is defined.
  3346. * This can be used to manipulate the value of changed cell before it is applied to the validator function.
  3347. *
  3348. * __Notice:__ this will not affect values of changes. This will change value ONLY for validation!
  3349. *
  3350. * @event Hooks#beforeValidate
  3351. * @since 0.9.5
  3352. * @param {*} value Value of the cell.
  3353. * @param {Number} row Row index.
  3354. * @param {String|Number} prop Property name / column index.
  3355. * @param {String} [source] String that identifies source of hook call
  3356. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  3357. */
  3358. 'beforeValidate',
  3359. /**
  3360. * Callback fired before cell value is rendered into the DOM (through renderer function).
  3361. *
  3362. * @event Hooks#beforeValueRender
  3363. * @since 0.29.0
  3364. * @param {*} value Cell value to render.
  3365. */
  3366. 'beforeValueRender',
  3367. /**
  3368. * Callback fired after Handsontable instance is constructed (via `new` operator).
  3369. *
  3370. * @event Hooks#construct
  3371. * @since 0.16.1
  3372. */
  3373. 'construct',
  3374. /**
  3375. * Callback fired after Handsontable instance is initiated but before table is rendered.
  3376. *
  3377. * @event Hooks#init
  3378. * @since 0.16.1
  3379. */
  3380. 'init',
  3381. /**
  3382. * Fired when a column index is about to be modified by a callback function.
  3383. *
  3384. * @event Hooks#modifyCol
  3385. * @since 0.11
  3386. * @param {Number} col Visual column index.
  3387. */
  3388. 'modifyCol',
  3389. /**
  3390. * Fired when a column index is about to be de-modified by a callback function.
  3391. *
  3392. * @event Hooks#unmodifyCol
  3393. * @since 0.23.0
  3394. * @param {Number} col Physical column index.
  3395. */
  3396. 'unmodifyCol',
  3397. /**
  3398. * Fired when a physical row index is about to be de-modified by a callback function.
  3399. *
  3400. * @event Hooks#unmodifyRow
  3401. * @since 0.26.2
  3402. * @param {Number} row Physical row index.
  3403. */
  3404. 'unmodifyRow',
  3405. /**
  3406. * Fired when a column header index is about to be modified by a callback function.
  3407. *
  3408. * @event Hooks#modifyColHeader
  3409. * @since 0.20.0
  3410. * @param {Number} column Visual column header index.
  3411. */
  3412. 'modifyColHeader',
  3413. /**
  3414. * Fired when a column width is about to be modified by a callback function.
  3415. *
  3416. * @event Hooks#modifyColWidth
  3417. * @since 0.11
  3418. * @param {Number} width Current column width.
  3419. * @param {Number} col Column index.
  3420. */
  3421. 'modifyColWidth',
  3422. /**
  3423. * Fired when a row index is about to be modified by a callback function.
  3424. *
  3425. * @event Hooks#modifyRow
  3426. * @since 0.11
  3427. * @param {Number} row Row index.
  3428. */
  3429. 'modifyRow',
  3430. /**
  3431. * Fired when a row header index is about to be modified by a callback function.
  3432. *
  3433. * @event Hooks#modifyRowHeader
  3434. * @since 0.20.0
  3435. * @param {Number} row Row header index.
  3436. */
  3437. 'modifyRowHeader',
  3438. /**
  3439. * Fired when a row height is about to be modified by a callback function.
  3440. *
  3441. * @event Hooks#modifyRowHeight
  3442. * @since 0.11.0
  3443. * @param {Number} height Row height.
  3444. * @param {Number} row Row index.
  3445. */
  3446. 'modifyRowHeight',
  3447. /**
  3448. * Fired when a data was retrieved or modified.
  3449. *
  3450. * @event Hooks#modifyData
  3451. * @since 0.28.0
  3452. * @param {Number} row Row height.
  3453. * @param {Number} column Column index.
  3454. * @param {Object} valueHolder Object which contains original value which can be modified by overwriting `.value` property.
  3455. * @param {String} ioMode String which indicates for what operation hook is fired (`get` or `set`).
  3456. */
  3457. 'modifyData',
  3458. /**
  3459. * Fired when a data was retrieved or modified.
  3460. *
  3461. * @event Hooks#modifyRowData
  3462. * @since 0.28.0
  3463. * @param {Number} row Physical row index.
  3464. */
  3465. 'modifyRowData',
  3466. /**
  3467. * Used to modify the cell coordinates when using the `getCell` method.
  3468. *
  3469. * @event Hooks#modifyGetCellCoords
  3470. * @since 0.36.0
  3471. * @param {Number} row Visual row index.
  3472. * @param {Number} col Visual column index.
  3473. * @param {Boolean} topmost If set to true, it returns the TD element from the topmost overlay. For example,
  3474. * if the wanted cell is in the range of fixed rows, it will return a TD element from the `top` overlay.
  3475. */
  3476. 'modifyGetCellCoords',
  3477. /**
  3478. * Fired after loading data using the Persistent State plugin.
  3479. *
  3480. * @event Hooks#persistentStateLoad
  3481. * @param {String} key Key string.
  3482. * @param {Object} valuePlaceholder Object containing the loaded data.
  3483. */
  3484. 'persistentStateLoad',
  3485. /**
  3486. * Fired after resetting data using the Persistent State plugin.
  3487. *
  3488. * @event Hooks#persistentStateReset
  3489. * @param {String} key Key string.
  3490. */
  3491. 'persistentStateReset',
  3492. /**
  3493. * Fired after resetting data using the Persistent State plugin.
  3494. *
  3495. * @event Hooks#persistentStateSave
  3496. * @param {String} key Key string.
  3497. * @param {Mixed} value Value to save.
  3498. */
  3499. 'persistentStateSave',
  3500. /**
  3501. * Fired before sorting the column. If you return `false` value then sorting will be not applied by
  3502. * Handsontable (useful for server-side sorting).
  3503. *
  3504. * @event Hooks#beforeColumnSort
  3505. * @param {Number} column Sorted visual column index.
  3506. * @param {Boolean} order Soring order where:
  3507. * * `true` means ascending order,
  3508. * * `false` means descending order,
  3509. * * `undefined` means original order.
  3510. */
  3511. 'beforeColumnSort',
  3512. /**
  3513. * Fired after sorting the column.
  3514. *
  3515. * @event Hooks#afterColumnSort
  3516. * @param {Number} column Sorted visual column index.
  3517. * @param {Boolean} order Soring order where:
  3518. * * `true` means ascending order
  3519. * * `false` means descending order
  3520. * * `undefined` means original order
  3521. */
  3522. 'afterColumnSort',
  3523. /**
  3524. * @description
  3525. * Fired after setting range of autofill.
  3526. * Both arguments are provided in the following format:
  3527. * ```js
  3528. * [startRow, startColumn, endRow, endColumn]
  3529. * ```
  3530. *
  3531. * @event Hooks#modifyAutofillRange
  3532. * @param {Array} startArea Array of visual coordinates of the starting point for the drag-down operation.
  3533. * @param {Array} entireArea Array of visual coordinates of the entire area of the drag-down operation.
  3534. */
  3535. 'modifyAutofillRange',
  3536. /**
  3537. * Fired to allow modifying the copyable range with a callback function.
  3538. *
  3539. * @since 0.19.0
  3540. * @event Hooks#modifyCopyableRange
  3541. * @param {Array} copyableRanges Array of objects defining copyable cells.
  3542. */
  3543. 'modifyCopyableRange',
  3544. /**
  3545. * Called before copying the values into clipboard and before clearing values of the selected cells.
  3546. *
  3547. * @event Hooks#beforeCut
  3548. * @since 0.31.1
  3549. * @param {Array} data An array of arrays which contains data to cut.
  3550. * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
  3551. * which will be cut out.
  3552. * @returns {*} If returns `false` then operation of the cutting out is cancelled.
  3553. *
  3554. * @example
  3555. * ```js
  3556. * // To disregard a single row, remove it from array using data.splice(i, 1).
  3557. * ...
  3558. * new Handsontable(document.getElementById('example'), {
  3559. * beforeCut: function(data, coords) {
  3560. * // data -> [[1, 2, 3], [4, 5, 6]]
  3561. * data.splice(0, 1);
  3562. * // data -> [[4, 5, 6]]
  3563. * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}]
  3564. * }
  3565. * });
  3566. * ...
  3567. *
  3568. * // To cancel cutting out, return false from the callback.
  3569. * ...
  3570. * new Handsontable(document.getElementById('example'), {
  3571. * beforeCut: function(data, coords) {
  3572. * return false;
  3573. * }
  3574. * });
  3575. * ...
  3576. * ```
  3577. */
  3578. 'beforeCut',
  3579. /**
  3580. * Fired after data are cutted out from the table.
  3581. *
  3582. * @event Hooks#afterCut
  3583. * @since 0.31.1
  3584. * @param {Array} data An array of arrays which contains the cutted out data.
  3585. * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
  3586. * which was cut out.
  3587. */
  3588. 'afterCut',
  3589. /**
  3590. * Fired before values are copied into clipboard.
  3591. *
  3592. * @event Hooks#beforeCopy
  3593. * @since 0.31.1
  3594. * @param {Array} data An array of arrays which contains data to copied.
  3595. * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
  3596. * which will copied.
  3597. * @returns {*} If returns `false` then copying is cancelled.
  3598. *
  3599. * @example
  3600. * ```js
  3601. * // To disregard a single row, remove it from array using data.splice(i, 1).
  3602. * ...
  3603. * new Handsontable(document.getElementById('example'), {
  3604. * beforeCopy: function(data, coords) {
  3605. * // data -> [[1, 2, 3], [4, 5, 6]]
  3606. * data.splice(0, 1);
  3607. * // data -> [[4, 5, 6]]
  3608. * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}]
  3609. * }
  3610. * });
  3611. * ...
  3612. *
  3613. * // To cancel copying, return false from the callback.
  3614. * ...
  3615. * new Handsontable(document.getElementById('example'), {
  3616. * beforeCopy: function(data, coords) {
  3617. * return false;
  3618. * }
  3619. * });
  3620. * ...
  3621. * ```
  3622. */
  3623. 'beforeCopy',
  3624. /**
  3625. * Fired after data are pasted into table.
  3626. *
  3627. * @event Hooks#afterCopy
  3628. * @since 0.31.1
  3629. * @param {Array} data An array of arrays which contains the copied data.
  3630. * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
  3631. * which was copied.
  3632. */
  3633. 'afterCopy',
  3634. /**
  3635. * Fired before values are pasted into table.
  3636. *
  3637. * @event Hooks#beforePaste
  3638. * @since 0.31.1
  3639. * @param {Array} data An array of arrays which contains data to paste.
  3640. * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
  3641. * that correspond to the previously selected area.
  3642. * @returns {*} If returns `false` then pasting is cancelled.
  3643. *
  3644. * @example
  3645. * ```js
  3646. * // To disregard a single row, remove it from array using data.splice(i, 1).
  3647. * ...
  3648. * new Handsontable(document.getElementById('example'), {
  3649. * beforePaste: function(data, coords) {
  3650. * // data -> [[1, 2, 3], [4, 5, 6]]
  3651. * data.splice(0, 1);
  3652. * // data -> [[4, 5, 6]]
  3653. * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}]
  3654. * }
  3655. * });
  3656. * ...
  3657. *
  3658. * // To cancel pasting, return false from the callback.
  3659. * ...
  3660. * new Handsontable(document.getElementById('example'), {
  3661. * beforePaste: function(data, coords) {
  3662. * return false;
  3663. * }
  3664. * });
  3665. * ...
  3666. * ```
  3667. */
  3668. 'beforePaste',
  3669. /**
  3670. * Fired after values are pasted into table.
  3671. *
  3672. * @event Hooks#afterPaste
  3673. * @since 0.31.1
  3674. * @param {Array} data An array of arrays which contains the pasted data.
  3675. * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
  3676. * that correspond to the previously selected area.
  3677. */
  3678. 'afterPaste',
  3679. /**
  3680. * Fired before change order of the visual indexes.
  3681. *
  3682. * @event Hooks#beforeColumnMove
  3683. * @param {Array} columns Array of visual column indexes to be moved.
  3684. * @param {Number} target Visual column index being a target for moved columns.
  3685. */
  3686. 'beforeColumnMove',
  3687. /**
  3688. * Fired after change order of the visual indexes.
  3689. *
  3690. * @event Hooks#afterColumnMove
  3691. * @param {Array} columns Array of visual column indexes that were moved.
  3692. * @param {Number} target Visual column index being a target for moved columns.
  3693. */
  3694. 'afterColumnMove',
  3695. /**
  3696. * Fired before change order of the visual indexes.
  3697. *
  3698. * @event Hooks#beforeRowMove
  3699. * @param {Array} rows Array of visual row indexes to be moved.
  3700. * @param {Number} target Visual row index being a target for moved rows.
  3701. */
  3702. 'beforeRowMove',
  3703. /**
  3704. * Fired after change order of the visual indexes.
  3705. *
  3706. * @event Hooks#afterRowMove
  3707. * @param {Array} rows Array of visual row indexes that were moved.
  3708. * @param {Number} target Visual row index being a target for moved rows.
  3709. */
  3710. 'afterRowMove',
  3711. /**
  3712. * Fired before rendering the table with modified column sizes.
  3713. *
  3714. * @event Hooks#beforeColumnResize
  3715. * @param {Number} currentColumn Visual index of the resized column.
  3716. * @param {Number} newSize Calculated new column width.
  3717. * @param {Boolean} isDoubleClick Flag that determines whether there was a double-click.
  3718. * @returns {Number} Returns a new column size or `undefined`, if column size should be calculated automatically.
  3719. */
  3720. 'beforeColumnResize',
  3721. /**
  3722. * Fired after rendering the table with modified column sizes.
  3723. *
  3724. * @event Hooks#afterColumnResize
  3725. * @param {Number} currentColumn Visual index of the resized column.
  3726. * @param {Number} newSize Calculated new column width.
  3727. * @param {Boolean} isDoubleClick Flag that determines whether there was a double-click.
  3728. */
  3729. 'afterColumnResize',
  3730. /**
  3731. * Fired before rendering the table with modified row sizes.
  3732. *
  3733. * @event Hooks#beforeRowResize
  3734. * @param {Number} currentRow Visual index of the resized row.
  3735. * @param {Number} newSize Calculated new row height.
  3736. * @param {Boolean} isDoubleClick Flag that determines whether there was a double-click.
  3737. * @returns {Number} Returns the new row size or `undefined` if row size should be calculated automatically.
  3738. */
  3739. 'beforeRowResize',
  3740. /**
  3741. * Fired after rendering the table with modified row sizes.
  3742. *
  3743. * @event Hooks#afterRowResize
  3744. * @param {Number} currentRow Visual index of the resized row.
  3745. * @param {Number} newSize Calculated new row height.
  3746. * @param {Boolean} isDoubleClick Flag that determines whether there was a double-click.
  3747. */
  3748. 'afterRowResize',
  3749. /**
  3750. * Fired after getting the column header renderers.
  3751. *
  3752. * @event Hooks#afterGetColumnHeaderRenderers
  3753. * @param {Array} array Array of the column header renderers.
  3754. */
  3755. 'afterGetColumnHeaderRenderers',
  3756. /**
  3757. * Fired after getting the row header renderers.
  3758. *
  3759. * @event Hooks#afterGetRowHeaderRenderers
  3760. * @param {Array} array Array of the row header renderers.
  3761. */
  3762. 'afterGetRowHeaderRenderers',
  3763. /**
  3764. * Fired before applying stretched column width to column.
  3765. *
  3766. * @event Hooks#beforeStretchingColumnWidth
  3767. * @param {Number} stretchedWidth Calculated width.
  3768. * @param {Number} column Visual column index.
  3769. * @returns {Number} Returns new width which will be applied to the column element.
  3770. */
  3771. 'beforeStretchingColumnWidth',
  3772. /**
  3773. * Fired before applying [filtering]{@link http://docs.handsontable.com/pro/demo-filtering.html}.
  3774. *
  3775. * @pro
  3776. * @event Hooks#beforeFilter
  3777. * @param {Array} conditionsStack An array of objects with added formulas.
  3778. * @returns {Boolean} If hook returns `false` value then filtering won't be applied on the UI side (server-side filtering).
  3779. */
  3780. 'beforeFilter',
  3781. /**
  3782. * Fired after applying [filtering]{@link http://docs.handsontable.com/pro/demo-filtering.html}.
  3783. *
  3784. * @pro
  3785. * @event Hooks#afterFilter
  3786. * @param {Array} conditionsStack An array of objects with added formulas.
  3787. */
  3788. 'afterFilter',
  3789. /**
  3790. * Used to modify the column header height.
  3791. *
  3792. * @event Hooks#modifyColumnHeaderHeight
  3793. * @since 0.25.0
  3794. * @param {Number} col Visual column index.
  3795. */
  3796. 'modifyColumnHeaderHeight',
  3797. /**
  3798. * Fired before the undo action. Contains information about the action that is being undone.
  3799. *
  3800. * @event Hooks#beforeUndo
  3801. * @since 0.26.2
  3802. * @param {Object} action The action object. Contains information about the action being undone. The `actionType`
  3803. * property of the object specifies the type of the action in a String format. (e.g. `'remove_row'`).
  3804. */
  3805. 'beforeUndo',
  3806. /**
  3807. * Fired after the undo action. Contains information about the action that is being undone.
  3808. *
  3809. * @event Hooks#afterUndo
  3810. * @since 0.26.2
  3811. * @param {Object} action The action object. Contains information about the action being undone. The `actionType`
  3812. * property of the object specifies the type of the action in a String format. (e.g. `'remove_row'`).
  3813. */
  3814. 'afterUndo',
  3815. /**
  3816. * Fired before the redo action. Contains information about the action that is being redone.
  3817. *
  3818. * @event Hooks#beforeRedo
  3819. * @since 0.26.2
  3820. * @param {Object} action The action object. Contains information about the action being redone. The `actionType`
  3821. * property of the object specifies the type of the action in a String format. (e.g. `'remove_row'`).
  3822. */
  3823. 'beforeRedo',
  3824. /**
  3825. * Fired after the redo action. Contains information about the action that is being redone.
  3826. *
  3827. * @event Hooks#afterRedo
  3828. * @since 0.26.2
  3829. * @param {Object} action The action object. Contains information about the action being redone. The `actionType`
  3830. * property of the object specifies the type of the action in a String format. (e.g. `'remove_row'`).
  3831. */
  3832. 'afterRedo',
  3833. /**
  3834. * Used to modify the row header width.
  3835. *
  3836. * @event Hooks#modifyRowHeaderWidth
  3837. * @param {Number} rowHeaderWidth Row header width.
  3838. */
  3839. 'modifyRowHeaderWidth',
  3840. /**
  3841. * Fired from the `populateFromArray` method during the `autofill` process. Fired for each "autofilled" cell individually.
  3842. *
  3843. * @event Hooks#beforeAutofillInsidePopulate
  3844. * @param {Object} index Object containing `row` and `col` properties, defining the number of rows/columns from the initial cell of the autofill.
  3845. * @param {String} direction Declares the direction of the autofill. Possible values: `up`, `down`, `left`, `right`.
  3846. * @param {Array} input Array of arrays. Contains an array of rows with data being used in the autofill.
  3847. * @param {Array} deltas The deltas array passed to the `populateFromArray` method.
  3848. */
  3849. 'beforeAutofillInsidePopulate',
  3850. /**
  3851. * Fired when the start of the selection is being modified. (e.g. moving the selection with the arrow keys).
  3852. *
  3853. * @event Hooks#modifyTransformStart
  3854. * @param {CellCoords} delta Cell coords object declaring the delta of the new selection relative to the previous one.
  3855. */
  3856. 'modifyTransformStart',
  3857. /**
  3858. * Fired when the end of the selection is being modified. (e.g. moving the selection with the arrow keys).
  3859. *
  3860. * @event Hooks#modifyTransformEnd
  3861. * @param {CellCoords} delta Cell coords object declaring the delta of the new selection relative to the previous one.
  3862. */
  3863. 'modifyTransformEnd',
  3864. /**
  3865. * Fired after the start of the selection is being modified. (e.g. moving the selection with the arrow keys).
  3866. *
  3867. * @event Hooks#afterModifyTransformStart
  3868. * @param {CellCoords} coords Coords of the freshly selected cell.
  3869. * @param {Number} rowTransformDir `-1` if trying to select a cell with a negative row index. `0` otherwise.
  3870. * @param {Number} colTransformDir `-1` if trying to select a cell with a negative column index. `0` otherwise.
  3871. */
  3872. 'afterModifyTransformStart',
  3873. /**
  3874. * Fired after the end of the selection is being modified. (e.g. moving the selection with the arrow keys).
  3875. *
  3876. * @event Hooks#afterModifyTransformEnd
  3877. * @param {CellCoords} coords Visual coords of the freshly selected cell.
  3878. * @param {Number} rowTransformDir `-1` if trying to select a cell with a negative row index. `0` otherwise.
  3879. * @param {Number} colTransformDir `-1` if trying to select a cell with a negative column index. `0` otherwise.
  3880. */
  3881. 'afterModifyTransformEnd',
  3882. /**
  3883. * Fired inside the `viewportRowCalculatorOverride` method. Allows modifying the row calculator parameters.
  3884. *
  3885. * @event Hooks#afterViewportRowCalculatorOverride
  3886. * @param {Object} calc The row calculator.
  3887. */
  3888. 'afterViewportRowCalculatorOverride',
  3889. /**
  3890. * Fired inside the `viewportColumnCalculatorOverride` method. Allows modifying the row calculator parameters.
  3891. *
  3892. * @event Hooks#afterViewportColumnCalculatorOverride
  3893. * @param {Object} calc The row calculator.
  3894. */
  3895. 'afterViewportColumnCalculatorOverride',
  3896. /**
  3897. * Fired after initializing all the plugins.
  3898. *
  3899. * @event Hooks#afterPluginsInitialized
  3900. */
  3901. 'afterPluginsInitialized',
  3902. /**
  3903. * Used when saving/loading the manual row heights state.
  3904. *
  3905. * @event Hooks#manualRowHeights
  3906. * @param {Array} state The current manual row heights state.
  3907. */
  3908. 'manualRowHeights',
  3909. /**
  3910. * Used to skip the length cache calculation for a defined period of time.
  3911. *
  3912. * @event Hooks#skipLengthCache
  3913. * @param {Number} delay The delay in milliseconds.
  3914. */
  3915. 'skipLengthCache',
  3916. /**
  3917. * Fired after trimming rows in the TrimRows plugin.
  3918. *
  3919. * @pro
  3920. * @event Hooks#afterTrimRow
  3921. * @param {Array} rows Physical indexes of trimmed rows.
  3922. */
  3923. 'afterTrimRow',
  3924. /**
  3925. * Fired after untrimming rows in the TrimRows plugin.
  3926. *
  3927. * @pro
  3928. * @event Hooks#afterUntrimRow
  3929. * @param {Array} rows Physical indexes of untrimmed rows.
  3930. */
  3931. 'afterUntrimRow',
  3932. /**
  3933. * Fired before opening the dropdown menu.
  3934. *
  3935. * @pro
  3936. * @event Hooks#beforeDropdownMenuShow
  3937. * @param {DropdownMenu} instance The DropdownMenu instance.
  3938. */
  3939. 'beforeDropdownMenuShow',
  3940. /**
  3941. * Fired after opening the dropdown menu.
  3942. *
  3943. * @pro
  3944. * @event Hooks#afterDropdownMenuShow
  3945. * @param {DropdownMenu} instance The DropdownMenu instance.
  3946. */
  3947. 'afterDropdownMenuShow',
  3948. /**
  3949. * Fired after hiding the dropdown menu.
  3950. *
  3951. * @pro
  3952. * @event Hooks#afterDropdownMenuHide
  3953. * @param {DropdownMenu} instance The DropdownMenu instance.
  3954. */
  3955. 'afterDropdownMenuHide',
  3956. /**
  3957. * Used to check whether the provided row index is hidden.
  3958. *
  3959. * @pro
  3960. * @event Hooks#hiddenRow
  3961. * @param {Number} row The visual row index in question.
  3962. */
  3963. 'hiddenRow',
  3964. /**
  3965. * Used to check whether the provided column index is hidden.
  3966. *
  3967. * @pro
  3968. * @event Hooks#hiddenColumn
  3969. * @param {Number} column The visual column index in question.
  3970. */
  3971. 'hiddenColumn',
  3972. /**
  3973. * Fired before adding a children to the NestedRows structure.
  3974. *
  3975. * @pro
  3976. * @event Hooks#beforeAddChild
  3977. * @param {Object} parent The parent object.
  3978. * @param {Object|undefined} element The element added as a child. If `undefined`, a blank child was added.
  3979. * @param {Number|undefined} index The index within the parent where the new child was added. If `undefined`, the element was added as the last child.
  3980. */
  3981. 'beforeAddChild',
  3982. /**
  3983. * Fired after adding a children to the NestedRows structure.
  3984. *
  3985. * @pro
  3986. * @event Hooks#afterAddChild
  3987. * @param {Object} parent The parent object.
  3988. * @param {Object|undefined} element The element added as a child. If `undefined`, a blank child was added.
  3989. * @param {Number|undefined} index The index within the parent where the new child was added. If `undefined`, the element was added as the last child.
  3990. */
  3991. 'afterAddChild',
  3992. /**
  3993. * Fired before detaching a child from its parent in the NestedRows plugin.
  3994. *
  3995. * @pro
  3996. * @event Hooks#beforeDetachChild
  3997. * @param {Object} parent An object representing the parent from which the element is to be detached.
  3998. * @param {Object} element The detached element.
  3999. */
  4000. 'beforeDetachChild',
  4001. /**
  4002. * Fired after detaching a child from its parent in the NestedRows plugin.
  4003. *
  4004. * @pro
  4005. * @event Hooks#afterDetachChild
  4006. * @param {Object} parent An object representing the parent from which the element was detached.
  4007. * @param {Object} element The detached element.
  4008. */
  4009. 'afterDetachChild',
  4010. /**
  4011. * Fired after the editor is opened and rendered.
  4012. *
  4013. * @event Hooks#afterBeginEditing
  4014. * @param {Number} row Row index of the edited cell.
  4015. * @param {Number} column Column index of the edited cell.
  4016. */
  4017. 'afterBeginEditing',
  4018. /**
  4019. * Fired before cell merging.
  4020. *
  4021. * @event Hooks#beforeMergeCells
  4022. * @param {CellRange} cellRange Selection cell range.
  4023. * @param {Boolean} [auto=false] `true` if called automatically by the plugin.
  4024. */
  4025. 'beforeMergeCells',
  4026. /**
  4027. * Fired after cell merging.
  4028. *
  4029. * @event Hooks#afterMergeCells
  4030. * @param {CellRange} cellRange Selection cell range.
  4031. * @param {Object} mergeParent The parent collection of the provided cell range.
  4032. * @param {Boolean} [auto=false] `true` if called automatically by the plugin.
  4033. */
  4034. 'afterMergeCells',
  4035. /**
  4036. * Fired before unmerging the cells.
  4037. *
  4038. * @event Hooks#beforeUnmergeCells
  4039. * @param {CellRange} cellRange Selection cell range.
  4040. * @param {Boolean} [auto=false] `true` if called automatically by the plugin.
  4041. */
  4042. 'beforeUnmergeCells',
  4043. /**
  4044. * Fired after unmerging the cells.
  4045. *
  4046. * @event Hooks#beforeUnmergeCells
  4047. * @param {CellRange} cellRange Selection cell range.
  4048. * @param {Boolean} [auto=false] `true` if called automatically by the plugin.
  4049. */
  4050. 'afterUnmergeCells',
  4051. /**
  4052. * Fired after the listening is turned on.
  4053. *
  4054. * @event Hooks#afterListen
  4055. * @since 0.34.5
  4056. */
  4057. 'afterListen',
  4058. /**
  4059. * Fired after the listening is turned off.
  4060. *
  4061. * @event Hooks#afterUnlisten
  4062. * @since 0.34.5
  4063. */
  4064. 'afterUnlisten'];
  4065. var Hooks = function () {
  4066. _createClass(Hooks, null, [{
  4067. key: 'getSingleton',
  4068. value: function getSingleton() {
  4069. return globalSingleton;
  4070. }
  4071. /**
  4072. *
  4073. */
  4074. }]);
  4075. function Hooks() {
  4076. _classCallCheck(this, Hooks);
  4077. this.globalBucket = this.createEmptyBucket();
  4078. }
  4079. /**
  4080. * Returns a new object with empty handlers related to every registered hook name.
  4081. *
  4082. * @returns {Object} The empty bucket object.
  4083. *
  4084. * @example
  4085. * ```js
  4086. * Handsontable.hooks.createEmptyBucket();
  4087. * // Results:
  4088. * {
  4089. * ...
  4090. * afterCreateCol: [],
  4091. * afterCreateRow: [],
  4092. * beforeInit: [],
  4093. * ...
  4094. * }
  4095. * ```
  4096. */
  4097. _createClass(Hooks, [{
  4098. key: 'createEmptyBucket',
  4099. value: function createEmptyBucket() {
  4100. var bucket = Object.create(null);
  4101. // eslint-disable-next-line no-return-assign
  4102. (0, _array.arrayEach)(REGISTERED_HOOKS, function (hook) {
  4103. return bucket[hook] = [];
  4104. });
  4105. return bucket;
  4106. }
  4107. /**
  4108. * Get hook bucket based on the context of the object or if argument is `undefined`, get the global hook bucket.
  4109. *
  4110. * @param {Object} [context=null] A Handsontable instance.
  4111. * @returns {Object} Returns a global or Handsontable instance bucket.
  4112. */
  4113. }, {
  4114. key: 'getBucket',
  4115. value: function getBucket() {
  4116. var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  4117. if (context) {
  4118. if (!context.pluginHookBucket) {
  4119. context.pluginHookBucket = this.createEmptyBucket();
  4120. }
  4121. return context.pluginHookBucket;
  4122. }
  4123. return this.globalBucket;
  4124. }
  4125. /**
  4126. * Adds a listener (globally or locally) to a specified hook name.
  4127. * If the `context` parameter is provided, the hook will be added only to the instance it references.
  4128. * Otherwise, the callback will be used everytime the hook fires on any Handsontable instance.
  4129. * You can provide an array of callback functions as the `callback` argument, this way they will all be fired
  4130. * once the hook is triggered.
  4131. *
  4132. * @see Core#addHook
  4133. * @param {String} key Hook name.
  4134. * @param {Function|Array} callback Callback function or an array of functions.
  4135. * @param {Object} [context=null] The context for the hook callback to be added - a Handsontable instance or leave empty.
  4136. * @returns {Hooks} Instance of Hooks.
  4137. *
  4138. * @example
  4139. * ```js
  4140. * // single callback, added locally
  4141. * Handsontable.hooks.add('beforeInit', myCallback, hotInstance);
  4142. *
  4143. * // single callback, added globally
  4144. * Handsontable.hooks.add('beforeInit', myCallback);
  4145. *
  4146. * // multiple callbacks, added locally
  4147. * Handsontable.hooks.add('beforeInit', [myCallback, anotherCallback], hotInstance);
  4148. *
  4149. * // multiple callbacks, added globally
  4150. * Handsontable.hooks.add('beforeInit', [myCallback, anotherCallback]);
  4151. * ```
  4152. */
  4153. }, {
  4154. key: 'add',
  4155. value: function add(key, callback) {
  4156. var _this = this;
  4157. var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4158. if (Array.isArray(callback)) {
  4159. (0, _array.arrayEach)(callback, function (c) {
  4160. return _this.add(key, c, context);
  4161. });
  4162. } else {
  4163. var bucket = this.getBucket(context);
  4164. if (typeof bucket[key] === 'undefined') {
  4165. this.register(key);
  4166. bucket[key] = [];
  4167. }
  4168. callback.skip = false;
  4169. if (bucket[key].indexOf(callback) === -1) {
  4170. // only add a hook if it has not already been added (adding the same hook twice is now silently ignored)
  4171. var foundInitialHook = false;
  4172. if (callback.initialHook) {
  4173. (0, _array.arrayEach)(bucket[key], function (cb, i) {
  4174. if (cb.initialHook) {
  4175. bucket[key][i] = callback;
  4176. foundInitialHook = true;
  4177. return false;
  4178. }
  4179. });
  4180. }
  4181. if (!foundInitialHook) {
  4182. bucket[key].push(callback);
  4183. }
  4184. }
  4185. }
  4186. return this;
  4187. }
  4188. /**
  4189. * Adds a listener to a specified hook. After the hook runs this listener will be automatically removed from the bucket.
  4190. *
  4191. * @see Core#addHookOnce
  4192. * @param {String} key Hook/Event name.
  4193. * @param {Function|Array} callback Callback function.
  4194. * @param {Object} [context=null] A Handsontable instance.
  4195. *
  4196. * @example
  4197. * ```js
  4198. * Handsontable.hooks.once('beforeInit', myCallback, hotInstance);
  4199. * ```
  4200. */
  4201. }, {
  4202. key: 'once',
  4203. value: function once(key, callback) {
  4204. var _this2 = this;
  4205. var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4206. if (Array.isArray(callback)) {
  4207. (0, _array.arrayEach)(callback, function (c) {
  4208. return _this2.once(key, c, context);
  4209. });
  4210. } else {
  4211. callback.runOnce = true;
  4212. this.add(key, callback, context);
  4213. }
  4214. }
  4215. /**
  4216. * Removes a listener from a hook with a given name. If the `context` argument is provided, it removes a listener from a local hook assigned to the given Handsontable instance.
  4217. *
  4218. * @see Core#removeHook
  4219. * @param {String} key Hook/Event name.
  4220. * @param {Function} callback Callback function (needs the be the function that was previously added to the hook).
  4221. * @param {Object} [context=null] Handsontable instance.
  4222. * @return {Boolean} Returns `true` if hook was removed, `false` otherwise.
  4223. *
  4224. * @example
  4225. * ```js
  4226. * Handsontable.hooks.remove('beforeInit', myCallback);
  4227. * ```
  4228. */
  4229. }, {
  4230. key: 'remove',
  4231. value: function remove(key, callback) {
  4232. var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4233. var bucket = this.getBucket(context);
  4234. if (typeof bucket[key] !== 'undefined') {
  4235. if (bucket[key].indexOf(callback) >= 0) {
  4236. callback.skip = true;
  4237. return true;
  4238. }
  4239. }
  4240. return false;
  4241. }
  4242. /**
  4243. * Checks whether there are any registered listeners for the provided hook name.
  4244. * If the `context` parameter is provided, it only checks for listeners assigned to the given Handsontable instance.
  4245. *
  4246. * @param {String} key Hook name.
  4247. * @param {Object} [context=null] A Handsontable instance.
  4248. * @returns {Boolean} `true` for success, `false` otherwise.
  4249. */
  4250. }, {
  4251. key: 'has',
  4252. value: function has(key) {
  4253. var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  4254. var bucket = this.getBucket(context);
  4255. return !!(bucket[key] !== void 0 && bucket[key].length);
  4256. }
  4257. /**
  4258. * Runs all local and global callbacks assigned to the hook identified by the `key` parameter.
  4259. * It returns either a return value from the last called callback or the first parameter (`p1`) passed to the `run` function.
  4260. *
  4261. * @see Core#runHooks
  4262. * @param {Object} context Handsontable instance.
  4263. * @param {String} key Hook/Event name.
  4264. * @param {*} [p1] Parameter to be passed as an argument to the callback function.
  4265. * @param {*} [p2] Parameter to be passed as an argument to the callback function.
  4266. * @param {*} [p3] Parameter to be passed as an argument to the callback function.
  4267. * @param {*} [p4] Parameter to be passed as an argument to the callback function.
  4268. * @param {*} [p5] Parameter to be passed as an argument to the callback function.
  4269. * @param {*} [p6] Parameter to be passed as an argument to the callback function.
  4270. * @returns {*} Either a return value from the last called callback or `p1`.
  4271. *
  4272. * @example
  4273. * ```js
  4274. * Handsontable.hooks.run(hot, 'beforeInit');
  4275. * ```
  4276. */
  4277. }, {
  4278. key: 'run',
  4279. value: function run(context, key, p1, p2, p3, p4, p5, p6) {
  4280. {
  4281. var globalHandlers = this.globalBucket[key];
  4282. var index = -1;
  4283. var length = globalHandlers ? globalHandlers.length : 0;
  4284. if (length) {
  4285. // Do not optimise this loop with arrayEach or arrow function! If you do You'll decrease perf because of GC.
  4286. while (++index < length) {
  4287. if (!globalHandlers[index] || globalHandlers[index].skip) {
  4288. /* eslint-disable no-continue */
  4289. continue;
  4290. }
  4291. // performance considerations - http://jsperf.com/call-vs-apply-for-a-plugin-architecture
  4292. var res = globalHandlers[index].call(context, p1, p2, p3, p4, p5, p6);
  4293. if (res !== void 0) {
  4294. p1 = res;
  4295. }
  4296. if (globalHandlers[index] && globalHandlers[index].runOnce) {
  4297. this.remove(key, globalHandlers[index]);
  4298. }
  4299. }
  4300. }
  4301. }
  4302. {
  4303. var localHandlers = this.getBucket(context)[key];
  4304. var _index = -1;
  4305. var _length = localHandlers ? localHandlers.length : 0;
  4306. if (_length) {
  4307. // Do not optimise this loop with arrayEach or arrow function! If you do You'll decrease perf because of GC.
  4308. while (++_index < _length) {
  4309. if (!localHandlers[_index] || localHandlers[_index].skip) {
  4310. /* eslint-disable no-continue */
  4311. continue;
  4312. }
  4313. // performance considerations - http://jsperf.com/call-vs-apply-for-a-plugin-architecture
  4314. var _res = localHandlers[_index].call(context, p1, p2, p3, p4, p5, p6);
  4315. if (_res !== void 0) {
  4316. p1 = _res;
  4317. }
  4318. if (localHandlers[_index] && localHandlers[_index].runOnce) {
  4319. this.remove(key, localHandlers[_index], context);
  4320. }
  4321. }
  4322. }
  4323. }
  4324. return p1;
  4325. }
  4326. /**
  4327. * Destroy all listeners connected to the context. If no context is provided, the global listeners will be destroyed.
  4328. *
  4329. * @param {Object} [context=null] A Handsontable instance.
  4330. * @example
  4331. * ```js
  4332. * // destroy the global listeners
  4333. * Handsontable.hooks.destroy();
  4334. *
  4335. * // destroy the local listeners
  4336. * Handsontable.hooks.destroy(hotInstance);
  4337. * ```
  4338. */
  4339. }, {
  4340. key: 'destroy',
  4341. value: function destroy() {
  4342. var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  4343. // eslint-disable-next-line no-return-assign
  4344. (0, _object.objectEach)(this.getBucket(context), function (value, key, bucket) {
  4345. return bucket[key].length = 0;
  4346. });
  4347. }
  4348. /**
  4349. * Registers a hook name (adds it to the list of the known hook names). Used by plugins.
  4350. * It is not necessary to call register, but if you use it, your plugin hook will be used returned by
  4351. * the `getRegistered` method. (which itself is used in the demo http://docs.handsontable.com/tutorial-callbacks.html).
  4352. *
  4353. * @param key {String} The hook name.
  4354. *
  4355. * @example
  4356. * ```js
  4357. * Handsontable.hooks.register('myHook');
  4358. * ```
  4359. */
  4360. }, {
  4361. key: 'register',
  4362. value: function register(key) {
  4363. if (!this.isRegistered(key)) {
  4364. REGISTERED_HOOKS.push(key);
  4365. }
  4366. }
  4367. /**
  4368. * Deregisters a hook name (removes it from the list of known hook names).
  4369. *
  4370. * @param key {String} Hook name.
  4371. *
  4372. * @example
  4373. * ```js
  4374. * Handsontable.hooks.deregister('myHook');
  4375. * ```
  4376. */
  4377. }, {
  4378. key: 'deregister',
  4379. value: function deregister(key) {
  4380. if (this.isRegistered(key)) {
  4381. REGISTERED_HOOKS.splice(REGISTERED_HOOKS.indexOf(key), 1);
  4382. }
  4383. }
  4384. /**
  4385. * Returns a boolean depending on if a hook by such name has been registered.
  4386. *
  4387. * @param key {String} Hook name.
  4388. * @returns {Boolean} `true` for success, `false` otherwise.
  4389. *
  4390. * @example
  4391. * ```js
  4392. * Handsontable.hooks.isRegistered('beforeInit');
  4393. *
  4394. * // Results:
  4395. * true
  4396. * ```
  4397. */
  4398. }, {
  4399. key: 'isRegistered',
  4400. value: function isRegistered(key) {
  4401. return REGISTERED_HOOKS.indexOf(key) >= 0;
  4402. }
  4403. /**
  4404. * Returns an array of registered hooks.
  4405. *
  4406. * @returns {Array} An array of registered hooks.
  4407. *
  4408. * @example
  4409. * ```js
  4410. * Handsontable.hooks.getRegistered();
  4411. *
  4412. * // Results:
  4413. * [
  4414. * ...
  4415. * 'beforeInit',
  4416. * 'beforeRender',
  4417. * 'beforeSetRangeEnd',
  4418. * 'beforeDrawBorders',
  4419. * 'beforeChange',
  4420. * ...
  4421. * ]
  4422. * ```
  4423. */
  4424. }, {
  4425. key: 'getRegistered',
  4426. value: function getRegistered() {
  4427. return REGISTERED_HOOKS;
  4428. }
  4429. }]);
  4430. return Hooks;
  4431. }();
  4432. var globalSingleton = new Hooks();
  4433. exports.default = Hooks;
  4434. /***/ }),
  4435. /* 16 */
  4436. /***/ (function(module, exports, __webpack_require__) {
  4437. "use strict";
  4438. exports.__esModule = true;
  4439. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  4440. var _templateObject = _taggedTemplateLiteral(['\n Your license key of Handsontable Pro has expired.\u200C\u200C\u200C\u200C \n Renew your maintenance plan at https://handsontable.com or downgrade to the previous version of the software.\n '], ['\n Your license key of Handsontable Pro has expired.\u200C\u200C\u200C\u200C\\x20\n Renew your maintenance plan at https://handsontable.com or downgrade to the previous version of the software.\n ']);
  4441. exports.stringify = stringify;
  4442. exports.isDefined = isDefined;
  4443. exports.isUndefined = isUndefined;
  4444. exports.isEmpty = isEmpty;
  4445. exports.isRegExp = isRegExp;
  4446. exports._injectProductInfo = _injectProductInfo;
  4447. var _moment = __webpack_require__(41);
  4448. var _moment2 = _interopRequireDefault(_moment);
  4449. var _templateLiteralTag = __webpack_require__(42);
  4450. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4451. function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
  4452. /**
  4453. * Converts any value to string.
  4454. *
  4455. * @param {*} value
  4456. * @returns {String}
  4457. */
  4458. function stringify(value) {
  4459. var result = void 0;
  4460. switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) {
  4461. case 'string':
  4462. case 'number':
  4463. result = '' + value;
  4464. break;
  4465. case 'object':
  4466. result = value === null ? '' : value.toString();
  4467. break;
  4468. case 'undefined':
  4469. result = '';
  4470. break;
  4471. default:
  4472. result = value.toString();
  4473. break;
  4474. }
  4475. return result;
  4476. }
  4477. /**
  4478. * Checks if given variable is defined.
  4479. *
  4480. * @param {*} variable Variable to check.
  4481. * @returns {Boolean}
  4482. */
  4483. function isDefined(variable) {
  4484. return typeof variable !== 'undefined';
  4485. }
  4486. /**
  4487. * Checks if given variable is undefined.
  4488. *
  4489. * @param {*} variable Variable to check.
  4490. * @returns {Boolean}
  4491. */
  4492. function isUndefined(variable) {
  4493. return typeof variable === 'undefined';
  4494. }
  4495. /**
  4496. * Check if given variable is null, empty string or undefined.
  4497. *
  4498. * @param {*} variable Variable to check.
  4499. * @returns {Boolean}
  4500. */
  4501. function isEmpty(variable) {
  4502. return variable === null || variable === '' || isUndefined(variable);
  4503. }
  4504. /**
  4505. * Check if given variable is a regular expression.
  4506. *
  4507. * @param {*} variable Variable to check.
  4508. * @returns {Boolean}
  4509. */
  4510. function isRegExp(variable) {
  4511. return Object.prototype.toString.call(variable) === '[object RegExp]';
  4512. }
  4513. /* eslint-disable */
  4514. var _m = '\x6C\x65\x6E\x67\x74\x68';
  4515. var _hd = function _hd(v) {
  4516. return parseInt(v, 16);
  4517. };
  4518. var _pi = function _pi(v) {
  4519. return parseInt(v, 10);
  4520. };
  4521. var _ss = function _ss(v, s, l) {
  4522. return v['\x73\x75\x62\x73\x74\x72'](s, l);
  4523. };
  4524. var _cp = function _cp(v) {
  4525. return v['\x63\x6F\x64\x65\x50\x6F\x69\x6E\x74\x41\x74'](0) - 65;
  4526. };
  4527. var _norm = function _norm(v) {
  4528. return ('' + v).replace(/\-/g, '');
  4529. };
  4530. var _extractTime = function _extractTime(v) {
  4531. return _hd(_ss(_norm(v), _hd('12'), _cp('\x46'))) / (_hd(_ss(_norm(v), _cp('\x42'), ~~![][_m])) || 9);
  4532. };
  4533. var _ignored = function _ignored() {
  4534. return typeof location !== 'undefined' && /^([a-z0-9\-]+\.)?\x68\x61\x6E\x64\x73\x6F\x6E\x74\x61\x62\x6C\x65\x2E\x63\x6F\x6D$/i.test(location.host);
  4535. };
  4536. var _notified = false;
  4537. function _injectProductInfo(key, element) {
  4538. key = _norm(key || '');
  4539. var warningMessage = '';
  4540. var showDomMessage = true;
  4541. var schemaValidity = _checkKeySchema(key);
  4542. var ignored = _ignored();
  4543. var trial = isEmpty(key) || key === 'trial';
  4544. if (trial || schemaValidity) {
  4545. if (schemaValidity) {
  4546. var releaseTime = Math.floor((0, _moment2.default)('11/04/2018', 'DD/MM/YYYY').toDate().getTime() / 8.64e7);
  4547. var keyGenTime = _extractTime(key);
  4548. if (keyGenTime > 45000 || keyGenTime !== parseInt(keyGenTime, 10)) {
  4549. warningMessage = 'The license key provided to Handsontable Pro is invalid. Make sure you pass it correctly.';
  4550. }
  4551. if (!warningMessage) {
  4552. if (releaseTime > keyGenTime + 1) {
  4553. warningMessage = (0, _templateLiteralTag.toSingleLine)(_templateObject);
  4554. }
  4555. showDomMessage = releaseTime > keyGenTime + 15;
  4556. }
  4557. } else {
  4558. warningMessage = 'Evaluation version of Handsontable Pro. Not licensed for use in a production environment.';
  4559. }
  4560. } else {
  4561. warningMessage = 'The license key provided to Handsontable Pro is invalid. Make sure you pass it correctly.';
  4562. }
  4563. if (ignored) {
  4564. warningMessage = false;
  4565. showDomMessage = false;
  4566. }
  4567. if (warningMessage && !_notified) {
  4568. console[trial ? 'info' : 'warn'](warningMessage);
  4569. _notified = true;
  4570. }
  4571. if (showDomMessage && element.parentNode) {
  4572. var message = document.createElement('div');
  4573. message.id = 'hot-display-license-info';
  4574. message.appendChild(document.createTextNode('Evaluation version of Handsontable Pro.'));
  4575. message.appendChild(document.createElement('br'));
  4576. message.appendChild(document.createTextNode('Not licensed for production use.'));
  4577. element.parentNode.insertBefore(message, element.nextSibling);
  4578. }
  4579. }
  4580. function _checkKeySchema(v) {
  4581. var z = [][_m];
  4582. var p = z;
  4583. if (v[_m] !== _cp('\x5A')) {
  4584. return false;
  4585. }
  4586. for (var c = '', i = '\x42\x3C\x48\x34\x50\x2B'.split(''), j = _cp(i.shift()); j; j = _cp(i.shift() || 'A')) {
  4587. --j < ''[_m] ? p = p | (_pi('' + _pi(_hd(c) + (_hd(_ss(v, Math.abs(j), 2)) + []).padStart(2, '0'))) % 97 || 2) >> 1 : c = _ss(v, j, !j ? 6 : i[_m] === 1 ? 9 : 8);
  4588. }
  4589. return p === z;
  4590. }
  4591. /* eslint-enable */
  4592. /***/ }),
  4593. /* 17 */
  4594. /***/ (function(module, exports, __webpack_require__) {
  4595. "use strict";
  4596. exports.__esModule = true;
  4597. exports.getRegisteredEditors = exports.getRegisteredEditorNames = exports.hasEditor = exports.getEditorInstance = exports.getEditor = exports.registerEditor = undefined;
  4598. exports.RegisteredEditor = RegisteredEditor;
  4599. exports._getEditorInstance = _getEditorInstance;
  4600. var _staticRegister2 = __webpack_require__(39);
  4601. var _staticRegister3 = _interopRequireDefault(_staticRegister2);
  4602. var _pluginHooks = __webpack_require__(15);
  4603. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  4604. var _baseEditor = __webpack_require__(54);
  4605. var _baseEditor2 = _interopRequireDefault(_baseEditor);
  4606. var _autocompleteEditor = __webpack_require__(307);
  4607. var _autocompleteEditor2 = _interopRequireDefault(_autocompleteEditor);
  4608. var _checkboxEditor = __webpack_require__(356);
  4609. var _checkboxEditor2 = _interopRequireDefault(_checkboxEditor);
  4610. var _dateEditor = __webpack_require__(357);
  4611. var _dateEditor2 = _interopRequireDefault(_dateEditor);
  4612. var _dropdownEditor = __webpack_require__(360);
  4613. var _dropdownEditor2 = _interopRequireDefault(_dropdownEditor);
  4614. var _handsontableEditor = __webpack_require__(308);
  4615. var _handsontableEditor2 = _interopRequireDefault(_handsontableEditor);
  4616. var _numericEditor = __webpack_require__(361);
  4617. var _numericEditor2 = _interopRequireDefault(_numericEditor);
  4618. var _passwordEditor = __webpack_require__(362);
  4619. var _passwordEditor2 = _interopRequireDefault(_passwordEditor);
  4620. var _selectEditor = __webpack_require__(363);
  4621. var _selectEditor2 = _interopRequireDefault(_selectEditor);
  4622. var _textEditor = __webpack_require__(57);
  4623. var _textEditor2 = _interopRequireDefault(_textEditor);
  4624. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4625. /**
  4626. * Utility to register editors and common namespace for keeping reference to all editor classes
  4627. */
  4628. var registeredEditorClasses = new WeakMap();
  4629. var _staticRegister = (0, _staticRegister3.default)('editors'),
  4630. register = _staticRegister.register,
  4631. getItem = _staticRegister.getItem,
  4632. hasItem = _staticRegister.hasItem,
  4633. getNames = _staticRegister.getNames,
  4634. getValues = _staticRegister.getValues;
  4635. _register('base', _baseEditor2.default);
  4636. _register('autocomplete', _autocompleteEditor2.default);
  4637. _register('checkbox', _checkboxEditor2.default);
  4638. _register('date', _dateEditor2.default);
  4639. _register('dropdown', _dropdownEditor2.default);
  4640. _register('handsontable', _handsontableEditor2.default);
  4641. _register('numeric', _numericEditor2.default);
  4642. _register('password', _passwordEditor2.default);
  4643. _register('select', _selectEditor2.default);
  4644. _register('text', _textEditor2.default);
  4645. function RegisteredEditor(editorClass) {
  4646. var instances = {};
  4647. var Clazz = editorClass;
  4648. this.getConstructor = function () {
  4649. return editorClass;
  4650. };
  4651. this.getInstance = function (hotInstance) {
  4652. if (!(hotInstance.guid in instances)) {
  4653. instances[hotInstance.guid] = new Clazz(hotInstance);
  4654. }
  4655. return instances[hotInstance.guid];
  4656. };
  4657. _pluginHooks2.default.getSingleton().add('afterDestroy', function () {
  4658. instances = {};
  4659. });
  4660. }
  4661. /**
  4662. * Returns instance (singleton) of editor class.
  4663. *
  4664. * @param {String} name Name of an editor under which it has been stored.
  4665. * @param {Object} hotInstance Instance of Handsontable.
  4666. * @returns {Function} Returns instance of editor.
  4667. */
  4668. function _getEditorInstance(name, hotInstance) {
  4669. var editor = void 0;
  4670. if (typeof name === 'function') {
  4671. if (!registeredEditorClasses.get(name)) {
  4672. _register(null, name);
  4673. }
  4674. editor = registeredEditorClasses.get(name);
  4675. } else if (typeof name === 'string') {
  4676. editor = getItem(name);
  4677. } else {
  4678. throw Error('Only strings and functions can be passed as "editor" parameter');
  4679. }
  4680. if (!editor) {
  4681. throw Error('No editor registered under name "' + name + '"');
  4682. }
  4683. return editor.getInstance(hotInstance);
  4684. }
  4685. /**
  4686. * Retrieve editor class.
  4687. *
  4688. * @param {String} name Editor identification.
  4689. * @returns {Function} Returns editor class.
  4690. */
  4691. function _getItem(name) {
  4692. if (!hasItem(name)) {
  4693. throw Error('No registered editor found under "' + name + '" name');
  4694. }
  4695. return getItem(name).getConstructor();
  4696. }
  4697. /**
  4698. * Register editor class under specified name.
  4699. *
  4700. * @param {String} name Editor identification.
  4701. * @param {Function} editorClass Editor class.
  4702. */
  4703. function _register(name, editorClass) {
  4704. var editorWrapper = new RegisteredEditor(editorClass);
  4705. if (typeof name === 'string') {
  4706. register(name, editorWrapper);
  4707. }
  4708. registeredEditorClasses.set(editorClass, editorWrapper);
  4709. }
  4710. exports.registerEditor = _register;
  4711. exports.getEditor = _getItem;
  4712. exports.getEditorInstance = _getEditorInstance;
  4713. exports.hasEditor = hasItem;
  4714. exports.getRegisteredEditorNames = getNames;
  4715. exports.getRegisteredEditors = getValues;
  4716. /***/ }),
  4717. /* 18 */
  4718. /***/ (function(module, exports, __webpack_require__) {
  4719. var isObject = __webpack_require__(9);
  4720. module.exports = function (it) {
  4721. if (!isObject(it)) throw TypeError(it + ' is not an object!');
  4722. return it;
  4723. };
  4724. /***/ }),
  4725. /* 19 */
  4726. /***/ (function(module, exports, __webpack_require__) {
  4727. "use strict";
  4728. exports.__esModule = true;
  4729. exports.normalizeSelection = normalizeSelection;
  4730. exports.isSeparator = isSeparator;
  4731. exports.hasSubMenu = hasSubMenu;
  4732. exports.isDisabled = isDisabled;
  4733. exports.isSelectionDisabled = isSelectionDisabled;
  4734. exports.getValidSelection = getValidSelection;
  4735. exports.prepareVerticalAlignClass = prepareVerticalAlignClass;
  4736. exports.prepareHorizontalAlignClass = prepareHorizontalAlignClass;
  4737. exports.getAlignmentClasses = getAlignmentClasses;
  4738. exports.align = align;
  4739. exports.checkSelectionConsistency = checkSelectionConsistency;
  4740. exports.markLabelAsSelected = markLabelAsSelected;
  4741. exports.isItemHidden = isItemHidden;
  4742. exports.filterSeparators = filterSeparators;
  4743. var _array = __webpack_require__(1);
  4744. var _number = __webpack_require__(5);
  4745. var _element = __webpack_require__(0);
  4746. var _separator = __webpack_require__(93);
  4747. function normalizeSelection(selRanges) {
  4748. return (0, _array.arrayMap)(selRanges, function (range) {
  4749. return {
  4750. start: range.getTopLeftCorner(),
  4751. end: range.getBottomRightCorner()
  4752. };
  4753. });
  4754. }
  4755. function isSeparator(cell) {
  4756. return (0, _element.hasClass)(cell, 'htSeparator');
  4757. }
  4758. function hasSubMenu(cell) {
  4759. return (0, _element.hasClass)(cell, 'htSubmenu');
  4760. }
  4761. function isDisabled(cell) {
  4762. return (0, _element.hasClass)(cell, 'htDisabled');
  4763. }
  4764. function isSelectionDisabled(cell) {
  4765. return (0, _element.hasClass)(cell, 'htSelectionDisabled');
  4766. }
  4767. function getValidSelection(hot) {
  4768. var selected = hot.getSelected();
  4769. if (!selected) {
  4770. return null;
  4771. }
  4772. if (selected[0] < 0) {
  4773. return null;
  4774. }
  4775. return selected;
  4776. }
  4777. function prepareVerticalAlignClass(className, alignment) {
  4778. if (className.indexOf(alignment) != -1) {
  4779. return className;
  4780. }
  4781. className = className.replace('htTop', '').replace('htMiddle', '').replace('htBottom', '').replace(' ', '');
  4782. className += ' ' + alignment;
  4783. return className;
  4784. }
  4785. function prepareHorizontalAlignClass(className, alignment) {
  4786. if (className.indexOf(alignment) != -1) {
  4787. return className;
  4788. }
  4789. className = className.replace('htLeft', '').replace('htCenter', '').replace('htRight', '').replace('htJustify', '').replace(' ', '');
  4790. className += ' ' + alignment;
  4791. return className;
  4792. }
  4793. function getAlignmentClasses(ranges, callback) {
  4794. var classes = {};
  4795. (0, _array.arrayEach)(ranges, function (_ref) {
  4796. var from = _ref.from,
  4797. to = _ref.to;
  4798. for (var row = from.row; row <= to.row; row++) {
  4799. for (var col = from.col; col <= to.col; col++) {
  4800. if (!classes[row]) {
  4801. classes[row] = [];
  4802. }
  4803. classes[row][col] = callback(row, col);
  4804. }
  4805. }
  4806. });
  4807. return classes;
  4808. }
  4809. function align(ranges, type, alignment, cellDescriptor, propertySetter) {
  4810. (0, _array.arrayEach)(ranges, function (_ref2) {
  4811. var from = _ref2.from,
  4812. to = _ref2.to;
  4813. if (from.row == to.row && from.col == to.col) {
  4814. applyAlignClassName(from.row, from.col, type, alignment, cellDescriptor, propertySetter);
  4815. } else {
  4816. for (var row = from.row; row <= to.row; row++) {
  4817. for (var col = from.col; col <= to.col; col++) {
  4818. applyAlignClassName(row, col, type, alignment, cellDescriptor, propertySetter);
  4819. }
  4820. }
  4821. }
  4822. });
  4823. }
  4824. function applyAlignClassName(row, col, type, alignment, cellDescriptor, propertySetter) {
  4825. var cellMeta = cellDescriptor(row, col);
  4826. var className = alignment;
  4827. if (cellMeta.className) {
  4828. if (type === 'vertical') {
  4829. className = prepareVerticalAlignClass(cellMeta.className, alignment);
  4830. } else {
  4831. className = prepareHorizontalAlignClass(cellMeta.className, alignment);
  4832. }
  4833. }
  4834. propertySetter(row, col, 'className', className);
  4835. }
  4836. function checkSelectionConsistency(ranges, comparator) {
  4837. var result = false;
  4838. if (Array.isArray(ranges)) {
  4839. (0, _array.arrayEach)(ranges, function (range) {
  4840. range.forAll(function (row, col) {
  4841. if (comparator(row, col)) {
  4842. result = true;
  4843. return false;
  4844. }
  4845. });
  4846. return result;
  4847. });
  4848. }
  4849. return result;
  4850. }
  4851. function markLabelAsSelected(label) {
  4852. // workaround for https://github.com/handsontable/handsontable/issues/1946
  4853. return '<span class="selected">' + String.fromCharCode(10003) + '</span>' + label;
  4854. }
  4855. function isItemHidden(item, instance) {
  4856. return !item.hidden || !(typeof item.hidden == 'function' && item.hidden.call(instance));
  4857. }
  4858. function shiftSeparators(items, separator) {
  4859. var result = items.slice(0);
  4860. for (var i = 0; i < result.length;) {
  4861. if (result[i].name === separator) {
  4862. result.shift();
  4863. } else {
  4864. break;
  4865. }
  4866. }
  4867. return result;
  4868. }
  4869. function popSeparators(items, separator) {
  4870. var result = items.slice(0);
  4871. result.reverse();
  4872. result = shiftSeparators(result, separator);
  4873. result.reverse();
  4874. return result;
  4875. }
  4876. function removeDuplicatedSeparators(items) {
  4877. var result = [];
  4878. (0, _array.arrayEach)(items, function (value, index) {
  4879. if (index > 0) {
  4880. if (result[result.length - 1].name !== value.name) {
  4881. result.push(value);
  4882. }
  4883. } else {
  4884. result.push(value);
  4885. }
  4886. });
  4887. return result;
  4888. }
  4889. function filterSeparators(items) {
  4890. var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _separator.KEY;
  4891. var result = items.slice(0);
  4892. result = shiftSeparators(result, separator);
  4893. result = popSeparators(result, separator);
  4894. result = removeDuplicatedSeparators(result);
  4895. return result;
  4896. }
  4897. /***/ }),
  4898. /* 20 */
  4899. /***/ (function(module, exports, __webpack_require__) {
  4900. var anObject = __webpack_require__(18);
  4901. var IE8_DOM_DEFINE = __webpack_require__(98);
  4902. var toPrimitive = __webpack_require__(73);
  4903. var dP = Object.defineProperty;
  4904. exports.f = __webpack_require__(22) ? Object.defineProperty : function defineProperty(O, P, Attributes) {
  4905. anObject(O);
  4906. P = toPrimitive(P, true);
  4907. anObject(Attributes);
  4908. if (IE8_DOM_DEFINE) try {
  4909. return dP(O, P, Attributes);
  4910. } catch (e) { /* empty */ }
  4911. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
  4912. if ('value' in Attributes) O[P] = Attributes.value;
  4913. return O;
  4914. };
  4915. /***/ }),
  4916. /* 21 */
  4917. /***/ (function(module, exports, __webpack_require__) {
  4918. "use strict";
  4919. exports.__esModule = true;
  4920. exports.KEY_CODES = undefined;
  4921. exports.isPrintableChar = isPrintableChar;
  4922. exports.isMetaKey = isMetaKey;
  4923. exports.isCtrlKey = isCtrlKey;
  4924. exports.isCtrlMetaKey = isCtrlMetaKey;
  4925. exports.isKey = isKey;
  4926. var _array = __webpack_require__(1);
  4927. var KEY_CODES = exports.KEY_CODES = {
  4928. MOUSE_LEFT: 1,
  4929. MOUSE_RIGHT: 3,
  4930. MOUSE_MIDDLE: 2,
  4931. BACKSPACE: 8,
  4932. COMMA: 188,
  4933. INSERT: 45,
  4934. DELETE: 46,
  4935. END: 35,
  4936. ENTER: 13,
  4937. ESCAPE: 27,
  4938. CONTROL: 17,
  4939. COMMAND_LEFT: 91,
  4940. COMMAND_RIGHT: 93,
  4941. COMMAND_FIREFOX: 224,
  4942. ALT: 18,
  4943. HOME: 36,
  4944. PAGE_DOWN: 34,
  4945. PAGE_UP: 33,
  4946. PERIOD: 190,
  4947. SPACE: 32,
  4948. SHIFT: 16,
  4949. CAPS_LOCK: 20,
  4950. TAB: 9,
  4951. ARROW_RIGHT: 39,
  4952. ARROW_LEFT: 37,
  4953. ARROW_UP: 38,
  4954. ARROW_DOWN: 40,
  4955. F1: 112,
  4956. F2: 113,
  4957. F3: 114,
  4958. F4: 115,
  4959. F5: 116,
  4960. F6: 117,
  4961. F7: 118,
  4962. F8: 119,
  4963. F9: 120,
  4964. F10: 121,
  4965. F11: 122,
  4966. F12: 123,
  4967. A: 65,
  4968. X: 88,
  4969. C: 67,
  4970. V: 86
  4971. };
  4972. /**
  4973. * Returns true if keyCode represents a printable character.
  4974. *
  4975. * @param {Number} keyCode
  4976. * @returns {Boolean}
  4977. */
  4978. function isPrintableChar(keyCode) {
  4979. return keyCode == 32 || // space
  4980. keyCode >= 48 && keyCode <= 57 || // 0-9
  4981. keyCode >= 96 && keyCode <= 111 || // numpad
  4982. keyCode >= 186 && keyCode <= 192 || // ;=,-./`
  4983. keyCode >= 219 && keyCode <= 222 || // []{}\|"'
  4984. keyCode >= 226 || // special chars (229 for Asian chars)
  4985. keyCode >= 65 && keyCode <= 90; // a-z
  4986. }
  4987. /**
  4988. * @param {Number} keyCode
  4989. * @returns {Boolean}
  4990. */
  4991. function isMetaKey(keyCode) {
  4992. var metaKeys = [KEY_CODES.ARROW_DOWN, KEY_CODES.ARROW_UP, KEY_CODES.ARROW_LEFT, KEY_CODES.ARROW_RIGHT, KEY_CODES.HOME, KEY_CODES.END, KEY_CODES.DELETE, KEY_CODES.BACKSPACE, KEY_CODES.F1, KEY_CODES.F2, KEY_CODES.F3, KEY_CODES.F4, KEY_CODES.F5, KEY_CODES.F6, KEY_CODES.F7, KEY_CODES.F8, KEY_CODES.F9, KEY_CODES.F10, KEY_CODES.F11, KEY_CODES.F12, KEY_CODES.TAB, KEY_CODES.PAGE_DOWN, KEY_CODES.PAGE_UP, KEY_CODES.ENTER, KEY_CODES.ESCAPE, KEY_CODES.SHIFT, KEY_CODES.CAPS_LOCK, KEY_CODES.ALT];
  4993. return metaKeys.indexOf(keyCode) !== -1;
  4994. }
  4995. /**
  4996. * Checks if passed key code is ctrl or cmd key. Depends on what OS the code runs it check key code based on
  4997. * different meta key codes.
  4998. *
  4999. * @param {Number} keyCode Key code to check.
  5000. * @returns {Boolean}
  5001. */
  5002. function isCtrlKey(keyCode) {
  5003. var keys = [];
  5004. if (window.navigator.platform.includes('Mac')) {
  5005. keys.push(KEY_CODES.COMMAND_LEFT, KEY_CODES.COMMAND_RIGHT, KEY_CODES.COMMAND_FIREFOX);
  5006. } else {
  5007. keys.push(KEY_CODES.CONTROL);
  5008. }
  5009. return keys.includes(keyCode);
  5010. }
  5011. /**
  5012. * Checks if passed key code is ctrl or cmd key. This helper checks if the key code matches to meta keys
  5013. * regardless of the OS on which it is running.
  5014. *
  5015. * @param {Number} keyCode Key code to check.
  5016. * @returns {Boolean}
  5017. */
  5018. function isCtrlMetaKey(keyCode) {
  5019. return [KEY_CODES.CONTROL, KEY_CODES.COMMAND_LEFT, KEY_CODES.COMMAND_RIGHT, KEY_CODES.COMMAND_FIREFOX].includes(keyCode);
  5020. }
  5021. /**
  5022. * @param {Number} keyCode
  5023. * @param {String} baseCode
  5024. * @returns {Boolean}
  5025. */
  5026. function isKey(keyCode, baseCode) {
  5027. var keys = baseCode.split('|');
  5028. var result = false;
  5029. (0, _array.arrayEach)(keys, function (key) {
  5030. if (keyCode === KEY_CODES[key]) {
  5031. result = true;
  5032. return false;
  5033. }
  5034. });
  5035. return result;
  5036. }
  5037. /***/ }),
  5038. /* 22 */
  5039. /***/ (function(module, exports, __webpack_require__) {
  5040. // Thank's IE8 for his funny defineProperty
  5041. module.exports = !__webpack_require__(23)(function () {
  5042. return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
  5043. });
  5044. /***/ }),
  5045. /* 23 */
  5046. /***/ (function(module, exports) {
  5047. module.exports = function (exec) {
  5048. try {
  5049. return !!exec();
  5050. } catch (e) {
  5051. return true;
  5052. }
  5053. };
  5054. /***/ }),
  5055. /* 24 */
  5056. /***/ (function(module, exports, __webpack_require__) {
  5057. // to indexed object, toObject with fallback for non-array-like ES3 strings
  5058. var IObject = __webpack_require__(75);
  5059. var defined = __webpack_require__(38);
  5060. module.exports = function (it) {
  5061. return IObject(defined(it));
  5062. };
  5063. /***/ }),
  5064. /* 25 */
  5065. /***/ (function(module, exports, __webpack_require__) {
  5066. // 7.1.15 ToLength
  5067. var toInteger = __webpack_require__(59);
  5068. var min = Math.min;
  5069. module.exports = function (it) {
  5070. return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
  5071. };
  5072. /***/ }),
  5073. /* 26 */
  5074. /***/ (function(module, exports, __webpack_require__) {
  5075. // most Object methods by ES6 should accept primitives
  5076. var $export = __webpack_require__(3);
  5077. var core = __webpack_require__(45);
  5078. var fails = __webpack_require__(23);
  5079. module.exports = function (KEY, exec) {
  5080. var fn = (core.Object || {})[KEY] || Object[KEY];
  5081. var exp = {};
  5082. exp[KEY] = exec(fn);
  5083. $export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp);
  5084. };
  5085. /***/ }),
  5086. /* 27 */
  5087. /***/ (function(module, exports, __webpack_require__) {
  5088. "use strict";
  5089. exports.__esModule = true;
  5090. exports.isIE8 = isIE8;
  5091. exports.isIE9 = isIE9;
  5092. exports.isSafari = isSafari;
  5093. exports.isChrome = isChrome;
  5094. exports.isMobileBrowser = isMobileBrowser;
  5095. var _isIE8 = !document.createTextNode('test').textContent;
  5096. function isIE8() {
  5097. return _isIE8;
  5098. }
  5099. var _isIE9 = !!document.documentMode;
  5100. function isIE9() {
  5101. return _isIE9;
  5102. }
  5103. var _isSafari = /Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor);
  5104. function isSafari() {
  5105. return _isSafari;
  5106. }
  5107. var _isChrome = /Chrome/.test(navigator.userAgent) && /Google/.test(navigator.vendor);
  5108. function isChrome() {
  5109. return _isChrome;
  5110. }
  5111. function isMobileBrowser(userAgent) {
  5112. if (!userAgent) {
  5113. userAgent = navigator.userAgent;
  5114. }
  5115. return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent)
  5116. );
  5117. }
  5118. /***/ }),
  5119. /* 28 */
  5120. /***/ (function(module, exports, __webpack_require__) {
  5121. "use strict";
  5122. exports.__esModule = true;
  5123. exports.getRegisteredValidators = exports.getRegisteredValidatorNames = exports.hasValidator = exports.getValidator = exports.registerValidator = undefined;
  5124. var _staticRegister2 = __webpack_require__(39);
  5125. var _staticRegister3 = _interopRequireDefault(_staticRegister2);
  5126. var _autocompleteValidator = __webpack_require__(372);
  5127. var _autocompleteValidator2 = _interopRequireDefault(_autocompleteValidator);
  5128. var _dateValidator = __webpack_require__(373);
  5129. var _dateValidator2 = _interopRequireDefault(_dateValidator);
  5130. var _numericValidator = __webpack_require__(374);
  5131. var _numericValidator2 = _interopRequireDefault(_numericValidator);
  5132. var _timeValidator = __webpack_require__(375);
  5133. var _timeValidator2 = _interopRequireDefault(_timeValidator);
  5134. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5135. var _staticRegister = (0, _staticRegister3.default)('validators'),
  5136. register = _staticRegister.register,
  5137. getItem = _staticRegister.getItem,
  5138. hasItem = _staticRegister.hasItem,
  5139. getNames = _staticRegister.getNames,
  5140. getValues = _staticRegister.getValues;
  5141. register('autocomplete', _autocompleteValidator2.default);
  5142. register('date', _dateValidator2.default);
  5143. register('numeric', _numericValidator2.default);
  5144. register('time', _timeValidator2.default);
  5145. /**
  5146. * Retrieve validator function.
  5147. *
  5148. * @param {String} name Validator identification.
  5149. * @returns {Function} Returns validator function.
  5150. */
  5151. function _getItem(name) {
  5152. if (typeof name === 'function') {
  5153. return name;
  5154. }
  5155. if (!hasItem(name)) {
  5156. throw Error('No registered validator found under "' + name + '" name');
  5157. }
  5158. return getItem(name);
  5159. }
  5160. exports.registerValidator = register;
  5161. exports.getValidator = _getItem;
  5162. exports.hasValidator = hasItem;
  5163. exports.getRegisteredValidatorNames = getNames;
  5164. exports.getRegisteredValidators = getValues;
  5165. /***/ }),
  5166. /* 29 */
  5167. /***/ (function(module, exports) {
  5168. var hasOwnProperty = {}.hasOwnProperty;
  5169. module.exports = function (it, key) {
  5170. return hasOwnProperty.call(it, key);
  5171. };
  5172. /***/ }),
  5173. /* 30 */
  5174. /***/ (function(module, exports, __webpack_require__) {
  5175. var global = __webpack_require__(14);
  5176. var hide = __webpack_require__(31);
  5177. var has = __webpack_require__(29);
  5178. var SRC = __webpack_require__(49)('src');
  5179. var TO_STRING = 'toString';
  5180. var $toString = Function[TO_STRING];
  5181. var TPL = ('' + $toString).split(TO_STRING);
  5182. __webpack_require__(45).inspectSource = function (it) {
  5183. return $toString.call(it);
  5184. };
  5185. (module.exports = function (O, key, val, safe) {
  5186. var isFunction = typeof val == 'function';
  5187. if (isFunction) has(val, 'name') || hide(val, 'name', key);
  5188. if (O[key] === val) return;
  5189. if (isFunction) has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
  5190. if (O === global) {
  5191. O[key] = val;
  5192. } else if (!safe) {
  5193. delete O[key];
  5194. hide(O, key, val);
  5195. } else if (O[key]) {
  5196. O[key] = val;
  5197. } else {
  5198. hide(O, key, val);
  5199. }
  5200. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  5201. })(Function.prototype, TO_STRING, function toString() {
  5202. return typeof this == 'function' && this[SRC] || $toString.call(this);
  5203. });
  5204. /***/ }),
  5205. /* 31 */
  5206. /***/ (function(module, exports, __webpack_require__) {
  5207. var dP = __webpack_require__(20);
  5208. var createDesc = __webpack_require__(50);
  5209. module.exports = __webpack_require__(22) ? function (object, key, value) {
  5210. return dP.f(object, key, createDesc(1, value));
  5211. } : function (object, key, value) {
  5212. object[key] = value;
  5213. return object;
  5214. };
  5215. /***/ }),
  5216. /* 32 */
  5217. /***/ (function(module, exports, __webpack_require__) {
  5218. // optional / simple context binding
  5219. var aFunction = __webpack_require__(62);
  5220. module.exports = function (fn, that, length) {
  5221. aFunction(fn);
  5222. if (that === undefined) return fn;
  5223. switch (length) {
  5224. case 1: return function (a) {
  5225. return fn.call(that, a);
  5226. };
  5227. case 2: return function (a, b) {
  5228. return fn.call(that, a, b);
  5229. };
  5230. case 3: return function (a, b, c) {
  5231. return fn.call(that, a, b, c);
  5232. };
  5233. }
  5234. return function (/* ...args */) {
  5235. return fn.apply(that, arguments);
  5236. };
  5237. };
  5238. /***/ }),
  5239. /* 33 */
  5240. /***/ (function(module, exports, __webpack_require__) {
  5241. // 7.1.13 ToObject(argument)
  5242. var defined = __webpack_require__(38);
  5243. module.exports = function (it) {
  5244. return Object(defined(it));
  5245. };
  5246. /***/ }),
  5247. /* 34 */
  5248. /***/ (function(module, exports, __webpack_require__) {
  5249. var META = __webpack_require__(49)('meta');
  5250. var isObject = __webpack_require__(9);
  5251. var has = __webpack_require__(29);
  5252. var setDesc = __webpack_require__(20).f;
  5253. var id = 0;
  5254. var isExtensible = Object.isExtensible || function () {
  5255. return true;
  5256. };
  5257. var FREEZE = !__webpack_require__(23)(function () {
  5258. return isExtensible(Object.preventExtensions({}));
  5259. });
  5260. var setMeta = function (it) {
  5261. setDesc(it, META, { value: {
  5262. i: 'O' + ++id, // object ID
  5263. w: {} // weak collections IDs
  5264. } });
  5265. };
  5266. var fastKey = function (it, create) {
  5267. // return primitive with prefix
  5268. if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  5269. if (!has(it, META)) {
  5270. // can't set metadata to uncaught frozen object
  5271. if (!isExtensible(it)) return 'F';
  5272. // not necessary to add metadata
  5273. if (!create) return 'E';
  5274. // add missing metadata
  5275. setMeta(it);
  5276. // return object ID
  5277. } return it[META].i;
  5278. };
  5279. var getWeak = function (it, create) {
  5280. if (!has(it, META)) {
  5281. // can't set metadata to uncaught frozen object
  5282. if (!isExtensible(it)) return true;
  5283. // not necessary to add metadata
  5284. if (!create) return false;
  5285. // add missing metadata
  5286. setMeta(it);
  5287. // return hash weak collections IDs
  5288. } return it[META].w;
  5289. };
  5290. // add metadata on freeze-family methods calling
  5291. var onFreeze = function (it) {
  5292. if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);
  5293. return it;
  5294. };
  5295. var meta = module.exports = {
  5296. KEY: META,
  5297. NEED: false,
  5298. fastKey: fastKey,
  5299. getWeak: getWeak,
  5300. onFreeze: onFreeze
  5301. };
  5302. /***/ }),
  5303. /* 35 */
  5304. /***/ (function(module, exports, __webpack_require__) {
  5305. "use strict";
  5306. exports.__esModule = true;
  5307. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  5308. var _element = __webpack_require__(0);
  5309. var _object = __webpack_require__(2);
  5310. var _array = __webpack_require__(1);
  5311. var _eventManager = __webpack_require__(6);
  5312. var _eventManager2 = _interopRequireDefault(_eventManager);
  5313. var _core = __webpack_require__(179);
  5314. var _core2 = _interopRequireDefault(_core);
  5315. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5316. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5317. var registeredOverlays = {};
  5318. /**
  5319. * Creates an overlay over the original Walkontable instance. The overlay renders the clone of the original Walkontable
  5320. * and (optionally) implements behavior needed for native horizontal and vertical scrolling.
  5321. *
  5322. * @class Overlay
  5323. */
  5324. var Overlay = function () {
  5325. _createClass(Overlay, null, [{
  5326. key: 'registerOverlay',
  5327. /**
  5328. * Register overlay class.
  5329. *
  5330. * @param {String} type Overlay type, one of the CLONE_TYPES value
  5331. * @param {Overlay} overlayClass Overlay class extended from base overlay class {@link Overlay}
  5332. */
  5333. value: function registerOverlay(type, overlayClass) {
  5334. if (Overlay.CLONE_TYPES.indexOf(type) === -1) {
  5335. throw new Error('Unsupported overlay (' + type + ').');
  5336. }
  5337. registeredOverlays[type] = overlayClass;
  5338. }
  5339. /**
  5340. * Create new instance of overlay type.
  5341. *
  5342. * @param {String} type Overlay type, one of the CLONE_TYPES value
  5343. * @param {Walkontable} wot Walkontable instance
  5344. */
  5345. }, {
  5346. key: 'createOverlay',
  5347. value: function createOverlay(type, wot) {
  5348. return new registeredOverlays[type](wot);
  5349. }
  5350. /**
  5351. * Check if specified overlay was registered.
  5352. *
  5353. * @param {String} type Overlay type, one of the CLONE_TYPES value
  5354. * @returns {Boolean}
  5355. */
  5356. }, {
  5357. key: 'hasOverlay',
  5358. value: function hasOverlay(type) {
  5359. return registeredOverlays[type] !== void 0;
  5360. }
  5361. /**
  5362. * Checks if overlay object (`overlay`) is instance of overlay type (`type`).
  5363. *
  5364. * @param {Overlay} overlay Overlay object
  5365. * @param {String} type Overlay type, one of the CLONE_TYPES value
  5366. * @returns {Boolean}
  5367. */
  5368. }, {
  5369. key: 'isOverlayTypeOf',
  5370. value: function isOverlayTypeOf(overlay, type) {
  5371. if (!overlay || !registeredOverlays[type]) {
  5372. return false;
  5373. }
  5374. return overlay instanceof registeredOverlays[type];
  5375. }
  5376. /**
  5377. * @param {Walkontable} wotInstance
  5378. */
  5379. }, {
  5380. key: 'CLONE_TOP',
  5381. /**
  5382. * @type {String}
  5383. */
  5384. get: function get() {
  5385. return 'top';
  5386. }
  5387. /**
  5388. * @type {String}
  5389. */
  5390. }, {
  5391. key: 'CLONE_BOTTOM',
  5392. get: function get() {
  5393. return 'bottom';
  5394. }
  5395. /**
  5396. * @type {String}
  5397. */
  5398. }, {
  5399. key: 'CLONE_LEFT',
  5400. get: function get() {
  5401. return 'left';
  5402. }
  5403. /**
  5404. * @type {String}
  5405. */
  5406. }, {
  5407. key: 'CLONE_TOP_LEFT_CORNER',
  5408. get: function get() {
  5409. return 'top_left_corner';
  5410. }
  5411. /**
  5412. * @type {String}
  5413. */
  5414. }, {
  5415. key: 'CLONE_BOTTOM_LEFT_CORNER',
  5416. get: function get() {
  5417. return 'bottom_left_corner';
  5418. }
  5419. /**
  5420. * @type {String}
  5421. */
  5422. }, {
  5423. key: 'CLONE_DEBUG',
  5424. get: function get() {
  5425. return 'debug';
  5426. }
  5427. /**
  5428. * List of all availables clone types
  5429. *
  5430. * @type {Array}
  5431. */
  5432. }, {
  5433. key: 'CLONE_TYPES',
  5434. get: function get() {
  5435. return [Overlay.CLONE_TOP, Overlay.CLONE_BOTTOM, Overlay.CLONE_LEFT, Overlay.CLONE_TOP_LEFT_CORNER, Overlay.CLONE_BOTTOM_LEFT_CORNER, Overlay.CLONE_DEBUG];
  5436. }
  5437. }]);
  5438. function Overlay(wotInstance) {
  5439. _classCallCheck(this, Overlay);
  5440. (0, _object.defineGetter)(this, 'wot', wotInstance, {
  5441. writable: false
  5442. });
  5443. // legacy support, deprecated in the future
  5444. this.instance = this.wot;
  5445. this.type = '';
  5446. this.mainTableScrollableElement = null;
  5447. this.TABLE = this.wot.wtTable.TABLE;
  5448. this.hider = this.wot.wtTable.hider;
  5449. this.spreader = this.wot.wtTable.spreader;
  5450. this.holder = this.wot.wtTable.holder;
  5451. this.wtRootElement = this.wot.wtTable.wtRootElement;
  5452. this.trimmingContainer = (0, _element.getTrimmingContainer)(this.hider.parentNode.parentNode);
  5453. this.areElementSizesAdjusted = false;
  5454. this.updateStateOfRendering();
  5455. }
  5456. /**
  5457. * Update internal state of object with an information about the need of full rendering of the overlay.
  5458. *
  5459. * @returns {Boolean} Returns `true` if the state has changed since the last check.
  5460. */
  5461. _createClass(Overlay, [{
  5462. key: 'updateStateOfRendering',
  5463. value: function updateStateOfRendering() {
  5464. var previousState = this.needFullRender;
  5465. this.needFullRender = this.shouldBeRendered();
  5466. var changed = previousState !== this.needFullRender;
  5467. if (changed && !this.needFullRender) {
  5468. this.reset();
  5469. }
  5470. return changed;
  5471. }
  5472. /**
  5473. * Checks if overlay should be fully rendered
  5474. *
  5475. * @returns {Boolean}
  5476. */
  5477. }, {
  5478. key: 'shouldBeRendered',
  5479. value: function shouldBeRendered() {
  5480. return true;
  5481. }
  5482. /**
  5483. * Update the trimming container.
  5484. */
  5485. }, {
  5486. key: 'updateTrimmingContainer',
  5487. value: function updateTrimmingContainer() {
  5488. this.trimmingContainer = (0, _element.getTrimmingContainer)(this.hider.parentNode.parentNode);
  5489. }
  5490. /**
  5491. * Update the main scrollable element.
  5492. */
  5493. }, {
  5494. key: 'updateMainScrollableElement',
  5495. value: function updateMainScrollableElement() {
  5496. this.mainTableScrollableElement = (0, _element.getScrollableElement)(this.wot.wtTable.TABLE);
  5497. }
  5498. /**
  5499. * Make a clone of table for overlay
  5500. *
  5501. * @param {String} direction Can be `Overlay.CLONE_TOP`, `Overlay.CLONE_LEFT`,
  5502. * `Overlay.CLONE_TOP_LEFT_CORNER`, `Overlay.CLONE_DEBUG`
  5503. * @returns {Walkontable}
  5504. */
  5505. }, {
  5506. key: 'makeClone',
  5507. value: function makeClone(direction) {
  5508. if (Overlay.CLONE_TYPES.indexOf(direction) === -1) {
  5509. throw new Error('Clone type "' + direction + '" is not supported.');
  5510. }
  5511. var clone = document.createElement('DIV');
  5512. var clonedTable = document.createElement('TABLE');
  5513. clone.className = 'ht_clone_' + direction + ' handsontable';
  5514. clone.style.position = 'absolute';
  5515. clone.style.top = 0;
  5516. clone.style.left = 0; //.right = 0 for RTL
  5517. clone.style.overflow = 'hidden';
  5518. clonedTable.className = this.wot.wtTable.TABLE.className;
  5519. clone.appendChild(clonedTable);
  5520. this.type = direction;
  5521. this.wot.wtTable.wtRootElement.parentNode.appendChild(clone);
  5522. var preventOverflow = this.wot.getSetting('preventOverflow');
  5523. if (preventOverflow === true || preventOverflow === 'horizontal' && this.type === Overlay.CLONE_TOP || preventOverflow === 'vertical' && this.type === Overlay.CLONE_LEFT) {
  5524. this.mainTableScrollableElement = window;
  5525. } else {
  5526. this.mainTableScrollableElement = (0, _element.getScrollableElement)(this.wot.wtTable.TABLE);
  5527. }
  5528. return new _core2.default({
  5529. cloneSource: this.wot,
  5530. cloneOverlay: this,
  5531. table: clonedTable
  5532. });
  5533. }
  5534. /**
  5535. * Refresh/Redraw overlay
  5536. *
  5537. * @param {Boolean} [fastDraw=false]
  5538. */
  5539. }, {
  5540. key: 'refresh',
  5541. value: function refresh() {
  5542. var fastDraw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5543. // When hot settings are changed we allow to refresh overlay once before blocking
  5544. var nextCycleRenderFlag = this.shouldBeRendered();
  5545. if (this.clone && (this.needFullRender || nextCycleRenderFlag)) {
  5546. this.clone.draw(fastDraw);
  5547. }
  5548. this.needFullRender = nextCycleRenderFlag;
  5549. }
  5550. /**
  5551. * Reset overlay styles to initial values.
  5552. */
  5553. }, {
  5554. key: 'reset',
  5555. value: function reset() {
  5556. if (!this.clone) {
  5557. return;
  5558. }
  5559. var holder = this.clone.wtTable.holder;
  5560. var hider = this.clone.wtTable.hider;
  5561. var holderStyle = holder.style;
  5562. var hidderStyle = hider.style;
  5563. var rootStyle = holder.parentNode.style;
  5564. (0, _array.arrayEach)([holderStyle, hidderStyle, rootStyle], function (style) {
  5565. style.width = '';
  5566. style.height = '';
  5567. });
  5568. }
  5569. /**
  5570. * Destroy overlay instance
  5571. */
  5572. }, {
  5573. key: 'destroy',
  5574. value: function destroy() {
  5575. new _eventManager2.default(this.clone).destroy();
  5576. }
  5577. }]);
  5578. return Overlay;
  5579. }();
  5580. exports.default = Overlay;
  5581. /***/ }),
  5582. /* 36 */
  5583. /***/ (function(module, exports, __webpack_require__) {
  5584. "use strict";
  5585. exports.__esModule = true;
  5586. exports.toUpperCaseFirst = toUpperCaseFirst;
  5587. exports.equalsIgnoreCase = equalsIgnoreCase;
  5588. exports.randomString = randomString;
  5589. exports.isPercentValue = isPercentValue;
  5590. exports.substitute = substitute;
  5591. exports.stripTags = stripTags;
  5592. var _mixed = __webpack_require__(16);
  5593. var _number = __webpack_require__(5);
  5594. /**
  5595. * Convert string to upper case first letter.
  5596. *
  5597. * @param {String} string String to convert.
  5598. * @returns {String}
  5599. */
  5600. function toUpperCaseFirst(string) {
  5601. return string[0].toUpperCase() + string.substr(1);
  5602. }
  5603. /**
  5604. * Compare strings case insensitively.
  5605. *
  5606. * @param {...String} strings Strings to compare.
  5607. * @returns {Boolean}
  5608. */
  5609. function equalsIgnoreCase() {
  5610. var unique = [];
  5611. for (var _len = arguments.length, strings = Array(_len), _key = 0; _key < _len; _key++) {
  5612. strings[_key] = arguments[_key];
  5613. }
  5614. var length = strings.length;
  5615. while (length--) {
  5616. var string = (0, _mixed.stringify)(strings[length]).toLowerCase();
  5617. if (unique.indexOf(string) === -1) {
  5618. unique.push(string);
  5619. }
  5620. }
  5621. return unique.length === 1;
  5622. }
  5623. /**
  5624. * Generates a random hex string. Used as namespace for Handsontable instance events.
  5625. *
  5626. * @return {String} Returns 16-long character random string (eq. `'92b1bfc74ec4'`).
  5627. */
  5628. function randomString() {
  5629. function s4() {
  5630. return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
  5631. }
  5632. return s4() + s4() + s4() + s4();
  5633. }
  5634. /**
  5635. * Checks if value is valid percent.
  5636. *
  5637. * @param {String} value
  5638. * @returns {Boolean}
  5639. */
  5640. function isPercentValue(value) {
  5641. return (/^([0-9][0-9]?%$)|(^100%$)/.test(value)
  5642. );
  5643. }
  5644. /**
  5645. * Substitute strings placed beetwen square brackets into value defined in `variables` object. String names defined in
  5646. * square brackets must be the same as property name of `variables` object.
  5647. *
  5648. * @param {String} template Template string.
  5649. * @param {Object} variables Object which contains all available values which can be injected into template.
  5650. * @returns {String}
  5651. */
  5652. function substitute(template) {
  5653. var variables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  5654. return ('' + template).replace(/(?:\\)?\[([^[\]]+)]/g, function (match, name) {
  5655. if (match.charAt(0) === '\\') {
  5656. return match.substr(1, match.length - 1);
  5657. }
  5658. return variables[name] === void 0 ? '' : variables[name];
  5659. });
  5660. }
  5661. var STRIP_TAGS_REGEX = /<\/?\w+\/?>|<\w+[\s|/][^>]*>/gi;
  5662. /**
  5663. * Strip any HTML tag from the string.
  5664. *
  5665. * @param {String} string String to cut HTML from.
  5666. * @return {String}
  5667. */
  5668. function stripTags(string) {
  5669. string += '';
  5670. return string.replace(STRIP_TAGS_REGEX, '');
  5671. }
  5672. /***/ }),
  5673. /* 37 */
  5674. /***/ (function(module, exports, __webpack_require__) {
  5675. // 19.1.2.14 / 15.2.3.14 Object.keys(O)
  5676. var $keys = __webpack_require__(99);
  5677. var enumBugKeys = __webpack_require__(78);
  5678. module.exports = Object.keys || function keys(O) {
  5679. return $keys(O, enumBugKeys);
  5680. };
  5681. /***/ }),
  5682. /* 38 */
  5683. /***/ (function(module, exports) {
  5684. // 7.2.1 RequireObjectCoercible(argument)
  5685. module.exports = function (it) {
  5686. if (it == undefined) throw TypeError("Can't call method on " + it);
  5687. return it;
  5688. };
  5689. /***/ }),
  5690. /* 39 */
  5691. /***/ (function(module, exports, __webpack_require__) {
  5692. "use strict";
  5693. exports.__esModule = true;
  5694. exports.default = staticRegister;
  5695. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  5696. var collection = exports.collection = new Map();
  5697. function staticRegister() {
  5698. var namespace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'common';
  5699. if (!collection.has(namespace)) {
  5700. collection.set(namespace, new Map());
  5701. }
  5702. var subCollection = collection.get(namespace);
  5703. /**
  5704. * Register an item to the collection. If the item under the same was exist earlier then this item will be replaced with new one.
  5705. *
  5706. * @param {String} name Identification of the item.
  5707. * @param {*} item Item to save in the collection.
  5708. */
  5709. function register(name, item) {
  5710. subCollection.set(name, item);
  5711. }
  5712. /**
  5713. * Retrieve the item from the collection.
  5714. *
  5715. * @param {String} name Identification of the item.
  5716. * @returns {*} Returns item which was saved in the collection.
  5717. */
  5718. function getItem(name) {
  5719. return subCollection.get(name);
  5720. }
  5721. /**
  5722. * Check if item under specyfied name is exists.
  5723. *
  5724. * @param {String} name Identification of the item.
  5725. * @returns {Boolean} Returns `true` or `false` depends on if element exists in the collection.
  5726. */
  5727. function hasItem(name) {
  5728. return subCollection.has(name);
  5729. }
  5730. /**
  5731. * Retrieve list of names registered from the collection.
  5732. *
  5733. * @returns {Array} Returns an array of strings with all names under which objects are stored.
  5734. */
  5735. function getNames() {
  5736. return [].concat(_toConsumableArray(subCollection.keys()));
  5737. }
  5738. /**
  5739. * Retrieve all registered values from the collection.
  5740. *
  5741. * @returns {Array} Returns an array with all values stored in the collection.
  5742. */
  5743. function getValues() {
  5744. return [].concat(_toConsumableArray(subCollection.values()));
  5745. }
  5746. return {
  5747. register: register,
  5748. getItem: getItem,
  5749. hasItem: hasItem,
  5750. getNames: getNames,
  5751. getValues: getValues
  5752. };
  5753. }
  5754. /***/ }),
  5755. /* 40 */
  5756. /***/ (function(module, exports, __webpack_require__) {
  5757. "use strict";
  5758. exports.__esModule = true;
  5759. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  5760. exports.requestAnimationFrame = requestAnimationFrame;
  5761. exports.cancelAnimationFrame = cancelAnimationFrame;
  5762. exports.isTouchSupported = isTouchSupported;
  5763. exports.isWebComponentSupportedNatively = isWebComponentSupportedNatively;
  5764. exports.hasCaptionProblem = hasCaptionProblem;
  5765. exports.getComparisonFunction = getComparisonFunction;
  5766. // https://gist.github.com/paulirish/1579671
  5767. var lastTime = 0;
  5768. var vendors = ['ms', 'moz', 'webkit', 'o'];
  5769. var _requestAnimationFrame = window.requestAnimationFrame;
  5770. var _cancelAnimationFrame = window.cancelAnimationFrame;
  5771. for (var x = 0; x < vendors.length && !_requestAnimationFrame; ++x) {
  5772. _requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
  5773. _cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
  5774. }
  5775. if (!_requestAnimationFrame) {
  5776. _requestAnimationFrame = function _requestAnimationFrame(callback) {
  5777. var currTime = new Date().getTime();
  5778. var timeToCall = Math.max(0, 16 - (currTime - lastTime));
  5779. var id = window.setTimeout(function () {
  5780. callback(currTime + timeToCall);
  5781. }, timeToCall);
  5782. lastTime = currTime + timeToCall;
  5783. return id;
  5784. };
  5785. }
  5786. if (!_cancelAnimationFrame) {
  5787. _cancelAnimationFrame = function _cancelAnimationFrame(id) {
  5788. clearTimeout(id);
  5789. };
  5790. }
  5791. /**
  5792. * Polyfill for requestAnimationFrame
  5793. *
  5794. * @param {Function} callback
  5795. * @returns {Number}
  5796. */
  5797. function requestAnimationFrame(callback) {
  5798. return _requestAnimationFrame.call(window, callback);
  5799. }
  5800. /**
  5801. * Polyfill for cancelAnimationFrame
  5802. *
  5803. * @param {Number} id
  5804. */
  5805. function cancelAnimationFrame(id) {
  5806. _cancelAnimationFrame.call(window, id);
  5807. }
  5808. function isTouchSupported() {
  5809. return 'ontouchstart' in window;
  5810. }
  5811. /**
  5812. * Checks if browser is support web components natively
  5813. *
  5814. * @returns {Boolean}
  5815. */
  5816. function isWebComponentSupportedNatively() {
  5817. var test = document.createElement('div');
  5818. return !!(test.createShadowRoot && test.createShadowRoot.toString().match(/\[native code\]/));
  5819. }
  5820. var _hasCaptionProblem;
  5821. function detectCaptionProblem() {
  5822. var TABLE = document.createElement('TABLE');
  5823. TABLE.style.borderSpacing = 0;
  5824. TABLE.style.borderWidth = 0;
  5825. TABLE.style.padding = 0;
  5826. var TBODY = document.createElement('TBODY');
  5827. TABLE.appendChild(TBODY);
  5828. TBODY.appendChild(document.createElement('TR'));
  5829. TBODY.firstChild.appendChild(document.createElement('TD'));
  5830. TBODY.firstChild.firstChild.innerHTML = '<tr><td>t<br>t</td></tr>';
  5831. var CAPTION = document.createElement('CAPTION');
  5832. CAPTION.innerHTML = 'c<br>c<br>c<br>c';
  5833. CAPTION.style.padding = 0;
  5834. CAPTION.style.margin = 0;
  5835. TABLE.insertBefore(CAPTION, TBODY);
  5836. document.body.appendChild(TABLE);
  5837. _hasCaptionProblem = TABLE.offsetHeight < 2 * TABLE.lastChild.offsetHeight; // boolean
  5838. document.body.removeChild(TABLE);
  5839. }
  5840. function hasCaptionProblem() {
  5841. if (_hasCaptionProblem === void 0) {
  5842. detectCaptionProblem();
  5843. }
  5844. return _hasCaptionProblem;
  5845. }
  5846. var comparisonFunction = void 0;
  5847. /**
  5848. * Get string comparison function for sorting purposes. It supports multilingual string comparison base on Internationalization API.
  5849. *
  5850. * @param {String} [language]
  5851. * @param {Object} [options]
  5852. * @returns {*}
  5853. */
  5854. function getComparisonFunction(language) {
  5855. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  5856. if (comparisonFunction) {
  5857. return comparisonFunction;
  5858. }
  5859. if ((typeof Intl === 'undefined' ? 'undefined' : _typeof(Intl)) === 'object') {
  5860. comparisonFunction = new Intl.Collator(language, options).compare;
  5861. } else if (typeof String.prototype.localeCompare === 'function') {
  5862. comparisonFunction = function comparisonFunction(a, b) {
  5863. return ('' + a).localeCompare(b);
  5864. };
  5865. } else {
  5866. comparisonFunction = function comparisonFunction(a, b) {
  5867. if (a === b) {
  5868. return 0;
  5869. }
  5870. return a > b ? -1 : 1;
  5871. };
  5872. }
  5873. return comparisonFunction;
  5874. }
  5875. /***/ }),
  5876. /* 41 */
  5877. /***/ (function(module, exports, __webpack_require__) {
  5878. /* WEBPACK VAR INJECTION */(function(module) {var require;//! moment.js
  5879. //! version : 2.20.1
  5880. //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
  5881. //! license : MIT
  5882. //! momentjs.com
  5883. ;(function (global, factory) {
  5884. true ? module.exports = factory() :
  5885. typeof define === 'function' && define.amd ? define(factory) :
  5886. global.moment = factory()
  5887. }(this, (function () { 'use strict';
  5888. var hookCallback;
  5889. function hooks () {
  5890. return hookCallback.apply(null, arguments);
  5891. }
  5892. // This is done to register the method called with moment()
  5893. // without creating circular dependencies.
  5894. function setHookCallback (callback) {
  5895. hookCallback = callback;
  5896. }
  5897. function isArray(input) {
  5898. return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
  5899. }
  5900. function isObject(input) {
  5901. // IE8 will treat undefined and null as object if it wasn't for
  5902. // input != null
  5903. return input != null && Object.prototype.toString.call(input) === '[object Object]';
  5904. }
  5905. function isObjectEmpty(obj) {
  5906. if (Object.getOwnPropertyNames) {
  5907. return (Object.getOwnPropertyNames(obj).length === 0);
  5908. } else {
  5909. var k;
  5910. for (k in obj) {
  5911. if (obj.hasOwnProperty(k)) {
  5912. return false;
  5913. }
  5914. }
  5915. return true;
  5916. }
  5917. }
  5918. function isUndefined(input) {
  5919. return input === void 0;
  5920. }
  5921. function isNumber(input) {
  5922. return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]';
  5923. }
  5924. function isDate(input) {
  5925. return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
  5926. }
  5927. function map(arr, fn) {
  5928. var res = [], i;
  5929. for (i = 0; i < arr.length; ++i) {
  5930. res.push(fn(arr[i], i));
  5931. }
  5932. return res;
  5933. }
  5934. function hasOwnProp(a, b) {
  5935. return Object.prototype.hasOwnProperty.call(a, b);
  5936. }
  5937. function extend(a, b) {
  5938. for (var i in b) {
  5939. if (hasOwnProp(b, i)) {
  5940. a[i] = b[i];
  5941. }
  5942. }
  5943. if (hasOwnProp(b, 'toString')) {
  5944. a.toString = b.toString;
  5945. }
  5946. if (hasOwnProp(b, 'valueOf')) {
  5947. a.valueOf = b.valueOf;
  5948. }
  5949. return a;
  5950. }
  5951. function createUTC (input, format, locale, strict) {
  5952. return createLocalOrUTC(input, format, locale, strict, true).utc();
  5953. }
  5954. function defaultParsingFlags() {
  5955. // We need to deep clone this object.
  5956. return {
  5957. empty : false,
  5958. unusedTokens : [],
  5959. unusedInput : [],
  5960. overflow : -2,
  5961. charsLeftOver : 0,
  5962. nullInput : false,
  5963. invalidMonth : null,
  5964. invalidFormat : false,
  5965. userInvalidated : false,
  5966. iso : false,
  5967. parsedDateParts : [],
  5968. meridiem : null,
  5969. rfc2822 : false,
  5970. weekdayMismatch : false
  5971. };
  5972. }
  5973. function getParsingFlags(m) {
  5974. if (m._pf == null) {
  5975. m._pf = defaultParsingFlags();
  5976. }
  5977. return m._pf;
  5978. }
  5979. var some;
  5980. if (Array.prototype.some) {
  5981. some = Array.prototype.some;
  5982. } else {
  5983. some = function (fun) {
  5984. var t = Object(this);
  5985. var len = t.length >>> 0;
  5986. for (var i = 0; i < len; i++) {
  5987. if (i in t && fun.call(this, t[i], i, t)) {
  5988. return true;
  5989. }
  5990. }
  5991. return false;
  5992. };
  5993. }
  5994. function isValid(m) {
  5995. if (m._isValid == null) {
  5996. var flags = getParsingFlags(m);
  5997. var parsedParts = some.call(flags.parsedDateParts, function (i) {
  5998. return i != null;
  5999. });
  6000. var isNowValid = !isNaN(m._d.getTime()) &&
  6001. flags.overflow < 0 &&
  6002. !flags.empty &&
  6003. !flags.invalidMonth &&
  6004. !flags.invalidWeekday &&
  6005. !flags.weekdayMismatch &&
  6006. !flags.nullInput &&
  6007. !flags.invalidFormat &&
  6008. !flags.userInvalidated &&
  6009. (!flags.meridiem || (flags.meridiem && parsedParts));
  6010. if (m._strict) {
  6011. isNowValid = isNowValid &&
  6012. flags.charsLeftOver === 0 &&
  6013. flags.unusedTokens.length === 0 &&
  6014. flags.bigHour === undefined;
  6015. }
  6016. if (Object.isFrozen == null || !Object.isFrozen(m)) {
  6017. m._isValid = isNowValid;
  6018. }
  6019. else {
  6020. return isNowValid;
  6021. }
  6022. }
  6023. return m._isValid;
  6024. }
  6025. function createInvalid (flags) {
  6026. var m = createUTC(NaN);
  6027. if (flags != null) {
  6028. extend(getParsingFlags(m), flags);
  6029. }
  6030. else {
  6031. getParsingFlags(m).userInvalidated = true;
  6032. }
  6033. return m;
  6034. }
  6035. // Plugins that add properties should also add the key here (null value),
  6036. // so we can properly clone ourselves.
  6037. var momentProperties = hooks.momentProperties = [];
  6038. function copyConfig(to, from) {
  6039. var i, prop, val;
  6040. if (!isUndefined(from._isAMomentObject)) {
  6041. to._isAMomentObject = from._isAMomentObject;
  6042. }
  6043. if (!isUndefined(from._i)) {
  6044. to._i = from._i;
  6045. }
  6046. if (!isUndefined(from._f)) {
  6047. to._f = from._f;
  6048. }
  6049. if (!isUndefined(from._l)) {
  6050. to._l = from._l;
  6051. }
  6052. if (!isUndefined(from._strict)) {
  6053. to._strict = from._strict;
  6054. }
  6055. if (!isUndefined(from._tzm)) {
  6056. to._tzm = from._tzm;
  6057. }
  6058. if (!isUndefined(from._isUTC)) {
  6059. to._isUTC = from._isUTC;
  6060. }
  6061. if (!isUndefined(from._offset)) {
  6062. to._offset = from._offset;
  6063. }
  6064. if (!isUndefined(from._pf)) {
  6065. to._pf = getParsingFlags(from);
  6066. }
  6067. if (!isUndefined(from._locale)) {
  6068. to._locale = from._locale;
  6069. }
  6070. if (momentProperties.length > 0) {
  6071. for (i = 0; i < momentProperties.length; i++) {
  6072. prop = momentProperties[i];
  6073. val = from[prop];
  6074. if (!isUndefined(val)) {
  6075. to[prop] = val;
  6076. }
  6077. }
  6078. }
  6079. return to;
  6080. }
  6081. var updateInProgress = false;
  6082. // Moment prototype object
  6083. function Moment(config) {
  6084. copyConfig(this, config);
  6085. this._d = new Date(config._d != null ? config._d.getTime() : NaN);
  6086. if (!this.isValid()) {
  6087. this._d = new Date(NaN);
  6088. }
  6089. // Prevent infinite loop in case updateOffset creates new moment
  6090. // objects.
  6091. if (updateInProgress === false) {
  6092. updateInProgress = true;
  6093. hooks.updateOffset(this);
  6094. updateInProgress = false;
  6095. }
  6096. }
  6097. function isMoment (obj) {
  6098. return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
  6099. }
  6100. function absFloor (number) {
  6101. if (number < 0) {
  6102. // -0 -> 0
  6103. return Math.ceil(number) || 0;
  6104. } else {
  6105. return Math.floor(number);
  6106. }
  6107. }
  6108. function toInt(argumentForCoercion) {
  6109. var coercedNumber = +argumentForCoercion,
  6110. value = 0;
  6111. if (coercedNumber !== 0 && isFinite(coercedNumber)) {
  6112. value = absFloor(coercedNumber);
  6113. }
  6114. return value;
  6115. }
  6116. // compare two arrays, return the number of differences
  6117. function compareArrays(array1, array2, dontConvert) {
  6118. var len = Math.min(array1.length, array2.length),
  6119. lengthDiff = Math.abs(array1.length - array2.length),
  6120. diffs = 0,
  6121. i;
  6122. for (i = 0; i < len; i++) {
  6123. if ((dontConvert && array1[i] !== array2[i]) ||
  6124. (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
  6125. diffs++;
  6126. }
  6127. }
  6128. return diffs + lengthDiff;
  6129. }
  6130. function warn(msg) {
  6131. if (hooks.suppressDeprecationWarnings === false &&
  6132. (typeof console !== 'undefined') && console.warn) {
  6133. console.warn('Deprecation warning: ' + msg);
  6134. }
  6135. }
  6136. function deprecate(msg, fn) {
  6137. var firstTime = true;
  6138. return extend(function () {
  6139. if (hooks.deprecationHandler != null) {
  6140. hooks.deprecationHandler(null, msg);
  6141. }
  6142. if (firstTime) {
  6143. var args = [];
  6144. var arg;
  6145. for (var i = 0; i < arguments.length; i++) {
  6146. arg = '';
  6147. if (typeof arguments[i] === 'object') {
  6148. arg += '\n[' + i + '] ';
  6149. for (var key in arguments[0]) {
  6150. arg += key + ': ' + arguments[0][key] + ', ';
  6151. }
  6152. arg = arg.slice(0, -2); // Remove trailing comma and space
  6153. } else {
  6154. arg = arguments[i];
  6155. }
  6156. args.push(arg);
  6157. }
  6158. warn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + (new Error()).stack);
  6159. firstTime = false;
  6160. }
  6161. return fn.apply(this, arguments);
  6162. }, fn);
  6163. }
  6164. var deprecations = {};
  6165. function deprecateSimple(name, msg) {
  6166. if (hooks.deprecationHandler != null) {
  6167. hooks.deprecationHandler(name, msg);
  6168. }
  6169. if (!deprecations[name]) {
  6170. warn(msg);
  6171. deprecations[name] = true;
  6172. }
  6173. }
  6174. hooks.suppressDeprecationWarnings = false;
  6175. hooks.deprecationHandler = null;
  6176. function isFunction(input) {
  6177. return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
  6178. }
  6179. function set (config) {
  6180. var prop, i;
  6181. for (i in config) {
  6182. prop = config[i];
  6183. if (isFunction(prop)) {
  6184. this[i] = prop;
  6185. } else {
  6186. this['_' + i] = prop;
  6187. }
  6188. }
  6189. this._config = config;
  6190. // Lenient ordinal parsing accepts just a number in addition to
  6191. // number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
  6192. // TODO: Remove "ordinalParse" fallback in next major release.
  6193. this._dayOfMonthOrdinalParseLenient = new RegExp(
  6194. (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
  6195. '|' + (/\d{1,2}/).source);
  6196. }
  6197. function mergeConfigs(parentConfig, childConfig) {
  6198. var res = extend({}, parentConfig), prop;
  6199. for (prop in childConfig) {
  6200. if (hasOwnProp(childConfig, prop)) {
  6201. if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
  6202. res[prop] = {};
  6203. extend(res[prop], parentConfig[prop]);
  6204. extend(res[prop], childConfig[prop]);
  6205. } else if (childConfig[prop] != null) {
  6206. res[prop] = childConfig[prop];
  6207. } else {
  6208. delete res[prop];
  6209. }
  6210. }
  6211. }
  6212. for (prop in parentConfig) {
  6213. if (hasOwnProp(parentConfig, prop) &&
  6214. !hasOwnProp(childConfig, prop) &&
  6215. isObject(parentConfig[prop])) {
  6216. // make sure changes to properties don't modify parent config
  6217. res[prop] = extend({}, res[prop]);
  6218. }
  6219. }
  6220. return res;
  6221. }
  6222. function Locale(config) {
  6223. if (config != null) {
  6224. this.set(config);
  6225. }
  6226. }
  6227. var keys;
  6228. if (Object.keys) {
  6229. keys = Object.keys;
  6230. } else {
  6231. keys = function (obj) {
  6232. var i, res = [];
  6233. for (i in obj) {
  6234. if (hasOwnProp(obj, i)) {
  6235. res.push(i);
  6236. }
  6237. }
  6238. return res;
  6239. };
  6240. }
  6241. var defaultCalendar = {
  6242. sameDay : '[Today at] LT',
  6243. nextDay : '[Tomorrow at] LT',
  6244. nextWeek : 'dddd [at] LT',
  6245. lastDay : '[Yesterday at] LT',
  6246. lastWeek : '[Last] dddd [at] LT',
  6247. sameElse : 'L'
  6248. };
  6249. function calendar (key, mom, now) {
  6250. var output = this._calendar[key] || this._calendar['sameElse'];
  6251. return isFunction(output) ? output.call(mom, now) : output;
  6252. }
  6253. var defaultLongDateFormat = {
  6254. LTS : 'h:mm:ss A',
  6255. LT : 'h:mm A',
  6256. L : 'MM/DD/YYYY',
  6257. LL : 'MMMM D, YYYY',
  6258. LLL : 'MMMM D, YYYY h:mm A',
  6259. LLLL : 'dddd, MMMM D, YYYY h:mm A'
  6260. };
  6261. function longDateFormat (key) {
  6262. var format = this._longDateFormat[key],
  6263. formatUpper = this._longDateFormat[key.toUpperCase()];
  6264. if (format || !formatUpper) {
  6265. return format;
  6266. }
  6267. this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
  6268. return val.slice(1);
  6269. });
  6270. return this._longDateFormat[key];
  6271. }
  6272. var defaultInvalidDate = 'Invalid date';
  6273. function invalidDate () {
  6274. return this._invalidDate;
  6275. }
  6276. var defaultOrdinal = '%d';
  6277. var defaultDayOfMonthOrdinalParse = /\d{1,2}/;
  6278. function ordinal (number) {
  6279. return this._ordinal.replace('%d', number);
  6280. }
  6281. var defaultRelativeTime = {
  6282. future : 'in %s',
  6283. past : '%s ago',
  6284. s : 'a few seconds',
  6285. ss : '%d seconds',
  6286. m : 'a minute',
  6287. mm : '%d minutes',
  6288. h : 'an hour',
  6289. hh : '%d hours',
  6290. d : 'a day',
  6291. dd : '%d days',
  6292. M : 'a month',
  6293. MM : '%d months',
  6294. y : 'a year',
  6295. yy : '%d years'
  6296. };
  6297. function relativeTime (number, withoutSuffix, string, isFuture) {
  6298. var output = this._relativeTime[string];
  6299. return (isFunction(output)) ?
  6300. output(number, withoutSuffix, string, isFuture) :
  6301. output.replace(/%d/i, number);
  6302. }
  6303. function pastFuture (diff, output) {
  6304. var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
  6305. return isFunction(format) ? format(output) : format.replace(/%s/i, output);
  6306. }
  6307. var aliases = {};
  6308. function addUnitAlias (unit, shorthand) {
  6309. var lowerCase = unit.toLowerCase();
  6310. aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
  6311. }
  6312. function normalizeUnits(units) {
  6313. return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
  6314. }
  6315. function normalizeObjectUnits(inputObject) {
  6316. var normalizedInput = {},
  6317. normalizedProp,
  6318. prop;
  6319. for (prop in inputObject) {
  6320. if (hasOwnProp(inputObject, prop)) {
  6321. normalizedProp = normalizeUnits(prop);
  6322. if (normalizedProp) {
  6323. normalizedInput[normalizedProp] = inputObject[prop];
  6324. }
  6325. }
  6326. }
  6327. return normalizedInput;
  6328. }
  6329. var priorities = {};
  6330. function addUnitPriority(unit, priority) {
  6331. priorities[unit] = priority;
  6332. }
  6333. function getPrioritizedUnits(unitsObj) {
  6334. var units = [];
  6335. for (var u in unitsObj) {
  6336. units.push({unit: u, priority: priorities[u]});
  6337. }
  6338. units.sort(function (a, b) {
  6339. return a.priority - b.priority;
  6340. });
  6341. return units;
  6342. }
  6343. function zeroFill(number, targetLength, forceSign) {
  6344. var absNumber = '' + Math.abs(number),
  6345. zerosToFill = targetLength - absNumber.length,
  6346. sign = number >= 0;
  6347. return (sign ? (forceSign ? '+' : '') : '-') +
  6348. Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
  6349. }
  6350. var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
  6351. var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
  6352. var formatFunctions = {};
  6353. var formatTokenFunctions = {};
  6354. // token: 'M'
  6355. // padded: ['MM', 2]
  6356. // ordinal: 'Mo'
  6357. // callback: function () { this.month() + 1 }
  6358. function addFormatToken (token, padded, ordinal, callback) {
  6359. var func = callback;
  6360. if (typeof callback === 'string') {
  6361. func = function () {
  6362. return this[callback]();
  6363. };
  6364. }
  6365. if (token) {
  6366. formatTokenFunctions[token] = func;
  6367. }
  6368. if (padded) {
  6369. formatTokenFunctions[padded[0]] = function () {
  6370. return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
  6371. };
  6372. }
  6373. if (ordinal) {
  6374. formatTokenFunctions[ordinal] = function () {
  6375. return this.localeData().ordinal(func.apply(this, arguments), token);
  6376. };
  6377. }
  6378. }
  6379. function removeFormattingTokens(input) {
  6380. if (input.match(/\[[\s\S]/)) {
  6381. return input.replace(/^\[|\]$/g, '');
  6382. }
  6383. return input.replace(/\\/g, '');
  6384. }
  6385. function makeFormatFunction(format) {
  6386. var array = format.match(formattingTokens), i, length;
  6387. for (i = 0, length = array.length; i < length; i++) {
  6388. if (formatTokenFunctions[array[i]]) {
  6389. array[i] = formatTokenFunctions[array[i]];
  6390. } else {
  6391. array[i] = removeFormattingTokens(array[i]);
  6392. }
  6393. }
  6394. return function (mom) {
  6395. var output = '', i;
  6396. for (i = 0; i < length; i++) {
  6397. output += isFunction(array[i]) ? array[i].call(mom, format) : array[i];
  6398. }
  6399. return output;
  6400. };
  6401. }
  6402. // format date using native date object
  6403. function formatMoment(m, format) {
  6404. if (!m.isValid()) {
  6405. return m.localeData().invalidDate();
  6406. }
  6407. format = expandFormat(format, m.localeData());
  6408. formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
  6409. return formatFunctions[format](m);
  6410. }
  6411. function expandFormat(format, locale) {
  6412. var i = 5;
  6413. function replaceLongDateFormatTokens(input) {
  6414. return locale.longDateFormat(input) || input;
  6415. }
  6416. localFormattingTokens.lastIndex = 0;
  6417. while (i >= 0 && localFormattingTokens.test(format)) {
  6418. format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
  6419. localFormattingTokens.lastIndex = 0;
  6420. i -= 1;
  6421. }
  6422. return format;
  6423. }
  6424. var match1 = /\d/; // 0 - 9
  6425. var match2 = /\d\d/; // 00 - 99
  6426. var match3 = /\d{3}/; // 000 - 999
  6427. var match4 = /\d{4}/; // 0000 - 9999
  6428. var match6 = /[+-]?\d{6}/; // -999999 - 999999
  6429. var match1to2 = /\d\d?/; // 0 - 99
  6430. var match3to4 = /\d\d\d\d?/; // 999 - 9999
  6431. var match5to6 = /\d\d\d\d\d\d?/; // 99999 - 999999
  6432. var match1to3 = /\d{1,3}/; // 0 - 999
  6433. var match1to4 = /\d{1,4}/; // 0 - 9999
  6434. var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999
  6435. var matchUnsigned = /\d+/; // 0 - inf
  6436. var matchSigned = /[+-]?\d+/; // -inf - inf
  6437. var matchOffset = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z
  6438. var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi; // +00 -00 +00:00 -00:00 +0000 -0000 or Z
  6439. var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123
  6440. // any word (or two) characters or numbers including two/three word month in arabic.
  6441. // includes scottish gaelic two word and hyphenated months
  6442. var matchWord = /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i;
  6443. var regexes = {};
  6444. function addRegexToken (token, regex, strictRegex) {
  6445. regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) {
  6446. return (isStrict && strictRegex) ? strictRegex : regex;
  6447. };
  6448. }
  6449. function getParseRegexForToken (token, config) {
  6450. if (!hasOwnProp(regexes, token)) {
  6451. return new RegExp(unescapeFormat(token));
  6452. }
  6453. return regexes[token](config._strict, config._locale);
  6454. }
  6455. // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
  6456. function unescapeFormat(s) {
  6457. return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
  6458. return p1 || p2 || p3 || p4;
  6459. }));
  6460. }
  6461. function regexEscape(s) {
  6462. return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
  6463. }
  6464. var tokens = {};
  6465. function addParseToken (token, callback) {
  6466. var i, func = callback;
  6467. if (typeof token === 'string') {
  6468. token = [token];
  6469. }
  6470. if (isNumber(callback)) {
  6471. func = function (input, array) {
  6472. array[callback] = toInt(input);
  6473. };
  6474. }
  6475. for (i = 0; i < token.length; i++) {
  6476. tokens[token[i]] = func;
  6477. }
  6478. }
  6479. function addWeekParseToken (token, callback) {
  6480. addParseToken(token, function (input, array, config, token) {
  6481. config._w = config._w || {};
  6482. callback(input, config._w, config, token);
  6483. });
  6484. }
  6485. function addTimeToArrayFromToken(token, input, config) {
  6486. if (input != null && hasOwnProp(tokens, token)) {
  6487. tokens[token](input, config._a, config, token);
  6488. }
  6489. }
  6490. var YEAR = 0;
  6491. var MONTH = 1;
  6492. var DATE = 2;
  6493. var HOUR = 3;
  6494. var MINUTE = 4;
  6495. var SECOND = 5;
  6496. var MILLISECOND = 6;
  6497. var WEEK = 7;
  6498. var WEEKDAY = 8;
  6499. // FORMATTING
  6500. addFormatToken('Y', 0, 0, function () {
  6501. var y = this.year();
  6502. return y <= 9999 ? '' + y : '+' + y;
  6503. });
  6504. addFormatToken(0, ['YY', 2], 0, function () {
  6505. return this.year() % 100;
  6506. });
  6507. addFormatToken(0, ['YYYY', 4], 0, 'year');
  6508. addFormatToken(0, ['YYYYY', 5], 0, 'year');
  6509. addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
  6510. // ALIASES
  6511. addUnitAlias('year', 'y');
  6512. // PRIORITIES
  6513. addUnitPriority('year', 1);
  6514. // PARSING
  6515. addRegexToken('Y', matchSigned);
  6516. addRegexToken('YY', match1to2, match2);
  6517. addRegexToken('YYYY', match1to4, match4);
  6518. addRegexToken('YYYYY', match1to6, match6);
  6519. addRegexToken('YYYYYY', match1to6, match6);
  6520. addParseToken(['YYYYY', 'YYYYYY'], YEAR);
  6521. addParseToken('YYYY', function (input, array) {
  6522. array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
  6523. });
  6524. addParseToken('YY', function (input, array) {
  6525. array[YEAR] = hooks.parseTwoDigitYear(input);
  6526. });
  6527. addParseToken('Y', function (input, array) {
  6528. array[YEAR] = parseInt(input, 10);
  6529. });
  6530. // HELPERS
  6531. function daysInYear(year) {
  6532. return isLeapYear(year) ? 366 : 365;
  6533. }
  6534. function isLeapYear(year) {
  6535. return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
  6536. }
  6537. // HOOKS
  6538. hooks.parseTwoDigitYear = function (input) {
  6539. return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
  6540. };
  6541. // MOMENTS
  6542. var getSetYear = makeGetSet('FullYear', true);
  6543. function getIsLeapYear () {
  6544. return isLeapYear(this.year());
  6545. }
  6546. function makeGetSet (unit, keepTime) {
  6547. return function (value) {
  6548. if (value != null) {
  6549. set$1(this, unit, value);
  6550. hooks.updateOffset(this, keepTime);
  6551. return this;
  6552. } else {
  6553. return get(this, unit);
  6554. }
  6555. };
  6556. }
  6557. function get (mom, unit) {
  6558. return mom.isValid() ?
  6559. mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() : NaN;
  6560. }
  6561. function set$1 (mom, unit, value) {
  6562. if (mom.isValid() && !isNaN(value)) {
  6563. if (unit === 'FullYear' && isLeapYear(mom.year()) && mom.month() === 1 && mom.date() === 29) {
  6564. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value, mom.month(), daysInMonth(value, mom.month()));
  6565. }
  6566. else {
  6567. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
  6568. }
  6569. }
  6570. }
  6571. // MOMENTS
  6572. function stringGet (units) {
  6573. units = normalizeUnits(units);
  6574. if (isFunction(this[units])) {
  6575. return this[units]();
  6576. }
  6577. return this;
  6578. }
  6579. function stringSet (units, value) {
  6580. if (typeof units === 'object') {
  6581. units = normalizeObjectUnits(units);
  6582. var prioritized = getPrioritizedUnits(units);
  6583. for (var i = 0; i < prioritized.length; i++) {
  6584. this[prioritized[i].unit](units[prioritized[i].unit]);
  6585. }
  6586. } else {
  6587. units = normalizeUnits(units);
  6588. if (isFunction(this[units])) {
  6589. return this[units](value);
  6590. }
  6591. }
  6592. return this;
  6593. }
  6594. function mod(n, x) {
  6595. return ((n % x) + x) % x;
  6596. }
  6597. var indexOf;
  6598. if (Array.prototype.indexOf) {
  6599. indexOf = Array.prototype.indexOf;
  6600. } else {
  6601. indexOf = function (o) {
  6602. // I know
  6603. var i;
  6604. for (i = 0; i < this.length; ++i) {
  6605. if (this[i] === o) {
  6606. return i;
  6607. }
  6608. }
  6609. return -1;
  6610. };
  6611. }
  6612. function daysInMonth(year, month) {
  6613. if (isNaN(year) || isNaN(month)) {
  6614. return NaN;
  6615. }
  6616. var modMonth = mod(month, 12);
  6617. year += (month - modMonth) / 12;
  6618. return modMonth === 1 ? (isLeapYear(year) ? 29 : 28) : (31 - modMonth % 7 % 2);
  6619. }
  6620. // FORMATTING
  6621. addFormatToken('M', ['MM', 2], 'Mo', function () {
  6622. return this.month() + 1;
  6623. });
  6624. addFormatToken('MMM', 0, 0, function (format) {
  6625. return this.localeData().monthsShort(this, format);
  6626. });
  6627. addFormatToken('MMMM', 0, 0, function (format) {
  6628. return this.localeData().months(this, format);
  6629. });
  6630. // ALIASES
  6631. addUnitAlias('month', 'M');
  6632. // PRIORITY
  6633. addUnitPriority('month', 8);
  6634. // PARSING
  6635. addRegexToken('M', match1to2);
  6636. addRegexToken('MM', match1to2, match2);
  6637. addRegexToken('MMM', function (isStrict, locale) {
  6638. return locale.monthsShortRegex(isStrict);
  6639. });
  6640. addRegexToken('MMMM', function (isStrict, locale) {
  6641. return locale.monthsRegex(isStrict);
  6642. });
  6643. addParseToken(['M', 'MM'], function (input, array) {
  6644. array[MONTH] = toInt(input) - 1;
  6645. });
  6646. addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
  6647. var month = config._locale.monthsParse(input, token, config._strict);
  6648. // if we didn't find a month name, mark the date as invalid.
  6649. if (month != null) {
  6650. array[MONTH] = month;
  6651. } else {
  6652. getParsingFlags(config).invalidMonth = input;
  6653. }
  6654. });
  6655. // LOCALES
  6656. var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/;
  6657. var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
  6658. function localeMonths (m, format) {
  6659. if (!m) {
  6660. return isArray(this._months) ? this._months :
  6661. this._months['standalone'];
  6662. }
  6663. return isArray(this._months) ? this._months[m.month()] :
  6664. this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone'][m.month()];
  6665. }
  6666. var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
  6667. function localeMonthsShort (m, format) {
  6668. if (!m) {
  6669. return isArray(this._monthsShort) ? this._monthsShort :
  6670. this._monthsShort['standalone'];
  6671. }
  6672. return isArray(this._monthsShort) ? this._monthsShort[m.month()] :
  6673. this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
  6674. }
  6675. function handleStrictParse(monthName, format, strict) {
  6676. var i, ii, mom, llc = monthName.toLocaleLowerCase();
  6677. if (!this._monthsParse) {
  6678. // this is not used
  6679. this._monthsParse = [];
  6680. this._longMonthsParse = [];
  6681. this._shortMonthsParse = [];
  6682. for (i = 0; i < 12; ++i) {
  6683. mom = createUTC([2000, i]);
  6684. this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase();
  6685. this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
  6686. }
  6687. }
  6688. if (strict) {
  6689. if (format === 'MMM') {
  6690. ii = indexOf.call(this._shortMonthsParse, llc);
  6691. return ii !== -1 ? ii : null;
  6692. } else {
  6693. ii = indexOf.call(this._longMonthsParse, llc);
  6694. return ii !== -1 ? ii : null;
  6695. }
  6696. } else {
  6697. if (format === 'MMM') {
  6698. ii = indexOf.call(this._shortMonthsParse, llc);
  6699. if (ii !== -1) {
  6700. return ii;
  6701. }
  6702. ii = indexOf.call(this._longMonthsParse, llc);
  6703. return ii !== -1 ? ii : null;
  6704. } else {
  6705. ii = indexOf.call(this._longMonthsParse, llc);
  6706. if (ii !== -1) {
  6707. return ii;
  6708. }
  6709. ii = indexOf.call(this._shortMonthsParse, llc);
  6710. return ii !== -1 ? ii : null;
  6711. }
  6712. }
  6713. }
  6714. function localeMonthsParse (monthName, format, strict) {
  6715. var i, mom, regex;
  6716. if (this._monthsParseExact) {
  6717. return handleStrictParse.call(this, monthName, format, strict);
  6718. }
  6719. if (!this._monthsParse) {
  6720. this._monthsParse = [];
  6721. this._longMonthsParse = [];
  6722. this._shortMonthsParse = [];
  6723. }
  6724. // TODO: add sorting
  6725. // Sorting makes sure if one month (or abbr) is a prefix of another
  6726. // see sorting in computeMonthsParse
  6727. for (i = 0; i < 12; i++) {
  6728. // make the regex if we don't have it already
  6729. mom = createUTC([2000, i]);
  6730. if (strict && !this._longMonthsParse[i]) {
  6731. this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
  6732. this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
  6733. }
  6734. if (!strict && !this._monthsParse[i]) {
  6735. regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
  6736. this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
  6737. }
  6738. // test the regex
  6739. if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
  6740. return i;
  6741. } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
  6742. return i;
  6743. } else if (!strict && this._monthsParse[i].test(monthName)) {
  6744. return i;
  6745. }
  6746. }
  6747. }
  6748. // MOMENTS
  6749. function setMonth (mom, value) {
  6750. var dayOfMonth;
  6751. if (!mom.isValid()) {
  6752. // No op
  6753. return mom;
  6754. }
  6755. if (typeof value === 'string') {
  6756. if (/^\d+$/.test(value)) {
  6757. value = toInt(value);
  6758. } else {
  6759. value = mom.localeData().monthsParse(value);
  6760. // TODO: Another silent failure?
  6761. if (!isNumber(value)) {
  6762. return mom;
  6763. }
  6764. }
  6765. }
  6766. dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
  6767. mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
  6768. return mom;
  6769. }
  6770. function getSetMonth (value) {
  6771. if (value != null) {
  6772. setMonth(this, value);
  6773. hooks.updateOffset(this, true);
  6774. return this;
  6775. } else {
  6776. return get(this, 'Month');
  6777. }
  6778. }
  6779. function getDaysInMonth () {
  6780. return daysInMonth(this.year(), this.month());
  6781. }
  6782. var defaultMonthsShortRegex = matchWord;
  6783. function monthsShortRegex (isStrict) {
  6784. if (this._monthsParseExact) {
  6785. if (!hasOwnProp(this, '_monthsRegex')) {
  6786. computeMonthsParse.call(this);
  6787. }
  6788. if (isStrict) {
  6789. return this._monthsShortStrictRegex;
  6790. } else {
  6791. return this._monthsShortRegex;
  6792. }
  6793. } else {
  6794. if (!hasOwnProp(this, '_monthsShortRegex')) {
  6795. this._monthsShortRegex = defaultMonthsShortRegex;
  6796. }
  6797. return this._monthsShortStrictRegex && isStrict ?
  6798. this._monthsShortStrictRegex : this._monthsShortRegex;
  6799. }
  6800. }
  6801. var defaultMonthsRegex = matchWord;
  6802. function monthsRegex (isStrict) {
  6803. if (this._monthsParseExact) {
  6804. if (!hasOwnProp(this, '_monthsRegex')) {
  6805. computeMonthsParse.call(this);
  6806. }
  6807. if (isStrict) {
  6808. return this._monthsStrictRegex;
  6809. } else {
  6810. return this._monthsRegex;
  6811. }
  6812. } else {
  6813. if (!hasOwnProp(this, '_monthsRegex')) {
  6814. this._monthsRegex = defaultMonthsRegex;
  6815. }
  6816. return this._monthsStrictRegex && isStrict ?
  6817. this._monthsStrictRegex : this._monthsRegex;
  6818. }
  6819. }
  6820. function computeMonthsParse () {
  6821. function cmpLenRev(a, b) {
  6822. return b.length - a.length;
  6823. }
  6824. var shortPieces = [], longPieces = [], mixedPieces = [],
  6825. i, mom;
  6826. for (i = 0; i < 12; i++) {
  6827. // make the regex if we don't have it already
  6828. mom = createUTC([2000, i]);
  6829. shortPieces.push(this.monthsShort(mom, ''));
  6830. longPieces.push(this.months(mom, ''));
  6831. mixedPieces.push(this.months(mom, ''));
  6832. mixedPieces.push(this.monthsShort(mom, ''));
  6833. }
  6834. // Sorting makes sure if one month (or abbr) is a prefix of another it
  6835. // will match the longer piece.
  6836. shortPieces.sort(cmpLenRev);
  6837. longPieces.sort(cmpLenRev);
  6838. mixedPieces.sort(cmpLenRev);
  6839. for (i = 0; i < 12; i++) {
  6840. shortPieces[i] = regexEscape(shortPieces[i]);
  6841. longPieces[i] = regexEscape(longPieces[i]);
  6842. }
  6843. for (i = 0; i < 24; i++) {
  6844. mixedPieces[i] = regexEscape(mixedPieces[i]);
  6845. }
  6846. this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  6847. this._monthsShortRegex = this._monthsRegex;
  6848. this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
  6849. this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
  6850. }
  6851. function createDate (y, m, d, h, M, s, ms) {
  6852. // can't just apply() to create a date:
  6853. // https://stackoverflow.com/q/181348
  6854. var date = new Date(y, m, d, h, M, s, ms);
  6855. // the date constructor remaps years 0-99 to 1900-1999
  6856. if (y < 100 && y >= 0 && isFinite(date.getFullYear())) {
  6857. date.setFullYear(y);
  6858. }
  6859. return date;
  6860. }
  6861. function createUTCDate (y) {
  6862. var date = new Date(Date.UTC.apply(null, arguments));
  6863. // the Date.UTC function remaps years 0-99 to 1900-1999
  6864. if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) {
  6865. date.setUTCFullYear(y);
  6866. }
  6867. return date;
  6868. }
  6869. // start-of-first-week - start-of-year
  6870. function firstWeekOffset(year, dow, doy) {
  6871. var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  6872. fwd = 7 + dow - doy,
  6873. // first-week day local weekday -- which local weekday is fwd
  6874. fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
  6875. return -fwdlw + fwd - 1;
  6876. }
  6877. // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
  6878. function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
  6879. var localWeekday = (7 + weekday - dow) % 7,
  6880. weekOffset = firstWeekOffset(year, dow, doy),
  6881. dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
  6882. resYear, resDayOfYear;
  6883. if (dayOfYear <= 0) {
  6884. resYear = year - 1;
  6885. resDayOfYear = daysInYear(resYear) + dayOfYear;
  6886. } else if (dayOfYear > daysInYear(year)) {
  6887. resYear = year + 1;
  6888. resDayOfYear = dayOfYear - daysInYear(year);
  6889. } else {
  6890. resYear = year;
  6891. resDayOfYear = dayOfYear;
  6892. }
  6893. return {
  6894. year: resYear,
  6895. dayOfYear: resDayOfYear
  6896. };
  6897. }
  6898. function weekOfYear(mom, dow, doy) {
  6899. var weekOffset = firstWeekOffset(mom.year(), dow, doy),
  6900. week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
  6901. resWeek, resYear;
  6902. if (week < 1) {
  6903. resYear = mom.year() - 1;
  6904. resWeek = week + weeksInYear(resYear, dow, doy);
  6905. } else if (week > weeksInYear(mom.year(), dow, doy)) {
  6906. resWeek = week - weeksInYear(mom.year(), dow, doy);
  6907. resYear = mom.year() + 1;
  6908. } else {
  6909. resYear = mom.year();
  6910. resWeek = week;
  6911. }
  6912. return {
  6913. week: resWeek,
  6914. year: resYear
  6915. };
  6916. }
  6917. function weeksInYear(year, dow, doy) {
  6918. var weekOffset = firstWeekOffset(year, dow, doy),
  6919. weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
  6920. return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
  6921. }
  6922. // FORMATTING
  6923. addFormatToken('w', ['ww', 2], 'wo', 'week');
  6924. addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
  6925. // ALIASES
  6926. addUnitAlias('week', 'w');
  6927. addUnitAlias('isoWeek', 'W');
  6928. // PRIORITIES
  6929. addUnitPriority('week', 5);
  6930. addUnitPriority('isoWeek', 5);
  6931. // PARSING
  6932. addRegexToken('w', match1to2);
  6933. addRegexToken('ww', match1to2, match2);
  6934. addRegexToken('W', match1to2);
  6935. addRegexToken('WW', match1to2, match2);
  6936. addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
  6937. week[token.substr(0, 1)] = toInt(input);
  6938. });
  6939. // HELPERS
  6940. // LOCALES
  6941. function localeWeek (mom) {
  6942. return weekOfYear(mom, this._week.dow, this._week.doy).week;
  6943. }
  6944. var defaultLocaleWeek = {
  6945. dow : 0, // Sunday is the first day of the week.
  6946. doy : 6 // The week that contains Jan 1st is the first week of the year.
  6947. };
  6948. function localeFirstDayOfWeek () {
  6949. return this._week.dow;
  6950. }
  6951. function localeFirstDayOfYear () {
  6952. return this._week.doy;
  6953. }
  6954. // MOMENTS
  6955. function getSetWeek (input) {
  6956. var week = this.localeData().week(this);
  6957. return input == null ? week : this.add((input - week) * 7, 'd');
  6958. }
  6959. function getSetISOWeek (input) {
  6960. var week = weekOfYear(this, 1, 4).week;
  6961. return input == null ? week : this.add((input - week) * 7, 'd');
  6962. }
  6963. // FORMATTING
  6964. addFormatToken('d', 0, 'do', 'day');
  6965. addFormatToken('dd', 0, 0, function (format) {
  6966. return this.localeData().weekdaysMin(this, format);
  6967. });
  6968. addFormatToken('ddd', 0, 0, function (format) {
  6969. return this.localeData().weekdaysShort(this, format);
  6970. });
  6971. addFormatToken('dddd', 0, 0, function (format) {
  6972. return this.localeData().weekdays(this, format);
  6973. });
  6974. addFormatToken('e', 0, 0, 'weekday');
  6975. addFormatToken('E', 0, 0, 'isoWeekday');
  6976. // ALIASES
  6977. addUnitAlias('day', 'd');
  6978. addUnitAlias('weekday', 'e');
  6979. addUnitAlias('isoWeekday', 'E');
  6980. // PRIORITY
  6981. addUnitPriority('day', 11);
  6982. addUnitPriority('weekday', 11);
  6983. addUnitPriority('isoWeekday', 11);
  6984. // PARSING
  6985. addRegexToken('d', match1to2);
  6986. addRegexToken('e', match1to2);
  6987. addRegexToken('E', match1to2);
  6988. addRegexToken('dd', function (isStrict, locale) {
  6989. return locale.weekdaysMinRegex(isStrict);
  6990. });
  6991. addRegexToken('ddd', function (isStrict, locale) {
  6992. return locale.weekdaysShortRegex(isStrict);
  6993. });
  6994. addRegexToken('dddd', function (isStrict, locale) {
  6995. return locale.weekdaysRegex(isStrict);
  6996. });
  6997. addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
  6998. var weekday = config._locale.weekdaysParse(input, token, config._strict);
  6999. // if we didn't get a weekday name, mark the date as invalid
  7000. if (weekday != null) {
  7001. week.d = weekday;
  7002. } else {
  7003. getParsingFlags(config).invalidWeekday = input;
  7004. }
  7005. });
  7006. addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
  7007. week[token] = toInt(input);
  7008. });
  7009. // HELPERS
  7010. function parseWeekday(input, locale) {
  7011. if (typeof input !== 'string') {
  7012. return input;
  7013. }
  7014. if (!isNaN(input)) {
  7015. return parseInt(input, 10);
  7016. }
  7017. input = locale.weekdaysParse(input);
  7018. if (typeof input === 'number') {
  7019. return input;
  7020. }
  7021. return null;
  7022. }
  7023. function parseIsoWeekday(input, locale) {
  7024. if (typeof input === 'string') {
  7025. return locale.weekdaysParse(input) % 7 || 7;
  7026. }
  7027. return isNaN(input) ? null : input;
  7028. }
  7029. // LOCALES
  7030. var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
  7031. function localeWeekdays (m, format) {
  7032. if (!m) {
  7033. return isArray(this._weekdays) ? this._weekdays :
  7034. this._weekdays['standalone'];
  7035. }
  7036. return isArray(this._weekdays) ? this._weekdays[m.day()] :
  7037. this._weekdays[this._weekdays.isFormat.test(format) ? 'format' : 'standalone'][m.day()];
  7038. }
  7039. var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
  7040. function localeWeekdaysShort (m) {
  7041. return (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
  7042. }
  7043. var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
  7044. function localeWeekdaysMin (m) {
  7045. return (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
  7046. }
  7047. function handleStrictParse$1(weekdayName, format, strict) {
  7048. var i, ii, mom, llc = weekdayName.toLocaleLowerCase();
  7049. if (!this._weekdaysParse) {
  7050. this._weekdaysParse = [];
  7051. this._shortWeekdaysParse = [];
  7052. this._minWeekdaysParse = [];
  7053. for (i = 0; i < 7; ++i) {
  7054. mom = createUTC([2000, 1]).day(i);
  7055. this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase();
  7056. this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase();
  7057. this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
  7058. }
  7059. }
  7060. if (strict) {
  7061. if (format === 'dddd') {
  7062. ii = indexOf.call(this._weekdaysParse, llc);
  7063. return ii !== -1 ? ii : null;
  7064. } else if (format === 'ddd') {
  7065. ii = indexOf.call(this._shortWeekdaysParse, llc);
  7066. return ii !== -1 ? ii : null;
  7067. } else {
  7068. ii = indexOf.call(this._minWeekdaysParse, llc);
  7069. return ii !== -1 ? ii : null;
  7070. }
  7071. } else {
  7072. if (format === 'dddd') {
  7073. ii = indexOf.call(this._weekdaysParse, llc);
  7074. if (ii !== -1) {
  7075. return ii;
  7076. }
  7077. ii = indexOf.call(this._shortWeekdaysParse, llc);
  7078. if (ii !== -1) {
  7079. return ii;
  7080. }
  7081. ii = indexOf.call(this._minWeekdaysParse, llc);
  7082. return ii !== -1 ? ii : null;
  7083. } else if (format === 'ddd') {
  7084. ii = indexOf.call(this._shortWeekdaysParse, llc);
  7085. if (ii !== -1) {
  7086. return ii;
  7087. }
  7088. ii = indexOf.call(this._weekdaysParse, llc);
  7089. if (ii !== -1) {
  7090. return ii;
  7091. }
  7092. ii = indexOf.call(this._minWeekdaysParse, llc);
  7093. return ii !== -1 ? ii : null;
  7094. } else {
  7095. ii = indexOf.call(this._minWeekdaysParse, llc);
  7096. if (ii !== -1) {
  7097. return ii;
  7098. }
  7099. ii = indexOf.call(this._weekdaysParse, llc);
  7100. if (ii !== -1) {
  7101. return ii;
  7102. }
  7103. ii = indexOf.call(this._shortWeekdaysParse, llc);
  7104. return ii !== -1 ? ii : null;
  7105. }
  7106. }
  7107. }
  7108. function localeWeekdaysParse (weekdayName, format, strict) {
  7109. var i, mom, regex;
  7110. if (this._weekdaysParseExact) {
  7111. return handleStrictParse$1.call(this, weekdayName, format, strict);
  7112. }
  7113. if (!this._weekdaysParse) {
  7114. this._weekdaysParse = [];
  7115. this._minWeekdaysParse = [];
  7116. this._shortWeekdaysParse = [];
  7117. this._fullWeekdaysParse = [];
  7118. }
  7119. for (i = 0; i < 7; i++) {
  7120. // make the regex if we don't have it already
  7121. mom = createUTC([2000, 1]).day(i);
  7122. if (strict && !this._fullWeekdaysParse[i]) {
  7123. this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\.?') + '$', 'i');
  7124. this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\.?') + '$', 'i');
  7125. this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\.?') + '$', 'i');
  7126. }
  7127. if (!this._weekdaysParse[i]) {
  7128. regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
  7129. this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
  7130. }
  7131. // test the regex
  7132. if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) {
  7133. return i;
  7134. } else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) {
  7135. return i;
  7136. } else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) {
  7137. return i;
  7138. } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
  7139. return i;
  7140. }
  7141. }
  7142. }
  7143. // MOMENTS
  7144. function getSetDayOfWeek (input) {
  7145. if (!this.isValid()) {
  7146. return input != null ? this : NaN;
  7147. }
  7148. var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
  7149. if (input != null) {
  7150. input = parseWeekday(input, this.localeData());
  7151. return this.add(input - day, 'd');
  7152. } else {
  7153. return day;
  7154. }
  7155. }
  7156. function getSetLocaleDayOfWeek (input) {
  7157. if (!this.isValid()) {
  7158. return input != null ? this : NaN;
  7159. }
  7160. var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
  7161. return input == null ? weekday : this.add(input - weekday, 'd');
  7162. }
  7163. function getSetISODayOfWeek (input) {
  7164. if (!this.isValid()) {
  7165. return input != null ? this : NaN;
  7166. }
  7167. // behaves the same as moment#day except
  7168. // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
  7169. // as a setter, sunday should belong to the previous week.
  7170. if (input != null) {
  7171. var weekday = parseIsoWeekday(input, this.localeData());
  7172. return this.day(this.day() % 7 ? weekday : weekday - 7);
  7173. } else {
  7174. return this.day() || 7;
  7175. }
  7176. }
  7177. var defaultWeekdaysRegex = matchWord;
  7178. function weekdaysRegex (isStrict) {
  7179. if (this._weekdaysParseExact) {
  7180. if (!hasOwnProp(this, '_weekdaysRegex')) {
  7181. computeWeekdaysParse.call(this);
  7182. }
  7183. if (isStrict) {
  7184. return this._weekdaysStrictRegex;
  7185. } else {
  7186. return this._weekdaysRegex;
  7187. }
  7188. } else {
  7189. if (!hasOwnProp(this, '_weekdaysRegex')) {
  7190. this._weekdaysRegex = defaultWeekdaysRegex;
  7191. }
  7192. return this._weekdaysStrictRegex && isStrict ?
  7193. this._weekdaysStrictRegex : this._weekdaysRegex;
  7194. }
  7195. }
  7196. var defaultWeekdaysShortRegex = matchWord;
  7197. function weekdaysShortRegex (isStrict) {
  7198. if (this._weekdaysParseExact) {
  7199. if (!hasOwnProp(this, '_weekdaysRegex')) {
  7200. computeWeekdaysParse.call(this);
  7201. }
  7202. if (isStrict) {
  7203. return this._weekdaysShortStrictRegex;
  7204. } else {
  7205. return this._weekdaysShortRegex;
  7206. }
  7207. } else {
  7208. if (!hasOwnProp(this, '_weekdaysShortRegex')) {
  7209. this._weekdaysShortRegex = defaultWeekdaysShortRegex;
  7210. }
  7211. return this._weekdaysShortStrictRegex && isStrict ?
  7212. this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
  7213. }
  7214. }
  7215. var defaultWeekdaysMinRegex = matchWord;
  7216. function weekdaysMinRegex (isStrict) {
  7217. if (this._weekdaysParseExact) {
  7218. if (!hasOwnProp(this, '_weekdaysRegex')) {
  7219. computeWeekdaysParse.call(this);
  7220. }
  7221. if (isStrict) {
  7222. return this._weekdaysMinStrictRegex;
  7223. } else {
  7224. return this._weekdaysMinRegex;
  7225. }
  7226. } else {
  7227. if (!hasOwnProp(this, '_weekdaysMinRegex')) {
  7228. this._weekdaysMinRegex = defaultWeekdaysMinRegex;
  7229. }
  7230. return this._weekdaysMinStrictRegex && isStrict ?
  7231. this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
  7232. }
  7233. }
  7234. function computeWeekdaysParse () {
  7235. function cmpLenRev(a, b) {
  7236. return b.length - a.length;
  7237. }
  7238. var minPieces = [], shortPieces = [], longPieces = [], mixedPieces = [],
  7239. i, mom, minp, shortp, longp;
  7240. for (i = 0; i < 7; i++) {
  7241. // make the regex if we don't have it already
  7242. mom = createUTC([2000, 1]).day(i);
  7243. minp = this.weekdaysMin(mom, '');
  7244. shortp = this.weekdaysShort(mom, '');
  7245. longp = this.weekdays(mom, '');
  7246. minPieces.push(minp);
  7247. shortPieces.push(shortp);
  7248. longPieces.push(longp);
  7249. mixedPieces.push(minp);
  7250. mixedPieces.push(shortp);
  7251. mixedPieces.push(longp);
  7252. }
  7253. // Sorting makes sure if one weekday (or abbr) is a prefix of another it
  7254. // will match the longer piece.
  7255. minPieces.sort(cmpLenRev);
  7256. shortPieces.sort(cmpLenRev);
  7257. longPieces.sort(cmpLenRev);
  7258. mixedPieces.sort(cmpLenRev);
  7259. for (i = 0; i < 7; i++) {
  7260. shortPieces[i] = regexEscape(shortPieces[i]);
  7261. longPieces[i] = regexEscape(longPieces[i]);
  7262. mixedPieces[i] = regexEscape(mixedPieces[i]);
  7263. }
  7264. this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  7265. this._weekdaysShortRegex = this._weekdaysRegex;
  7266. this._weekdaysMinRegex = this._weekdaysRegex;
  7267. this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
  7268. this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
  7269. this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i');
  7270. }
  7271. // FORMATTING
  7272. function hFormat() {
  7273. return this.hours() % 12 || 12;
  7274. }
  7275. function kFormat() {
  7276. return this.hours() || 24;
  7277. }
  7278. addFormatToken('H', ['HH', 2], 0, 'hour');
  7279. addFormatToken('h', ['hh', 2], 0, hFormat);
  7280. addFormatToken('k', ['kk', 2], 0, kFormat);
  7281. addFormatToken('hmm', 0, 0, function () {
  7282. return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
  7283. });
  7284. addFormatToken('hmmss', 0, 0, function () {
  7285. return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2) +
  7286. zeroFill(this.seconds(), 2);
  7287. });
  7288. addFormatToken('Hmm', 0, 0, function () {
  7289. return '' + this.hours() + zeroFill(this.minutes(), 2);
  7290. });
  7291. addFormatToken('Hmmss', 0, 0, function () {
  7292. return '' + this.hours() + zeroFill(this.minutes(), 2) +
  7293. zeroFill(this.seconds(), 2);
  7294. });
  7295. function meridiem (token, lowercase) {
  7296. addFormatToken(token, 0, 0, function () {
  7297. return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
  7298. });
  7299. }
  7300. meridiem('a', true);
  7301. meridiem('A', false);
  7302. // ALIASES
  7303. addUnitAlias('hour', 'h');
  7304. // PRIORITY
  7305. addUnitPriority('hour', 13);
  7306. // PARSING
  7307. function matchMeridiem (isStrict, locale) {
  7308. return locale._meridiemParse;
  7309. }
  7310. addRegexToken('a', matchMeridiem);
  7311. addRegexToken('A', matchMeridiem);
  7312. addRegexToken('H', match1to2);
  7313. addRegexToken('h', match1to2);
  7314. addRegexToken('k', match1to2);
  7315. addRegexToken('HH', match1to2, match2);
  7316. addRegexToken('hh', match1to2, match2);
  7317. addRegexToken('kk', match1to2, match2);
  7318. addRegexToken('hmm', match3to4);
  7319. addRegexToken('hmmss', match5to6);
  7320. addRegexToken('Hmm', match3to4);
  7321. addRegexToken('Hmmss', match5to6);
  7322. addParseToken(['H', 'HH'], HOUR);
  7323. addParseToken(['k', 'kk'], function (input, array, config) {
  7324. var kInput = toInt(input);
  7325. array[HOUR] = kInput === 24 ? 0 : kInput;
  7326. });
  7327. addParseToken(['a', 'A'], function (input, array, config) {
  7328. config._isPm = config._locale.isPM(input);
  7329. config._meridiem = input;
  7330. });
  7331. addParseToken(['h', 'hh'], function (input, array, config) {
  7332. array[HOUR] = toInt(input);
  7333. getParsingFlags(config).bigHour = true;
  7334. });
  7335. addParseToken('hmm', function (input, array, config) {
  7336. var pos = input.length - 2;
  7337. array[HOUR] = toInt(input.substr(0, pos));
  7338. array[MINUTE] = toInt(input.substr(pos));
  7339. getParsingFlags(config).bigHour = true;
  7340. });
  7341. addParseToken('hmmss', function (input, array, config) {
  7342. var pos1 = input.length - 4;
  7343. var pos2 = input.length - 2;
  7344. array[HOUR] = toInt(input.substr(0, pos1));
  7345. array[MINUTE] = toInt(input.substr(pos1, 2));
  7346. array[SECOND] = toInt(input.substr(pos2));
  7347. getParsingFlags(config).bigHour = true;
  7348. });
  7349. addParseToken('Hmm', function (input, array, config) {
  7350. var pos = input.length - 2;
  7351. array[HOUR] = toInt(input.substr(0, pos));
  7352. array[MINUTE] = toInt(input.substr(pos));
  7353. });
  7354. addParseToken('Hmmss', function (input, array, config) {
  7355. var pos1 = input.length - 4;
  7356. var pos2 = input.length - 2;
  7357. array[HOUR] = toInt(input.substr(0, pos1));
  7358. array[MINUTE] = toInt(input.substr(pos1, 2));
  7359. array[SECOND] = toInt(input.substr(pos2));
  7360. });
  7361. // LOCALES
  7362. function localeIsPM (input) {
  7363. // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
  7364. // Using charAt should be more compatible.
  7365. return ((input + '').toLowerCase().charAt(0) === 'p');
  7366. }
  7367. var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
  7368. function localeMeridiem (hours, minutes, isLower) {
  7369. if (hours > 11) {
  7370. return isLower ? 'pm' : 'PM';
  7371. } else {
  7372. return isLower ? 'am' : 'AM';
  7373. }
  7374. }
  7375. // MOMENTS
  7376. // Setting the hour should keep the time, because the user explicitly
  7377. // specified which hour he wants. So trying to maintain the same hour (in
  7378. // a new timezone) makes sense. Adding/subtracting hours does not follow
  7379. // this rule.
  7380. var getSetHour = makeGetSet('Hours', true);
  7381. // months
  7382. // week
  7383. // weekdays
  7384. // meridiem
  7385. var baseConfig = {
  7386. calendar: defaultCalendar,
  7387. longDateFormat: defaultLongDateFormat,
  7388. invalidDate: defaultInvalidDate,
  7389. ordinal: defaultOrdinal,
  7390. dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
  7391. relativeTime: defaultRelativeTime,
  7392. months: defaultLocaleMonths,
  7393. monthsShort: defaultLocaleMonthsShort,
  7394. week: defaultLocaleWeek,
  7395. weekdays: defaultLocaleWeekdays,
  7396. weekdaysMin: defaultLocaleWeekdaysMin,
  7397. weekdaysShort: defaultLocaleWeekdaysShort,
  7398. meridiemParse: defaultLocaleMeridiemParse
  7399. };
  7400. // internal storage for locale config files
  7401. var locales = {};
  7402. var localeFamilies = {};
  7403. var globalLocale;
  7404. function normalizeLocale(key) {
  7405. return key ? key.toLowerCase().replace('_', '-') : key;
  7406. }
  7407. // pick the locale from the array
  7408. // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
  7409. // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
  7410. function chooseLocale(names) {
  7411. var i = 0, j, next, locale, split;
  7412. while (i < names.length) {
  7413. split = normalizeLocale(names[i]).split('-');
  7414. j = split.length;
  7415. next = normalizeLocale(names[i + 1]);
  7416. next = next ? next.split('-') : null;
  7417. while (j > 0) {
  7418. locale = loadLocale(split.slice(0, j).join('-'));
  7419. if (locale) {
  7420. return locale;
  7421. }
  7422. if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
  7423. //the next array item is better than a shallower substring of this one
  7424. break;
  7425. }
  7426. j--;
  7427. }
  7428. i++;
  7429. }
  7430. return null;
  7431. }
  7432. function loadLocale(name) {
  7433. var oldLocale = null;
  7434. // TODO: Find a better way to register and load all the locales in Node
  7435. if (!locales[name] && (typeof module !== 'undefined') &&
  7436. module && module.exports) {
  7437. try {
  7438. oldLocale = globalLocale._abbr;
  7439. var aliasedRequire = require;
  7440. __webpack_require__(350)("./" + name);
  7441. getSetGlobalLocale(oldLocale);
  7442. } catch (e) {}
  7443. }
  7444. return locales[name];
  7445. }
  7446. // This function will load locale and then set the global locale. If
  7447. // no arguments are passed in, it will simply return the current global
  7448. // locale key.
  7449. function getSetGlobalLocale (key, values) {
  7450. var data;
  7451. if (key) {
  7452. if (isUndefined(values)) {
  7453. data = getLocale(key);
  7454. }
  7455. else {
  7456. data = defineLocale(key, values);
  7457. }
  7458. if (data) {
  7459. // moment.duration._locale = moment._locale = data;
  7460. globalLocale = data;
  7461. }
  7462. }
  7463. return globalLocale._abbr;
  7464. }
  7465. function defineLocale (name, config) {
  7466. if (config !== null) {
  7467. var parentConfig = baseConfig;
  7468. config.abbr = name;
  7469. if (locales[name] != null) {
  7470. deprecateSimple('defineLocaleOverride',
  7471. 'use moment.updateLocale(localeName, config) to change ' +
  7472. 'an existing locale. moment.defineLocale(localeName, ' +
  7473. 'config) should only be used for creating a new locale ' +
  7474. 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.');
  7475. parentConfig = locales[name]._config;
  7476. } else if (config.parentLocale != null) {
  7477. if (locales[config.parentLocale] != null) {
  7478. parentConfig = locales[config.parentLocale]._config;
  7479. } else {
  7480. if (!localeFamilies[config.parentLocale]) {
  7481. localeFamilies[config.parentLocale] = [];
  7482. }
  7483. localeFamilies[config.parentLocale].push({
  7484. name: name,
  7485. config: config
  7486. });
  7487. return null;
  7488. }
  7489. }
  7490. locales[name] = new Locale(mergeConfigs(parentConfig, config));
  7491. if (localeFamilies[name]) {
  7492. localeFamilies[name].forEach(function (x) {
  7493. defineLocale(x.name, x.config);
  7494. });
  7495. }
  7496. // backwards compat for now: also set the locale
  7497. // make sure we set the locale AFTER all child locales have been
  7498. // created, so we won't end up with the child locale set.
  7499. getSetGlobalLocale(name);
  7500. return locales[name];
  7501. } else {
  7502. // useful for testing
  7503. delete locales[name];
  7504. return null;
  7505. }
  7506. }
  7507. function updateLocale(name, config) {
  7508. if (config != null) {
  7509. var locale, tmpLocale, parentConfig = baseConfig;
  7510. // MERGE
  7511. tmpLocale = loadLocale(name);
  7512. if (tmpLocale != null) {
  7513. parentConfig = tmpLocale._config;
  7514. }
  7515. config = mergeConfigs(parentConfig, config);
  7516. locale = new Locale(config);
  7517. locale.parentLocale = locales[name];
  7518. locales[name] = locale;
  7519. // backwards compat for now: also set the locale
  7520. getSetGlobalLocale(name);
  7521. } else {
  7522. // pass null for config to unupdate, useful for tests
  7523. if (locales[name] != null) {
  7524. if (locales[name].parentLocale != null) {
  7525. locales[name] = locales[name].parentLocale;
  7526. } else if (locales[name] != null) {
  7527. delete locales[name];
  7528. }
  7529. }
  7530. }
  7531. return locales[name];
  7532. }
  7533. // returns locale data
  7534. function getLocale (key) {
  7535. var locale;
  7536. if (key && key._locale && key._locale._abbr) {
  7537. key = key._locale._abbr;
  7538. }
  7539. if (!key) {
  7540. return globalLocale;
  7541. }
  7542. if (!isArray(key)) {
  7543. //short-circuit everything else
  7544. locale = loadLocale(key);
  7545. if (locale) {
  7546. return locale;
  7547. }
  7548. key = [key];
  7549. }
  7550. return chooseLocale(key);
  7551. }
  7552. function listLocales() {
  7553. return keys(locales);
  7554. }
  7555. function checkOverflow (m) {
  7556. var overflow;
  7557. var a = m._a;
  7558. if (a && getParsingFlags(m).overflow === -2) {
  7559. overflow =
  7560. a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
  7561. a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
  7562. a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR :
  7563. a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE :
  7564. a[SECOND] < 0 || a[SECOND] > 59 ? SECOND :
  7565. a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
  7566. -1;
  7567. if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
  7568. overflow = DATE;
  7569. }
  7570. if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
  7571. overflow = WEEK;
  7572. }
  7573. if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
  7574. overflow = WEEKDAY;
  7575. }
  7576. getParsingFlags(m).overflow = overflow;
  7577. }
  7578. return m;
  7579. }
  7580. // Pick the first defined of two or three arguments.
  7581. function defaults(a, b, c) {
  7582. if (a != null) {
  7583. return a;
  7584. }
  7585. if (b != null) {
  7586. return b;
  7587. }
  7588. return c;
  7589. }
  7590. function currentDateArray(config) {
  7591. // hooks is actually the exported moment object
  7592. var nowValue = new Date(hooks.now());
  7593. if (config._useUTC) {
  7594. return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()];
  7595. }
  7596. return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
  7597. }
  7598. // convert an array to a date.
  7599. // the array should mirror the parameters below
  7600. // note: all values past the year are optional and will default to the lowest possible value.
  7601. // [year, month, day , hour, minute, second, millisecond]
  7602. function configFromArray (config) {
  7603. var i, date, input = [], currentDate, expectedWeekday, yearToUse;
  7604. if (config._d) {
  7605. return;
  7606. }
  7607. currentDate = currentDateArray(config);
  7608. //compute day of the year from weeks and weekdays
  7609. if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
  7610. dayOfYearFromWeekInfo(config);
  7611. }
  7612. //if the day of the year is set, figure out what it is
  7613. if (config._dayOfYear != null) {
  7614. yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
  7615. if (config._dayOfYear > daysInYear(yearToUse) || config._dayOfYear === 0) {
  7616. getParsingFlags(config)._overflowDayOfYear = true;
  7617. }
  7618. date = createUTCDate(yearToUse, 0, config._dayOfYear);
  7619. config._a[MONTH] = date.getUTCMonth();
  7620. config._a[DATE] = date.getUTCDate();
  7621. }
  7622. // Default to current date.
  7623. // * if no year, month, day of month are given, default to today
  7624. // * if day of month is given, default month and year
  7625. // * if month is given, default only year
  7626. // * if year is given, don't default anything
  7627. for (i = 0; i < 3 && config._a[i] == null; ++i) {
  7628. config._a[i] = input[i] = currentDate[i];
  7629. }
  7630. // Zero out whatever was not defaulted, including time
  7631. for (; i < 7; i++) {
  7632. config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
  7633. }
  7634. // Check for 24:00:00.000
  7635. if (config._a[HOUR] === 24 &&
  7636. config._a[MINUTE] === 0 &&
  7637. config._a[SECOND] === 0 &&
  7638. config._a[MILLISECOND] === 0) {
  7639. config._nextDay = true;
  7640. config._a[HOUR] = 0;
  7641. }
  7642. config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
  7643. expectedWeekday = config._useUTC ? config._d.getUTCDay() : config._d.getDay();
  7644. // Apply timezone offset from input. The actual utcOffset can be changed
  7645. // with parseZone.
  7646. if (config._tzm != null) {
  7647. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  7648. }
  7649. if (config._nextDay) {
  7650. config._a[HOUR] = 24;
  7651. }
  7652. // check for mismatching day of week
  7653. if (config._w && typeof config._w.d !== 'undefined' && config._w.d !== expectedWeekday) {
  7654. getParsingFlags(config).weekdayMismatch = true;
  7655. }
  7656. }
  7657. function dayOfYearFromWeekInfo(config) {
  7658. var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow;
  7659. w = config._w;
  7660. if (w.GG != null || w.W != null || w.E != null) {
  7661. dow = 1;
  7662. doy = 4;
  7663. // TODO: We need to take the current isoWeekYear, but that depends on
  7664. // how we interpret now (local, utc, fixed offset). So create
  7665. // a now version of current config (take local/utc/offset flags, and
  7666. // create now).
  7667. weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(createLocal(), 1, 4).year);
  7668. week = defaults(w.W, 1);
  7669. weekday = defaults(w.E, 1);
  7670. if (weekday < 1 || weekday > 7) {
  7671. weekdayOverflow = true;
  7672. }
  7673. } else {
  7674. dow = config._locale._week.dow;
  7675. doy = config._locale._week.doy;
  7676. var curWeek = weekOfYear(createLocal(), dow, doy);
  7677. weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
  7678. // Default to current week.
  7679. week = defaults(w.w, curWeek.week);
  7680. if (w.d != null) {
  7681. // weekday -- low day numbers are considered next week
  7682. weekday = w.d;
  7683. if (weekday < 0 || weekday > 6) {
  7684. weekdayOverflow = true;
  7685. }
  7686. } else if (w.e != null) {
  7687. // local weekday -- counting starts from begining of week
  7688. weekday = w.e + dow;
  7689. if (w.e < 0 || w.e > 6) {
  7690. weekdayOverflow = true;
  7691. }
  7692. } else {
  7693. // default to begining of week
  7694. weekday = dow;
  7695. }
  7696. }
  7697. if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
  7698. getParsingFlags(config)._overflowWeeks = true;
  7699. } else if (weekdayOverflow != null) {
  7700. getParsingFlags(config)._overflowWeekday = true;
  7701. } else {
  7702. temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
  7703. config._a[YEAR] = temp.year;
  7704. config._dayOfYear = temp.dayOfYear;
  7705. }
  7706. }
  7707. // iso 8601 regex
  7708. // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
  7709. var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
  7710. var basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
  7711. var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/;
  7712. var isoDates = [
  7713. ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/],
  7714. ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/],
  7715. ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/],
  7716. ['GGGG-[W]WW', /\d{4}-W\d\d/, false],
  7717. ['YYYY-DDD', /\d{4}-\d{3}/],
  7718. ['YYYY-MM', /\d{4}-\d\d/, false],
  7719. ['YYYYYYMMDD', /[+-]\d{10}/],
  7720. ['YYYYMMDD', /\d{8}/],
  7721. // YYYYMM is NOT allowed by the standard
  7722. ['GGGG[W]WWE', /\d{4}W\d{3}/],
  7723. ['GGGG[W]WW', /\d{4}W\d{2}/, false],
  7724. ['YYYYDDD', /\d{7}/]
  7725. ];
  7726. // iso time formats and regexes
  7727. var isoTimes = [
  7728. ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
  7729. ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
  7730. ['HH:mm:ss', /\d\d:\d\d:\d\d/],
  7731. ['HH:mm', /\d\d:\d\d/],
  7732. ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
  7733. ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
  7734. ['HHmmss', /\d\d\d\d\d\d/],
  7735. ['HHmm', /\d\d\d\d/],
  7736. ['HH', /\d\d/]
  7737. ];
  7738. var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
  7739. // date from iso format
  7740. function configFromISO(config) {
  7741. var i, l,
  7742. string = config._i,
  7743. match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
  7744. allowTime, dateFormat, timeFormat, tzFormat;
  7745. if (match) {
  7746. getParsingFlags(config).iso = true;
  7747. for (i = 0, l = isoDates.length; i < l; i++) {
  7748. if (isoDates[i][1].exec(match[1])) {
  7749. dateFormat = isoDates[i][0];
  7750. allowTime = isoDates[i][2] !== false;
  7751. break;
  7752. }
  7753. }
  7754. if (dateFormat == null) {
  7755. config._isValid = false;
  7756. return;
  7757. }
  7758. if (match[3]) {
  7759. for (i = 0, l = isoTimes.length; i < l; i++) {
  7760. if (isoTimes[i][1].exec(match[3])) {
  7761. // match[2] should be 'T' or space
  7762. timeFormat = (match[2] || ' ') + isoTimes[i][0];
  7763. break;
  7764. }
  7765. }
  7766. if (timeFormat == null) {
  7767. config._isValid = false;
  7768. return;
  7769. }
  7770. }
  7771. if (!allowTime && timeFormat != null) {
  7772. config._isValid = false;
  7773. return;
  7774. }
  7775. if (match[4]) {
  7776. if (tzRegex.exec(match[4])) {
  7777. tzFormat = 'Z';
  7778. } else {
  7779. config._isValid = false;
  7780. return;
  7781. }
  7782. }
  7783. config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
  7784. configFromStringAndFormat(config);
  7785. } else {
  7786. config._isValid = false;
  7787. }
  7788. }
  7789. // RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3
  7790. var rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/;
  7791. function extractFromRFC2822Strings(yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) {
  7792. var result = [
  7793. untruncateYear(yearStr),
  7794. defaultLocaleMonthsShort.indexOf(monthStr),
  7795. parseInt(dayStr, 10),
  7796. parseInt(hourStr, 10),
  7797. parseInt(minuteStr, 10)
  7798. ];
  7799. if (secondStr) {
  7800. result.push(parseInt(secondStr, 10));
  7801. }
  7802. return result;
  7803. }
  7804. function untruncateYear(yearStr) {
  7805. var year = parseInt(yearStr, 10);
  7806. if (year <= 49) {
  7807. return 2000 + year;
  7808. } else if (year <= 999) {
  7809. return 1900 + year;
  7810. }
  7811. return year;
  7812. }
  7813. function preprocessRFC2822(s) {
  7814. // Remove comments and folding whitespace and replace multiple-spaces with a single space
  7815. return s.replace(/\([^)]*\)|[\n\t]/g, ' ').replace(/(\s\s+)/g, ' ').trim();
  7816. }
  7817. function checkWeekday(weekdayStr, parsedInput, config) {
  7818. if (weekdayStr) {
  7819. // TODO: Replace the vanilla JS Date object with an indepentent day-of-week check.
  7820. var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr),
  7821. weekdayActual = new Date(parsedInput[0], parsedInput[1], parsedInput[2]).getDay();
  7822. if (weekdayProvided !== weekdayActual) {
  7823. getParsingFlags(config).weekdayMismatch = true;
  7824. config._isValid = false;
  7825. return false;
  7826. }
  7827. }
  7828. return true;
  7829. }
  7830. var obsOffsets = {
  7831. UT: 0,
  7832. GMT: 0,
  7833. EDT: -4 * 60,
  7834. EST: -5 * 60,
  7835. CDT: -5 * 60,
  7836. CST: -6 * 60,
  7837. MDT: -6 * 60,
  7838. MST: -7 * 60,
  7839. PDT: -7 * 60,
  7840. PST: -8 * 60
  7841. };
  7842. function calculateOffset(obsOffset, militaryOffset, numOffset) {
  7843. if (obsOffset) {
  7844. return obsOffsets[obsOffset];
  7845. } else if (militaryOffset) {
  7846. // the only allowed military tz is Z
  7847. return 0;
  7848. } else {
  7849. var hm = parseInt(numOffset, 10);
  7850. var m = hm % 100, h = (hm - m) / 100;
  7851. return h * 60 + m;
  7852. }
  7853. }
  7854. // date and time from ref 2822 format
  7855. function configFromRFC2822(config) {
  7856. var match = rfc2822.exec(preprocessRFC2822(config._i));
  7857. if (match) {
  7858. var parsedArray = extractFromRFC2822Strings(match[4], match[3], match[2], match[5], match[6], match[7]);
  7859. if (!checkWeekday(match[1], parsedArray, config)) {
  7860. return;
  7861. }
  7862. config._a = parsedArray;
  7863. config._tzm = calculateOffset(match[8], match[9], match[10]);
  7864. config._d = createUTCDate.apply(null, config._a);
  7865. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  7866. getParsingFlags(config).rfc2822 = true;
  7867. } else {
  7868. config._isValid = false;
  7869. }
  7870. }
  7871. // date from iso format or fallback
  7872. function configFromString(config) {
  7873. var matched = aspNetJsonRegex.exec(config._i);
  7874. if (matched !== null) {
  7875. config._d = new Date(+matched[1]);
  7876. return;
  7877. }
  7878. configFromISO(config);
  7879. if (config._isValid === false) {
  7880. delete config._isValid;
  7881. } else {
  7882. return;
  7883. }
  7884. configFromRFC2822(config);
  7885. if (config._isValid === false) {
  7886. delete config._isValid;
  7887. } else {
  7888. return;
  7889. }
  7890. // Final attempt, use Input Fallback
  7891. hooks.createFromInputFallback(config);
  7892. }
  7893. hooks.createFromInputFallback = deprecate(
  7894. 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' +
  7895. 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' +
  7896. 'discouraged and will be removed in an upcoming major release. Please refer to ' +
  7897. 'http://momentjs.com/guides/#/warnings/js-date/ for more info.',
  7898. function (config) {
  7899. config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
  7900. }
  7901. );
  7902. // constant that refers to the ISO standard
  7903. hooks.ISO_8601 = function () {};
  7904. // constant that refers to the RFC 2822 form
  7905. hooks.RFC_2822 = function () {};
  7906. // date from string and format string
  7907. function configFromStringAndFormat(config) {
  7908. // TODO: Move this to another part of the creation flow to prevent circular deps
  7909. if (config._f === hooks.ISO_8601) {
  7910. configFromISO(config);
  7911. return;
  7912. }
  7913. if (config._f === hooks.RFC_2822) {
  7914. configFromRFC2822(config);
  7915. return;
  7916. }
  7917. config._a = [];
  7918. getParsingFlags(config).empty = true;
  7919. // This array is used to make a Date, either with `new Date` or `Date.UTC`
  7920. var string = '' + config._i,
  7921. i, parsedInput, tokens, token, skipped,
  7922. stringLength = string.length,
  7923. totalParsedInputLength = 0;
  7924. tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
  7925. for (i = 0; i < tokens.length; i++) {
  7926. token = tokens[i];
  7927. parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
  7928. // console.log('token', token, 'parsedInput', parsedInput,
  7929. // 'regex', getParseRegexForToken(token, config));
  7930. if (parsedInput) {
  7931. skipped = string.substr(0, string.indexOf(parsedInput));
  7932. if (skipped.length > 0) {
  7933. getParsingFlags(config).unusedInput.push(skipped);
  7934. }
  7935. string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
  7936. totalParsedInputLength += parsedInput.length;
  7937. }
  7938. // don't parse if it's not a known token
  7939. if (formatTokenFunctions[token]) {
  7940. if (parsedInput) {
  7941. getParsingFlags(config).empty = false;
  7942. }
  7943. else {
  7944. getParsingFlags(config).unusedTokens.push(token);
  7945. }
  7946. addTimeToArrayFromToken(token, parsedInput, config);
  7947. }
  7948. else if (config._strict && !parsedInput) {
  7949. getParsingFlags(config).unusedTokens.push(token);
  7950. }
  7951. }
  7952. // add remaining unparsed input length to the string
  7953. getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
  7954. if (string.length > 0) {
  7955. getParsingFlags(config).unusedInput.push(string);
  7956. }
  7957. // clear _12h flag if hour is <= 12
  7958. if (config._a[HOUR] <= 12 &&
  7959. getParsingFlags(config).bigHour === true &&
  7960. config._a[HOUR] > 0) {
  7961. getParsingFlags(config).bigHour = undefined;
  7962. }
  7963. getParsingFlags(config).parsedDateParts = config._a.slice(0);
  7964. getParsingFlags(config).meridiem = config._meridiem;
  7965. // handle meridiem
  7966. config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
  7967. configFromArray(config);
  7968. checkOverflow(config);
  7969. }
  7970. function meridiemFixWrap (locale, hour, meridiem) {
  7971. var isPm;
  7972. if (meridiem == null) {
  7973. // nothing to do
  7974. return hour;
  7975. }
  7976. if (locale.meridiemHour != null) {
  7977. return locale.meridiemHour(hour, meridiem);
  7978. } else if (locale.isPM != null) {
  7979. // Fallback
  7980. isPm = locale.isPM(meridiem);
  7981. if (isPm && hour < 12) {
  7982. hour += 12;
  7983. }
  7984. if (!isPm && hour === 12) {
  7985. hour = 0;
  7986. }
  7987. return hour;
  7988. } else {
  7989. // this is not supposed to happen
  7990. return hour;
  7991. }
  7992. }
  7993. // date from string and array of format strings
  7994. function configFromStringAndArray(config) {
  7995. var tempConfig,
  7996. bestMoment,
  7997. scoreToBeat,
  7998. i,
  7999. currentScore;
  8000. if (config._f.length === 0) {
  8001. getParsingFlags(config).invalidFormat = true;
  8002. config._d = new Date(NaN);
  8003. return;
  8004. }
  8005. for (i = 0; i < config._f.length; i++) {
  8006. currentScore = 0;
  8007. tempConfig = copyConfig({}, config);
  8008. if (config._useUTC != null) {
  8009. tempConfig._useUTC = config._useUTC;
  8010. }
  8011. tempConfig._f = config._f[i];
  8012. configFromStringAndFormat(tempConfig);
  8013. if (!isValid(tempConfig)) {
  8014. continue;
  8015. }
  8016. // if there is any input that was not parsed add a penalty for that format
  8017. currentScore += getParsingFlags(tempConfig).charsLeftOver;
  8018. //or tokens
  8019. currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
  8020. getParsingFlags(tempConfig).score = currentScore;
  8021. if (scoreToBeat == null || currentScore < scoreToBeat) {
  8022. scoreToBeat = currentScore;
  8023. bestMoment = tempConfig;
  8024. }
  8025. }
  8026. extend(config, bestMoment || tempConfig);
  8027. }
  8028. function configFromObject(config) {
  8029. if (config._d) {
  8030. return;
  8031. }
  8032. var i = normalizeObjectUnits(config._i);
  8033. config._a = map([i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond], function (obj) {
  8034. return obj && parseInt(obj, 10);
  8035. });
  8036. configFromArray(config);
  8037. }
  8038. function createFromConfig (config) {
  8039. var res = new Moment(checkOverflow(prepareConfig(config)));
  8040. if (res._nextDay) {
  8041. // Adding is smart enough around DST
  8042. res.add(1, 'd');
  8043. res._nextDay = undefined;
  8044. }
  8045. return res;
  8046. }
  8047. function prepareConfig (config) {
  8048. var input = config._i,
  8049. format = config._f;
  8050. config._locale = config._locale || getLocale(config._l);
  8051. if (input === null || (format === undefined && input === '')) {
  8052. return createInvalid({nullInput: true});
  8053. }
  8054. if (typeof input === 'string') {
  8055. config._i = input = config._locale.preparse(input);
  8056. }
  8057. if (isMoment(input)) {
  8058. return new Moment(checkOverflow(input));
  8059. } else if (isDate(input)) {
  8060. config._d = input;
  8061. } else if (isArray(format)) {
  8062. configFromStringAndArray(config);
  8063. } else if (format) {
  8064. configFromStringAndFormat(config);
  8065. } else {
  8066. configFromInput(config);
  8067. }
  8068. if (!isValid(config)) {
  8069. config._d = null;
  8070. }
  8071. return config;
  8072. }
  8073. function configFromInput(config) {
  8074. var input = config._i;
  8075. if (isUndefined(input)) {
  8076. config._d = new Date(hooks.now());
  8077. } else if (isDate(input)) {
  8078. config._d = new Date(input.valueOf());
  8079. } else if (typeof input === 'string') {
  8080. configFromString(config);
  8081. } else if (isArray(input)) {
  8082. config._a = map(input.slice(0), function (obj) {
  8083. return parseInt(obj, 10);
  8084. });
  8085. configFromArray(config);
  8086. } else if (isObject(input)) {
  8087. configFromObject(config);
  8088. } else if (isNumber(input)) {
  8089. // from milliseconds
  8090. config._d = new Date(input);
  8091. } else {
  8092. hooks.createFromInputFallback(config);
  8093. }
  8094. }
  8095. function createLocalOrUTC (input, format, locale, strict, isUTC) {
  8096. var c = {};
  8097. if (locale === true || locale === false) {
  8098. strict = locale;
  8099. locale = undefined;
  8100. }
  8101. if ((isObject(input) && isObjectEmpty(input)) ||
  8102. (isArray(input) && input.length === 0)) {
  8103. input = undefined;
  8104. }
  8105. // object construction must be done this way.
  8106. // https://github.com/moment/moment/issues/1423
  8107. c._isAMomentObject = true;
  8108. c._useUTC = c._isUTC = isUTC;
  8109. c._l = locale;
  8110. c._i = input;
  8111. c._f = format;
  8112. c._strict = strict;
  8113. return createFromConfig(c);
  8114. }
  8115. function createLocal (input, format, locale, strict) {
  8116. return createLocalOrUTC(input, format, locale, strict, false);
  8117. }
  8118. var prototypeMin = deprecate(
  8119. 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
  8120. function () {
  8121. var other = createLocal.apply(null, arguments);
  8122. if (this.isValid() && other.isValid()) {
  8123. return other < this ? this : other;
  8124. } else {
  8125. return createInvalid();
  8126. }
  8127. }
  8128. );
  8129. var prototypeMax = deprecate(
  8130. 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
  8131. function () {
  8132. var other = createLocal.apply(null, arguments);
  8133. if (this.isValid() && other.isValid()) {
  8134. return other > this ? this : other;
  8135. } else {
  8136. return createInvalid();
  8137. }
  8138. }
  8139. );
  8140. // Pick a moment m from moments so that m[fn](other) is true for all
  8141. // other. This relies on the function fn to be transitive.
  8142. //
  8143. // moments should either be an array of moment objects or an array, whose
  8144. // first element is an array of moment objects.
  8145. function pickBy(fn, moments) {
  8146. var res, i;
  8147. if (moments.length === 1 && isArray(moments[0])) {
  8148. moments = moments[0];
  8149. }
  8150. if (!moments.length) {
  8151. return createLocal();
  8152. }
  8153. res = moments[0];
  8154. for (i = 1; i < moments.length; ++i) {
  8155. if (!moments[i].isValid() || moments[i][fn](res)) {
  8156. res = moments[i];
  8157. }
  8158. }
  8159. return res;
  8160. }
  8161. // TODO: Use [].sort instead?
  8162. function min () {
  8163. var args = [].slice.call(arguments, 0);
  8164. return pickBy('isBefore', args);
  8165. }
  8166. function max () {
  8167. var args = [].slice.call(arguments, 0);
  8168. return pickBy('isAfter', args);
  8169. }
  8170. var now = function () {
  8171. return Date.now ? Date.now() : +(new Date());
  8172. };
  8173. var ordering = ['year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond'];
  8174. function isDurationValid(m) {
  8175. for (var key in m) {
  8176. if (!(indexOf.call(ordering, key) !== -1 && (m[key] == null || !isNaN(m[key])))) {
  8177. return false;
  8178. }
  8179. }
  8180. var unitHasDecimal = false;
  8181. for (var i = 0; i < ordering.length; ++i) {
  8182. if (m[ordering[i]]) {
  8183. if (unitHasDecimal) {
  8184. return false; // only allow non-integers for smallest unit
  8185. }
  8186. if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
  8187. unitHasDecimal = true;
  8188. }
  8189. }
  8190. }
  8191. return true;
  8192. }
  8193. function isValid$1() {
  8194. return this._isValid;
  8195. }
  8196. function createInvalid$1() {
  8197. return createDuration(NaN);
  8198. }
  8199. function Duration (duration) {
  8200. var normalizedInput = normalizeObjectUnits(duration),
  8201. years = normalizedInput.year || 0,
  8202. quarters = normalizedInput.quarter || 0,
  8203. months = normalizedInput.month || 0,
  8204. weeks = normalizedInput.week || 0,
  8205. days = normalizedInput.day || 0,
  8206. hours = normalizedInput.hour || 0,
  8207. minutes = normalizedInput.minute || 0,
  8208. seconds = normalizedInput.second || 0,
  8209. milliseconds = normalizedInput.millisecond || 0;
  8210. this._isValid = isDurationValid(normalizedInput);
  8211. // representation for dateAddRemove
  8212. this._milliseconds = +milliseconds +
  8213. seconds * 1e3 + // 1000
  8214. minutes * 6e4 + // 1000 * 60
  8215. hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
  8216. // Because of dateAddRemove treats 24 hours as different from a
  8217. // day when working around DST, we need to store them separately
  8218. this._days = +days +
  8219. weeks * 7;
  8220. // It is impossible to translate months into days without knowing
  8221. // which months you are are talking about, so we have to store
  8222. // it separately.
  8223. this._months = +months +
  8224. quarters * 3 +
  8225. years * 12;
  8226. this._data = {};
  8227. this._locale = getLocale();
  8228. this._bubble();
  8229. }
  8230. function isDuration (obj) {
  8231. return obj instanceof Duration;
  8232. }
  8233. function absRound (number) {
  8234. if (number < 0) {
  8235. return Math.round(-1 * number) * -1;
  8236. } else {
  8237. return Math.round(number);
  8238. }
  8239. }
  8240. // FORMATTING
  8241. function offset (token, separator) {
  8242. addFormatToken(token, 0, 0, function () {
  8243. var offset = this.utcOffset();
  8244. var sign = '+';
  8245. if (offset < 0) {
  8246. offset = -offset;
  8247. sign = '-';
  8248. }
  8249. return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2);
  8250. });
  8251. }
  8252. offset('Z', ':');
  8253. offset('ZZ', '');
  8254. // PARSING
  8255. addRegexToken('Z', matchShortOffset);
  8256. addRegexToken('ZZ', matchShortOffset);
  8257. addParseToken(['Z', 'ZZ'], function (input, array, config) {
  8258. config._useUTC = true;
  8259. config._tzm = offsetFromString(matchShortOffset, input);
  8260. });
  8261. // HELPERS
  8262. // timezone chunker
  8263. // '+10:00' > ['10', '00']
  8264. // '-1530' > ['-15', '30']
  8265. var chunkOffset = /([\+\-]|\d\d)/gi;
  8266. function offsetFromString(matcher, string) {
  8267. var matches = (string || '').match(matcher);
  8268. if (matches === null) {
  8269. return null;
  8270. }
  8271. var chunk = matches[matches.length - 1] || [];
  8272. var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
  8273. var minutes = +(parts[1] * 60) + toInt(parts[2]);
  8274. return minutes === 0 ?
  8275. 0 :
  8276. parts[0] === '+' ? minutes : -minutes;
  8277. }
  8278. // Return a moment from input, that is local/utc/zone equivalent to model.
  8279. function cloneWithOffset(input, model) {
  8280. var res, diff;
  8281. if (model._isUTC) {
  8282. res = model.clone();
  8283. diff = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf();
  8284. // Use low-level api, because this fn is low-level api.
  8285. res._d.setTime(res._d.valueOf() + diff);
  8286. hooks.updateOffset(res, false);
  8287. return res;
  8288. } else {
  8289. return createLocal(input).local();
  8290. }
  8291. }
  8292. function getDateOffset (m) {
  8293. // On Firefox.24 Date#getTimezoneOffset returns a floating point.
  8294. // https://github.com/moment/moment/pull/1871
  8295. return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
  8296. }
  8297. // HOOKS
  8298. // This function will be called whenever a moment is mutated.
  8299. // It is intended to keep the offset in sync with the timezone.
  8300. hooks.updateOffset = function () {};
  8301. // MOMENTS
  8302. // keepLocalTime = true means only change the timezone, without
  8303. // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
  8304. // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
  8305. // +0200, so we adjust the time as needed, to be valid.
  8306. //
  8307. // Keeping the time actually adds/subtracts (one hour)
  8308. // from the actual represented time. That is why we call updateOffset
  8309. // a second time. In case it wants us to change the offset again
  8310. // _changeInProgress == true case, then we have to adjust, because
  8311. // there is no such time in the given timezone.
  8312. function getSetOffset (input, keepLocalTime, keepMinutes) {
  8313. var offset = this._offset || 0,
  8314. localAdjust;
  8315. if (!this.isValid()) {
  8316. return input != null ? this : NaN;
  8317. }
  8318. if (input != null) {
  8319. if (typeof input === 'string') {
  8320. input = offsetFromString(matchShortOffset, input);
  8321. if (input === null) {
  8322. return this;
  8323. }
  8324. } else if (Math.abs(input) < 16 && !keepMinutes) {
  8325. input = input * 60;
  8326. }
  8327. if (!this._isUTC && keepLocalTime) {
  8328. localAdjust = getDateOffset(this);
  8329. }
  8330. this._offset = input;
  8331. this._isUTC = true;
  8332. if (localAdjust != null) {
  8333. this.add(localAdjust, 'm');
  8334. }
  8335. if (offset !== input) {
  8336. if (!keepLocalTime || this._changeInProgress) {
  8337. addSubtract(this, createDuration(input - offset, 'm'), 1, false);
  8338. } else if (!this._changeInProgress) {
  8339. this._changeInProgress = true;
  8340. hooks.updateOffset(this, true);
  8341. this._changeInProgress = null;
  8342. }
  8343. }
  8344. return this;
  8345. } else {
  8346. return this._isUTC ? offset : getDateOffset(this);
  8347. }
  8348. }
  8349. function getSetZone (input, keepLocalTime) {
  8350. if (input != null) {
  8351. if (typeof input !== 'string') {
  8352. input = -input;
  8353. }
  8354. this.utcOffset(input, keepLocalTime);
  8355. return this;
  8356. } else {
  8357. return -this.utcOffset();
  8358. }
  8359. }
  8360. function setOffsetToUTC (keepLocalTime) {
  8361. return this.utcOffset(0, keepLocalTime);
  8362. }
  8363. function setOffsetToLocal (keepLocalTime) {
  8364. if (this._isUTC) {
  8365. this.utcOffset(0, keepLocalTime);
  8366. this._isUTC = false;
  8367. if (keepLocalTime) {
  8368. this.subtract(getDateOffset(this), 'm');
  8369. }
  8370. }
  8371. return this;
  8372. }
  8373. function setOffsetToParsedOffset () {
  8374. if (this._tzm != null) {
  8375. this.utcOffset(this._tzm, false, true);
  8376. } else if (typeof this._i === 'string') {
  8377. var tZone = offsetFromString(matchOffset, this._i);
  8378. if (tZone != null) {
  8379. this.utcOffset(tZone);
  8380. }
  8381. else {
  8382. this.utcOffset(0, true);
  8383. }
  8384. }
  8385. return this;
  8386. }
  8387. function hasAlignedHourOffset (input) {
  8388. if (!this.isValid()) {
  8389. return false;
  8390. }
  8391. input = input ? createLocal(input).utcOffset() : 0;
  8392. return (this.utcOffset() - input) % 60 === 0;
  8393. }
  8394. function isDaylightSavingTime () {
  8395. return (
  8396. this.utcOffset() > this.clone().month(0).utcOffset() ||
  8397. this.utcOffset() > this.clone().month(5).utcOffset()
  8398. );
  8399. }
  8400. function isDaylightSavingTimeShifted () {
  8401. if (!isUndefined(this._isDSTShifted)) {
  8402. return this._isDSTShifted;
  8403. }
  8404. var c = {};
  8405. copyConfig(c, this);
  8406. c = prepareConfig(c);
  8407. if (c._a) {
  8408. var other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
  8409. this._isDSTShifted = this.isValid() &&
  8410. compareArrays(c._a, other.toArray()) > 0;
  8411. } else {
  8412. this._isDSTShifted = false;
  8413. }
  8414. return this._isDSTShifted;
  8415. }
  8416. function isLocal () {
  8417. return this.isValid() ? !this._isUTC : false;
  8418. }
  8419. function isUtcOffset () {
  8420. return this.isValid() ? this._isUTC : false;
  8421. }
  8422. function isUtc () {
  8423. return this.isValid() ? this._isUTC && this._offset === 0 : false;
  8424. }
  8425. // ASP.NET json date format regex
  8426. var aspNetRegex = /^(\-|\+)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/;
  8427. // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
  8428. // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
  8429. // and further modified to allow for strings containing both week and day
  8430. var isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
  8431. function createDuration (input, key) {
  8432. var duration = input,
  8433. // matching against regexp is expensive, do it on demand
  8434. match = null,
  8435. sign,
  8436. ret,
  8437. diffRes;
  8438. if (isDuration(input)) {
  8439. duration = {
  8440. ms : input._milliseconds,
  8441. d : input._days,
  8442. M : input._months
  8443. };
  8444. } else if (isNumber(input)) {
  8445. duration = {};
  8446. if (key) {
  8447. duration[key] = input;
  8448. } else {
  8449. duration.milliseconds = input;
  8450. }
  8451. } else if (!!(match = aspNetRegex.exec(input))) {
  8452. sign = (match[1] === '-') ? -1 : 1;
  8453. duration = {
  8454. y : 0,
  8455. d : toInt(match[DATE]) * sign,
  8456. h : toInt(match[HOUR]) * sign,
  8457. m : toInt(match[MINUTE]) * sign,
  8458. s : toInt(match[SECOND]) * sign,
  8459. ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match
  8460. };
  8461. } else if (!!(match = isoRegex.exec(input))) {
  8462. sign = (match[1] === '-') ? -1 : (match[1] === '+') ? 1 : 1;
  8463. duration = {
  8464. y : parseIso(match[2], sign),
  8465. M : parseIso(match[3], sign),
  8466. w : parseIso(match[4], sign),
  8467. d : parseIso(match[5], sign),
  8468. h : parseIso(match[6], sign),
  8469. m : parseIso(match[7], sign),
  8470. s : parseIso(match[8], sign)
  8471. };
  8472. } else if (duration == null) {// checks for null or undefined
  8473. duration = {};
  8474. } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
  8475. diffRes = momentsDifference(createLocal(duration.from), createLocal(duration.to));
  8476. duration = {};
  8477. duration.ms = diffRes.milliseconds;
  8478. duration.M = diffRes.months;
  8479. }
  8480. ret = new Duration(duration);
  8481. if (isDuration(input) && hasOwnProp(input, '_locale')) {
  8482. ret._locale = input._locale;
  8483. }
  8484. return ret;
  8485. }
  8486. createDuration.fn = Duration.prototype;
  8487. createDuration.invalid = createInvalid$1;
  8488. function parseIso (inp, sign) {
  8489. // We'd normally use ~~inp for this, but unfortunately it also
  8490. // converts floats to ints.
  8491. // inp may be undefined, so careful calling replace on it.
  8492. var res = inp && parseFloat(inp.replace(',', '.'));
  8493. // apply sign while we're at it
  8494. return (isNaN(res) ? 0 : res) * sign;
  8495. }
  8496. function positiveMomentsDifference(base, other) {
  8497. var res = {milliseconds: 0, months: 0};
  8498. res.months = other.month() - base.month() +
  8499. (other.year() - base.year()) * 12;
  8500. if (base.clone().add(res.months, 'M').isAfter(other)) {
  8501. --res.months;
  8502. }
  8503. res.milliseconds = +other - +(base.clone().add(res.months, 'M'));
  8504. return res;
  8505. }
  8506. function momentsDifference(base, other) {
  8507. var res;
  8508. if (!(base.isValid() && other.isValid())) {
  8509. return {milliseconds: 0, months: 0};
  8510. }
  8511. other = cloneWithOffset(other, base);
  8512. if (base.isBefore(other)) {
  8513. res = positiveMomentsDifference(base, other);
  8514. } else {
  8515. res = positiveMomentsDifference(other, base);
  8516. res.milliseconds = -res.milliseconds;
  8517. res.months = -res.months;
  8518. }
  8519. return res;
  8520. }
  8521. // TODO: remove 'name' arg after deprecation is removed
  8522. function createAdder(direction, name) {
  8523. return function (val, period) {
  8524. var dur, tmp;
  8525. //invert the arguments, but complain about it
  8526. if (period !== null && !isNaN(+period)) {
  8527. deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period). ' +
  8528. 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.');
  8529. tmp = val; val = period; period = tmp;
  8530. }
  8531. val = typeof val === 'string' ? +val : val;
  8532. dur = createDuration(val, period);
  8533. addSubtract(this, dur, direction);
  8534. return this;
  8535. };
  8536. }
  8537. function addSubtract (mom, duration, isAdding, updateOffset) {
  8538. var milliseconds = duration._milliseconds,
  8539. days = absRound(duration._days),
  8540. months = absRound(duration._months);
  8541. if (!mom.isValid()) {
  8542. // No op
  8543. return;
  8544. }
  8545. updateOffset = updateOffset == null ? true : updateOffset;
  8546. if (months) {
  8547. setMonth(mom, get(mom, 'Month') + months * isAdding);
  8548. }
  8549. if (days) {
  8550. set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
  8551. }
  8552. if (milliseconds) {
  8553. mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
  8554. }
  8555. if (updateOffset) {
  8556. hooks.updateOffset(mom, days || months);
  8557. }
  8558. }
  8559. var add = createAdder(1, 'add');
  8560. var subtract = createAdder(-1, 'subtract');
  8561. function getCalendarFormat(myMoment, now) {
  8562. var diff = myMoment.diff(now, 'days', true);
  8563. return diff < -6 ? 'sameElse' :
  8564. diff < -1 ? 'lastWeek' :
  8565. diff < 0 ? 'lastDay' :
  8566. diff < 1 ? 'sameDay' :
  8567. diff < 2 ? 'nextDay' :
  8568. diff < 7 ? 'nextWeek' : 'sameElse';
  8569. }
  8570. function calendar$1 (time, formats) {
  8571. // We want to compare the start of today, vs this.
  8572. // Getting start-of-today depends on whether we're local/utc/offset or not.
  8573. var now = time || createLocal(),
  8574. sod = cloneWithOffset(now, this).startOf('day'),
  8575. format = hooks.calendarFormat(this, sod) || 'sameElse';
  8576. var output = formats && (isFunction(formats[format]) ? formats[format].call(this, now) : formats[format]);
  8577. return this.format(output || this.localeData().calendar(format, this, createLocal(now)));
  8578. }
  8579. function clone () {
  8580. return new Moment(this);
  8581. }
  8582. function isAfter (input, units) {
  8583. var localInput = isMoment(input) ? input : createLocal(input);
  8584. if (!(this.isValid() && localInput.isValid())) {
  8585. return false;
  8586. }
  8587. units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
  8588. if (units === 'millisecond') {
  8589. return this.valueOf() > localInput.valueOf();
  8590. } else {
  8591. return localInput.valueOf() < this.clone().startOf(units).valueOf();
  8592. }
  8593. }
  8594. function isBefore (input, units) {
  8595. var localInput = isMoment(input) ? input : createLocal(input);
  8596. if (!(this.isValid() && localInput.isValid())) {
  8597. return false;
  8598. }
  8599. units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
  8600. if (units === 'millisecond') {
  8601. return this.valueOf() < localInput.valueOf();
  8602. } else {
  8603. return this.clone().endOf(units).valueOf() < localInput.valueOf();
  8604. }
  8605. }
  8606. function isBetween (from, to, units, inclusivity) {
  8607. inclusivity = inclusivity || '()';
  8608. return (inclusivity[0] === '(' ? this.isAfter(from, units) : !this.isBefore(from, units)) &&
  8609. (inclusivity[1] === ')' ? this.isBefore(to, units) : !this.isAfter(to, units));
  8610. }
  8611. function isSame (input, units) {
  8612. var localInput = isMoment(input) ? input : createLocal(input),
  8613. inputMs;
  8614. if (!(this.isValid() && localInput.isValid())) {
  8615. return false;
  8616. }
  8617. units = normalizeUnits(units || 'millisecond');
  8618. if (units === 'millisecond') {
  8619. return this.valueOf() === localInput.valueOf();
  8620. } else {
  8621. inputMs = localInput.valueOf();
  8622. return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
  8623. }
  8624. }
  8625. function isSameOrAfter (input, units) {
  8626. return this.isSame(input, units) || this.isAfter(input,units);
  8627. }
  8628. function isSameOrBefore (input, units) {
  8629. return this.isSame(input, units) || this.isBefore(input,units);
  8630. }
  8631. function diff (input, units, asFloat) {
  8632. var that,
  8633. zoneDelta,
  8634. delta, output;
  8635. if (!this.isValid()) {
  8636. return NaN;
  8637. }
  8638. that = cloneWithOffset(input, this);
  8639. if (!that.isValid()) {
  8640. return NaN;
  8641. }
  8642. zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
  8643. units = normalizeUnits(units);
  8644. switch (units) {
  8645. case 'year': output = monthDiff(this, that) / 12; break;
  8646. case 'month': output = monthDiff(this, that); break;
  8647. case 'quarter': output = monthDiff(this, that) / 3; break;
  8648. case 'second': output = (this - that) / 1e3; break; // 1000
  8649. case 'minute': output = (this - that) / 6e4; break; // 1000 * 60
  8650. case 'hour': output = (this - that) / 36e5; break; // 1000 * 60 * 60
  8651. case 'day': output = (this - that - zoneDelta) / 864e5; break; // 1000 * 60 * 60 * 24, negate dst
  8652. case 'week': output = (this - that - zoneDelta) / 6048e5; break; // 1000 * 60 * 60 * 24 * 7, negate dst
  8653. default: output = this - that;
  8654. }
  8655. return asFloat ? output : absFloor(output);
  8656. }
  8657. function monthDiff (a, b) {
  8658. // difference in months
  8659. var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
  8660. // b is in (anchor - 1 month, anchor + 1 month)
  8661. anchor = a.clone().add(wholeMonthDiff, 'months'),
  8662. anchor2, adjust;
  8663. if (b - anchor < 0) {
  8664. anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
  8665. // linear across the month
  8666. adjust = (b - anchor) / (anchor - anchor2);
  8667. } else {
  8668. anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
  8669. // linear across the month
  8670. adjust = (b - anchor) / (anchor2 - anchor);
  8671. }
  8672. //check for negative zero, return zero if negative zero
  8673. return -(wholeMonthDiff + adjust) || 0;
  8674. }
  8675. hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
  8676. hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
  8677. function toString () {
  8678. return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
  8679. }
  8680. function toISOString(keepOffset) {
  8681. if (!this.isValid()) {
  8682. return null;
  8683. }
  8684. var utc = keepOffset !== true;
  8685. var m = utc ? this.clone().utc() : this;
  8686. if (m.year() < 0 || m.year() > 9999) {
  8687. return formatMoment(m, utc ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ');
  8688. }
  8689. if (isFunction(Date.prototype.toISOString)) {
  8690. // native implementation is ~50x faster, use it when we can
  8691. if (utc) {
  8692. return this.toDate().toISOString();
  8693. } else {
  8694. return new Date(this._d.valueOf()).toISOString().replace('Z', formatMoment(m, 'Z'));
  8695. }
  8696. }
  8697. return formatMoment(m, utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ');
  8698. }
  8699. /**
  8700. * Return a human readable representation of a moment that can
  8701. * also be evaluated to get a new moment which is the same
  8702. *
  8703. * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects
  8704. */
  8705. function inspect () {
  8706. if (!this.isValid()) {
  8707. return 'moment.invalid(/* ' + this._i + ' */)';
  8708. }
  8709. var func = 'moment';
  8710. var zone = '';
  8711. if (!this.isLocal()) {
  8712. func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
  8713. zone = 'Z';
  8714. }
  8715. var prefix = '[' + func + '("]';
  8716. var year = (0 <= this.year() && this.year() <= 9999) ? 'YYYY' : 'YYYYYY';
  8717. var datetime = '-MM-DD[T]HH:mm:ss.SSS';
  8718. var suffix = zone + '[")]';
  8719. return this.format(prefix + year + datetime + suffix);
  8720. }
  8721. function format (inputString) {
  8722. if (!inputString) {
  8723. inputString = this.isUtc() ? hooks.defaultFormatUtc : hooks.defaultFormat;
  8724. }
  8725. var output = formatMoment(this, inputString);
  8726. return this.localeData().postformat(output);
  8727. }
  8728. function from (time, withoutSuffix) {
  8729. if (this.isValid() &&
  8730. ((isMoment(time) && time.isValid()) ||
  8731. createLocal(time).isValid())) {
  8732. return createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
  8733. } else {
  8734. return this.localeData().invalidDate();
  8735. }
  8736. }
  8737. function fromNow (withoutSuffix) {
  8738. return this.from(createLocal(), withoutSuffix);
  8739. }
  8740. function to (time, withoutSuffix) {
  8741. if (this.isValid() &&
  8742. ((isMoment(time) && time.isValid()) ||
  8743. createLocal(time).isValid())) {
  8744. return createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix);
  8745. } else {
  8746. return this.localeData().invalidDate();
  8747. }
  8748. }
  8749. function toNow (withoutSuffix) {
  8750. return this.to(createLocal(), withoutSuffix);
  8751. }
  8752. // If passed a locale key, it will set the locale for this
  8753. // instance. Otherwise, it will return the locale configuration
  8754. // variables for this instance.
  8755. function locale (key) {
  8756. var newLocaleData;
  8757. if (key === undefined) {
  8758. return this._locale._abbr;
  8759. } else {
  8760. newLocaleData = getLocale(key);
  8761. if (newLocaleData != null) {
  8762. this._locale = newLocaleData;
  8763. }
  8764. return this;
  8765. }
  8766. }
  8767. var lang = deprecate(
  8768. 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
  8769. function (key) {
  8770. if (key === undefined) {
  8771. return this.localeData();
  8772. } else {
  8773. return this.locale(key);
  8774. }
  8775. }
  8776. );
  8777. function localeData () {
  8778. return this._locale;
  8779. }
  8780. function startOf (units) {
  8781. units = normalizeUnits(units);
  8782. // the following switch intentionally omits break keywords
  8783. // to utilize falling through the cases.
  8784. switch (units) {
  8785. case 'year':
  8786. this.month(0);
  8787. /* falls through */
  8788. case 'quarter':
  8789. case 'month':
  8790. this.date(1);
  8791. /* falls through */
  8792. case 'week':
  8793. case 'isoWeek':
  8794. case 'day':
  8795. case 'date':
  8796. this.hours(0);
  8797. /* falls through */
  8798. case 'hour':
  8799. this.minutes(0);
  8800. /* falls through */
  8801. case 'minute':
  8802. this.seconds(0);
  8803. /* falls through */
  8804. case 'second':
  8805. this.milliseconds(0);
  8806. }
  8807. // weeks are a special case
  8808. if (units === 'week') {
  8809. this.weekday(0);
  8810. }
  8811. if (units === 'isoWeek') {
  8812. this.isoWeekday(1);
  8813. }
  8814. // quarters are also special
  8815. if (units === 'quarter') {
  8816. this.month(Math.floor(this.month() / 3) * 3);
  8817. }
  8818. return this;
  8819. }
  8820. function endOf (units) {
  8821. units = normalizeUnits(units);
  8822. if (units === undefined || units === 'millisecond') {
  8823. return this;
  8824. }
  8825. // 'date' is an alias for 'day', so it should be considered as such.
  8826. if (units === 'date') {
  8827. units = 'day';
  8828. }
  8829. return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
  8830. }
  8831. function valueOf () {
  8832. return this._d.valueOf() - ((this._offset || 0) * 60000);
  8833. }
  8834. function unix () {
  8835. return Math.floor(this.valueOf() / 1000);
  8836. }
  8837. function toDate () {
  8838. return new Date(this.valueOf());
  8839. }
  8840. function toArray () {
  8841. var m = this;
  8842. return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
  8843. }
  8844. function toObject () {
  8845. var m = this;
  8846. return {
  8847. years: m.year(),
  8848. months: m.month(),
  8849. date: m.date(),
  8850. hours: m.hours(),
  8851. minutes: m.minutes(),
  8852. seconds: m.seconds(),
  8853. milliseconds: m.milliseconds()
  8854. };
  8855. }
  8856. function toJSON () {
  8857. // new Date(NaN).toJSON() === null
  8858. return this.isValid() ? this.toISOString() : null;
  8859. }
  8860. function isValid$2 () {
  8861. return isValid(this);
  8862. }
  8863. function parsingFlags () {
  8864. return extend({}, getParsingFlags(this));
  8865. }
  8866. function invalidAt () {
  8867. return getParsingFlags(this).overflow;
  8868. }
  8869. function creationData() {
  8870. return {
  8871. input: this._i,
  8872. format: this._f,
  8873. locale: this._locale,
  8874. isUTC: this._isUTC,
  8875. strict: this._strict
  8876. };
  8877. }
  8878. // FORMATTING
  8879. addFormatToken(0, ['gg', 2], 0, function () {
  8880. return this.weekYear() % 100;
  8881. });
  8882. addFormatToken(0, ['GG', 2], 0, function () {
  8883. return this.isoWeekYear() % 100;
  8884. });
  8885. function addWeekYearFormatToken (token, getter) {
  8886. addFormatToken(0, [token, token.length], 0, getter);
  8887. }
  8888. addWeekYearFormatToken('gggg', 'weekYear');
  8889. addWeekYearFormatToken('ggggg', 'weekYear');
  8890. addWeekYearFormatToken('GGGG', 'isoWeekYear');
  8891. addWeekYearFormatToken('GGGGG', 'isoWeekYear');
  8892. // ALIASES
  8893. addUnitAlias('weekYear', 'gg');
  8894. addUnitAlias('isoWeekYear', 'GG');
  8895. // PRIORITY
  8896. addUnitPriority('weekYear', 1);
  8897. addUnitPriority('isoWeekYear', 1);
  8898. // PARSING
  8899. addRegexToken('G', matchSigned);
  8900. addRegexToken('g', matchSigned);
  8901. addRegexToken('GG', match1to2, match2);
  8902. addRegexToken('gg', match1to2, match2);
  8903. addRegexToken('GGGG', match1to4, match4);
  8904. addRegexToken('gggg', match1to4, match4);
  8905. addRegexToken('GGGGG', match1to6, match6);
  8906. addRegexToken('ggggg', match1to6, match6);
  8907. addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
  8908. week[token.substr(0, 2)] = toInt(input);
  8909. });
  8910. addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
  8911. week[token] = hooks.parseTwoDigitYear(input);
  8912. });
  8913. // MOMENTS
  8914. function getSetWeekYear (input) {
  8915. return getSetWeekYearHelper.call(this,
  8916. input,
  8917. this.week(),
  8918. this.weekday(),
  8919. this.localeData()._week.dow,
  8920. this.localeData()._week.doy);
  8921. }
  8922. function getSetISOWeekYear (input) {
  8923. return getSetWeekYearHelper.call(this,
  8924. input, this.isoWeek(), this.isoWeekday(), 1, 4);
  8925. }
  8926. function getISOWeeksInYear () {
  8927. return weeksInYear(this.year(), 1, 4);
  8928. }
  8929. function getWeeksInYear () {
  8930. var weekInfo = this.localeData()._week;
  8931. return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
  8932. }
  8933. function getSetWeekYearHelper(input, week, weekday, dow, doy) {
  8934. var weeksTarget;
  8935. if (input == null) {
  8936. return weekOfYear(this, dow, doy).year;
  8937. } else {
  8938. weeksTarget = weeksInYear(input, dow, doy);
  8939. if (week > weeksTarget) {
  8940. week = weeksTarget;
  8941. }
  8942. return setWeekAll.call(this, input, week, weekday, dow, doy);
  8943. }
  8944. }
  8945. function setWeekAll(weekYear, week, weekday, dow, doy) {
  8946. var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
  8947. date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
  8948. this.year(date.getUTCFullYear());
  8949. this.month(date.getUTCMonth());
  8950. this.date(date.getUTCDate());
  8951. return this;
  8952. }
  8953. // FORMATTING
  8954. addFormatToken('Q', 0, 'Qo', 'quarter');
  8955. // ALIASES
  8956. addUnitAlias('quarter', 'Q');
  8957. // PRIORITY
  8958. addUnitPriority('quarter', 7);
  8959. // PARSING
  8960. addRegexToken('Q', match1);
  8961. addParseToken('Q', function (input, array) {
  8962. array[MONTH] = (toInt(input) - 1) * 3;
  8963. });
  8964. // MOMENTS
  8965. function getSetQuarter (input) {
  8966. return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
  8967. }
  8968. // FORMATTING
  8969. addFormatToken('D', ['DD', 2], 'Do', 'date');
  8970. // ALIASES
  8971. addUnitAlias('date', 'D');
  8972. // PRIOROITY
  8973. addUnitPriority('date', 9);
  8974. // PARSING
  8975. addRegexToken('D', match1to2);
  8976. addRegexToken('DD', match1to2, match2);
  8977. addRegexToken('Do', function (isStrict, locale) {
  8978. // TODO: Remove "ordinalParse" fallback in next major release.
  8979. return isStrict ?
  8980. (locale._dayOfMonthOrdinalParse || locale._ordinalParse) :
  8981. locale._dayOfMonthOrdinalParseLenient;
  8982. });
  8983. addParseToken(['D', 'DD'], DATE);
  8984. addParseToken('Do', function (input, array) {
  8985. array[DATE] = toInt(input.match(match1to2)[0]);
  8986. });
  8987. // MOMENTS
  8988. var getSetDayOfMonth = makeGetSet('Date', true);
  8989. // FORMATTING
  8990. addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
  8991. // ALIASES
  8992. addUnitAlias('dayOfYear', 'DDD');
  8993. // PRIORITY
  8994. addUnitPriority('dayOfYear', 4);
  8995. // PARSING
  8996. addRegexToken('DDD', match1to3);
  8997. addRegexToken('DDDD', match3);
  8998. addParseToken(['DDD', 'DDDD'], function (input, array, config) {
  8999. config._dayOfYear = toInt(input);
  9000. });
  9001. // HELPERS
  9002. // MOMENTS
  9003. function getSetDayOfYear (input) {
  9004. var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
  9005. return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
  9006. }
  9007. // FORMATTING
  9008. addFormatToken('m', ['mm', 2], 0, 'minute');
  9009. // ALIASES
  9010. addUnitAlias('minute', 'm');
  9011. // PRIORITY
  9012. addUnitPriority('minute', 14);
  9013. // PARSING
  9014. addRegexToken('m', match1to2);
  9015. addRegexToken('mm', match1to2, match2);
  9016. addParseToken(['m', 'mm'], MINUTE);
  9017. // MOMENTS
  9018. var getSetMinute = makeGetSet('Minutes', false);
  9019. // FORMATTING
  9020. addFormatToken('s', ['ss', 2], 0, 'second');
  9021. // ALIASES
  9022. addUnitAlias('second', 's');
  9023. // PRIORITY
  9024. addUnitPriority('second', 15);
  9025. // PARSING
  9026. addRegexToken('s', match1to2);
  9027. addRegexToken('ss', match1to2, match2);
  9028. addParseToken(['s', 'ss'], SECOND);
  9029. // MOMENTS
  9030. var getSetSecond = makeGetSet('Seconds', false);
  9031. // FORMATTING
  9032. addFormatToken('S', 0, 0, function () {
  9033. return ~~(this.millisecond() / 100);
  9034. });
  9035. addFormatToken(0, ['SS', 2], 0, function () {
  9036. return ~~(this.millisecond() / 10);
  9037. });
  9038. addFormatToken(0, ['SSS', 3], 0, 'millisecond');
  9039. addFormatToken(0, ['SSSS', 4], 0, function () {
  9040. return this.millisecond() * 10;
  9041. });
  9042. addFormatToken(0, ['SSSSS', 5], 0, function () {
  9043. return this.millisecond() * 100;
  9044. });
  9045. addFormatToken(0, ['SSSSSS', 6], 0, function () {
  9046. return this.millisecond() * 1000;
  9047. });
  9048. addFormatToken(0, ['SSSSSSS', 7], 0, function () {
  9049. return this.millisecond() * 10000;
  9050. });
  9051. addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
  9052. return this.millisecond() * 100000;
  9053. });
  9054. addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
  9055. return this.millisecond() * 1000000;
  9056. });
  9057. // ALIASES
  9058. addUnitAlias('millisecond', 'ms');
  9059. // PRIORITY
  9060. addUnitPriority('millisecond', 16);
  9061. // PARSING
  9062. addRegexToken('S', match1to3, match1);
  9063. addRegexToken('SS', match1to3, match2);
  9064. addRegexToken('SSS', match1to3, match3);
  9065. var token;
  9066. for (token = 'SSSS'; token.length <= 9; token += 'S') {
  9067. addRegexToken(token, matchUnsigned);
  9068. }
  9069. function parseMs(input, array) {
  9070. array[MILLISECOND] = toInt(('0.' + input) * 1000);
  9071. }
  9072. for (token = 'S'; token.length <= 9; token += 'S') {
  9073. addParseToken(token, parseMs);
  9074. }
  9075. // MOMENTS
  9076. var getSetMillisecond = makeGetSet('Milliseconds', false);
  9077. // FORMATTING
  9078. addFormatToken('z', 0, 0, 'zoneAbbr');
  9079. addFormatToken('zz', 0, 0, 'zoneName');
  9080. // MOMENTS
  9081. function getZoneAbbr () {
  9082. return this._isUTC ? 'UTC' : '';
  9083. }
  9084. function getZoneName () {
  9085. return this._isUTC ? 'Coordinated Universal Time' : '';
  9086. }
  9087. var proto = Moment.prototype;
  9088. proto.add = add;
  9089. proto.calendar = calendar$1;
  9090. proto.clone = clone;
  9091. proto.diff = diff;
  9092. proto.endOf = endOf;
  9093. proto.format = format;
  9094. proto.from = from;
  9095. proto.fromNow = fromNow;
  9096. proto.to = to;
  9097. proto.toNow = toNow;
  9098. proto.get = stringGet;
  9099. proto.invalidAt = invalidAt;
  9100. proto.isAfter = isAfter;
  9101. proto.isBefore = isBefore;
  9102. proto.isBetween = isBetween;
  9103. proto.isSame = isSame;
  9104. proto.isSameOrAfter = isSameOrAfter;
  9105. proto.isSameOrBefore = isSameOrBefore;
  9106. proto.isValid = isValid$2;
  9107. proto.lang = lang;
  9108. proto.locale = locale;
  9109. proto.localeData = localeData;
  9110. proto.max = prototypeMax;
  9111. proto.min = prototypeMin;
  9112. proto.parsingFlags = parsingFlags;
  9113. proto.set = stringSet;
  9114. proto.startOf = startOf;
  9115. proto.subtract = subtract;
  9116. proto.toArray = toArray;
  9117. proto.toObject = toObject;
  9118. proto.toDate = toDate;
  9119. proto.toISOString = toISOString;
  9120. proto.inspect = inspect;
  9121. proto.toJSON = toJSON;
  9122. proto.toString = toString;
  9123. proto.unix = unix;
  9124. proto.valueOf = valueOf;
  9125. proto.creationData = creationData;
  9126. // Year
  9127. proto.year = getSetYear;
  9128. proto.isLeapYear = getIsLeapYear;
  9129. // Week Year
  9130. proto.weekYear = getSetWeekYear;
  9131. proto.isoWeekYear = getSetISOWeekYear;
  9132. // Quarter
  9133. proto.quarter = proto.quarters = getSetQuarter;
  9134. // Month
  9135. proto.month = getSetMonth;
  9136. proto.daysInMonth = getDaysInMonth;
  9137. // Week
  9138. proto.week = proto.weeks = getSetWeek;
  9139. proto.isoWeek = proto.isoWeeks = getSetISOWeek;
  9140. proto.weeksInYear = getWeeksInYear;
  9141. proto.isoWeeksInYear = getISOWeeksInYear;
  9142. // Day
  9143. proto.date = getSetDayOfMonth;
  9144. proto.day = proto.days = getSetDayOfWeek;
  9145. proto.weekday = getSetLocaleDayOfWeek;
  9146. proto.isoWeekday = getSetISODayOfWeek;
  9147. proto.dayOfYear = getSetDayOfYear;
  9148. // Hour
  9149. proto.hour = proto.hours = getSetHour;
  9150. // Minute
  9151. proto.minute = proto.minutes = getSetMinute;
  9152. // Second
  9153. proto.second = proto.seconds = getSetSecond;
  9154. // Millisecond
  9155. proto.millisecond = proto.milliseconds = getSetMillisecond;
  9156. // Offset
  9157. proto.utcOffset = getSetOffset;
  9158. proto.utc = setOffsetToUTC;
  9159. proto.local = setOffsetToLocal;
  9160. proto.parseZone = setOffsetToParsedOffset;
  9161. proto.hasAlignedHourOffset = hasAlignedHourOffset;
  9162. proto.isDST = isDaylightSavingTime;
  9163. proto.isLocal = isLocal;
  9164. proto.isUtcOffset = isUtcOffset;
  9165. proto.isUtc = isUtc;
  9166. proto.isUTC = isUtc;
  9167. // Timezone
  9168. proto.zoneAbbr = getZoneAbbr;
  9169. proto.zoneName = getZoneName;
  9170. // Deprecations
  9171. proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
  9172. proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
  9173. proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
  9174. proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', getSetZone);
  9175. proto.isDSTShifted = deprecate('isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', isDaylightSavingTimeShifted);
  9176. function createUnix (input) {
  9177. return createLocal(input * 1000);
  9178. }
  9179. function createInZone () {
  9180. return createLocal.apply(null, arguments).parseZone();
  9181. }
  9182. function preParsePostFormat (string) {
  9183. return string;
  9184. }
  9185. var proto$1 = Locale.prototype;
  9186. proto$1.calendar = calendar;
  9187. proto$1.longDateFormat = longDateFormat;
  9188. proto$1.invalidDate = invalidDate;
  9189. proto$1.ordinal = ordinal;
  9190. proto$1.preparse = preParsePostFormat;
  9191. proto$1.postformat = preParsePostFormat;
  9192. proto$1.relativeTime = relativeTime;
  9193. proto$1.pastFuture = pastFuture;
  9194. proto$1.set = set;
  9195. // Month
  9196. proto$1.months = localeMonths;
  9197. proto$1.monthsShort = localeMonthsShort;
  9198. proto$1.monthsParse = localeMonthsParse;
  9199. proto$1.monthsRegex = monthsRegex;
  9200. proto$1.monthsShortRegex = monthsShortRegex;
  9201. // Week
  9202. proto$1.week = localeWeek;
  9203. proto$1.firstDayOfYear = localeFirstDayOfYear;
  9204. proto$1.firstDayOfWeek = localeFirstDayOfWeek;
  9205. // Day of Week
  9206. proto$1.weekdays = localeWeekdays;
  9207. proto$1.weekdaysMin = localeWeekdaysMin;
  9208. proto$1.weekdaysShort = localeWeekdaysShort;
  9209. proto$1.weekdaysParse = localeWeekdaysParse;
  9210. proto$1.weekdaysRegex = weekdaysRegex;
  9211. proto$1.weekdaysShortRegex = weekdaysShortRegex;
  9212. proto$1.weekdaysMinRegex = weekdaysMinRegex;
  9213. // Hours
  9214. proto$1.isPM = localeIsPM;
  9215. proto$1.meridiem = localeMeridiem;
  9216. function get$1 (format, index, field, setter) {
  9217. var locale = getLocale();
  9218. var utc = createUTC().set(setter, index);
  9219. return locale[field](utc, format);
  9220. }
  9221. function listMonthsImpl (format, index, field) {
  9222. if (isNumber(format)) {
  9223. index = format;
  9224. format = undefined;
  9225. }
  9226. format = format || '';
  9227. if (index != null) {
  9228. return get$1(format, index, field, 'month');
  9229. }
  9230. var i;
  9231. var out = [];
  9232. for (i = 0; i < 12; i++) {
  9233. out[i] = get$1(format, i, field, 'month');
  9234. }
  9235. return out;
  9236. }
  9237. // ()
  9238. // (5)
  9239. // (fmt, 5)
  9240. // (fmt)
  9241. // (true)
  9242. // (true, 5)
  9243. // (true, fmt, 5)
  9244. // (true, fmt)
  9245. function listWeekdaysImpl (localeSorted, format, index, field) {
  9246. if (typeof localeSorted === 'boolean') {
  9247. if (isNumber(format)) {
  9248. index = format;
  9249. format = undefined;
  9250. }
  9251. format = format || '';
  9252. } else {
  9253. format = localeSorted;
  9254. index = format;
  9255. localeSorted = false;
  9256. if (isNumber(format)) {
  9257. index = format;
  9258. format = undefined;
  9259. }
  9260. format = format || '';
  9261. }
  9262. var locale = getLocale(),
  9263. shift = localeSorted ? locale._week.dow : 0;
  9264. if (index != null) {
  9265. return get$1(format, (index + shift) % 7, field, 'day');
  9266. }
  9267. var i;
  9268. var out = [];
  9269. for (i = 0; i < 7; i++) {
  9270. out[i] = get$1(format, (i + shift) % 7, field, 'day');
  9271. }
  9272. return out;
  9273. }
  9274. function listMonths (format, index) {
  9275. return listMonthsImpl(format, index, 'months');
  9276. }
  9277. function listMonthsShort (format, index) {
  9278. return listMonthsImpl(format, index, 'monthsShort');
  9279. }
  9280. function listWeekdays (localeSorted, format, index) {
  9281. return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
  9282. }
  9283. function listWeekdaysShort (localeSorted, format, index) {
  9284. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
  9285. }
  9286. function listWeekdaysMin (localeSorted, format, index) {
  9287. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
  9288. }
  9289. getSetGlobalLocale('en', {
  9290. dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
  9291. ordinal : function (number) {
  9292. var b = number % 10,
  9293. output = (toInt(number % 100 / 10) === 1) ? 'th' :
  9294. (b === 1) ? 'st' :
  9295. (b === 2) ? 'nd' :
  9296. (b === 3) ? 'rd' : 'th';
  9297. return number + output;
  9298. }
  9299. });
  9300. // Side effect imports
  9301. hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', getSetGlobalLocale);
  9302. hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', getLocale);
  9303. var mathAbs = Math.abs;
  9304. function abs () {
  9305. var data = this._data;
  9306. this._milliseconds = mathAbs(this._milliseconds);
  9307. this._days = mathAbs(this._days);
  9308. this._months = mathAbs(this._months);
  9309. data.milliseconds = mathAbs(data.milliseconds);
  9310. data.seconds = mathAbs(data.seconds);
  9311. data.minutes = mathAbs(data.minutes);
  9312. data.hours = mathAbs(data.hours);
  9313. data.months = mathAbs(data.months);
  9314. data.years = mathAbs(data.years);
  9315. return this;
  9316. }
  9317. function addSubtract$1 (duration, input, value, direction) {
  9318. var other = createDuration(input, value);
  9319. duration._milliseconds += direction * other._milliseconds;
  9320. duration._days += direction * other._days;
  9321. duration._months += direction * other._months;
  9322. return duration._bubble();
  9323. }
  9324. // supports only 2.0-style add(1, 's') or add(duration)
  9325. function add$1 (input, value) {
  9326. return addSubtract$1(this, input, value, 1);
  9327. }
  9328. // supports only 2.0-style subtract(1, 's') or subtract(duration)
  9329. function subtract$1 (input, value) {
  9330. return addSubtract$1(this, input, value, -1);
  9331. }
  9332. function absCeil (number) {
  9333. if (number < 0) {
  9334. return Math.floor(number);
  9335. } else {
  9336. return Math.ceil(number);
  9337. }
  9338. }
  9339. function bubble () {
  9340. var milliseconds = this._milliseconds;
  9341. var days = this._days;
  9342. var months = this._months;
  9343. var data = this._data;
  9344. var seconds, minutes, hours, years, monthsFromDays;
  9345. // if we have a mix of positive and negative values, bubble down first
  9346. // check: https://github.com/moment/moment/issues/2166
  9347. if (!((milliseconds >= 0 && days >= 0 && months >= 0) ||
  9348. (milliseconds <= 0 && days <= 0 && months <= 0))) {
  9349. milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
  9350. days = 0;
  9351. months = 0;
  9352. }
  9353. // The following code bubbles up values, see the tests for
  9354. // examples of what that means.
  9355. data.milliseconds = milliseconds % 1000;
  9356. seconds = absFloor(milliseconds / 1000);
  9357. data.seconds = seconds % 60;
  9358. minutes = absFloor(seconds / 60);
  9359. data.minutes = minutes % 60;
  9360. hours = absFloor(minutes / 60);
  9361. data.hours = hours % 24;
  9362. days += absFloor(hours / 24);
  9363. // convert days to months
  9364. monthsFromDays = absFloor(daysToMonths(days));
  9365. months += monthsFromDays;
  9366. days -= absCeil(monthsToDays(monthsFromDays));
  9367. // 12 months -> 1 year
  9368. years = absFloor(months / 12);
  9369. months %= 12;
  9370. data.days = days;
  9371. data.months = months;
  9372. data.years = years;
  9373. return this;
  9374. }
  9375. function daysToMonths (days) {
  9376. // 400 years have 146097 days (taking into account leap year rules)
  9377. // 400 years have 12 months === 4800
  9378. return days * 4800 / 146097;
  9379. }
  9380. function monthsToDays (months) {
  9381. // the reverse of daysToMonths
  9382. return months * 146097 / 4800;
  9383. }
  9384. function as (units) {
  9385. if (!this.isValid()) {
  9386. return NaN;
  9387. }
  9388. var days;
  9389. var months;
  9390. var milliseconds = this._milliseconds;
  9391. units = normalizeUnits(units);
  9392. if (units === 'month' || units === 'year') {
  9393. days = this._days + milliseconds / 864e5;
  9394. months = this._months + daysToMonths(days);
  9395. return units === 'month' ? months : months / 12;
  9396. } else {
  9397. // handle milliseconds separately because of floating point math errors (issue #1867)
  9398. days = this._days + Math.round(monthsToDays(this._months));
  9399. switch (units) {
  9400. case 'week' : return days / 7 + milliseconds / 6048e5;
  9401. case 'day' : return days + milliseconds / 864e5;
  9402. case 'hour' : return days * 24 + milliseconds / 36e5;
  9403. case 'minute' : return days * 1440 + milliseconds / 6e4;
  9404. case 'second' : return days * 86400 + milliseconds / 1000;
  9405. // Math.floor prevents floating point math errors here
  9406. case 'millisecond': return Math.floor(days * 864e5) + milliseconds;
  9407. default: throw new Error('Unknown unit ' + units);
  9408. }
  9409. }
  9410. }
  9411. // TODO: Use this.as('ms')?
  9412. function valueOf$1 () {
  9413. if (!this.isValid()) {
  9414. return NaN;
  9415. }
  9416. return (
  9417. this._milliseconds +
  9418. this._days * 864e5 +
  9419. (this._months % 12) * 2592e6 +
  9420. toInt(this._months / 12) * 31536e6
  9421. );
  9422. }
  9423. function makeAs (alias) {
  9424. return function () {
  9425. return this.as(alias);
  9426. };
  9427. }
  9428. var asMilliseconds = makeAs('ms');
  9429. var asSeconds = makeAs('s');
  9430. var asMinutes = makeAs('m');
  9431. var asHours = makeAs('h');
  9432. var asDays = makeAs('d');
  9433. var asWeeks = makeAs('w');
  9434. var asMonths = makeAs('M');
  9435. var asYears = makeAs('y');
  9436. function clone$1 () {
  9437. return createDuration(this);
  9438. }
  9439. function get$2 (units) {
  9440. units = normalizeUnits(units);
  9441. return this.isValid() ? this[units + 's']() : NaN;
  9442. }
  9443. function makeGetter(name) {
  9444. return function () {
  9445. return this.isValid() ? this._data[name] : NaN;
  9446. };
  9447. }
  9448. var milliseconds = makeGetter('milliseconds');
  9449. var seconds = makeGetter('seconds');
  9450. var minutes = makeGetter('minutes');
  9451. var hours = makeGetter('hours');
  9452. var days = makeGetter('days');
  9453. var months = makeGetter('months');
  9454. var years = makeGetter('years');
  9455. function weeks () {
  9456. return absFloor(this.days() / 7);
  9457. }
  9458. var round = Math.round;
  9459. var thresholds = {
  9460. ss: 44, // a few seconds to seconds
  9461. s : 45, // seconds to minute
  9462. m : 45, // minutes to hour
  9463. h : 22, // hours to day
  9464. d : 26, // days to month
  9465. M : 11 // months to year
  9466. };
  9467. // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
  9468. function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
  9469. return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
  9470. }
  9471. function relativeTime$1 (posNegDuration, withoutSuffix, locale) {
  9472. var duration = createDuration(posNegDuration).abs();
  9473. var seconds = round(duration.as('s'));
  9474. var minutes = round(duration.as('m'));
  9475. var hours = round(duration.as('h'));
  9476. var days = round(duration.as('d'));
  9477. var months = round(duration.as('M'));
  9478. var years = round(duration.as('y'));
  9479. var a = seconds <= thresholds.ss && ['s', seconds] ||
  9480. seconds < thresholds.s && ['ss', seconds] ||
  9481. minutes <= 1 && ['m'] ||
  9482. minutes < thresholds.m && ['mm', minutes] ||
  9483. hours <= 1 && ['h'] ||
  9484. hours < thresholds.h && ['hh', hours] ||
  9485. days <= 1 && ['d'] ||
  9486. days < thresholds.d && ['dd', days] ||
  9487. months <= 1 && ['M'] ||
  9488. months < thresholds.M && ['MM', months] ||
  9489. years <= 1 && ['y'] || ['yy', years];
  9490. a[2] = withoutSuffix;
  9491. a[3] = +posNegDuration > 0;
  9492. a[4] = locale;
  9493. return substituteTimeAgo.apply(null, a);
  9494. }
  9495. // This function allows you to set the rounding function for relative time strings
  9496. function getSetRelativeTimeRounding (roundingFunction) {
  9497. if (roundingFunction === undefined) {
  9498. return round;
  9499. }
  9500. if (typeof(roundingFunction) === 'function') {
  9501. round = roundingFunction;
  9502. return true;
  9503. }
  9504. return false;
  9505. }
  9506. // This function allows you to set a threshold for relative time strings
  9507. function getSetRelativeTimeThreshold (threshold, limit) {
  9508. if (thresholds[threshold] === undefined) {
  9509. return false;
  9510. }
  9511. if (limit === undefined) {
  9512. return thresholds[threshold];
  9513. }
  9514. thresholds[threshold] = limit;
  9515. if (threshold === 's') {
  9516. thresholds.ss = limit - 1;
  9517. }
  9518. return true;
  9519. }
  9520. function humanize (withSuffix) {
  9521. if (!this.isValid()) {
  9522. return this.localeData().invalidDate();
  9523. }
  9524. var locale = this.localeData();
  9525. var output = relativeTime$1(this, !withSuffix, locale);
  9526. if (withSuffix) {
  9527. output = locale.pastFuture(+this, output);
  9528. }
  9529. return locale.postformat(output);
  9530. }
  9531. var abs$1 = Math.abs;
  9532. function sign(x) {
  9533. return ((x > 0) - (x < 0)) || +x;
  9534. }
  9535. function toISOString$1() {
  9536. // for ISO strings we do not use the normal bubbling rules:
  9537. // * milliseconds bubble up until they become hours
  9538. // * days do not bubble at all
  9539. // * months bubble up until they become years
  9540. // This is because there is no context-free conversion between hours and days
  9541. // (think of clock changes)
  9542. // and also not between days and months (28-31 days per month)
  9543. if (!this.isValid()) {
  9544. return this.localeData().invalidDate();
  9545. }
  9546. var seconds = abs$1(this._milliseconds) / 1000;
  9547. var days = abs$1(this._days);
  9548. var months = abs$1(this._months);
  9549. var minutes, hours, years;
  9550. // 3600 seconds -> 60 minutes -> 1 hour
  9551. minutes = absFloor(seconds / 60);
  9552. hours = absFloor(minutes / 60);
  9553. seconds %= 60;
  9554. minutes %= 60;
  9555. // 12 months -> 1 year
  9556. years = absFloor(months / 12);
  9557. months %= 12;
  9558. // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
  9559. var Y = years;
  9560. var M = months;
  9561. var D = days;
  9562. var h = hours;
  9563. var m = minutes;
  9564. var s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : '';
  9565. var total = this.asSeconds();
  9566. if (!total) {
  9567. // this is the same as C#'s (Noda) and python (isodate)...
  9568. // but not other JS (goog.date)
  9569. return 'P0D';
  9570. }
  9571. var totalSign = total < 0 ? '-' : '';
  9572. var ymSign = sign(this._months) !== sign(total) ? '-' : '';
  9573. var daysSign = sign(this._days) !== sign(total) ? '-' : '';
  9574. var hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : '';
  9575. return totalSign + 'P' +
  9576. (Y ? ymSign + Y + 'Y' : '') +
  9577. (M ? ymSign + M + 'M' : '') +
  9578. (D ? daysSign + D + 'D' : '') +
  9579. ((h || m || s) ? 'T' : '') +
  9580. (h ? hmsSign + h + 'H' : '') +
  9581. (m ? hmsSign + m + 'M' : '') +
  9582. (s ? hmsSign + s + 'S' : '');
  9583. }
  9584. var proto$2 = Duration.prototype;
  9585. proto$2.isValid = isValid$1;
  9586. proto$2.abs = abs;
  9587. proto$2.add = add$1;
  9588. proto$2.subtract = subtract$1;
  9589. proto$2.as = as;
  9590. proto$2.asMilliseconds = asMilliseconds;
  9591. proto$2.asSeconds = asSeconds;
  9592. proto$2.asMinutes = asMinutes;
  9593. proto$2.asHours = asHours;
  9594. proto$2.asDays = asDays;
  9595. proto$2.asWeeks = asWeeks;
  9596. proto$2.asMonths = asMonths;
  9597. proto$2.asYears = asYears;
  9598. proto$2.valueOf = valueOf$1;
  9599. proto$2._bubble = bubble;
  9600. proto$2.clone = clone$1;
  9601. proto$2.get = get$2;
  9602. proto$2.milliseconds = milliseconds;
  9603. proto$2.seconds = seconds;
  9604. proto$2.minutes = minutes;
  9605. proto$2.hours = hours;
  9606. proto$2.days = days;
  9607. proto$2.weeks = weeks;
  9608. proto$2.months = months;
  9609. proto$2.years = years;
  9610. proto$2.humanize = humanize;
  9611. proto$2.toISOString = toISOString$1;
  9612. proto$2.toString = toISOString$1;
  9613. proto$2.toJSON = toISOString$1;
  9614. proto$2.locale = locale;
  9615. proto$2.localeData = localeData;
  9616. // Deprecations
  9617. proto$2.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', toISOString$1);
  9618. proto$2.lang = lang;
  9619. // Side effect imports
  9620. // FORMATTING
  9621. addFormatToken('X', 0, 0, 'unix');
  9622. addFormatToken('x', 0, 0, 'valueOf');
  9623. // PARSING
  9624. addRegexToken('x', matchSigned);
  9625. addRegexToken('X', matchTimestamp);
  9626. addParseToken('X', function (input, array, config) {
  9627. config._d = new Date(parseFloat(input, 10) * 1000);
  9628. });
  9629. addParseToken('x', function (input, array, config) {
  9630. config._d = new Date(toInt(input));
  9631. });
  9632. // Side effect imports
  9633. hooks.version = '2.20.1';
  9634. setHookCallback(createLocal);
  9635. hooks.fn = proto;
  9636. hooks.min = min;
  9637. hooks.max = max;
  9638. hooks.now = now;
  9639. hooks.utc = createUTC;
  9640. hooks.unix = createUnix;
  9641. hooks.months = listMonths;
  9642. hooks.isDate = isDate;
  9643. hooks.locale = getSetGlobalLocale;
  9644. hooks.invalid = createInvalid;
  9645. hooks.duration = createDuration;
  9646. hooks.isMoment = isMoment;
  9647. hooks.weekdays = listWeekdays;
  9648. hooks.parseZone = createInZone;
  9649. hooks.localeData = getLocale;
  9650. hooks.isDuration = isDuration;
  9651. hooks.monthsShort = listMonthsShort;
  9652. hooks.weekdaysMin = listWeekdaysMin;
  9653. hooks.defineLocale = defineLocale;
  9654. hooks.updateLocale = updateLocale;
  9655. hooks.locales = listLocales;
  9656. hooks.weekdaysShort = listWeekdaysShort;
  9657. hooks.normalizeUnits = normalizeUnits;
  9658. hooks.relativeTimeRounding = getSetRelativeTimeRounding;
  9659. hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
  9660. hooks.calendarFormat = getCalendarFormat;
  9661. hooks.prototype = proto;
  9662. // currently HTML5 input type only supports 24-hour formats
  9663. hooks.HTML5_FMT = {
  9664. DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm', // <input type="datetime-local" />
  9665. DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss', // <input type="datetime-local" step="1" />
  9666. DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS', // <input type="datetime-local" step="0.001" />
  9667. DATE: 'YYYY-MM-DD', // <input type="date" />
  9668. TIME: 'HH:mm', // <input type="time" />
  9669. TIME_SECONDS: 'HH:mm:ss', // <input type="time" step="1" />
  9670. TIME_MS: 'HH:mm:ss.SSS', // <input type="time" step="0.001" />
  9671. WEEK: 'YYYY-[W]WW', // <input type="week" />
  9672. MONTH: 'YYYY-MM' // <input type="month" />
  9673. };
  9674. return hooks;
  9675. })));
  9676. /*** EXPORTS FROM exports-to-window-loader ***/
  9677. window['moment'] = __webpack_require__(41);
  9678. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(349)(module)))
  9679. /***/ }),
  9680. /* 42 */
  9681. /***/ (function(module, exports, __webpack_require__) {
  9682. "use strict";
  9683. exports.__esModule = true;
  9684. exports.toSingleLine = toSingleLine;
  9685. var _array = __webpack_require__(1);
  9686. /**
  9687. * Tags a multiline string and return new one without line break characters and following spaces.
  9688. *
  9689. * @param {Array} strings Parts of the entire string without expressions.
  9690. * @param {...String} expressions Expressions converted to strings, which are added to the entire string.
  9691. * @returns {String}
  9692. */
  9693. function toSingleLine(strings) {
  9694. for (var _len = arguments.length, expressions = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  9695. expressions[_key - 1] = arguments[_key];
  9696. }
  9697. var result = (0, _array.arrayReduce)(strings, function (previousValue, currentValue, index) {
  9698. var valueWithoutWhiteSpaces = currentValue.replace(/(?:\r?\n\s+)/g, '');
  9699. var expressionForIndex = expressions[index] ? expressions[index] : '';
  9700. return previousValue + valueWithoutWhiteSpaces + expressionForIndex;
  9701. }, '');
  9702. return result.trim();
  9703. } /* eslint-disable import/prefer-default-export */
  9704. /***/ }),
  9705. /* 43 */
  9706. /***/ (function(module, exports, __webpack_require__) {
  9707. "use strict";
  9708. exports.__esModule = true;
  9709. exports.isFunction = isFunction;
  9710. exports.throttle = throttle;
  9711. exports.throttleAfterHits = throttleAfterHits;
  9712. exports.debounce = debounce;
  9713. exports.pipe = pipe;
  9714. exports.partial = partial;
  9715. exports.curry = curry;
  9716. exports.curryRight = curryRight;
  9717. var _array = __webpack_require__(1);
  9718. /**
  9719. * Checks if given variable is function.
  9720. *
  9721. * @param {*} func Variable to check.
  9722. * @returns {Boolean}
  9723. */
  9724. function isFunction(func) {
  9725. return typeof func === 'function';
  9726. }
  9727. /**
  9728. * Creates throttle function that enforces a maximum number of times a function (`func`) can be called over time (`wait`).
  9729. *
  9730. * @param {Function} func Function to invoke.
  9731. * @param {Number} wait Delay in miliseconds.
  9732. * @returns {Function}
  9733. */
  9734. function throttle(func) {
  9735. var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
  9736. var lastCalled = 0;
  9737. var result = {
  9738. lastCallThrottled: true
  9739. };
  9740. var lastTimer = null;
  9741. function _throttle() {
  9742. var _this = this;
  9743. var args = arguments;
  9744. var stamp = Date.now();
  9745. var needCall = false;
  9746. result.lastCallThrottled = true;
  9747. if (!lastCalled) {
  9748. lastCalled = stamp;
  9749. needCall = true;
  9750. }
  9751. var remaining = wait - (stamp - lastCalled);
  9752. if (needCall) {
  9753. result.lastCallThrottled = false;
  9754. func.apply(this, args);
  9755. } else {
  9756. if (lastTimer) {
  9757. clearTimeout(lastTimer);
  9758. }
  9759. lastTimer = setTimeout(function () {
  9760. result.lastCallThrottled = false;
  9761. func.apply(_this, args);
  9762. lastCalled = 0;
  9763. lastTimer = void 0;
  9764. }, remaining);
  9765. }
  9766. return result;
  9767. }
  9768. return _throttle;
  9769. }
  9770. /**
  9771. * Creates throttle function that enforces a maximum number of times a function (`func`) can be called over
  9772. * time (`wait`) after specified hits.
  9773. *
  9774. * @param {Function} func Function to invoke.
  9775. * @param {Number} wait Delay in miliseconds.
  9776. * @param {Number} hits Number of hits after throttling will be applied.
  9777. * @returns {Function}
  9778. */
  9779. function throttleAfterHits(func) {
  9780. var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
  9781. var hits = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
  9782. var funcThrottle = throttle(func, wait);
  9783. var remainHits = hits;
  9784. function _clearHits() {
  9785. remainHits = hits;
  9786. }
  9787. function _throttleAfterHits() {
  9788. if (remainHits) {
  9789. remainHits--;
  9790. return func.apply(this, arguments);
  9791. }
  9792. return funcThrottle.apply(this, arguments);
  9793. }
  9794. _throttleAfterHits.clearHits = _clearHits;
  9795. return _throttleAfterHits;
  9796. }
  9797. /**
  9798. * Creates debounce function that enforces a function (`func`) not be called again until a certain amount of time (`wait`)
  9799. * has passed without it being called.
  9800. *
  9801. * @param {Function} func Function to invoke.
  9802. * @param {Number} wait Delay in milliseconds.
  9803. * @returns {Function}
  9804. */
  9805. function debounce(func) {
  9806. var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
  9807. var lastTimer = null;
  9808. var result = void 0;
  9809. function _debounce() {
  9810. var _this2 = this;
  9811. var args = arguments;
  9812. if (lastTimer) {
  9813. clearTimeout(lastTimer);
  9814. }
  9815. lastTimer = setTimeout(function () {
  9816. result = func.apply(_this2, args);
  9817. }, wait);
  9818. return result;
  9819. }
  9820. return _debounce;
  9821. }
  9822. /**
  9823. * Creates the function that returns the result of calling the given functions. Result of the first function is passed to
  9824. * the second as an argument and so on. Only first function in the chain can handle multiple arguments.
  9825. *
  9826. * @param {Function} functions Functions to compose.
  9827. * @returns {Function}
  9828. */
  9829. function pipe() {
  9830. for (var _len = arguments.length, functions = Array(_len), _key = 0; _key < _len; _key++) {
  9831. functions[_key] = arguments[_key];
  9832. }
  9833. var firstFunc = functions[0],
  9834. restFunc = functions.slice(1);
  9835. return function _pipe() {
  9836. return (0, _array.arrayReduce)(restFunc, function (acc, fn) {
  9837. return fn(acc);
  9838. }, firstFunc.apply(this, arguments));
  9839. };
  9840. }
  9841. /**
  9842. * Creates the function that returns the function with cached arguments.
  9843. *
  9844. * @param {Function} func Function to partialization.
  9845. * @param {Array} params Function arguments to cache.
  9846. * @returns {Function}
  9847. */
  9848. function partial(func) {
  9849. for (var _len2 = arguments.length, params = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  9850. params[_key2 - 1] = arguments[_key2];
  9851. }
  9852. return function _partial() {
  9853. for (var _len3 = arguments.length, restParams = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  9854. restParams[_key3] = arguments[_key3];
  9855. }
  9856. return func.apply(this, params.concat(restParams));
  9857. };
  9858. }
  9859. /**
  9860. * Creates the functions that returns the function with cached arguments. If count if passed arguments will be matched
  9861. * to the arguments defined in `func` then function will be invoked.
  9862. * Arguments are added to the stack in direction from the left to the right.
  9863. *
  9864. * @example
  9865. * ```
  9866. * var replace = curry(function(find, replace, string) {
  9867. * return string.replace(find, replace);
  9868. * });
  9869. *
  9870. * // returns function with bounded first argument
  9871. * var replace = replace('foo')
  9872. *
  9873. * // returns replaced string - all arguments was passed so function was invoked
  9874. * replace('bar', 'Some test with foo...');
  9875. *
  9876. * ```
  9877. *
  9878. * @param {Function} func Function to currying.
  9879. * @returns {Function}
  9880. */
  9881. function curry(func) {
  9882. var argsLength = func.length;
  9883. function given(argsSoFar) {
  9884. return function _curry() {
  9885. for (var _len4 = arguments.length, params = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
  9886. params[_key4] = arguments[_key4];
  9887. }
  9888. var passedArgsSoFar = argsSoFar.concat(params);
  9889. var result = void 0;
  9890. if (passedArgsSoFar.length >= argsLength) {
  9891. result = func.apply(this, passedArgsSoFar);
  9892. } else {
  9893. result = given(passedArgsSoFar);
  9894. }
  9895. return result;
  9896. };
  9897. }
  9898. return given([]);
  9899. }
  9900. /**
  9901. * Creates the functions that returns the function with cached arguments. If count if passed arguments will be matched
  9902. * to the arguments defined in `func` then function will be invoked.
  9903. * Arguments are added to the stack in direction from the right to the left.
  9904. *
  9905. * @example
  9906. * ```
  9907. * var replace = curry(function(find, replace, string) {
  9908. * return string.replace(find, replace);
  9909. * });
  9910. *
  9911. * // returns function with bounded first argument
  9912. * var replace = replace('Some test with foo...')
  9913. *
  9914. * // returns replaced string - all arguments was passed so function was invoked
  9915. * replace('bar', 'foo');
  9916. *
  9917. * ```
  9918. *
  9919. * @param {Function} func Function to currying.
  9920. * @returns {Function}
  9921. */
  9922. function curryRight(func) {
  9923. var argsLength = func.length;
  9924. function given(argsSoFar) {
  9925. return function _curry() {
  9926. for (var _len5 = arguments.length, params = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
  9927. params[_key5] = arguments[_key5];
  9928. }
  9929. var passedArgsSoFar = argsSoFar.concat(params.reverse());
  9930. var result = void 0;
  9931. if (passedArgsSoFar.length >= argsLength) {
  9932. result = func.apply(this, passedArgsSoFar);
  9933. } else {
  9934. result = given(passedArgsSoFar);
  9935. }
  9936. return result;
  9937. };
  9938. }
  9939. return given([]);
  9940. }
  9941. /***/ }),
  9942. /* 44 */
  9943. /***/ (function(module, exports) {
  9944. var toString = {}.toString;
  9945. module.exports = function (it) {
  9946. return toString.call(it).slice(8, -1);
  9947. };
  9948. /***/ }),
  9949. /* 45 */
  9950. /***/ (function(module, exports) {
  9951. var core = module.exports = { version: '2.5.5' };
  9952. if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
  9953. /***/ }),
  9954. /* 46 */
  9955. /***/ (function(module, exports, __webpack_require__) {
  9956. var isObject = __webpack_require__(9);
  9957. module.exports = function (it, TYPE) {
  9958. if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');
  9959. return it;
  9960. };
  9961. /***/ }),
  9962. /* 47 */
  9963. /***/ (function(module, exports, __webpack_require__) {
  9964. // 22.1.3.31 Array.prototype[@@unscopables]
  9965. var UNSCOPABLES = __webpack_require__(11)('unscopables');
  9966. var ArrayProto = Array.prototype;
  9967. if (ArrayProto[UNSCOPABLES] == undefined) __webpack_require__(31)(ArrayProto, UNSCOPABLES, {});
  9968. module.exports = function (key) {
  9969. ArrayProto[UNSCOPABLES][key] = true;
  9970. };
  9971. /***/ }),
  9972. /* 48 */
  9973. /***/ (function(module, exports, __webpack_require__) {
  9974. "use strict";
  9975. exports.__esModule = true;
  9976. exports.createClassName = createClassName;
  9977. exports.createDefaultCustomBorder = createDefaultCustomBorder;
  9978. exports.createSingleEmptyBorder = createSingleEmptyBorder;
  9979. exports.createDefaultHtBorder = createDefaultHtBorder;
  9980. exports.createEmptyBorders = createEmptyBorders;
  9981. exports.extendDefaultBorder = extendDefaultBorder;
  9982. exports.checkSelectionBorders = checkSelectionBorders;
  9983. exports.markSelected = markSelected;
  9984. var _object = __webpack_require__(2);
  9985. var _array = __webpack_require__(1);
  9986. /**
  9987. * Create separated class name for borders for each cell.
  9988. *
  9989. * @param {Number} row Visual row index.
  9990. * @param {Number} col Visual column index.
  9991. * @returns {String}
  9992. */
  9993. function createClassName(row, col) {
  9994. return 'border_row' + row + 'col' + col;
  9995. }
  9996. /**
  9997. * Create default single border for each position (top/right/bottom/left).
  9998. *
  9999. * @returns {Object} `{{width: number, color: string}}`
  10000. */
  10001. function createDefaultCustomBorder() {
  10002. return {
  10003. width: 1,
  10004. color: '#000'
  10005. };
  10006. }
  10007. /**
  10008. * Create default object for empty border.
  10009. *
  10010. * @returns {Object} `{{hide: boolean}}`
  10011. */
  10012. function createSingleEmptyBorder() {
  10013. return { hide: true };
  10014. }
  10015. /**
  10016. * Create default Handsontable border object.
  10017. *
  10018. * @returns {Object} `{{width: number, color: string, cornerVisible: boolean}}`
  10019. */
  10020. function createDefaultHtBorder() {
  10021. return {
  10022. width: 1,
  10023. color: '#000',
  10024. cornerVisible: false
  10025. };
  10026. }
  10027. /**
  10028. * Prepare empty border for each cell with all custom borders hidden.
  10029. *
  10030. * @param {Number} row Visual row index.
  10031. * @param {Number} col Visual column index.
  10032. * @returns {Object} `{{className: *, border: *, row: *, col: *, top: {hide: boolean}, right: {hide: boolean}, bottom: {hide: boolean}, left: {hide: boolean}}}`
  10033. */
  10034. function createEmptyBorders(row, col) {
  10035. return {
  10036. className: createClassName(row, col),
  10037. border: createDefaultHtBorder(),
  10038. row: row,
  10039. col: col,
  10040. top: createSingleEmptyBorder(),
  10041. right: createSingleEmptyBorder(),
  10042. bottom: createSingleEmptyBorder(),
  10043. left: createSingleEmptyBorder()
  10044. };
  10045. }
  10046. function extendDefaultBorder(defaultBorder, customBorder) {
  10047. if ((0, _object.hasOwnProperty)(customBorder, 'border')) {
  10048. defaultBorder.border = customBorder.border;
  10049. }
  10050. if ((0, _object.hasOwnProperty)(customBorder, 'top')) {
  10051. defaultBorder.top = customBorder.top;
  10052. }
  10053. if ((0, _object.hasOwnProperty)(customBorder, 'right')) {
  10054. defaultBorder.right = customBorder.right;
  10055. }
  10056. if ((0, _object.hasOwnProperty)(customBorder, 'bottom')) {
  10057. defaultBorder.bottom = customBorder.bottom;
  10058. }
  10059. if ((0, _object.hasOwnProperty)(customBorder, 'left')) {
  10060. defaultBorder.left = customBorder.left;
  10061. }
  10062. return defaultBorder;
  10063. }
  10064. /**
  10065. * Check if selection has border by className
  10066. *
  10067. * @param hot
  10068. * @param direction
  10069. */
  10070. function checkSelectionBorders(hot, direction) {
  10071. var atLeastOneHasBorder = false;
  10072. (0, _array.arrayEach)(hot.getSelectedRange(), function (range) {
  10073. range.forAll(function (r, c) {
  10074. var metaBorders = hot.getCellMeta(r, c).borders;
  10075. if (metaBorders) {
  10076. if (direction) {
  10077. if (!(0, _object.hasOwnProperty)(metaBorders[direction], 'hide')) {
  10078. atLeastOneHasBorder = true;
  10079. return false; // breaks forAll
  10080. }
  10081. } else {
  10082. atLeastOneHasBorder = true;
  10083. return false; // breaks forAll
  10084. }
  10085. }
  10086. });
  10087. });
  10088. return atLeastOneHasBorder;
  10089. }
  10090. /**
  10091. * Mark label in contextMenu as selected
  10092. *
  10093. * @param label
  10094. * @returns {string}
  10095. */
  10096. function markSelected(label) {
  10097. return '<span class="selected">' + String.fromCharCode(10003) + '</span>' + label; // workaround for https://github.com/handsontable/handsontable/issues/1946
  10098. }
  10099. /***/ }),
  10100. /* 49 */
  10101. /***/ (function(module, exports) {
  10102. var id = 0;
  10103. var px = Math.random();
  10104. module.exports = function (key) {
  10105. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  10106. };
  10107. /***/ }),
  10108. /* 50 */
  10109. /***/ (function(module, exports) {
  10110. module.exports = function (bitmap, value) {
  10111. return {
  10112. enumerable: !(bitmap & 1),
  10113. configurable: !(bitmap & 2),
  10114. writable: !(bitmap & 4),
  10115. value: value
  10116. };
  10117. };
  10118. /***/ }),
  10119. /* 51 */
  10120. /***/ (function(module, exports) {
  10121. module.exports = {};
  10122. /***/ }),
  10123. /* 52 */
  10124. /***/ (function(module, exports, __webpack_require__) {
  10125. var def = __webpack_require__(20).f;
  10126. var has = __webpack_require__(29);
  10127. var TAG = __webpack_require__(11)('toStringTag');
  10128. module.exports = function (it, tag, stat) {
  10129. if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
  10130. };
  10131. /***/ }),
  10132. /* 53 */
  10133. /***/ (function(module, exports) {
  10134. exports.f = {}.propertyIsEnumerable;
  10135. /***/ }),
  10136. /* 54 */
  10137. /***/ (function(module, exports, __webpack_require__) {
  10138. "use strict";
  10139. exports.__esModule = true;
  10140. exports.EditorState = undefined;
  10141. var _src = __webpack_require__(4);
  10142. var _mixed = __webpack_require__(16);
  10143. var EditorState = exports.EditorState = {
  10144. VIRGIN: 'STATE_VIRGIN', // before editing
  10145. EDITING: 'STATE_EDITING',
  10146. WAITING: 'STATE_WAITING', // waiting for async validation
  10147. FINISHED: 'STATE_FINISHED'
  10148. };
  10149. function BaseEditor(instance) {
  10150. this.instance = instance;
  10151. this.state = EditorState.VIRGIN;
  10152. this._opened = false;
  10153. this._fullEditMode = false;
  10154. this._closeCallback = null;
  10155. this.init();
  10156. }
  10157. BaseEditor.prototype._fireCallbacks = function (result) {
  10158. if (this._closeCallback) {
  10159. this._closeCallback(result);
  10160. this._closeCallback = null;
  10161. }
  10162. };
  10163. BaseEditor.prototype.init = function () {};
  10164. BaseEditor.prototype.getValue = function () {
  10165. throw Error('Editor getValue() method unimplemented');
  10166. };
  10167. BaseEditor.prototype.setValue = function (newValue) {
  10168. throw Error('Editor setValue() method unimplemented');
  10169. };
  10170. BaseEditor.prototype.open = function () {
  10171. throw Error('Editor open() method unimplemented');
  10172. };
  10173. BaseEditor.prototype.close = function () {
  10174. throw Error('Editor close() method unimplemented');
  10175. };
  10176. BaseEditor.prototype.prepare = function (row, col, prop, td, originalValue, cellProperties) {
  10177. this.TD = td;
  10178. this.row = row;
  10179. this.col = col;
  10180. this.prop = prop;
  10181. this.originalValue = originalValue;
  10182. this.cellProperties = cellProperties;
  10183. this.state = EditorState.VIRGIN;
  10184. };
  10185. BaseEditor.prototype.extend = function () {
  10186. var baseClass = this.constructor;
  10187. function Editor() {
  10188. baseClass.apply(this, arguments);
  10189. }
  10190. function inherit(Child, Parent) {
  10191. function Bridge() {}
  10192. Bridge.prototype = Parent.prototype;
  10193. Child.prototype = new Bridge();
  10194. Child.prototype.constructor = Child;
  10195. return Child;
  10196. }
  10197. return inherit(Editor, baseClass);
  10198. };
  10199. BaseEditor.prototype.saveValue = function (value, ctrlDown) {
  10200. var selection = void 0;
  10201. var tmp = void 0;
  10202. // if ctrl+enter and multiple cells selected, behave like Excel (finish editing and apply to all cells)
  10203. if (ctrlDown) {
  10204. selection = this.instance.getSelectedLast();
  10205. if (selection[0] > selection[2]) {
  10206. tmp = selection[0];
  10207. selection[0] = selection[2];
  10208. selection[2] = tmp;
  10209. }
  10210. if (selection[1] > selection[3]) {
  10211. tmp = selection[1];
  10212. selection[1] = selection[3];
  10213. selection[3] = tmp;
  10214. }
  10215. } else {
  10216. selection = [this.row, this.col, null, null];
  10217. }
  10218. this.instance.populateFromArray(selection[0], selection[1], value, selection[2], selection[3], 'edit');
  10219. };
  10220. BaseEditor.prototype.beginEditing = function (newInitialValue, event) {
  10221. if (this.state !== EditorState.VIRGIN) {
  10222. return;
  10223. }
  10224. this.instance.view.scrollViewport(new _src.CellCoords(this.row, this.col));
  10225. this.instance.view.render();
  10226. this.state = EditorState.EDITING;
  10227. newInitialValue = typeof newInitialValue === 'string' ? newInitialValue : this.originalValue;
  10228. this.setValue((0, _mixed.stringify)(newInitialValue));
  10229. this.open(event);
  10230. this._opened = true;
  10231. this.focus();
  10232. // only rerender the selections (FillHandle should disappear when beginediting is triggered)
  10233. this.instance.view.render();
  10234. this.instance.runHooks('afterBeginEditing', this.row, this.col);
  10235. };
  10236. BaseEditor.prototype.finishEditing = function (restoreOriginalValue, ctrlDown, callback) {
  10237. var _this = this,
  10238. val;
  10239. if (callback) {
  10240. var previousCloseCallback = this._closeCallback;
  10241. this._closeCallback = function (result) {
  10242. if (previousCloseCallback) {
  10243. previousCloseCallback(result);
  10244. }
  10245. callback(result);
  10246. _this.instance.view.render();
  10247. };
  10248. }
  10249. if (this.isWaiting()) {
  10250. return;
  10251. }
  10252. if (this.state == EditorState.VIRGIN) {
  10253. this.instance._registerTimeout(setTimeout(function () {
  10254. _this._fireCallbacks(true);
  10255. }, 0));
  10256. return;
  10257. }
  10258. if (this.state == EditorState.EDITING) {
  10259. if (restoreOriginalValue) {
  10260. this.cancelChanges();
  10261. this.instance.view.render();
  10262. return;
  10263. }
  10264. var value = this.getValue();
  10265. if (this.instance.getSettings().trimWhitespace) {
  10266. // We trim only string values
  10267. val = [[typeof value === 'string' ? String.prototype.trim.call(value || '') : value]];
  10268. } else {
  10269. val = [[value]];
  10270. }
  10271. this.state = EditorState.WAITING;
  10272. this.saveValue(val, ctrlDown);
  10273. if (this.instance.getCellValidator(this.cellProperties)) {
  10274. this.instance.addHookOnce('postAfterValidate', function (result) {
  10275. _this.state = EditorState.FINISHED;
  10276. _this.discardEditor(result);
  10277. });
  10278. } else {
  10279. this.state = EditorState.FINISHED;
  10280. this.discardEditor(true);
  10281. }
  10282. }
  10283. };
  10284. BaseEditor.prototype.cancelChanges = function () {
  10285. this.state = EditorState.FINISHED;
  10286. this.discardEditor();
  10287. };
  10288. BaseEditor.prototype.discardEditor = function (result) {
  10289. if (this.state !== EditorState.FINISHED) {
  10290. return;
  10291. }
  10292. // validator was defined and failed
  10293. if (result === false && this.cellProperties.allowInvalid !== true) {
  10294. this.instance.selectCell(this.row, this.col);
  10295. this.focus();
  10296. this.state = EditorState.EDITING;
  10297. this._fireCallbacks(false);
  10298. } else {
  10299. this.close();
  10300. this._opened = false;
  10301. this._fullEditMode = false;
  10302. this.state = EditorState.VIRGIN;
  10303. this._fireCallbacks(true);
  10304. }
  10305. };
  10306. /**
  10307. * Switch editor into full edit mode. In this state navigation keys don't close editor. This mode is activated
  10308. * automatically after hit ENTER or F2 key on the cell or while editing cell press F2 key.
  10309. */
  10310. BaseEditor.prototype.enableFullEditMode = function () {
  10311. this._fullEditMode = true;
  10312. };
  10313. /**
  10314. * Checks if editor is in full edit mode.
  10315. *
  10316. * @returns {Boolean}
  10317. */
  10318. BaseEditor.prototype.isInFullEditMode = function () {
  10319. return this._fullEditMode;
  10320. };
  10321. BaseEditor.prototype.isOpened = function () {
  10322. return this._opened;
  10323. };
  10324. BaseEditor.prototype.isWaiting = function () {
  10325. return this.state === EditorState.WAITING;
  10326. };
  10327. BaseEditor.prototype.checkEditorSection = function () {
  10328. var totalRows = this.instance.countRows();
  10329. var section = '';
  10330. if (this.row < this.instance.getSettings().fixedRowsTop) {
  10331. if (this.col < this.instance.getSettings().fixedColumnsLeft) {
  10332. section = 'top-left-corner';
  10333. } else {
  10334. section = 'top';
  10335. }
  10336. } else if (this.instance.getSettings().fixedRowsBottom && this.row >= totalRows - this.instance.getSettings().fixedRowsBottom) {
  10337. if (this.col < this.instance.getSettings().fixedColumnsLeft) {
  10338. section = 'bottom-left-corner';
  10339. } else {
  10340. section = 'bottom';
  10341. }
  10342. } else if (this.col < this.instance.getSettings().fixedColumnsLeft) {
  10343. section = 'left';
  10344. }
  10345. return section;
  10346. };
  10347. exports.default = BaseEditor;
  10348. /***/ }),
  10349. /* 55 */
  10350. /***/ (function(module, exports, __webpack_require__) {
  10351. "use strict";
  10352. exports.__esModule = true;
  10353. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  10354. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10355. /**
  10356. * CellCoords holds cell coordinates (row, column) and few method to validate them and
  10357. * retrieve as an array or an object
  10358. *
  10359. * @class CellCoords
  10360. */
  10361. var CellCoords = function () {
  10362. /**
  10363. * @param {Number} row Row index
  10364. * @param {Number} col Column index
  10365. */
  10366. function CellCoords(row, col) {
  10367. _classCallCheck(this, CellCoords);
  10368. if (typeof row !== 'undefined' && typeof col !== 'undefined') {
  10369. this.row = row;
  10370. this.col = col;
  10371. } else {
  10372. this.row = null;
  10373. this.col = null;
  10374. }
  10375. }
  10376. /**
  10377. * Checks if given set of coordinates is valid in context of a given Walkontable instance
  10378. *
  10379. * @param {Walkontable} wotInstance
  10380. * @returns {Boolean}
  10381. */
  10382. _createClass(CellCoords, [{
  10383. key: 'isValid',
  10384. value: function isValid(wotInstance) {
  10385. // is it a valid cell index (0 or higher)
  10386. if (this.row < 0 || this.col < 0) {
  10387. return false;
  10388. }
  10389. // is selection within total rows and columns
  10390. if (this.row >= wotInstance.getSetting('totalRows') || this.col >= wotInstance.getSetting('totalColumns')) {
  10391. return false;
  10392. }
  10393. return true;
  10394. }
  10395. /**
  10396. * Checks if this cell coords are the same as cell coords given as a parameter
  10397. *
  10398. * @param {CellCoords} cellCoords
  10399. * @returns {Boolean}
  10400. */
  10401. }, {
  10402. key: 'isEqual',
  10403. value: function isEqual(cellCoords) {
  10404. if (cellCoords === this) {
  10405. return true;
  10406. }
  10407. return this.row === cellCoords.row && this.col === cellCoords.col;
  10408. }
  10409. /**
  10410. * Checks if tested coordinates are positioned in south-east from this cell coords
  10411. *
  10412. * @param {Object} testedCoords
  10413. * @returns {Boolean}
  10414. */
  10415. }, {
  10416. key: 'isSouthEastOf',
  10417. value: function isSouthEastOf(testedCoords) {
  10418. return this.row >= testedCoords.row && this.col >= testedCoords.col;
  10419. }
  10420. /**
  10421. * Checks if tested coordinates are positioned in north-east from this cell coords
  10422. *
  10423. * @param {Object} testedCoords
  10424. * @returns {Boolean}
  10425. */
  10426. }, {
  10427. key: 'isNorthWestOf',
  10428. value: function isNorthWestOf(testedCoords) {
  10429. return this.row <= testedCoords.row && this.col <= testedCoords.col;
  10430. }
  10431. /**
  10432. * Checks if tested coordinates are positioned in south-west from this cell coords
  10433. *
  10434. * @param {Object} testedCoords
  10435. * @returns {Boolean}
  10436. */
  10437. }, {
  10438. key: 'isSouthWestOf',
  10439. value: function isSouthWestOf(testedCoords) {
  10440. return this.row >= testedCoords.row && this.col <= testedCoords.col;
  10441. }
  10442. /**
  10443. * Checks if tested coordinates are positioned in north-east from this cell coords
  10444. *
  10445. * @param {Object} testedCoords
  10446. * @returns {Boolean}
  10447. */
  10448. }, {
  10449. key: 'isNorthEastOf',
  10450. value: function isNorthEastOf(testedCoords) {
  10451. return this.row <= testedCoords.row && this.col >= testedCoords.col;
  10452. }
  10453. /**
  10454. * Convert CellCoords to literal object.
  10455. *
  10456. * @return {Object} Returns a literal object with `row` and `col` properties.
  10457. */
  10458. }, {
  10459. key: 'toObject',
  10460. value: function toObject() {
  10461. return {
  10462. row: this.row,
  10463. col: this.col
  10464. };
  10465. }
  10466. }]);
  10467. return CellCoords;
  10468. }();
  10469. exports.default = CellCoords;
  10470. /***/ }),
  10471. /* 56 */
  10472. /***/ (function(module, exports, __webpack_require__) {
  10473. "use strict";
  10474. exports.__esModule = true;
  10475. exports.log = log;
  10476. exports.warn = warn;
  10477. exports.info = info;
  10478. exports.error = error;
  10479. var _mixed = __webpack_require__(16);
  10480. /**
  10481. * Logs message to the console if the `console` object is exposed.
  10482. *
  10483. * @param {...*} args Values which will be logged.
  10484. */
  10485. function log() {
  10486. if ((0, _mixed.isDefined)(console)) {
  10487. var _console;
  10488. (_console = console).log.apply(_console, arguments);
  10489. }
  10490. } /* eslint-disable no-console */
  10491. /* eslint-disable no-restricted-globals */
  10492. /**
  10493. * "In Internet Explorer 9 (and 8), the console object is only exposed when the developer tools are opened
  10494. * for a particular tab."
  10495. *
  10496. * Source: https://stackoverflow.com/a/5473193
  10497. */
  10498. ;
  10499. /**
  10500. * Logs warn to the console if the `console` object is exposed.
  10501. *
  10502. * @param {...*} args Values which will be logged.
  10503. */
  10504. function warn() {
  10505. if ((0, _mixed.isDefined)(console)) {
  10506. var _console2;
  10507. (_console2 = console).warn.apply(_console2, arguments);
  10508. }
  10509. };
  10510. /**
  10511. * Logs info to the console if the `console` object is exposed.
  10512. *
  10513. * @param {...*} args Values which will be logged.
  10514. */
  10515. function info() {
  10516. if ((0, _mixed.isDefined)(console)) {
  10517. var _console3;
  10518. (_console3 = console).info.apply(_console3, arguments);
  10519. }
  10520. };
  10521. /**
  10522. * Logs error to the console if the `console` object is exposed.
  10523. *
  10524. * @param {...*} args Values which will be logged.
  10525. */
  10526. function error() {
  10527. if ((0, _mixed.isDefined)(console)) {
  10528. var _console4;
  10529. (_console4 = console).error.apply(_console4, arguments);
  10530. }
  10531. };
  10532. /***/ }),
  10533. /* 57 */
  10534. /***/ (function(module, exports, __webpack_require__) {
  10535. "use strict";
  10536. exports.__esModule = true;
  10537. var _element = __webpack_require__(0);
  10538. var _autoResize = __webpack_require__(355);
  10539. var _autoResize2 = _interopRequireDefault(_autoResize);
  10540. var _baseEditor = __webpack_require__(54);
  10541. var _baseEditor2 = _interopRequireDefault(_baseEditor);
  10542. var _eventManager = __webpack_require__(6);
  10543. var _eventManager2 = _interopRequireDefault(_eventManager);
  10544. var _unicode = __webpack_require__(21);
  10545. var _event = __webpack_require__(12);
  10546. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10547. var TextEditor = _baseEditor2.default.prototype.extend();
  10548. /**
  10549. * @private
  10550. * @editor TextEditor
  10551. * @class TextEditor
  10552. * @dependencies autoResize
  10553. */
  10554. TextEditor.prototype.init = function () {
  10555. var that = this;
  10556. this.createElements();
  10557. this.eventManager = new _eventManager2.default(this);
  10558. this.bindEvents();
  10559. this.autoResize = (0, _autoResize2.default)();
  10560. this.instance.addHook('afterDestroy', function () {
  10561. that.destroy();
  10562. });
  10563. };
  10564. TextEditor.prototype.getValue = function () {
  10565. return this.TEXTAREA.value;
  10566. };
  10567. TextEditor.prototype.setValue = function (newValue) {
  10568. this.TEXTAREA.value = newValue;
  10569. };
  10570. var onBeforeKeyDown = function onBeforeKeyDown(event) {
  10571. var instance = this,
  10572. that = instance.getActiveEditor(),
  10573. ctrlDown;
  10574. // catch CTRL but not right ALT (which in some systems triggers ALT+CTRL)
  10575. ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  10576. // Process only events that have been fired in the editor
  10577. if (event.target !== that.TEXTAREA || (0, _event.isImmediatePropagationStopped)(event)) {
  10578. return;
  10579. }
  10580. if (event.keyCode === 17 || event.keyCode === 224 || event.keyCode === 91 || event.keyCode === 93) {
  10581. // when CTRL or its equivalent is pressed and cell is edited, don't prepare selectable text in textarea
  10582. (0, _event.stopImmediatePropagation)(event);
  10583. return;
  10584. }
  10585. switch (event.keyCode) {
  10586. case _unicode.KEY_CODES.ARROW_RIGHT:
  10587. if (that.isInFullEditMode()) {
  10588. if (!that.isWaiting() && !that.allowKeyEventPropagation || !that.isWaiting() && that.allowKeyEventPropagation && !that.allowKeyEventPropagation(event.keyCode)) {
  10589. (0, _event.stopImmediatePropagation)(event);
  10590. }
  10591. }
  10592. break;
  10593. case _unicode.KEY_CODES.ARROW_LEFT:
  10594. if (that.isInFullEditMode()) {
  10595. if (!that.isWaiting() && !that.allowKeyEventPropagation || !that.isWaiting() && that.allowKeyEventPropagation && !that.allowKeyEventPropagation(event.keyCode)) {
  10596. (0, _event.stopImmediatePropagation)(event);
  10597. }
  10598. }
  10599. break;
  10600. case _unicode.KEY_CODES.ARROW_UP:
  10601. case _unicode.KEY_CODES.ARROW_DOWN:
  10602. if (that.isInFullEditMode()) {
  10603. if (!that.isWaiting() && !that.allowKeyEventPropagation || !that.isWaiting() && that.allowKeyEventPropagation && !that.allowKeyEventPropagation(event.keyCode)) {
  10604. (0, _event.stopImmediatePropagation)(event);
  10605. }
  10606. }
  10607. break;
  10608. case _unicode.KEY_CODES.ENTER:
  10609. {
  10610. var isMultipleSelection = this.selection.isMultiple();
  10611. if (ctrlDown && !isMultipleSelection || event.altKey) {
  10612. // if ctrl+enter or alt+enter, add new line
  10613. if (that.isOpened()) {
  10614. var caretPosition = (0, _element.getCaretPosition)(that.TEXTAREA);
  10615. var value = that.getValue();
  10616. var newValue = value.slice(0, caretPosition) + '\n' + value.slice(caretPosition);
  10617. that.setValue(newValue);
  10618. (0, _element.setCaretPosition)(that.TEXTAREA, caretPosition + 1);
  10619. } else {
  10620. that.beginEditing(that.originalValue + '\n');
  10621. }
  10622. (0, _event.stopImmediatePropagation)(event);
  10623. }
  10624. event.preventDefault(); // don't add newline to field
  10625. break;
  10626. }
  10627. case _unicode.KEY_CODES.A:
  10628. case _unicode.KEY_CODES.X:
  10629. case _unicode.KEY_CODES.C:
  10630. case _unicode.KEY_CODES.V:
  10631. if (ctrlDown) {
  10632. (0, _event.stopImmediatePropagation)(event); // CTRL+A, CTRL+C, CTRL+V, CTRL+X should only work locally when cell is edited (not in table context)
  10633. }
  10634. break;
  10635. case _unicode.KEY_CODES.BACKSPACE:
  10636. case _unicode.KEY_CODES.DELETE:
  10637. case _unicode.KEY_CODES.HOME:
  10638. case _unicode.KEY_CODES.END:
  10639. (0, _event.stopImmediatePropagation)(event); // backspace, delete, home, end should only work locally when cell is edited (not in table context)
  10640. break;
  10641. default:
  10642. break;
  10643. }
  10644. if ([_unicode.KEY_CODES.ARROW_UP, _unicode.KEY_CODES.ARROW_RIGHT, _unicode.KEY_CODES.ARROW_DOWN, _unicode.KEY_CODES.ARROW_LEFT].indexOf(event.keyCode) === -1) {
  10645. that.autoResize.resize(String.fromCharCode(event.keyCode));
  10646. }
  10647. };
  10648. TextEditor.prototype.open = function () {
  10649. this.refreshDimensions(); // need it instantly, to prevent https://github.com/handsontable/handsontable/issues/348
  10650. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  10651. };
  10652. TextEditor.prototype.close = function (tdOutside) {
  10653. this.textareaParentStyle.display = 'none';
  10654. this.autoResize.unObserve();
  10655. if (document.activeElement === this.TEXTAREA) {
  10656. this.instance.listen(); // don't refocus the table if user focused some cell outside of HT on purpose
  10657. }
  10658. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  10659. };
  10660. TextEditor.prototype.focus = function () {
  10661. this.TEXTAREA.focus();
  10662. (0, _element.setCaretPosition)(this.TEXTAREA, this.TEXTAREA.value.length);
  10663. };
  10664. TextEditor.prototype.createElements = function () {
  10665. // this.$body = $(document.body);
  10666. this.TEXTAREA = document.createElement('TEXTAREA');
  10667. (0, _element.addClass)(this.TEXTAREA, 'handsontableInput');
  10668. this.textareaStyle = this.TEXTAREA.style;
  10669. this.textareaStyle.width = 0;
  10670. this.textareaStyle.height = 0;
  10671. this.TEXTAREA_PARENT = document.createElement('DIV');
  10672. (0, _element.addClass)(this.TEXTAREA_PARENT, 'handsontableInputHolder');
  10673. this.textareaParentStyle = this.TEXTAREA_PARENT.style;
  10674. this.textareaParentStyle.top = 0;
  10675. this.textareaParentStyle.left = 0;
  10676. this.textareaParentStyle.display = 'none';
  10677. this.TEXTAREA_PARENT.appendChild(this.TEXTAREA);
  10678. this.instance.rootElement.appendChild(this.TEXTAREA_PARENT);
  10679. var that = this;
  10680. this.instance._registerTimeout(setTimeout(function () {
  10681. that.refreshDimensions();
  10682. }, 0));
  10683. };
  10684. TextEditor.prototype.getEditedCell = function () {
  10685. var editorSection = this.checkEditorSection(),
  10686. editedCell;
  10687. switch (editorSection) {
  10688. case 'top':
  10689. editedCell = this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.getCell({
  10690. row: this.row,
  10691. col: this.col
  10692. });
  10693. this.textareaParentStyle.zIndex = 101;
  10694. break;
  10695. case 'top-left-corner':
  10696. editedCell = this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.getCell({
  10697. row: this.row,
  10698. col: this.col
  10699. });
  10700. this.textareaParentStyle.zIndex = 103;
  10701. break;
  10702. case 'bottom-left-corner':
  10703. editedCell = this.instance.view.wt.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.getCell({
  10704. row: this.row,
  10705. col: this.col
  10706. });
  10707. this.textareaParentStyle.zIndex = 103;
  10708. break;
  10709. case 'left':
  10710. editedCell = this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.getCell({
  10711. row: this.row,
  10712. col: this.col
  10713. });
  10714. this.textareaParentStyle.zIndex = 102;
  10715. break;
  10716. case 'bottom':
  10717. editedCell = this.instance.view.wt.wtOverlays.bottomOverlay.clone.wtTable.getCell({
  10718. row: this.row,
  10719. col: this.col
  10720. });
  10721. this.textareaParentStyle.zIndex = 102;
  10722. break;
  10723. default:
  10724. editedCell = this.instance.getCell(this.row, this.col);
  10725. this.textareaParentStyle.zIndex = '';
  10726. break;
  10727. }
  10728. return editedCell != -1 && editedCell != -2 ? editedCell : void 0;
  10729. };
  10730. TextEditor.prototype.refreshValue = function () {
  10731. var sourceData = this.instance.getSourceDataAtCell(this.row, this.prop);
  10732. this.originalValue = sourceData;
  10733. this.setValue(sourceData);
  10734. this.refreshDimensions();
  10735. };
  10736. TextEditor.prototype.refreshDimensions = function () {
  10737. if (this.state !== _baseEditor.EditorState.EDITING) {
  10738. return;
  10739. }
  10740. this.TD = this.getEditedCell();
  10741. // TD is outside of the viewport.
  10742. if (!this.TD) {
  10743. this.close(true);
  10744. return;
  10745. }
  10746. var currentOffset = (0, _element.offset)(this.TD);
  10747. var containerOffset = (0, _element.offset)(this.instance.rootElement);
  10748. var scrollableContainer = this.instance.view.wt.wtOverlays.topOverlay.mainTableScrollableElement;
  10749. var totalRowsCount = this.instance.countRows();
  10750. var containerScrollTop = scrollableContainer !== window ? scrollableContainer.scrollTop : 0;
  10751. var containerScrollLeft = scrollableContainer !== window ? scrollableContainer.scrollLeft : 0;
  10752. var editorSection = this.checkEditorSection();
  10753. var scrollTop = ['', 'left'].includes(editorSection) ? containerScrollTop : 0;
  10754. var scrollLeft = ['', 'top', 'bottom'].includes(editorSection) ? containerScrollLeft : 0;
  10755. // If colHeaders is disabled, cells in the first row have border-top
  10756. var editTopModifier = currentOffset.top === containerOffset.top ? 0 : 1;
  10757. var settings = this.instance.getSettings();
  10758. var rowHeadersCount = this.instance.hasRowHeaders();
  10759. var colHeadersCount = this.instance.hasColHeaders();
  10760. var backgroundColor = this.TD.style.backgroundColor;
  10761. var editTop = currentOffset.top - containerOffset.top - editTopModifier - scrollTop;
  10762. var editLeft = currentOffset.left - containerOffset.left - 1 - scrollLeft;
  10763. var cssTransformOffset = void 0;
  10764. // TODO: Refactor this to the new instance.getCell method (from #ply-59), after 0.12.1 is released
  10765. switch (editorSection) {
  10766. case 'top':
  10767. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.holder.parentNode);
  10768. break;
  10769. case 'left':
  10770. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.holder.parentNode);
  10771. break;
  10772. case 'top-left-corner':
  10773. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.holder.parentNode);
  10774. break;
  10775. case 'bottom-left-corner':
  10776. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.holder.parentNode);
  10777. break;
  10778. case 'bottom':
  10779. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.bottomOverlay.clone.wtTable.holder.parentNode);
  10780. break;
  10781. default:
  10782. break;
  10783. }
  10784. if (colHeadersCount && this.instance.getSelectedLast()[0] === 0 || settings.fixedRowsBottom && this.instance.getSelectedLast()[0] === totalRowsCount - settings.fixedRowsBottom) {
  10785. editTop += 1;
  10786. }
  10787. if (this.instance.getSelectedLast()[1] === 0) {
  10788. editLeft += 1;
  10789. }
  10790. if (cssTransformOffset && cssTransformOffset != -1) {
  10791. this.textareaParentStyle[cssTransformOffset[0]] = cssTransformOffset[1];
  10792. } else {
  10793. (0, _element.resetCssTransform)(this.TEXTAREA_PARENT);
  10794. }
  10795. this.textareaParentStyle.top = editTop + 'px';
  10796. this.textareaParentStyle.left = editLeft + 'px';
  10797. var firstRowOffset = this.instance.view.wt.wtViewport.rowsRenderCalculator.startPosition;
  10798. var firstColumnOffset = this.instance.view.wt.wtViewport.columnsRenderCalculator.startPosition;
  10799. var horizontalScrollPosition = this.instance.view.wt.wtOverlays.leftOverlay.getScrollPosition();
  10800. var verticalScrollPosition = this.instance.view.wt.wtOverlays.topOverlay.getScrollPosition();
  10801. var scrollbarWidth = (0, _element.getScrollbarWidth)();
  10802. var cellTopOffset = this.TD.offsetTop + firstRowOffset - verticalScrollPosition;
  10803. var cellLeftOffset = this.TD.offsetLeft + firstColumnOffset - horizontalScrollPosition;
  10804. var width = (0, _element.innerWidth)(this.TD) - 8;
  10805. var actualVerticalScrollbarWidth = (0, _element.hasVerticalScrollbar)(scrollableContainer) ? scrollbarWidth : 0;
  10806. var actualHorizontalScrollbarWidth = (0, _element.hasHorizontalScrollbar)(scrollableContainer) ? scrollbarWidth : 0;
  10807. var maxWidth = this.instance.view.maximumVisibleElementWidth(cellLeftOffset) - 9 - actualVerticalScrollbarWidth;
  10808. var height = this.TD.scrollHeight + 1;
  10809. var maxHeight = Math.max(this.instance.view.maximumVisibleElementHeight(cellTopOffset) - actualHorizontalScrollbarWidth, 23);
  10810. var cellComputedStyle = (0, _element.getComputedStyle)(this.TD);
  10811. this.TEXTAREA.style.fontSize = cellComputedStyle.fontSize;
  10812. this.TEXTAREA.style.fontFamily = cellComputedStyle.fontFamily;
  10813. this.TEXTAREA.style.backgroundColor = ''; // RESET STYLE
  10814. this.TEXTAREA.style.backgroundColor = backgroundColor ? backgroundColor : (0, _element.getComputedStyle)(this.TEXTAREA).backgroundColor;
  10815. this.autoResize.init(this.TEXTAREA, {
  10816. minHeight: Math.min(height, maxHeight),
  10817. maxHeight: maxHeight, // TEXTAREA should never be wider than visible part of the viewport (should not cover the scrollbar)
  10818. minWidth: Math.min(width, maxWidth),
  10819. maxWidth: maxWidth // TEXTAREA should never be wider than visible part of the viewport (should not cover the scrollbar)
  10820. }, true);
  10821. this.textareaParentStyle.display = 'block';
  10822. };
  10823. TextEditor.prototype.bindEvents = function () {
  10824. var editor = this;
  10825. this.eventManager.addEventListener(this.TEXTAREA, 'cut', function (event) {
  10826. (0, _event.stopPropagation)(event);
  10827. });
  10828. this.eventManager.addEventListener(this.TEXTAREA, 'paste', function (event) {
  10829. (0, _event.stopPropagation)(event);
  10830. });
  10831. this.instance.addHook('afterScrollHorizontally', function () {
  10832. editor.refreshDimensions();
  10833. });
  10834. this.instance.addHook('afterScrollVertically', function () {
  10835. editor.refreshDimensions();
  10836. });
  10837. this.instance.addHook('afterColumnResize', function () {
  10838. editor.refreshDimensions();
  10839. editor.focus();
  10840. });
  10841. this.instance.addHook('afterRowResize', function () {
  10842. editor.refreshDimensions();
  10843. editor.focus();
  10844. });
  10845. this.instance.addHook('afterDestroy', function () {
  10846. editor.eventManager.destroy();
  10847. });
  10848. };
  10849. TextEditor.prototype.destroy = function () {
  10850. this.eventManager.destroy();
  10851. };
  10852. exports.default = TextEditor;
  10853. /***/ }),
  10854. /* 58 */
  10855. /***/ (function(module, exports, __webpack_require__) {
  10856. "use strict";
  10857. exports.__esModule = true;
  10858. var _array = __webpack_require__(1);
  10859. var _object = __webpack_require__(2);
  10860. var MIXIN_NAME = 'localHooks';
  10861. /**
  10862. * Mixin object to extend objects functionality for local hooks.
  10863. *
  10864. * @type {Object}
  10865. */
  10866. var localHooks = {
  10867. /**
  10868. * Internal hooks storage.
  10869. */
  10870. _localHooks: Object.create(null),
  10871. /**
  10872. * Add hook to the collection.
  10873. *
  10874. * @param {String} key Hook name.
  10875. * @param {Function} callback Hook callback
  10876. */
  10877. addLocalHook: function addLocalHook(key, callback) {
  10878. if (!this._localHooks[key]) {
  10879. this._localHooks[key] = [];
  10880. }
  10881. this._localHooks[key].push(callback);
  10882. },
  10883. /**
  10884. * Run hooks.
  10885. *
  10886. * @param {String} key Hook name.
  10887. * @param {*} params
  10888. */
  10889. runLocalHooks: function runLocalHooks(key) {
  10890. var _this = this;
  10891. for (var _len = arguments.length, params = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  10892. params[_key - 1] = arguments[_key];
  10893. }
  10894. if (this._localHooks[key]) {
  10895. (0, _array.arrayEach)(this._localHooks[key], function (callback) {
  10896. return callback.apply(_this, params);
  10897. });
  10898. }
  10899. },
  10900. /**
  10901. * Clear all added hooks.
  10902. */
  10903. clearLocalHooks: function clearLocalHooks() {
  10904. this._localHooks = {};
  10905. }
  10906. };
  10907. (0, _object.defineGetter)(localHooks, 'MIXIN_NAME', MIXIN_NAME, {
  10908. writable: false,
  10909. enumerable: false
  10910. });
  10911. exports.default = localHooks;
  10912. /***/ }),
  10913. /* 59 */
  10914. /***/ (function(module, exports) {
  10915. // 7.1.4 ToInteger
  10916. var ceil = Math.ceil;
  10917. var floor = Math.floor;
  10918. module.exports = function (it) {
  10919. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  10920. };
  10921. /***/ }),
  10922. /* 60 */
  10923. /***/ (function(module, exports, __webpack_require__) {
  10924. var toInteger = __webpack_require__(59);
  10925. var max = Math.max;
  10926. var min = Math.min;
  10927. module.exports = function (index, length) {
  10928. index = toInteger(index);
  10929. return index < 0 ? max(index + length, 0) : min(index, length);
  10930. };
  10931. /***/ }),
  10932. /* 61 */
  10933. /***/ (function(module, exports, __webpack_require__) {
  10934. var redefine = __webpack_require__(30);
  10935. module.exports = function (target, src, safe) {
  10936. for (var key in src) redefine(target, key, src[key], safe);
  10937. return target;
  10938. };
  10939. /***/ }),
  10940. /* 62 */
  10941. /***/ (function(module, exports) {
  10942. module.exports = function (it) {
  10943. if (typeof it != 'function') throw TypeError(it + ' is not a function!');
  10944. return it;
  10945. };
  10946. /***/ }),
  10947. /* 63 */
  10948. /***/ (function(module, exports) {
  10949. module.exports = function (it, Constructor, name, forbiddenField) {
  10950. if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {
  10951. throw TypeError(name + ': incorrect invocation!');
  10952. } return it;
  10953. };
  10954. /***/ }),
  10955. /* 64 */
  10956. /***/ (function(module, exports, __webpack_require__) {
  10957. var ctx = __webpack_require__(32);
  10958. var call = __webpack_require__(102);
  10959. var isArrayIter = __webpack_require__(103);
  10960. var anObject = __webpack_require__(18);
  10961. var toLength = __webpack_require__(25);
  10962. var getIterFn = __webpack_require__(104);
  10963. var BREAK = {};
  10964. var RETURN = {};
  10965. var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
  10966. var iterFn = ITERATOR ? function () { return iterable; } : getIterFn(iterable);
  10967. var f = ctx(fn, that, entries ? 2 : 1);
  10968. var index = 0;
  10969. var length, step, iterator, result;
  10970. if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
  10971. // fast case for arrays with default iterator
  10972. if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) {
  10973. result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
  10974. if (result === BREAK || result === RETURN) return result;
  10975. } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
  10976. result = call(iterator, f, step.value, entries);
  10977. if (result === BREAK || result === RETURN) return result;
  10978. }
  10979. };
  10980. exports.BREAK = BREAK;
  10981. exports.RETURN = RETURN;
  10982. /***/ }),
  10983. /* 65 */
  10984. /***/ (function(module, exports) {
  10985. module.exports = false;
  10986. /***/ }),
  10987. /* 66 */
  10988. /***/ (function(module, exports, __webpack_require__) {
  10989. "use strict";
  10990. var global = __webpack_require__(14);
  10991. var $export = __webpack_require__(3);
  10992. var redefine = __webpack_require__(30);
  10993. var redefineAll = __webpack_require__(61);
  10994. var meta = __webpack_require__(34);
  10995. var forOf = __webpack_require__(64);
  10996. var anInstance = __webpack_require__(63);
  10997. var isObject = __webpack_require__(9);
  10998. var fails = __webpack_require__(23);
  10999. var $iterDetect = __webpack_require__(79);
  11000. var setToStringTag = __webpack_require__(52);
  11001. var inheritIfRequired = __webpack_require__(329);
  11002. module.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
  11003. var Base = global[NAME];
  11004. var C = Base;
  11005. var ADDER = IS_MAP ? 'set' : 'add';
  11006. var proto = C && C.prototype;
  11007. var O = {};
  11008. var fixMethod = function (KEY) {
  11009. var fn = proto[KEY];
  11010. redefine(proto, KEY,
  11011. KEY == 'delete' ? function (a) {
  11012. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  11013. } : KEY == 'has' ? function has(a) {
  11014. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  11015. } : KEY == 'get' ? function get(a) {
  11016. return IS_WEAK && !isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a);
  11017. } : KEY == 'add' ? function add(a) { fn.call(this, a === 0 ? 0 : a); return this; }
  11018. : function set(a, b) { fn.call(this, a === 0 ? 0 : a, b); return this; }
  11019. );
  11020. };
  11021. if (typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function () {
  11022. new C().entries().next();
  11023. }))) {
  11024. // create collection constructor
  11025. C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
  11026. redefineAll(C.prototype, methods);
  11027. meta.NEED = true;
  11028. } else {
  11029. var instance = new C();
  11030. // early implementations not supports chaining
  11031. var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;
  11032. // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false
  11033. var THROWS_ON_PRIMITIVES = fails(function () { instance.has(1); });
  11034. // most early implementations doesn't supports iterables, most modern - not close it correctly
  11035. var ACCEPT_ITERABLES = $iterDetect(function (iter) { new C(iter); }); // eslint-disable-line no-new
  11036. // for early implementations -0 and +0 not the same
  11037. var BUGGY_ZERO = !IS_WEAK && fails(function () {
  11038. // V8 ~ Chromium 42- fails only with 5+ elements
  11039. var $instance = new C();
  11040. var index = 5;
  11041. while (index--) $instance[ADDER](index, index);
  11042. return !$instance.has(-0);
  11043. });
  11044. if (!ACCEPT_ITERABLES) {
  11045. C = wrapper(function (target, iterable) {
  11046. anInstance(target, C, NAME);
  11047. var that = inheritIfRequired(new Base(), target, C);
  11048. if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
  11049. return that;
  11050. });
  11051. C.prototype = proto;
  11052. proto.constructor = C;
  11053. }
  11054. if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {
  11055. fixMethod('delete');
  11056. fixMethod('has');
  11057. IS_MAP && fixMethod('get');
  11058. }
  11059. if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER);
  11060. // weak collections should not contains .clear method
  11061. if (IS_WEAK && proto.clear) delete proto.clear;
  11062. }
  11063. setToStringTag(C, NAME);
  11064. O[NAME] = C;
  11065. $export($export.G + $export.W + $export.F * (C != Base), O);
  11066. if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);
  11067. return C;
  11068. };
  11069. /***/ }),
  11070. /* 67 */
  11071. /***/ (function(module, exports, __webpack_require__) {
  11072. var pIE = __webpack_require__(53);
  11073. var createDesc = __webpack_require__(50);
  11074. var toIObject = __webpack_require__(24);
  11075. var toPrimitive = __webpack_require__(73);
  11076. var has = __webpack_require__(29);
  11077. var IE8_DOM_DEFINE = __webpack_require__(98);
  11078. var gOPD = Object.getOwnPropertyDescriptor;
  11079. exports.f = __webpack_require__(22) ? gOPD : function getOwnPropertyDescriptor(O, P) {
  11080. O = toIObject(O);
  11081. P = toPrimitive(P, true);
  11082. if (IE8_DOM_DEFINE) try {
  11083. return gOPD(O, P);
  11084. } catch (e) { /* empty */ }
  11085. if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);
  11086. };
  11087. /***/ }),
  11088. /* 68 */
  11089. /***/ (function(module, exports, __webpack_require__) {
  11090. // 0 -> Array#forEach
  11091. // 1 -> Array#map
  11092. // 2 -> Array#filter
  11093. // 3 -> Array#some
  11094. // 4 -> Array#every
  11095. // 5 -> Array#find
  11096. // 6 -> Array#findIndex
  11097. var ctx = __webpack_require__(32);
  11098. var IObject = __webpack_require__(75);
  11099. var toObject = __webpack_require__(33);
  11100. var toLength = __webpack_require__(25);
  11101. var asc = __webpack_require__(330);
  11102. module.exports = function (TYPE, $create) {
  11103. var IS_MAP = TYPE == 1;
  11104. var IS_FILTER = TYPE == 2;
  11105. var IS_SOME = TYPE == 3;
  11106. var IS_EVERY = TYPE == 4;
  11107. var IS_FIND_INDEX = TYPE == 6;
  11108. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  11109. var create = $create || asc;
  11110. return function ($this, callbackfn, that) {
  11111. var O = toObject($this);
  11112. var self = IObject(O);
  11113. var f = ctx(callbackfn, that, 3);
  11114. var length = toLength(self.length);
  11115. var index = 0;
  11116. var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  11117. var val, res;
  11118. for (;length > index; index++) if (NO_HOLES || index in self) {
  11119. val = self[index];
  11120. res = f(val, index, O);
  11121. if (TYPE) {
  11122. if (IS_MAP) result[index] = res; // map
  11123. else if (res) switch (TYPE) {
  11124. case 3: return true; // some
  11125. case 5: return val; // find
  11126. case 6: return index; // findIndex
  11127. case 2: result.push(val); // filter
  11128. } else if (IS_EVERY) return false; // every
  11129. }
  11130. }
  11131. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
  11132. };
  11133. };
  11134. /***/ }),
  11135. /* 69 */
  11136. /***/ (function(module, exports) {
  11137. exports.f = Object.getOwnPropertySymbols;
  11138. /***/ }),
  11139. /* 70 */
  11140. /***/ (function(module, exports, __webpack_require__) {
  11141. "use strict";
  11142. var hide = __webpack_require__(31);
  11143. var redefine = __webpack_require__(30);
  11144. var fails = __webpack_require__(23);
  11145. var defined = __webpack_require__(38);
  11146. var wks = __webpack_require__(11);
  11147. module.exports = function (KEY, length, exec) {
  11148. var SYMBOL = wks(KEY);
  11149. var fns = exec(defined, SYMBOL, ''[KEY]);
  11150. var strfn = fns[0];
  11151. var rxfn = fns[1];
  11152. if (fails(function () {
  11153. var O = {};
  11154. O[SYMBOL] = function () { return 7; };
  11155. return ''[KEY](O) != 7;
  11156. })) {
  11157. redefine(String.prototype, KEY, strfn);
  11158. hide(RegExp.prototype, SYMBOL, length == 2
  11159. // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
  11160. // 21.2.5.11 RegExp.prototype[@@split](string, limit)
  11161. ? function (string, arg) { return rxfn.call(string, this, arg); }
  11162. // 21.2.5.6 RegExp.prototype[@@match](string)
  11163. // 21.2.5.9 RegExp.prototype[@@search](string)
  11164. : function (string) { return rxfn.call(string, this); }
  11165. );
  11166. }
  11167. };
  11168. /***/ }),
  11169. /* 71 */
  11170. /***/ (function(module, exports, __webpack_require__) {
  11171. "use strict";
  11172. exports.__esModule = true;
  11173. exports.DEFAULT_LANGUAGE_CODE = exports.getLanguagesDictionaries = exports.getDefaultLanguageDictionary = exports.hasLanguageDictionary = exports.getLanguageDictionary = exports.registerLanguageDictionary = undefined;
  11174. var _object = __webpack_require__(2);
  11175. var _utils = __webpack_require__(317);
  11176. var _staticRegister2 = __webpack_require__(39);
  11177. var _staticRegister3 = _interopRequireDefault(_staticRegister2);
  11178. var _enUS = __webpack_require__(391);
  11179. var _enUS2 = _interopRequireDefault(_enUS);
  11180. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11181. var DEFAULT_LANGUAGE_CODE = _enUS2.default.languageCode;
  11182. var _staticRegister = (0, _staticRegister3.default)('languagesDictionaries'),
  11183. registerGloballyLanguageDictionary = _staticRegister.register,
  11184. getGlobalLanguageDictionary = _staticRegister.getItem,
  11185. hasGlobalLanguageDictionary = _staticRegister.hasItem,
  11186. getGlobalLanguagesDictionaries = _staticRegister.getValues;
  11187. /**
  11188. * Register language dictionary for specific language code.
  11189. *
  11190. * @param {String|Object} languageCodeOrDictionary Language code for specific language i.e. 'en-US', 'pt-BR', 'de-DE' or object representing dictionary.
  11191. * @param {Object} dictionary Dictionary for specific language (optional if first parameter has already dictionary).
  11192. */
  11193. function registerLanguage(languageCodeOrDictionary, dictionary) {
  11194. var languageCode = languageCodeOrDictionary;
  11195. // Dictionary passed as first argument.
  11196. if ((0, _object.isObject)(languageCodeOrDictionary)) {
  11197. dictionary = languageCodeOrDictionary;
  11198. languageCode = dictionary.languageCode;
  11199. }
  11200. extendLanguageDictionary(languageCode, dictionary);
  11201. registerGloballyLanguageDictionary(languageCode, (0, _object.deepClone)(dictionary));
  11202. // We do not allow user to work with dictionary by reference, it can cause lot of bugs.
  11203. return (0, _object.deepClone)(dictionary);
  11204. };
  11205. /**
  11206. * Get language dictionary for specific language code.
  11207. *
  11208. * @param {String} languageCode Language code.
  11209. * @returns {Object} Object with constants representing identifiers for translation (as keys) and corresponding translation phrases (as values).
  11210. */
  11211. function getLanguage(languageCode) {
  11212. if (!hasLanguage(languageCode)) {
  11213. return null;
  11214. }
  11215. return (0, _object.deepClone)(getGlobalLanguageDictionary(languageCode));
  11216. }
  11217. /**
  11218. *
  11219. * Get if language with specified language code was registered.
  11220. *
  11221. * @param {String} languageCode Language code for specific language i.e. 'en-US', 'pt-BR', 'de-DE'.
  11222. * @returns {Boolean}
  11223. */
  11224. function hasLanguage(languageCode) {
  11225. return hasGlobalLanguageDictionary(languageCode);
  11226. }
  11227. /**
  11228. * Get default language dictionary.
  11229. *
  11230. * @returns {Object} Object with constants representing identifiers for translation (as keys) and corresponding translation phrases (as values).
  11231. */
  11232. function getDefaultLanguage() {
  11233. return _enUS2.default;
  11234. }
  11235. /**
  11236. * Extend handled dictionary by default language dictionary. As result, if any dictionary key isn't defined for specific language, it will be filled with default language value ("dictionary gaps" are supplemented).
  11237. *
  11238. * @private
  11239. * @param {String} languageCode Language code.
  11240. * @param {Object} dictionary Dictionary which is extended.
  11241. */
  11242. function extendLanguageDictionary(languageCode, dictionary) {
  11243. if (languageCode !== DEFAULT_LANGUAGE_CODE) {
  11244. (0, _utils.extendNotExistingKeys)(dictionary, getGlobalLanguageDictionary(DEFAULT_LANGUAGE_CODE));
  11245. }
  11246. }
  11247. /**
  11248. * Get registered language dictionaries.
  11249. *
  11250. * @returns {Array}
  11251. */
  11252. function getLanguages() {
  11253. return getGlobalLanguagesDictionaries();
  11254. }
  11255. exports.registerLanguageDictionary = registerLanguage;
  11256. exports.getLanguageDictionary = getLanguage;
  11257. exports.hasLanguageDictionary = hasLanguage;
  11258. exports.getDefaultLanguageDictionary = getDefaultLanguage;
  11259. exports.getLanguagesDictionaries = getLanguages;
  11260. exports.DEFAULT_LANGUAGE_CODE = DEFAULT_LANGUAGE_CODE;
  11261. /**
  11262. * Automatically registers default dictionary.
  11263. */
  11264. registerLanguage(_enUS2.default);
  11265. /***/ }),
  11266. /* 72 */
  11267. /***/ (function(module, exports, __webpack_require__) {
  11268. var isObject = __webpack_require__(9);
  11269. var document = __webpack_require__(14).document;
  11270. // typeof document.createElement is 'object' in old IE
  11271. var is = isObject(document) && isObject(document.createElement);
  11272. module.exports = function (it) {
  11273. return is ? document.createElement(it) : {};
  11274. };
  11275. /***/ }),
  11276. /* 73 */
  11277. /***/ (function(module, exports, __webpack_require__) {
  11278. // 7.1.1 ToPrimitive(input [, PreferredType])
  11279. var isObject = __webpack_require__(9);
  11280. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  11281. // and the second argument - flag - preferred type is a string
  11282. module.exports = function (it, S) {
  11283. if (!isObject(it)) return it;
  11284. var fn, val;
  11285. if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  11286. if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
  11287. if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  11288. throw TypeError("Can't convert object to primitive value");
  11289. };
  11290. /***/ }),
  11291. /* 74 */
  11292. /***/ (function(module, exports, __webpack_require__) {
  11293. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  11294. var anObject = __webpack_require__(18);
  11295. var dPs = __webpack_require__(327);
  11296. var enumBugKeys = __webpack_require__(78);
  11297. var IE_PROTO = __webpack_require__(76)('IE_PROTO');
  11298. var Empty = function () { /* empty */ };
  11299. var PROTOTYPE = 'prototype';
  11300. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  11301. var createDict = function () {
  11302. // Thrash, waste and sodomy: IE GC bug
  11303. var iframe = __webpack_require__(72)('iframe');
  11304. var i = enumBugKeys.length;
  11305. var lt = '<';
  11306. var gt = '>';
  11307. var iframeDocument;
  11308. iframe.style.display = 'none';
  11309. __webpack_require__(101).appendChild(iframe);
  11310. iframe.src = 'javascript:'; // eslint-disable-line no-script-url
  11311. // createDict = iframe.contentWindow.Object;
  11312. // html.removeChild(iframe);
  11313. iframeDocument = iframe.contentWindow.document;
  11314. iframeDocument.open();
  11315. iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
  11316. iframeDocument.close();
  11317. createDict = iframeDocument.F;
  11318. while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];
  11319. return createDict();
  11320. };
  11321. module.exports = Object.create || function create(O, Properties) {
  11322. var result;
  11323. if (O !== null) {
  11324. Empty[PROTOTYPE] = anObject(O);
  11325. result = new Empty();
  11326. Empty[PROTOTYPE] = null;
  11327. // add "__proto__" for Object.getPrototypeOf polyfill
  11328. result[IE_PROTO] = O;
  11329. } else result = createDict();
  11330. return Properties === undefined ? result : dPs(result, Properties);
  11331. };
  11332. /***/ }),
  11333. /* 75 */
  11334. /***/ (function(module, exports, __webpack_require__) {
  11335. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  11336. var cof = __webpack_require__(44);
  11337. // eslint-disable-next-line no-prototype-builtins
  11338. module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
  11339. return cof(it) == 'String' ? it.split('') : Object(it);
  11340. };
  11341. /***/ }),
  11342. /* 76 */
  11343. /***/ (function(module, exports, __webpack_require__) {
  11344. var shared = __webpack_require__(77)('keys');
  11345. var uid = __webpack_require__(49);
  11346. module.exports = function (key) {
  11347. return shared[key] || (shared[key] = uid(key));
  11348. };
  11349. /***/ }),
  11350. /* 77 */
  11351. /***/ (function(module, exports, __webpack_require__) {
  11352. var global = __webpack_require__(14);
  11353. var SHARED = '__core-js_shared__';
  11354. var store = global[SHARED] || (global[SHARED] = {});
  11355. module.exports = function (key) {
  11356. return store[key] || (store[key] = {});
  11357. };
  11358. /***/ }),
  11359. /* 78 */
  11360. /***/ (function(module, exports) {
  11361. // IE 8- don't enum bug keys
  11362. module.exports = (
  11363. 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
  11364. ).split(',');
  11365. /***/ }),
  11366. /* 79 */
  11367. /***/ (function(module, exports, __webpack_require__) {
  11368. var ITERATOR = __webpack_require__(11)('iterator');
  11369. var SAFE_CLOSING = false;
  11370. try {
  11371. var riter = [7][ITERATOR]();
  11372. riter['return'] = function () { SAFE_CLOSING = true; };
  11373. // eslint-disable-next-line no-throw-literal
  11374. Array.from(riter, function () { throw 2; });
  11375. } catch (e) { /* empty */ }
  11376. module.exports = function (exec, skipClosing) {
  11377. if (!skipClosing && !SAFE_CLOSING) return false;
  11378. var safe = false;
  11379. try {
  11380. var arr = [7];
  11381. var iter = arr[ITERATOR]();
  11382. iter.next = function () { return { done: safe = true }; };
  11383. arr[ITERATOR] = function () { return iter; };
  11384. exec(arr);
  11385. } catch (e) { /* empty */ }
  11386. return safe;
  11387. };
  11388. /***/ }),
  11389. /* 80 */
  11390. /***/ (function(module, exports, __webpack_require__) {
  11391. var ctx = __webpack_require__(32);
  11392. var invoke = __webpack_require__(333);
  11393. var html = __webpack_require__(101);
  11394. var cel = __webpack_require__(72);
  11395. var global = __webpack_require__(14);
  11396. var process = global.process;
  11397. var setTask = global.setImmediate;
  11398. var clearTask = global.clearImmediate;
  11399. var MessageChannel = global.MessageChannel;
  11400. var Dispatch = global.Dispatch;
  11401. var counter = 0;
  11402. var queue = {};
  11403. var ONREADYSTATECHANGE = 'onreadystatechange';
  11404. var defer, channel, port;
  11405. var run = function () {
  11406. var id = +this;
  11407. // eslint-disable-next-line no-prototype-builtins
  11408. if (queue.hasOwnProperty(id)) {
  11409. var fn = queue[id];
  11410. delete queue[id];
  11411. fn();
  11412. }
  11413. };
  11414. var listener = function (event) {
  11415. run.call(event.data);
  11416. };
  11417. // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
  11418. if (!setTask || !clearTask) {
  11419. setTask = function setImmediate(fn) {
  11420. var args = [];
  11421. var i = 1;
  11422. while (arguments.length > i) args.push(arguments[i++]);
  11423. queue[++counter] = function () {
  11424. // eslint-disable-next-line no-new-func
  11425. invoke(typeof fn == 'function' ? fn : Function(fn), args);
  11426. };
  11427. defer(counter);
  11428. return counter;
  11429. };
  11430. clearTask = function clearImmediate(id) {
  11431. delete queue[id];
  11432. };
  11433. // Node.js 0.8-
  11434. if (__webpack_require__(44)(process) == 'process') {
  11435. defer = function (id) {
  11436. process.nextTick(ctx(run, id, 1));
  11437. };
  11438. // Sphere (JS game engine) Dispatch API
  11439. } else if (Dispatch && Dispatch.now) {
  11440. defer = function (id) {
  11441. Dispatch.now(ctx(run, id, 1));
  11442. };
  11443. // Browsers with MessageChannel, includes WebWorkers
  11444. } else if (MessageChannel) {
  11445. channel = new MessageChannel();
  11446. port = channel.port2;
  11447. channel.port1.onmessage = listener;
  11448. defer = ctx(port.postMessage, port, 1);
  11449. // Browsers with postMessage, skip WebWorkers
  11450. // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
  11451. } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) {
  11452. defer = function (id) {
  11453. global.postMessage(id + '', '*');
  11454. };
  11455. global.addEventListener('message', listener, false);
  11456. // IE8-
  11457. } else if (ONREADYSTATECHANGE in cel('script')) {
  11458. defer = function (id) {
  11459. html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function () {
  11460. html.removeChild(this);
  11461. run.call(id);
  11462. };
  11463. };
  11464. // Rest old browsers
  11465. } else {
  11466. defer = function (id) {
  11467. setTimeout(ctx(run, id, 1), 0);
  11468. };
  11469. }
  11470. }
  11471. module.exports = {
  11472. set: setTask,
  11473. clear: clearTask
  11474. };
  11475. /***/ }),
  11476. /* 81 */
  11477. /***/ (function(module, exports, __webpack_require__) {
  11478. // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
  11479. var $keys = __webpack_require__(99);
  11480. var hiddenKeys = __webpack_require__(78).concat('length', 'prototype');
  11481. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  11482. return $keys(O, hiddenKeys);
  11483. };
  11484. /***/ }),
  11485. /* 82 */
  11486. /***/ (function(module, exports, __webpack_require__) {
  11487. // helper for String#{startsWith, endsWith, includes}
  11488. var isRegExp = __webpack_require__(142);
  11489. var defined = __webpack_require__(38);
  11490. module.exports = function (that, searchString, NAME) {
  11491. if (isRegExp(searchString)) throw TypeError('String#' + NAME + " doesn't accept regex!");
  11492. return String(defined(that));
  11493. };
  11494. /***/ }),
  11495. /* 83 */
  11496. /***/ (function(module, exports, __webpack_require__) {
  11497. var MATCH = __webpack_require__(11)('match');
  11498. module.exports = function (KEY) {
  11499. var re = /./;
  11500. try {
  11501. '/./'[KEY](re);
  11502. } catch (e) {
  11503. try {
  11504. re[MATCH] = false;
  11505. return !'/./'[KEY](re);
  11506. } catch (f) { /* empty */ }
  11507. } return true;
  11508. };
  11509. /***/ }),
  11510. /* 84 */
  11511. /***/ (function(module, exports, __webpack_require__) {
  11512. "use strict";
  11513. var $defineProperty = __webpack_require__(20);
  11514. var createDesc = __webpack_require__(50);
  11515. module.exports = function (object, index, value) {
  11516. if (index in object) $defineProperty.f(object, index, createDesc(0, value));
  11517. else object[index] = value;
  11518. };
  11519. /***/ }),
  11520. /* 85 */
  11521. /***/ (function(module, exports, __webpack_require__) {
  11522. "use strict";
  11523. var addToUnscopables = __webpack_require__(47);
  11524. var step = __webpack_require__(108);
  11525. var Iterators = __webpack_require__(51);
  11526. var toIObject = __webpack_require__(24);
  11527. // 22.1.3.4 Array.prototype.entries()
  11528. // 22.1.3.13 Array.prototype.keys()
  11529. // 22.1.3.29 Array.prototype.values()
  11530. // 22.1.3.30 Array.prototype[@@iterator]()
  11531. module.exports = __webpack_require__(106)(Array, 'Array', function (iterated, kind) {
  11532. this._t = toIObject(iterated); // target
  11533. this._i = 0; // next index
  11534. this._k = kind; // kind
  11535. // 22.1.5.2.1 %ArrayIteratorPrototype%.next()
  11536. }, function () {
  11537. var O = this._t;
  11538. var kind = this._k;
  11539. var index = this._i++;
  11540. if (!O || index >= O.length) {
  11541. this._t = undefined;
  11542. return step(1);
  11543. }
  11544. if (kind == 'keys') return step(0, index);
  11545. if (kind == 'values') return step(0, O[index]);
  11546. return step(0, [index, O[index]]);
  11547. }, 'values');
  11548. // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
  11549. Iterators.Arguments = Iterators.Array;
  11550. addToUnscopables('keys');
  11551. addToUnscopables('values');
  11552. addToUnscopables('entries');
  11553. /***/ }),
  11554. /* 86 */
  11555. /***/ (function(module, exports, __webpack_require__) {
  11556. "use strict";
  11557. exports.__esModule = true;
  11558. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  11559. var _coords = __webpack_require__(55);
  11560. var _coords2 = _interopRequireDefault(_coords);
  11561. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11562. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11563. /**
  11564. * A cell range is a set of exactly two CellCoords (that can be the same or different).
  11565. *
  11566. * @class CellRange
  11567. */
  11568. var CellRange = function () {
  11569. /**
  11570. * @param {CellCoords} highlight Used to draw bold border around a cell where selection was
  11571. * started and to edit the cell when you press Enter.
  11572. * @param {CellCoords} [from] Usually the same as highlight, but in Excel there is distinction - one can change
  11573. * highlight within a selection.
  11574. * @param {CellCoords} [to] End selection.
  11575. */
  11576. function CellRange(highlight) {
  11577. var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : highlight;
  11578. var to = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : highlight;
  11579. _classCallCheck(this, CellRange);
  11580. this.highlight = highlight;
  11581. this.from = from;
  11582. this.to = to;
  11583. }
  11584. /**
  11585. * Set the new coordinates for highlighting selection.
  11586. *
  11587. * @param {CellCoords} coords Coordinates to use.
  11588. */
  11589. _createClass(CellRange, [{
  11590. key: 'setHighlight',
  11591. value: function setHighlight(coords) {
  11592. this.highlight = coords;
  11593. return this;
  11594. }
  11595. /**
  11596. * Set the new coordinates where selection starts from.
  11597. *
  11598. * @param {CellCoords} coords Coordinates to use.
  11599. */
  11600. }, {
  11601. key: 'setFrom',
  11602. value: function setFrom(coords) {
  11603. this.from = coords;
  11604. return this;
  11605. }
  11606. /**
  11607. * Set new coordinates where selection ends from.
  11608. *
  11609. * @param {CellCoords} coords Coordinates to use.
  11610. */
  11611. }, {
  11612. key: 'setTo',
  11613. value: function setTo(coords) {
  11614. this.to = coords;
  11615. return this;
  11616. }
  11617. /**
  11618. * Checks if given coords are valid in context of a given Walkontable instance
  11619. *
  11620. * @param {Walkontable} wotInstance
  11621. * @returns {Boolean}
  11622. */
  11623. }, {
  11624. key: 'isValid',
  11625. value: function isValid(wotInstance) {
  11626. return this.from.isValid(wotInstance) && this.to.isValid(wotInstance);
  11627. }
  11628. /**
  11629. * Checks if this cell range is restricted to one cell
  11630. *
  11631. * @returns {Boolean}
  11632. */
  11633. }, {
  11634. key: 'isSingle',
  11635. value: function isSingle() {
  11636. return this.from.row === this.to.row && this.from.col === this.to.col;
  11637. }
  11638. /**
  11639. * Returns selected range height (in number of rows)
  11640. *
  11641. * @returns {Number}
  11642. */
  11643. }, {
  11644. key: 'getHeight',
  11645. value: function getHeight() {
  11646. return Math.max(this.from.row, this.to.row) - Math.min(this.from.row, this.to.row) + 1;
  11647. }
  11648. /**
  11649. * Returns selected range width (in number of columns)
  11650. *
  11651. * @returns {Number}
  11652. */
  11653. }, {
  11654. key: 'getWidth',
  11655. value: function getWidth() {
  11656. return Math.max(this.from.col, this.to.col) - Math.min(this.from.col, this.to.col) + 1;
  11657. }
  11658. /**
  11659. * Checks if given cell coords is within `from` and `to` cell coords of this range
  11660. *
  11661. * @param {CellCoords} cellCoords
  11662. * @returns {Boolean}
  11663. */
  11664. }, {
  11665. key: 'includes',
  11666. value: function includes(cellCoords) {
  11667. var row = cellCoords.row,
  11668. col = cellCoords.col;
  11669. var topLeft = this.getTopLeftCorner();
  11670. var bottomRight = this.getBottomRightCorner();
  11671. return topLeft.row <= row && bottomRight.row >= row && topLeft.col <= col && bottomRight.col >= col;
  11672. }
  11673. /**
  11674. * Checks if given range is within of this range
  11675. *
  11676. * @param {CellRange} testedRange
  11677. * @returns {Boolean}
  11678. */
  11679. }, {
  11680. key: 'includesRange',
  11681. value: function includesRange(testedRange) {
  11682. return this.includes(testedRange.getTopLeftCorner()) && this.includes(testedRange.getBottomRightCorner());
  11683. }
  11684. /**
  11685. * Checks if given range is equal to this range
  11686. *
  11687. * @param {CellRange} testedRange
  11688. * @returns {Boolean}
  11689. */
  11690. }, {
  11691. key: 'isEqual',
  11692. value: function isEqual(testedRange) {
  11693. return Math.min(this.from.row, this.to.row) === Math.min(testedRange.from.row, testedRange.to.row) && Math.max(this.from.row, this.to.row) === Math.max(testedRange.from.row, testedRange.to.row) && Math.min(this.from.col, this.to.col) === Math.min(testedRange.from.col, testedRange.to.col) && Math.max(this.from.col, this.to.col) === Math.max(testedRange.from.col, testedRange.to.col);
  11694. }
  11695. /**
  11696. * Checks if tested range overlaps with the range.
  11697. * Range A is considered to to be overlapping with range B if intersection of A and B or B and A is not empty.
  11698. *
  11699. * @param {CellRange} testedRange
  11700. * @returns {Boolean}
  11701. */
  11702. }, {
  11703. key: 'overlaps',
  11704. value: function overlaps(testedRange) {
  11705. return testedRange.isSouthEastOf(this.getTopLeftCorner()) && testedRange.isNorthWestOf(this.getBottomRightCorner());
  11706. }
  11707. /**
  11708. * @param {CellRange} testedCoords
  11709. * @returns {Boolean}
  11710. */
  11711. }, {
  11712. key: 'isSouthEastOf',
  11713. value: function isSouthEastOf(testedCoords) {
  11714. return this.getTopLeftCorner().isSouthEastOf(testedCoords) || this.getBottomRightCorner().isSouthEastOf(testedCoords);
  11715. }
  11716. /**
  11717. * @param {CellRange} testedCoords
  11718. * @returns {Boolean}
  11719. */
  11720. }, {
  11721. key: 'isNorthWestOf',
  11722. value: function isNorthWestOf(testedCoords) {
  11723. return this.getTopLeftCorner().isNorthWestOf(testedCoords) || this.getBottomRightCorner().isNorthWestOf(testedCoords);
  11724. }
  11725. /**
  11726. * Returns `true` if the provided range is overlapping the current range horizontally
  11727. * (e.g. the current range's last column is 5 and the provided range's first column is 3).
  11728. *
  11729. * @param {CellRange} range The range to check against.
  11730. * @returns {Boolean}
  11731. */
  11732. }, {
  11733. key: 'isOverlappingHorizontally',
  11734. value: function isOverlappingHorizontally(range) {
  11735. return this.getTopRightCorner().col >= range.getTopLeftCorner().col && this.getTopRightCorner().col <= range.getTopRightCorner().col || this.getTopLeftCorner().col <= range.getTopRightCorner().col && this.getTopLeftCorner().col >= range.getTopLeftCorner().col;
  11736. }
  11737. /**
  11738. * Returns `true` if the provided range is overlapping the current range vertically
  11739. * (e.g. the current range's last row is 5 and the provided range's first row is 3).
  11740. *
  11741. * @param {CellRange} range The range to check against.
  11742. * @returns {Boolean}
  11743. */
  11744. }, {
  11745. key: 'isOverlappingVertically',
  11746. value: function isOverlappingVertically(range) {
  11747. return this.getBottomRightCorner().row >= range.getTopRightCorner().row && this.getBottomRightCorner().row <= range.getBottomRightCorner().row || this.getTopRightCorner().row <= range.getBottomRightCorner().row && this.getTopRightCorner().row >= range.getTopRightCorner().row;
  11748. }
  11749. /**
  11750. * Adds a cell to a range (only if exceeds corners of the range). Returns information if range was expanded
  11751. *
  11752. * @param {CellCoords} cellCoords
  11753. * @returns {Boolean}
  11754. */
  11755. }, {
  11756. key: 'expand',
  11757. value: function expand(cellCoords) {
  11758. var topLeft = this.getTopLeftCorner();
  11759. var bottomRight = this.getBottomRightCorner();
  11760. if (cellCoords.row < topLeft.row || cellCoords.col < topLeft.col || cellCoords.row > bottomRight.row || cellCoords.col > bottomRight.col) {
  11761. this.from = new _coords2.default(Math.min(topLeft.row, cellCoords.row), Math.min(topLeft.col, cellCoords.col));
  11762. this.to = new _coords2.default(Math.max(bottomRight.row, cellCoords.row), Math.max(bottomRight.col, cellCoords.col));
  11763. return true;
  11764. }
  11765. return false;
  11766. }
  11767. /**
  11768. * @param {CellRange} expandingRange
  11769. * @returns {Boolean}
  11770. */
  11771. }, {
  11772. key: 'expandByRange',
  11773. value: function expandByRange(expandingRange) {
  11774. if (this.includesRange(expandingRange) || !this.overlaps(expandingRange)) {
  11775. return false;
  11776. }
  11777. var topLeft = this.getTopLeftCorner();
  11778. var bottomRight = this.getBottomRightCorner();
  11779. var initialDirection = this.getDirection();
  11780. var expandingTopLeft = expandingRange.getTopLeftCorner();
  11781. var expandingBottomRight = expandingRange.getBottomRightCorner();
  11782. var resultTopRow = Math.min(topLeft.row, expandingTopLeft.row);
  11783. var resultTopCol = Math.min(topLeft.col, expandingTopLeft.col);
  11784. var resultBottomRow = Math.max(bottomRight.row, expandingBottomRight.row);
  11785. var resultBottomCol = Math.max(bottomRight.col, expandingBottomRight.col);
  11786. var finalFrom = new _coords2.default(resultTopRow, resultTopCol);
  11787. var finalTo = new _coords2.default(resultBottomRow, resultBottomCol);
  11788. this.from = finalFrom;
  11789. this.to = finalTo;
  11790. this.setDirection(initialDirection);
  11791. if (this.highlight.row === this.getBottomRightCorner().row && this.getVerticalDirection() === 'N-S') {
  11792. this.flipDirectionVertically();
  11793. }
  11794. if (this.highlight.col === this.getTopRightCorner().col && this.getHorizontalDirection() === 'W-E') {
  11795. this.flipDirectionHorizontally();
  11796. }
  11797. return true;
  11798. }
  11799. /**
  11800. * @returns {String}
  11801. */
  11802. }, {
  11803. key: 'getDirection',
  11804. value: function getDirection() {
  11805. if (this.from.isNorthWestOf(this.to)) {
  11806. // NorthWest - SouthEast
  11807. return 'NW-SE';
  11808. } else if (this.from.isNorthEastOf(this.to)) {
  11809. // NorthEast - SouthWest
  11810. return 'NE-SW';
  11811. } else if (this.from.isSouthEastOf(this.to)) {
  11812. // SouthEast - NorthWest
  11813. return 'SE-NW';
  11814. } else if (this.from.isSouthWestOf(this.to)) {
  11815. // SouthWest - NorthEast
  11816. return 'SW-NE';
  11817. }
  11818. }
  11819. /**
  11820. * Get the vertical direction of the range.
  11821. *
  11822. * @returns {String} Available options: `N-S` (north->south), `S-N` (south->north).
  11823. */
  11824. }, {
  11825. key: 'getVerticalDirection',
  11826. value: function getVerticalDirection() {
  11827. return ['NE-SW', 'NW-SE'].indexOf(this.getDirection()) > -1 ? 'N-S' : 'S-N';
  11828. }
  11829. /**
  11830. * Get the horizontal direction of the range.
  11831. *
  11832. * @returns {String} Available options: `W-E` (west->east), `E-W` (east->west).
  11833. */
  11834. }, {
  11835. key: 'getHorizontalDirection',
  11836. value: function getHorizontalDirection() {
  11837. return ['NW-SE', 'SW-NE'].indexOf(this.getDirection()) > -1 ? 'W-E' : 'E-W';
  11838. }
  11839. /**
  11840. * @param {String} direction
  11841. */
  11842. }, {
  11843. key: 'setDirection',
  11844. value: function setDirection(direction) {
  11845. switch (direction) {
  11846. case 'NW-SE':
  11847. var _ref = [this.getTopLeftCorner(), this.getBottomRightCorner()];
  11848. this.from = _ref[0];
  11849. this.to = _ref[1];
  11850. break;
  11851. case 'NE-SW':
  11852. var _ref2 = [this.getTopRightCorner(), this.getBottomLeftCorner()];
  11853. this.from = _ref2[0];
  11854. this.to = _ref2[1];
  11855. break;
  11856. case 'SE-NW':
  11857. var _ref3 = [this.getBottomRightCorner(), this.getTopLeftCorner()];
  11858. this.from = _ref3[0];
  11859. this.to = _ref3[1];
  11860. break;
  11861. case 'SW-NE':
  11862. var _ref4 = [this.getBottomLeftCorner(), this.getTopRightCorner()];
  11863. this.from = _ref4[0];
  11864. this.to = _ref4[1];
  11865. break;
  11866. default:
  11867. break;
  11868. }
  11869. }
  11870. /**
  11871. * Flip the direction vertically. (e.g. `NW-SE` changes to `SW-NE`)
  11872. */
  11873. }, {
  11874. key: 'flipDirectionVertically',
  11875. value: function flipDirectionVertically() {
  11876. var direction = this.getDirection();
  11877. switch (direction) {
  11878. case 'NW-SE':
  11879. this.setDirection('SW-NE');
  11880. break;
  11881. case 'NE-SW':
  11882. this.setDirection('SE-NW');
  11883. break;
  11884. case 'SE-NW':
  11885. this.setDirection('NE-SW');
  11886. break;
  11887. case 'SW-NE':
  11888. this.setDirection('NW-SE');
  11889. break;
  11890. default:
  11891. break;
  11892. }
  11893. }
  11894. /**
  11895. * Flip the direction horizontally. (e.g. `NW-SE` changes to `NE-SW`)
  11896. */
  11897. }, {
  11898. key: 'flipDirectionHorizontally',
  11899. value: function flipDirectionHorizontally() {
  11900. var direction = this.getDirection();
  11901. switch (direction) {
  11902. case 'NW-SE':
  11903. this.setDirection('NE-SW');
  11904. break;
  11905. case 'NE-SW':
  11906. this.setDirection('NW-SE');
  11907. break;
  11908. case 'SE-NW':
  11909. this.setDirection('SW-NE');
  11910. break;
  11911. case 'SW-NE':
  11912. this.setDirection('SE-NW');
  11913. break;
  11914. default:
  11915. break;
  11916. }
  11917. }
  11918. /**
  11919. * Get top left corner of this range
  11920. *
  11921. * @returns {CellCoords}
  11922. */
  11923. }, {
  11924. key: 'getTopLeftCorner',
  11925. value: function getTopLeftCorner() {
  11926. return new _coords2.default(Math.min(this.from.row, this.to.row), Math.min(this.from.col, this.to.col));
  11927. }
  11928. /**
  11929. * Get bottom right corner of this range
  11930. *
  11931. * @returns {CellCoords}
  11932. */
  11933. }, {
  11934. key: 'getBottomRightCorner',
  11935. value: function getBottomRightCorner() {
  11936. return new _coords2.default(Math.max(this.from.row, this.to.row), Math.max(this.from.col, this.to.col));
  11937. }
  11938. /**
  11939. * Get top right corner of this range
  11940. *
  11941. * @returns {CellCoords}
  11942. */
  11943. }, {
  11944. key: 'getTopRightCorner',
  11945. value: function getTopRightCorner() {
  11946. return new _coords2.default(Math.min(this.from.row, this.to.row), Math.max(this.from.col, this.to.col));
  11947. }
  11948. /**
  11949. * Get bottom left corner of this range
  11950. *
  11951. * @returns {CellCoords}
  11952. */
  11953. }, {
  11954. key: 'getBottomLeftCorner',
  11955. value: function getBottomLeftCorner() {
  11956. return new _coords2.default(Math.max(this.from.row, this.to.row), Math.min(this.from.col, this.to.col));
  11957. }
  11958. /**
  11959. * @param {CellCoords} coords
  11960. * @param {CellRange} expandedRange
  11961. * @returns {*}
  11962. */
  11963. }, {
  11964. key: 'isCorner',
  11965. value: function isCorner(coords, expandedRange) {
  11966. if (expandedRange && expandedRange.includes(coords) && (this.getTopLeftCorner().isEqual(new _coords2.default(expandedRange.from.row, expandedRange.from.col)) || this.getTopRightCorner().isEqual(new _coords2.default(expandedRange.from.row, expandedRange.to.col)) || this.getBottomLeftCorner().isEqual(new _coords2.default(expandedRange.to.row, expandedRange.from.col)) || this.getBottomRightCorner().isEqual(new _coords2.default(expandedRange.to.row, expandedRange.to.col)))) {
  11967. return true;
  11968. }
  11969. return coords.isEqual(this.getTopLeftCorner()) || coords.isEqual(this.getTopRightCorner()) || coords.isEqual(this.getBottomLeftCorner()) || coords.isEqual(this.getBottomRightCorner());
  11970. }
  11971. /**
  11972. * @param {CellCoords} coords
  11973. * @param {CellRange} expandedRange
  11974. * @returns {CellCoords}
  11975. */
  11976. }, {
  11977. key: 'getOppositeCorner',
  11978. value: function getOppositeCorner(coords, expandedRange) {
  11979. if (!(coords instanceof _coords2.default)) {
  11980. return false;
  11981. }
  11982. if (expandedRange) {
  11983. if (expandedRange.includes(coords)) {
  11984. if (this.getTopLeftCorner().isEqual(new _coords2.default(expandedRange.from.row, expandedRange.from.col))) {
  11985. return this.getBottomRightCorner();
  11986. }
  11987. if (this.getTopRightCorner().isEqual(new _coords2.default(expandedRange.from.row, expandedRange.to.col))) {
  11988. return this.getBottomLeftCorner();
  11989. }
  11990. if (this.getBottomLeftCorner().isEqual(new _coords2.default(expandedRange.to.row, expandedRange.from.col))) {
  11991. return this.getTopRightCorner();
  11992. }
  11993. if (this.getBottomRightCorner().isEqual(new _coords2.default(expandedRange.to.row, expandedRange.to.col))) {
  11994. return this.getTopLeftCorner();
  11995. }
  11996. }
  11997. }
  11998. if (coords.isEqual(this.getBottomRightCorner())) {
  11999. return this.getTopLeftCorner();
  12000. } else if (coords.isEqual(this.getTopLeftCorner())) {
  12001. return this.getBottomRightCorner();
  12002. } else if (coords.isEqual(this.getTopRightCorner())) {
  12003. return this.getBottomLeftCorner();
  12004. } else if (coords.isEqual(this.getBottomLeftCorner())) {
  12005. return this.getTopRightCorner();
  12006. }
  12007. }
  12008. /**
  12009. * @param {CellRange} range
  12010. * @returns {Array}
  12011. */
  12012. }, {
  12013. key: 'getBordersSharedWith',
  12014. value: function getBordersSharedWith(range) {
  12015. if (!this.includesRange(range)) {
  12016. return [];
  12017. }
  12018. var thisBorders = {
  12019. top: Math.min(this.from.row, this.to.row),
  12020. bottom: Math.max(this.from.row, this.to.row),
  12021. left: Math.min(this.from.col, this.to.col),
  12022. right: Math.max(this.from.col, this.to.col)
  12023. };
  12024. var rangeBorders = {
  12025. top: Math.min(range.from.row, range.to.row),
  12026. bottom: Math.max(range.from.row, range.to.row),
  12027. left: Math.min(range.from.col, range.to.col),
  12028. right: Math.max(range.from.col, range.to.col)
  12029. };
  12030. var result = [];
  12031. if (thisBorders.top == rangeBorders.top) {
  12032. result.push('top');
  12033. }
  12034. if (thisBorders.right == rangeBorders.right) {
  12035. result.push('right');
  12036. }
  12037. if (thisBorders.bottom == rangeBorders.bottom) {
  12038. result.push('bottom');
  12039. }
  12040. if (thisBorders.left == rangeBorders.left) {
  12041. result.push('left');
  12042. }
  12043. return result;
  12044. }
  12045. /**
  12046. * Get inner selected cell coords defined by this range
  12047. *
  12048. * @returns {Array}
  12049. */
  12050. }, {
  12051. key: 'getInner',
  12052. value: function getInner() {
  12053. var topLeft = this.getTopLeftCorner();
  12054. var bottomRight = this.getBottomRightCorner();
  12055. var out = [];
  12056. for (var r = topLeft.row; r <= bottomRight.row; r++) {
  12057. for (var c = topLeft.col; c <= bottomRight.col; c++) {
  12058. if (!(this.from.row === r && this.from.col === c) && !(this.to.row === r && this.to.col === c)) {
  12059. out.push(new _coords2.default(r, c));
  12060. }
  12061. }
  12062. }
  12063. return out;
  12064. }
  12065. /**
  12066. * Get all selected cell coords defined by this range
  12067. *
  12068. * @returns {Array}
  12069. */
  12070. }, {
  12071. key: 'getAll',
  12072. value: function getAll() {
  12073. var topLeft = this.getTopLeftCorner();
  12074. var bottomRight = this.getBottomRightCorner();
  12075. var out = [];
  12076. for (var r = topLeft.row; r <= bottomRight.row; r++) {
  12077. for (var c = topLeft.col; c <= bottomRight.col; c++) {
  12078. if (topLeft.row === r && topLeft.col === c) {
  12079. out.push(topLeft);
  12080. } else if (bottomRight.row === r && bottomRight.col === c) {
  12081. out.push(bottomRight);
  12082. } else {
  12083. out.push(new _coords2.default(r, c));
  12084. }
  12085. }
  12086. }
  12087. return out;
  12088. }
  12089. /**
  12090. * Runs a callback function against all cells in the range. You can break the iteration by returning
  12091. * `false` in the callback function
  12092. *
  12093. * @param callback {Function}
  12094. */
  12095. }, {
  12096. key: 'forAll',
  12097. value: function forAll(callback) {
  12098. var topLeft = this.getTopLeftCorner();
  12099. var bottomRight = this.getBottomRightCorner();
  12100. for (var r = topLeft.row; r <= bottomRight.row; r++) {
  12101. for (var c = topLeft.col; c <= bottomRight.col; c++) {
  12102. var breakIteration = callback(r, c);
  12103. if (breakIteration === false) {
  12104. return;
  12105. }
  12106. }
  12107. }
  12108. }
  12109. /**
  12110. * Convert CellRange to literal object.
  12111. *
  12112. * @return {Object} Returns a literal object with `from` and `to` properties which each of that object
  12113. * contains `row` and `col` keys.
  12114. */
  12115. }, {
  12116. key: 'toObject',
  12117. value: function toObject() {
  12118. return {
  12119. from: this.from.toObject(),
  12120. to: this.to.toObject()
  12121. };
  12122. }
  12123. }]);
  12124. return CellRange;
  12125. }();
  12126. exports.default = CellRange;
  12127. /***/ }),
  12128. /* 87 */
  12129. /***/ (function(module, exports, __webpack_require__) {
  12130. "use strict";
  12131. exports.__esModule = true;
  12132. exports.getRegisteredCellTypes = exports.getRegisteredCellTypeNames = exports.hasCellType = exports.getCellType = exports.registerCellType = undefined;
  12133. var _staticRegister2 = __webpack_require__(39);
  12134. var _staticRegister3 = _interopRequireDefault(_staticRegister2);
  12135. var _editors = __webpack_require__(17);
  12136. var _renderers = __webpack_require__(13);
  12137. var _validators = __webpack_require__(28);
  12138. var _autocompleteType = __webpack_require__(376);
  12139. var _autocompleteType2 = _interopRequireDefault(_autocompleteType);
  12140. var _checkboxType = __webpack_require__(377);
  12141. var _checkboxType2 = _interopRequireDefault(_checkboxType);
  12142. var _dateType = __webpack_require__(378);
  12143. var _dateType2 = _interopRequireDefault(_dateType);
  12144. var _dropdownType = __webpack_require__(379);
  12145. var _dropdownType2 = _interopRequireDefault(_dropdownType);
  12146. var _handsontableType = __webpack_require__(380);
  12147. var _handsontableType2 = _interopRequireDefault(_handsontableType);
  12148. var _numericType = __webpack_require__(381);
  12149. var _numericType2 = _interopRequireDefault(_numericType);
  12150. var _passwordType = __webpack_require__(382);
  12151. var _passwordType2 = _interopRequireDefault(_passwordType);
  12152. var _textType = __webpack_require__(383);
  12153. var _textType2 = _interopRequireDefault(_textType);
  12154. var _timeType = __webpack_require__(384);
  12155. var _timeType2 = _interopRequireDefault(_timeType);
  12156. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12157. var _staticRegister = (0, _staticRegister3.default)('cellTypes'),
  12158. register = _staticRegister.register,
  12159. getItem = _staticRegister.getItem,
  12160. hasItem = _staticRegister.hasItem,
  12161. getNames = _staticRegister.getNames,
  12162. getValues = _staticRegister.getValues;
  12163. _register('autocomplete', _autocompleteType2.default);
  12164. _register('checkbox', _checkboxType2.default);
  12165. _register('date', _dateType2.default);
  12166. _register('dropdown', _dropdownType2.default);
  12167. _register('handsontable', _handsontableType2.default);
  12168. _register('numeric', _numericType2.default);
  12169. _register('password', _passwordType2.default);
  12170. _register('text', _textType2.default);
  12171. _register('time', _timeType2.default);
  12172. /**
  12173. * Retrieve cell type object.
  12174. *
  12175. * @param {String} name Cell type identification.
  12176. * @returns {Object} Returns cell type object.
  12177. */
  12178. function _getItem(name) {
  12179. if (!hasItem(name)) {
  12180. throw Error('You declared cell type "' + name + '" as a string that is not mapped to a known object.\n Cell type must be an object or a string mapped to an object registered by "Handsontable.cellTypes.registerCellType" method');
  12181. }
  12182. return getItem(name);
  12183. }
  12184. /**
  12185. * Register cell type under specified name.
  12186. *
  12187. * @param {String} name Cell type identification.
  12188. * @param {Object} type An object with contains keys (eq: `editor`, `renderer`, `validator`) which describes specified behaviour of the cell.
  12189. */
  12190. function _register(name, type) {
  12191. var editor = type.editor,
  12192. renderer = type.renderer,
  12193. validator = type.validator;
  12194. if (editor) {
  12195. (0, _editors.registerEditor)(name, editor);
  12196. }
  12197. if (renderer) {
  12198. (0, _renderers.registerRenderer)(name, renderer);
  12199. }
  12200. if (validator) {
  12201. (0, _validators.registerValidator)(name, validator);
  12202. }
  12203. register(name, type);
  12204. }
  12205. exports.registerCellType = _register;
  12206. exports.getCellType = _getItem;
  12207. exports.hasCellType = hasItem;
  12208. exports.getRegisteredCellTypeNames = getNames;
  12209. exports.getRegisteredCellTypes = getValues;
  12210. /***/ }),
  12211. /* 88 */
  12212. /***/ (function(module, exports, __webpack_require__) {
  12213. "use strict";
  12214. exports.__esModule = true;
  12215. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  12216. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  12217. var _templateObject = _taggedTemplateLiteral(['Deprecation warning: This method is going to be removed in the next release. \n If you want to select a cell using props, please use the `selectCell` method.'], ['Deprecation warning: This method is going to be removed in the next release.\\x20\n If you want to select a cell using props, please use the \\`selectCell\\` method.']);
  12218. exports.default = Core;
  12219. var _element = __webpack_require__(0);
  12220. var _setting = __webpack_require__(89);
  12221. var _function = __webpack_require__(43);
  12222. var _console = __webpack_require__(56);
  12223. var _mixed = __webpack_require__(16);
  12224. var _browser = __webpack_require__(27);
  12225. var _dataMap = __webpack_require__(385);
  12226. var _dataMap2 = _interopRequireDefault(_dataMap);
  12227. var _editorManager = __webpack_require__(388);
  12228. var _editorManager2 = _interopRequireDefault(_editorManager);
  12229. var _eventManager = __webpack_require__(6);
  12230. var _eventManager2 = _interopRequireDefault(_eventManager);
  12231. var _object = __webpack_require__(2);
  12232. var _array = __webpack_require__(1);
  12233. var _templateLiteralTag = __webpack_require__(42);
  12234. var _plugins = __webpack_require__(8);
  12235. var _renderers = __webpack_require__(13);
  12236. var _validators = __webpack_require__(28);
  12237. var _string = __webpack_require__(36);
  12238. var _number = __webpack_require__(5);
  12239. var _tableView = __webpack_require__(389);
  12240. var _tableView2 = _interopRequireDefault(_tableView);
  12241. var _dataSource = __webpack_require__(390);
  12242. var _dataSource2 = _interopRequireDefault(_dataSource);
  12243. var _data = __webpack_require__(90);
  12244. var _recordTranslator = __webpack_require__(313);
  12245. var _rootInstance = __webpack_require__(314);
  12246. var _src = __webpack_require__(4);
  12247. var _pluginHooks = __webpack_require__(15);
  12248. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  12249. var _defaultSettings = __webpack_require__(315);
  12250. var _defaultSettings2 = _interopRequireDefault(_defaultSettings);
  12251. var _cellTypes = __webpack_require__(87);
  12252. var _i18n = __webpack_require__(316);
  12253. var _dictionariesManager = __webpack_require__(71);
  12254. var _utils = __webpack_require__(317);
  12255. var _keyStateObserver = __webpack_require__(318);
  12256. var _selection = __webpack_require__(394);
  12257. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12258. function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
  12259. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  12260. var activeGuid = null;
  12261. /**
  12262. * Handsontable constructor
  12263. *
  12264. * @core
  12265. * @constructor Core
  12266. * @description
  12267. *
  12268. * After Handsontable is constructed, you can modify the grid behavior using the available public methods.
  12269. *
  12270. * ---
  12271. * ## How to call methods
  12272. *
  12273. * These are 2 equal ways to call a Handsontable method:
  12274. *
  12275. * ```js
  12276. * // all following examples assume that you constructed Handsontable like this
  12277. * var ht = new Handsontable(document.getElementById('example1'), options);
  12278. *
  12279. * // now, to use setDataAtCell method, you can either:
  12280. * ht.setDataAtCell(0, 0, 'new value');
  12281. * ```
  12282. *
  12283. * Alternatively, you can call the method using jQuery wrapper (__obsolete__, requires initialization using our jQuery guide
  12284. * ```js
  12285. * $('#example1').handsontable('setDataAtCell', 0, 0, 'new value');
  12286. * ```
  12287. * ---
  12288. */
  12289. function Core(rootElement, userSettings) {
  12290. var _this = this;
  12291. var rootInstanceSymbol = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  12292. var priv,
  12293. datamap,
  12294. dataSource,
  12295. grid,
  12296. editorManager,
  12297. preventScrollingToCell = false,
  12298. instance = this,
  12299. GridSettings = function GridSettings() {},
  12300. eventManager = new _eventManager2.default(instance);
  12301. (0, _object.extend)(GridSettings.prototype, _defaultSettings2.default.prototype); // create grid settings as a copy of default settings
  12302. (0, _object.extend)(GridSettings.prototype, userSettings); // overwrite defaults with user settings
  12303. (0, _object.extend)(GridSettings.prototype, expandType(userSettings));
  12304. (0, _utils.applyLanguageSetting)(GridSettings.prototype, userSettings.language);
  12305. if ((0, _rootInstance.hasValidParameter)(rootInstanceSymbol)) {
  12306. (0, _rootInstance.registerAsRootInstance)(this);
  12307. }
  12308. (0, _keyStateObserver.startObserving)();
  12309. this.rootElement = rootElement;
  12310. this.isHotTableEnv = (0, _element.isChildOfWebComponentTable)(this.rootElement);
  12311. _eventManager2.default.isHotTableEnv = this.isHotTableEnv;
  12312. this.container = document.createElement('div');
  12313. this.renderCall = false;
  12314. rootElement.insertBefore(this.container, rootElement.firstChild);
  12315. if (false) {
  12316. (0, _mixed._injectProductInfo)(userSettings.licenseKey, rootElement);
  12317. }
  12318. this.guid = 'ht_' + (0, _string.randomString)(); // this is the namespace for global events
  12319. var recordTranslator = (0, _recordTranslator.getTranslator)(instance);
  12320. dataSource = new _dataSource2.default(instance);
  12321. if (!this.rootElement.id || this.rootElement.id.substring(0, 3) === 'ht_') {
  12322. this.rootElement.id = this.guid; // if root element does not have an id, assign a random id
  12323. }
  12324. priv = {
  12325. cellSettings: [],
  12326. columnSettings: [],
  12327. columnsSettingConflicts: ['data', 'width', 'language'],
  12328. settings: new GridSettings(), // current settings instance
  12329. selRange: null, // exposed by public method `getSelectedRange`
  12330. isPopulated: null,
  12331. scrollable: null,
  12332. firstRun: true
  12333. };
  12334. var selection = new _selection.Selection(priv.settings, {
  12335. countCols: function countCols() {
  12336. return instance.countCols();
  12337. },
  12338. countRows: function countRows() {
  12339. return instance.countRows();
  12340. },
  12341. propToCol: function propToCol(prop) {
  12342. return datamap.propToCol(prop);
  12343. },
  12344. isEditorOpened: function isEditorOpened() {
  12345. return instance.getActiveEditor() ? instance.getActiveEditor().isOpened() : false;
  12346. }
  12347. });
  12348. this.selection = selection;
  12349. this.selection.addLocalHook('beforeSetRangeStart', function (cellCoords) {
  12350. _this.runHooks('beforeSetRangeStart', cellCoords);
  12351. });
  12352. this.selection.addLocalHook('beforeSetRangeStartOnly', function (cellCoords) {
  12353. _this.runHooks('beforeSetRangeStartOnly', cellCoords);
  12354. });
  12355. this.selection.addLocalHook('beforeSetRangeEnd', function (cellCoords) {
  12356. _this.runHooks('beforeSetRangeEnd', cellCoords);
  12357. if (cellCoords.row < 0) {
  12358. cellCoords.row = _this.view.wt.wtTable.getFirstVisibleRow();
  12359. }
  12360. if (cellCoords.col < 0) {
  12361. cellCoords.col = _this.view.wt.wtTable.getFirstVisibleColumn();
  12362. }
  12363. });
  12364. this.selection.addLocalHook('afterSetRangeEnd', function (cellCoords) {
  12365. var preventScrolling = (0, _object.createObjectPropListener)(false);
  12366. var selectionRange = _this.selection.getSelectedRange();
  12367. var _selectionRange$curre = selectionRange.current(),
  12368. from = _selectionRange$curre.from,
  12369. to = _selectionRange$curre.to;
  12370. var selectionLayerLevel = selectionRange.size() - 1;
  12371. _this.runHooks('afterSelection', from.row, from.col, to.row, to.col, preventScrolling, selectionLayerLevel);
  12372. _this.runHooks('afterSelectionByProp', from.row, instance.colToProp(from.col), to.row, instance.colToProp(to.col), preventScrolling, selectionLayerLevel);
  12373. var isSelectedByAnyHeader = _this.selection.isSelectedByAnyHeader();
  12374. var currentSelectedRange = _this.selection.selectedRange.current();
  12375. var scrollToCell = true;
  12376. if (preventScrollingToCell) {
  12377. scrollToCell = false;
  12378. }
  12379. if (preventScrolling.isTouched()) {
  12380. scrollToCell = !preventScrolling.value;
  12381. }
  12382. if (scrollToCell !== false && !isSelectedByAnyHeader) {
  12383. if (currentSelectedRange && !_this.selection.isMultiple()) {
  12384. _this.view.scrollViewport(currentSelectedRange.from);
  12385. } else {
  12386. _this.view.scrollViewport(cellCoords);
  12387. }
  12388. }
  12389. var isSelectedByRowHeader = _this.selection.isSelectedByRowHeader();
  12390. var isSelectedByColumnHeader = _this.selection.isSelectedByColumnHeader();
  12391. // @TODO: These CSS classes are no longer needed anymore. They are used only as a indicator of the selected
  12392. // rows/columns in the MergedCells plugin (via border.js#L520 in the walkontable module). After fixing
  12393. // the Border class this should be removed.
  12394. if (isSelectedByRowHeader && isSelectedByColumnHeader) {
  12395. (0, _element.addClass)(_this.rootElement, ['ht__selection--rows', 'ht__selection--columns']);
  12396. } else if (isSelectedByRowHeader) {
  12397. (0, _element.removeClass)(_this.rootElement, 'ht__selection--columns');
  12398. (0, _element.addClass)(_this.rootElement, 'ht__selection--rows');
  12399. } else if (isSelectedByColumnHeader) {
  12400. (0, _element.removeClass)(_this.rootElement, 'ht__selection--rows');
  12401. (0, _element.addClass)(_this.rootElement, 'ht__selection--columns');
  12402. } else {
  12403. (0, _element.removeClass)(_this.rootElement, ['ht__selection--rows', 'ht__selection--columns']);
  12404. }
  12405. _this._refreshBorders(null);
  12406. });
  12407. this.selection.addLocalHook('afterSelectionFinished', function (cellRanges) {
  12408. var selectionLayerLevel = cellRanges.length - 1;
  12409. var _cellRanges$selection = cellRanges[selectionLayerLevel],
  12410. from = _cellRanges$selection.from,
  12411. to = _cellRanges$selection.to;
  12412. _this.runHooks('afterSelectionEnd', from.row, from.col, to.row, to.col, selectionLayerLevel);
  12413. _this.runHooks('afterSelectionEndByProp', from.row, instance.colToProp(from.col), to.row, instance.colToProp(to.col), selectionLayerLevel);
  12414. });
  12415. this.selection.addLocalHook('afterIsMultipleSelection', function (isMultiple) {
  12416. var changedIsMultiple = _this.runHooks('afterIsMultipleSelection', isMultiple.value);
  12417. if (isMultiple.value) {
  12418. isMultiple.value = changedIsMultiple;
  12419. }
  12420. });
  12421. this.selection.addLocalHook('beforeModifyTransformStart', function (cellCoordsDelta) {
  12422. _this.runHooks('modifyTransformStart', cellCoordsDelta);
  12423. });
  12424. this.selection.addLocalHook('afterModifyTransformStart', function (coords, rowTransformDir, colTransformDir) {
  12425. _this.runHooks('afterModifyTransformStart', coords, rowTransformDir, colTransformDir);
  12426. });
  12427. this.selection.addLocalHook('beforeModifyTransformEnd', function (cellCoordsDelta) {
  12428. _this.runHooks('modifyTransformEnd', cellCoordsDelta);
  12429. });
  12430. this.selection.addLocalHook('afterModifyTransformEnd', function (coords, rowTransformDir, colTransformDir) {
  12431. _this.runHooks('afterModifyTransformEnd', coords, rowTransformDir, colTransformDir);
  12432. });
  12433. this.selection.addLocalHook('afterDeselect', function () {
  12434. editorManager.destroyEditor();
  12435. _this._refreshBorders();
  12436. (0, _element.removeClass)(_this.rootElement, ['ht__selection--rows', 'ht__selection--columns']);
  12437. _this.runHooks('afterDeselect');
  12438. });
  12439. this.selection.addLocalHook('insertRowRequire', function (totalRows) {
  12440. _this.alter('insert_row', totalRows, 1, 'auto');
  12441. });
  12442. this.selection.addLocalHook('insertColRequire', function (totalCols) {
  12443. _this.alter('insert_col', totalCols, 1, 'auto');
  12444. });
  12445. grid = {
  12446. /**
  12447. * Inserts or removes rows and columns.
  12448. *
  12449. * @memberof Core#
  12450. * @function alter
  12451. * @private
  12452. * @param {String} action Possible values: "insert_row", "insert_col", "remove_row", "remove_col".
  12453. * @param {Number|Array} index Row or column visual index which from the alter action will be triggered.
  12454. * Alter actions such as "remove_row" and "remove_col" support array indexes in the
  12455. * format `[[index, amount], [index, amount]...]` this can be used to remove
  12456. * non-consecutive columns or rows in one call.
  12457. * @param {Number} amount Ammount rows or columns to remove.
  12458. * @param {String} [source] Optional. Source of hook runner.
  12459. * @param {Boolean} [keepEmptyRows] Optional. Flag for preventing deletion of empty rows.
  12460. */
  12461. alter: function alter(action, index, amount, source, keepEmptyRows) {
  12462. var delta;
  12463. amount = amount || 1;
  12464. function spliceWith(data, index, count, toInject) {
  12465. var valueFactory = function valueFactory() {
  12466. var result = void 0;
  12467. if (toInject === 'array') {
  12468. result = [];
  12469. } else if (toInject === 'object') {
  12470. result = {};
  12471. }
  12472. return result;
  12473. };
  12474. var spliceArgs = (0, _array.arrayMap)(new Array(count), function () {
  12475. return valueFactory();
  12476. });
  12477. spliceArgs.unshift(index, 0);
  12478. data.splice.apply(data, _toConsumableArray(spliceArgs));
  12479. }
  12480. var normalizeIndexesGroup = function normalizeIndexesGroup(indexes) {
  12481. if (indexes.length === 0) {
  12482. return [];
  12483. }
  12484. var sortedIndexes = [].concat(_toConsumableArray(indexes));
  12485. // Sort the indexes in ascending order.
  12486. sortedIndexes.sort(function (_ref, _ref2) {
  12487. var _ref4 = _slicedToArray(_ref, 1),
  12488. indexA = _ref4[0];
  12489. var _ref3 = _slicedToArray(_ref2, 1),
  12490. indexB = _ref3[0];
  12491. if (indexA === indexB) {
  12492. return 0;
  12493. }
  12494. return indexA > indexB ? 1 : -1;
  12495. });
  12496. // Normalize the {index, amount} groups into bigger groups.
  12497. var normalizedIndexes = (0, _array.arrayReduce)(sortedIndexes, function (acc, _ref5) {
  12498. var _ref6 = _slicedToArray(_ref5, 2),
  12499. index = _ref6[0],
  12500. amount = _ref6[1];
  12501. var previousItem = acc[acc.length - 1];
  12502. var _previousItem = _slicedToArray(previousItem, 2),
  12503. prevIndex = _previousItem[0],
  12504. prevAmount = _previousItem[1];
  12505. var prevLastIndex = prevIndex + prevAmount;
  12506. if (index <= prevLastIndex) {
  12507. var amountToAdd = Math.max(amount - (prevLastIndex - index), 0);
  12508. previousItem[1] += amountToAdd;
  12509. } else {
  12510. acc.push([index, amount]);
  12511. }
  12512. return acc;
  12513. }, [sortedIndexes[0]]);
  12514. return normalizedIndexes;
  12515. };
  12516. /* eslint-disable no-case-declarations */
  12517. switch (action) {
  12518. case 'insert_row':
  12519. var numberOfSourceRows = instance.countSourceRows();
  12520. if (instance.getSettings().maxRows === numberOfSourceRows) {
  12521. return;
  12522. }
  12523. index = (0, _mixed.isDefined)(index) ? index : numberOfSourceRows;
  12524. delta = datamap.createRow(index, amount, source);
  12525. spliceWith(priv.cellSettings, index, amount, 'array');
  12526. if (delta) {
  12527. if (selection.isSelected() && selection.selectedRange.current().from.row >= index) {
  12528. selection.selectedRange.current().from.row += delta;
  12529. selection.transformEnd(delta, 0); // will call render() internally
  12530. } else {
  12531. instance._refreshBorders(); // it will call render and prepare methods
  12532. }
  12533. }
  12534. break;
  12535. case 'insert_col':
  12536. delta = datamap.createCol(index, amount, source);
  12537. for (var row = 0, len = instance.countSourceRows(); row < len; row++) {
  12538. if (priv.cellSettings[row]) {
  12539. spliceWith(priv.cellSettings[row], index, amount);
  12540. }
  12541. }
  12542. if (delta) {
  12543. if (Array.isArray(instance.getSettings().colHeaders)) {
  12544. var spliceArray = [index, 0];
  12545. spliceArray.length += delta; // inserts empty (undefined) elements at the end of an array
  12546. Array.prototype.splice.apply(instance.getSettings().colHeaders, spliceArray); // inserts empty (undefined) elements into the colHeader array
  12547. }
  12548. if (selection.isSelected() && selection.selectedRange.current().from.col >= index) {
  12549. selection.selectedRange.current().from.col += delta;
  12550. selection.transformEnd(0, delta); // will call render() internally
  12551. } else {
  12552. instance._refreshBorders(); // it will call render and prepare methods
  12553. }
  12554. }
  12555. break;
  12556. case 'remove_row':
  12557. var removeRow = function removeRow(indexes) {
  12558. var offset = 0;
  12559. (0, _array.arrayEach)(indexes, function (_ref7) {
  12560. var _ref8 = _slicedToArray(_ref7, 2),
  12561. index = _ref8[0],
  12562. amount = _ref8[1];
  12563. var calcIndex = (0, _mixed.isEmpty)(index) ? instance.countRows() - 1 : Math.max(index - offset, 0);
  12564. // If the 'index' is an integer decrease it by 'offset' otherwise pass it through to make the value
  12565. // compatible with datamap.removeCol method.
  12566. if (Number.isInteger(index)) {
  12567. index = Math.max(index - offset, 0);
  12568. }
  12569. // TODO: for datamap.removeRow index should be passed as it is (with undefined and null values). If not, the logic
  12570. // inside the datamap.removeRow breaks the removing functionality.
  12571. datamap.removeRow(index, amount, source);
  12572. priv.cellSettings.splice(calcIndex, amount);
  12573. var totalRows = instance.countRows();
  12574. var fixedRowsTop = instance.getSettings().fixedRowsTop;
  12575. if (fixedRowsTop >= calcIndex + 1) {
  12576. instance.getSettings().fixedRowsTop -= Math.min(amount, fixedRowsTop - calcIndex);
  12577. }
  12578. var fixedRowsBottom = instance.getSettings().fixedRowsBottom;
  12579. if (fixedRowsBottom && calcIndex >= totalRows - fixedRowsBottom) {
  12580. instance.getSettings().fixedRowsBottom -= Math.min(amount, fixedRowsBottom);
  12581. }
  12582. offset += amount;
  12583. });
  12584. };
  12585. if (Array.isArray(index)) {
  12586. removeRow(normalizeIndexesGroup(index));
  12587. } else {
  12588. removeRow([[index, amount]]);
  12589. }
  12590. grid.adjustRowsAndCols();
  12591. instance._refreshBorders(); // it will call render and prepare methods
  12592. break;
  12593. case 'remove_col':
  12594. var removeCol = function removeCol(indexes) {
  12595. var offset = 0;
  12596. (0, _array.arrayEach)(indexes, function (_ref9) {
  12597. var _ref10 = _slicedToArray(_ref9, 2),
  12598. index = _ref10[0],
  12599. amount = _ref10[1];
  12600. var calcIndex = (0, _mixed.isEmpty)(index) ? instance.countCols() - 1 : Math.max(index - offset, 0);
  12601. var visualColumnIndex = recordTranslator.toPhysicalColumn(calcIndex);
  12602. // If the 'index' is an integer decrease it by 'offset' otherwise pass it through to make the value
  12603. // compatible with datamap.removeCol method.
  12604. if (Number.isInteger(index)) {
  12605. index = Math.max(index - offset, 0);
  12606. }
  12607. // TODO: for datamap.removeCol index should be passed as it is (with undefined and null values). If not, the logic
  12608. // inside the datamap.removeCol breaks the removing functionality.
  12609. datamap.removeCol(index, amount, source);
  12610. for (var _row = 0, _len = instance.countSourceRows(); _row < _len; _row++) {
  12611. if (priv.cellSettings[_row]) {
  12612. // if row hasn't been rendered it wouldn't have cellSettings
  12613. priv.cellSettings[_row].splice(visualColumnIndex, amount);
  12614. }
  12615. }
  12616. var fixedColumnsLeft = instance.getSettings().fixedColumnsLeft;
  12617. if (fixedColumnsLeft >= calcIndex + 1) {
  12618. instance.getSettings().fixedColumnsLeft -= Math.min(amount, fixedColumnsLeft - calcIndex);
  12619. }
  12620. if (Array.isArray(instance.getSettings().colHeaders)) {
  12621. if (typeof visualColumnIndex === 'undefined') {
  12622. visualColumnIndex = -1;
  12623. }
  12624. instance.getSettings().colHeaders.splice(visualColumnIndex, amount);
  12625. }
  12626. offset += amount;
  12627. });
  12628. };
  12629. if (Array.isArray(index)) {
  12630. removeCol(normalizeIndexesGroup(index));
  12631. } else {
  12632. removeCol([[index, amount]]);
  12633. }
  12634. grid.adjustRowsAndCols();
  12635. instance._refreshBorders(); // it will call render and prepare methods
  12636. break;
  12637. default:
  12638. throw new Error('There is no such action "' + action + '"');
  12639. }
  12640. if (!keepEmptyRows) {
  12641. grid.adjustRowsAndCols(); // makes sure that we did not add rows that will be removed in next refresh
  12642. }
  12643. },
  12644. /**
  12645. * Makes sure there are empty rows at the bottom of the table
  12646. */
  12647. adjustRowsAndCols: function adjustRowsAndCols() {
  12648. if (priv.settings.minRows) {
  12649. // should I add empty rows to data source to meet minRows?
  12650. var rows = instance.countRows();
  12651. if (rows < priv.settings.minRows) {
  12652. for (var r = 0, minRows = priv.settings.minRows; r < minRows - rows; r++) {
  12653. datamap.createRow(instance.countRows(), 1, 'auto');
  12654. }
  12655. }
  12656. }
  12657. if (priv.settings.minSpareRows) {
  12658. var emptyRows = instance.countEmptyRows(true);
  12659. // should I add empty rows to meet minSpareRows?
  12660. if (emptyRows < priv.settings.minSpareRows) {
  12661. for (; emptyRows < priv.settings.minSpareRows && instance.countSourceRows() < priv.settings.maxRows; emptyRows++) {
  12662. datamap.createRow(instance.countRows(), 1, 'auto');
  12663. }
  12664. }
  12665. }
  12666. {
  12667. var emptyCols = void 0;
  12668. // count currently empty cols
  12669. if (priv.settings.minCols || priv.settings.minSpareCols) {
  12670. emptyCols = instance.countEmptyCols(true);
  12671. }
  12672. // should I add empty cols to meet minCols?
  12673. if (priv.settings.minCols && !priv.settings.columns && instance.countCols() < priv.settings.minCols) {
  12674. for (; instance.countCols() < priv.settings.minCols; emptyCols++) {
  12675. datamap.createCol(instance.countCols(), 1, 'auto');
  12676. }
  12677. }
  12678. // should I add empty cols to meet minSpareCols?
  12679. if (priv.settings.minSpareCols && !priv.settings.columns && instance.dataType === 'array' && emptyCols < priv.settings.minSpareCols) {
  12680. for (; emptyCols < priv.settings.minSpareCols && instance.countCols() < priv.settings.maxCols; emptyCols++) {
  12681. datamap.createCol(instance.countCols(), 1, 'auto');
  12682. }
  12683. }
  12684. }
  12685. var rowCount = instance.countRows();
  12686. var colCount = instance.countCols();
  12687. if (rowCount === 0 || colCount === 0) {
  12688. selection.deselect();
  12689. }
  12690. if (selection.isSelected()) {
  12691. (0, _array.arrayEach)(selection.selectedRange, function (range) {
  12692. var selectionChanged = false;
  12693. var fromRow = range.from.row;
  12694. var fromCol = range.from.col;
  12695. var toRow = range.to.row;
  12696. var toCol = range.to.col;
  12697. // if selection is outside, move selection to last row
  12698. if (fromRow > rowCount - 1) {
  12699. fromRow = rowCount - 1;
  12700. selectionChanged = true;
  12701. if (toRow > fromRow) {
  12702. toRow = fromRow;
  12703. }
  12704. } else if (toRow > rowCount - 1) {
  12705. toRow = rowCount - 1;
  12706. selectionChanged = true;
  12707. if (fromRow > toRow) {
  12708. fromRow = toRow;
  12709. }
  12710. }
  12711. // if selection is outside, move selection to last row
  12712. if (fromCol > colCount - 1) {
  12713. fromCol = colCount - 1;
  12714. selectionChanged = true;
  12715. if (toCol > fromCol) {
  12716. toCol = fromCol;
  12717. }
  12718. } else if (toCol > colCount - 1) {
  12719. toCol = colCount - 1;
  12720. selectionChanged = true;
  12721. if (fromCol > toCol) {
  12722. fromCol = toCol;
  12723. }
  12724. }
  12725. if (selectionChanged) {
  12726. instance.selectCell(fromRow, fromCol, toRow, toCol);
  12727. }
  12728. });
  12729. }
  12730. if (instance.view) {
  12731. instance.view.wt.wtOverlays.adjustElementsSize();
  12732. }
  12733. },
  12734. /**
  12735. * Populate the data from the provided 2d array from the given cell coordinates.
  12736. *
  12737. * @private
  12738. * @param {Object} start Start selection position. Visual indexes.
  12739. * @param {Array} input 2d data array.
  12740. * @param {Object} [end] End selection position (only for drag-down mode). Visual indexes.
  12741. * @param {String} [source="populateFromArray"] Source information string.
  12742. * @param {String} [method="overwrite"] Populate method. Possible options: `shift_down`, `shift_right`, `overwrite`.
  12743. * @param {String} direction (left|right|up|down) String specifying the direction.
  12744. * @param {Array} deltas The deltas array. A difference between values of adjacent cells.
  12745. * Useful **only** when the type of handled cells is `numeric`.
  12746. * @returns {Object|undefined} ending td in pasted area (only if any cell was changed).
  12747. */
  12748. populateFromArray: function populateFromArray(start, input, end, source, method, direction, deltas) {
  12749. // TODO: either remove or implement the `direction` argument. Currently it's not working at all.
  12750. var r,
  12751. rlen,
  12752. c,
  12753. clen,
  12754. setData = [],
  12755. current = {};
  12756. rlen = input.length;
  12757. if (rlen === 0) {
  12758. return false;
  12759. }
  12760. var repeatCol,
  12761. repeatRow,
  12762. cmax,
  12763. rmax,
  12764. baseEnd = {
  12765. row: end === null ? null : end.row,
  12766. col: end === null ? null : end.col
  12767. };
  12768. /* eslint-disable no-case-declarations */
  12769. // insert data with specified pasteMode method
  12770. switch (method) {
  12771. case 'shift_down':
  12772. repeatCol = end ? end.col - start.col + 1 : 0;
  12773. repeatRow = end ? end.row - start.row + 1 : 0;
  12774. input = (0, _data.translateRowsToColumns)(input);
  12775. for (c = 0, clen = input.length, cmax = Math.max(clen, repeatCol); c < cmax; c++) {
  12776. if (c < clen) {
  12777. var _instance;
  12778. for (r = 0, rlen = input[c].length; r < repeatRow - rlen; r++) {
  12779. input[c].push(input[c][r % rlen]);
  12780. }
  12781. input[c].unshift(start.col + c, start.row, 0);
  12782. (_instance = instance).spliceCol.apply(_instance, _toConsumableArray(input[c]));
  12783. } else {
  12784. var _instance2;
  12785. input[c % clen][0] = start.col + c;
  12786. (_instance2 = instance).spliceCol.apply(_instance2, _toConsumableArray(input[c % clen]));
  12787. }
  12788. }
  12789. break;
  12790. case 'shift_right':
  12791. repeatCol = end ? end.col - start.col + 1 : 0;
  12792. repeatRow = end ? end.row - start.row + 1 : 0;
  12793. for (r = 0, rlen = input.length, rmax = Math.max(rlen, repeatRow); r < rmax; r++) {
  12794. if (r < rlen) {
  12795. var _instance3;
  12796. for (c = 0, clen = input[r].length; c < repeatCol - clen; c++) {
  12797. input[r].push(input[r][c % clen]);
  12798. }
  12799. input[r].unshift(start.row + r, start.col, 0);
  12800. (_instance3 = instance).spliceRow.apply(_instance3, _toConsumableArray(input[r]));
  12801. } else {
  12802. var _instance4;
  12803. input[r % rlen][0] = start.row + r;
  12804. (_instance4 = instance).spliceRow.apply(_instance4, _toConsumableArray(input[r % rlen]));
  12805. }
  12806. }
  12807. break;
  12808. case 'overwrite':
  12809. default:
  12810. // overwrite and other not specified options
  12811. current.row = start.row;
  12812. current.col = start.col;
  12813. var selected = { // selected range
  12814. row: end && start ? end.row - start.row + 1 : 1,
  12815. col: end && start ? end.col - start.col + 1 : 1
  12816. };
  12817. var skippedRow = 0;
  12818. var skippedColumn = 0;
  12819. var pushData = true;
  12820. var cellMeta = void 0;
  12821. var getInputValue = function getInputValue(row) {
  12822. var col = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  12823. var rowValue = input[row % input.length];
  12824. if (col !== null) {
  12825. return rowValue[col % rowValue.length];
  12826. }
  12827. return rowValue;
  12828. };
  12829. var rowInputLength = input.length;
  12830. var rowSelectionLength = end ? end.row - start.row + 1 : 0;
  12831. if (end) {
  12832. rlen = rowSelectionLength;
  12833. } else {
  12834. rlen = Math.max(rowInputLength, rowSelectionLength);
  12835. }
  12836. for (r = 0; r < rlen; r++) {
  12837. if (end && current.row > end.row && rowSelectionLength > rowInputLength || !priv.settings.allowInsertRow && current.row > instance.countRows() - 1 || current.row >= priv.settings.maxRows) {
  12838. break;
  12839. }
  12840. var visualRow = r - skippedRow;
  12841. var colInputLength = getInputValue(visualRow).length;
  12842. var colSelectionLength = end ? end.col - start.col + 1 : 0;
  12843. if (end) {
  12844. clen = colSelectionLength;
  12845. } else {
  12846. clen = Math.max(colInputLength, colSelectionLength);
  12847. }
  12848. current.col = start.col;
  12849. cellMeta = instance.getCellMeta(current.row, current.col);
  12850. if ((source === 'CopyPaste.paste' || source === 'Autofill.autofill') && cellMeta.skipRowOnPaste) {
  12851. skippedRow++;
  12852. current.row++;
  12853. rlen++;
  12854. /* eslint-disable no-continue */
  12855. continue;
  12856. }
  12857. skippedColumn = 0;
  12858. for (c = 0; c < clen; c++) {
  12859. if (end && current.col > end.col && colSelectionLength > colInputLength || !priv.settings.allowInsertColumn && current.col > instance.countCols() - 1 || current.col >= priv.settings.maxCols) {
  12860. break;
  12861. }
  12862. cellMeta = instance.getCellMeta(current.row, current.col);
  12863. if ((source === 'CopyPaste.paste' || source === 'Autofill.fill') && cellMeta.skipColumnOnPaste) {
  12864. skippedColumn++;
  12865. current.col++;
  12866. clen++;
  12867. continue;
  12868. }
  12869. if (cellMeta.readOnly) {
  12870. current.col++;
  12871. /* eslint-disable no-continue */
  12872. continue;
  12873. }
  12874. var visualColumn = c - skippedColumn;
  12875. var value = getInputValue(visualRow, visualColumn);
  12876. var orgValue = instance.getDataAtCell(current.row, current.col);
  12877. var index = {
  12878. row: visualRow,
  12879. col: visualColumn
  12880. };
  12881. if (source === 'Autofill.fill') {
  12882. var result = instance.runHooks('beforeAutofillInsidePopulate', index, direction, input, deltas, {}, selected);
  12883. if (result) {
  12884. value = (0, _mixed.isUndefined)(result.value) ? value : result.value;
  12885. }
  12886. }
  12887. if (value !== null && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
  12888. if (orgValue === null || (typeof orgValue === 'undefined' ? 'undefined' : _typeof(orgValue)) !== 'object') {
  12889. pushData = false;
  12890. } else {
  12891. var orgValueSchema = (0, _object.duckSchema)(orgValue[0] || orgValue);
  12892. var valueSchema = (0, _object.duckSchema)(value[0] || value);
  12893. /* eslint-disable max-depth */
  12894. if ((0, _object.isObjectEqual)(orgValueSchema, valueSchema)) {
  12895. value = (0, _object.deepClone)(value);
  12896. } else {
  12897. pushData = false;
  12898. }
  12899. }
  12900. } else if (orgValue !== null && (typeof orgValue === 'undefined' ? 'undefined' : _typeof(orgValue)) === 'object') {
  12901. pushData = false;
  12902. }
  12903. if (pushData) {
  12904. setData.push([current.row, current.col, value]);
  12905. }
  12906. pushData = true;
  12907. current.col++;
  12908. }
  12909. current.row++;
  12910. }
  12911. instance.setDataAtCell(setData, null, null, source || 'populateFromArray');
  12912. break;
  12913. }
  12914. }
  12915. };
  12916. /**
  12917. * Internal function to set `language` key of settings.
  12918. *
  12919. * @private
  12920. * @param {String} languageCode Language code for specific language i.e. 'en-US', 'pt-BR', 'de-DE'
  12921. * @fires Hooks#afterLanguageChange
  12922. */
  12923. function setLanguage(languageCode) {
  12924. var normalizedLanguageCode = (0, _utils.normalizeLanguageCode)(languageCode);
  12925. if ((0, _dictionariesManager.hasLanguageDictionary)(normalizedLanguageCode)) {
  12926. instance.runHooks('beforeLanguageChange', normalizedLanguageCode);
  12927. GridSettings.prototype.language = normalizedLanguageCode;
  12928. instance.runHooks('afterLanguageChange', normalizedLanguageCode);
  12929. } else {
  12930. (0, _utils.warnUserAboutLanguageRegistration)(languageCode);
  12931. }
  12932. }
  12933. this.init = function () {
  12934. dataSource.setData(priv.settings.data);
  12935. instance.runHooks('beforeInit');
  12936. if ((0, _browser.isMobileBrowser)()) {
  12937. (0, _element.addClass)(instance.rootElement, 'mobile');
  12938. }
  12939. this.updateSettings(priv.settings, true);
  12940. this.view = new _tableView2.default(this);
  12941. editorManager = _editorManager2.default.getInstance(instance, priv, selection, datamap);
  12942. this.forceFullRender = true; // used when data was changed
  12943. instance.runHooks('init');
  12944. this.view.render();
  12945. if (_typeof(priv.firstRun) === 'object') {
  12946. instance.runHooks('afterChange', priv.firstRun[0], priv.firstRun[1]);
  12947. priv.firstRun = false;
  12948. }
  12949. instance.runHooks('afterInit');
  12950. };
  12951. function ValidatorsQueue() {
  12952. // moved this one level up so it can be used in any function here. Probably this should be moved to a separate file
  12953. var resolved = false;
  12954. return {
  12955. validatorsInQueue: 0,
  12956. valid: true,
  12957. addValidatorToQueue: function addValidatorToQueue() {
  12958. this.validatorsInQueue++;
  12959. resolved = false;
  12960. },
  12961. removeValidatorFormQueue: function removeValidatorFormQueue() {
  12962. this.validatorsInQueue = this.validatorsInQueue - 1 < 0 ? 0 : this.validatorsInQueue - 1;
  12963. this.checkIfQueueIsEmpty();
  12964. },
  12965. onQueueEmpty: function onQueueEmpty(valid) {},
  12966. checkIfQueueIsEmpty: function checkIfQueueIsEmpty() {
  12967. if (this.validatorsInQueue == 0 && resolved == false) {
  12968. resolved = true;
  12969. this.onQueueEmpty(this.valid);
  12970. }
  12971. }
  12972. };
  12973. }
  12974. /**
  12975. * Get parsed number from numeric string.
  12976. *
  12977. * @private
  12978. * @param {String} numericData Float (separated by a dot or a comma) or integer.
  12979. * @returns {Number} Number if we get data in parsable format, not changed value otherwise.
  12980. */
  12981. function getParsedNumber(numericData) {
  12982. // Unifying "float like" string. Change from value with comma determiner to value with dot determiner,
  12983. // for example from `450,65` to `450.65`.
  12984. var unifiedNumericData = numericData.replace(',', '.');
  12985. if (isNaN(parseFloat(unifiedNumericData)) === false) {
  12986. return parseFloat(unifiedNumericData);
  12987. }
  12988. return numericData;
  12989. }
  12990. function validateChanges(changes, source, callback) {
  12991. var waitingForValidator = new ValidatorsQueue();
  12992. var isNumericData = function isNumericData(value) {
  12993. return value.length > 0 && /^-?[\d\s]*(\.|,)?\d*$/.test(value);
  12994. };
  12995. waitingForValidator.onQueueEmpty = resolve;
  12996. for (var i = changes.length - 1; i >= 0; i--) {
  12997. if (changes[i] === null) {
  12998. changes.splice(i, 1);
  12999. } else {
  13000. var _changes$i = _slicedToArray(changes[i], 4),
  13001. row = _changes$i[0],
  13002. prop = _changes$i[1],
  13003. newValue = _changes$i[3];
  13004. var col = datamap.propToCol(prop);
  13005. var cellProperties = instance.getCellMeta(row, col);
  13006. if (cellProperties.type === 'numeric' && typeof newValue === 'string' && isNumericData(newValue)) {
  13007. changes[i][3] = getParsedNumber(newValue);
  13008. }
  13009. /* eslint-disable no-loop-func */
  13010. if (instance.getCellValidator(cellProperties)) {
  13011. waitingForValidator.addValidatorToQueue();
  13012. instance.validateCell(changes[i][3], cellProperties, function (i, cellProperties) {
  13013. return function (result) {
  13014. if (typeof result !== 'boolean') {
  13015. throw new Error('Validation error: result is not boolean');
  13016. }
  13017. if (result === false && cellProperties.allowInvalid === false) {
  13018. changes.splice(i, 1); // cancel the change
  13019. cellProperties.valid = true; // we cancelled the change, so cell value is still valid
  13020. var cell = instance.getCell(cellProperties.visualRow, cellProperties.visualCol);
  13021. (0, _element.removeClass)(cell, instance.getSettings().invalidCellClassName);
  13022. --i;
  13023. }
  13024. waitingForValidator.removeValidatorFormQueue();
  13025. };
  13026. }(i, cellProperties), source);
  13027. }
  13028. }
  13029. }
  13030. waitingForValidator.checkIfQueueIsEmpty();
  13031. function resolve() {
  13032. var beforeChangeResult;
  13033. if (changes.length) {
  13034. beforeChangeResult = instance.runHooks('beforeChange', changes, source || 'edit');
  13035. if ((0, _function.isFunction)(beforeChangeResult)) {
  13036. (0, _console.warn)('Your beforeChange callback returns a function. It\'s not supported since Handsontable 0.12.1 (and the returned function will not be executed).');
  13037. } else if (beforeChangeResult === false) {
  13038. changes.splice(0, changes.length); // invalidate all changes (remove everything from array)
  13039. }
  13040. }
  13041. callback(); // called when async validators are resolved and beforeChange was not async
  13042. }
  13043. }
  13044. /**
  13045. * Internal function to apply changes. Called after validateChanges
  13046. *
  13047. * @private
  13048. * @param {Array} changes Array in form of [row, prop, oldValue, newValue]
  13049. * @param {String} source String that identifies how this change will be described in changes array (useful in onChange callback)
  13050. * @fires Hooks#beforeChangeRender
  13051. * @fires Hooks#afterChange
  13052. */
  13053. function applyChanges(changes, source) {
  13054. var i = changes.length - 1;
  13055. if (i < 0) {
  13056. return;
  13057. }
  13058. for (; i >= 0; i--) {
  13059. var skipThisChange = false;
  13060. if (changes[i] === null) {
  13061. changes.splice(i, 1);
  13062. /* eslint-disable no-continue */
  13063. continue;
  13064. }
  13065. if (changes[i][2] == null && changes[i][3] == null) {
  13066. /* eslint-disable no-continue */
  13067. continue;
  13068. }
  13069. if (priv.settings.allowInsertRow) {
  13070. while (changes[i][0] > instance.countRows() - 1) {
  13071. var numberOfCreatedRows = datamap.createRow(void 0, void 0, source);
  13072. if (numberOfCreatedRows === 0) {
  13073. skipThisChange = true;
  13074. break;
  13075. }
  13076. }
  13077. }
  13078. if (skipThisChange) {
  13079. /* eslint-disable no-continue */
  13080. continue;
  13081. }
  13082. if (instance.dataType === 'array' && (!priv.settings.columns || priv.settings.columns.length === 0) && priv.settings.allowInsertColumn) {
  13083. while (datamap.propToCol(changes[i][1]) > instance.countCols() - 1) {
  13084. datamap.createCol(void 0, void 0, source);
  13085. }
  13086. }
  13087. datamap.set(changes[i][0], changes[i][1], changes[i][3]);
  13088. }
  13089. instance.forceFullRender = true; // used when data was changed
  13090. grid.adjustRowsAndCols();
  13091. instance.runHooks('beforeChangeRender', changes, source);
  13092. editorManager.lockEditor();
  13093. instance._refreshBorders(null);
  13094. editorManager.unlockEditor();
  13095. instance.view.wt.wtOverlays.adjustElementsSize();
  13096. instance.runHooks('afterChange', changes, source || 'edit');
  13097. var activeEditor = instance.getActiveEditor();
  13098. if (activeEditor && (0, _mixed.isDefined)(activeEditor.refreshValue)) {
  13099. activeEditor.refreshValue();
  13100. }
  13101. }
  13102. /**
  13103. * Validate a single cell.
  13104. *
  13105. * @param {String|Number} value
  13106. * @param cellProperties
  13107. * @param callback
  13108. * @param source
  13109. */
  13110. this.validateCell = function (value, cellProperties, callback, source) {
  13111. var validator = instance.getCellValidator(cellProperties);
  13112. // the `canBeValidated = false` argument suggests, that the cell passes validation by default.
  13113. function done(valid) {
  13114. var canBeValidated = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  13115. // Fixes GH#3903
  13116. if (!canBeValidated || cellProperties.hidden === true) {
  13117. callback(valid);
  13118. return;
  13119. }
  13120. var col = cellProperties.visualCol,
  13121. row = cellProperties.visualRow,
  13122. td = instance.getCell(row, col, true);
  13123. if (td && td.nodeName != 'TH') {
  13124. instance.view.wt.wtSettings.settings.cellRenderer(row, col, td);
  13125. }
  13126. callback(valid);
  13127. }
  13128. if ((0, _mixed.isRegExp)(validator)) {
  13129. validator = function (validator) {
  13130. return function (value, callback) {
  13131. callback(validator.test(value));
  13132. };
  13133. }(validator);
  13134. }
  13135. if ((0, _function.isFunction)(validator)) {
  13136. value = instance.runHooks('beforeValidate', value, cellProperties.visualRow, cellProperties.prop, source);
  13137. // To provide consistent behaviour, validation should be always asynchronous
  13138. instance._registerTimeout(setTimeout(function () {
  13139. validator.call(cellProperties, value, function (valid) {
  13140. valid = instance.runHooks('afterValidate', valid, value, cellProperties.visualRow, cellProperties.prop, source);
  13141. cellProperties.valid = valid;
  13142. done(valid);
  13143. instance.runHooks('postAfterValidate', valid, value, cellProperties.visualRow, cellProperties.prop, source);
  13144. });
  13145. }, 0));
  13146. } else {
  13147. // resolve callback even if validator function was not found
  13148. instance._registerTimeout(setTimeout(function () {
  13149. cellProperties.valid = true;
  13150. done(cellProperties.valid, false);
  13151. }, 0));
  13152. }
  13153. };
  13154. function setDataInputToArray(row, propOrCol, value) {
  13155. if ((typeof row === 'undefined' ? 'undefined' : _typeof(row)) === 'object') {
  13156. // is it an array of changes
  13157. return row;
  13158. }
  13159. return [[row, propOrCol, value]];
  13160. }
  13161. /**
  13162. * @description
  13163. * Set new value to a cell. To change many cells at once, pass an array of `changes` in format `[[row, col, value], ...]` as
  13164. * the only parameter. `col` is the index of a __visible__ column (note that if columns were reordered,
  13165. * the current visible order will be used). `source` is a flag for before/afterChange events. If you pass only array of
  13166. * changes then `source` could be set as second parameter.
  13167. *
  13168. * @memberof Core#
  13169. * @function setDataAtCell
  13170. * @param {Number|Array} row Visual row index or array of changes in format `[[row, col, value], ...]`.
  13171. * @param {Number} col Visual column index.
  13172. * @param {String} value New value.
  13173. * @param {String} [source] String that identifies how this change will be described in the changes array (useful in onAfterChange or onBeforeChange callback).
  13174. */
  13175. this.setDataAtCell = function (row, col, value, source) {
  13176. var input = setDataInputToArray(row, col, value),
  13177. i,
  13178. ilen,
  13179. changes = [],
  13180. prop;
  13181. for (i = 0, ilen = input.length; i < ilen; i++) {
  13182. if (_typeof(input[i]) !== 'object') {
  13183. throw new Error('Method `setDataAtCell` accepts row number or changes array of arrays as its first parameter');
  13184. }
  13185. if (typeof input[i][1] !== 'number') {
  13186. throw new Error('Method `setDataAtCell` accepts row and column number as its parameters. If you want to use object property name, use method `setDataAtRowProp`');
  13187. }
  13188. prop = datamap.colToProp(input[i][1]);
  13189. changes.push([input[i][0], prop, dataSource.getAtCell(recordTranslator.toPhysicalRow(input[i][0]), input[i][1]), input[i][2]]);
  13190. }
  13191. if (!source && (typeof row === 'undefined' ? 'undefined' : _typeof(row)) === 'object') {
  13192. source = col;
  13193. }
  13194. instance.runHooks('afterSetDataAtCell', changes, source);
  13195. validateChanges(changes, source, function () {
  13196. applyChanges(changes, source);
  13197. });
  13198. };
  13199. /**
  13200. * @description
  13201. * Set new value to a cell. To change many cells at once, pass an array of `changes` in format `[[row, prop, value], ...]` as
  13202. * the only parameter. `prop` is the name of the object property (e.g. `first.name`). `source` is a flag for before/afterChange events.
  13203. * If you pass only array of changes then `source` could be set as second parameter.
  13204. *
  13205. * @memberof Core#
  13206. * @function setDataAtRowProp
  13207. * @param {Number|Array} row Visual row index or array of changes in format `[[row, prop, value], ...]`.
  13208. * @param {String} prop Property name or the source string.
  13209. * @param {String} value Value to be set.
  13210. * @param {String} [source] String that identifies how this change will be described in changes array (useful in onChange callback).
  13211. */
  13212. this.setDataAtRowProp = function (row, prop, value, source) {
  13213. var input = setDataInputToArray(row, prop, value),
  13214. i,
  13215. ilen,
  13216. changes = [];
  13217. for (i = 0, ilen = input.length; i < ilen; i++) {
  13218. changes.push([input[i][0], input[i][1], dataSource.getAtCell(recordTranslator.toPhysicalRow(input[i][0]), input[i][1]), input[i][2]]);
  13219. }
  13220. if (!source && (typeof row === 'undefined' ? 'undefined' : _typeof(row)) === 'object') {
  13221. source = prop;
  13222. }
  13223. instance.runHooks('afterSetDataAtRowProp', changes, source);
  13224. validateChanges(changes, source, function () {
  13225. applyChanges(changes, source);
  13226. });
  13227. };
  13228. /**
  13229. * Listen to the keyboard input on document body.
  13230. *
  13231. * @memberof Core#
  13232. * @function listen
  13233. * @since 0.11
  13234. * @param {Boolean} [modifyDocumentFocus=true] If `true`, currently focused element will be blured (which returns focus
  13235. * to the document.body). Otherwise the active element does not lose its focus.
  13236. */
  13237. this.listen = function () {
  13238. var modifyDocumentFocus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  13239. if (modifyDocumentFocus) {
  13240. var invalidActiveElement = !document.activeElement || document.activeElement && document.activeElement.nodeName === void 0;
  13241. if (document.activeElement && document.activeElement !== document.body && !invalidActiveElement) {
  13242. document.activeElement.blur();
  13243. } else if (invalidActiveElement) {
  13244. // IE
  13245. document.body.focus();
  13246. }
  13247. }
  13248. if (instance && !instance.isListening()) {
  13249. activeGuid = instance.guid;
  13250. instance.runHooks('afterListen');
  13251. }
  13252. };
  13253. /**
  13254. * Stop listening to keyboard input on the document body.
  13255. *
  13256. * @memberof Core#
  13257. * @function unlisten
  13258. * @since 0.11
  13259. */
  13260. this.unlisten = function () {
  13261. if (this.isListening()) {
  13262. activeGuid = null;
  13263. instance.runHooks('afterUnlisten');
  13264. }
  13265. };
  13266. /**
  13267. * Returns `true` if the current Handsontable instance is listening to keyboard input on document body.
  13268. *
  13269. * @memberof Core#
  13270. * @function isListening
  13271. * @since 0.11
  13272. * @returns {Boolean} `true` if the instance is listening, `false` otherwise.
  13273. */
  13274. this.isListening = function () {
  13275. return activeGuid === instance.guid;
  13276. };
  13277. /**
  13278. * Destroys the current editor, renders and selects the current cell.
  13279. *
  13280. * @memberof Core#
  13281. * @function destroyEditor
  13282. * @param {Boolean} [revertOriginal] If != `true`, edited data is saved. Otherwise the previous value is restored.
  13283. */
  13284. this.destroyEditor = function (revertOriginal) {
  13285. instance._refreshBorders(revertOriginal);
  13286. };
  13287. /**
  13288. * Populate cells at position with 2D input array (e.g. `[[1, 2], [3, 4]]`).
  13289. * Use `endRow`, `endCol` when you want to cut input when a certain row is reached.
  13290. * Optional `source` parameter (default value "populateFromArray") is used to identify this call in the resulting events (beforeChange, afterChange).
  13291. * Optional `populateMethod` parameter (default value "overwrite", possible values "shift_down" and "shift_right")
  13292. * has the same effect as pasteMode option {@link Options#pasteMode}
  13293. *
  13294. * @memberof Core#
  13295. * @function populateFromArray
  13296. * @since 0.9.0
  13297. * @param {Number} row Start visual row index.
  13298. * @param {Number} col Start visual column index.
  13299. * @param {Array} input 2d array
  13300. * @param {Number} [endRow] End visual row index (use when you want to cut input when certain row is reached).
  13301. * @param {Number} [endCol] End visual column index (use when you want to cut input when certain column is reached).
  13302. * @param {String} [source="populateFromArray"] Source string.
  13303. * @param {String} [method="overwrite"] Populate method. Possible options: `shift_down`, `shift_right`, `overwrite`.
  13304. * @param {String} direction Populate direction. (left|right|up|down)
  13305. * @param {Array} deltas Deltas array.
  13306. * @returns {Object|undefined} The ending TD element in pasted area (only if any cells were changed).
  13307. */
  13308. this.populateFromArray = function (row, col, input, endRow, endCol, source, method, direction, deltas) {
  13309. var c;
  13310. if (!((typeof input === 'undefined' ? 'undefined' : _typeof(input)) === 'object' && _typeof(input[0]) === 'object')) {
  13311. throw new Error('populateFromArray parameter `input` must be an array of arrays'); // API changed in 0.9-beta2, let's check if you use it correctly
  13312. }
  13313. c = typeof endRow === 'number' ? new _src.CellCoords(endRow, endCol) : null;
  13314. return grid.populateFromArray(new _src.CellCoords(row, col), input, c, source, method, direction, deltas);
  13315. };
  13316. /**
  13317. * Adds/removes data from the column. This function is modelled after Array.splice.
  13318. * Parameter `col` is the index of the column in which do you want to do splice.
  13319. * Parameter `index` is the row index at which to start changing the array.
  13320. * If negative, will begin that many elements from the end. Parameter `amount`, is the number of the old array elements to remove.
  13321. * If the amount is 0, no elements are removed. Fourth and further parameters are the `elements` to add to the array.
  13322. * If you don't specify any elements, spliceCol simply removes elements from the array.
  13323. * {@link DataMap#spliceCol}
  13324. *
  13325. * @memberof Core#
  13326. * @function spliceCol
  13327. * @since 0.9-beta2
  13328. * @param {Number} col Index of the column in which do you want to do splice.
  13329. * @param {Number} index Index at which to start changing the array. If negative, will begin that many elements from the end.
  13330. * @param {Number} amount An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed.
  13331. * @param {*} [elements] The elements to add to the array. If you don't specify any elements, spliceCol simply removes elements from the array.
  13332. */
  13333. this.spliceCol = function (col, index, amount /* , elements... */) {
  13334. var _datamap;
  13335. return (_datamap = datamap).spliceCol.apply(_datamap, arguments);
  13336. };
  13337. /**
  13338. * Adds/removes data from the row. This function works is modelled after Array.splice.
  13339. * Parameter `row` is the index of row in which do you want to do splice.
  13340. * Parameter `index` is the column index at which to start changing the array.
  13341. * If negative, will begin that many elements from the end. Parameter `amount`, is the number of old array elements to remove.
  13342. * If the amount is 0, no elements are removed. Fourth and further parameters are the `elements` to add to the array.
  13343. * If you don't specify any elements, spliceCol simply removes elements from the array.
  13344. * {@link DataMap#spliceRow}
  13345. *
  13346. * @memberof Core#
  13347. * @function spliceRow
  13348. * @since 0.11
  13349. * @param {Number} row Index of column in which do you want to do splice.
  13350. * @param {Number} index Index at which to start changing the array. If negative, will begin that many elements from the end.
  13351. * @param {Number} amount An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed.
  13352. * @param {*} [elements] The elements to add to the array. If you don't specify any elements, spliceCol simply removes elements from the array.
  13353. */
  13354. this.spliceRow = function (row, index, amount /* , elements... */) {
  13355. var _datamap2;
  13356. return (_datamap2 = datamap).spliceRow.apply(_datamap2, arguments);
  13357. };
  13358. /**
  13359. * Returns indexes of the currently selected cells as an array of arrays `[[startRow, startCol, endRow, endCol], ...]`.
  13360. *
  13361. * Start row and start col are the coordinates of the active cell (where the selection was started).
  13362. *
  13363. * The version 0.36.0 adds a non-consecutive selection feature. Since this version, the method returns an array of arrays.
  13364. * Additionally to collect the coordinates of the currently selected area (as it was previously done by the method)
  13365. * you need to use `getSelectedLast` method.
  13366. *
  13367. * @memberof Core#
  13368. * @function getSelected
  13369. * @returns {Array[]|undefined} An array of arrays of the selection's coordinates.
  13370. */
  13371. this.getSelected = function () {
  13372. // https://github.com/handsontable/handsontable/issues/44 //cjl
  13373. if (selection.isSelected()) {
  13374. return (0, _array.arrayMap)(selection.getSelectedRange(), function (_ref11) {
  13375. var from = _ref11.from,
  13376. to = _ref11.to;
  13377. return [from.row, from.col, to.row, to.col];
  13378. });
  13379. }
  13380. };
  13381. /**
  13382. * Returns the last coordinates applied to the table as a an array `[startRow, startCol, endRow, endCol]`.
  13383. *
  13384. * @since 0.36.0
  13385. * @memberof Core#
  13386. * @function getSelectedLast
  13387. * @returns {Array|undefined} An array of the selection's coordinates.
  13388. */
  13389. this.getSelectedLast = function () {
  13390. var selected = this.getSelected();
  13391. var result = void 0;
  13392. if (selected && selected.length > 0) {
  13393. result = selected[selected.length - 1];
  13394. }
  13395. return result;
  13396. };
  13397. /**
  13398. * Returns the current selection as an array of CellRange objects.
  13399. *
  13400. * The version 0.36.0 adds a non-consecutive selection feature. Since this version, the method returns an array of arrays.
  13401. * Additionally to collect the coordinates of the currently selected area (as it was previously done by the method)
  13402. * you need to use `getSelectedRangeLast` method.
  13403. *
  13404. * @memberof Core#
  13405. * @function getSelectedRange
  13406. * @since 0.11
  13407. * @returns {CellRange[]|undefined} Selected range object or undefined` if there is no selection.
  13408. */
  13409. this.getSelectedRange = function () {
  13410. // https://github.com/handsontable/handsontable/issues/44 //cjl
  13411. if (selection.isSelected()) {
  13412. return Array.from(selection.getSelectedRange());
  13413. }
  13414. };
  13415. /**
  13416. * Returns the last coordinates applied to the table as a CellRange object.
  13417. *
  13418. * @memberof Core#
  13419. * @function getSelectedRangeLast
  13420. * @since 0.36.0
  13421. * @returns {CellRange|undefined} Selected range object or undefined` if there is no selection.
  13422. */
  13423. this.getSelectedRangeLast = function () {
  13424. var selectedRange = this.getSelectedRange();
  13425. var result = void 0;
  13426. if (selectedRange && selectedRange.length > 0) {
  13427. result = selectedRange[selectedRange.length - 1];
  13428. }
  13429. return result;
  13430. };
  13431. /**
  13432. * Erases content from cells that have been selected in the table.
  13433. *
  13434. * @memberof Core#
  13435. * @function emptySelectedCells
  13436. * @since 0.36.0
  13437. */
  13438. this.emptySelectedCells = function () {
  13439. var _this2 = this;
  13440. if (!selection.isSelected()) {
  13441. return;
  13442. }
  13443. var changes = [];
  13444. (0, _array.arrayEach)(selection.getSelectedRange(), function (cellRange) {
  13445. var topLeft = cellRange.getTopLeftCorner();
  13446. var bottomRight = cellRange.getBottomRightCorner();
  13447. (0, _number.rangeEach)(topLeft.row, bottomRight.row, function (row) {
  13448. (0, _number.rangeEach)(topLeft.col, bottomRight.col, function (column) {
  13449. if (!_this2.getCellMeta(row, column).readOnly) {
  13450. changes.push([row, column, '']);
  13451. }
  13452. });
  13453. });
  13454. });
  13455. if (changes.length > 0) {
  13456. this.setDataAtCell(changes);
  13457. }
  13458. };
  13459. /**
  13460. * Rerender the table.
  13461. *
  13462. * @memberof Core#
  13463. * @function render
  13464. */
  13465. this.render = function () {
  13466. if (instance.view) {
  13467. instance.renderCall = true;
  13468. instance.forceFullRender = true; // used when data was changed
  13469. editorManager.lockEditor();
  13470. instance._refreshBorders(null);
  13471. editorManager.unlockEditor();
  13472. }
  13473. };
  13474. /**
  13475. * Reset all cells in the grid to contain data from the data array.
  13476. *
  13477. * @memberof Core#
  13478. * @function loadData
  13479. * @param {Array} data Array of arrays or array of objects containing data.
  13480. * @fires Hooks#afterLoadData
  13481. * @fires Hooks#afterChange
  13482. */
  13483. this.loadData = function (data) {
  13484. if (Array.isArray(priv.settings.dataSchema)) {
  13485. instance.dataType = 'array';
  13486. } else if ((0, _function.isFunction)(priv.settings.dataSchema)) {
  13487. instance.dataType = 'function';
  13488. } else {
  13489. instance.dataType = 'object';
  13490. }
  13491. if (datamap) {
  13492. datamap.destroy();
  13493. }
  13494. datamap = new _dataMap2.default(instance, priv, GridSettings);
  13495. if ((typeof data === 'undefined' ? 'undefined' : _typeof(data)) === 'object' && data !== null) {
  13496. if (!(data.push && data.splice)) {
  13497. // check if data is array. Must use duck-type check so Backbone Collections also pass it
  13498. // when data is not an array, attempt to make a single-row array of it
  13499. data = [data];
  13500. }
  13501. } else if (data === null) {
  13502. data = [];
  13503. var row;
  13504. var r = 0;
  13505. var rlen = 0;
  13506. var dataSchema = datamap.getSchema();
  13507. for (r = 0, rlen = priv.settings.startRows; r < rlen; r++) {
  13508. if ((instance.dataType === 'object' || instance.dataType === 'function') && priv.settings.dataSchema) {
  13509. row = (0, _object.deepClone)(dataSchema);
  13510. data.push(row);
  13511. } else if (instance.dataType === 'array') {
  13512. row = (0, _object.deepClone)(dataSchema[0]);
  13513. data.push(row);
  13514. } else {
  13515. row = [];
  13516. for (var c = 0, clen = priv.settings.startCols; c < clen; c++) {
  13517. row.push(null);
  13518. }
  13519. data.push(row);
  13520. }
  13521. }
  13522. } else {
  13523. throw new Error('loadData only accepts array of objects or array of arrays (' + (typeof data === 'undefined' ? 'undefined' : _typeof(data)) + ' given)');
  13524. }
  13525. priv.isPopulated = false;
  13526. GridSettings.prototype.data = data;
  13527. if (Array.isArray(data[0])) {
  13528. instance.dataType = 'array';
  13529. }
  13530. datamap.dataSource = data;
  13531. dataSource.data = data;
  13532. dataSource.dataType = instance.dataType;
  13533. dataSource.colToProp = datamap.colToProp.bind(datamap);
  13534. dataSource.propToCol = datamap.propToCol.bind(datamap);
  13535. clearCellSettingCache();
  13536. grid.adjustRowsAndCols();
  13537. instance.runHooks('afterLoadData', priv.firstRun);
  13538. if (priv.firstRun) {
  13539. priv.firstRun = [null, 'loadData'];
  13540. } else {
  13541. instance.runHooks('afterChange', null, 'loadData');
  13542. instance.render();
  13543. }
  13544. priv.isPopulated = true;
  13545. function clearCellSettingCache() {
  13546. priv.cellSettings.length = 0;
  13547. }
  13548. };
  13549. /**
  13550. * Returns the current data object (the same one that was passed by `data` configuration option or `loadData` method,
  13551. * unless the `modifyRow` hook was used to trim some of the rows. If that's the case - use the {@link Core#getSourceData} method.).
  13552. * Optionally you can provide cell range by defining `row`, `col`, `row2`, `col2` to get only a fragment of grid data.
  13553. *
  13554. * Note: getData functionality changed with the release of version 0.20. If you're looking for the previous functionality,
  13555. * you should use the {@link Core#getSourceData} method.
  13556. *
  13557. * @memberof Core#
  13558. * @function getData
  13559. * @param {Number} [r] From visual row index.
  13560. * @param {Number} [c] From visual column index.
  13561. * @param {Number} [r2] To visual row index.
  13562. * @param {Number} [c2] To visual column index.
  13563. * @returns {Array} Array with the data.
  13564. */
  13565. this.getData = function (r, c, r2, c2) {
  13566. if ((0, _mixed.isUndefined)(r)) {
  13567. return datamap.getAll();
  13568. }
  13569. return datamap.getRange(new _src.CellCoords(r, c), new _src.CellCoords(r2, c2), datamap.DESTINATION_RENDERER);
  13570. };
  13571. /**
  13572. * Returns a string value of the selected range. Each column is separated by tab, each row is separated by a new line character.
  13573. * {@link DataMap#getCopyableText}
  13574. *
  13575. * @memberof Core#
  13576. * @function getCopyableText
  13577. * @since 0.11
  13578. * @param {Number} startRow From visual row index.
  13579. * @param {Number} startCol From visual column index.
  13580. * @param {Number} endRow To visual row index.
  13581. * @param {Number} endCol To visual column index.
  13582. * @returns {String}
  13583. */
  13584. this.getCopyableText = function (startRow, startCol, endRow, endCol) {
  13585. return datamap.getCopyableText(new _src.CellCoords(startRow, startCol), new _src.CellCoords(endRow, endCol));
  13586. };
  13587. /**
  13588. * Returns the data's copyable value at specified row and column index ({@link DataMap#getCopyable}).
  13589. *
  13590. * @memberof Core#
  13591. * @function getCopyableData
  13592. * @since 0.19.0
  13593. * @param {Number} row Visual row index.
  13594. * @param {Number} column Visual column index.
  13595. * @returns {String}
  13596. */
  13597. this.getCopyableData = function (row, column) {
  13598. return datamap.getCopyable(row, datamap.colToProp(column));
  13599. };
  13600. /**
  13601. * Returns schema provided by constructor settings. If it doesn't exist then it returns the schema based on the data
  13602. * structure in the first row.
  13603. *
  13604. * @memberof Core#
  13605. * @function getSchema
  13606. * @since 0.13.2
  13607. * @returns {Object} Schema object.
  13608. */
  13609. this.getSchema = function () {
  13610. return datamap.getSchema();
  13611. };
  13612. /**
  13613. * Use it if you need to change configuration after initialization. The `settings` parameter is an object containing the new
  13614. * settings, declared the same way as in the initial settings object.
  13615. * Note, that although the `updateSettings` method doesn't overwrite the previously declared settings, it might reset
  13616. * the settings made post-initialization. (for example - ignore changes made using the columnResize feature).
  13617. *
  13618. * @memberof Core#
  13619. * @function updateSettings
  13620. * @param {Object} settings New settings object.
  13621. * @param {Boolean} init Calls this method in the initialization mode. Internal use only.
  13622. * Used by API could be cause of the unexpected behaviour of the Handsontable.
  13623. * @example
  13624. * ```js
  13625. * hot.updateSettings({
  13626. * contextMenu: true,
  13627. * colHeaders: true,
  13628. * fixedRowsTop: 2
  13629. * });
  13630. * ```
  13631. * @fires Hooks#afterCellMetaReset
  13632. * @fires Hooks#afterUpdateSettings
  13633. */
  13634. this.updateSettings = function (settings, init) {
  13635. var columnsAsFunc = false;
  13636. var i = void 0;
  13637. var j = void 0;
  13638. var clen = void 0;
  13639. if ((0, _mixed.isDefined)(settings.rows)) {
  13640. throw new Error('"rows" setting is no longer supported. do you mean startRows, minRows or maxRows?');
  13641. }
  13642. if ((0, _mixed.isDefined)(settings.cols)) {
  13643. throw new Error('"cols" setting is no longer supported. do you mean startCols, minCols or maxCols?');
  13644. }
  13645. for (i in settings) {
  13646. if (i === 'data') {
  13647. /* eslint-disable-next-line no-continue */
  13648. continue; // loadData will be triggered later
  13649. } else if (i === 'language') {
  13650. setLanguage(settings.language);
  13651. /* eslint-disable-next-line no-continue */
  13652. continue;
  13653. } else if (_pluginHooks2.default.getSingleton().getRegistered().indexOf(i) > -1) {
  13654. if ((0, _function.isFunction)(settings[i]) || Array.isArray(settings[i])) {
  13655. settings[i].initialHook = true;
  13656. instance.addHook(i, settings[i]);
  13657. }
  13658. } else if (!init && (0, _object.hasOwnProperty)(settings, i)) {
  13659. // Update settings
  13660. GridSettings.prototype[i] = settings[i];
  13661. }
  13662. }
  13663. // Load data or create data map
  13664. if (settings.data === void 0 && priv.settings.data === void 0) {
  13665. instance.loadData(null); // data source created just now
  13666. } else if (settings.data !== void 0) {
  13667. instance.loadData(settings.data); // data source given as option
  13668. } else if (settings.columns !== void 0) {
  13669. datamap.createMap();
  13670. }
  13671. clen = instance.countCols();
  13672. var columnSetting = settings.columns || GridSettings.prototype.columns;
  13673. // Init columns constructors configuration
  13674. if (columnSetting && (0, _function.isFunction)(columnSetting)) {
  13675. clen = instance.countSourceCols();
  13676. columnsAsFunc = true;
  13677. }
  13678. // Clear cellSettings cache
  13679. if (settings.cell !== void 0 || settings.cells !== void 0 || settings.columns !== void 0) {
  13680. priv.cellSettings.length = 0;
  13681. }
  13682. if (clen > 0) {
  13683. var proto = void 0;
  13684. var column = void 0;
  13685. for (i = 0, j = 0; i < clen; i++) {
  13686. if (columnsAsFunc && !columnSetting(i)) {
  13687. /* eslint-disable no-continue */
  13688. continue;
  13689. }
  13690. priv.columnSettings[j] = (0, _setting.columnFactory)(GridSettings, priv.columnsSettingConflicts);
  13691. // shortcut for prototype
  13692. proto = priv.columnSettings[j].prototype;
  13693. // Use settings provided by user
  13694. if (columnSetting) {
  13695. if (columnsAsFunc) {
  13696. column = columnSetting(i);
  13697. } else {
  13698. column = columnSetting[j];
  13699. }
  13700. if (column) {
  13701. (0, _object.extend)(proto, column);
  13702. (0, _object.extend)(proto, expandType(column));
  13703. }
  13704. }
  13705. j++;
  13706. }
  13707. }
  13708. if ((0, _mixed.isDefined)(settings.cell)) {
  13709. for (var key in settings.cell) {
  13710. if ((0, _object.hasOwnProperty)(settings.cell, key)) {
  13711. var cell = settings.cell[key];
  13712. instance.setCellMetaObject(cell.row, cell.col, cell);
  13713. }
  13714. }
  13715. }
  13716. instance.runHooks('afterCellMetaReset');
  13717. if ((0, _mixed.isDefined)(settings.className)) {
  13718. if (GridSettings.prototype.className) {
  13719. (0, _element.removeClass)(instance.rootElement, GridSettings.prototype.className);
  13720. }
  13721. if (settings.className) {
  13722. (0, _element.addClass)(instance.rootElement, settings.className);
  13723. }
  13724. }
  13725. var currentHeight = instance.rootElement.style.height;
  13726. if (currentHeight !== '') {
  13727. currentHeight = parseInt(instance.rootElement.style.height, 10);
  13728. }
  13729. var height = settings.height;
  13730. if ((0, _function.isFunction)(height)) {
  13731. height = height();
  13732. }
  13733. if (init) {
  13734. var initialStyle = instance.rootElement.getAttribute('style');
  13735. if (initialStyle) {
  13736. instance.rootElement.setAttribute('data-initialstyle', instance.rootElement.getAttribute('style'));
  13737. }
  13738. }
  13739. if (height === null) {
  13740. var _initialStyle = instance.rootElement.getAttribute('data-initialstyle');
  13741. if (_initialStyle && (_initialStyle.indexOf('height') > -1 || _initialStyle.indexOf('overflow') > -1)) {
  13742. instance.rootElement.setAttribute('style', _initialStyle);
  13743. } else {
  13744. instance.rootElement.style.height = '';
  13745. instance.rootElement.style.overflow = '';
  13746. }
  13747. } else if (height !== void 0) {
  13748. instance.rootElement.style.height = height + 'px';
  13749. instance.rootElement.style.overflow = 'hidden';
  13750. }
  13751. if (typeof settings.width !== 'undefined') {
  13752. var width = settings.width;
  13753. if ((0, _function.isFunction)(width)) {
  13754. width = width();
  13755. }
  13756. instance.rootElement.style.width = width + 'px';
  13757. }
  13758. if (!init) {
  13759. datamap.clearLengthCache(); // force clear cache length on updateSettings() #3416
  13760. if (instance.view) {
  13761. instance.view.wt.wtViewport.resetHasOversizedColumnHeadersMarked();
  13762. }
  13763. instance.runHooks('afterUpdateSettings', settings);
  13764. }
  13765. grid.adjustRowsAndCols();
  13766. if (instance.view && !priv.firstRun) {
  13767. instance.forceFullRender = true; // used when data was changed
  13768. editorManager.lockEditor();
  13769. instance._refreshBorders(null);
  13770. editorManager.unlockEditor();
  13771. }
  13772. if (!init && instance.view && (currentHeight === '' || height === '' || height === void 0) && currentHeight !== height) {
  13773. instance.view.wt.wtOverlays.updateMainScrollableElements();
  13774. }
  13775. };
  13776. /**
  13777. * Get value from the selected cell.
  13778. *
  13779. * @memberof Core#
  13780. * @function getValue
  13781. * @since 0.11
  13782. * @returns {*} Value of selected cell.
  13783. */
  13784. this.getValue = function () {
  13785. var sel = instance.getSelectedLast();
  13786. if (GridSettings.prototype.getValue) {
  13787. if ((0, _function.isFunction)(GridSettings.prototype.getValue)) {
  13788. return GridSettings.prototype.getValue.call(instance);
  13789. } else if (sel) {
  13790. return instance.getData()[sel[0][0]][GridSettings.prototype.getValue];
  13791. }
  13792. } else if (sel) {
  13793. return instance.getDataAtCell(sel[0], sel[1]);
  13794. }
  13795. };
  13796. function expandType(obj) {
  13797. if (!(0, _object.hasOwnProperty)(obj, 'type')) {
  13798. // ignore obj.prototype.type
  13799. return;
  13800. }
  13801. var type,
  13802. expandedType = {};
  13803. if (_typeof(obj.type) === 'object') {
  13804. type = obj.type;
  13805. } else if (typeof obj.type === 'string') {
  13806. type = (0, _cellTypes.getCellType)(obj.type);
  13807. }
  13808. for (var i in type) {
  13809. if ((0, _object.hasOwnProperty)(type, i) && !(0, _object.hasOwnProperty)(obj, i)) {
  13810. expandedType[i] = type[i];
  13811. }
  13812. }
  13813. return expandedType;
  13814. }
  13815. /**
  13816. * Returns the object settings.
  13817. *
  13818. * @memberof Core#
  13819. * @function getSettings
  13820. * @returns {Object} Object containing the current grid settings.
  13821. */
  13822. this.getSettings = function () {
  13823. return priv.settings;
  13824. };
  13825. /**
  13826. * Clears the data from the grid (the table settings remain intact).
  13827. *
  13828. * @memberof Core#
  13829. * @function clear
  13830. * @since 0.11.0
  13831. */
  13832. this.clear = function () {
  13833. this.selectAll();
  13834. this.emptySelectedCells();
  13835. };
  13836. /**
  13837. * @memberof Core#
  13838. * @function alter
  13839. * @param {String} action See grid.alter for possible values: `"insert_row"`, `"insert_col"`, `"remove_row"`, `"remove_col"`
  13840. * @param {Number} index Visual index of the row/column before which the new row/column will be inserted/removed.
  13841. * @param {Number} [amount = 1] Amound of rows/columns to be inserted/removed.
  13842. * @param {String} [source] Source indicator.
  13843. * @param {Boolean} [keepEmptyRows] Flag for preventing deletion of empty rows.
  13844. * @description
  13845. *
  13846. * Allows altering the table structure by either inserting/removing rows or inserting/removing columns:
  13847. *
  13848. * Insert new row(s) above the row with a given `index`. If index is `null` or `undefined`, the new row will be
  13849. * added after the last row.
  13850. * ```js
  13851. * var hot = new Handsontable(document.getElementById('example'));
  13852. * hot.alter('insert_row', 10);
  13853. * ```
  13854. *
  13855. * Insert new column(s) before the column with a given `index`. If index is `null` or `undefined`, the new column
  13856. * will be added after the last column.
  13857. * ```js
  13858. * var hot = new Handsontable(document.getElementById('example'));
  13859. * hot.alter('insert_col', 10);
  13860. * ```
  13861. *
  13862. * Remove the row(s) at the given `index`.
  13863. * ```js
  13864. * var hot = new Handsontable(document.getElementById('example'));
  13865. * hot.alter('remove_row', 10);
  13866. * ```
  13867. *
  13868. * Remove the column(s) at the given `index`.
  13869. * ```js
  13870. * var hot = new Handsontable(document.getElementById('example'));
  13871. * hot.alter('remove_col', 10);
  13872. * ```
  13873. */
  13874. this.alter = function (action, index, amount, source, keepEmptyRows) {
  13875. grid.alter(action, index, amount, source, keepEmptyRows);
  13876. };
  13877. /**
  13878. * Returns a TD element for the given `row` and `col` arguments, if it is rendered on screen.
  13879. * Returns `null` if the TD is not rendered on screen (probably because that part of the table is not visible).
  13880. *
  13881. * @memberof Core#
  13882. * @function getCell
  13883. * @param {Number} row Visual row index.
  13884. * @param {Number} col Visual column index.
  13885. * @param {Boolean} topmost If set to true, it returns the TD element from the topmost overlay. For example,
  13886. * if the wanted cell is in the range of fixed rows, it will return a TD element from the `top` overlay.
  13887. * @returns {Element} The cell's TD element.
  13888. */
  13889. this.getCell = function (row, col, topmost) {
  13890. return instance.view.getCellAtCoords(new _src.CellCoords(row, col), topmost);
  13891. };
  13892. /**
  13893. * Returns the coordinates of the cell, provided as a HTML Element.
  13894. *
  13895. * @memberof Core#
  13896. * @function getCoords
  13897. * @param {Element} elem The HTML Element representing the cell.
  13898. * @returns {CellCoords} Visual coordinates object.
  13899. */
  13900. this.getCoords = function (elem) {
  13901. return this.view.wt.wtTable.getCoords.call(this.view.wt.wtTable, elem);
  13902. };
  13903. /**
  13904. * Returns the property name that corresponds with the given column index. {@link DataMap#colToProp}
  13905. * If the data source is an array of arrays, it returns the columns index.
  13906. *
  13907. * @memberof Core#
  13908. * @function colToProp
  13909. * @param {Number} col Visual column index.
  13910. * @returns {String|Number} Column property or physical column index.
  13911. */
  13912. this.colToProp = function (col) {
  13913. return datamap.colToProp(col);
  13914. };
  13915. /**
  13916. * Returns column index that corresponds with the given property. {@link DataMap#propToCol}
  13917. *
  13918. * @memberof Core#
  13919. * @function propToCol
  13920. * @param {String|Number} prop Property name or physical column index.
  13921. * @returns {Number} Visual column index.
  13922. */
  13923. this.propToCol = function (prop) {
  13924. return datamap.propToCol(prop);
  13925. };
  13926. /**
  13927. * Translate physical row index into visual.
  13928. *
  13929. * @since 0.29.0
  13930. * @memberof Core#
  13931. * @function toVisualRow
  13932. * @param {Number} row Physical row index.
  13933. * @returns {Number} Returns visual row index.
  13934. */
  13935. this.toVisualRow = function (row) {
  13936. return recordTranslator.toVisualRow(row);
  13937. };
  13938. /**
  13939. * Translate physical column index into visual.
  13940. *
  13941. * @since 0.29.0
  13942. * @memberof Core#
  13943. * @function toVisualColumn
  13944. * @param {Number} column Physical column index.
  13945. * @returns {Number} Returns visual column index.
  13946. */
  13947. this.toVisualColumn = function (column) {
  13948. return recordTranslator.toVisualColumn(column);
  13949. };
  13950. /**
  13951. * Translate visual row index into physical.
  13952. * If displayed rows order is different than the order of rows stored in memory (i.e. sorting is applied)
  13953. * to retrieve valid physical row index you can use this method.
  13954. *
  13955. * @since 0.29.0
  13956. * @memberof Core#
  13957. * @function toPhysicalRow
  13958. * @param {Number} row Visual row index.
  13959. * @returns {Number} Returns physical row index.
  13960. */
  13961. this.toPhysicalRow = function (row) {
  13962. return recordTranslator.toPhysicalRow(row);
  13963. };
  13964. /**
  13965. * Translate visual column index into physical.
  13966. * If displayed columns order is different than the order of columns stored in memory (i.e. manual column move is applied)
  13967. * to retrieve valid physical column index you can use this method.
  13968. *
  13969. * @since 0.29.0
  13970. * @memberof Core#
  13971. * @function toPhysicalColumn
  13972. * @param {Number} column Visual column index.
  13973. * @returns {Number} Returns physical column index.
  13974. */
  13975. this.toPhysicalColumn = function (column) {
  13976. return recordTranslator.toPhysicalColumn(column);
  13977. };
  13978. /**
  13979. * @description
  13980. * Returns the cell value at `row`, `col`. `row` and `col` are the __visible__ indexes (note, that if columns were reordered or sorted,
  13981. * the currently visible order will be used).
  13982. *
  13983. * @memberof Core#
  13984. * @function getDataAtCell
  13985. * @param {Number} row Visual row index.
  13986. * @param {Number} col Visual column index.
  13987. * @returns {String|Boolean|null} Data at cell.
  13988. */
  13989. this.getDataAtCell = function (row, col) {
  13990. return datamap.get(row, datamap.colToProp(col));
  13991. };
  13992. /**
  13993. * Return value at `row`, `prop`. (Uses {@link DataMap#get})
  13994. *
  13995. * @memberof Core#
  13996. * @function getDataAtRowProp
  13997. * @param {Number} row Visual row index.
  13998. * @param {String} prop Property name.
  13999. * @returns {*} Cell value.
  14000. */
  14001. this.getDataAtRowProp = function (row, prop) {
  14002. return datamap.get(row, prop);
  14003. };
  14004. /**
  14005. * @description
  14006. * Returns array of column values from the data source. `col` is the __visible__ index of the column.
  14007. * Note, that if columns were reordered or sorted, the currently visible order will be used.
  14008. *
  14009. * @memberof Core#
  14010. * @function getDataAtCol
  14011. * @since 0.9-beta2
  14012. * @param {Number} col Visual column index.
  14013. * @returns {Array} Array of cell values.
  14014. */
  14015. this.getDataAtCol = function (col) {
  14016. var out = [];
  14017. return out.concat.apply(out, _toConsumableArray(datamap.getRange(new _src.CellCoords(0, col), new _src.CellCoords(priv.settings.data.length - 1, col), datamap.DESTINATION_RENDERER)));
  14018. };
  14019. /**
  14020. * Given the object property name (e.g. `'first.name'`), returns an array of column's values from the data source.
  14021. * You can also provide a column index as the first argument.
  14022. *
  14023. * @memberof Core#
  14024. * @function getDataAtProp
  14025. * @since 0.9-beta2
  14026. * @param {String|Number} prop Property name / physical column index.
  14027. * @returns {Array} Array of cell values.
  14028. */
  14029. // TODO: Getting data from `datamap` should work on visual indexes.
  14030. this.getDataAtProp = function (prop) {
  14031. var out = [],
  14032. range;
  14033. range = datamap.getRange(new _src.CellCoords(0, datamap.propToCol(prop)), new _src.CellCoords(priv.settings.data.length - 1, datamap.propToCol(prop)), datamap.DESTINATION_RENDERER);
  14034. return out.concat.apply(out, _toConsumableArray(range));
  14035. };
  14036. /**
  14037. * Returns the source data object (the same that was passed by `data` configuration option or `loadData` method).
  14038. * Optionally you can provide a cell range by using the `row`, `col`, `row2`, `col2` arguments, to get only a fragment of grid data.
  14039. *
  14040. * @memberof Core#
  14041. * @function getSourceData
  14042. * @since 0.20.0
  14043. * @param {Number} [r] From physical row index.
  14044. * @param {Number} [c] From physical column index (or visual index, if data type is an array of objects).
  14045. * @param {Number} [r2] To physical row index.
  14046. * @param {Number} [c2] To physical column index (or visual index, if data type is an array of objects).
  14047. * @returns {Array} Array of grid data.
  14048. */
  14049. this.getSourceData = function (r, c, r2, c2) {
  14050. var data = void 0;
  14051. if (r === void 0) {
  14052. data = dataSource.getData();
  14053. } else {
  14054. data = dataSource.getByRange(new _src.CellCoords(r, c), new _src.CellCoords(r2, c2));
  14055. }
  14056. return data;
  14057. };
  14058. /**
  14059. * Returns the source data object as an arrays of arrays format even when source data was provided in another format.
  14060. * Optionally you can provide a cell range by using the `row`, `col`, `row2`, `col2` arguments, to get only a fragment of grid data.
  14061. *
  14062. * @memberof Core#
  14063. * @function getSourceDataArray
  14064. * @since 0.28.0
  14065. * @param {Number} [r] From physical row index.
  14066. * @param {Number} [c] From physical column index (or visual index, if data type is an array of objects).
  14067. * @param {Number} [r2] To physical row index.
  14068. * @param {Number} [c2] To physical column index (or visual index, if data type is an array of objects).
  14069. * @returns {Array} An array of arrays.
  14070. */
  14071. this.getSourceDataArray = function (r, c, r2, c2) {
  14072. var data = void 0;
  14073. if (r === void 0) {
  14074. data = dataSource.getData(true);
  14075. } else {
  14076. data = dataSource.getByRange(new _src.CellCoords(r, c), new _src.CellCoords(r2, c2), true);
  14077. }
  14078. return data;
  14079. };
  14080. /**
  14081. * Returns an array of column values from the data source. `col` is the index of the row in the data source.
  14082. *
  14083. * @memberof Core#
  14084. * @function getSourceDataAtCol
  14085. * @since 0.11.0-beta3
  14086. * @param {Number} column Visual column index.
  14087. * @returns {Array} Array of the column's cell values.
  14088. */
  14089. // TODO: Getting data from `sourceData` should work always on physical indexes.
  14090. this.getSourceDataAtCol = function (column) {
  14091. return dataSource.getAtColumn(column);
  14092. };
  14093. /**
  14094. * Returns a single row of the data (array or object, depending on what you have). `row` is the index of the row in the data source.
  14095. *
  14096. * @memberof Core#
  14097. * @function getSourceDataAtRow
  14098. * @since 0.11.0-beta3
  14099. * @param {Number} row Physical row index.
  14100. * @returns {Array|Object} Single row of data.
  14101. */
  14102. this.getSourceDataAtRow = function (row) {
  14103. return dataSource.getAtRow(row);
  14104. };
  14105. /**
  14106. * Returns a single value from the data source.
  14107. *
  14108. * @memberof Core#
  14109. * @function getSourceDataAtCell
  14110. * @param {Number} row Physical row index.
  14111. * @param {Number} column Visual column index.
  14112. * @returns {*} Cell data.
  14113. * @since 0.20.0
  14114. */
  14115. // TODO: Getting data from `sourceData` should work always on physical indexes.
  14116. this.getSourceDataAtCell = function (row, column) {
  14117. return dataSource.getAtCell(row, column);
  14118. };
  14119. /**
  14120. * @description
  14121. * Returns a single row of the data. The `row` argument is the __visible__ index of the row.
  14122. *
  14123. * @memberof Core#
  14124. * @function getDataAtRow
  14125. * @param {Number} row Visual row index.
  14126. * @returns {Array} Array of row's cell data.
  14127. * @since 0.9-beta2
  14128. */
  14129. this.getDataAtRow = function (row) {
  14130. var data = datamap.getRange(new _src.CellCoords(row, 0), new _src.CellCoords(row, this.countCols() - 1), datamap.DESTINATION_RENDERER);
  14131. return data[0] || [];
  14132. };
  14133. /**
  14134. * @description
  14135. * Returns a data type defined in the Handsontable settings under the `type` key ([Options#type](http://docs.handsontable.com/Options.html#type)).
  14136. * If there are cells with different types in the selected range, it returns `'mixed'`.
  14137. *
  14138. * @since 0.18.1
  14139. * @memberof Core#
  14140. * @function getDataType
  14141. * @param {Number} rowFrom From visual row index.
  14142. * @param {Number} columnFrom From visual column index.
  14143. * @param {Number} rowTo To visual row index.
  14144. * @param {Number} columnTo To visual column index.
  14145. * @returns {String} Cell type (e.q: `'mixed'`, `'text'`, `'numeric'`, `'autocomplete'`).
  14146. */
  14147. this.getDataType = function (rowFrom, columnFrom, rowTo, columnTo) {
  14148. var _this3 = this;
  14149. var previousType = null;
  14150. var currentType = null;
  14151. if (rowFrom === void 0) {
  14152. rowFrom = 0;
  14153. rowTo = this.countRows();
  14154. columnFrom = 0;
  14155. columnTo = this.countCols();
  14156. }
  14157. if (rowTo === void 0) {
  14158. rowTo = rowFrom;
  14159. }
  14160. if (columnTo === void 0) {
  14161. columnTo = columnFrom;
  14162. }
  14163. var type = 'mixed';
  14164. (0, _number.rangeEach)(Math.min(rowFrom, rowTo), Math.max(rowFrom, rowTo), function (row) {
  14165. var isTypeEqual = true;
  14166. (0, _number.rangeEach)(Math.min(columnFrom, columnTo), Math.max(columnFrom, columnTo), function (column) {
  14167. var cellType = _this3.getCellMeta(row, column);
  14168. currentType = cellType.type;
  14169. if (previousType) {
  14170. isTypeEqual = previousType === currentType;
  14171. } else {
  14172. previousType = currentType;
  14173. }
  14174. return isTypeEqual;
  14175. });
  14176. type = isTypeEqual ? currentType : 'mixed';
  14177. return isTypeEqual;
  14178. });
  14179. return type;
  14180. };
  14181. /**
  14182. * Remove a property defined by the `key` argument from the cell meta object for the provided `row` and `col` coordinates.
  14183. *
  14184. * @memberof Core#
  14185. * @function removeCellMeta
  14186. * @param {Number} row Visual row index.
  14187. * @param {Number} col Visual column index.
  14188. * @param {String} key Property name.
  14189. * @fires Hooks#beforeRemoveCellMeta
  14190. * @fires Hooks#afterRemoveCellMeta
  14191. */
  14192. this.removeCellMeta = function (row, col, key) {
  14193. var _recordTranslator$toP = recordTranslator.toPhysical(row, col),
  14194. _recordTranslator$toP2 = _slicedToArray(_recordTranslator$toP, 2),
  14195. physicalRow = _recordTranslator$toP2[0],
  14196. physicalColumn = _recordTranslator$toP2[1];
  14197. var cachedValue = priv.cellSettings[physicalRow][physicalColumn][key];
  14198. var hookResult = instance.runHooks('beforeRemoveCellMeta', row, col, key, cachedValue);
  14199. if (hookResult !== false) {
  14200. delete priv.cellSettings[physicalRow][physicalColumn][key];
  14201. instance.runHooks('afterRemoveCellMeta', row, col, key, cachedValue);
  14202. }
  14203. cachedValue = null;
  14204. };
  14205. /**
  14206. * Remove one or more rows from the cell meta object.
  14207. *
  14208. * @since 0.30.0
  14209. * @param {Number} index An integer that specifies at what position to add/remove items, Use negative values to specify the position from the end of the array.
  14210. * @param {Number} deleteAmount The number of items to be removed. If set to 0, no items will be removed.
  14211. * @param {Array} items The new items to be added to the array.
  14212. */
  14213. this.spliceCellsMeta = function (index, deleteAmount) {
  14214. var _priv$cellSettings;
  14215. for (var _len2 = arguments.length, items = Array(_len2 > 2 ? _len2 - 2 : 0), _key = 2; _key < _len2; _key++) {
  14216. items[_key - 2] = arguments[_key];
  14217. }
  14218. (_priv$cellSettings = priv.cellSettings).splice.apply(_priv$cellSettings, [index, deleteAmount].concat(items));
  14219. };
  14220. /**
  14221. * Set cell meta data object defined by `prop` to the corresponding params `row` and `col`.
  14222. *
  14223. * @memberof Core#
  14224. * @function setCellMetaObject
  14225. * @since 0.11
  14226. * @param {Number} row Visual row index.
  14227. * @param {Number} col Visual column index.
  14228. * @param {Object} prop Meta object.
  14229. */
  14230. this.setCellMetaObject = function (row, col, prop) {
  14231. if ((typeof prop === 'undefined' ? 'undefined' : _typeof(prop)) === 'object') {
  14232. for (var key in prop) {
  14233. if ((0, _object.hasOwnProperty)(prop, key)) {
  14234. var value = prop[key];
  14235. this.setCellMeta(row, col, key, value);
  14236. }
  14237. }
  14238. }
  14239. };
  14240. /**
  14241. * Sets a property defined by the `key` object to the meta object of a cell corresponding to params `row` and `col`.
  14242. *
  14243. * @memberof Core#
  14244. * @function setCellMeta
  14245. * @since 0.11
  14246. * @param {Number} row Visual row index.
  14247. * @param {Number} col Visual column index.
  14248. * @param {String} key Property name.
  14249. * @param {String} val Property value.
  14250. * @fires Hooks#afterSetCellMeta
  14251. */
  14252. this.setCellMeta = function (row, col, key, val) {
  14253. var _recordTranslator$toP3 = recordTranslator.toPhysical(row, col),
  14254. _recordTranslator$toP4 = _slicedToArray(_recordTranslator$toP3, 2),
  14255. physicalRow = _recordTranslator$toP4[0],
  14256. physicalColumn = _recordTranslator$toP4[1];
  14257. if (!priv.columnSettings[physicalColumn]) {
  14258. priv.columnSettings[physicalColumn] = (0, _setting.columnFactory)(GridSettings, priv.columnsSettingConflicts);
  14259. }
  14260. if (!priv.cellSettings[physicalRow]) {
  14261. priv.cellSettings[physicalRow] = [];
  14262. }
  14263. if (!priv.cellSettings[physicalRow][physicalColumn]) {
  14264. priv.cellSettings[physicalRow][physicalColumn] = new priv.columnSettings[physicalColumn]();
  14265. }
  14266. priv.cellSettings[physicalRow][physicalColumn][key] = val;
  14267. instance.runHooks('afterSetCellMeta', row, col, key, val);
  14268. };
  14269. /**
  14270. * Get all the cells meta settings at least once generated in the table (in order of cell initialization).
  14271. *
  14272. * @since 0.19.0
  14273. * @returns {Array} Returns Array of ColumnSettings object.
  14274. */
  14275. this.getCellsMeta = function () {
  14276. return (0, _array.arrayFlatten)(priv.cellSettings);
  14277. };
  14278. /**
  14279. * Returns the cell properties object for the given `row` and `col` coordinates.
  14280. *
  14281. * @memberof Core#
  14282. * @function getCellMeta
  14283. * @param {Number} row Visual row index.
  14284. * @param {Number} col Visual column index.
  14285. * @returns {Object} The cell properties object.
  14286. * @fires Hooks#beforeGetCellMeta
  14287. * @fires Hooks#afterGetCellMeta
  14288. */
  14289. this.getCellMeta = function (row, col) {
  14290. var prop = datamap.colToProp(col);
  14291. var cellProperties = void 0;
  14292. var _recordTranslator$toP5 = recordTranslator.toPhysical(row, col),
  14293. _recordTranslator$toP6 = _slicedToArray(_recordTranslator$toP5, 2),
  14294. physicalRow = _recordTranslator$toP6[0],
  14295. physicalColumn = _recordTranslator$toP6[1];
  14296. // Workaround for #11. Connected also with #3849. It should be fixed within #4497.
  14297. if (physicalRow === null) {
  14298. physicalRow = row;
  14299. }
  14300. if (!priv.columnSettings[physicalColumn]) {
  14301. priv.columnSettings[physicalColumn] = (0, _setting.columnFactory)(GridSettings, priv.columnsSettingConflicts);
  14302. }
  14303. if (!priv.cellSettings[physicalRow]) {
  14304. priv.cellSettings[physicalRow] = [];
  14305. }
  14306. if (!priv.cellSettings[physicalRow][physicalColumn]) {
  14307. priv.cellSettings[physicalRow][physicalColumn] = new priv.columnSettings[physicalColumn]();
  14308. }
  14309. cellProperties = priv.cellSettings[physicalRow][physicalColumn]; // retrieve cellProperties from cache
  14310. cellProperties.row = physicalRow;
  14311. cellProperties.col = physicalColumn;
  14312. cellProperties.visualRow = row;
  14313. cellProperties.visualCol = col;
  14314. cellProperties.prop = prop;
  14315. cellProperties.instance = instance;
  14316. instance.runHooks('beforeGetCellMeta', row, col, cellProperties);
  14317. (0, _object.extend)(cellProperties, expandType(cellProperties)); // for `type` added in beforeGetCellMeta
  14318. if (cellProperties.cells) {
  14319. var settings = cellProperties.cells.call(cellProperties, physicalRow, physicalColumn, prop);
  14320. if (settings) {
  14321. (0, _object.extend)(cellProperties, settings);
  14322. (0, _object.extend)(cellProperties, expandType(settings)); // for `type` added in cells
  14323. }
  14324. }
  14325. instance.runHooks('afterGetCellMeta', row, col, cellProperties);
  14326. return cellProperties;
  14327. };
  14328. /**
  14329. * Returns a row off the cell meta array.
  14330. *
  14331. * @memberof Core#
  14332. * @function getCellMetaAtRow
  14333. * @since 0.30.0
  14334. * @param {Number} row Physical index of the row to return cell meta for.
  14335. * @returns {Array}
  14336. */
  14337. this.getCellMetaAtRow = function (row) {
  14338. return priv.cellSettings[row];
  14339. };
  14340. /**
  14341. * Checks if the data format and config allows user to modify the column structure.
  14342. * @returns {boolean}
  14343. */
  14344. this.isColumnModificationAllowed = function () {
  14345. return !(instance.dataType === 'object' || instance.getSettings().columns);
  14346. };
  14347. var rendererLookup = (0, _data.cellMethodLookupFactory)('renderer');
  14348. /**
  14349. * Returns the cell renderer function by given `row` and `col` arguments.
  14350. *
  14351. * @memberof Core#
  14352. * @function getCellRenderer
  14353. * @since 0.11
  14354. * @param {Number|Object} row Visual row index or cell meta object.
  14355. * @param {Number} [col] Visual column index.
  14356. * @returns {Function} The renderer function.
  14357. */
  14358. this.getCellRenderer = function (row, col) {
  14359. return (0, _renderers.getRenderer)(rendererLookup.call(this, row, col));
  14360. };
  14361. /**
  14362. * Returns the cell editor by the provided `row` and `col` arguments.
  14363. *
  14364. * @memberof Core#
  14365. * @function getCellEditor
  14366. * @param {Number} row Visual row index.
  14367. * @param {Number} col Visual column index.
  14368. * @returns {Object} The Editor object.
  14369. */
  14370. this.getCellEditor = (0, _data.cellMethodLookupFactory)('editor');
  14371. var validatorLookup = (0, _data.cellMethodLookupFactory)('validator');
  14372. /**
  14373. * Returns the cell validator by `row` and `col`, provided a validator is defined. If not - it doesn't return anything.
  14374. *
  14375. * @memberof Core#
  14376. * @function getCellValidator
  14377. * @param {Number} row Visual row index.
  14378. * @param {Number} col Visual column index.
  14379. * @returns {Function|RegExp|undefined} The validator function.
  14380. */
  14381. this.getCellValidator = function (row, col) {
  14382. var validator = validatorLookup.call(this, row, col);
  14383. if (typeof validator === 'string') {
  14384. validator = (0, _validators.getValidator)(validator);
  14385. }
  14386. return validator;
  14387. };
  14388. /**
  14389. * Validates all cells using their validator functions and calls callback when finished.
  14390. *
  14391. * If one of the cells is invalid, the callback will be fired with `'valid'` arguments as `false` - otherwise it would equal `true`.
  14392. *
  14393. * @memberof Core#
  14394. * @function validateCells
  14395. * @param {Function} [callback] The callback function.
  14396. */
  14397. this.validateCells = function (callback) {
  14398. this._validateCells(callback);
  14399. };
  14400. /**
  14401. * Validates rows using their validator functions and calls callback when finished.
  14402. *
  14403. * If one of the cells is invalid, the callback will be fired with `'valid'` arguments as `false` - otherwise it would equal `true`.
  14404. *
  14405. * @memberof Core#
  14406. * @function validateRows
  14407. * @param {Array} [rows] Array of validation target visual row indexes.
  14408. * @param {Function} [callback] The callback function.
  14409. */
  14410. this.validateRows = function (rows, callback) {
  14411. if (!Array.isArray(rows)) {
  14412. throw new Error('validateRows parameter `rows` must be an array');
  14413. }
  14414. this._validateCells(callback, rows);
  14415. };
  14416. /**
  14417. * Validates columns using their validator functions and calls callback when finished.
  14418. *
  14419. * If one of the cells is invalid, the callback will be fired with `'valid'` arguments as `false` - otherwise it would equal `true`.
  14420. *
  14421. * @memberof Core#
  14422. * @function validateColumns
  14423. * @param {Array} [columns] Array of validation target visual columns indexes.
  14424. * @param {Function} [callback] The callback function.
  14425. */
  14426. this.validateColumns = function (columns, callback) {
  14427. if (!Array.isArray(columns)) {
  14428. throw new Error('validateColumns parameter `columns` must be an array');
  14429. }
  14430. this._validateCells(callback, undefined, columns);
  14431. };
  14432. /**
  14433. * Validates all cells using their validator functions and calls callback when finished.
  14434. *
  14435. * If one of the cells is invalid, the callback will be fired with `'valid'` arguments as `false` - otherwise it would equal `true`.
  14436. *
  14437. * Private use intended.
  14438. *
  14439. * @private
  14440. * @memberof Core#
  14441. * @function _validateCells
  14442. * @param {Function} [callback] The callback function.
  14443. * @param {Array} [rows] Optional. Array of validation target visual row indexes.
  14444. * @param {Array} [columns] Optional. Array of validation target visual column indexes.
  14445. */
  14446. this._validateCells = function (callback, rows, columns) {
  14447. var waitingForValidator = new ValidatorsQueue();
  14448. if (callback) {
  14449. waitingForValidator.onQueueEmpty = callback;
  14450. }
  14451. var i = instance.countRows() - 1;
  14452. while (i >= 0) {
  14453. if (rows !== undefined && rows.indexOf(i) === -1) {
  14454. i--;
  14455. continue;
  14456. }
  14457. var j = instance.countCols() - 1;
  14458. while (j >= 0) {
  14459. if (columns !== undefined && columns.indexOf(j) === -1) {
  14460. j--;
  14461. continue;
  14462. }
  14463. waitingForValidator.addValidatorToQueue();
  14464. instance.validateCell(instance.getDataAtCell(i, j), instance.getCellMeta(i, j), function (result) {
  14465. if (typeof result !== 'boolean') {
  14466. throw new Error('Validation error: result is not boolean');
  14467. }
  14468. if (result === false) {
  14469. waitingForValidator.valid = false;
  14470. }
  14471. waitingForValidator.removeValidatorFormQueue();
  14472. }, 'validateCells');
  14473. j--;
  14474. }
  14475. i--;
  14476. }
  14477. waitingForValidator.checkIfQueueIsEmpty();
  14478. };
  14479. /**
  14480. * Returns an array of row headers' values (if they are enabled). If param `row` was given, it returns the header of the given row as a string.
  14481. *
  14482. * @memberof Core#
  14483. * @function getRowHeader
  14484. * @param {Number} [row] Visual row index.
  14485. * @fires Hooks#modifyRowHeader
  14486. * @returns {Array|String} Array of header values / single header value.
  14487. */
  14488. this.getRowHeader = function (row) {
  14489. var rowHeader = priv.settings.rowHeaders;
  14490. if (row !== void 0) {
  14491. row = instance.runHooks('modifyRowHeader', row);
  14492. }
  14493. if (row === void 0) {
  14494. rowHeader = [];
  14495. (0, _number.rangeEach)(instance.countRows() - 1, function (i) {
  14496. rowHeader.push(instance.getRowHeader(i));
  14497. });
  14498. } else if (Array.isArray(rowHeader) && rowHeader[row] !== void 0) {
  14499. rowHeader = rowHeader[row];
  14500. } else if ((0, _function.isFunction)(rowHeader)) {
  14501. rowHeader = rowHeader(row);
  14502. } else if (rowHeader && typeof rowHeader !== 'string' && typeof rowHeader !== 'number') {
  14503. rowHeader = row + 1;
  14504. }
  14505. return rowHeader;
  14506. };
  14507. /**
  14508. * Returns information about if this table is configured to display row headers.
  14509. *
  14510. * @memberof Core#
  14511. * @function hasRowHeaders
  14512. * @returns {Boolean} `true` if the instance has the row headers enabled, `false` otherwise.
  14513. * @since 0.11
  14514. */
  14515. this.hasRowHeaders = function () {
  14516. return !!priv.settings.rowHeaders;
  14517. };
  14518. /**
  14519. * Returns information about if this table is configured to display column headers.
  14520. *
  14521. * @memberof Core#
  14522. * @function hasColHeaders
  14523. * @since 0.11
  14524. * @returns {Boolean} `True` if the instance has the column headers enabled, `false` otherwise.
  14525. */
  14526. this.hasColHeaders = function () {
  14527. if (priv.settings.colHeaders !== void 0 && priv.settings.colHeaders !== null) {
  14528. // Polymer has empty value = null
  14529. return !!priv.settings.colHeaders;
  14530. }
  14531. for (var i = 0, ilen = instance.countCols(); i < ilen; i++) {
  14532. if (instance.getColHeader(i)) {
  14533. return true;
  14534. }
  14535. }
  14536. return false;
  14537. };
  14538. /**
  14539. * Returns an array of column headers (in string format, if they are enabled). If param `col` is given, it returns the header at the given column as a string.
  14540. *
  14541. * @memberof Core#
  14542. * @function getColHeader
  14543. * @param {Number} [col] Visual column index.
  14544. * @fires Hooks#modifyColHeader
  14545. * @returns {Array|String} The column header(s).
  14546. */
  14547. this.getColHeader = function (col) {
  14548. var columnsAsFunc = priv.settings.columns && (0, _function.isFunction)(priv.settings.columns);
  14549. var result = priv.settings.colHeaders;
  14550. col = instance.runHooks('modifyColHeader', col);
  14551. if (col === void 0) {
  14552. var out = [];
  14553. var ilen = columnsAsFunc ? instance.countSourceCols() : instance.countCols();
  14554. for (var i = 0; i < ilen; i++) {
  14555. out.push(instance.getColHeader(i));
  14556. }
  14557. result = out;
  14558. } else {
  14559. var translateVisualIndexToColumns = function translateVisualIndexToColumns(col) {
  14560. var arr = [];
  14561. var columnsLen = instance.countSourceCols();
  14562. var index = 0;
  14563. for (; index < columnsLen; index++) {
  14564. if ((0, _function.isFunction)(instance.getSettings().columns) && instance.getSettings().columns(index)) {
  14565. arr.push(index);
  14566. }
  14567. }
  14568. return arr[col];
  14569. };
  14570. var baseCol = col;
  14571. col = instance.runHooks('modifyCol', col);
  14572. var prop = translateVisualIndexToColumns(col);
  14573. if (priv.settings.columns && (0, _function.isFunction)(priv.settings.columns) && priv.settings.columns(prop) && priv.settings.columns(prop).title) {
  14574. result = priv.settings.columns(prop).title;
  14575. } else if (priv.settings.columns && priv.settings.columns[col] && priv.settings.columns[col].title) {
  14576. result = priv.settings.columns[col].title;
  14577. } else if (Array.isArray(priv.settings.colHeaders) && priv.settings.colHeaders[col] !== void 0) {
  14578. result = priv.settings.colHeaders[col];
  14579. } else if ((0, _function.isFunction)(priv.settings.colHeaders)) {
  14580. result = priv.settings.colHeaders(col);
  14581. } else if (priv.settings.colHeaders && typeof priv.settings.colHeaders !== 'string' && typeof priv.settings.colHeaders !== 'number') {
  14582. result = (0, _data.spreadsheetColumnLabel)(baseCol); // see #1458
  14583. }
  14584. }
  14585. return result;
  14586. };
  14587. /**
  14588. * Return column width from settings (no guessing). Private use intended.
  14589. *
  14590. * @private
  14591. * @memberof Core#
  14592. * @function _getColWidthFromSettings
  14593. * @param {Number} col Visual col index.
  14594. * @returns {Number}
  14595. */
  14596. this._getColWidthFromSettings = function (col) {
  14597. var cellProperties = instance.getCellMeta(0, col);
  14598. var width = cellProperties.width;
  14599. if (width === void 0 || width === priv.settings.width) {
  14600. width = cellProperties.colWidths;
  14601. }
  14602. if (width !== void 0 && width !== null) {
  14603. switch (typeof width === 'undefined' ? 'undefined' : _typeof(width)) {
  14604. case 'object':
  14605. // array
  14606. width = width[col];
  14607. break;
  14608. case 'function':
  14609. width = width(col);
  14610. break;
  14611. default:
  14612. break;
  14613. }
  14614. if (typeof width === 'string') {
  14615. width = parseInt(width, 10);
  14616. }
  14617. }
  14618. return width;
  14619. };
  14620. /**
  14621. * Returns the width of the requested column.
  14622. *
  14623. * @memberof Core#
  14624. * @function getColWidth
  14625. * @since 0.11
  14626. * @param {Number} col Visual column index.
  14627. * @returns {Number} Column width.
  14628. * @fires Hooks#modifyColWidth
  14629. */
  14630. this.getColWidth = function (col) {
  14631. var width = instance._getColWidthFromSettings(col);
  14632. width = instance.runHooks('modifyColWidth', width, col);
  14633. if (width === void 0) {
  14634. width = _src.ViewportColumnsCalculator.DEFAULT_WIDTH;
  14635. }
  14636. return width;
  14637. };
  14638. /**
  14639. * Return row height from settings (no guessing). Private use intended.
  14640. *
  14641. * @private
  14642. * @memberof Core#
  14643. * @function _getRowHeightFromSettings
  14644. * @param {Number} row Visual row index.
  14645. * @returns {Number}
  14646. */
  14647. this._getRowHeightFromSettings = function (row) {
  14648. // let cellProperties = instance.getCellMeta(row, 0);
  14649. // let height = cellProperties.height;
  14650. //
  14651. // if (height === void 0 || height === priv.settings.height) {
  14652. // height = cellProperties.rowHeights;
  14653. // }
  14654. var height = priv.settings.rowHeights;
  14655. if (height !== void 0 && height !== null) {
  14656. switch (typeof height === 'undefined' ? 'undefined' : _typeof(height)) {
  14657. case 'object':
  14658. // array
  14659. height = height[row];
  14660. break;
  14661. case 'function':
  14662. height = height(row);
  14663. break;
  14664. default:
  14665. break;
  14666. }
  14667. if (typeof height === 'string') {
  14668. height = parseInt(height, 10);
  14669. }
  14670. }
  14671. return height;
  14672. };
  14673. /**
  14674. * Returns the row height.
  14675. *
  14676. * @memberof Core#
  14677. * @function getRowHeight
  14678. * @since 0.11
  14679. * @param {Number} row Visual row index.
  14680. * @returns {Number} The given row's height.
  14681. * @fires Hooks#modifyRowHeight
  14682. */
  14683. this.getRowHeight = function (row) {
  14684. var height = instance._getRowHeightFromSettings(row);
  14685. height = instance.runHooks('modifyRowHeight', height, row);
  14686. return height;
  14687. };
  14688. /**
  14689. * Returns the total number of rows in the data source.
  14690. *
  14691. * @memberof Core#
  14692. * @function countSourceRows
  14693. * @since 0.20.0
  14694. * @returns {Number} Total number in rows in data source.
  14695. */
  14696. this.countSourceRows = function () {
  14697. var sourceLength = instance.runHooks('modifySourceLength');
  14698. return sourceLength || (instance.getSourceData() ? instance.getSourceData().length : 0);
  14699. };
  14700. /**
  14701. * Returns the total number of columns in the data source.
  14702. *
  14703. * @memberof Core#
  14704. * @function countSourceCols
  14705. * @since 0.26.1
  14706. * @returns {Number} Total number in columns in data source.
  14707. */
  14708. this.countSourceCols = function () {
  14709. var len = 0;
  14710. var obj = instance.getSourceData() && instance.getSourceData()[0] ? instance.getSourceData()[0] : [];
  14711. if ((0, _object.isObject)(obj)) {
  14712. len = (0, _object.deepObjectSize)(obj);
  14713. } else {
  14714. len = obj.length || 0;
  14715. }
  14716. return len;
  14717. };
  14718. /**
  14719. * Returns the total number of rows in the grid.
  14720. *
  14721. * @memberof Core#
  14722. * @function countRows
  14723. * @returns {Number} Total number in rows the grid.
  14724. */
  14725. this.countRows = function () {
  14726. return datamap.getLength();
  14727. };
  14728. /**
  14729. * Returns the total number of columns in the grid.
  14730. *
  14731. * @memberof Core#
  14732. * @function countCols
  14733. * @returns {Number} Total number of columns.
  14734. */
  14735. this.countCols = function () {
  14736. var maxCols = this.getSettings().maxCols;
  14737. var dataHasLength = false;
  14738. var dataLen = 0;
  14739. if (instance.dataType === 'array') {
  14740. dataHasLength = priv.settings.data && priv.settings.data[0] && priv.settings.data[0].length;
  14741. }
  14742. if (dataHasLength) {
  14743. dataLen = priv.settings.data[0].length;
  14744. }
  14745. if (priv.settings.columns) {
  14746. var columnsIsFunction = (0, _function.isFunction)(priv.settings.columns);
  14747. if (columnsIsFunction) {
  14748. if (instance.dataType === 'array') {
  14749. var columnLen = 0;
  14750. for (var i = 0; i < dataLen; i++) {
  14751. if (priv.settings.columns(i)) {
  14752. columnLen++;
  14753. }
  14754. }
  14755. dataLen = columnLen;
  14756. } else if (instance.dataType === 'object' || instance.dataType === 'function') {
  14757. dataLen = datamap.colToPropCache.length;
  14758. }
  14759. } else {
  14760. dataLen = priv.settings.columns.length;
  14761. }
  14762. } else if (instance.dataType === 'object' || instance.dataType === 'function') {
  14763. dataLen = datamap.colToPropCache.length;
  14764. }
  14765. return Math.min(maxCols, dataLen);
  14766. };
  14767. /**
  14768. * Returns an visual index of the first rendered row.
  14769. *
  14770. * @memberof Core#
  14771. * @function rowOffset
  14772. * @returns {Number} Visual index of first rendered row.
  14773. */
  14774. this.rowOffset = function () {
  14775. return instance.view.wt.wtTable.getFirstRenderedRow();
  14776. };
  14777. /**
  14778. * Returns the visual index of the first rendered column.
  14779. *
  14780. * @memberof Core#
  14781. * @function colOffset
  14782. * @returns {Number} Visual index of the first visible column.
  14783. */
  14784. this.colOffset = function () {
  14785. return instance.view.wt.wtTable.getFirstRenderedColumn();
  14786. };
  14787. /**
  14788. * Returns the number of rendered rows (including rows partially or fully rendered outside viewport).
  14789. *
  14790. * @memberof Core#
  14791. * @function countRenderedRows
  14792. * @returns {Number} Returns -1 if table is not visible.
  14793. */
  14794. this.countRenderedRows = function () {
  14795. return instance.view.wt.drawn ? instance.view.wt.wtTable.getRenderedRowsCount() : -1;
  14796. };
  14797. /**
  14798. * Returns the number of visible rows (rendered rows that fully fit inside viewport).
  14799. *
  14800. * @memberof Core#
  14801. * @function countVisibleRows
  14802. * @returns {Number} Number of visible rows or -1.
  14803. */
  14804. this.countVisibleRows = function () {
  14805. return instance.view.wt.drawn ? instance.view.wt.wtTable.getVisibleRowsCount() : -1;
  14806. };
  14807. /**
  14808. * Returns the number of rendered columns (including columns partially or fully rendered outside viewport).
  14809. *
  14810. * @memberof Core#
  14811. * @function countRenderedCols
  14812. * @returns {Number} Returns -1 if table is not visible.
  14813. */
  14814. this.countRenderedCols = function () {
  14815. return instance.view.wt.drawn ? instance.view.wt.wtTable.getRenderedColumnsCount() : -1;
  14816. };
  14817. /**
  14818. * Returns the number of visible columns. Returns -1 if table is not visible
  14819. *
  14820. * @memberof Core#
  14821. * @function countVisibleCols
  14822. * @return {Number} Number of visible columns or -1.
  14823. */
  14824. this.countVisibleCols = function () {
  14825. return instance.view.wt.drawn ? instance.view.wt.wtTable.getVisibleColumnsCount() : -1;
  14826. };
  14827. /**
  14828. * Returns the number of empty rows. If the optional ending parameter is `true`, returns the
  14829. * number of empty rows at the bottom of the table.
  14830. *
  14831. * @memberof Core#
  14832. * @function countEmptyRows
  14833. * @param {Boolean} [ending] If `true`, will only count empty rows at the end of the data source.
  14834. * @returns {Number} Count empty rows.
  14835. */
  14836. this.countEmptyRows = function (ending) {
  14837. var emptyRows = 0;
  14838. (0, _number.rangeEachReverse)(instance.countRows() - 1, function (visualIndex) {
  14839. if (instance.isEmptyRow(visualIndex)) {
  14840. emptyRows += 1;
  14841. } else if (ending === true) {
  14842. return false;
  14843. }
  14844. });
  14845. return emptyRows;
  14846. };
  14847. /**
  14848. * Returns the number of empty columns. If the optional ending parameter is `true`, returns the number of empty
  14849. * columns at right hand edge of the table.
  14850. *
  14851. * @memberof Core#
  14852. * @function countEmptyCols
  14853. * @param {Boolean} [ending] If `true`, will only count empty columns at the end of the data source row.
  14854. * @returns {Number} Count empty cols.
  14855. */
  14856. this.countEmptyCols = function (ending) {
  14857. if (instance.countRows() < 1) {
  14858. return 0;
  14859. }
  14860. var emptyColumns = 0;
  14861. (0, _number.rangeEachReverse)(instance.countCols() - 1, function (visualIndex) {
  14862. if (instance.isEmptyCol(visualIndex)) {
  14863. emptyColumns += 1;
  14864. } else if (ending === true) {
  14865. return false;
  14866. }
  14867. });
  14868. return emptyColumns;
  14869. };
  14870. /**
  14871. * Check if all cells in the row declared by the `row` argument are empty.
  14872. *
  14873. * @memberof Core#
  14874. * @function isEmptyRow
  14875. * @param {Number} row Visual row index.
  14876. * @returns {Boolean} `true` if the row at the given `row` is empty, `false` otherwise.
  14877. */
  14878. this.isEmptyRow = function (row) {
  14879. return priv.settings.isEmptyRow.call(instance, row);
  14880. };
  14881. /**
  14882. * Check if all cells in the the column declared by the `col` argument are empty.
  14883. *
  14884. * @memberof Core#
  14885. * @function isEmptyCol
  14886. * @param {Number} col Column index.
  14887. * @returns {Boolean} `true` if the column at the given `col` is empty, `false` otherwise.
  14888. */
  14889. this.isEmptyCol = function (col) {
  14890. return priv.settings.isEmptyCol.call(instance, col);
  14891. };
  14892. /**
  14893. * Select cell specified by `row` and `col` values or a range of cells finishing at `endRow`, `endCol`. If the table
  14894. * was configured to support data column properties that properties can be used to making a selection.
  14895. *
  14896. * By default, viewport will be scrolled to the selection. After the `selectCell` method had finished, the instance
  14897. * will be listening to keyboard input on the document.
  14898. *
  14899. * @example
  14900. * ```js
  14901. * // select a single cell
  14902. * hot.selectCell(2, 4);
  14903. * // select a single cell using column property
  14904. * hot.selectCell(2, 'address');
  14905. * // select a range of cells
  14906. * hot.selectCell(2, 4, 3, 5);
  14907. * // select a range of cells using column properties
  14908. * hot.selectCell(2, 'address', 3, 'phone_number');
  14909. * // select a range of cells without scrolling to them
  14910. * hot.selectCell(2, 'address', 3, 'phone_number', false);
  14911. * ```
  14912. *
  14913. * @memberof Core#
  14914. * @function selectCell
  14915. * @param {Number} row Visual row index.
  14916. * @param {Number|String} column Visual column index or column property.
  14917. * @param {Number} [endRow] Visual end row index (if selecting a range).
  14918. * @param {Number|String} [endColumn] Visual end column index or column property (if selecting a range).
  14919. * @param {Boolean} [scrollToCell=true] If `true`, the viewport will be scrolled to the selection.
  14920. * @param {Boolean} [changeListener=true] If `false`, Handsontable will not change keyboard events listener to himself.
  14921. * @returns {Boolean} `true` if selection was successful, `false` otherwise.
  14922. */
  14923. this.selectCell = function (row, column, endRow, endColumn) {
  14924. var scrollToCell = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  14925. var changeListener = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
  14926. if ((0, _mixed.isUndefined)(row) || (0, _mixed.isUndefined)(column)) {
  14927. return false;
  14928. }
  14929. return this.selectCells([[row, column, endRow, endColumn]], scrollToCell, changeListener);
  14930. };
  14931. /**
  14932. * Make multiple, non-contiguous selection specified by `row` and `column` values or a range of cells
  14933. * finishing at `endRow`, `endColumn`. The method supports two input formats which are the same as that
  14934. * produces by `getSelected` and `getSelectedRange` methods.
  14935. *
  14936. * By default, viewport will be scrolled to selection. After the `selectCells` method had finished, the instance
  14937. * will be listening to keyboard input on the document.
  14938. *
  14939. * @example
  14940. * ```js
  14941. * // using an array of arrays
  14942. * hot.selectCells([[1, 1, 2, 2], [3, 3], [6, 2, 0, 2]]);
  14943. * // using an array of arrays with defined columns as props
  14944. * hot.selectCells([[1, 'id', 2, 'first_name'], [3, 'full_name'], [6, 'last_name', 0, 'first_name']]);
  14945. * // or using an array of CellRange objects (produced by `.getSelectedRange()` method)
  14946. * const selected = hot.getSelectedRange();
  14947. *
  14948. * selected[0].from.row = 0;
  14949. * selected[0].from.col = 0;
  14950. *
  14951. * hot.selectCells(selected);
  14952. * ```
  14953. *
  14954. * @memberof Core#
  14955. * @since 0.38.0
  14956. * @function selectCells
  14957. * @param {Array[]|CellRange[]} coords Visual coords passed as an array of array (`[[rowStart, columnStart, rowEnd, columnEnd], ...]`)
  14958. * the same format as `getSelected` method returns or as an CellRange objects
  14959. * which is the same format what `getSelectedRange` method returns.
  14960. * @param {Boolean} [scrollToCell=true] If `true`, the viewport will be scrolled to the selection.
  14961. * @param {Boolean} [changeListener=true] If `false`, Handsontable will not change keyboard events listener to himself.
  14962. * @returns {Boolean} `true` if selection was successful, `false` otherwise.
  14963. */
  14964. this.selectCells = function () {
  14965. var coords = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [[]];
  14966. var scrollToCell = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  14967. var changeListener = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  14968. if (scrollToCell === false) {
  14969. preventScrollingToCell = true;
  14970. }
  14971. var wasSelected = selection.selectCells(coords);
  14972. if (wasSelected && changeListener) {
  14973. instance.listen();
  14974. }
  14975. preventScrollingToCell = false;
  14976. return wasSelected;
  14977. };
  14978. /**
  14979. * Select the cell specified by the `row` and `prop` arguments, or a range finishing at `endRow`, `endProp`.
  14980. * By default, viewport will be scrolled to selection.
  14981. *
  14982. * @deprecated
  14983. * @memberof Core#
  14984. * @function selectCellByProp
  14985. * @param {Number} row Visual row index.
  14986. * @param {String} prop Property name.
  14987. * @param {Number} [endRow] visual end row index (if selecting a range).
  14988. * @param {String} [endProp] End property name (if selecting a range).
  14989. * @param {Boolean} [scrollToCell=true] If `true`, viewport will be scrolled to the selection.
  14990. * @param {Boolean} [changeListener=true] If `false`, Handsontable will not change keyboard events listener to himself.
  14991. * @returns {Boolean} `true` if selection was successful, `false` otherwise.
  14992. */
  14993. this.selectCellByProp = function (row, prop, endRow, endProp) {
  14994. var scrollToCell = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  14995. var changeListener = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
  14996. (0, _console.warn)((0, _templateLiteralTag.toSingleLine)(_templateObject));
  14997. return this.selectCells([[row, prop, endRow, endProp]], scrollToCell, changeListener);
  14998. };
  14999. /**
  15000. * Select column specified by `startColumn` visual index, column property or a range of columns finishing at `endColumn`.
  15001. *
  15002. * @example
  15003. * ```js
  15004. * // select column using visual index
  15005. * hot.selectColumns(1);
  15006. * // select column using column property
  15007. * hot.selectColumns('id');
  15008. * // select range of columns using visual indexes
  15009. * hot.selectColumns(1, 4);
  15010. * // select range of columns using column properties
  15011. * hot.selectColumns('id', 'last_name');
  15012. * ```
  15013. *
  15014. * @memberof Core#
  15015. * @since 0.38.0
  15016. * @function selectColumns
  15017. * @param {Number} startColumn The visual column index from which the selection starts.
  15018. * @param {Number} [endColumn=startColumn] The visual column index to which the selection finishes. If `endColumn`
  15019. * is not defined the column defined by `startColumn` will be selected.
  15020. * @returns {Boolean} `true` if selection was successful, `false` otherwise.
  15021. */
  15022. this.selectColumns = function (startColumn) {
  15023. var endColumn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startColumn;
  15024. return selection.selectColumns(startColumn, endColumn);
  15025. };
  15026. /**
  15027. * Select row specified by `startRow` visual index or a range of rows finishing at `endRow`.
  15028. *
  15029. * @example
  15030. * ```js
  15031. * select row using visual index
  15032. * hot.selectRows(1);
  15033. * select range of rows using visual indexes
  15034. * hot.selectRows(1, 4);
  15035. * ```
  15036. *
  15037. * @memberof Core#
  15038. * @since 0.38.0
  15039. * @function selectRows
  15040. * @param {Number} startRow The visual row index from which the selection starts.
  15041. * @param {Number} [endRow=startRow] The visual row index to which the selection finishes. If `endRow`
  15042. * is not defined the row defined by `startRow` will be selected.
  15043. * @returns {Boolean} `true` if selection was successful, `false` otherwise.
  15044. */
  15045. this.selectRows = function (startRow) {
  15046. var endRow = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startRow;
  15047. return selection.selectRows(startRow, endRow);
  15048. };
  15049. /**
  15050. * Deselects the current cell selection on grid.
  15051. *
  15052. * @memberof Core#
  15053. * @function deselectCell
  15054. */
  15055. this.deselectCell = function () {
  15056. selection.deselect();
  15057. };
  15058. /**
  15059. * Select the whole table. The previous selection will be overwritten.
  15060. *
  15061. * @since 0.38.2
  15062. * @memberof Core#
  15063. * @function selectAll
  15064. */
  15065. this.selectAll = function () {
  15066. preventScrollingToCell = true;
  15067. selection.selectAll();
  15068. preventScrollingToCell = false;
  15069. };
  15070. /**
  15071. * Scroll viewport to coords specified by the `row` and `column` arguments.
  15072. *
  15073. * @since 0.24.3
  15074. * @memberof Core#
  15075. * @function scrollViewportTo
  15076. * @param {Number} [row] Visual row index.
  15077. * @param {Number} [column] Visual column index.
  15078. * @param {Boolean} [snapToBottom = false] If `true`, viewport is scrolled to show the cell on the bottom of the table.
  15079. * @param {Boolean} [snapToRight = false] If `true`, viewport is scrolled to show the cell on the right side of the table.
  15080. * @returns {Boolean} `true` if scroll was successful, `false` otherwise.
  15081. */
  15082. this.scrollViewportTo = function (row, column) {
  15083. var snapToBottom = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  15084. var snapToRight = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  15085. if (row !== void 0 && (row < 0 || row >= instance.countRows())) {
  15086. return false;
  15087. }
  15088. if (column !== void 0 && (column < 0 || column >= instance.countCols())) {
  15089. return false;
  15090. }
  15091. var result = false;
  15092. if (row !== void 0 && column !== void 0) {
  15093. instance.view.wt.wtOverlays.topOverlay.scrollTo(row, snapToBottom);
  15094. instance.view.wt.wtOverlays.leftOverlay.scrollTo(column, snapToRight);
  15095. result = true;
  15096. }
  15097. if (typeof row === 'number' && typeof column !== 'number') {
  15098. instance.view.wt.wtOverlays.topOverlay.scrollTo(row, snapToBottom);
  15099. result = true;
  15100. }
  15101. if (typeof column === 'number' && typeof row !== 'number') {
  15102. instance.view.wt.wtOverlays.leftOverlay.scrollTo(column, snapToRight);
  15103. result = true;
  15104. }
  15105. return result;
  15106. };
  15107. /**
  15108. * Removes grid from the DOM.
  15109. *
  15110. * @memberof Core#
  15111. * @function destroy
  15112. * @fires Hooks#afterDestroy
  15113. */
  15114. this.destroy = function () {
  15115. instance._clearTimeouts();
  15116. if (instance.view) {
  15117. // in case HT is destroyed before initialization has finished
  15118. instance.view.destroy();
  15119. }
  15120. if (dataSource) {
  15121. dataSource.destroy();
  15122. }
  15123. dataSource = null;
  15124. (0, _keyStateObserver.stopObserving)();
  15125. if (false) {
  15126. var licenseInfo = document.querySelector('#hot-display-license-info');
  15127. if (licenseInfo) {
  15128. licenseInfo.parentNode.removeChild(licenseInfo);
  15129. }
  15130. }
  15131. (0, _element.empty)(instance.rootElement);
  15132. eventManager.destroy();
  15133. if (editorManager) {
  15134. editorManager.destroy();
  15135. }
  15136. instance.runHooks('afterDestroy');
  15137. _pluginHooks2.default.getSingleton().destroy(instance);
  15138. for (var i in instance) {
  15139. if ((0, _object.hasOwnProperty)(instance, i)) {
  15140. // replace instance methods with post mortem
  15141. if ((0, _function.isFunction)(instance[i])) {
  15142. instance[i] = postMortem;
  15143. } else if (i !== 'guid') {
  15144. // replace instance properties with null (restores memory)
  15145. // it should not be necessary but this prevents a memory leak side effects that show itself in Jasmine tests
  15146. instance[i] = null;
  15147. }
  15148. }
  15149. }
  15150. // replace private properties with null (restores memory)
  15151. // it should not be necessary but this prevents a memory leak side effects that show itself in Jasmine tests
  15152. if (datamap) {
  15153. datamap.destroy();
  15154. }
  15155. datamap = null;
  15156. priv = null;
  15157. grid = null;
  15158. selection = null;
  15159. editorManager = null;
  15160. instance = null;
  15161. GridSettings = null;
  15162. };
  15163. /**
  15164. * Replacement for all methods after Handsotnable was destroyed.
  15165. *
  15166. * @private
  15167. */
  15168. function postMortem() {
  15169. throw new Error('This method cannot be called because this Handsontable instance has been destroyed');
  15170. }
  15171. /**
  15172. * Returns the active editor object.
  15173. *
  15174. * @memberof Core#
  15175. * @function getActiveEditor
  15176. * @returns {Object} The active editor object.
  15177. */
  15178. this.getActiveEditor = function () {
  15179. return editorManager.getActiveEditor();
  15180. };
  15181. /**
  15182. * Returns plugin instance using the plugin name provided.
  15183. *
  15184. * @memberof Core#
  15185. * @function getPlugin
  15186. * @param {String} pluginName The plugin name.
  15187. * @returns {*} The plugin instance.
  15188. * @since 0.15.0
  15189. */
  15190. this.getPlugin = function (pluginName) {
  15191. return (0, _plugins.getPlugin)(this, pluginName);
  15192. };
  15193. /**
  15194. * Returns the Handsontable instance.
  15195. *
  15196. * @memberof Core#
  15197. * @function getInstance
  15198. * @returns {Handsontable} The Handsontable instance.
  15199. */
  15200. this.getInstance = function () {
  15201. return instance;
  15202. };
  15203. /**
  15204. * Adds listener to the specified hook name (only for this Handsontable instance).
  15205. *
  15206. * @memberof Core#
  15207. * @function addHook
  15208. * @see Hooks#add
  15209. * @param {String} key Hook name.
  15210. * @param {Function|Array} callback Function or array of Functions.
  15211. *
  15212. * @example
  15213. * ```js
  15214. * hot.addHook('beforeInit', myCallback);
  15215. * ```
  15216. */
  15217. this.addHook = function (key, callback) {
  15218. _pluginHooks2.default.getSingleton().add(key, callback, instance);
  15219. };
  15220. /**
  15221. * Check if for a specified hook name there are added listeners (only for this Handsontable instance).
  15222. *
  15223. * @memberof Core#
  15224. * @function hasHook
  15225. * @see Hooks#has
  15226. * @param {String} key Hook name
  15227. * @return {Boolean}
  15228. *
  15229. * @example
  15230. * ```js
  15231. * var hasBeforeInitListeners = hot.hasHook('beforeInit');
  15232. * ```
  15233. */
  15234. this.hasHook = function (key) {
  15235. return _pluginHooks2.default.getSingleton().has(key, instance);
  15236. };
  15237. /**
  15238. * Adds listener to specified hook name (only for this Handsontable instance).
  15239. * After the listener is triggered, it will be automatically removed.
  15240. *
  15241. * @memberof Core#
  15242. * @function addHookOnce
  15243. * @see Hooks#once
  15244. * @param {String} key Hook name.
  15245. * @param {Function|Array} callback Function or array of Functions.
  15246. *
  15247. * @example
  15248. * ```js
  15249. * hot.addHookOnce('beforeInit', myCallback);
  15250. * ```
  15251. */
  15252. this.addHookOnce = function (key, callback) {
  15253. _pluginHooks2.default.getSingleton().once(key, callback, instance);
  15254. };
  15255. /**
  15256. * Removes the hook listener previously registered with {@link Core#addHook}.
  15257. *
  15258. * @memberof Core#
  15259. * @function removeHook
  15260. * @see Hooks#remove
  15261. * @param {String} key Hook name.
  15262. * @param {Function} callback Function which have been registered via {@link Core#addHook}.
  15263. *
  15264. * @example
  15265. * ```js
  15266. * hot.removeHook('beforeInit', myCallback);
  15267. * ```
  15268. */
  15269. this.removeHook = function (key, callback) {
  15270. _pluginHooks2.default.getSingleton().remove(key, callback, instance);
  15271. };
  15272. /**
  15273. * Run the callbacks for the hook provided in the `key` argument using the parameters given in the other arguments.
  15274. *
  15275. * @memberof Core#
  15276. * @function runHooks
  15277. * @see Hooks#run
  15278. * @param {String} key Hook name.
  15279. * @param {*} [p1] Argument passed to the callback.
  15280. * @param {*} [p2] Argument passed to the callback.
  15281. * @param {*} [p3] Argument passed to the callback.
  15282. * @param {*} [p4] Argument passed to the callback.
  15283. * @param {*} [p5] Argument passed to the callback.
  15284. * @param {*} [p6] Argument passed to the callback.
  15285. * @returns {*}
  15286. *
  15287. * @example
  15288. * ```js
  15289. * hot.runHooks('beforeInit');
  15290. * ```
  15291. */
  15292. this.runHooks = function (key, p1, p2, p3, p4, p5, p6) {
  15293. return _pluginHooks2.default.getSingleton().run(instance, key, p1, p2, p3, p4, p5, p6);
  15294. };
  15295. /**
  15296. * Get phrase for specified dictionary key.
  15297. *
  15298. * @memberof Core#
  15299. * @function getTranslatedPhrase
  15300. * @since 0.35.0
  15301. * @param {String} dictionaryKey Constant which is dictionary key.
  15302. * @param {*} extraArguments Arguments which will be handled by formatters.
  15303. *
  15304. * @returns {String}
  15305. */
  15306. this.getTranslatedPhrase = function (dictionaryKey, extraArguments) {
  15307. return (0, _i18n.getTranslatedPhrase)(priv.settings.language, dictionaryKey, extraArguments);
  15308. };
  15309. this.timeouts = [];
  15310. /**
  15311. * Sets timeout. Purpose of this method is to clear all known timeouts when `destroy` method is called.
  15312. *
  15313. * @param {*} handle
  15314. * @private
  15315. */
  15316. this._registerTimeout = function (handle) {
  15317. this.timeouts.push(handle);
  15318. };
  15319. /**
  15320. * Clears all known timeouts.
  15321. *
  15322. * @private
  15323. */
  15324. this._clearTimeouts = function () {
  15325. for (var i = 0, ilen = this.timeouts.length; i < ilen; i++) {
  15326. clearTimeout(this.timeouts[i]);
  15327. }
  15328. };
  15329. /**
  15330. * Refresh selection borders. This is temporary method relic after selection rewrite.
  15331. *
  15332. * @private
  15333. * @param {Boolean} revertOriginal
  15334. */
  15335. this._refreshBorders = function (revertOriginal) {
  15336. editorManager.destroyEditor(revertOriginal);
  15337. instance.view.render();
  15338. if (selection.isSelected()) {
  15339. editorManager.prepareEditor();
  15340. }
  15341. };
  15342. _pluginHooks2.default.getSingleton().run(instance, 'construct');
  15343. };
  15344. /***/ }),
  15345. /* 89 */
  15346. /***/ (function(module, exports, __webpack_require__) {
  15347. "use strict";
  15348. exports.__esModule = true;
  15349. exports.columnFactory = columnFactory;
  15350. var _object = __webpack_require__(2);
  15351. /* eslint-disable import/prefer-default-export */
  15352. /**
  15353. * Factory for columns constructors.
  15354. *
  15355. * @param {Object} GridSettings
  15356. * @param {Array} conflictList
  15357. * @return {Object} ColumnSettings
  15358. */
  15359. function columnFactory(GridSettings, conflictList) {
  15360. function ColumnSettings() {};
  15361. (0, _object.inherit)(ColumnSettings, GridSettings);
  15362. // Clear conflict settings
  15363. for (var i = 0, len = conflictList.length; i < len; i++) {
  15364. ColumnSettings.prototype[conflictList[i]] = void 0;
  15365. }
  15366. return ColumnSettings;
  15367. }
  15368. /***/ }),
  15369. /* 90 */
  15370. /***/ (function(module, exports, __webpack_require__) {
  15371. "use strict";
  15372. exports.__esModule = true;
  15373. exports.spreadsheetColumnLabel = spreadsheetColumnLabel;
  15374. exports.spreadsheetColumnIndex = spreadsheetColumnIndex;
  15375. exports.createSpreadsheetData = createSpreadsheetData;
  15376. exports.createSpreadsheetObjectData = createSpreadsheetObjectData;
  15377. exports.createEmptySpreadsheetData = createEmptySpreadsheetData;
  15378. exports.translateRowsToColumns = translateRowsToColumns;
  15379. exports.cellMethodLookupFactory = cellMethodLookupFactory;
  15380. var _cellTypes = __webpack_require__(87);
  15381. var _object = __webpack_require__(2);
  15382. var COLUMN_LABEL_BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  15383. var COLUMN_LABEL_BASE_LENGTH = COLUMN_LABEL_BASE.length;
  15384. /**
  15385. * Generates spreadsheet-like column names: A, B, C, ..., Z, AA, AB, etc.
  15386. *
  15387. * @param {Number} index Column index.
  15388. * @returns {String}
  15389. */
  15390. function spreadsheetColumnLabel(index) {
  15391. var dividend = index + 1;
  15392. var columnLabel = '';
  15393. var modulo = void 0;
  15394. while (dividend > 0) {
  15395. modulo = (dividend - 1) % COLUMN_LABEL_BASE_LENGTH;
  15396. columnLabel = String.fromCharCode(65 + modulo) + columnLabel;
  15397. dividend = parseInt((dividend - modulo) / COLUMN_LABEL_BASE_LENGTH, 10);
  15398. }
  15399. return columnLabel;
  15400. }
  15401. /**
  15402. * Generates spreadsheet-like column index from theirs labels: A, B, C ...., Z, AA, AB, etc.
  15403. *
  15404. * @param {String} label Column label.
  15405. * @returns {Number}
  15406. */
  15407. function spreadsheetColumnIndex(label) {
  15408. var result = 0;
  15409. if (label) {
  15410. for (var i = 0, j = label.length - 1; i < label.length; i += 1, j -= 1) {
  15411. result += Math.pow(COLUMN_LABEL_BASE_LENGTH, j) * (COLUMN_LABEL_BASE.indexOf(label[i]) + 1);
  15412. }
  15413. }
  15414. --result;
  15415. return result;
  15416. }
  15417. /**
  15418. * Creates 2D array of Excel-like values "A1", "A2", ...
  15419. *
  15420. * @param {Number} rows Number of rows to generate.
  15421. * @param {Number} columns Number of columns to generate.
  15422. * @returns {Array}
  15423. */
  15424. function createSpreadsheetData() {
  15425. var rows = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
  15426. var columns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4;
  15427. var _rows = [],
  15428. i,
  15429. j;
  15430. for (i = 0; i < rows; i++) {
  15431. var row = [];
  15432. for (j = 0; j < columns; j++) {
  15433. row.push(spreadsheetColumnLabel(j) + (i + 1));
  15434. }
  15435. _rows.push(row);
  15436. }
  15437. return _rows;
  15438. }
  15439. /**
  15440. * Creates 2D array of Excel-like values "A1", "A2", as an array of objects.
  15441. *
  15442. * @param {Number} rows Number of rows to generate.
  15443. * @param {Number} colCount Number of columns to generate.
  15444. * @returns {Array}
  15445. */
  15446. function createSpreadsheetObjectData() {
  15447. var rows = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
  15448. var colCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4;
  15449. var _rows = [],
  15450. i,
  15451. j;
  15452. for (i = 0; i < rows; i++) {
  15453. var row = {};
  15454. for (j = 0; j < colCount; j++) {
  15455. row['prop' + j] = spreadsheetColumnLabel(j) + (i + 1);
  15456. }
  15457. _rows.push(row);
  15458. }
  15459. return _rows;
  15460. }
  15461. /**
  15462. * Generates an empty data object.
  15463. *
  15464. * @param {Number} rows Number of rows to generate.
  15465. * @param {Number} columns Number of columns to generate
  15466. * @returns {Array}
  15467. */
  15468. function createEmptySpreadsheetData(rows, columns) {
  15469. var data = [];
  15470. var row = void 0;
  15471. for (var i = 0; i < rows; i++) {
  15472. row = [];
  15473. for (var j = 0; j < columns; j++) {
  15474. row.push('');
  15475. }
  15476. data.push(row);
  15477. }
  15478. return data;
  15479. }
  15480. function translateRowsToColumns(input) {
  15481. var i,
  15482. ilen,
  15483. j,
  15484. jlen,
  15485. output = [],
  15486. olen = 0;
  15487. for (i = 0, ilen = input.length; i < ilen; i++) {
  15488. for (j = 0, jlen = input[i].length; j < jlen; j++) {
  15489. if (j == olen) {
  15490. output.push([]);
  15491. olen++;
  15492. }
  15493. output[j].push(input[i][j]);
  15494. }
  15495. }
  15496. return output;
  15497. }
  15498. /**
  15499. * Factory that produces a function for searching methods (or any properties) which could be defined directly in
  15500. * table configuration or implicitly, within cell type definition.
  15501. *
  15502. * For example: renderer can be defined explicitly using "renderer" property in column configuration or it can be
  15503. * defined implicitly using "type" property.
  15504. *
  15505. * Methods/properties defined explicitly always takes precedence over those defined through "type".
  15506. *
  15507. * If the method/property is not found in an object, searching is continued recursively through prototype chain, until
  15508. * it reaches the Object.prototype.
  15509. *
  15510. *
  15511. * @param methodName {String} name of the method/property to search (i.e. 'renderer', 'validator', 'copyable')
  15512. * @param allowUndefined {Boolean} [optional] if false, the search is continued if methodName has not been found in cell "type"
  15513. * @returns {Function}
  15514. */
  15515. function cellMethodLookupFactory(methodName, allowUndefined) {
  15516. allowUndefined = typeof allowUndefined == 'undefined' ? true : allowUndefined;
  15517. return function cellMethodLookup(row, col) {
  15518. return function getMethodFromProperties(properties) {
  15519. if (!properties) {
  15520. return; // method not found
  15521. } else if ((0, _object.hasOwnProperty)(properties, methodName) && properties[methodName] !== void 0) {
  15522. // check if it is own and is not empty
  15523. return properties[methodName]; // method defined directly
  15524. } else if ((0, _object.hasOwnProperty)(properties, 'type') && properties.type) {
  15525. // check if it is own and is not empty
  15526. var type;
  15527. if (typeof properties.type != 'string') {
  15528. throw new Error('Cell type must be a string ');
  15529. }
  15530. type = (0, _cellTypes.getCellType)(properties.type);
  15531. if ((0, _object.hasOwnProperty)(type, methodName)) {
  15532. return type[methodName]; // method defined in type.
  15533. } else if (allowUndefined) {
  15534. return; // method does not defined in type (eg. validator), returns undefined
  15535. }
  15536. }
  15537. return getMethodFromProperties(Object.getPrototypeOf(properties));
  15538. }(typeof row == 'number' ? this.getCellMeta(row, col) : row);
  15539. };
  15540. }
  15541. /***/ }),
  15542. /* 91 */
  15543. /***/ (function(module, exports, __webpack_require__) {
  15544. "use strict";
  15545. exports.__esModule = true;
  15546. exports.SELECTION_TYPES = exports.SELECTION_TYPE_OBJECT = exports.SELECTION_TYPE_ARRAY = exports.SELECTION_TYPE_EMPTY = exports.SELECTION_TYPE_UNRECOGNIZED = undefined;
  15547. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  15548. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  15549. exports.detectSelectionType = detectSelectionType;
  15550. exports.normalizeSelectionFactory = normalizeSelectionFactory;
  15551. exports.transformSelectionToColumnDistance = transformSelectionToColumnDistance;
  15552. exports.transformSelectionToRowDistance = transformSelectionToRowDistance;
  15553. exports.isValidCoord = isValidCoord;
  15554. var _src = __webpack_require__(4);
  15555. var _array = __webpack_require__(1);
  15556. var _mixed = __webpack_require__(16);
  15557. var SELECTION_TYPE_UNRECOGNIZED = exports.SELECTION_TYPE_UNRECOGNIZED = 0;
  15558. var SELECTION_TYPE_EMPTY = exports.SELECTION_TYPE_EMPTY = 1;
  15559. var SELECTION_TYPE_ARRAY = exports.SELECTION_TYPE_ARRAY = 2;
  15560. var SELECTION_TYPE_OBJECT = exports.SELECTION_TYPE_OBJECT = 3;
  15561. var SELECTION_TYPES = exports.SELECTION_TYPES = [SELECTION_TYPE_OBJECT, SELECTION_TYPE_ARRAY];
  15562. var ARRAY_TYPE_PATTERN = [['number'], ['number', 'string'], ['number', 'undefined'], ['number', 'string', 'undefined']];
  15563. var rootCall = Symbol('root');
  15564. var childCall = Symbol('child');
  15565. /**
  15566. * Detect selection schema structure.
  15567. *
  15568. * @param {*} selectionRanges The selected range or and array of selected ranges. This type of data is produced by
  15569. * `hot.getSelected()`, `hot.getSelectedLast()`, `hot.getSelectedRange()`
  15570. * and `hot.getSelectedRangeLast()` methods.
  15571. * @returns {Number} Returns a number that specifies the type of detected selection schema. If selection schema type
  15572. * is unrecognized than it returns `0`.
  15573. */
  15574. function detectSelectionType(selectionRanges) {
  15575. var _callSymbol = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : rootCall;
  15576. if (_callSymbol !== rootCall && _callSymbol !== childCall) {
  15577. throw new Error('The second argument is used internally only and cannot be overwritten.');
  15578. }
  15579. var isArray = Array.isArray(selectionRanges);
  15580. var isRootCall = _callSymbol === rootCall;
  15581. var result = SELECTION_TYPE_UNRECOGNIZED;
  15582. if (isArray) {
  15583. var firstItem = selectionRanges[0];
  15584. if (selectionRanges.length === 0) {
  15585. result = SELECTION_TYPE_EMPTY;
  15586. } else if (isRootCall && firstItem instanceof _src.CellRange) {
  15587. result = SELECTION_TYPE_OBJECT;
  15588. } else if (isRootCall && Array.isArray(firstItem)) {
  15589. result = detectSelectionType(firstItem, childCall);
  15590. } else if (selectionRanges.length >= 2 && selectionRanges.length <= 4) {
  15591. var isArrayType = !selectionRanges.some(function (value, index) {
  15592. return !ARRAY_TYPE_PATTERN[index].includes(typeof value === 'undefined' ? 'undefined' : _typeof(value));
  15593. });
  15594. if (isArrayType) {
  15595. result = SELECTION_TYPE_ARRAY;
  15596. }
  15597. }
  15598. }
  15599. return result;
  15600. }
  15601. /**
  15602. * Factory function designed for normalization data schema from different data structures of the selection ranges.
  15603. *
  15604. * @param {String} type Selection type which will be processed.
  15605. * @param {Object} [options]
  15606. * @param {Boolean} [options.keepDirection=false] If `true`, the coordinates which contain the direction of the
  15607. * selected cells won't be changed. Otherwise, the selection will be
  15608. * normalized to values starting from top-left to bottom-right.
  15609. * @param {Function} [options.propToCol] Pass the converting function (usually `datamap.propToCol`) if the column
  15610. * defined as props should be normalized to the numeric values.
  15611. * @returns {Number[]} Returns normalized data about selected range as an array (`[rowStart, columnStart, rowEnd, columnEnd]`).
  15612. */
  15613. function normalizeSelectionFactory(type) {
  15614. var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  15615. _ref$keepDirection = _ref.keepDirection,
  15616. keepDirection = _ref$keepDirection === undefined ? false : _ref$keepDirection,
  15617. propToCol = _ref.propToCol;
  15618. if (!SELECTION_TYPES.includes(type)) {
  15619. throw new Error('Unsupported selection ranges schema type was provided.');
  15620. }
  15621. return function (selection) {
  15622. var isObjectType = type === SELECTION_TYPE_OBJECT;
  15623. var rowStart = isObjectType ? selection.from.row : selection[0];
  15624. var columnStart = isObjectType ? selection.from.col : selection[1];
  15625. var rowEnd = isObjectType ? selection.to.row : selection[2];
  15626. var columnEnd = isObjectType ? selection.to.col : selection[3];
  15627. if (typeof propToCol === 'function') {
  15628. if (typeof columnStart === 'string') {
  15629. columnStart = propToCol(columnStart);
  15630. }
  15631. if (typeof columnEnd === 'string') {
  15632. columnEnd = propToCol(columnEnd);
  15633. }
  15634. }
  15635. if ((0, _mixed.isUndefined)(rowEnd)) {
  15636. rowEnd = rowStart;
  15637. }
  15638. if ((0, _mixed.isUndefined)(columnEnd)) {
  15639. columnEnd = columnStart;
  15640. }
  15641. if (!keepDirection) {
  15642. var origRowStart = rowStart;
  15643. var origColumnStart = columnStart;
  15644. var origRowEnd = rowEnd;
  15645. var origColumnEnd = columnEnd;
  15646. rowStart = Math.min(origRowStart, origRowEnd);
  15647. columnStart = Math.min(origColumnStart, origColumnEnd);
  15648. rowEnd = Math.max(origRowStart, origRowEnd);
  15649. columnEnd = Math.max(origColumnStart, origColumnEnd);
  15650. }
  15651. return [rowStart, columnStart, rowEnd, columnEnd];
  15652. };
  15653. }
  15654. /**
  15655. * Function transform selection ranges (produced by `hot.getSelected()` and `hot.getSelectedRange()`) to normalized
  15656. * data structure. It merges repeated ranges into consecutive coordinates. The returned structure
  15657. * contains an array of arrays. The single item contains at index 0 visual column index from the selection was
  15658. * started and at index 1 distance as a count of selected columns.
  15659. *
  15660. * @param {Array[]|CellRange[]} selectionRanges Selection ranges produced by Handsontable.
  15661. * @return {Array[]} Returns an array of arrays with ranges defines in that schema:
  15662. * `[[visualColumnStart, distance], [visualColumnStart, distance], ...]`.
  15663. * The column distances are always created starting from the left (zero index) to the
  15664. * right (the latest column index).
  15665. */
  15666. function transformSelectionToColumnDistance(selectionRanges) {
  15667. var selectionType = detectSelectionType(selectionRanges);
  15668. if (selectionType === SELECTION_TYPE_UNRECOGNIZED || selectionType === SELECTION_TYPE_EMPTY) {
  15669. return [];
  15670. }
  15671. var selectionSchemaNormalizer = normalizeSelectionFactory(selectionType);
  15672. var unorderedIndexes = new Set();
  15673. // Iterate through all ranges and collect all column indexes which are not saved yet.
  15674. (0, _array.arrayEach)(selectionRanges, function (selection) {
  15675. var _selectionSchemaNorma = selectionSchemaNormalizer(selection),
  15676. _selectionSchemaNorma2 = _slicedToArray(_selectionSchemaNorma, 4),
  15677. columnStart = _selectionSchemaNorma2[1],
  15678. columnEnd = _selectionSchemaNorma2[3];
  15679. var amount = columnEnd - columnStart + 1;
  15680. (0, _array.arrayEach)(Array.from(new Array(amount), function (_, i) {
  15681. return columnStart + i;
  15682. }), function (index) {
  15683. if (!unorderedIndexes.has(index)) {
  15684. unorderedIndexes.add(index);
  15685. }
  15686. });
  15687. });
  15688. // Sort indexes in ascending order to easily detecting non-consecutive columns.
  15689. var orderedIndexes = Array.from(unorderedIndexes).sort(function (a, b) {
  15690. return a - b;
  15691. });
  15692. var normalizedColumnRanges = (0, _array.arrayReduce)(orderedIndexes, function (acc, visualColumnIndex, index, array) {
  15693. if (index !== 0 && visualColumnIndex === array[index - 1] + 1) {
  15694. acc[acc.length - 1][1]++;
  15695. } else {
  15696. acc.push([visualColumnIndex, 1]);
  15697. }
  15698. return acc;
  15699. }, []);
  15700. return normalizedColumnRanges;
  15701. }
  15702. /**
  15703. * Function transform selection ranges (produced by `hot.getSelected()` and `hot.getSelectedRange()`) to normalized
  15704. * data structure. It merges repeated ranges into consecutive coordinates. The returned structure
  15705. * contains an array of arrays. The single item contains at index 0 visual column index from the selection was
  15706. * started and at index 1 distance as a count of selected columns.
  15707. *
  15708. * @param {Array[]|CellRange[]} selectionRanges Selection ranges produced by Handsontable.
  15709. * @return {Array[]} Returns an array of arrays with ranges defines in that schema:
  15710. * `[[visualColumnStart, distance], [visualColumnStart, distance], ...]`.
  15711. * The column distances are always created starting from the left (zero index) to the
  15712. * right (the latest column index).
  15713. */
  15714. function transformSelectionToRowDistance(selectionRanges) {
  15715. var selectionType = detectSelectionType(selectionRanges);
  15716. if (selectionType === SELECTION_TYPE_UNRECOGNIZED || selectionType === SELECTION_TYPE_EMPTY) {
  15717. return [];
  15718. }
  15719. var selectionSchemaNormalizer = normalizeSelectionFactory(selectionType);
  15720. var unorderedIndexes = new Set();
  15721. // Iterate through all ranges and collect all column indexes which are not saved yet.
  15722. (0, _array.arrayEach)(selectionRanges, function (selection) {
  15723. var _selectionSchemaNorma3 = selectionSchemaNormalizer(selection),
  15724. _selectionSchemaNorma4 = _slicedToArray(_selectionSchemaNorma3, 3),
  15725. rowStart = _selectionSchemaNorma4[0],
  15726. rowEnd = _selectionSchemaNorma4[2];
  15727. var amount = rowEnd - rowStart + 1;
  15728. (0, _array.arrayEach)(Array.from(new Array(amount), function (_, i) {
  15729. return rowStart + i;
  15730. }), function (index) {
  15731. if (!unorderedIndexes.has(index)) {
  15732. unorderedIndexes.add(index);
  15733. }
  15734. });
  15735. });
  15736. // Sort indexes in ascending order to easily detecting non-consecutive columns.
  15737. var orderedIndexes = Array.from(unorderedIndexes).sort(function (a, b) {
  15738. return a - b;
  15739. });
  15740. var normalizedRowRanges = (0, _array.arrayReduce)(orderedIndexes, function (acc, rowIndex, index, array) {
  15741. if (index !== 0 && rowIndex === array[index - 1] + 1) {
  15742. acc[acc.length - 1][1]++;
  15743. } else {
  15744. acc.push([rowIndex, 1]);
  15745. }
  15746. return acc;
  15747. }, []);
  15748. return normalizedRowRanges;
  15749. }
  15750. /**
  15751. * Check if passed value can be treated as valid cell coordinate. The second argument is
  15752. * used to check if the value doesn't exceed the defined max table rows/columns count.
  15753. *
  15754. * @param {*} coord
  15755. * @param {Number} maxTableItemsCount The value that declares the maximum coordinate that is still validatable.
  15756. * @return {Boolean}
  15757. */
  15758. function isValidCoord(coord) {
  15759. var maxTableItemsCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
  15760. return typeof coord === 'number' && coord >= 0 && coord < maxTableItemsCount;
  15761. };
  15762. /***/ }),
  15763. /* 92 */
  15764. /***/ (function(module, exports, __webpack_require__) {
  15765. "use strict";
  15766. exports.__esModule = true;
  15767. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  15768. var _element = __webpack_require__(0);
  15769. var _array = __webpack_require__(1);
  15770. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15771. /**
  15772. * @class GhostTable
  15773. * @util
  15774. */
  15775. var GhostTable = function () {
  15776. function GhostTable(hotInstance) {
  15777. _classCallCheck(this, GhostTable);
  15778. /**
  15779. * Handsontable instance.
  15780. *
  15781. * @type {Core}
  15782. */
  15783. this.hot = hotInstance;
  15784. /**
  15785. * Container element where every table will be injected.
  15786. *
  15787. * @type {HTMLElement|null}
  15788. */
  15789. this.container = null;
  15790. /**
  15791. * Flag which determine is table was injected to DOM.
  15792. *
  15793. * @type {Boolean}
  15794. */
  15795. this.injected = false;
  15796. /**
  15797. * Added rows collection.
  15798. *
  15799. * @type {Array}
  15800. */
  15801. this.rows = [];
  15802. /**
  15803. * Added columns collection.
  15804. *
  15805. * @type {Array}
  15806. */
  15807. this.columns = [];
  15808. /**
  15809. * Samples prepared for calculations.
  15810. *
  15811. * @type {Map}
  15812. * @default {null}
  15813. */
  15814. this.samples = null;
  15815. /**
  15816. * Ghost table settings.
  15817. *
  15818. * @type {Object}
  15819. * @default {Object}
  15820. */
  15821. this.settings = {
  15822. useHeaders: true
  15823. };
  15824. }
  15825. /**
  15826. * Add row.
  15827. *
  15828. * @param {Number} row Row index.
  15829. * @param {Map} samples Samples Map object.
  15830. */
  15831. _createClass(GhostTable, [{
  15832. key: 'addRow',
  15833. value: function addRow(row, samples) {
  15834. if (this.columns.length) {
  15835. throw new Error('Doesn\'t support multi-dimensional table');
  15836. }
  15837. if (!this.rows.length) {
  15838. this.container = this.createContainer(this.hot.rootElement.className);
  15839. }
  15840. var rowObject = { row: row };
  15841. this.rows.push(rowObject);
  15842. this.samples = samples;
  15843. this.table = this.createTable(this.hot.table.className);
  15844. this.table.colGroup.appendChild(this.createColGroupsCol());
  15845. this.table.tr.appendChild(this.createRow(row));
  15846. this.container.container.appendChild(this.table.fragment);
  15847. rowObject.table = this.table.table;
  15848. }
  15849. /**
  15850. * Add a row consisting of the column headers.
  15851. */
  15852. }, {
  15853. key: 'addColumnHeadersRow',
  15854. value: function addColumnHeadersRow(samples) {
  15855. if (this.hot.getColHeader(0) != null) {
  15856. var rowObject = { row: -1 };
  15857. this.rows.push(rowObject);
  15858. this.container = this.createContainer(this.hot.rootElement.className);
  15859. this.samples = samples;
  15860. this.table = this.createTable(this.hot.table.className);
  15861. this.table.colGroup.appendChild(this.createColGroupsCol());
  15862. this.table.tHead.appendChild(this.createColumnHeadersRow());
  15863. this.container.container.appendChild(this.table.fragment);
  15864. rowObject.table = this.table.table;
  15865. }
  15866. }
  15867. /**
  15868. * Add column.
  15869. *
  15870. * @param {Number} column Column index.
  15871. * @param {Map} samples Samples Map object.
  15872. */
  15873. }, {
  15874. key: 'addColumn',
  15875. value: function addColumn(column, samples) {
  15876. if (this.rows.length) {
  15877. throw new Error('Doesn\'t support multi-dimensional table');
  15878. }
  15879. if (!this.columns.length) {
  15880. this.container = this.createContainer(this.hot.rootElement.className);
  15881. }
  15882. var columnObject = { col: column };
  15883. this.columns.push(columnObject);
  15884. this.samples = samples;
  15885. this.table = this.createTable(this.hot.table.className);
  15886. if (this.getSetting('useHeaders') && this.hot.getColHeader(column) !== null) {
  15887. this.hot.view.appendColHeader(column, this.table.th);
  15888. }
  15889. this.table.tBody.appendChild(this.createCol(column));
  15890. this.container.container.appendChild(this.table.fragment);
  15891. columnObject.table = this.table.table;
  15892. }
  15893. /**
  15894. * Get calculated heights.
  15895. *
  15896. * @param {Function} callback Callback which will be fired for each calculated row.
  15897. */
  15898. }, {
  15899. key: 'getHeights',
  15900. value: function getHeights(callback) {
  15901. if (!this.injected) {
  15902. this.injectTable();
  15903. }
  15904. (0, _array.arrayEach)(this.rows, function (row) {
  15905. // -1 <- reduce border-top from table
  15906. callback(row.row, (0, _element.outerHeight)(row.table) - 1);
  15907. });
  15908. }
  15909. /**
  15910. * Get calculated widths.
  15911. *
  15912. * @param {Function} callback Callback which will be fired for each calculated column.
  15913. */
  15914. }, {
  15915. key: 'getWidths',
  15916. value: function getWidths(callback) {
  15917. if (!this.injected) {
  15918. this.injectTable();
  15919. }
  15920. (0, _array.arrayEach)(this.columns, function (column) {
  15921. callback(column.col, (0, _element.outerWidth)(column.table));
  15922. });
  15923. }
  15924. /**
  15925. * Set the Ghost Table settings to the provided object.
  15926. *
  15927. * @param {Object} settings New Ghost Table Settings
  15928. */
  15929. }, {
  15930. key: 'setSettings',
  15931. value: function setSettings(settings) {
  15932. this.settings = settings;
  15933. }
  15934. /**
  15935. * Set a single setting of the Ghost Table.
  15936. *
  15937. * @param {String} name Setting name.
  15938. * @param {*} value Setting value.
  15939. */
  15940. }, {
  15941. key: 'setSetting',
  15942. value: function setSetting(name, value) {
  15943. if (!this.settings) {
  15944. this.settings = {};
  15945. }
  15946. this.settings[name] = value;
  15947. }
  15948. /**
  15949. * Get the Ghost Table settings.
  15950. *
  15951. * @returns {Object|null}
  15952. */
  15953. }, {
  15954. key: 'getSettings',
  15955. value: function getSettings() {
  15956. return this.settings;
  15957. }
  15958. /**
  15959. * Get a single Ghost Table setting.
  15960. *
  15961. * @param {String} name
  15962. * @returns {Boolean|null}
  15963. */
  15964. }, {
  15965. key: 'getSetting',
  15966. value: function getSetting(name) {
  15967. if (this.settings) {
  15968. return this.settings[name];
  15969. }
  15970. return null;
  15971. }
  15972. /**
  15973. * Create colgroup col elements.
  15974. *
  15975. * @returns {DocumentFragment}
  15976. */
  15977. }, {
  15978. key: 'createColGroupsCol',
  15979. value: function createColGroupsCol() {
  15980. var _this = this;
  15981. var d = document;
  15982. var fragment = d.createDocumentFragment();
  15983. if (this.hot.hasRowHeaders()) {
  15984. fragment.appendChild(this.createColElement(-1));
  15985. }
  15986. this.samples.forEach(function (sample) {
  15987. (0, _array.arrayEach)(sample.strings, function (string) {
  15988. fragment.appendChild(_this.createColElement(string.col));
  15989. });
  15990. });
  15991. return fragment;
  15992. }
  15993. /**
  15994. * Create table row element.
  15995. *
  15996. * @param {Number} row Row index.
  15997. * @returns {DocumentFragment} Returns created table row elements.
  15998. */
  15999. }, {
  16000. key: 'createRow',
  16001. value: function createRow(row) {
  16002. var _this2 = this;
  16003. var d = document;
  16004. var fragment = d.createDocumentFragment();
  16005. var th = d.createElement('th');
  16006. if (this.hot.hasRowHeaders()) {
  16007. this.hot.view.appendRowHeader(row, th);
  16008. fragment.appendChild(th);
  16009. }
  16010. this.samples.forEach(function (sample) {
  16011. (0, _array.arrayEach)(sample.strings, function (string) {
  16012. var column = string.col;
  16013. var cellProperties = _this2.hot.getCellMeta(row, column);
  16014. cellProperties.col = column;
  16015. cellProperties.row = row;
  16016. var renderer = _this2.hot.getCellRenderer(cellProperties);
  16017. var td = d.createElement('td');
  16018. renderer(_this2.hot, td, row, column, _this2.hot.colToProp(column), string.value, cellProperties);
  16019. fragment.appendChild(td);
  16020. });
  16021. });
  16022. return fragment;
  16023. }
  16024. }, {
  16025. key: 'createColumnHeadersRow',
  16026. value: function createColumnHeadersRow() {
  16027. var _this3 = this;
  16028. var d = document;
  16029. var fragment = d.createDocumentFragment();
  16030. if (this.hot.hasRowHeaders()) {
  16031. var th = d.createElement('th');
  16032. this.hot.view.appendColHeader(-1, th);
  16033. fragment.appendChild(th);
  16034. }
  16035. this.samples.forEach(function (sample) {
  16036. (0, _array.arrayEach)(sample.strings, function (string) {
  16037. var column = string.col;
  16038. var th = d.createElement('th');
  16039. _this3.hot.view.appendColHeader(column, th);
  16040. fragment.appendChild(th);
  16041. });
  16042. });
  16043. return fragment;
  16044. }
  16045. /**
  16046. * Create table column elements.
  16047. *
  16048. * @param {Number} column Column index.
  16049. * @returns {DocumentFragment} Returns created column table column elements.
  16050. */
  16051. }, {
  16052. key: 'createCol',
  16053. value: function createCol(column) {
  16054. var _this4 = this;
  16055. var d = document;
  16056. var fragment = d.createDocumentFragment();
  16057. this.samples.forEach(function (sample) {
  16058. (0, _array.arrayEach)(sample.strings, function (string) {
  16059. var row = string.row;
  16060. var cellProperties = _this4.hot.getCellMeta(row, column);
  16061. cellProperties.col = column;
  16062. cellProperties.row = row;
  16063. var renderer = _this4.hot.getCellRenderer(cellProperties);
  16064. var td = d.createElement('td');
  16065. var tr = d.createElement('tr');
  16066. renderer(_this4.hot, td, row, column, _this4.hot.colToProp(column), string.value, cellProperties);
  16067. tr.appendChild(td);
  16068. fragment.appendChild(tr);
  16069. });
  16070. });
  16071. return fragment;
  16072. }
  16073. /**
  16074. * Remove table from document and reset internal state.
  16075. */
  16076. }, {
  16077. key: 'clean',
  16078. value: function clean() {
  16079. this.rows.length = 0;
  16080. this.rows[-1] = void 0;
  16081. this.columns.length = 0;
  16082. if (this.samples) {
  16083. this.samples.clear();
  16084. }
  16085. this.samples = null;
  16086. this.removeTable();
  16087. }
  16088. /**
  16089. * Inject generated table into document.
  16090. *
  16091. * @param {HTMLElement} [parent=null]
  16092. */
  16093. }, {
  16094. key: 'injectTable',
  16095. value: function injectTable() {
  16096. var parent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  16097. if (!this.injected) {
  16098. (parent || this.hot.rootElement).appendChild(this.container.fragment);
  16099. this.injected = true;
  16100. }
  16101. }
  16102. /**
  16103. * Remove table from document.
  16104. */
  16105. }, {
  16106. key: 'removeTable',
  16107. value: function removeTable() {
  16108. if (this.injected && this.container.container.parentNode) {
  16109. this.container.container.parentNode.removeChild(this.container.container);
  16110. this.container = null;
  16111. this.injected = false;
  16112. }
  16113. }
  16114. /**
  16115. * Create col element.
  16116. *
  16117. * @param {Number} column Column index.
  16118. * @returns {HTMLElement}
  16119. */
  16120. }, {
  16121. key: 'createColElement',
  16122. value: function createColElement(column) {
  16123. var d = document;
  16124. var col = d.createElement('col');
  16125. col.style.width = this.hot.view.wt.wtTable.getStretchedColumnWidth(column) + 'px';
  16126. return col;
  16127. }
  16128. /**
  16129. * Create table element.
  16130. *
  16131. * @param {String} className
  16132. * @returns {Object}
  16133. */
  16134. }, {
  16135. key: 'createTable',
  16136. value: function createTable() {
  16137. var className = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  16138. var d = document;
  16139. var fragment = d.createDocumentFragment();
  16140. var table = d.createElement('table');
  16141. var tHead = d.createElement('thead');
  16142. var tBody = d.createElement('tbody');
  16143. var colGroup = d.createElement('colgroup');
  16144. var tr = d.createElement('tr');
  16145. var th = d.createElement('th');
  16146. if (this.isVertical()) {
  16147. table.appendChild(colGroup);
  16148. }
  16149. if (this.isHorizontal()) {
  16150. tr.appendChild(th);
  16151. tHead.appendChild(tr);
  16152. table.style.tableLayout = 'auto';
  16153. table.style.width = 'auto';
  16154. }
  16155. table.appendChild(tHead);
  16156. if (this.isVertical()) {
  16157. tBody.appendChild(tr);
  16158. }
  16159. table.appendChild(tBody);
  16160. (0, _element.addClass)(table, className);
  16161. fragment.appendChild(table);
  16162. return { fragment: fragment, table: table, tHead: tHead, tBody: tBody, colGroup: colGroup, tr: tr, th: th };
  16163. }
  16164. /**
  16165. * Create container for tables.
  16166. *
  16167. * @param {String} className
  16168. * @returns {Object}
  16169. */
  16170. }, {
  16171. key: 'createContainer',
  16172. value: function createContainer() {
  16173. var className = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  16174. var d = document;
  16175. var fragment = d.createDocumentFragment();
  16176. var container = d.createElement('div');
  16177. className = 'htGhostTable htAutoSize ' + className.trim();
  16178. (0, _element.addClass)(container, className);
  16179. fragment.appendChild(container);
  16180. return { fragment: fragment, container: container };
  16181. }
  16182. /**
  16183. * Checks if table is raised vertically (checking rows).
  16184. *
  16185. * @returns {Boolean}
  16186. */
  16187. }, {
  16188. key: 'isVertical',
  16189. value: function isVertical() {
  16190. return !!(this.rows.length && !this.columns.length);
  16191. }
  16192. /**
  16193. * Checks if table is raised horizontally (checking columns).
  16194. *
  16195. * @returns {Boolean}
  16196. */
  16197. }, {
  16198. key: 'isHorizontal',
  16199. value: function isHorizontal() {
  16200. return !!(this.columns.length && !this.rows.length);
  16201. }
  16202. }]);
  16203. return GhostTable;
  16204. }();
  16205. exports.default = GhostTable;
  16206. /***/ }),
  16207. /* 93 */
  16208. /***/ (function(module, exports, __webpack_require__) {
  16209. "use strict";
  16210. exports.__esModule = true;
  16211. exports.default = separatorItem;
  16212. var KEY = exports.KEY = '---------';
  16213. function separatorItem() {
  16214. return {
  16215. name: KEY
  16216. };
  16217. }
  16218. /***/ }),
  16219. /* 94 */
  16220. /***/ (function(module, exports, __webpack_require__) {
  16221. "use strict";
  16222. exports.__esModule = true;
  16223. exports.ITEMS = exports.UNDO = exports.SEPARATOR = exports.ROW_BELOW = exports.ROW_ABOVE = exports.REMOVE_ROW = exports.REMOVE_COLUMN = exports.REDO = exports.READ_ONLY = exports.COLUMN_RIGHT = exports.COLUMN_LEFT = exports.CLEAR_COLUMN = exports.ALIGNMENT = undefined;
  16224. var _predefinedItems2;
  16225. var _alignment = __webpack_require__(422);
  16226. Object.defineProperty(exports, 'ALIGNMENT', {
  16227. enumerable: true,
  16228. get: function get() {
  16229. return _alignment.KEY;
  16230. }
  16231. });
  16232. var _clearColumn = __webpack_require__(423);
  16233. Object.defineProperty(exports, 'CLEAR_COLUMN', {
  16234. enumerable: true,
  16235. get: function get() {
  16236. return _clearColumn.KEY;
  16237. }
  16238. });
  16239. var _columnLeft = __webpack_require__(424);
  16240. Object.defineProperty(exports, 'COLUMN_LEFT', {
  16241. enumerable: true,
  16242. get: function get() {
  16243. return _columnLeft.KEY;
  16244. }
  16245. });
  16246. var _columnRight = __webpack_require__(425);
  16247. Object.defineProperty(exports, 'COLUMN_RIGHT', {
  16248. enumerable: true,
  16249. get: function get() {
  16250. return _columnRight.KEY;
  16251. }
  16252. });
  16253. var _readOnly = __webpack_require__(426);
  16254. Object.defineProperty(exports, 'READ_ONLY', {
  16255. enumerable: true,
  16256. get: function get() {
  16257. return _readOnly.KEY;
  16258. }
  16259. });
  16260. var _redo = __webpack_require__(427);
  16261. Object.defineProperty(exports, 'REDO', {
  16262. enumerable: true,
  16263. get: function get() {
  16264. return _redo.KEY;
  16265. }
  16266. });
  16267. var _removeColumn = __webpack_require__(428);
  16268. Object.defineProperty(exports, 'REMOVE_COLUMN', {
  16269. enumerable: true,
  16270. get: function get() {
  16271. return _removeColumn.KEY;
  16272. }
  16273. });
  16274. var _removeRow = __webpack_require__(429);
  16275. Object.defineProperty(exports, 'REMOVE_ROW', {
  16276. enumerable: true,
  16277. get: function get() {
  16278. return _removeRow.KEY;
  16279. }
  16280. });
  16281. var _rowAbove = __webpack_require__(430);
  16282. Object.defineProperty(exports, 'ROW_ABOVE', {
  16283. enumerable: true,
  16284. get: function get() {
  16285. return _rowAbove.KEY;
  16286. }
  16287. });
  16288. var _rowBelow = __webpack_require__(431);
  16289. Object.defineProperty(exports, 'ROW_BELOW', {
  16290. enumerable: true,
  16291. get: function get() {
  16292. return _rowBelow.KEY;
  16293. }
  16294. });
  16295. var _separator = __webpack_require__(93);
  16296. Object.defineProperty(exports, 'SEPARATOR', {
  16297. enumerable: true,
  16298. get: function get() {
  16299. return _separator.KEY;
  16300. }
  16301. });
  16302. var _undo = __webpack_require__(432);
  16303. Object.defineProperty(exports, 'UNDO', {
  16304. enumerable: true,
  16305. get: function get() {
  16306. return _undo.KEY;
  16307. }
  16308. });
  16309. exports.predefinedItems = predefinedItems;
  16310. exports.addItem = addItem;
  16311. var _object = __webpack_require__(2);
  16312. var _alignment2 = _interopRequireDefault(_alignment);
  16313. var _clearColumn2 = _interopRequireDefault(_clearColumn);
  16314. var _columnLeft2 = _interopRequireDefault(_columnLeft);
  16315. var _columnRight2 = _interopRequireDefault(_columnRight);
  16316. var _readOnly2 = _interopRequireDefault(_readOnly);
  16317. var _redo2 = _interopRequireDefault(_redo);
  16318. var _removeColumn2 = _interopRequireDefault(_removeColumn);
  16319. var _removeRow2 = _interopRequireDefault(_removeRow);
  16320. var _rowAbove2 = _interopRequireDefault(_rowAbove);
  16321. var _rowBelow2 = _interopRequireDefault(_rowBelow);
  16322. var _separator2 = _interopRequireDefault(_separator);
  16323. var _undo2 = _interopRequireDefault(_undo);
  16324. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  16325. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  16326. var ITEMS = exports.ITEMS = [_rowAbove.KEY, _rowBelow.KEY, _columnLeft.KEY, _columnRight.KEY, _clearColumn.KEY, _removeRow.KEY, _removeColumn.KEY, _undo.KEY, _redo.KEY, _readOnly.KEY, _alignment.KEY, _separator.KEY];
  16327. var _predefinedItems = (_predefinedItems2 = {}, _defineProperty(_predefinedItems2, _separator.KEY, _separator2.default), _defineProperty(_predefinedItems2, _rowAbove.KEY, _rowAbove2.default), _defineProperty(_predefinedItems2, _rowBelow.KEY, _rowBelow2.default), _defineProperty(_predefinedItems2, _columnLeft.KEY, _columnLeft2.default), _defineProperty(_predefinedItems2, _columnRight.KEY, _columnRight2.default), _defineProperty(_predefinedItems2, _clearColumn.KEY, _clearColumn2.default), _defineProperty(_predefinedItems2, _removeRow.KEY, _removeRow2.default), _defineProperty(_predefinedItems2, _removeColumn.KEY, _removeColumn2.default), _defineProperty(_predefinedItems2, _undo.KEY, _undo2.default), _defineProperty(_predefinedItems2, _redo.KEY, _redo2.default), _defineProperty(_predefinedItems2, _readOnly.KEY, _readOnly2.default), _defineProperty(_predefinedItems2, _alignment.KEY, _alignment2.default), _predefinedItems2);
  16328. /**
  16329. * Gets new object with all predefined menu items.
  16330. *
  16331. * @returns {Object}
  16332. */
  16333. function predefinedItems() {
  16334. var items = {};
  16335. (0, _object.objectEach)(_predefinedItems, function (itemFactory, key) {
  16336. items[key] = itemFactory();
  16337. });
  16338. return items;
  16339. }
  16340. /**
  16341. * Add new predefined menu item to the collection.
  16342. *
  16343. * @param {String} key Menu command id.
  16344. * @param {Object} item Object command descriptor.
  16345. */
  16346. function addItem(key, item) {
  16347. if (ITEMS.indexOf(key) === -1) {
  16348. _predefinedItems[key] = item;
  16349. }
  16350. }
  16351. /***/ }),
  16352. /* 95 */
  16353. /***/ (function(module, exports, __webpack_require__) {
  16354. "use strict";
  16355. exports.__esModule = true;
  16356. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  16357. var _templateObject = _taggedTemplateLiteral(['The merged cell declared with {row: ', ', col: ', ', rowspan: \n ', ', colspan: ', '} contains negative values, which is not supported. It \n will not be added to the collection.'], ['The merged cell declared with {row: ', ', col: ', ', rowspan: \n ', ', colspan: ', '} contains negative values, which is not supported. It \n will not be added to the collection.']),
  16358. _templateObject2 = _taggedTemplateLiteral(['The merged cell declared at [', ', ', '] is positioned (or positioned partially) \n outside of the table range. It was not added to the table, please fix your setup.'], ['The merged cell declared at [', ', ', '] is positioned (or positioned partially) \n outside of the table range. It was not added to the table, please fix your setup.']),
  16359. _templateObject3 = _taggedTemplateLiteral(['The merged cell declared at [', ', ', '] has both "rowspan" \n and "colspan" declared as "1", which makes it a single cell. It cannot be added to the collection.'], ['The merged cell declared at [', ', ', '] has both "rowspan" \n and "colspan" declared as "1", which makes it a single cell. It cannot be added to the collection.']),
  16360. _templateObject4 = _taggedTemplateLiteral(['The merged cell declared at [', ', ', '] has "rowspan" or "colspan" declared as \n "0", which is not supported. It cannot be added to the collection.'], ['The merged cell declared at [', ', ', '] has "rowspan" or "colspan" declared as \n "0", which is not supported. It cannot be added to the collection.']);
  16361. var _index = __webpack_require__(4);
  16362. var _templateLiteralTag = __webpack_require__(42);
  16363. function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
  16364. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16365. /**
  16366. * The `MergedCellCoords` class represents a single merged cell.
  16367. *
  16368. * @class MergedCellCoords
  16369. * @plugin MergeCells
  16370. */
  16371. var MergedCellCoords = function () {
  16372. function MergedCellCoords(row, column, rowspan, colspan) {
  16373. _classCallCheck(this, MergedCellCoords);
  16374. /**
  16375. * The index of the topmost merged cell row.
  16376. *
  16377. * @type {Number}
  16378. */
  16379. this.row = row;
  16380. /**
  16381. * The index of the leftmost column.
  16382. *
  16383. * @type {Number}
  16384. */
  16385. this.col = column;
  16386. /**
  16387. * The `rowspan` value of the merged cell.
  16388. *
  16389. * @type {Number}
  16390. */
  16391. this.rowspan = rowspan;
  16392. /**
  16393. * The `colspan` value of the merged cell.
  16394. *
  16395. * @type {Number}
  16396. */
  16397. this.colspan = colspan;
  16398. /**
  16399. * `true` only if the merged cell is bound to be removed.
  16400. *
  16401. * @type {Boolean}
  16402. */
  16403. this.removed = false;
  16404. }
  16405. /**
  16406. * Get a warning message for when the declared merged cell data contains negative values.
  16407. *
  16408. * @param {Object} newMergedCell Object containg information about the merged cells that was about to be added.
  16409. * @return {String}
  16410. */
  16411. _createClass(MergedCellCoords, [{
  16412. key: 'normalize',
  16413. /**
  16414. * Sanitize (prevent from going outside the boundaries) the merged cell.
  16415. *
  16416. * @param hotInstance
  16417. */
  16418. value: function normalize(hotInstance) {
  16419. var totalRows = hotInstance.countRows();
  16420. var totalColumns = hotInstance.countCols();
  16421. if (this.row < 0) {
  16422. this.row = 0;
  16423. } else if (this.row > totalRows - 1) {
  16424. this.row = totalRows - 1;
  16425. }
  16426. if (this.col < 0) {
  16427. this.col = 0;
  16428. } else if (this.col > totalColumns - 1) {
  16429. this.col = totalColumns - 1;
  16430. }
  16431. if (this.row + this.rowspan > totalRows - 1) {
  16432. this.rowspan = totalRows - this.row;
  16433. }
  16434. if (this.col + this.colspan > totalColumns - 1) {
  16435. this.colspan = totalColumns - this.col;
  16436. }
  16437. }
  16438. /**
  16439. * Returns `true` if the provided coordinates are inside the merged cell.
  16440. *
  16441. * @param {Number} row The row index.
  16442. * @param {Number} column The column index.
  16443. * @return {Boolean}
  16444. */
  16445. }, {
  16446. key: 'includes',
  16447. value: function includes(row, column) {
  16448. return this.row <= row && this.col <= column && this.row + this.rowspan - 1 >= row && this.col + this.colspan - 1 >= column;
  16449. }
  16450. /**
  16451. * Returns `true` if the provided `column` property is within the column span of the merged cell.
  16452. *
  16453. * @param {Number} column The column index.
  16454. * @return {Boolean}
  16455. */
  16456. }, {
  16457. key: 'includesHorizontally',
  16458. value: function includesHorizontally(column) {
  16459. return this.col <= column && this.col + this.colspan - 1 >= column;
  16460. }
  16461. /**
  16462. * Returns `true` if the provided `row` property is within the row span of the merged cell.
  16463. *
  16464. * @param {Number} row Row index.
  16465. * @return {Boolean}
  16466. */
  16467. }, {
  16468. key: 'includesVertically',
  16469. value: function includesVertically(row) {
  16470. return this.row <= row && this.row + this.rowspan - 1 >= row;
  16471. }
  16472. /**
  16473. * Shift (and possibly resize, if needed) the merged cell.
  16474. *
  16475. * @param {Array} shiftVector 2-element array containing the information on the shifting in the `x` and `y` axis.
  16476. * @param {Number} indexOfChange Index of the preceding change.
  16477. * @returns {Boolean} Returns `false` if the whole merged cell was removed.
  16478. */
  16479. }, {
  16480. key: 'shift',
  16481. value: function shift(shiftVector, indexOfChange) {
  16482. var shiftValue = shiftVector[0] || shiftVector[1];
  16483. var shiftedIndex = indexOfChange + Math.abs(shiftVector[0] || shiftVector[1]) - 1;
  16484. var span = shiftVector[0] ? 'colspan' : 'rowspan';
  16485. var index = shiftVector[0] ? 'col' : 'row';
  16486. var changeStart = Math.min(indexOfChange, shiftedIndex);
  16487. var changeEnd = Math.max(indexOfChange, shiftedIndex);
  16488. var mergeStart = this[index];
  16489. var mergeEnd = this[index] + this[span] - 1;
  16490. if (mergeStart >= indexOfChange) {
  16491. this[index] += shiftValue;
  16492. }
  16493. // adding rows/columns
  16494. if (shiftValue > 0) {
  16495. if (indexOfChange <= mergeEnd && indexOfChange > mergeStart) {
  16496. this[span] += shiftValue;
  16497. }
  16498. // removing rows/columns
  16499. } else if (shiftValue < 0) {
  16500. // removing the whole merge
  16501. if (changeStart <= mergeStart && changeEnd >= mergeEnd) {
  16502. this.removed = true;
  16503. return false;
  16504. // removing the merge partially, including the beginning
  16505. } else if (mergeStart >= changeStart && mergeStart <= changeEnd) {
  16506. var removedOffset = changeEnd - mergeStart + 1;
  16507. var preRemovedOffset = Math.abs(shiftValue) - removedOffset;
  16508. this[index] -= preRemovedOffset + shiftValue;
  16509. this[span] -= removedOffset;
  16510. // removing the middle part of the merge
  16511. } else if (mergeStart <= changeStart && mergeEnd >= changeEnd) {
  16512. this[span] += shiftValue;
  16513. // removing the end part of the merge
  16514. } else if (mergeStart <= changeStart && mergeEnd >= changeStart && mergeEnd < changeEnd) {
  16515. var removedPart = mergeEnd - changeStart + 1;
  16516. this[span] -= removedPart;
  16517. }
  16518. }
  16519. return true;
  16520. }
  16521. /**
  16522. * Check if the second provided merged cell is "farther" in the provided direction.
  16523. *
  16524. * @param {MergedCellCoords} mergedCell The merged cell to check.
  16525. * @param {String} direction Drag direction.
  16526. * @return {Boolean|null} `true` if the second provided merged cell is "farther".
  16527. */
  16528. }, {
  16529. key: 'isFarther',
  16530. value: function isFarther(mergedCell, direction) {
  16531. if (!mergedCell) {
  16532. return true;
  16533. }
  16534. if (direction === 'down') {
  16535. return mergedCell.row + mergedCell.rowspan - 1 < this.row + this.rowspan - 1;
  16536. } else if (direction === 'up') {
  16537. return mergedCell.row > this.row;
  16538. } else if (direction === 'right') {
  16539. return mergedCell.col + mergedCell.colspan - 1 < this.col + this.colspan - 1;
  16540. } else if (direction === 'left') {
  16541. return mergedCell.col > this.col;
  16542. }
  16543. return null;
  16544. }
  16545. /**
  16546. * Get the bottom row index of the merged cell.
  16547. *
  16548. * @returns {Number}
  16549. */
  16550. }, {
  16551. key: 'getLastRow',
  16552. value: function getLastRow() {
  16553. return this.row + this.rowspan - 1;
  16554. }
  16555. /**
  16556. * Get the rightmost column index of the merged cell.
  16557. *
  16558. * @returns {Number}
  16559. */
  16560. }, {
  16561. key: 'getLastColumn',
  16562. value: function getLastColumn() {
  16563. return this.col + this.colspan - 1;
  16564. }
  16565. /**
  16566. * Get the range coordinates of the merged cell.
  16567. *
  16568. * @return {CellRange}
  16569. */
  16570. }, {
  16571. key: 'getRange',
  16572. value: function getRange() {
  16573. return new _index.CellRange(new _index.CellCoords(this.row, this.col), new _index.CellCoords(this.row, this.col), new _index.CellCoords(this.getLastRow(), this.getLastColumn()));
  16574. }
  16575. }], [{
  16576. key: 'NEGATIVE_VALUES_WARNING',
  16577. value: function NEGATIVE_VALUES_WARNING(newMergedCell) {
  16578. return (0, _templateLiteralTag.toSingleLine)(_templateObject, newMergedCell.row, newMergedCell.col, newMergedCell.rowspan, newMergedCell.colspan);
  16579. }
  16580. /**
  16581. * Get a warning message for when the declared merged cell data contains values exceeding the table limits.
  16582. *
  16583. * @param {Object} newMergedCell Object containg information about the merged cells that was about to be added.
  16584. * @return {String}
  16585. */
  16586. }, {
  16587. key: 'IS_OUT_OF_BOUNDS_WARNING',
  16588. value: function IS_OUT_OF_BOUNDS_WARNING(newMergedCell) {
  16589. return (0, _templateLiteralTag.toSingleLine)(_templateObject2, newMergedCell.row, newMergedCell.col);
  16590. }
  16591. /**
  16592. * Get a warning message for when the declared merged cell data represents a single cell.
  16593. *
  16594. * @param {Object} newMergedCell Object containg information about the merged cells that was about to be added.
  16595. * @return {String}
  16596. */
  16597. }, {
  16598. key: 'IS_SINGLE_CELL',
  16599. value: function IS_SINGLE_CELL(newMergedCell) {
  16600. return (0, _templateLiteralTag.toSingleLine)(_templateObject3, newMergedCell.row, newMergedCell.col);
  16601. }
  16602. /**
  16603. * Get a warning message for when the declared merged cell data contains "colspan" or "rowspan", that equals 0.
  16604. *
  16605. * @param {Object} newMergedCell Object containg information about the merged cells that was about to be added.
  16606. * @return {String}
  16607. */
  16608. }, {
  16609. key: 'ZERO_SPAN_WARNING',
  16610. value: function ZERO_SPAN_WARNING(newMergedCell) {
  16611. return (0, _templateLiteralTag.toSingleLine)(_templateObject4, newMergedCell.row, newMergedCell.col);
  16612. }
  16613. /**
  16614. * Check whether the values provided for a merged cell contain any negative values.
  16615. *
  16616. * @param {Object} mergedCellInfo Object containing the `row`, `col`, `rowspan` and `colspan` properties.
  16617. * @return {Boolean}
  16618. */
  16619. }, {
  16620. key: 'containsNegativeValues',
  16621. value: function containsNegativeValues(mergedCellInfo) {
  16622. return mergedCellInfo.row < 0 || mergedCellInfo.col < 0 || mergedCellInfo.rowspan < 0 || mergedCellInfo.colspan < 0;
  16623. }
  16624. /**
  16625. * Check whether the provided merged cell information object represents a single cell.
  16626. *
  16627. * @private
  16628. * @param {Object} mergedCellInfo An object with `row`, `col`, `rowspan` and `colspan` properties.
  16629. * @return {Boolean}
  16630. */
  16631. }, {
  16632. key: 'isSingleCell',
  16633. value: function isSingleCell(mergedCellInfo) {
  16634. return mergedCellInfo.colspan === 1 && mergedCellInfo.rowspan === 1;
  16635. }
  16636. /**
  16637. * Check whether the provided merged cell information object contains a rowspan or colspan of 0.
  16638. *
  16639. * @private
  16640. * @param {Object} mergedCellInfo An object with `row`, `col`, `rowspan` and `colspan` properties.
  16641. * @return {Boolean}
  16642. */
  16643. }, {
  16644. key: 'containsZeroSpan',
  16645. value: function containsZeroSpan(mergedCellInfo) {
  16646. return mergedCellInfo.colspan === 0 || mergedCellInfo.rowspan === 0;
  16647. }
  16648. /**
  16649. * Check whether the provided merged cell object is to be declared out of bounds of the table.
  16650. *
  16651. * @param {Object} mergeCell Object containing the `row`, `col`, `rowspan` and `colspan` properties.
  16652. * @param {Number} rowCount Number of rows in the table.
  16653. * @param {Number} columnCount Number of rows in the table.
  16654. * @return {Boolean}
  16655. */
  16656. }, {
  16657. key: 'isOutOfBounds',
  16658. value: function isOutOfBounds(mergeCell, rowCount, columnCount) {
  16659. return mergeCell.row < 0 || mergeCell.col < 0 || mergeCell.row >= rowCount || mergeCell.row + mergeCell.rowspan - 1 >= rowCount || mergeCell.col >= columnCount || mergeCell.col + mergeCell.colspan - 1 >= columnCount;
  16660. }
  16661. }]);
  16662. return MergedCellCoords;
  16663. }();
  16664. exports.default = MergedCellCoords;
  16665. /***/ }),
  16666. /* 96 */
  16667. /***/ (function(module, exports, __webpack_require__) {
  16668. "use strict";
  16669. var strong = __webpack_require__(97);
  16670. var validate = __webpack_require__(46);
  16671. var MAP = 'Map';
  16672. // 23.1 Map Objects
  16673. module.exports = __webpack_require__(66)(MAP, function (get) {
  16674. return function Map() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
  16675. }, {
  16676. // 23.1.3.6 Map.prototype.get(key)
  16677. get: function get(key) {
  16678. var entry = strong.getEntry(validate(this, MAP), key);
  16679. return entry && entry.v;
  16680. },
  16681. // 23.1.3.9 Map.prototype.set(key, value)
  16682. set: function set(key, value) {
  16683. return strong.def(validate(this, MAP), key === 0 ? 0 : key, value);
  16684. }
  16685. }, strong, true);
  16686. /***/ }),
  16687. /* 97 */
  16688. /***/ (function(module, exports, __webpack_require__) {
  16689. "use strict";
  16690. var dP = __webpack_require__(20).f;
  16691. var create = __webpack_require__(74);
  16692. var redefineAll = __webpack_require__(61);
  16693. var ctx = __webpack_require__(32);
  16694. var anInstance = __webpack_require__(63);
  16695. var forOf = __webpack_require__(64);
  16696. var $iterDefine = __webpack_require__(106);
  16697. var step = __webpack_require__(108);
  16698. var setSpecies = __webpack_require__(109);
  16699. var DESCRIPTORS = __webpack_require__(22);
  16700. var fastKey = __webpack_require__(34).fastKey;
  16701. var validate = __webpack_require__(46);
  16702. var SIZE = DESCRIPTORS ? '_s' : 'size';
  16703. var getEntry = function (that, key) {
  16704. // fast case
  16705. var index = fastKey(key);
  16706. var entry;
  16707. if (index !== 'F') return that._i[index];
  16708. // frozen object case
  16709. for (entry = that._f; entry; entry = entry.n) {
  16710. if (entry.k == key) return entry;
  16711. }
  16712. };
  16713. module.exports = {
  16714. getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {
  16715. var C = wrapper(function (that, iterable) {
  16716. anInstance(that, C, NAME, '_i');
  16717. that._t = NAME; // collection type
  16718. that._i = create(null); // index
  16719. that._f = undefined; // first entry
  16720. that._l = undefined; // last entry
  16721. that[SIZE] = 0; // size
  16722. if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
  16723. });
  16724. redefineAll(C.prototype, {
  16725. // 23.1.3.1 Map.prototype.clear()
  16726. // 23.2.3.2 Set.prototype.clear()
  16727. clear: function clear() {
  16728. for (var that = validate(this, NAME), data = that._i, entry = that._f; entry; entry = entry.n) {
  16729. entry.r = true;
  16730. if (entry.p) entry.p = entry.p.n = undefined;
  16731. delete data[entry.i];
  16732. }
  16733. that._f = that._l = undefined;
  16734. that[SIZE] = 0;
  16735. },
  16736. // 23.1.3.3 Map.prototype.delete(key)
  16737. // 23.2.3.4 Set.prototype.delete(value)
  16738. 'delete': function (key) {
  16739. var that = validate(this, NAME);
  16740. var entry = getEntry(that, key);
  16741. if (entry) {
  16742. var next = entry.n;
  16743. var prev = entry.p;
  16744. delete that._i[entry.i];
  16745. entry.r = true;
  16746. if (prev) prev.n = next;
  16747. if (next) next.p = prev;
  16748. if (that._f == entry) that._f = next;
  16749. if (that._l == entry) that._l = prev;
  16750. that[SIZE]--;
  16751. } return !!entry;
  16752. },
  16753. // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
  16754. // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)
  16755. forEach: function forEach(callbackfn /* , that = undefined */) {
  16756. validate(this, NAME);
  16757. var f = ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);
  16758. var entry;
  16759. while (entry = entry ? entry.n : this._f) {
  16760. f(entry.v, entry.k, this);
  16761. // revert to the last existing entry
  16762. while (entry && entry.r) entry = entry.p;
  16763. }
  16764. },
  16765. // 23.1.3.7 Map.prototype.has(key)
  16766. // 23.2.3.7 Set.prototype.has(value)
  16767. has: function has(key) {
  16768. return !!getEntry(validate(this, NAME), key);
  16769. }
  16770. });
  16771. if (DESCRIPTORS) dP(C.prototype, 'size', {
  16772. get: function () {
  16773. return validate(this, NAME)[SIZE];
  16774. }
  16775. });
  16776. return C;
  16777. },
  16778. def: function (that, key, value) {
  16779. var entry = getEntry(that, key);
  16780. var prev, index;
  16781. // change existing entry
  16782. if (entry) {
  16783. entry.v = value;
  16784. // create new entry
  16785. } else {
  16786. that._l = entry = {
  16787. i: index = fastKey(key, true), // <- index
  16788. k: key, // <- key
  16789. v: value, // <- value
  16790. p: prev = that._l, // <- previous entry
  16791. n: undefined, // <- next entry
  16792. r: false // <- removed
  16793. };
  16794. if (!that._f) that._f = entry;
  16795. if (prev) prev.n = entry;
  16796. that[SIZE]++;
  16797. // add to index
  16798. if (index !== 'F') that._i[index] = entry;
  16799. } return that;
  16800. },
  16801. getEntry: getEntry,
  16802. setStrong: function (C, NAME, IS_MAP) {
  16803. // add .keys, .values, .entries, [@@iterator]
  16804. // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11
  16805. $iterDefine(C, NAME, function (iterated, kind) {
  16806. this._t = validate(iterated, NAME); // target
  16807. this._k = kind; // kind
  16808. this._l = undefined; // previous
  16809. }, function () {
  16810. var that = this;
  16811. var kind = that._k;
  16812. var entry = that._l;
  16813. // revert to the last existing entry
  16814. while (entry && entry.r) entry = entry.p;
  16815. // get next entry
  16816. if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) {
  16817. // or finish the iteration
  16818. that._t = undefined;
  16819. return step(1);
  16820. }
  16821. // return step by kind
  16822. if (kind == 'keys') return step(0, entry.k);
  16823. if (kind == 'values') return step(0, entry.v);
  16824. return step(0, [entry.k, entry.v]);
  16825. }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
  16826. // add [@@species], 23.1.2.2, 23.2.2.2
  16827. setSpecies(NAME);
  16828. }
  16829. };
  16830. /***/ }),
  16831. /* 98 */
  16832. /***/ (function(module, exports, __webpack_require__) {
  16833. module.exports = !__webpack_require__(22) && !__webpack_require__(23)(function () {
  16834. return Object.defineProperty(__webpack_require__(72)('div'), 'a', { get: function () { return 7; } }).a != 7;
  16835. });
  16836. /***/ }),
  16837. /* 99 */
  16838. /***/ (function(module, exports, __webpack_require__) {
  16839. var has = __webpack_require__(29);
  16840. var toIObject = __webpack_require__(24);
  16841. var arrayIndexOf = __webpack_require__(100)(false);
  16842. var IE_PROTO = __webpack_require__(76)('IE_PROTO');
  16843. module.exports = function (object, names) {
  16844. var O = toIObject(object);
  16845. var i = 0;
  16846. var result = [];
  16847. var key;
  16848. for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key);
  16849. // Don't enum bug & hidden keys
  16850. while (names.length > i) if (has(O, key = names[i++])) {
  16851. ~arrayIndexOf(result, key) || result.push(key);
  16852. }
  16853. return result;
  16854. };
  16855. /***/ }),
  16856. /* 100 */
  16857. /***/ (function(module, exports, __webpack_require__) {
  16858. // false -> Array#indexOf
  16859. // true -> Array#includes
  16860. var toIObject = __webpack_require__(24);
  16861. var toLength = __webpack_require__(25);
  16862. var toAbsoluteIndex = __webpack_require__(60);
  16863. module.exports = function (IS_INCLUDES) {
  16864. return function ($this, el, fromIndex) {
  16865. var O = toIObject($this);
  16866. var length = toLength(O.length);
  16867. var index = toAbsoluteIndex(fromIndex, length);
  16868. var value;
  16869. // Array#includes uses SameValueZero equality algorithm
  16870. // eslint-disable-next-line no-self-compare
  16871. if (IS_INCLUDES && el != el) while (length > index) {
  16872. value = O[index++];
  16873. // eslint-disable-next-line no-self-compare
  16874. if (value != value) return true;
  16875. // Array#indexOf ignores holes, Array#includes - not
  16876. } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
  16877. if (O[index] === el) return IS_INCLUDES || index || 0;
  16878. } return !IS_INCLUDES && -1;
  16879. };
  16880. };
  16881. /***/ }),
  16882. /* 101 */
  16883. /***/ (function(module, exports, __webpack_require__) {
  16884. var document = __webpack_require__(14).document;
  16885. module.exports = document && document.documentElement;
  16886. /***/ }),
  16887. /* 102 */
  16888. /***/ (function(module, exports, __webpack_require__) {
  16889. // call something on iterator step with safe closing on error
  16890. var anObject = __webpack_require__(18);
  16891. module.exports = function (iterator, fn, value, entries) {
  16892. try {
  16893. return entries ? fn(anObject(value)[0], value[1]) : fn(value);
  16894. // 7.4.6 IteratorClose(iterator, completion)
  16895. } catch (e) {
  16896. var ret = iterator['return'];
  16897. if (ret !== undefined) anObject(ret.call(iterator));
  16898. throw e;
  16899. }
  16900. };
  16901. /***/ }),
  16902. /* 103 */
  16903. /***/ (function(module, exports, __webpack_require__) {
  16904. // check on default Array iterator
  16905. var Iterators = __webpack_require__(51);
  16906. var ITERATOR = __webpack_require__(11)('iterator');
  16907. var ArrayProto = Array.prototype;
  16908. module.exports = function (it) {
  16909. return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
  16910. };
  16911. /***/ }),
  16912. /* 104 */
  16913. /***/ (function(module, exports, __webpack_require__) {
  16914. var classof = __webpack_require__(105);
  16915. var ITERATOR = __webpack_require__(11)('iterator');
  16916. var Iterators = __webpack_require__(51);
  16917. module.exports = __webpack_require__(45).getIteratorMethod = function (it) {
  16918. if (it != undefined) return it[ITERATOR]
  16919. || it['@@iterator']
  16920. || Iterators[classof(it)];
  16921. };
  16922. /***/ }),
  16923. /* 105 */
  16924. /***/ (function(module, exports, __webpack_require__) {
  16925. // getting tag from 19.1.3.6 Object.prototype.toString()
  16926. var cof = __webpack_require__(44);
  16927. var TAG = __webpack_require__(11)('toStringTag');
  16928. // ES3 wrong here
  16929. var ARG = cof(function () { return arguments; }()) == 'Arguments';
  16930. // fallback for IE11 Script Access Denied error
  16931. var tryGet = function (it, key) {
  16932. try {
  16933. return it[key];
  16934. } catch (e) { /* empty */ }
  16935. };
  16936. module.exports = function (it) {
  16937. var O, T, B;
  16938. return it === undefined ? 'Undefined' : it === null ? 'Null'
  16939. // @@toStringTag case
  16940. : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
  16941. // builtinTag case
  16942. : ARG ? cof(O)
  16943. // ES3 arguments fallback
  16944. : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
  16945. };
  16946. /***/ }),
  16947. /* 106 */
  16948. /***/ (function(module, exports, __webpack_require__) {
  16949. "use strict";
  16950. var LIBRARY = __webpack_require__(65);
  16951. var $export = __webpack_require__(3);
  16952. var redefine = __webpack_require__(30);
  16953. var hide = __webpack_require__(31);
  16954. var Iterators = __webpack_require__(51);
  16955. var $iterCreate = __webpack_require__(328);
  16956. var setToStringTag = __webpack_require__(52);
  16957. var getPrototypeOf = __webpack_require__(107);
  16958. var ITERATOR = __webpack_require__(11)('iterator');
  16959. var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
  16960. var FF_ITERATOR = '@@iterator';
  16961. var KEYS = 'keys';
  16962. var VALUES = 'values';
  16963. var returnThis = function () { return this; };
  16964. module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
  16965. $iterCreate(Constructor, NAME, next);
  16966. var getMethod = function (kind) {
  16967. if (!BUGGY && kind in proto) return proto[kind];
  16968. switch (kind) {
  16969. case KEYS: return function keys() { return new Constructor(this, kind); };
  16970. case VALUES: return function values() { return new Constructor(this, kind); };
  16971. } return function entries() { return new Constructor(this, kind); };
  16972. };
  16973. var TAG = NAME + ' Iterator';
  16974. var DEF_VALUES = DEFAULT == VALUES;
  16975. var VALUES_BUG = false;
  16976. var proto = Base.prototype;
  16977. var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
  16978. var $default = $native || getMethod(DEFAULT);
  16979. var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
  16980. var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
  16981. var methods, key, IteratorPrototype;
  16982. // Fix native
  16983. if ($anyNative) {
  16984. IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
  16985. if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
  16986. // Set @@toStringTag to native iterators
  16987. setToStringTag(IteratorPrototype, TAG, true);
  16988. // fix for some old engines
  16989. if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis);
  16990. }
  16991. }
  16992. // fix Array#{values, @@iterator}.name in V8 / FF
  16993. if (DEF_VALUES && $native && $native.name !== VALUES) {
  16994. VALUES_BUG = true;
  16995. $default = function values() { return $native.call(this); };
  16996. }
  16997. // Define iterator
  16998. if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
  16999. hide(proto, ITERATOR, $default);
  17000. }
  17001. // Plug for library
  17002. Iterators[NAME] = $default;
  17003. Iterators[TAG] = returnThis;
  17004. if (DEFAULT) {
  17005. methods = {
  17006. values: DEF_VALUES ? $default : getMethod(VALUES),
  17007. keys: IS_SET ? $default : getMethod(KEYS),
  17008. entries: $entries
  17009. };
  17010. if (FORCED) for (key in methods) {
  17011. if (!(key in proto)) redefine(proto, key, methods[key]);
  17012. } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
  17013. }
  17014. return methods;
  17015. };
  17016. /***/ }),
  17017. /* 107 */
  17018. /***/ (function(module, exports, __webpack_require__) {
  17019. // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
  17020. var has = __webpack_require__(29);
  17021. var toObject = __webpack_require__(33);
  17022. var IE_PROTO = __webpack_require__(76)('IE_PROTO');
  17023. var ObjectProto = Object.prototype;
  17024. module.exports = Object.getPrototypeOf || function (O) {
  17025. O = toObject(O);
  17026. if (has(O, IE_PROTO)) return O[IE_PROTO];
  17027. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  17028. return O.constructor.prototype;
  17029. } return O instanceof Object ? ObjectProto : null;
  17030. };
  17031. /***/ }),
  17032. /* 108 */
  17033. /***/ (function(module, exports) {
  17034. module.exports = function (done, value) {
  17035. return { value: value, done: !!done };
  17036. };
  17037. /***/ }),
  17038. /* 109 */
  17039. /***/ (function(module, exports, __webpack_require__) {
  17040. "use strict";
  17041. var global = __webpack_require__(14);
  17042. var dP = __webpack_require__(20);
  17043. var DESCRIPTORS = __webpack_require__(22);
  17044. var SPECIES = __webpack_require__(11)('species');
  17045. module.exports = function (KEY) {
  17046. var C = global[KEY];
  17047. if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, {
  17048. configurable: true,
  17049. get: function () { return this; }
  17050. });
  17051. };
  17052. /***/ }),
  17053. /* 110 */
  17054. /***/ (function(module, exports, __webpack_require__) {
  17055. // Works with __proto__ only. Old v8 can't work with null proto objects.
  17056. /* eslint-disable no-proto */
  17057. var isObject = __webpack_require__(9);
  17058. var anObject = __webpack_require__(18);
  17059. var check = function (O, proto) {
  17060. anObject(O);
  17061. if (!isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!");
  17062. };
  17063. module.exports = {
  17064. set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line
  17065. function (test, buggy, set) {
  17066. try {
  17067. set = __webpack_require__(32)(Function.call, __webpack_require__(67).f(Object.prototype, '__proto__').set, 2);
  17068. set(test, []);
  17069. buggy = !(test instanceof Array);
  17070. } catch (e) { buggy = true; }
  17071. return function setPrototypeOf(O, proto) {
  17072. check(O, proto);
  17073. if (buggy) O.__proto__ = proto;
  17074. else set(O, proto);
  17075. return O;
  17076. };
  17077. }({}, false) : undefined),
  17078. check: check
  17079. };
  17080. /***/ }),
  17081. /* 111 */
  17082. /***/ (function(module, exports, __webpack_require__) {
  17083. "use strict";
  17084. var strong = __webpack_require__(97);
  17085. var validate = __webpack_require__(46);
  17086. var SET = 'Set';
  17087. // 23.2 Set Objects
  17088. module.exports = __webpack_require__(66)(SET, function (get) {
  17089. return function Set() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
  17090. }, {
  17091. // 23.2.3.1 Set.prototype.add(value)
  17092. add: function add(value) {
  17093. return strong.def(validate(this, SET), value = value === 0 ? 0 : value, value);
  17094. }
  17095. }, strong);
  17096. /***/ }),
  17097. /* 112 */
  17098. /***/ (function(module, exports, __webpack_require__) {
  17099. "use strict";
  17100. var each = __webpack_require__(68)(0);
  17101. var redefine = __webpack_require__(30);
  17102. var meta = __webpack_require__(34);
  17103. var assign = __webpack_require__(114);
  17104. var weak = __webpack_require__(115);
  17105. var isObject = __webpack_require__(9);
  17106. var fails = __webpack_require__(23);
  17107. var validate = __webpack_require__(46);
  17108. var WEAK_MAP = 'WeakMap';
  17109. var getWeak = meta.getWeak;
  17110. var isExtensible = Object.isExtensible;
  17111. var uncaughtFrozenStore = weak.ufstore;
  17112. var tmp = {};
  17113. var InternalMap;
  17114. var wrapper = function (get) {
  17115. return function WeakMap() {
  17116. return get(this, arguments.length > 0 ? arguments[0] : undefined);
  17117. };
  17118. };
  17119. var methods = {
  17120. // 23.3.3.3 WeakMap.prototype.get(key)
  17121. get: function get(key) {
  17122. if (isObject(key)) {
  17123. var data = getWeak(key);
  17124. if (data === true) return uncaughtFrozenStore(validate(this, WEAK_MAP)).get(key);
  17125. return data ? data[this._i] : undefined;
  17126. }
  17127. },
  17128. // 23.3.3.5 WeakMap.prototype.set(key, value)
  17129. set: function set(key, value) {
  17130. return weak.def(validate(this, WEAK_MAP), key, value);
  17131. }
  17132. };
  17133. // 23.3 WeakMap Objects
  17134. var $WeakMap = module.exports = __webpack_require__(66)(WEAK_MAP, wrapper, methods, weak, true, true);
  17135. // IE11 WeakMap frozen keys fix
  17136. if (fails(function () { return new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7; })) {
  17137. InternalMap = weak.getConstructor(wrapper, WEAK_MAP);
  17138. assign(InternalMap.prototype, methods);
  17139. meta.NEED = true;
  17140. each(['delete', 'has', 'get', 'set'], function (key) {
  17141. var proto = $WeakMap.prototype;
  17142. var method = proto[key];
  17143. redefine(proto, key, function (a, b) {
  17144. // store frozen objects on internal weakmap shim
  17145. if (isObject(a) && !isExtensible(a)) {
  17146. if (!this._f) this._f = new InternalMap();
  17147. var result = this._f[key](a, b);
  17148. return key == 'set' ? this : result;
  17149. // store all the rest on native weakmap
  17150. } return method.call(this, a, b);
  17151. });
  17152. });
  17153. }
  17154. /***/ }),
  17155. /* 113 */
  17156. /***/ (function(module, exports, __webpack_require__) {
  17157. // 7.2.2 IsArray(argument)
  17158. var cof = __webpack_require__(44);
  17159. module.exports = Array.isArray || function isArray(arg) {
  17160. return cof(arg) == 'Array';
  17161. };
  17162. /***/ }),
  17163. /* 114 */
  17164. /***/ (function(module, exports, __webpack_require__) {
  17165. "use strict";
  17166. // 19.1.2.1 Object.assign(target, source, ...)
  17167. var getKeys = __webpack_require__(37);
  17168. var gOPS = __webpack_require__(69);
  17169. var pIE = __webpack_require__(53);
  17170. var toObject = __webpack_require__(33);
  17171. var IObject = __webpack_require__(75);
  17172. var $assign = Object.assign;
  17173. // should work with symbols and should have deterministic property order (V8 bug)
  17174. module.exports = !$assign || __webpack_require__(23)(function () {
  17175. var A = {};
  17176. var B = {};
  17177. // eslint-disable-next-line no-undef
  17178. var S = Symbol();
  17179. var K = 'abcdefghijklmnopqrst';
  17180. A[S] = 7;
  17181. K.split('').forEach(function (k) { B[k] = k; });
  17182. return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
  17183. }) ? function assign(target, source) { // eslint-disable-line no-unused-vars
  17184. var T = toObject(target);
  17185. var aLen = arguments.length;
  17186. var index = 1;
  17187. var getSymbols = gOPS.f;
  17188. var isEnum = pIE.f;
  17189. while (aLen > index) {
  17190. var S = IObject(arguments[index++]);
  17191. var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);
  17192. var length = keys.length;
  17193. var j = 0;
  17194. var key;
  17195. while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
  17196. } return T;
  17197. } : $assign;
  17198. /***/ }),
  17199. /* 115 */
  17200. /***/ (function(module, exports, __webpack_require__) {
  17201. "use strict";
  17202. var redefineAll = __webpack_require__(61);
  17203. var getWeak = __webpack_require__(34).getWeak;
  17204. var anObject = __webpack_require__(18);
  17205. var isObject = __webpack_require__(9);
  17206. var anInstance = __webpack_require__(63);
  17207. var forOf = __webpack_require__(64);
  17208. var createArrayMethod = __webpack_require__(68);
  17209. var $has = __webpack_require__(29);
  17210. var validate = __webpack_require__(46);
  17211. var arrayFind = createArrayMethod(5);
  17212. var arrayFindIndex = createArrayMethod(6);
  17213. var id = 0;
  17214. // fallback for uncaught frozen keys
  17215. var uncaughtFrozenStore = function (that) {
  17216. return that._l || (that._l = new UncaughtFrozenStore());
  17217. };
  17218. var UncaughtFrozenStore = function () {
  17219. this.a = [];
  17220. };
  17221. var findUncaughtFrozen = function (store, key) {
  17222. return arrayFind(store.a, function (it) {
  17223. return it[0] === key;
  17224. });
  17225. };
  17226. UncaughtFrozenStore.prototype = {
  17227. get: function (key) {
  17228. var entry = findUncaughtFrozen(this, key);
  17229. if (entry) return entry[1];
  17230. },
  17231. has: function (key) {
  17232. return !!findUncaughtFrozen(this, key);
  17233. },
  17234. set: function (key, value) {
  17235. var entry = findUncaughtFrozen(this, key);
  17236. if (entry) entry[1] = value;
  17237. else this.a.push([key, value]);
  17238. },
  17239. 'delete': function (key) {
  17240. var index = arrayFindIndex(this.a, function (it) {
  17241. return it[0] === key;
  17242. });
  17243. if (~index) this.a.splice(index, 1);
  17244. return !!~index;
  17245. }
  17246. };
  17247. module.exports = {
  17248. getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {
  17249. var C = wrapper(function (that, iterable) {
  17250. anInstance(that, C, NAME, '_i');
  17251. that._t = NAME; // collection type
  17252. that._i = id++; // collection id
  17253. that._l = undefined; // leak store for uncaught frozen objects
  17254. if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
  17255. });
  17256. redefineAll(C.prototype, {
  17257. // 23.3.3.2 WeakMap.prototype.delete(key)
  17258. // 23.4.3.3 WeakSet.prototype.delete(value)
  17259. 'delete': function (key) {
  17260. if (!isObject(key)) return false;
  17261. var data = getWeak(key);
  17262. if (data === true) return uncaughtFrozenStore(validate(this, NAME))['delete'](key);
  17263. return data && $has(data, this._i) && delete data[this._i];
  17264. },
  17265. // 23.3.3.4 WeakMap.prototype.has(key)
  17266. // 23.4.3.4 WeakSet.prototype.has(value)
  17267. has: function has(key) {
  17268. if (!isObject(key)) return false;
  17269. var data = getWeak(key);
  17270. if (data === true) return uncaughtFrozenStore(validate(this, NAME)).has(key);
  17271. return data && $has(data, this._i);
  17272. }
  17273. });
  17274. return C;
  17275. },
  17276. def: function (that, key, value) {
  17277. var data = getWeak(anObject(key), true);
  17278. if (data === true) uncaughtFrozenStore(that).set(key, value);
  17279. else data[that._i] = value;
  17280. return that;
  17281. },
  17282. ufstore: uncaughtFrozenStore
  17283. };
  17284. /***/ }),
  17285. /* 116 */
  17286. /***/ (function(module, exports, __webpack_require__) {
  17287. "use strict";
  17288. var weak = __webpack_require__(115);
  17289. var validate = __webpack_require__(46);
  17290. var WEAK_SET = 'WeakSet';
  17291. // 23.4 WeakSet Objects
  17292. __webpack_require__(66)(WEAK_SET, function (get) {
  17293. return function WeakSet() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
  17294. }, {
  17295. // 23.4.3.1 WeakSet.prototype.add(value)
  17296. add: function add(value) {
  17297. return weak.def(validate(this, WEAK_SET), value, true);
  17298. }
  17299. }, weak, false, true);
  17300. /***/ }),
  17301. /* 117 */
  17302. /***/ (function(module, exports, __webpack_require__) {
  17303. "use strict";
  17304. var LIBRARY = __webpack_require__(65);
  17305. var global = __webpack_require__(14);
  17306. var ctx = __webpack_require__(32);
  17307. var classof = __webpack_require__(105);
  17308. var $export = __webpack_require__(3);
  17309. var isObject = __webpack_require__(9);
  17310. var aFunction = __webpack_require__(62);
  17311. var anInstance = __webpack_require__(63);
  17312. var forOf = __webpack_require__(64);
  17313. var speciesConstructor = __webpack_require__(332);
  17314. var task = __webpack_require__(80).set;
  17315. var microtask = __webpack_require__(334)();
  17316. var newPromiseCapabilityModule = __webpack_require__(118);
  17317. var perform = __webpack_require__(335);
  17318. var promiseResolve = __webpack_require__(336);
  17319. var PROMISE = 'Promise';
  17320. var TypeError = global.TypeError;
  17321. var process = global.process;
  17322. var $Promise = global[PROMISE];
  17323. var isNode = classof(process) == 'process';
  17324. var empty = function () { /* empty */ };
  17325. var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;
  17326. var newPromiseCapability = newGenericPromiseCapability = newPromiseCapabilityModule.f;
  17327. var USE_NATIVE = !!function () {
  17328. try {
  17329. // correct subclassing with @@species support
  17330. var promise = $Promise.resolve(1);
  17331. var FakePromise = (promise.constructor = {})[__webpack_require__(11)('species')] = function (exec) {
  17332. exec(empty, empty);
  17333. };
  17334. // unhandled rejections tracking support, NodeJS Promise without it fails @@species test
  17335. return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise;
  17336. } catch (e) { /* empty */ }
  17337. }();
  17338. // helpers
  17339. var isThenable = function (it) {
  17340. var then;
  17341. return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
  17342. };
  17343. var notify = function (promise, isReject) {
  17344. if (promise._n) return;
  17345. promise._n = true;
  17346. var chain = promise._c;
  17347. microtask(function () {
  17348. var value = promise._v;
  17349. var ok = promise._s == 1;
  17350. var i = 0;
  17351. var run = function (reaction) {
  17352. var handler = ok ? reaction.ok : reaction.fail;
  17353. var resolve = reaction.resolve;
  17354. var reject = reaction.reject;
  17355. var domain = reaction.domain;
  17356. var result, then, exited;
  17357. try {
  17358. if (handler) {
  17359. if (!ok) {
  17360. if (promise._h == 2) onHandleUnhandled(promise);
  17361. promise._h = 1;
  17362. }
  17363. if (handler === true) result = value;
  17364. else {
  17365. if (domain) domain.enter();
  17366. result = handler(value); // may throw
  17367. if (domain) {
  17368. domain.exit();
  17369. exited = true;
  17370. }
  17371. }
  17372. if (result === reaction.promise) {
  17373. reject(TypeError('Promise-chain cycle'));
  17374. } else if (then = isThenable(result)) {
  17375. then.call(result, resolve, reject);
  17376. } else resolve(result);
  17377. } else reject(value);
  17378. } catch (e) {
  17379. if (domain && !exited) domain.exit();
  17380. reject(e);
  17381. }
  17382. };
  17383. while (chain.length > i) run(chain[i++]); // variable length - can't use forEach
  17384. promise._c = [];
  17385. promise._n = false;
  17386. if (isReject && !promise._h) onUnhandled(promise);
  17387. });
  17388. };
  17389. var onUnhandled = function (promise) {
  17390. task.call(global, function () {
  17391. var value = promise._v;
  17392. var unhandled = isUnhandled(promise);
  17393. var result, handler, console;
  17394. if (unhandled) {
  17395. result = perform(function () {
  17396. if (isNode) {
  17397. process.emit('unhandledRejection', value, promise);
  17398. } else if (handler = global.onunhandledrejection) {
  17399. handler({ promise: promise, reason: value });
  17400. } else if ((console = global.console) && console.error) {
  17401. console.error('Unhandled promise rejection', value);
  17402. }
  17403. });
  17404. // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
  17405. promise._h = isNode || isUnhandled(promise) ? 2 : 1;
  17406. } promise._a = undefined;
  17407. if (unhandled && result.e) throw result.v;
  17408. });
  17409. };
  17410. var isUnhandled = function (promise) {
  17411. return promise._h !== 1 && (promise._a || promise._c).length === 0;
  17412. };
  17413. var onHandleUnhandled = function (promise) {
  17414. task.call(global, function () {
  17415. var handler;
  17416. if (isNode) {
  17417. process.emit('rejectionHandled', promise);
  17418. } else if (handler = global.onrejectionhandled) {
  17419. handler({ promise: promise, reason: promise._v });
  17420. }
  17421. });
  17422. };
  17423. var $reject = function (value) {
  17424. var promise = this;
  17425. if (promise._d) return;
  17426. promise._d = true;
  17427. promise = promise._w || promise; // unwrap
  17428. promise._v = value;
  17429. promise._s = 2;
  17430. if (!promise._a) promise._a = promise._c.slice();
  17431. notify(promise, true);
  17432. };
  17433. var $resolve = function (value) {
  17434. var promise = this;
  17435. var then;
  17436. if (promise._d) return;
  17437. promise._d = true;
  17438. promise = promise._w || promise; // unwrap
  17439. try {
  17440. if (promise === value) throw TypeError("Promise can't be resolved itself");
  17441. if (then = isThenable(value)) {
  17442. microtask(function () {
  17443. var wrapper = { _w: promise, _d: false }; // wrap
  17444. try {
  17445. then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
  17446. } catch (e) {
  17447. $reject.call(wrapper, e);
  17448. }
  17449. });
  17450. } else {
  17451. promise._v = value;
  17452. promise._s = 1;
  17453. notify(promise, false);
  17454. }
  17455. } catch (e) {
  17456. $reject.call({ _w: promise, _d: false }, e); // wrap
  17457. }
  17458. };
  17459. // constructor polyfill
  17460. if (!USE_NATIVE) {
  17461. // 25.4.3.1 Promise(executor)
  17462. $Promise = function Promise(executor) {
  17463. anInstance(this, $Promise, PROMISE, '_h');
  17464. aFunction(executor);
  17465. Internal.call(this);
  17466. try {
  17467. executor(ctx($resolve, this, 1), ctx($reject, this, 1));
  17468. } catch (err) {
  17469. $reject.call(this, err);
  17470. }
  17471. };
  17472. // eslint-disable-next-line no-unused-vars
  17473. Internal = function Promise(executor) {
  17474. this._c = []; // <- awaiting reactions
  17475. this._a = undefined; // <- checked in isUnhandled reactions
  17476. this._s = 0; // <- state
  17477. this._d = false; // <- done
  17478. this._v = undefined; // <- value
  17479. this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled
  17480. this._n = false; // <- notify
  17481. };
  17482. Internal.prototype = __webpack_require__(61)($Promise.prototype, {
  17483. // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
  17484. then: function then(onFulfilled, onRejected) {
  17485. var reaction = newPromiseCapability(speciesConstructor(this, $Promise));
  17486. reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
  17487. reaction.fail = typeof onRejected == 'function' && onRejected;
  17488. reaction.domain = isNode ? process.domain : undefined;
  17489. this._c.push(reaction);
  17490. if (this._a) this._a.push(reaction);
  17491. if (this._s) notify(this, false);
  17492. return reaction.promise;
  17493. },
  17494. // 25.4.5.1 Promise.prototype.catch(onRejected)
  17495. 'catch': function (onRejected) {
  17496. return this.then(undefined, onRejected);
  17497. }
  17498. });
  17499. OwnPromiseCapability = function () {
  17500. var promise = new Internal();
  17501. this.promise = promise;
  17502. this.resolve = ctx($resolve, promise, 1);
  17503. this.reject = ctx($reject, promise, 1);
  17504. };
  17505. newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
  17506. return C === $Promise || C === Wrapper
  17507. ? new OwnPromiseCapability(C)
  17508. : newGenericPromiseCapability(C);
  17509. };
  17510. }
  17511. $export($export.G + $export.W + $export.F * !USE_NATIVE, { Promise: $Promise });
  17512. __webpack_require__(52)($Promise, PROMISE);
  17513. __webpack_require__(109)(PROMISE);
  17514. Wrapper = __webpack_require__(45)[PROMISE];
  17515. // statics
  17516. $export($export.S + $export.F * !USE_NATIVE, PROMISE, {
  17517. // 25.4.4.5 Promise.reject(r)
  17518. reject: function reject(r) {
  17519. var capability = newPromiseCapability(this);
  17520. var $$reject = capability.reject;
  17521. $$reject(r);
  17522. return capability.promise;
  17523. }
  17524. });
  17525. $export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {
  17526. // 25.4.4.6 Promise.resolve(x)
  17527. resolve: function resolve(x) {
  17528. return promiseResolve(LIBRARY && this === Wrapper ? $Promise : this, x);
  17529. }
  17530. });
  17531. $export($export.S + $export.F * !(USE_NATIVE && __webpack_require__(79)(function (iter) {
  17532. $Promise.all(iter)['catch'](empty);
  17533. })), PROMISE, {
  17534. // 25.4.4.1 Promise.all(iterable)
  17535. all: function all(iterable) {
  17536. var C = this;
  17537. var capability = newPromiseCapability(C);
  17538. var resolve = capability.resolve;
  17539. var reject = capability.reject;
  17540. var result = perform(function () {
  17541. var values = [];
  17542. var index = 0;
  17543. var remaining = 1;
  17544. forOf(iterable, false, function (promise) {
  17545. var $index = index++;
  17546. var alreadyCalled = false;
  17547. values.push(undefined);
  17548. remaining++;
  17549. C.resolve(promise).then(function (value) {
  17550. if (alreadyCalled) return;
  17551. alreadyCalled = true;
  17552. values[$index] = value;
  17553. --remaining || resolve(values);
  17554. }, reject);
  17555. });
  17556. --remaining || resolve(values);
  17557. });
  17558. if (result.e) reject(result.v);
  17559. return capability.promise;
  17560. },
  17561. // 25.4.4.4 Promise.race(iterable)
  17562. race: function race(iterable) {
  17563. var C = this;
  17564. var capability = newPromiseCapability(C);
  17565. var reject = capability.reject;
  17566. var result = perform(function () {
  17567. forOf(iterable, false, function (promise) {
  17568. C.resolve(promise).then(capability.resolve, reject);
  17569. });
  17570. });
  17571. if (result.e) reject(result.v);
  17572. return capability.promise;
  17573. }
  17574. });
  17575. /***/ }),
  17576. /* 118 */
  17577. /***/ (function(module, exports, __webpack_require__) {
  17578. "use strict";
  17579. // 25.4.1.5 NewPromiseCapability(C)
  17580. var aFunction = __webpack_require__(62);
  17581. function PromiseCapability(C) {
  17582. var resolve, reject;
  17583. this.promise = new C(function ($$resolve, $$reject) {
  17584. if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
  17585. resolve = $$resolve;
  17586. reject = $$reject;
  17587. });
  17588. this.resolve = aFunction(resolve);
  17589. this.reject = aFunction(reject);
  17590. }
  17591. module.exports.f = function (C) {
  17592. return new PromiseCapability(C);
  17593. };
  17594. /***/ }),
  17595. /* 119 */
  17596. /***/ (function(module, exports, __webpack_require__) {
  17597. "use strict";
  17598. // ECMAScript 6 symbols shim
  17599. var global = __webpack_require__(14);
  17600. var has = __webpack_require__(29);
  17601. var DESCRIPTORS = __webpack_require__(22);
  17602. var $export = __webpack_require__(3);
  17603. var redefine = __webpack_require__(30);
  17604. var META = __webpack_require__(34).KEY;
  17605. var $fails = __webpack_require__(23);
  17606. var shared = __webpack_require__(77);
  17607. var setToStringTag = __webpack_require__(52);
  17608. var uid = __webpack_require__(49);
  17609. var wks = __webpack_require__(11);
  17610. var wksExt = __webpack_require__(120);
  17611. var wksDefine = __webpack_require__(337);
  17612. var enumKeys = __webpack_require__(338);
  17613. var isArray = __webpack_require__(113);
  17614. var anObject = __webpack_require__(18);
  17615. var isObject = __webpack_require__(9);
  17616. var toIObject = __webpack_require__(24);
  17617. var toPrimitive = __webpack_require__(73);
  17618. var createDesc = __webpack_require__(50);
  17619. var _create = __webpack_require__(74);
  17620. var gOPNExt = __webpack_require__(121);
  17621. var $GOPD = __webpack_require__(67);
  17622. var $DP = __webpack_require__(20);
  17623. var $keys = __webpack_require__(37);
  17624. var gOPD = $GOPD.f;
  17625. var dP = $DP.f;
  17626. var gOPN = gOPNExt.f;
  17627. var $Symbol = global.Symbol;
  17628. var $JSON = global.JSON;
  17629. var _stringify = $JSON && $JSON.stringify;
  17630. var PROTOTYPE = 'prototype';
  17631. var HIDDEN = wks('_hidden');
  17632. var TO_PRIMITIVE = wks('toPrimitive');
  17633. var isEnum = {}.propertyIsEnumerable;
  17634. var SymbolRegistry = shared('symbol-registry');
  17635. var AllSymbols = shared('symbols');
  17636. var OPSymbols = shared('op-symbols');
  17637. var ObjectProto = Object[PROTOTYPE];
  17638. var USE_NATIVE = typeof $Symbol == 'function';
  17639. var QObject = global.QObject;
  17640. // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
  17641. var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
  17642. // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
  17643. var setSymbolDesc = DESCRIPTORS && $fails(function () {
  17644. return _create(dP({}, 'a', {
  17645. get: function () { return dP(this, 'a', { value: 7 }).a; }
  17646. })).a != 7;
  17647. }) ? function (it, key, D) {
  17648. var protoDesc = gOPD(ObjectProto, key);
  17649. if (protoDesc) delete ObjectProto[key];
  17650. dP(it, key, D);
  17651. if (protoDesc && it !== ObjectProto) dP(ObjectProto, key, protoDesc);
  17652. } : dP;
  17653. var wrap = function (tag) {
  17654. var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
  17655. sym._k = tag;
  17656. return sym;
  17657. };
  17658. var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function (it) {
  17659. return typeof it == 'symbol';
  17660. } : function (it) {
  17661. return it instanceof $Symbol;
  17662. };
  17663. var $defineProperty = function defineProperty(it, key, D) {
  17664. if (it === ObjectProto) $defineProperty(OPSymbols, key, D);
  17665. anObject(it);
  17666. key = toPrimitive(key, true);
  17667. anObject(D);
  17668. if (has(AllSymbols, key)) {
  17669. if (!D.enumerable) {
  17670. if (!has(it, HIDDEN)) dP(it, HIDDEN, createDesc(1, {}));
  17671. it[HIDDEN][key] = true;
  17672. } else {
  17673. if (has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false;
  17674. D = _create(D, { enumerable: createDesc(0, false) });
  17675. } return setSymbolDesc(it, key, D);
  17676. } return dP(it, key, D);
  17677. };
  17678. var $defineProperties = function defineProperties(it, P) {
  17679. anObject(it);
  17680. var keys = enumKeys(P = toIObject(P));
  17681. var i = 0;
  17682. var l = keys.length;
  17683. var key;
  17684. while (l > i) $defineProperty(it, key = keys[i++], P[key]);
  17685. return it;
  17686. };
  17687. var $create = function create(it, P) {
  17688. return P === undefined ? _create(it) : $defineProperties(_create(it), P);
  17689. };
  17690. var $propertyIsEnumerable = function propertyIsEnumerable(key) {
  17691. var E = isEnum.call(this, key = toPrimitive(key, true));
  17692. if (this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return false;
  17693. return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
  17694. };
  17695. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {
  17696. it = toIObject(it);
  17697. key = toPrimitive(key, true);
  17698. if (it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return;
  17699. var D = gOPD(it, key);
  17700. if (D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true;
  17701. return D;
  17702. };
  17703. var $getOwnPropertyNames = function getOwnPropertyNames(it) {
  17704. var names = gOPN(toIObject(it));
  17705. var result = [];
  17706. var i = 0;
  17707. var key;
  17708. while (names.length > i) {
  17709. if (!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key);
  17710. } return result;
  17711. };
  17712. var $getOwnPropertySymbols = function getOwnPropertySymbols(it) {
  17713. var IS_OP = it === ObjectProto;
  17714. var names = gOPN(IS_OP ? OPSymbols : toIObject(it));
  17715. var result = [];
  17716. var i = 0;
  17717. var key;
  17718. while (names.length > i) {
  17719. if (has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true)) result.push(AllSymbols[key]);
  17720. } return result;
  17721. };
  17722. // 19.4.1.1 Symbol([description])
  17723. if (!USE_NATIVE) {
  17724. $Symbol = function Symbol() {
  17725. if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!');
  17726. var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
  17727. var $set = function (value) {
  17728. if (this === ObjectProto) $set.call(OPSymbols, value);
  17729. if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
  17730. setSymbolDesc(this, tag, createDesc(1, value));
  17731. };
  17732. if (DESCRIPTORS && setter) setSymbolDesc(ObjectProto, tag, { configurable: true, set: $set });
  17733. return wrap(tag);
  17734. };
  17735. redefine($Symbol[PROTOTYPE], 'toString', function toString() {
  17736. return this._k;
  17737. });
  17738. $GOPD.f = $getOwnPropertyDescriptor;
  17739. $DP.f = $defineProperty;
  17740. __webpack_require__(81).f = gOPNExt.f = $getOwnPropertyNames;
  17741. __webpack_require__(53).f = $propertyIsEnumerable;
  17742. __webpack_require__(69).f = $getOwnPropertySymbols;
  17743. if (DESCRIPTORS && !__webpack_require__(65)) {
  17744. redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
  17745. }
  17746. wksExt.f = function (name) {
  17747. return wrap(wks(name));
  17748. };
  17749. }
  17750. $export($export.G + $export.W + $export.F * !USE_NATIVE, { Symbol: $Symbol });
  17751. for (var es6Symbols = (
  17752. // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14
  17753. 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'
  17754. ).split(','), j = 0; es6Symbols.length > j;)wks(es6Symbols[j++]);
  17755. for (var wellKnownSymbols = $keys(wks.store), k = 0; wellKnownSymbols.length > k;) wksDefine(wellKnownSymbols[k++]);
  17756. $export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
  17757. // 19.4.2.1 Symbol.for(key)
  17758. 'for': function (key) {
  17759. return has(SymbolRegistry, key += '')
  17760. ? SymbolRegistry[key]
  17761. : SymbolRegistry[key] = $Symbol(key);
  17762. },
  17763. // 19.4.2.5 Symbol.keyFor(sym)
  17764. keyFor: function keyFor(sym) {
  17765. if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!');
  17766. for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key;
  17767. },
  17768. useSetter: function () { setter = true; },
  17769. useSimple: function () { setter = false; }
  17770. });
  17771. $export($export.S + $export.F * !USE_NATIVE, 'Object', {
  17772. // 19.1.2.2 Object.create(O [, Properties])
  17773. create: $create,
  17774. // 19.1.2.4 Object.defineProperty(O, P, Attributes)
  17775. defineProperty: $defineProperty,
  17776. // 19.1.2.3 Object.defineProperties(O, Properties)
  17777. defineProperties: $defineProperties,
  17778. // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
  17779. getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
  17780. // 19.1.2.7 Object.getOwnPropertyNames(O)
  17781. getOwnPropertyNames: $getOwnPropertyNames,
  17782. // 19.1.2.8 Object.getOwnPropertySymbols(O)
  17783. getOwnPropertySymbols: $getOwnPropertySymbols
  17784. });
  17785. // 24.3.2 JSON.stringify(value [, replacer [, space]])
  17786. $JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function () {
  17787. var S = $Symbol();
  17788. // MS Edge converts symbol values to JSON as {}
  17789. // WebKit converts symbol values to JSON as null
  17790. // V8 throws on boxed symbols
  17791. return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}';
  17792. })), 'JSON', {
  17793. stringify: function stringify(it) {
  17794. var args = [it];
  17795. var i = 1;
  17796. var replacer, $replacer;
  17797. while (arguments.length > i) args.push(arguments[i++]);
  17798. $replacer = replacer = args[1];
  17799. if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
  17800. if (!isArray(replacer)) replacer = function (key, value) {
  17801. if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
  17802. if (!isSymbol(value)) return value;
  17803. };
  17804. args[1] = replacer;
  17805. return _stringify.apply($JSON, args);
  17806. }
  17807. });
  17808. // 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)
  17809. $Symbol[PROTOTYPE][TO_PRIMITIVE] || __webpack_require__(31)($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
  17810. // 19.4.3.5 Symbol.prototype[@@toStringTag]
  17811. setToStringTag($Symbol, 'Symbol');
  17812. // 20.2.1.9 Math[@@toStringTag]
  17813. setToStringTag(Math, 'Math', true);
  17814. // 24.3.3 JSON[@@toStringTag]
  17815. setToStringTag(global.JSON, 'JSON', true);
  17816. /***/ }),
  17817. /* 120 */
  17818. /***/ (function(module, exports, __webpack_require__) {
  17819. exports.f = __webpack_require__(11);
  17820. /***/ }),
  17821. /* 121 */
  17822. /***/ (function(module, exports, __webpack_require__) {
  17823. // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
  17824. var toIObject = __webpack_require__(24);
  17825. var gOPN = __webpack_require__(81).f;
  17826. var toString = {}.toString;
  17827. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
  17828. ? Object.getOwnPropertyNames(window) : [];
  17829. var getWindowNames = function (it) {
  17830. try {
  17831. return gOPN(it);
  17832. } catch (e) {
  17833. return windowNames.slice();
  17834. }
  17835. };
  17836. module.exports.f = function getOwnPropertyNames(it) {
  17837. return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));
  17838. };
  17839. /***/ }),
  17840. /* 122 */
  17841. /***/ (function(module, exports, __webpack_require__) {
  17842. // 19.1.2.5 Object.freeze(O)
  17843. var isObject = __webpack_require__(9);
  17844. var meta = __webpack_require__(34).onFreeze;
  17845. __webpack_require__(26)('freeze', function ($freeze) {
  17846. return function freeze(it) {
  17847. return $freeze && isObject(it) ? $freeze(meta(it)) : it;
  17848. };
  17849. });
  17850. /***/ }),
  17851. /* 123 */
  17852. /***/ (function(module, exports, __webpack_require__) {
  17853. // 19.1.2.17 Object.seal(O)
  17854. var isObject = __webpack_require__(9);
  17855. var meta = __webpack_require__(34).onFreeze;
  17856. __webpack_require__(26)('seal', function ($seal) {
  17857. return function seal(it) {
  17858. return $seal && isObject(it) ? $seal(meta(it)) : it;
  17859. };
  17860. });
  17861. /***/ }),
  17862. /* 124 */
  17863. /***/ (function(module, exports, __webpack_require__) {
  17864. // 19.1.2.15 Object.preventExtensions(O)
  17865. var isObject = __webpack_require__(9);
  17866. var meta = __webpack_require__(34).onFreeze;
  17867. __webpack_require__(26)('preventExtensions', function ($preventExtensions) {
  17868. return function preventExtensions(it) {
  17869. return $preventExtensions && isObject(it) ? $preventExtensions(meta(it)) : it;
  17870. };
  17871. });
  17872. /***/ }),
  17873. /* 125 */
  17874. /***/ (function(module, exports, __webpack_require__) {
  17875. // 19.1.2.12 Object.isFrozen(O)
  17876. var isObject = __webpack_require__(9);
  17877. __webpack_require__(26)('isFrozen', function ($isFrozen) {
  17878. return function isFrozen(it) {
  17879. return isObject(it) ? $isFrozen ? $isFrozen(it) : false : true;
  17880. };
  17881. });
  17882. /***/ }),
  17883. /* 126 */
  17884. /***/ (function(module, exports, __webpack_require__) {
  17885. // 19.1.2.13 Object.isSealed(O)
  17886. var isObject = __webpack_require__(9);
  17887. __webpack_require__(26)('isSealed', function ($isSealed) {
  17888. return function isSealed(it) {
  17889. return isObject(it) ? $isSealed ? $isSealed(it) : false : true;
  17890. };
  17891. });
  17892. /***/ }),
  17893. /* 127 */
  17894. /***/ (function(module, exports, __webpack_require__) {
  17895. // 19.1.2.11 Object.isExtensible(O)
  17896. var isObject = __webpack_require__(9);
  17897. __webpack_require__(26)('isExtensible', function ($isExtensible) {
  17898. return function isExtensible(it) {
  17899. return isObject(it) ? $isExtensible ? $isExtensible(it) : true : false;
  17900. };
  17901. });
  17902. /***/ }),
  17903. /* 128 */
  17904. /***/ (function(module, exports, __webpack_require__) {
  17905. // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
  17906. var toIObject = __webpack_require__(24);
  17907. var $getOwnPropertyDescriptor = __webpack_require__(67).f;
  17908. __webpack_require__(26)('getOwnPropertyDescriptor', function () {
  17909. return function getOwnPropertyDescriptor(it, key) {
  17910. return $getOwnPropertyDescriptor(toIObject(it), key);
  17911. };
  17912. });
  17913. /***/ }),
  17914. /* 129 */
  17915. /***/ (function(module, exports, __webpack_require__) {
  17916. // 19.1.2.9 Object.getPrototypeOf(O)
  17917. var toObject = __webpack_require__(33);
  17918. var $getPrototypeOf = __webpack_require__(107);
  17919. __webpack_require__(26)('getPrototypeOf', function () {
  17920. return function getPrototypeOf(it) {
  17921. return $getPrototypeOf(toObject(it));
  17922. };
  17923. });
  17924. /***/ }),
  17925. /* 130 */
  17926. /***/ (function(module, exports, __webpack_require__) {
  17927. // 19.1.2.14 Object.keys(O)
  17928. var toObject = __webpack_require__(33);
  17929. var $keys = __webpack_require__(37);
  17930. __webpack_require__(26)('keys', function () {
  17931. return function keys(it) {
  17932. return $keys(toObject(it));
  17933. };
  17934. });
  17935. /***/ }),
  17936. /* 131 */
  17937. /***/ (function(module, exports, __webpack_require__) {
  17938. // 19.1.2.7 Object.getOwnPropertyNames(O)
  17939. __webpack_require__(26)('getOwnPropertyNames', function () {
  17940. return __webpack_require__(121).f;
  17941. });
  17942. /***/ }),
  17943. /* 132 */
  17944. /***/ (function(module, exports, __webpack_require__) {
  17945. // 19.1.3.1 Object.assign(target, source)
  17946. var $export = __webpack_require__(3);
  17947. $export($export.S + $export.F, 'Object', { assign: __webpack_require__(114) });
  17948. /***/ }),
  17949. /* 133 */
  17950. /***/ (function(module, exports, __webpack_require__) {
  17951. // 19.1.3.10 Object.is(value1, value2)
  17952. var $export = __webpack_require__(3);
  17953. $export($export.S, 'Object', { is: __webpack_require__(339) });
  17954. /***/ }),
  17955. /* 134 */
  17956. /***/ (function(module, exports, __webpack_require__) {
  17957. // 19.1.3.19 Object.setPrototypeOf(O, proto)
  17958. var $export = __webpack_require__(3);
  17959. $export($export.S, 'Object', { setPrototypeOf: __webpack_require__(110).set });
  17960. /***/ }),
  17961. /* 135 */
  17962. /***/ (function(module, exports, __webpack_require__) {
  17963. var dP = __webpack_require__(20).f;
  17964. var FProto = Function.prototype;
  17965. var nameRE = /^\s*function ([^ (]*)/;
  17966. var NAME = 'name';
  17967. // 19.2.4.2 name
  17968. NAME in FProto || __webpack_require__(22) && dP(FProto, NAME, {
  17969. configurable: true,
  17970. get: function () {
  17971. try {
  17972. return ('' + this).match(nameRE)[1];
  17973. } catch (e) {
  17974. return '';
  17975. }
  17976. }
  17977. });
  17978. /***/ }),
  17979. /* 136 */
  17980. /***/ (function(module, exports, __webpack_require__) {
  17981. var $export = __webpack_require__(3);
  17982. var toIObject = __webpack_require__(24);
  17983. var toLength = __webpack_require__(25);
  17984. $export($export.S, 'String', {
  17985. // 21.1.2.4 String.raw(callSite, ...substitutions)
  17986. raw: function raw(callSite) {
  17987. var tpl = toIObject(callSite.raw);
  17988. var len = toLength(tpl.length);
  17989. var aLen = arguments.length;
  17990. var res = [];
  17991. var i = 0;
  17992. while (len > i) {
  17993. res.push(String(tpl[i++]));
  17994. if (i < aLen) res.push(String(arguments[i]));
  17995. } return res.join('');
  17996. }
  17997. });
  17998. /***/ }),
  17999. /* 137 */
  18000. /***/ (function(module, exports, __webpack_require__) {
  18001. var $export = __webpack_require__(3);
  18002. var toAbsoluteIndex = __webpack_require__(60);
  18003. var fromCharCode = String.fromCharCode;
  18004. var $fromCodePoint = String.fromCodePoint;
  18005. // length should be 1, old FF problem
  18006. $export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
  18007. // 21.1.2.2 String.fromCodePoint(...codePoints)
  18008. fromCodePoint: function fromCodePoint(x) { // eslint-disable-line no-unused-vars
  18009. var res = [];
  18010. var aLen = arguments.length;
  18011. var i = 0;
  18012. var code;
  18013. while (aLen > i) {
  18014. code = +arguments[i++];
  18015. if (toAbsoluteIndex(code, 0x10ffff) !== code) throw RangeError(code + ' is not a valid code point');
  18016. res.push(code < 0x10000
  18017. ? fromCharCode(code)
  18018. : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)
  18019. );
  18020. } return res.join('');
  18021. }
  18022. });
  18023. /***/ }),
  18024. /* 138 */
  18025. /***/ (function(module, exports, __webpack_require__) {
  18026. "use strict";
  18027. var $export = __webpack_require__(3);
  18028. var $at = __webpack_require__(340)(false);
  18029. $export($export.P, 'String', {
  18030. // 21.1.3.3 String.prototype.codePointAt(pos)
  18031. codePointAt: function codePointAt(pos) {
  18032. return $at(this, pos);
  18033. }
  18034. });
  18035. /***/ }),
  18036. /* 139 */
  18037. /***/ (function(module, exports, __webpack_require__) {
  18038. var $export = __webpack_require__(3);
  18039. $export($export.P, 'String', {
  18040. // 21.1.3.13 String.prototype.repeat(count)
  18041. repeat: __webpack_require__(140)
  18042. });
  18043. /***/ }),
  18044. /* 140 */
  18045. /***/ (function(module, exports, __webpack_require__) {
  18046. "use strict";
  18047. var toInteger = __webpack_require__(59);
  18048. var defined = __webpack_require__(38);
  18049. module.exports = function repeat(count) {
  18050. var str = String(defined(this));
  18051. var res = '';
  18052. var n = toInteger(count);
  18053. if (n < 0 || n == Infinity) throw RangeError("Count can't be negative");
  18054. for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) res += str;
  18055. return res;
  18056. };
  18057. /***/ }),
  18058. /* 141 */
  18059. /***/ (function(module, exports, __webpack_require__) {
  18060. "use strict";
  18061. // 21.1.3.18 String.prototype.startsWith(searchString [, position ])
  18062. var $export = __webpack_require__(3);
  18063. var toLength = __webpack_require__(25);
  18064. var context = __webpack_require__(82);
  18065. var STARTS_WITH = 'startsWith';
  18066. var $startsWith = ''[STARTS_WITH];
  18067. $export($export.P + $export.F * __webpack_require__(83)(STARTS_WITH), 'String', {
  18068. startsWith: function startsWith(searchString /* , position = 0 */) {
  18069. var that = context(this, searchString, STARTS_WITH);
  18070. var index = toLength(Math.min(arguments.length > 1 ? arguments[1] : undefined, that.length));
  18071. var search = String(searchString);
  18072. return $startsWith
  18073. ? $startsWith.call(that, search, index)
  18074. : that.slice(index, index + search.length) === search;
  18075. }
  18076. });
  18077. /***/ }),
  18078. /* 142 */
  18079. /***/ (function(module, exports, __webpack_require__) {
  18080. // 7.2.8 IsRegExp(argument)
  18081. var isObject = __webpack_require__(9);
  18082. var cof = __webpack_require__(44);
  18083. var MATCH = __webpack_require__(11)('match');
  18084. module.exports = function (it) {
  18085. var isRegExp;
  18086. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp');
  18087. };
  18088. /***/ }),
  18089. /* 143 */
  18090. /***/ (function(module, exports, __webpack_require__) {
  18091. "use strict";
  18092. // 21.1.3.6 String.prototype.endsWith(searchString [, endPosition])
  18093. var $export = __webpack_require__(3);
  18094. var toLength = __webpack_require__(25);
  18095. var context = __webpack_require__(82);
  18096. var ENDS_WITH = 'endsWith';
  18097. var $endsWith = ''[ENDS_WITH];
  18098. $export($export.P + $export.F * __webpack_require__(83)(ENDS_WITH), 'String', {
  18099. endsWith: function endsWith(searchString /* , endPosition = @length */) {
  18100. var that = context(this, searchString, ENDS_WITH);
  18101. var endPosition = arguments.length > 1 ? arguments[1] : undefined;
  18102. var len = toLength(that.length);
  18103. var end = endPosition === undefined ? len : Math.min(toLength(endPosition), len);
  18104. var search = String(searchString);
  18105. return $endsWith
  18106. ? $endsWith.call(that, search, end)
  18107. : that.slice(end - search.length, end) === search;
  18108. }
  18109. });
  18110. /***/ }),
  18111. /* 144 */
  18112. /***/ (function(module, exports, __webpack_require__) {
  18113. "use strict";
  18114. // 21.1.3.7 String.prototype.includes(searchString, position = 0)
  18115. var $export = __webpack_require__(3);
  18116. var context = __webpack_require__(82);
  18117. var INCLUDES = 'includes';
  18118. $export($export.P + $export.F * __webpack_require__(83)(INCLUDES), 'String', {
  18119. includes: function includes(searchString /* , position = 0 */) {
  18120. return !!~context(this, searchString, INCLUDES)
  18121. .indexOf(searchString, arguments.length > 1 ? arguments[1] : undefined);
  18122. }
  18123. });
  18124. /***/ }),
  18125. /* 145 */
  18126. /***/ (function(module, exports, __webpack_require__) {
  18127. // 21.2.5.3 get RegExp.prototype.flags()
  18128. if (__webpack_require__(22) && /./g.flags != 'g') __webpack_require__(20).f(RegExp.prototype, 'flags', {
  18129. configurable: true,
  18130. get: __webpack_require__(341)
  18131. });
  18132. /***/ }),
  18133. /* 146 */
  18134. /***/ (function(module, exports, __webpack_require__) {
  18135. // @@match logic
  18136. __webpack_require__(70)('match', 1, function (defined, MATCH, $match) {
  18137. // 21.1.3.11 String.prototype.match(regexp)
  18138. return [function match(regexp) {
  18139. 'use strict';
  18140. var O = defined(this);
  18141. var fn = regexp == undefined ? undefined : regexp[MATCH];
  18142. return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
  18143. }, $match];
  18144. });
  18145. /***/ }),
  18146. /* 147 */
  18147. /***/ (function(module, exports, __webpack_require__) {
  18148. // @@replace logic
  18149. __webpack_require__(70)('replace', 2, function (defined, REPLACE, $replace) {
  18150. // 21.1.3.14 String.prototype.replace(searchValue, replaceValue)
  18151. return [function replace(searchValue, replaceValue) {
  18152. 'use strict';
  18153. var O = defined(this);
  18154. var fn = searchValue == undefined ? undefined : searchValue[REPLACE];
  18155. return fn !== undefined
  18156. ? fn.call(searchValue, O, replaceValue)
  18157. : $replace.call(String(O), searchValue, replaceValue);
  18158. }, $replace];
  18159. });
  18160. /***/ }),
  18161. /* 148 */
  18162. /***/ (function(module, exports, __webpack_require__) {
  18163. // @@split logic
  18164. __webpack_require__(70)('split', 2, function (defined, SPLIT, $split) {
  18165. 'use strict';
  18166. var isRegExp = __webpack_require__(142);
  18167. var _split = $split;
  18168. var $push = [].push;
  18169. var $SPLIT = 'split';
  18170. var LENGTH = 'length';
  18171. var LAST_INDEX = 'lastIndex';
  18172. if (
  18173. 'abbc'[$SPLIT](/(b)*/)[1] == 'c' ||
  18174. 'test'[$SPLIT](/(?:)/, -1)[LENGTH] != 4 ||
  18175. 'ab'[$SPLIT](/(?:ab)*/)[LENGTH] != 2 ||
  18176. '.'[$SPLIT](/(.?)(.?)/)[LENGTH] != 4 ||
  18177. '.'[$SPLIT](/()()/)[LENGTH] > 1 ||
  18178. ''[$SPLIT](/.?/)[LENGTH]
  18179. ) {
  18180. var NPCG = /()??/.exec('')[1] === undefined; // nonparticipating capturing group
  18181. // based on es5-shim implementation, need to rework it
  18182. $split = function (separator, limit) {
  18183. var string = String(this);
  18184. if (separator === undefined && limit === 0) return [];
  18185. // If `separator` is not a regex, use native split
  18186. if (!isRegExp(separator)) return _split.call(string, separator, limit);
  18187. var output = [];
  18188. var flags = (separator.ignoreCase ? 'i' : '') +
  18189. (separator.multiline ? 'm' : '') +
  18190. (separator.unicode ? 'u' : '') +
  18191. (separator.sticky ? 'y' : '');
  18192. var lastLastIndex = 0;
  18193. var splitLimit = limit === undefined ? 4294967295 : limit >>> 0;
  18194. // Make `global` and avoid `lastIndex` issues by working with a copy
  18195. var separatorCopy = new RegExp(separator.source, flags + 'g');
  18196. var separator2, match, lastIndex, lastLength, i;
  18197. // Doesn't need flags gy, but they don't hurt
  18198. if (!NPCG) separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags);
  18199. while (match = separatorCopy.exec(string)) {
  18200. // `separatorCopy.lastIndex` is not reliable cross-browser
  18201. lastIndex = match.index + match[0][LENGTH];
  18202. if (lastIndex > lastLastIndex) {
  18203. output.push(string.slice(lastLastIndex, match.index));
  18204. // Fix browsers whose `exec` methods don't consistently return `undefined` for NPCG
  18205. // eslint-disable-next-line no-loop-func
  18206. if (!NPCG && match[LENGTH] > 1) match[0].replace(separator2, function () {
  18207. for (i = 1; i < arguments[LENGTH] - 2; i++) if (arguments[i] === undefined) match[i] = undefined;
  18208. });
  18209. if (match[LENGTH] > 1 && match.index < string[LENGTH]) $push.apply(output, match.slice(1));
  18210. lastLength = match[0][LENGTH];
  18211. lastLastIndex = lastIndex;
  18212. if (output[LENGTH] >= splitLimit) break;
  18213. }
  18214. if (separatorCopy[LAST_INDEX] === match.index) separatorCopy[LAST_INDEX]++; // Avoid an infinite loop
  18215. }
  18216. if (lastLastIndex === string[LENGTH]) {
  18217. if (lastLength || !separatorCopy.test('')) output.push('');
  18218. } else output.push(string.slice(lastLastIndex));
  18219. return output[LENGTH] > splitLimit ? output.slice(0, splitLimit) : output;
  18220. };
  18221. // Chakra, V8
  18222. } else if ('0'[$SPLIT](undefined, 0)[LENGTH]) {
  18223. $split = function (separator, limit) {
  18224. return separator === undefined && limit === 0 ? [] : _split.call(this, separator, limit);
  18225. };
  18226. }
  18227. // 21.1.3.17 String.prototype.split(separator, limit)
  18228. return [function split(separator, limit) {
  18229. var O = defined(this);
  18230. var fn = separator == undefined ? undefined : separator[SPLIT];
  18231. return fn !== undefined ? fn.call(separator, O, limit) : $split.call(String(O), separator, limit);
  18232. }, $split];
  18233. });
  18234. /***/ }),
  18235. /* 149 */
  18236. /***/ (function(module, exports, __webpack_require__) {
  18237. // @@search logic
  18238. __webpack_require__(70)('search', 1, function (defined, SEARCH, $search) {
  18239. // 21.1.3.15 String.prototype.search(regexp)
  18240. return [function search(regexp) {
  18241. 'use strict';
  18242. var O = defined(this);
  18243. var fn = regexp == undefined ? undefined : regexp[SEARCH];
  18244. return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O));
  18245. }, $search];
  18246. });
  18247. /***/ }),
  18248. /* 150 */
  18249. /***/ (function(module, exports, __webpack_require__) {
  18250. "use strict";
  18251. var ctx = __webpack_require__(32);
  18252. var $export = __webpack_require__(3);
  18253. var toObject = __webpack_require__(33);
  18254. var call = __webpack_require__(102);
  18255. var isArrayIter = __webpack_require__(103);
  18256. var toLength = __webpack_require__(25);
  18257. var createProperty = __webpack_require__(84);
  18258. var getIterFn = __webpack_require__(104);
  18259. $export($export.S + $export.F * !__webpack_require__(79)(function (iter) { Array.from(iter); }), 'Array', {
  18260. // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
  18261. from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
  18262. var O = toObject(arrayLike);
  18263. var C = typeof this == 'function' ? this : Array;
  18264. var aLen = arguments.length;
  18265. var mapfn = aLen > 1 ? arguments[1] : undefined;
  18266. var mapping = mapfn !== undefined;
  18267. var index = 0;
  18268. var iterFn = getIterFn(O);
  18269. var length, result, step, iterator;
  18270. if (mapping) mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
  18271. // if object isn't iterable or it's array with default iterator - use simple case
  18272. if (iterFn != undefined && !(C == Array && isArrayIter(iterFn))) {
  18273. for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) {
  18274. createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);
  18275. }
  18276. } else {
  18277. length = toLength(O.length);
  18278. for (result = new C(length); length > index; index++) {
  18279. createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
  18280. }
  18281. }
  18282. result.length = index;
  18283. return result;
  18284. }
  18285. });
  18286. /***/ }),
  18287. /* 151 */
  18288. /***/ (function(module, exports, __webpack_require__) {
  18289. "use strict";
  18290. var $export = __webpack_require__(3);
  18291. var createProperty = __webpack_require__(84);
  18292. // WebKit Array.of isn't generic
  18293. $export($export.S + $export.F * __webpack_require__(23)(function () {
  18294. function F() { /* empty */ }
  18295. return !(Array.of.call(F) instanceof F);
  18296. }), 'Array', {
  18297. // 22.1.2.3 Array.of( ...items)
  18298. of: function of(/* ...args */) {
  18299. var index = 0;
  18300. var aLen = arguments.length;
  18301. var result = new (typeof this == 'function' ? this : Array)(aLen);
  18302. while (aLen > index) createProperty(result, index, arguments[index++]);
  18303. result.length = aLen;
  18304. return result;
  18305. }
  18306. });
  18307. /***/ }),
  18308. /* 152 */
  18309. /***/ (function(module, exports, __webpack_require__) {
  18310. // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
  18311. var $export = __webpack_require__(3);
  18312. $export($export.P, 'Array', { copyWithin: __webpack_require__(342) });
  18313. __webpack_require__(47)('copyWithin');
  18314. /***/ }),
  18315. /* 153 */
  18316. /***/ (function(module, exports, __webpack_require__) {
  18317. "use strict";
  18318. // 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined)
  18319. var $export = __webpack_require__(3);
  18320. var $find = __webpack_require__(68)(5);
  18321. var KEY = 'find';
  18322. var forced = true;
  18323. // Shouldn't skip holes
  18324. if (KEY in []) Array(1)[KEY](function () { forced = false; });
  18325. $export($export.P + $export.F * forced, 'Array', {
  18326. find: function find(callbackfn /* , that = undefined */) {
  18327. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  18328. }
  18329. });
  18330. __webpack_require__(47)(KEY);
  18331. /***/ }),
  18332. /* 154 */
  18333. /***/ (function(module, exports, __webpack_require__) {
  18334. "use strict";
  18335. // 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined)
  18336. var $export = __webpack_require__(3);
  18337. var $find = __webpack_require__(68)(6);
  18338. var KEY = 'findIndex';
  18339. var forced = true;
  18340. // Shouldn't skip holes
  18341. if (KEY in []) Array(1)[KEY](function () { forced = false; });
  18342. $export($export.P + $export.F * forced, 'Array', {
  18343. findIndex: function findIndex(callbackfn /* , that = undefined */) {
  18344. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  18345. }
  18346. });
  18347. __webpack_require__(47)(KEY);
  18348. /***/ }),
  18349. /* 155 */
  18350. /***/ (function(module, exports, __webpack_require__) {
  18351. // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
  18352. var $export = __webpack_require__(3);
  18353. $export($export.P, 'Array', { fill: __webpack_require__(343) });
  18354. __webpack_require__(47)('fill');
  18355. /***/ }),
  18356. /* 156 */
  18357. /***/ (function(module, exports, __webpack_require__) {
  18358. // 20.1.2.2 Number.isFinite(number)
  18359. var $export = __webpack_require__(3);
  18360. var _isFinite = __webpack_require__(14).isFinite;
  18361. $export($export.S, 'Number', {
  18362. isFinite: function isFinite(it) {
  18363. return typeof it == 'number' && _isFinite(it);
  18364. }
  18365. });
  18366. /***/ }),
  18367. /* 157 */
  18368. /***/ (function(module, exports, __webpack_require__) {
  18369. // 20.1.2.3 Number.isInteger(number)
  18370. var $export = __webpack_require__(3);
  18371. $export($export.S, 'Number', { isInteger: __webpack_require__(158) });
  18372. /***/ }),
  18373. /* 158 */
  18374. /***/ (function(module, exports, __webpack_require__) {
  18375. // 20.1.2.3 Number.isInteger(number)
  18376. var isObject = __webpack_require__(9);
  18377. var floor = Math.floor;
  18378. module.exports = function isInteger(it) {
  18379. return !isObject(it) && isFinite(it) && floor(it) === it;
  18380. };
  18381. /***/ }),
  18382. /* 159 */
  18383. /***/ (function(module, exports, __webpack_require__) {
  18384. // 20.1.2.5 Number.isSafeInteger(number)
  18385. var $export = __webpack_require__(3);
  18386. var isInteger = __webpack_require__(158);
  18387. var abs = Math.abs;
  18388. $export($export.S, 'Number', {
  18389. isSafeInteger: function isSafeInteger(number) {
  18390. return isInteger(number) && abs(number) <= 0x1fffffffffffff;
  18391. }
  18392. });
  18393. /***/ }),
  18394. /* 160 */
  18395. /***/ (function(module, exports, __webpack_require__) {
  18396. // 20.1.2.4 Number.isNaN(number)
  18397. var $export = __webpack_require__(3);
  18398. $export($export.S, 'Number', {
  18399. isNaN: function isNaN(number) {
  18400. // eslint-disable-next-line no-self-compare
  18401. return number != number;
  18402. }
  18403. });
  18404. /***/ }),
  18405. /* 161 */
  18406. /***/ (function(module, exports, __webpack_require__) {
  18407. // 20.1.2.1 Number.EPSILON
  18408. var $export = __webpack_require__(3);
  18409. $export($export.S, 'Number', { EPSILON: Math.pow(2, -52) });
  18410. /***/ }),
  18411. /* 162 */
  18412. /***/ (function(module, exports, __webpack_require__) {
  18413. // 20.1.2.10 Number.MIN_SAFE_INTEGER
  18414. var $export = __webpack_require__(3);
  18415. $export($export.S, 'Number', { MIN_SAFE_INTEGER: -0x1fffffffffffff });
  18416. /***/ }),
  18417. /* 163 */
  18418. /***/ (function(module, exports, __webpack_require__) {
  18419. // 20.1.2.6 Number.MAX_SAFE_INTEGER
  18420. var $export = __webpack_require__(3);
  18421. $export($export.S, 'Number', { MAX_SAFE_INTEGER: 0x1fffffffffffff });
  18422. /***/ }),
  18423. /* 164 */
  18424. /***/ (function(module, exports, __webpack_require__) {
  18425. "use strict";
  18426. // https://github.com/tc39/Array.prototype.includes
  18427. var $export = __webpack_require__(3);
  18428. var $includes = __webpack_require__(100)(true);
  18429. $export($export.P, 'Array', {
  18430. includes: function includes(el /* , fromIndex = 0 */) {
  18431. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  18432. }
  18433. });
  18434. __webpack_require__(47)('includes');
  18435. /***/ }),
  18436. /* 165 */
  18437. /***/ (function(module, exports, __webpack_require__) {
  18438. // https://github.com/tc39/proposal-object-values-entries
  18439. var $export = __webpack_require__(3);
  18440. var $values = __webpack_require__(166)(false);
  18441. $export($export.S, 'Object', {
  18442. values: function values(it) {
  18443. return $values(it);
  18444. }
  18445. });
  18446. /***/ }),
  18447. /* 166 */
  18448. /***/ (function(module, exports, __webpack_require__) {
  18449. var getKeys = __webpack_require__(37);
  18450. var toIObject = __webpack_require__(24);
  18451. var isEnum = __webpack_require__(53).f;
  18452. module.exports = function (isEntries) {
  18453. return function (it) {
  18454. var O = toIObject(it);
  18455. var keys = getKeys(O);
  18456. var length = keys.length;
  18457. var i = 0;
  18458. var result = [];
  18459. var key;
  18460. while (length > i) if (isEnum.call(O, key = keys[i++])) {
  18461. result.push(isEntries ? [key, O[key]] : O[key]);
  18462. } return result;
  18463. };
  18464. };
  18465. /***/ }),
  18466. /* 167 */
  18467. /***/ (function(module, exports, __webpack_require__) {
  18468. // https://github.com/tc39/proposal-object-values-entries
  18469. var $export = __webpack_require__(3);
  18470. var $entries = __webpack_require__(166)(true);
  18471. $export($export.S, 'Object', {
  18472. entries: function entries(it) {
  18473. return $entries(it);
  18474. }
  18475. });
  18476. /***/ }),
  18477. /* 168 */
  18478. /***/ (function(module, exports, __webpack_require__) {
  18479. // https://github.com/tc39/proposal-object-getownpropertydescriptors
  18480. var $export = __webpack_require__(3);
  18481. var ownKeys = __webpack_require__(344);
  18482. var toIObject = __webpack_require__(24);
  18483. var gOPD = __webpack_require__(67);
  18484. var createProperty = __webpack_require__(84);
  18485. $export($export.S, 'Object', {
  18486. getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) {
  18487. var O = toIObject(object);
  18488. var getDesc = gOPD.f;
  18489. var keys = ownKeys(O);
  18490. var result = {};
  18491. var i = 0;
  18492. var key, desc;
  18493. while (keys.length > i) {
  18494. desc = getDesc(O, key = keys[i++]);
  18495. if (desc !== undefined) createProperty(result, key, desc);
  18496. }
  18497. return result;
  18498. }
  18499. });
  18500. /***/ }),
  18501. /* 169 */
  18502. /***/ (function(module, exports, __webpack_require__) {
  18503. "use strict";
  18504. // https://github.com/tc39/proposal-string-pad-start-end
  18505. var $export = __webpack_require__(3);
  18506. var $pad = __webpack_require__(170);
  18507. var userAgent = __webpack_require__(171);
  18508. // https://github.com/zloirock/core-js/issues/280
  18509. $export($export.P + $export.F * /Version\/10\.\d+(\.\d+)? Safari\//.test(userAgent), 'String', {
  18510. padStart: function padStart(maxLength /* , fillString = ' ' */) {
  18511. return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, true);
  18512. }
  18513. });
  18514. /***/ }),
  18515. /* 170 */
  18516. /***/ (function(module, exports, __webpack_require__) {
  18517. // https://github.com/tc39/proposal-string-pad-start-end
  18518. var toLength = __webpack_require__(25);
  18519. var repeat = __webpack_require__(140);
  18520. var defined = __webpack_require__(38);
  18521. module.exports = function (that, maxLength, fillString, left) {
  18522. var S = String(defined(that));
  18523. var stringLength = S.length;
  18524. var fillStr = fillString === undefined ? ' ' : String(fillString);
  18525. var intMaxLength = toLength(maxLength);
  18526. if (intMaxLength <= stringLength || fillStr == '') return S;
  18527. var fillLen = intMaxLength - stringLength;
  18528. var stringFiller = repeat.call(fillStr, Math.ceil(fillLen / fillStr.length));
  18529. if (stringFiller.length > fillLen) stringFiller = stringFiller.slice(0, fillLen);
  18530. return left ? stringFiller + S : S + stringFiller;
  18531. };
  18532. /***/ }),
  18533. /* 171 */
  18534. /***/ (function(module, exports, __webpack_require__) {
  18535. var global = __webpack_require__(14);
  18536. var navigator = global.navigator;
  18537. module.exports = navigator && navigator.userAgent || '';
  18538. /***/ }),
  18539. /* 172 */
  18540. /***/ (function(module, exports, __webpack_require__) {
  18541. "use strict";
  18542. // https://github.com/tc39/proposal-string-pad-start-end
  18543. var $export = __webpack_require__(3);
  18544. var $pad = __webpack_require__(170);
  18545. var userAgent = __webpack_require__(171);
  18546. // https://github.com/zloirock/core-js/issues/280
  18547. $export($export.P + $export.F * /Version\/10\.\d+(\.\d+)? Safari\//.test(userAgent), 'String', {
  18548. padEnd: function padEnd(maxLength /* , fillString = ' ' */) {
  18549. return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, false);
  18550. }
  18551. });
  18552. /***/ }),
  18553. /* 173 */
  18554. /***/ (function(module, exports, __webpack_require__) {
  18555. var $export = __webpack_require__(3);
  18556. var $task = __webpack_require__(80);
  18557. $export($export.G + $export.B, {
  18558. setImmediate: $task.set,
  18559. clearImmediate: $task.clear
  18560. });
  18561. /***/ }),
  18562. /* 174 */
  18563. /***/ (function(module, exports, __webpack_require__) {
  18564. var $iterators = __webpack_require__(85);
  18565. var getKeys = __webpack_require__(37);
  18566. var redefine = __webpack_require__(30);
  18567. var global = __webpack_require__(14);
  18568. var hide = __webpack_require__(31);
  18569. var Iterators = __webpack_require__(51);
  18570. var wks = __webpack_require__(11);
  18571. var ITERATOR = wks('iterator');
  18572. var TO_STRING_TAG = wks('toStringTag');
  18573. var ArrayValues = Iterators.Array;
  18574. var DOMIterables = {
  18575. CSSRuleList: true, // TODO: Not spec compliant, should be false.
  18576. CSSStyleDeclaration: false,
  18577. CSSValueList: false,
  18578. ClientRectList: false,
  18579. DOMRectList: false,
  18580. DOMStringList: false,
  18581. DOMTokenList: true,
  18582. DataTransferItemList: false,
  18583. FileList: false,
  18584. HTMLAllCollection: false,
  18585. HTMLCollection: false,
  18586. HTMLFormElement: false,
  18587. HTMLSelectElement: false,
  18588. MediaList: true, // TODO: Not spec compliant, should be false.
  18589. MimeTypeArray: false,
  18590. NamedNodeMap: false,
  18591. NodeList: true,
  18592. PaintRequestList: false,
  18593. Plugin: false,
  18594. PluginArray: false,
  18595. SVGLengthList: false,
  18596. SVGNumberList: false,
  18597. SVGPathSegList: false,
  18598. SVGPointList: false,
  18599. SVGStringList: false,
  18600. SVGTransformList: false,
  18601. SourceBufferList: false,
  18602. StyleSheetList: true, // TODO: Not spec compliant, should be false.
  18603. TextTrackCueList: false,
  18604. TextTrackList: false,
  18605. TouchList: false
  18606. };
  18607. for (var collections = getKeys(DOMIterables), i = 0; i < collections.length; i++) {
  18608. var NAME = collections[i];
  18609. var explicit = DOMIterables[NAME];
  18610. var Collection = global[NAME];
  18611. var proto = Collection && Collection.prototype;
  18612. var key;
  18613. if (proto) {
  18614. if (!proto[ITERATOR]) hide(proto, ITERATOR, ArrayValues);
  18615. if (!proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME);
  18616. Iterators[NAME] = ArrayValues;
  18617. if (explicit) for (key in $iterators) if (!proto[key]) redefine(proto, key, $iterators[key], true);
  18618. }
  18619. }
  18620. /***/ }),
  18621. /* 175 */
  18622. /***/ (function(module, exports, __webpack_require__) {
  18623. "use strict";
  18624. exports.__esModule = true;
  18625. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  18626. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18627. var privatePool = new WeakMap();
  18628. /**
  18629. * Calculates indexes of columns to render OR columns that are visible.
  18630. * To redo the calculation, you need to create a new calculator.
  18631. *
  18632. * @class ViewportColumnsCalculator
  18633. */
  18634. var ViewportColumnsCalculator = function () {
  18635. _createClass(ViewportColumnsCalculator, null, [{
  18636. key: 'DEFAULT_WIDTH',
  18637. /**
  18638. * Default column width
  18639. *
  18640. * @type {Number}
  18641. */
  18642. get: function get() {
  18643. return 50;
  18644. }
  18645. /**
  18646. * @param {Number} viewportWidth Width of the viewport
  18647. * @param {Number} scrollOffset Current horizontal scroll position of the viewport
  18648. * @param {Number} totalColumns Total number of rows
  18649. * @param {Function} columnWidthFn Function that returns the width of the column at a given index (in px)
  18650. * @param {Function} overrideFn Function that changes calculated this.startRow, this.endRow (used by MergeCells plugin)
  18651. * @param {Boolean} onlyFullyVisible if `true`, only startRow and endRow will be indexes of rows that are fully in viewport
  18652. * @param {Boolean} stretchH
  18653. * @param {Function} [stretchingColumnWidthFn] Function that returns the new width of the stretched column.
  18654. */
  18655. }]);
  18656. function ViewportColumnsCalculator(viewportWidth, scrollOffset, totalColumns, columnWidthFn, overrideFn, onlyFullyVisible, stretchH) {
  18657. var stretchingColumnWidthFn = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : function (width) {
  18658. return width;
  18659. };
  18660. _classCallCheck(this, ViewportColumnsCalculator);
  18661. privatePool.set(this, {
  18662. viewportWidth: viewportWidth,
  18663. scrollOffset: scrollOffset,
  18664. totalColumns: totalColumns,
  18665. columnWidthFn: columnWidthFn,
  18666. overrideFn: overrideFn,
  18667. onlyFullyVisible: onlyFullyVisible,
  18668. stretchingColumnWidthFn: stretchingColumnWidthFn
  18669. });
  18670. /**
  18671. * Number of rendered/visible columns
  18672. *
  18673. * @type {Number}
  18674. */
  18675. this.count = 0;
  18676. /**
  18677. * Index of the first rendered/visible column (can be overwritten using overrideFn)
  18678. *
  18679. * @type {Number|null}
  18680. */
  18681. this.startColumn = null;
  18682. /**
  18683. * Index of the last rendered/visible column (can be overwritten using overrideFn)
  18684. *
  18685. * @type {null}
  18686. */
  18687. this.endColumn = null;
  18688. /**
  18689. * Position of the first rendered/visible column (in px)
  18690. *
  18691. * @type {Number|null}
  18692. */
  18693. this.startPosition = null;
  18694. this.stretchAllRatio = 0;
  18695. this.stretchLastWidth = 0;
  18696. this.stretch = stretchH;
  18697. this.totalTargetWidth = 0;
  18698. this.needVerifyLastColumnWidth = true;
  18699. this.stretchAllColumnsWidth = [];
  18700. this.calculate();
  18701. }
  18702. /**
  18703. * Calculates viewport
  18704. */
  18705. _createClass(ViewportColumnsCalculator, [{
  18706. key: 'calculate',
  18707. value: function calculate() {
  18708. var sum = 0;
  18709. var needReverse = true;
  18710. var startPositions = [];
  18711. var columnWidth = void 0;
  18712. var priv = privatePool.get(this);
  18713. var onlyFullyVisible = priv.onlyFullyVisible;
  18714. var overrideFn = priv.overrideFn;
  18715. var scrollOffset = priv.scrollOffset;
  18716. var totalColumns = priv.totalColumns;
  18717. var viewportWidth = priv.viewportWidth;
  18718. for (var i = 0; i < totalColumns; i++) {
  18719. columnWidth = this._getColumnWidth(i);
  18720. if (sum <= scrollOffset && !onlyFullyVisible) {
  18721. this.startColumn = i;
  18722. }
  18723. // +1 pixel for row header width compensation for horizontal scroll > 0
  18724. var compensatedViewportWidth = scrollOffset > 0 ? viewportWidth + 1 : viewportWidth;
  18725. if (sum >= scrollOffset && sum + columnWidth <= scrollOffset + compensatedViewportWidth) {
  18726. if (this.startColumn == null) {
  18727. this.startColumn = i;
  18728. }
  18729. this.endColumn = i;
  18730. }
  18731. startPositions.push(sum);
  18732. sum += columnWidth;
  18733. if (!onlyFullyVisible) {
  18734. this.endColumn = i;
  18735. }
  18736. if (sum >= scrollOffset + viewportWidth) {
  18737. needReverse = false;
  18738. break;
  18739. }
  18740. }
  18741. if (this.endColumn === totalColumns - 1 && needReverse) {
  18742. this.startColumn = this.endColumn;
  18743. while (this.startColumn > 0) {
  18744. var viewportSum = startPositions[this.endColumn] + columnWidth - startPositions[this.startColumn - 1];
  18745. if (viewportSum <= viewportWidth || !onlyFullyVisible) {
  18746. this.startColumn--;
  18747. }
  18748. if (viewportSum > viewportWidth) {
  18749. break;
  18750. }
  18751. }
  18752. }
  18753. if (this.startColumn !== null && overrideFn) {
  18754. overrideFn(this);
  18755. }
  18756. this.startPosition = startPositions[this.startColumn];
  18757. if (this.startPosition == void 0) {
  18758. this.startPosition = null;
  18759. }
  18760. if (this.startColumn !== null) {
  18761. this.count = this.endColumn - this.startColumn + 1;
  18762. }
  18763. }
  18764. /**
  18765. * Recalculate columns stretching.
  18766. *
  18767. * @param {Number} totalWidth
  18768. */
  18769. }, {
  18770. key: 'refreshStretching',
  18771. value: function refreshStretching(totalWidth) {
  18772. if (this.stretch === 'none') {
  18773. return;
  18774. }
  18775. this.totalTargetWidth = totalWidth;
  18776. var priv = privatePool.get(this);
  18777. var totalColumns = priv.totalColumns;
  18778. var sumAll = 0;
  18779. for (var i = 0; i < totalColumns; i++) {
  18780. var columnWidth = this._getColumnWidth(i);
  18781. var permanentColumnWidth = priv.stretchingColumnWidthFn(void 0, i);
  18782. if (typeof permanentColumnWidth === 'number') {
  18783. totalWidth -= permanentColumnWidth;
  18784. } else {
  18785. sumAll += columnWidth;
  18786. }
  18787. }
  18788. var remainingSize = totalWidth - sumAll;
  18789. if (this.stretch === 'all' && remainingSize > 0) {
  18790. this.stretchAllRatio = totalWidth / sumAll;
  18791. this.stretchAllColumnsWidth = [];
  18792. this.needVerifyLastColumnWidth = true;
  18793. } else if (this.stretch === 'last' && totalWidth !== Infinity) {
  18794. var _columnWidth = this._getColumnWidth(totalColumns - 1);
  18795. var lastColumnWidth = remainingSize + _columnWidth;
  18796. this.stretchLastWidth = lastColumnWidth >= 0 ? lastColumnWidth : _columnWidth;
  18797. }
  18798. }
  18799. /**
  18800. * Get stretched column width based on stretchH (all or last) setting passed in handsontable instance.
  18801. *
  18802. * @param {Number} column
  18803. * @param {Number} baseWidth
  18804. * @returns {Number|null}
  18805. */
  18806. }, {
  18807. key: 'getStretchedColumnWidth',
  18808. value: function getStretchedColumnWidth(column, baseWidth) {
  18809. var result = null;
  18810. if (this.stretch === 'all' && this.stretchAllRatio !== 0) {
  18811. result = this._getStretchedAllColumnWidth(column, baseWidth);
  18812. } else if (this.stretch === 'last' && this.stretchLastWidth !== 0) {
  18813. result = this._getStretchedLastColumnWidth(column);
  18814. }
  18815. return result;
  18816. }
  18817. /**
  18818. * @param {Number} column
  18819. * @param {Number} baseWidth
  18820. * @returns {Number}
  18821. * @private
  18822. */
  18823. }, {
  18824. key: '_getStretchedAllColumnWidth',
  18825. value: function _getStretchedAllColumnWidth(column, baseWidth) {
  18826. var sumRatioWidth = 0;
  18827. var priv = privatePool.get(this);
  18828. var totalColumns = priv.totalColumns;
  18829. if (!this.stretchAllColumnsWidth[column]) {
  18830. var stretchedWidth = Math.round(baseWidth * this.stretchAllRatio);
  18831. var newStretchedWidth = priv.stretchingColumnWidthFn(stretchedWidth, column);
  18832. if (newStretchedWidth === void 0) {
  18833. this.stretchAllColumnsWidth[column] = stretchedWidth;
  18834. } else {
  18835. this.stretchAllColumnsWidth[column] = isNaN(newStretchedWidth) ? this._getColumnWidth(column) : newStretchedWidth;
  18836. }
  18837. }
  18838. if (this.stretchAllColumnsWidth.length === totalColumns && this.needVerifyLastColumnWidth) {
  18839. this.needVerifyLastColumnWidth = false;
  18840. for (var i = 0; i < this.stretchAllColumnsWidth.length; i++) {
  18841. sumRatioWidth += this.stretchAllColumnsWidth[i];
  18842. }
  18843. if (sumRatioWidth !== this.totalTargetWidth) {
  18844. this.stretchAllColumnsWidth[this.stretchAllColumnsWidth.length - 1] += this.totalTargetWidth - sumRatioWidth;
  18845. }
  18846. }
  18847. return this.stretchAllColumnsWidth[column];
  18848. }
  18849. /**
  18850. * @param {Number} column
  18851. * @returns {Number|null}
  18852. * @private
  18853. */
  18854. }, {
  18855. key: '_getStretchedLastColumnWidth',
  18856. value: function _getStretchedLastColumnWidth(column) {
  18857. var priv = privatePool.get(this);
  18858. var totalColumns = priv.totalColumns;
  18859. if (column === totalColumns - 1) {
  18860. return this.stretchLastWidth;
  18861. }
  18862. return null;
  18863. }
  18864. /**
  18865. * @param {Number} column Column index.
  18866. * @returns {Number}
  18867. * @private
  18868. */
  18869. }, {
  18870. key: '_getColumnWidth',
  18871. value: function _getColumnWidth(column) {
  18872. var width = privatePool.get(this).columnWidthFn(column);
  18873. if (width === void 0) {
  18874. width = ViewportColumnsCalculator.DEFAULT_WIDTH;
  18875. }
  18876. return width;
  18877. }
  18878. }]);
  18879. return ViewportColumnsCalculator;
  18880. }();
  18881. exports.default = ViewportColumnsCalculator;
  18882. /***/ }),
  18883. /* 176 */
  18884. /***/ (function(module, exports, __webpack_require__) {
  18885. "use strict";
  18886. exports.__esModule = true;
  18887. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  18888. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18889. var privatePool = new WeakMap();
  18890. /**
  18891. * Calculates indexes of rows to render OR rows that are visible.
  18892. * To redo the calculation, you need to create a new calculator.
  18893. *
  18894. * @class ViewportRowsCalculator
  18895. */
  18896. var ViewportRowsCalculator = function () {
  18897. _createClass(ViewportRowsCalculator, null, [{
  18898. key: "DEFAULT_HEIGHT",
  18899. /**
  18900. * Default row height
  18901. *
  18902. * @type {Number}
  18903. */
  18904. get: function get() {
  18905. return 23;
  18906. }
  18907. /**
  18908. * @param {Number} viewportHeight Height of the viewport
  18909. * @param {Number} scrollOffset Current vertical scroll position of the viewport
  18910. * @param {Number} totalRows Total number of rows
  18911. * @param {Function} rowHeightFn Function that returns the height of the row at a given index (in px)
  18912. * @param {Function} overrideFn Function that changes calculated this.startRow, this.endRow (used by MergeCells plugin)
  18913. * @param {Boolean} onlyFullyVisible if `true`, only startRow and endRow will be indexes of rows that are fully in viewport
  18914. * @param {Number} horizontalScrollbarHeight
  18915. */
  18916. }]);
  18917. function ViewportRowsCalculator(viewportHeight, scrollOffset, totalRows, rowHeightFn, overrideFn, onlyFullyVisible, horizontalScrollbarHeight) {
  18918. _classCallCheck(this, ViewportRowsCalculator);
  18919. privatePool.set(this, {
  18920. viewportHeight: viewportHeight,
  18921. scrollOffset: scrollOffset,
  18922. totalRows: totalRows,
  18923. rowHeightFn: rowHeightFn,
  18924. overrideFn: overrideFn,
  18925. onlyFullyVisible: onlyFullyVisible,
  18926. horizontalScrollbarHeight: horizontalScrollbarHeight
  18927. });
  18928. /**
  18929. * Number of rendered/visible rows
  18930. *
  18931. * @type {Number}
  18932. */
  18933. this.count = 0;
  18934. /**
  18935. * Index of the first rendered/visible row (can be overwritten using overrideFn)
  18936. *
  18937. * @type {Number|null}
  18938. */
  18939. this.startRow = null;
  18940. /**
  18941. * Index of the last rendered/visible row (can be overwritten using overrideFn)
  18942. *
  18943. * @type {null}
  18944. */
  18945. this.endRow = null;
  18946. /**
  18947. * Position of the first rendered/visible row (in px)
  18948. *
  18949. * @type {Number|null}
  18950. */
  18951. this.startPosition = null;
  18952. this.calculate();
  18953. }
  18954. /**
  18955. * Calculates viewport
  18956. */
  18957. _createClass(ViewportRowsCalculator, [{
  18958. key: "calculate",
  18959. value: function calculate() {
  18960. var sum = 0;
  18961. var needReverse = true;
  18962. var startPositions = [];
  18963. var priv = privatePool.get(this);
  18964. var onlyFullyVisible = priv.onlyFullyVisible;
  18965. var overrideFn = priv.overrideFn;
  18966. var rowHeightFn = priv.rowHeightFn;
  18967. var scrollOffset = priv.scrollOffset;
  18968. var totalRows = priv.totalRows;
  18969. var viewportHeight = priv.viewportHeight;
  18970. var horizontalScrollbarHeight = priv.horizontalScrollbarHeight || 0;
  18971. var rowHeight = void 0;
  18972. // Calculate the number (start and end index) of rows needed
  18973. for (var i = 0; i < totalRows; i++) {
  18974. rowHeight = rowHeightFn(i);
  18975. if (rowHeight === undefined) {
  18976. rowHeight = ViewportRowsCalculator.DEFAULT_HEIGHT;
  18977. }
  18978. if (sum <= scrollOffset && !onlyFullyVisible) {
  18979. this.startRow = i;
  18980. }
  18981. // the row is within the "visible range"
  18982. if (sum >= scrollOffset && sum + rowHeight <= scrollOffset + viewportHeight - horizontalScrollbarHeight) {
  18983. if (this.startRow === null) {
  18984. this.startRow = i;
  18985. }
  18986. this.endRow = i;
  18987. }
  18988. startPositions.push(sum);
  18989. sum += rowHeight;
  18990. if (!onlyFullyVisible) {
  18991. this.endRow = i;
  18992. }
  18993. if (sum >= scrollOffset + viewportHeight - horizontalScrollbarHeight) {
  18994. needReverse = false;
  18995. break;
  18996. }
  18997. }
  18998. // If the estimation has reached the last row and there is still some space available in the viewport,
  18999. // we need to render in reverse in order to fill the whole viewport with rows
  19000. if (this.endRow === totalRows - 1 && needReverse) {
  19001. this.startRow = this.endRow;
  19002. while (this.startRow > 0) {
  19003. // rowHeight is the height of the last row
  19004. var viewportSum = startPositions[this.endRow] + rowHeight - startPositions[this.startRow - 1];
  19005. if (viewportSum <= viewportHeight - horizontalScrollbarHeight || !onlyFullyVisible) {
  19006. this.startRow--;
  19007. }
  19008. if (viewportSum >= viewportHeight - horizontalScrollbarHeight) {
  19009. break;
  19010. }
  19011. }
  19012. }
  19013. if (this.startRow !== null && overrideFn) {
  19014. overrideFn(this);
  19015. }
  19016. this.startPosition = startPositions[this.startRow];
  19017. if (this.startPosition == void 0) {
  19018. this.startPosition = null;
  19019. }
  19020. if (this.startRow !== null) {
  19021. this.count = this.endRow - this.startRow + 1;
  19022. }
  19023. }
  19024. }]);
  19025. return ViewportRowsCalculator;
  19026. }();
  19027. exports.default = ViewportRowsCalculator;
  19028. /***/ }),
  19029. /* 177 */
  19030. /***/ (function(module, exports, __webpack_require__) {
  19031. "use strict";
  19032. exports.__esModule = true;
  19033. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  19034. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  19035. /**
  19036. * @class ColumnFilter
  19037. */
  19038. var ColumnFilter = function () {
  19039. /**
  19040. * @param {Number} offset
  19041. * @param {Number} total
  19042. * @param {Number} countTH
  19043. */
  19044. function ColumnFilter(offset, total, countTH) {
  19045. _classCallCheck(this, ColumnFilter);
  19046. this.offset = offset;
  19047. this.total = total;
  19048. this.countTH = countTH;
  19049. }
  19050. /**
  19051. * @param index
  19052. * @returns {Number}
  19053. */
  19054. _createClass(ColumnFilter, [{
  19055. key: "offsetted",
  19056. value: function offsetted(index) {
  19057. return index + this.offset;
  19058. }
  19059. /**
  19060. * @param index
  19061. * @returns {Number}
  19062. */
  19063. }, {
  19064. key: "unOffsetted",
  19065. value: function unOffsetted(index) {
  19066. return index - this.offset;
  19067. }
  19068. /**
  19069. * @param index
  19070. * @returns {Number}
  19071. */
  19072. }, {
  19073. key: "renderedToSource",
  19074. value: function renderedToSource(index) {
  19075. return this.offsetted(index);
  19076. }
  19077. /**
  19078. * @param index
  19079. * @returns {Number}
  19080. */
  19081. }, {
  19082. key: "sourceToRendered",
  19083. value: function sourceToRendered(index) {
  19084. return this.unOffsetted(index);
  19085. }
  19086. /**
  19087. * @param index
  19088. * @returns {Number}
  19089. */
  19090. }, {
  19091. key: "offsettedTH",
  19092. value: function offsettedTH(index) {
  19093. return index - this.countTH;
  19094. }
  19095. /**
  19096. * @param index
  19097. * @returns {Number}
  19098. */
  19099. }, {
  19100. key: "unOffsettedTH",
  19101. value: function unOffsettedTH(index) {
  19102. return index + this.countTH;
  19103. }
  19104. /**
  19105. * @param index
  19106. * @returns {Number}
  19107. */
  19108. }, {
  19109. key: "visibleRowHeadedColumnToSourceColumn",
  19110. value: function visibleRowHeadedColumnToSourceColumn(index) {
  19111. return this.renderedToSource(this.offsettedTH(index));
  19112. }
  19113. /**
  19114. * @param index
  19115. * @returns {Number}
  19116. */
  19117. }, {
  19118. key: "sourceColumnToVisibleRowHeadedColumn",
  19119. value: function sourceColumnToVisibleRowHeadedColumn(index) {
  19120. return this.unOffsettedTH(this.sourceToRendered(index));
  19121. }
  19122. }]);
  19123. return ColumnFilter;
  19124. }();
  19125. exports.default = ColumnFilter;
  19126. /***/ }),
  19127. /* 178 */
  19128. /***/ (function(module, exports, __webpack_require__) {
  19129. "use strict";
  19130. exports.__esModule = true;
  19131. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  19132. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  19133. /**
  19134. * @class RowFilter
  19135. */
  19136. var RowFilter = function () {
  19137. /**
  19138. * @param {Number} offset
  19139. * @param {Number} total
  19140. * @param {Number} countTH
  19141. */
  19142. function RowFilter(offset, total, countTH) {
  19143. _classCallCheck(this, RowFilter);
  19144. this.offset = offset;
  19145. this.total = total;
  19146. this.countTH = countTH;
  19147. }
  19148. /**
  19149. * @param index
  19150. * @returns {Number}
  19151. */
  19152. _createClass(RowFilter, [{
  19153. key: "offsetted",
  19154. value: function offsetted(index) {
  19155. return index + this.offset;
  19156. }
  19157. /**
  19158. * @param index
  19159. * @returns {Number}
  19160. */
  19161. }, {
  19162. key: "unOffsetted",
  19163. value: function unOffsetted(index) {
  19164. return index - this.offset;
  19165. }
  19166. /**
  19167. * @param index
  19168. * @returns {Number}
  19169. */
  19170. }, {
  19171. key: "renderedToSource",
  19172. value: function renderedToSource(index) {
  19173. return this.offsetted(index);
  19174. }
  19175. /**
  19176. * @param index
  19177. * @returns {Number}
  19178. */
  19179. }, {
  19180. key: "sourceToRendered",
  19181. value: function sourceToRendered(index) {
  19182. return this.unOffsetted(index);
  19183. }
  19184. /**
  19185. * @param index
  19186. * @returns {Number}
  19187. */
  19188. }, {
  19189. key: "offsettedTH",
  19190. value: function offsettedTH(index) {
  19191. return index - this.countTH;
  19192. }
  19193. /**
  19194. * @param index
  19195. * @returns {Number}
  19196. */
  19197. }, {
  19198. key: "unOffsettedTH",
  19199. value: function unOffsettedTH(index) {
  19200. return index + this.countTH;
  19201. }
  19202. /**
  19203. * @param index
  19204. * @returns {Number}
  19205. */
  19206. }, {
  19207. key: "visibleColHeadedRowToSourceRow",
  19208. value: function visibleColHeadedRowToSourceRow(index) {
  19209. return this.renderedToSource(this.offsettedTH(index));
  19210. }
  19211. /**
  19212. * @param index
  19213. * @returns {Number}
  19214. */
  19215. }, {
  19216. key: "sourceRowToVisibleColHeadedRow",
  19217. value: function sourceRowToVisibleColHeadedRow(index) {
  19218. return this.unOffsettedTH(this.sourceToRendered(index));
  19219. }
  19220. }]);
  19221. return RowFilter;
  19222. }();
  19223. exports.default = RowFilter;
  19224. /***/ }),
  19225. /* 179 */
  19226. /***/ (function(module, exports, __webpack_require__) {
  19227. "use strict";
  19228. exports.__esModule = true;
  19229. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  19230. var _element = __webpack_require__(0);
  19231. var _object = __webpack_require__(2);
  19232. var _string = __webpack_require__(36);
  19233. var _event = __webpack_require__(299);
  19234. var _event2 = _interopRequireDefault(_event);
  19235. var _overlays = __webpack_require__(300);
  19236. var _overlays2 = _interopRequireDefault(_overlays);
  19237. var _scroll = __webpack_require__(301);
  19238. var _scroll2 = _interopRequireDefault(_scroll);
  19239. var _settings = __webpack_require__(302);
  19240. var _settings2 = _interopRequireDefault(_settings);
  19241. var _table = __webpack_require__(303);
  19242. var _table2 = _interopRequireDefault(_table);
  19243. var _viewport = __webpack_require__(305);
  19244. var _viewport2 = _interopRequireDefault(_viewport);
  19245. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  19246. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  19247. /**
  19248. * @class Walkontable
  19249. */
  19250. var Walkontable = function () {
  19251. /**
  19252. * @param {Object} settings
  19253. */
  19254. function Walkontable(settings) {
  19255. _classCallCheck(this, Walkontable);
  19256. var originalHeaders = [];
  19257. // this is the namespace for global events
  19258. this.guid = 'wt_' + (0, _string.randomString)();
  19259. // bootstrap from settings
  19260. if (settings.cloneSource) {
  19261. this.cloneSource = settings.cloneSource;
  19262. this.cloneOverlay = settings.cloneOverlay;
  19263. this.wtSettings = settings.cloneSource.wtSettings;
  19264. this.wtTable = new _table2.default(this, settings.table, settings.wtRootElement);
  19265. this.wtScroll = new _scroll2.default(this);
  19266. this.wtViewport = settings.cloneSource.wtViewport;
  19267. this.wtEvent = new _event2.default(this);
  19268. this.selections = this.cloneSource.selections;
  19269. } else {
  19270. this.wtSettings = new _settings2.default(this, settings);
  19271. this.wtTable = new _table2.default(this, settings.table);
  19272. this.wtScroll = new _scroll2.default(this);
  19273. this.wtViewport = new _viewport2.default(this);
  19274. this.wtEvent = new _event2.default(this);
  19275. this.selections = this.getSetting('selections');
  19276. this.wtOverlays = new _overlays2.default(this);
  19277. this.exportSettingsAsClassNames();
  19278. }
  19279. // find original headers
  19280. if (this.wtTable.THEAD.childNodes.length && this.wtTable.THEAD.childNodes[0].childNodes.length) {
  19281. for (var c = 0, clen = this.wtTable.THEAD.childNodes[0].childNodes.length; c < clen; c++) {
  19282. originalHeaders.push(this.wtTable.THEAD.childNodes[0].childNodes[c].innerHTML);
  19283. }
  19284. if (!this.getSetting('columnHeaders').length) {
  19285. this.update('columnHeaders', [function (column, TH) {
  19286. (0, _element.fastInnerText)(TH, originalHeaders[column]);
  19287. }]);
  19288. }
  19289. }
  19290. this.drawn = false;
  19291. this.drawInterrupted = false;
  19292. }
  19293. /**
  19294. * Force rerender of Walkontable
  19295. *
  19296. * @param {Boolean} [fastDraw=false] When `true`, try to refresh only the positions of borders without rerendering
  19297. * the data. It will only work if Table.draw() does not force
  19298. * rendering anyway
  19299. * @returns {Walkontable}
  19300. */
  19301. _createClass(Walkontable, [{
  19302. key: 'draw',
  19303. value: function draw() {
  19304. var fastDraw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  19305. this.drawInterrupted = false;
  19306. if (!fastDraw && !(0, _element.isVisible)(this.wtTable.TABLE)) {
  19307. // draw interrupted because TABLE is not visible
  19308. this.drawInterrupted = true;
  19309. } else {
  19310. this.wtTable.draw(fastDraw);
  19311. }
  19312. return this;
  19313. }
  19314. /**
  19315. * Returns the TD at coords. If topmost is set to true, returns TD from the topmost overlay layer,
  19316. * if not set or set to false, returns TD from the master table.
  19317. *
  19318. * @param {CellCoords} coords
  19319. * @param {Boolean} [topmost=false]
  19320. * @returns {Object}
  19321. */
  19322. }, {
  19323. key: 'getCell',
  19324. value: function getCell(coords) {
  19325. var topmost = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  19326. if (!topmost) {
  19327. return this.wtTable.getCell(coords);
  19328. }
  19329. var totalRows = this.wtSettings.getSetting('totalRows');
  19330. var fixedRowsTop = this.wtSettings.getSetting('fixedRowsTop');
  19331. var fixedRowsBottom = this.wtSettings.getSetting('fixedRowsBottom');
  19332. var fixedColumns = this.wtSettings.getSetting('fixedColumnsLeft');
  19333. if (coords.row < fixedRowsTop && coords.col < fixedColumns) {
  19334. return this.wtOverlays.topLeftCornerOverlay.clone.wtTable.getCell(coords);
  19335. } else if (coords.row < fixedRowsTop) {
  19336. return this.wtOverlays.topOverlay.clone.wtTable.getCell(coords);
  19337. } else if (coords.col < fixedColumns && coords.row >= totalRows - fixedRowsBottom) {
  19338. if (this.wtOverlays.bottomLeftCornerOverlay && this.wtOverlays.bottomLeftCornerOverlay.clone) {
  19339. return this.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.getCell(coords);
  19340. }
  19341. } else if (coords.col < fixedColumns) {
  19342. return this.wtOverlays.leftOverlay.clone.wtTable.getCell(coords);
  19343. } else if (coords.row < totalRows && coords.row > totalRows - fixedRowsBottom) {
  19344. if (this.wtOverlays.bottomOverlay && this.wtOverlays.bottomOverlay.clone) {
  19345. return this.wtOverlays.bottomOverlay.clone.wtTable.getCell(coords);
  19346. }
  19347. }
  19348. return this.wtTable.getCell(coords);
  19349. }
  19350. /**
  19351. * @param {Object} settings
  19352. * @param {*} value
  19353. * @returns {Walkontable}
  19354. */
  19355. }, {
  19356. key: 'update',
  19357. value: function update(settings, value) {
  19358. return this.wtSettings.update(settings, value);
  19359. }
  19360. /**
  19361. * Scroll the viewport to a row at the given index in the data source
  19362. *
  19363. * @param {Number} row
  19364. * @returns {Walkontable}
  19365. */
  19366. }, {
  19367. key: 'scrollVertical',
  19368. value: function scrollVertical(row) {
  19369. this.wtOverlays.topOverlay.scrollTo(row);
  19370. this.getSetting('onScrollVertically');
  19371. return this;
  19372. }
  19373. /**
  19374. * Scroll the viewport to a column at the given index in the data source
  19375. *
  19376. * @param {Number} column
  19377. * @returns {Walkontable}
  19378. */
  19379. }, {
  19380. key: 'scrollHorizontal',
  19381. value: function scrollHorizontal(column) {
  19382. this.wtOverlays.leftOverlay.scrollTo(column);
  19383. this.getSetting('onScrollHorizontally');
  19384. return this;
  19385. }
  19386. /**
  19387. * Scrolls the viewport to a cell (rerenders if needed)
  19388. *
  19389. * @param {CellCoords} coords
  19390. * @returns {Walkontable}
  19391. */
  19392. }, {
  19393. key: 'scrollViewport',
  19394. value: function scrollViewport(coords) {
  19395. this.wtScroll.scrollViewport(coords);
  19396. return this;
  19397. }
  19398. /**
  19399. * @returns {Array}
  19400. */
  19401. }, {
  19402. key: 'getViewport',
  19403. value: function getViewport() {
  19404. return [this.wtTable.getFirstVisibleRow(), this.wtTable.getFirstVisibleColumn(), this.wtTable.getLastVisibleRow(), this.wtTable.getLastVisibleColumn()];
  19405. }
  19406. /**
  19407. * Get overlay name
  19408. *
  19409. * @returns {String}
  19410. */
  19411. }, {
  19412. key: 'getOverlayName',
  19413. value: function getOverlayName() {
  19414. return this.cloneOverlay ? this.cloneOverlay.type : 'master';
  19415. }
  19416. /**
  19417. * Check overlay type of this Walkontable instance.
  19418. *
  19419. * @param {String} name Clone type @see {Overlay.CLONE_TYPES}.
  19420. * @returns {Boolean}
  19421. */
  19422. }, {
  19423. key: 'isOverlayName',
  19424. value: function isOverlayName(name) {
  19425. if (this.cloneOverlay) {
  19426. return this.cloneOverlay.type === name;
  19427. }
  19428. return false;
  19429. }
  19430. /**
  19431. * Export settings as class names added to the parent element of the table.
  19432. */
  19433. }, {
  19434. key: 'exportSettingsAsClassNames',
  19435. value: function exportSettingsAsClassNames() {
  19436. var _this = this;
  19437. var toExport = {
  19438. rowHeaders: ['array'],
  19439. columnHeaders: ['array']
  19440. };
  19441. var allClassNames = [];
  19442. var newClassNames = [];
  19443. (0, _object.objectEach)(toExport, function (optionType, key) {
  19444. if (optionType.indexOf('array') > -1 && _this.getSetting(key).length) {
  19445. newClassNames.push('ht' + (0, _string.toUpperCaseFirst)(key));
  19446. }
  19447. allClassNames.push('ht' + (0, _string.toUpperCaseFirst)(key));
  19448. });
  19449. (0, _element.removeClass)(this.wtTable.wtRootElement.parentNode, allClassNames);
  19450. (0, _element.addClass)(this.wtTable.wtRootElement.parentNode, newClassNames);
  19451. }
  19452. /**
  19453. * Get/Set Walkontable instance setting
  19454. *
  19455. * @param {String} key
  19456. * @param {*} [param1]
  19457. * @param {*} [param2]
  19458. * @param {*} [param3]
  19459. * @param {*} [param4]
  19460. * @returns {*}
  19461. */
  19462. }, {
  19463. key: 'getSetting',
  19464. value: function getSetting(key, param1, param2, param3, param4) {
  19465. // this is faster than .apply - https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips
  19466. return this.wtSettings.getSetting(key, param1, param2, param3, param4);
  19467. }
  19468. /**
  19469. * Checks if setting exists
  19470. *
  19471. * @param {String} key
  19472. * @returns {Boolean}
  19473. */
  19474. }, {
  19475. key: 'hasSetting',
  19476. value: function hasSetting(key) {
  19477. return this.wtSettings.has(key);
  19478. }
  19479. /**
  19480. * Destroy instance
  19481. */
  19482. }, {
  19483. key: 'destroy',
  19484. value: function destroy() {
  19485. this.wtOverlays.destroy();
  19486. this.wtEvent.destroy();
  19487. }
  19488. }]);
  19489. return Walkontable;
  19490. }();
  19491. exports.default = Walkontable;
  19492. /***/ }),
  19493. /* 180 */
  19494. /***/ (function(module, exports) {
  19495. /***/ }),
  19496. /* 181 */
  19497. /***/ (function(module, exports) {
  19498. /***/ }),
  19499. /* 182 */
  19500. /***/ (function(module, exports) {
  19501. /***/ }),
  19502. /* 183 */
  19503. /***/ (function(module, exports) {
  19504. /***/ }),
  19505. /* 184 */
  19506. /***/ (function(module, exports) {
  19507. /***/ }),
  19508. /* 185 */
  19509. /***/ (function(module, exports) {
  19510. /***/ }),
  19511. /* 186 */
  19512. /***/ (function(module, exports) {
  19513. /***/ }),
  19514. /* 187 */
  19515. /***/ (function(module, exports) {
  19516. /***/ }),
  19517. /* 188 */
  19518. /***/ (function(module, exports) {
  19519. /***/ }),
  19520. /* 189 */
  19521. /***/ (function(module, exports) {
  19522. /***/ }),
  19523. /* 190 */
  19524. /***/ (function(module, exports) {
  19525. /***/ }),
  19526. /* 191 */
  19527. /***/ (function(module, exports) {
  19528. /***/ }),
  19529. /* 192 */
  19530. /***/ (function(module, exports) {
  19531. /***/ }),
  19532. /* 193 */
  19533. /***/ (function(module, exports) {
  19534. /***/ }),
  19535. /* 194 */
  19536. /***/ (function(module, exports) {
  19537. /***/ }),
  19538. /* 195 */
  19539. /***/ (function(module, exports) {
  19540. /***/ }),
  19541. /* 196 */
  19542. /***/ (function(module, exports) {
  19543. /***/ }),
  19544. /* 197 */
  19545. /***/ (function(module, exports) {
  19546. /***/ }),
  19547. /* 198 */
  19548. /***/ (function(module, exports) {
  19549. /***/ }),
  19550. /* 199 */
  19551. /***/ (function(module, exports) {
  19552. /***/ }),
  19553. /* 200 */
  19554. /***/ (function(module, exports) {
  19555. /***/ }),
  19556. /* 201 */
  19557. /***/ (function(module, exports) {
  19558. /***/ }),
  19559. /* 202 */
  19560. /***/ (function(module, exports) {
  19561. /***/ }),
  19562. /* 203 */
  19563. /***/ (function(module, exports) {
  19564. /***/ }),
  19565. /* 204 */
  19566. /***/ (function(module, exports) {
  19567. /***/ }),
  19568. /* 205 */
  19569. /***/ (function(module, exports) {
  19570. /***/ }),
  19571. /* 206 */
  19572. /***/ (function(module, exports) {
  19573. /***/ }),
  19574. /* 207 */
  19575. /***/ (function(module, exports) {
  19576. /***/ }),
  19577. /* 208 */
  19578. /***/ (function(module, exports) {
  19579. /***/ }),
  19580. /* 209 */
  19581. /***/ (function(module, exports) {
  19582. /***/ }),
  19583. /* 210 */
  19584. /***/ (function(module, exports) {
  19585. /***/ }),
  19586. /* 211 */
  19587. /***/ (function(module, exports) {
  19588. /***/ }),
  19589. /* 212 */
  19590. /***/ (function(module, exports) {
  19591. /***/ }),
  19592. /* 213 */
  19593. /***/ (function(module, exports) {
  19594. /***/ }),
  19595. /* 214 */
  19596. /***/ (function(module, exports) {
  19597. /***/ }),
  19598. /* 215 */
  19599. /***/ (function(module, exports) {
  19600. /***/ }),
  19601. /* 216 */
  19602. /***/ (function(module, exports) {
  19603. /***/ }),
  19604. /* 217 */
  19605. /***/ (function(module, exports) {
  19606. /***/ }),
  19607. /* 218 */
  19608. /***/ (function(module, exports) {
  19609. /***/ }),
  19610. /* 219 */
  19611. /***/ (function(module, exports) {
  19612. /***/ }),
  19613. /* 220 */
  19614. /***/ (function(module, exports) {
  19615. /***/ }),
  19616. /* 221 */
  19617. /***/ (function(module, exports) {
  19618. /***/ }),
  19619. /* 222 */
  19620. /***/ (function(module, exports) {
  19621. /***/ }),
  19622. /* 223 */
  19623. /***/ (function(module, exports) {
  19624. /***/ }),
  19625. /* 224 */
  19626. /***/ (function(module, exports) {
  19627. /***/ }),
  19628. /* 225 */
  19629. /***/ (function(module, exports) {
  19630. /***/ }),
  19631. /* 226 */
  19632. /***/ (function(module, exports) {
  19633. /***/ }),
  19634. /* 227 */
  19635. /***/ (function(module, exports) {
  19636. /***/ }),
  19637. /* 228 */
  19638. /***/ (function(module, exports) {
  19639. /***/ }),
  19640. /* 229 */
  19641. /***/ (function(module, exports) {
  19642. /***/ }),
  19643. /* 230 */
  19644. /***/ (function(module, exports) {
  19645. /***/ }),
  19646. /* 231 */
  19647. /***/ (function(module, exports) {
  19648. /***/ }),
  19649. /* 232 */
  19650. /***/ (function(module, exports) {
  19651. /***/ }),
  19652. /* 233 */
  19653. /***/ (function(module, exports) {
  19654. /***/ }),
  19655. /* 234 */
  19656. /***/ (function(module, exports) {
  19657. /***/ }),
  19658. /* 235 */
  19659. /***/ (function(module, exports) {
  19660. /***/ }),
  19661. /* 236 */
  19662. /***/ (function(module, exports) {
  19663. /***/ }),
  19664. /* 237 */
  19665. /***/ (function(module, exports) {
  19666. /***/ }),
  19667. /* 238 */
  19668. /***/ (function(module, exports) {
  19669. /***/ }),
  19670. /* 239 */
  19671. /***/ (function(module, exports) {
  19672. /***/ }),
  19673. /* 240 */
  19674. /***/ (function(module, exports) {
  19675. /***/ }),
  19676. /* 241 */
  19677. /***/ (function(module, exports) {
  19678. /***/ }),
  19679. /* 242 */
  19680. /***/ (function(module, exports) {
  19681. /***/ }),
  19682. /* 243 */
  19683. /***/ (function(module, exports) {
  19684. /***/ }),
  19685. /* 244 */
  19686. /***/ (function(module, exports) {
  19687. /***/ }),
  19688. /* 245 */
  19689. /***/ (function(module, exports) {
  19690. /***/ }),
  19691. /* 246 */
  19692. /***/ (function(module, exports) {
  19693. /***/ }),
  19694. /* 247 */
  19695. /***/ (function(module, exports) {
  19696. /***/ }),
  19697. /* 248 */
  19698. /***/ (function(module, exports) {
  19699. /***/ }),
  19700. /* 249 */
  19701. /***/ (function(module, exports) {
  19702. /***/ }),
  19703. /* 250 */
  19704. /***/ (function(module, exports) {
  19705. /***/ }),
  19706. /* 251 */
  19707. /***/ (function(module, exports) {
  19708. /***/ }),
  19709. /* 252 */
  19710. /***/ (function(module, exports) {
  19711. /***/ }),
  19712. /* 253 */
  19713. /***/ (function(module, exports) {
  19714. /***/ }),
  19715. /* 254 */
  19716. /***/ (function(module, exports) {
  19717. /***/ }),
  19718. /* 255 */
  19719. /***/ (function(module, exports) {
  19720. /***/ }),
  19721. /* 256 */
  19722. /***/ (function(module, exports) {
  19723. /***/ }),
  19724. /* 257 */
  19725. /***/ (function(module, exports) {
  19726. /***/ }),
  19727. /* 258 */
  19728. /***/ (function(module, exports) {
  19729. /***/ }),
  19730. /* 259 */
  19731. /***/ (function(module, exports) {
  19732. /***/ }),
  19733. /* 260 */
  19734. /***/ (function(module, exports) {
  19735. /***/ }),
  19736. /* 261 */
  19737. /***/ (function(module, exports) {
  19738. /***/ }),
  19739. /* 262 */
  19740. /***/ (function(module, exports) {
  19741. /***/ }),
  19742. /* 263 */
  19743. /***/ (function(module, exports) {
  19744. /***/ }),
  19745. /* 264 */
  19746. /***/ (function(module, exports) {
  19747. /***/ }),
  19748. /* 265 */
  19749. /***/ (function(module, exports) {
  19750. /***/ }),
  19751. /* 266 */
  19752. /***/ (function(module, exports) {
  19753. /***/ }),
  19754. /* 267 */
  19755. /***/ (function(module, exports) {
  19756. /***/ }),
  19757. /* 268 */
  19758. /***/ (function(module, exports) {
  19759. /***/ }),
  19760. /* 269 */
  19761. /***/ (function(module, exports) {
  19762. /***/ }),
  19763. /* 270 */
  19764. /***/ (function(module, exports) {
  19765. /***/ }),
  19766. /* 271 */
  19767. /***/ (function(module, exports) {
  19768. /***/ }),
  19769. /* 272 */
  19770. /***/ (function(module, exports) {
  19771. /***/ }),
  19772. /* 273 */
  19773. /***/ (function(module, exports) {
  19774. /***/ }),
  19775. /* 274 */
  19776. /***/ (function(module, exports) {
  19777. /***/ }),
  19778. /* 275 */
  19779. /***/ (function(module, exports) {
  19780. /***/ }),
  19781. /* 276 */
  19782. /***/ (function(module, exports) {
  19783. /***/ }),
  19784. /* 277 */
  19785. /***/ (function(module, exports) {
  19786. /***/ }),
  19787. /* 278 */
  19788. /***/ (function(module, exports) {
  19789. /***/ }),
  19790. /* 279 */
  19791. /***/ (function(module, exports) {
  19792. /***/ }),
  19793. /* 280 */
  19794. /***/ (function(module, exports) {
  19795. /***/ }),
  19796. /* 281 */
  19797. /***/ (function(module, exports) {
  19798. /***/ }),
  19799. /* 282 */
  19800. /***/ (function(module, exports) {
  19801. /***/ }),
  19802. /* 283 */
  19803. /***/ (function(module, exports) {
  19804. /***/ }),
  19805. /* 284 */
  19806. /***/ (function(module, exports) {
  19807. /***/ }),
  19808. /* 285 */
  19809. /***/ (function(module, exports) {
  19810. /***/ }),
  19811. /* 286 */
  19812. /***/ (function(module, exports) {
  19813. /***/ }),
  19814. /* 287 */
  19815. /***/ (function(module, exports) {
  19816. /***/ }),
  19817. /* 288 */
  19818. /***/ (function(module, exports) {
  19819. /***/ }),
  19820. /* 289 */
  19821. /***/ (function(module, exports) {
  19822. /***/ }),
  19823. /* 290 */
  19824. /***/ (function(module, exports) {
  19825. /***/ }),
  19826. /* 291 */
  19827. /***/ (function(module, exports) {
  19828. /***/ }),
  19829. /* 292 */
  19830. /***/ (function(module, exports) {
  19831. /***/ }),
  19832. /* 293 */
  19833. /***/ (function(module, exports) {
  19834. /***/ }),
  19835. /* 294 */
  19836. /***/ (function(module, exports) {
  19837. /***/ }),
  19838. /* 295 */
  19839. /***/ (function(module, exports) {
  19840. /***/ }),
  19841. /* 296 */
  19842. /***/ (function(module, exports) {
  19843. /***/ }),
  19844. /* 297 */
  19845. /***/ (function(module, exports) {
  19846. /***/ }),
  19847. /* 298 */
  19848. /***/ (function(module, exports) {
  19849. /***/ }),
  19850. /* 299 */
  19851. /***/ (function(module, exports, __webpack_require__) {
  19852. "use strict";
  19853. exports.__esModule = true;
  19854. var _element = __webpack_require__(0);
  19855. var _function = __webpack_require__(43);
  19856. var _browser = __webpack_require__(27);
  19857. var _eventManager = __webpack_require__(6);
  19858. var _eventManager2 = _interopRequireDefault(_eventManager);
  19859. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  19860. /**
  19861. *
  19862. */
  19863. function Event(instance) {
  19864. var that = this;
  19865. var eventManager = new _eventManager2.default(instance);
  19866. var selectedCellBeforeTouchEnd = void 0;
  19867. this.instance = instance;
  19868. var dblClickOrigin = [null, null];
  19869. this.dblClickTimeout = [null, null];
  19870. var onMouseDown = function onMouseDown(event) {
  19871. var activeElement = document.activeElement;
  19872. var getParentNode = (0, _function.partial)(_element.getParent, event.realTarget);
  19873. var realTarget = event.realTarget;
  19874. // ignore focusable element from mouse down processing (https://github.com/handsontable/handsontable/issues/3555)
  19875. if (realTarget === activeElement || getParentNode(0) === activeElement || getParentNode(1) === activeElement) {
  19876. return;
  19877. }
  19878. var cell = that.parentCell(realTarget);
  19879. if ((0, _element.hasClass)(realTarget, 'corner')) {
  19880. that.instance.getSetting('onCellCornerMouseDown', event, realTarget);
  19881. } else if (cell.TD) {
  19882. if (that.instance.hasSetting('onCellMouseDown')) {
  19883. that.instance.getSetting('onCellMouseDown', event, cell.coords, cell.TD, that.instance);
  19884. }
  19885. }
  19886. if (event.button !== 2) {
  19887. // if not right mouse button
  19888. if (cell.TD) {
  19889. dblClickOrigin[0] = cell.TD;
  19890. clearTimeout(that.dblClickTimeout[0]);
  19891. that.dblClickTimeout[0] = setTimeout(function () {
  19892. dblClickOrigin[0] = null;
  19893. }, 1000);
  19894. }
  19895. }
  19896. };
  19897. var onTouchMove = function onTouchMove(event) {
  19898. that.instance.touchMoving = true;
  19899. };
  19900. var onTouchStart = function onTouchStart(event) {
  19901. eventManager.addEventListener(this, 'touchmove', onTouchMove);
  19902. // Prevent cell selection when scrolling with touch event - not the best solution performance-wise
  19903. that.checkIfTouchMove = setTimeout(function () {
  19904. if (that.instance.touchMoving === true) {
  19905. that.instance.touchMoving = void 0;
  19906. eventManager.removeEventListener('touchmove', onTouchMove, false);
  19907. }
  19908. onMouseDown(event);
  19909. }, 30);
  19910. };
  19911. var onMouseOver = function onMouseOver(event) {
  19912. var table, td, mainWOT;
  19913. if (that.instance.hasSetting('onCellMouseOver')) {
  19914. table = that.instance.wtTable.TABLE;
  19915. td = (0, _element.closestDown)(event.realTarget, ['TD', 'TH'], table);
  19916. mainWOT = that.instance.cloneSource || that.instance;
  19917. if (td && td !== mainWOT.lastMouseOver && (0, _element.isChildOf)(td, table)) {
  19918. mainWOT.lastMouseOver = td;
  19919. that.instance.getSetting('onCellMouseOver', event, that.instance.wtTable.getCoords(td), td, that.instance);
  19920. }
  19921. }
  19922. };
  19923. var onMouseOut = function onMouseOut(event) {
  19924. var table = void 0;
  19925. var lastTD = void 0;
  19926. var nextTD = void 0;
  19927. if (that.instance.hasSetting('onCellMouseOut')) {
  19928. table = that.instance.wtTable.TABLE;
  19929. lastTD = (0, _element.closestDown)(event.realTarget, ['TD', 'TH'], table);
  19930. nextTD = (0, _element.closestDown)(event.relatedTarget, ['TD', 'TH'], table);
  19931. if (lastTD && lastTD !== nextTD && (0, _element.isChildOf)(lastTD, table)) {
  19932. that.instance.getSetting('onCellMouseOut', event, that.instance.wtTable.getCoords(lastTD), lastTD, that.instance);
  19933. }
  19934. }
  19935. };
  19936. var onMouseUp = function onMouseUp(event) {
  19937. if (event.button !== 2) {
  19938. // if not right mouse button
  19939. var cell = that.parentCell(event.realTarget);
  19940. if (cell.TD === dblClickOrigin[0] && cell.TD === dblClickOrigin[1]) {
  19941. if ((0, _element.hasClass)(event.realTarget, 'corner')) {
  19942. that.instance.getSetting('onCellCornerDblClick', event, cell.coords, cell.TD, that.instance);
  19943. } else {
  19944. that.instance.getSetting('onCellDblClick', event, cell.coords, cell.TD, that.instance);
  19945. }
  19946. dblClickOrigin[0] = null;
  19947. dblClickOrigin[1] = null;
  19948. } else if (cell.TD === dblClickOrigin[0]) {
  19949. that.instance.getSetting('onCellMouseUp', event, cell.coords, cell.TD, that.instance);
  19950. dblClickOrigin[1] = cell.TD;
  19951. clearTimeout(that.dblClickTimeout[1]);
  19952. that.dblClickTimeout[1] = setTimeout(function () {
  19953. dblClickOrigin[1] = null;
  19954. }, 500);
  19955. } else if (cell.TD && that.instance.hasSetting('onCellMouseUp')) {
  19956. that.instance.getSetting('onCellMouseUp', event, cell.coords, cell.TD, that.instance);
  19957. }
  19958. }
  19959. };
  19960. var selectedCellWasTouched = function selectedCellWasTouched(touchTarget) {
  19961. var cellUnderFinger = that.parentCell(touchTarget);
  19962. var coordsOfCellUnderFinger = cellUnderFinger.coords;
  19963. if (selectedCellBeforeTouchEnd && coordsOfCellUnderFinger) {
  19964. var _ref = [coordsOfCellUnderFinger.row, selectedCellBeforeTouchEnd.from.row],
  19965. rowTouched = _ref[0],
  19966. rowSelected = _ref[1];
  19967. var _ref2 = [coordsOfCellUnderFinger.col, selectedCellBeforeTouchEnd.from.col],
  19968. colTouched = _ref2[0],
  19969. colSelected = _ref2[1];
  19970. return rowTouched === rowSelected && colTouched === colSelected;
  19971. }
  19972. return false;
  19973. };
  19974. var onTouchEnd = function onTouchEnd(event) {
  19975. var excludeTags = ['A', 'BUTTON', 'INPUT'];
  19976. var target = event.target;
  19977. // touched link which was placed inside a cell (a cell with DOM `a` element) WILL NOT trigger the below function calls
  19978. // and as consequence will behave as standard (open the link).
  19979. if (selectedCellWasTouched(target) === false || excludeTags.includes(target.tagName) === false) {
  19980. event.preventDefault();
  19981. onMouseUp(event);
  19982. }
  19983. };
  19984. eventManager.addEventListener(this.instance.wtTable.holder, 'mousedown', onMouseDown);
  19985. eventManager.addEventListener(this.instance.wtTable.TABLE, 'mouseover', onMouseOver);
  19986. eventManager.addEventListener(this.instance.wtTable.TABLE, 'mouseout', onMouseOut);
  19987. eventManager.addEventListener(this.instance.wtTable.holder, 'mouseup', onMouseUp);
  19988. // check if full HOT instance, or detached WOT AND run on mobile device
  19989. if (this.instance.wtTable.holder.parentNode.parentNode && (0, _browser.isMobileBrowser)() && !that.instance.wtTable.isWorkingOnClone()) {
  19990. var classSelector = '.' + this.instance.wtTable.holder.parentNode.className.split(' ').join('.');
  19991. eventManager.addEventListener(this.instance.wtTable.holder, 'touchstart', function (event) {
  19992. selectedCellBeforeTouchEnd = instance.selections.getCell().cellRange;
  19993. that.instance.touchApplied = true;
  19994. if ((0, _element.isChildOf)(event.target, classSelector)) {
  19995. onTouchStart.call(event.target, event);
  19996. }
  19997. });
  19998. eventManager.addEventListener(this.instance.wtTable.holder, 'touchend', function (event) {
  19999. that.instance.touchApplied = false;
  20000. if ((0, _element.isChildOf)(event.target, classSelector)) {
  20001. onTouchEnd.call(event.target, event);
  20002. }
  20003. });
  20004. if (!that.instance.momentumScrolling) {
  20005. that.instance.momentumScrolling = {};
  20006. }
  20007. eventManager.addEventListener(this.instance.wtTable.holder, 'scroll', function (event) {
  20008. clearTimeout(that.instance.momentumScrolling._timeout);
  20009. if (!that.instance.momentumScrolling.ongoing) {
  20010. that.instance.getSetting('onBeforeTouchScroll');
  20011. }
  20012. that.instance.momentumScrolling.ongoing = true;
  20013. that.instance.momentumScrolling._timeout = setTimeout(function () {
  20014. if (!that.instance.touchApplied) {
  20015. that.instance.momentumScrolling.ongoing = false;
  20016. that.instance.getSetting('onAfterMomentumScroll');
  20017. }
  20018. }, 200);
  20019. });
  20020. }
  20021. eventManager.addEventListener(window, 'resize', function () {
  20022. if (that.instance.getSetting('stretchH') !== 'none') {
  20023. that.instance.draw();
  20024. }
  20025. });
  20026. this.destroy = function () {
  20027. clearTimeout(this.dblClickTimeout[0]);
  20028. clearTimeout(this.dblClickTimeout[1]);
  20029. eventManager.destroy();
  20030. };
  20031. }
  20032. Event.prototype.parentCell = function (elem) {
  20033. var cell = {};
  20034. var TABLE = this.instance.wtTable.TABLE;
  20035. var TD = (0, _element.closestDown)(elem, ['TD', 'TH'], TABLE);
  20036. if (TD) {
  20037. cell.coords = this.instance.wtTable.getCoords(TD);
  20038. cell.TD = TD;
  20039. } else if ((0, _element.hasClass)(elem, 'wtBorder') && (0, _element.hasClass)(elem, 'current')) {
  20040. cell.coords = this.instance.selections.getCell().cellRange.highlight;
  20041. cell.TD = this.instance.wtTable.getCell(cell.coords);
  20042. } else if ((0, _element.hasClass)(elem, 'wtBorder') && (0, _element.hasClass)(elem, 'area')) {
  20043. if (this.instance.selections.createOrGetArea().cellRange) {
  20044. cell.coords = this.instance.selections.createOrGetArea().cellRange.to;
  20045. cell.TD = this.instance.wtTable.getCell(cell.coords);
  20046. }
  20047. }
  20048. return cell;
  20049. };
  20050. exports.default = Event;
  20051. /***/ }),
  20052. /* 300 */
  20053. /***/ (function(module, exports, __webpack_require__) {
  20054. "use strict";
  20055. exports.__esModule = true;
  20056. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  20057. var _element = __webpack_require__(0);
  20058. var _array = __webpack_require__(1);
  20059. var _unicode = __webpack_require__(21);
  20060. var _browser = __webpack_require__(27);
  20061. var _eventManager = __webpack_require__(6);
  20062. var _eventManager2 = _interopRequireDefault(_eventManager);
  20063. var _base = __webpack_require__(35);
  20064. var _base2 = _interopRequireDefault(_base);
  20065. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  20066. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  20067. /**
  20068. * @class Overlays
  20069. */
  20070. var Overlays = function () {
  20071. /**
  20072. * @param {Walkontable} wotInstance
  20073. */
  20074. function Overlays(wotInstance) {
  20075. _classCallCheck(this, Overlays);
  20076. /**
  20077. * Sometimes `line-height` might be set to 'normal'. In that case, a default `font-size` should be multiplied by roughly 1.2.
  20078. * https://developer.mozilla.org/pl/docs/Web/CSS/line-height#Values
  20079. */
  20080. var BODY_LINE_HEIGHT = parseInt(getComputedStyle(document.body).lineHeight, 10);
  20081. var FALLBACK_BODY_LINE_HEIGHT = parseInt(getComputedStyle(document.body).fontSize, 10) * 1.2;
  20082. this.wot = wotInstance;
  20083. // legacy support
  20084. this.instance = this.wot;
  20085. this.eventManager = new _eventManager2.default(this.wot);
  20086. this.wot.update('scrollbarWidth', (0, _element.getScrollbarWidth)());
  20087. this.wot.update('scrollbarHeight', (0, _element.getScrollbarWidth)());
  20088. this.scrollableElement = (0, _element.getScrollableElement)(this.wot.wtTable.TABLE);
  20089. this.prepareOverlays();
  20090. this.destroyed = false;
  20091. this.keyPressed = false;
  20092. this.spreaderLastSize = {
  20093. width: null,
  20094. height: null
  20095. };
  20096. this.overlayScrollPositions = {
  20097. master: {
  20098. top: 0,
  20099. left: 0
  20100. },
  20101. top: {
  20102. top: null,
  20103. left: 0
  20104. },
  20105. bottom: {
  20106. top: null,
  20107. left: 0
  20108. },
  20109. left: {
  20110. top: 0,
  20111. left: null
  20112. }
  20113. };
  20114. this.pendingScrollCallbacks = {
  20115. master: {
  20116. top: 0,
  20117. left: 0
  20118. },
  20119. top: {
  20120. left: 0
  20121. },
  20122. bottom: {
  20123. left: 0
  20124. },
  20125. left: {
  20126. top: 0
  20127. }
  20128. };
  20129. this.verticalScrolling = false;
  20130. this.horizontalScrolling = false;
  20131. this.delegatedScrollCallback = false;
  20132. this.registeredListeners = [];
  20133. this.browserLineHeight = BODY_LINE_HEIGHT || FALLBACK_BODY_LINE_HEIGHT;
  20134. this.registerListeners();
  20135. }
  20136. /**
  20137. * Prepare overlays based on user settings.
  20138. *
  20139. * @returns {Boolean} Returns `true` if changes applied to overlay needs scroll synchronization.
  20140. */
  20141. _createClass(Overlays, [{
  20142. key: 'prepareOverlays',
  20143. value: function prepareOverlays() {
  20144. var syncScroll = false;
  20145. if (this.topOverlay) {
  20146. syncScroll = this.topOverlay.updateStateOfRendering() || syncScroll;
  20147. } else {
  20148. this.topOverlay = _base2.default.createOverlay(_base2.default.CLONE_TOP, this.wot);
  20149. }
  20150. if (!_base2.default.hasOverlay(_base2.default.CLONE_BOTTOM)) {
  20151. this.bottomOverlay = {
  20152. needFullRender: false,
  20153. updateStateOfRendering: function updateStateOfRendering() {
  20154. return false;
  20155. }
  20156. };
  20157. }
  20158. if (!_base2.default.hasOverlay(_base2.default.CLONE_BOTTOM_LEFT_CORNER)) {
  20159. this.bottomLeftCornerOverlay = {
  20160. needFullRender: false,
  20161. updateStateOfRendering: function updateStateOfRendering() {
  20162. return false;
  20163. }
  20164. };
  20165. }
  20166. if (this.bottomOverlay) {
  20167. syncScroll = this.bottomOverlay.updateStateOfRendering() || syncScroll;
  20168. } else {
  20169. this.bottomOverlay = _base2.default.createOverlay(_base2.default.CLONE_BOTTOM, this.wot);
  20170. }
  20171. if (this.leftOverlay) {
  20172. syncScroll = this.leftOverlay.updateStateOfRendering() || syncScroll;
  20173. } else {
  20174. this.leftOverlay = _base2.default.createOverlay(_base2.default.CLONE_LEFT, this.wot);
  20175. }
  20176. if (this.topOverlay.needFullRender && this.leftOverlay.needFullRender) {
  20177. if (this.topLeftCornerOverlay) {
  20178. syncScroll = this.topLeftCornerOverlay.updateStateOfRendering() || syncScroll;
  20179. } else {
  20180. this.topLeftCornerOverlay = _base2.default.createOverlay(_base2.default.CLONE_TOP_LEFT_CORNER, this.wot);
  20181. }
  20182. }
  20183. if (this.bottomOverlay.needFullRender && this.leftOverlay.needFullRender) {
  20184. if (this.bottomLeftCornerOverlay) {
  20185. syncScroll = this.bottomLeftCornerOverlay.updateStateOfRendering() || syncScroll;
  20186. } else {
  20187. this.bottomLeftCornerOverlay = _base2.default.createOverlay(_base2.default.CLONE_BOTTOM_LEFT_CORNER, this.wot);
  20188. }
  20189. }
  20190. if (this.wot.getSetting('debug') && !this.debug) {
  20191. this.debug = _base2.default.createOverlay(_base2.default.CLONE_DEBUG, this.wot);
  20192. }
  20193. return syncScroll;
  20194. }
  20195. /**
  20196. * Refresh and redraw table
  20197. */
  20198. }, {
  20199. key: 'refreshAll',
  20200. value: function refreshAll() {
  20201. if (!this.wot.drawn) {
  20202. return;
  20203. }
  20204. if (!this.wot.wtTable.holder.parentNode) {
  20205. // Walkontable was detached from DOM, but this handler was not removed
  20206. this.destroy();
  20207. return;
  20208. }
  20209. this.wot.draw(true);
  20210. if (this.verticalScrolling) {
  20211. this.leftOverlay.onScroll();
  20212. }
  20213. if (this.horizontalScrolling) {
  20214. this.topOverlay.onScroll();
  20215. }
  20216. this.verticalScrolling = false;
  20217. this.horizontalScrolling = false;
  20218. }
  20219. /**
  20220. * Register all necessary event listeners.
  20221. */
  20222. }, {
  20223. key: 'registerListeners',
  20224. value: function registerListeners() {
  20225. var _this = this;
  20226. var topOverlayScrollable = this.topOverlay.mainTableScrollableElement;
  20227. var leftOverlayScrollable = this.leftOverlay.mainTableScrollableElement;
  20228. var listenersToRegister = [];
  20229. listenersToRegister.push([document.documentElement, 'keydown', function (event) {
  20230. return _this.onKeyDown(event);
  20231. }]);
  20232. listenersToRegister.push([document.documentElement, 'keyup', function () {
  20233. return _this.onKeyUp();
  20234. }]);
  20235. listenersToRegister.push([document, 'visibilitychange', function () {
  20236. return _this.onKeyUp();
  20237. }]);
  20238. listenersToRegister.push([topOverlayScrollable, 'scroll', function (event) {
  20239. return _this.onTableScroll(event);
  20240. }]);
  20241. if (topOverlayScrollable !== leftOverlayScrollable) {
  20242. listenersToRegister.push([leftOverlayScrollable, 'scroll', function (event) {
  20243. return _this.onTableScroll(event);
  20244. }]);
  20245. }
  20246. var isHighPixelRatio = window.devicePixelRatio && window.devicePixelRatio > 1;
  20247. if (isHighPixelRatio || !(0, _browser.isChrome)()) {
  20248. listenersToRegister.push([this.instance.wtTable.wtRootElement.parentNode, 'wheel', function (event) {
  20249. return _this.onCloneWheel(event);
  20250. }]);
  20251. } else {
  20252. if (this.topOverlay.needFullRender) {
  20253. listenersToRegister.push([this.topOverlay.clone.wtTable.holder, 'wheel', function (event) {
  20254. return _this.onCloneWheel(event);
  20255. }]);
  20256. }
  20257. if (this.bottomOverlay.needFullRender) {
  20258. listenersToRegister.push([this.bottomOverlay.clone.wtTable.holder, 'wheel', function (event) {
  20259. return _this.onCloneWheel(event);
  20260. }]);
  20261. }
  20262. if (this.leftOverlay.needFullRender) {
  20263. listenersToRegister.push([this.leftOverlay.clone.wtTable.holder, 'wheel', function (event) {
  20264. return _this.onCloneWheel(event);
  20265. }]);
  20266. }
  20267. if (this.topLeftCornerOverlay && this.topLeftCornerOverlay.needFullRender) {
  20268. listenersToRegister.push([this.topLeftCornerOverlay.clone.wtTable.holder, 'wheel', function (event) {
  20269. return _this.onCloneWheel(event);
  20270. }]);
  20271. }
  20272. if (this.bottomLeftCornerOverlay && this.bottomLeftCornerOverlay.needFullRender) {
  20273. listenersToRegister.push([this.bottomLeftCornerOverlay.clone.wtTable.holder, 'wheel', function (event) {
  20274. return _this.onCloneWheel(event);
  20275. }]);
  20276. }
  20277. }
  20278. if (this.topOverlay.trimmingContainer !== window && this.leftOverlay.trimmingContainer !== window) {
  20279. // This is necessary?
  20280. // eventManager.addEventListener(window, 'scroll', (event) => this.refreshAll(event));
  20281. listenersToRegister.push([window, 'wheel', function (event) {
  20282. var overlay = void 0;
  20283. var deltaY = event.wheelDeltaY || event.deltaY;
  20284. var deltaX = event.wheelDeltaX || event.deltaX;
  20285. if (_this.topOverlay.clone.wtTable.holder.contains(event.realTarget)) {
  20286. overlay = 'top';
  20287. } else if (_this.bottomOverlay.clone && _this.bottomOverlay.clone.wtTable.holder.contains(event.realTarget)) {
  20288. overlay = 'bottom';
  20289. } else if (_this.leftOverlay.clone.wtTable.holder.contains(event.realTarget)) {
  20290. overlay = 'left';
  20291. } else if (_this.topLeftCornerOverlay && _this.topLeftCornerOverlay.clone && _this.topLeftCornerOverlay.clone.wtTable.holder.contains(event.realTarget)) {
  20292. overlay = 'topLeft';
  20293. } else if (_this.bottomLeftCornerOverlay && _this.bottomLeftCornerOverlay.clone && _this.bottomLeftCornerOverlay.clone.wtTable.holder.contains(event.realTarget)) {
  20294. overlay = 'bottomLeft';
  20295. }
  20296. if (overlay === 'top' && deltaY !== 0 || overlay === 'left' && deltaX !== 0 || overlay === 'bottom' && deltaY !== 0 || (overlay === 'topLeft' || overlay === 'bottomLeft') && (deltaY !== 0 || deltaX !== 0)) {
  20297. event.preventDefault();
  20298. }
  20299. }]);
  20300. }
  20301. while (listenersToRegister.length) {
  20302. var listener = listenersToRegister.pop();
  20303. this.eventManager.addEventListener(listener[0], listener[1], listener[2]);
  20304. this.registeredListeners.push(listener);
  20305. }
  20306. }
  20307. /**
  20308. * Deregister all previously registered listeners.
  20309. */
  20310. }, {
  20311. key: 'deregisterListeners',
  20312. value: function deregisterListeners() {
  20313. while (this.registeredListeners.length) {
  20314. var listener = this.registeredListeners.pop();
  20315. this.eventManager.removeEventListener(listener[0], listener[1], listener[2]);
  20316. }
  20317. }
  20318. /**
  20319. * Scroll listener
  20320. *
  20321. * @param {Event} event
  20322. */
  20323. }, {
  20324. key: 'onTableScroll',
  20325. value: function onTableScroll(event) {
  20326. // There was if statement which controlled flow of this function. It avoided the execution of the next lines
  20327. // on mobile devices. It was changed. Broader description of this case is included within issue #4856.
  20328. var masterHorizontal = this.leftOverlay.mainTableScrollableElement;
  20329. var masterVertical = this.topOverlay.mainTableScrollableElement;
  20330. var target = event.target;
  20331. // For key press, sync only master -> overlay position because while pressing Walkontable.render is triggered
  20332. // by hot.refreshBorder
  20333. if (this.keyPressed) {
  20334. if (masterVertical !== window && target !== window && !event.target.contains(masterVertical) || masterHorizontal !== window && target !== window && !event.target.contains(masterHorizontal)) {
  20335. return;
  20336. }
  20337. }
  20338. this.syncScrollPositions(event);
  20339. }
  20340. /**
  20341. * Wheel listener for cloned overlays.
  20342. *
  20343. * @param {Event} event
  20344. */
  20345. }, {
  20346. key: 'onCloneWheel',
  20347. value: function onCloneWheel(event) {
  20348. if (this.scrollableElement !== window) {
  20349. event.preventDefault();
  20350. }
  20351. // There was if statement which controlled flow of this function. It avoided the execution of the next lines
  20352. // on mobile devices. It was changed. Broader description of this case is included within issue #4856.
  20353. var masterHorizontal = this.leftOverlay.mainTableScrollableElement;
  20354. var masterVertical = this.topOverlay.mainTableScrollableElement;
  20355. var target = event.target;
  20356. // For key press, sync only master -> overlay position because while pressing Walkontable.render is triggered
  20357. // by hot.refreshBorder
  20358. var shouldNotWheelVertically = masterVertical !== window && target !== window && !event.target.contains(masterVertical);
  20359. var shouldNotWheelHorizontally = masterHorizontal !== window && target !== window && !event.target.contains(masterHorizontal);
  20360. if (this.keyPressed && (shouldNotWheelVertically || shouldNotWheelHorizontally)) {
  20361. return;
  20362. }
  20363. this.translateMouseWheelToScroll(event);
  20364. }
  20365. /**
  20366. * Key down listener
  20367. */
  20368. }, {
  20369. key: 'onKeyDown',
  20370. value: function onKeyDown(event) {
  20371. this.keyPressed = (0, _unicode.isKey)(event.keyCode, 'ARROW_UP|ARROW_RIGHT|ARROW_DOWN|ARROW_LEFT');
  20372. }
  20373. /**
  20374. * Key up listener
  20375. */
  20376. }, {
  20377. key: 'onKeyUp',
  20378. value: function onKeyUp() {
  20379. this.keyPressed = false;
  20380. }
  20381. /**
  20382. * Translate wheel event into scroll event and sync scroll overlays position
  20383. *
  20384. * @private
  20385. * @param {Event} event
  20386. * @returns {Boolean}
  20387. */
  20388. }, {
  20389. key: 'translateMouseWheelToScroll',
  20390. value: function translateMouseWheelToScroll(event) {
  20391. var deltaY = isNaN(event.deltaY) ? -1 * event.wheelDeltaY : event.deltaY;
  20392. var deltaX = isNaN(event.deltaX) ? -1 * event.wheelDeltaX : event.deltaX;
  20393. if (event.deltaMode === 1) {
  20394. deltaX += deltaX * this.browserLineHeight;
  20395. deltaY += deltaY * this.browserLineHeight;
  20396. }
  20397. this.scrollVertically(deltaY);
  20398. this.scrollHorizontally(deltaX);
  20399. return false;
  20400. }
  20401. }, {
  20402. key: 'scrollVertically',
  20403. value: function scrollVertically(distance) {
  20404. if (distance === 0) {
  20405. return 0;
  20406. }
  20407. this.scrollableElement.scrollTop += distance;
  20408. }
  20409. }, {
  20410. key: 'scrollHorizontally',
  20411. value: function scrollHorizontally(distance) {
  20412. if (distance === 0) {
  20413. return 0;
  20414. }
  20415. this.scrollableElement.scrollLeft += distance;
  20416. }
  20417. /**
  20418. * Synchronize scroll position between master table and overlay table.
  20419. *
  20420. * @private
  20421. * @param {Event|Object} event
  20422. */
  20423. }, {
  20424. key: 'syncScrollPositions',
  20425. value: function syncScrollPositions(event) {
  20426. if (this.destroyed) {
  20427. return;
  20428. }
  20429. var topHolder = this.topOverlay.clone.wtTable.holder;
  20430. var leftHolder = this.leftOverlay.clone.wtTable.holder;
  20431. var _ref = [this.scrollableElement.scrollLeft, this.scrollableElement.scrollTop],
  20432. scrollLeft = _ref[0],
  20433. scrollTop = _ref[1];
  20434. this.horizontalScrolling = topHolder.scrollLeft !== scrollLeft;
  20435. this.verticalScrolling = leftHolder.scrollTop !== scrollTop;
  20436. if (this.horizontalScrolling) {
  20437. topHolder.scrollLeft = scrollLeft;
  20438. }
  20439. if (this.verticalScrolling) {
  20440. leftHolder.scrollTop = scrollTop;
  20441. if (this.bottomOverlay.needFullRender) {
  20442. this.bottomOverlay.clone.wtTable.holder.scrollLeft = scrollLeft;
  20443. }
  20444. }
  20445. this.refreshAll();
  20446. }
  20447. /**
  20448. * Synchronize overlay scrollbars with the master scrollbar
  20449. */
  20450. }, {
  20451. key: 'syncScrollWithMaster',
  20452. value: function syncScrollWithMaster() {
  20453. var master = this.topOverlay.mainTableScrollableElement;
  20454. var scrollLeft = master.scrollLeft,
  20455. scrollTop = master.scrollTop;
  20456. if (this.topOverlay.needFullRender) {
  20457. this.topOverlay.clone.wtTable.holder.scrollLeft = scrollLeft;
  20458. }
  20459. if (this.bottomOverlay.needFullRender) {
  20460. this.bottomOverlay.clone.wtTable.holder.scrollLeft = scrollLeft;
  20461. }
  20462. if (this.leftOverlay.needFullRender) {
  20463. this.leftOverlay.clone.wtTable.holder.scrollTop = scrollTop;
  20464. }
  20465. }
  20466. /**
  20467. * Update the main scrollable elements for all the overlays.
  20468. */
  20469. }, {
  20470. key: 'updateMainScrollableElements',
  20471. value: function updateMainScrollableElements() {
  20472. this.deregisterListeners();
  20473. this.leftOverlay.updateMainScrollableElement();
  20474. this.topOverlay.updateMainScrollableElement();
  20475. if (this.bottomOverlay.needFullRender) {
  20476. this.bottomOverlay.updateMainScrollableElement();
  20477. }
  20478. this.scrollableElement = (0, _element.getScrollableElement)(this.wot.wtTable.TABLE);
  20479. this.registerListeners();
  20480. }
  20481. /**
  20482. *
  20483. */
  20484. }, {
  20485. key: 'destroy',
  20486. value: function destroy() {
  20487. this.eventManager.destroy();
  20488. this.topOverlay.destroy();
  20489. if (this.bottomOverlay.clone) {
  20490. this.bottomOverlay.destroy();
  20491. }
  20492. this.leftOverlay.destroy();
  20493. if (this.topLeftCornerOverlay) {
  20494. this.topLeftCornerOverlay.destroy();
  20495. }
  20496. if (this.bottomLeftCornerOverlay && this.bottomLeftCornerOverlay.clone) {
  20497. this.bottomLeftCornerOverlay.destroy();
  20498. }
  20499. if (this.debug) {
  20500. this.debug.destroy();
  20501. }
  20502. this.destroyed = true;
  20503. }
  20504. /**
  20505. * @param {Boolean} [fastDraw=false]
  20506. */
  20507. }, {
  20508. key: 'refresh',
  20509. value: function refresh() {
  20510. var fastDraw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  20511. if (this.topOverlay.areElementSizesAdjusted && this.leftOverlay.areElementSizesAdjusted) {
  20512. var container = this.wot.wtTable.wtRootElement.parentNode || this.wot.wtTable.wtRootElement;
  20513. var width = container.clientWidth;
  20514. var height = container.clientHeight;
  20515. if (width !== this.spreaderLastSize.width || height !== this.spreaderLastSize.height) {
  20516. this.spreaderLastSize.width = width;
  20517. this.spreaderLastSize.height = height;
  20518. this.adjustElementsSize();
  20519. }
  20520. }
  20521. if (this.bottomOverlay.clone) {
  20522. this.bottomOverlay.refresh(fastDraw);
  20523. }
  20524. this.leftOverlay.refresh(fastDraw);
  20525. this.topOverlay.refresh(fastDraw);
  20526. if (this.topLeftCornerOverlay) {
  20527. this.topLeftCornerOverlay.refresh(fastDraw);
  20528. }
  20529. if (this.bottomLeftCornerOverlay && this.bottomLeftCornerOverlay.clone) {
  20530. this.bottomLeftCornerOverlay.refresh(fastDraw);
  20531. }
  20532. if (this.debug) {
  20533. this.debug.refresh(fastDraw);
  20534. }
  20535. }
  20536. /**
  20537. * Adjust overlays elements size and master table size
  20538. *
  20539. * @param {Boolean} [force=false]
  20540. */
  20541. }, {
  20542. key: 'adjustElementsSize',
  20543. value: function adjustElementsSize() {
  20544. var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  20545. var totalColumns = this.wot.getSetting('totalColumns');
  20546. var totalRows = this.wot.getSetting('totalRows');
  20547. var headerRowSize = this.wot.wtViewport.getRowHeaderWidth();
  20548. var headerColumnSize = this.wot.wtViewport.getColumnHeaderHeight();
  20549. var hiderStyle = this.wot.wtTable.hider.style;
  20550. hiderStyle.width = headerRowSize + this.leftOverlay.sumCellSizes(0, totalColumns) + 'px';
  20551. hiderStyle.height = headerColumnSize + this.topOverlay.sumCellSizes(0, totalRows) + 1 + 'px';
  20552. this.topOverlay.adjustElementsSize(force);
  20553. this.leftOverlay.adjustElementsSize(force);
  20554. if (this.bottomOverlay.clone) {
  20555. this.bottomOverlay.adjustElementsSize(force);
  20556. }
  20557. }
  20558. /**
  20559. *
  20560. */
  20561. }, {
  20562. key: 'applyToDOM',
  20563. value: function applyToDOM() {
  20564. if (!this.topOverlay.areElementSizesAdjusted || !this.leftOverlay.areElementSizesAdjusted) {
  20565. this.adjustElementsSize();
  20566. }
  20567. this.topOverlay.applyToDOM();
  20568. if (this.bottomOverlay.clone) {
  20569. this.bottomOverlay.applyToDOM();
  20570. }
  20571. this.leftOverlay.applyToDOM();
  20572. }
  20573. /**
  20574. * Get the parent overlay of the provided element.
  20575. *
  20576. * @param {HTMLElement} element
  20577. * @returns {Object|null}
  20578. */
  20579. }, {
  20580. key: 'getParentOverlay',
  20581. value: function getParentOverlay(element) {
  20582. if (!element) {
  20583. return null;
  20584. }
  20585. var overlays = [this.topOverlay, this.leftOverlay, this.bottomOverlay, this.topLeftCornerOverlay, this.bottomLeftCornerOverlay];
  20586. var result = null;
  20587. (0, _array.arrayEach)(overlays, function (elem, i) {
  20588. if (!elem) {
  20589. return;
  20590. }
  20591. if (elem.clone && elem.clone.wtTable.TABLE.contains(element)) {
  20592. result = elem.clone;
  20593. }
  20594. });
  20595. return result;
  20596. }
  20597. }]);
  20598. return Overlays;
  20599. }();
  20600. exports.default = Overlays;
  20601. /***/ }),
  20602. /* 301 */
  20603. /***/ (function(module, exports, __webpack_require__) {
  20604. "use strict";
  20605. exports.__esModule = true;
  20606. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  20607. var _element = __webpack_require__(0);
  20608. var _number = __webpack_require__(5);
  20609. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  20610. /**
  20611. * @class Scroll
  20612. */
  20613. var Scroll = function () {
  20614. /**
  20615. * @param {Walkontable} wotInstance
  20616. */
  20617. function Scroll(wotInstance) {
  20618. _classCallCheck(this, Scroll);
  20619. this.wot = wotInstance;
  20620. // legacy support
  20621. this.instance = wotInstance;
  20622. }
  20623. /**
  20624. * Scrolls viewport to a cell by minimum number of cells
  20625. *
  20626. * @param {CellCoords} coords
  20627. */
  20628. _createClass(Scroll, [{
  20629. key: 'scrollViewport',
  20630. value: function scrollViewport(coords) {
  20631. if (!this.wot.drawn) {
  20632. return;
  20633. }
  20634. var _getVariables2 = this._getVariables(),
  20635. topOverlay = _getVariables2.topOverlay,
  20636. leftOverlay = _getVariables2.leftOverlay,
  20637. totalRows = _getVariables2.totalRows,
  20638. totalColumns = _getVariables2.totalColumns,
  20639. fixedRowsTop = _getVariables2.fixedRowsTop,
  20640. fixedRowsBottom = _getVariables2.fixedRowsBottom,
  20641. fixedColumnsLeft = _getVariables2.fixedColumnsLeft;
  20642. if (coords.row < 0 || coords.row > Math.max(totalRows - 1, 0)) {
  20643. throw new Error('row ' + coords.row + ' does not exist');
  20644. }
  20645. if (coords.col < 0 || coords.col > Math.max(totalColumns - 1, 0)) {
  20646. throw new Error('column ' + coords.col + ' does not exist');
  20647. }
  20648. if (coords.row >= fixedRowsTop && coords.row < this.getFirstVisibleRow()) {
  20649. topOverlay.scrollTo(coords.row);
  20650. } else if (coords.row > this.getLastVisibleRow() && coords.row < totalRows - fixedRowsBottom) {
  20651. topOverlay.scrollTo(coords.row, true);
  20652. }
  20653. if (coords.col >= fixedColumnsLeft && coords.col < this.getFirstVisibleColumn()) {
  20654. leftOverlay.scrollTo(coords.col);
  20655. } else if (coords.col > this.getLastVisibleColumn()) {
  20656. leftOverlay.scrollTo(coords.col, true);
  20657. }
  20658. }
  20659. /**
  20660. * Get first visible row based on virtual dom and how table is visible in browser window viewport.
  20661. *
  20662. * @returns {Number}
  20663. */
  20664. }, {
  20665. key: 'getFirstVisibleRow',
  20666. value: function getFirstVisibleRow() {
  20667. var _getVariables3 = this._getVariables(),
  20668. topOverlay = _getVariables3.topOverlay,
  20669. wtTable = _getVariables3.wtTable,
  20670. wtViewport = _getVariables3.wtViewport,
  20671. totalRows = _getVariables3.totalRows,
  20672. fixedRowsTop = _getVariables3.fixedRowsTop;
  20673. var firstVisibleRow = wtTable.getFirstVisibleRow();
  20674. if (topOverlay.mainTableScrollableElement === window) {
  20675. var rootElementOffset = (0, _element.offset)(wtTable.wtRootElement);
  20676. var totalTableHeight = (0, _element.innerHeight)(wtTable.hider);
  20677. var windowHeight = (0, _element.innerHeight)(window);
  20678. var windowScrollTop = (0, _element.getScrollTop)(window);
  20679. // Only calculate firstVisibleRow when table didn't filled (from up) whole viewport space
  20680. if (rootElementOffset.top + totalTableHeight - windowHeight <= windowScrollTop) {
  20681. var rowsHeight = wtViewport.getColumnHeaderHeight();
  20682. rowsHeight += topOverlay.sumCellSizes(0, fixedRowsTop);
  20683. (0, _number.rangeEachReverse)(totalRows, 1, function (row) {
  20684. rowsHeight += topOverlay.sumCellSizes(row - 1, row);
  20685. if (rootElementOffset.top + totalTableHeight - rowsHeight <= windowScrollTop) {
  20686. // Return physical row + 1
  20687. firstVisibleRow = row;
  20688. return false;
  20689. }
  20690. });
  20691. }
  20692. }
  20693. return firstVisibleRow;
  20694. }
  20695. /**
  20696. * Get last visible row based on virtual dom and how table is visible in browser window viewport.
  20697. *
  20698. * @returns {Number}
  20699. */
  20700. }, {
  20701. key: 'getLastVisibleRow',
  20702. value: function getLastVisibleRow() {
  20703. var _getVariables4 = this._getVariables(),
  20704. topOverlay = _getVariables4.topOverlay,
  20705. wtTable = _getVariables4.wtTable,
  20706. wtViewport = _getVariables4.wtViewport,
  20707. totalRows = _getVariables4.totalRows;
  20708. var lastVisibleRow = wtTable.getLastVisibleRow();
  20709. if (topOverlay.mainTableScrollableElement === window) {
  20710. var rootElementOffset = (0, _element.offset)(wtTable.wtRootElement);
  20711. var windowHeight = (0, _element.innerHeight)(window);
  20712. var windowScrollTop = (0, _element.getScrollTop)(window);
  20713. // Only calculate lastVisibleRow when table didn't filled (from bottom) whole viewport space
  20714. if (rootElementOffset.top > windowScrollTop) {
  20715. var rowsHeight = wtViewport.getColumnHeaderHeight();
  20716. (0, _number.rangeEach)(1, totalRows, function (row) {
  20717. rowsHeight += topOverlay.sumCellSizes(row - 1, row);
  20718. if (rootElementOffset.top + rowsHeight - windowScrollTop >= windowHeight) {
  20719. // Return physical row - 1 (-2 because rangeEach gives row index + 1 - sumCellSizes requirements)
  20720. lastVisibleRow = row - 2;
  20721. return false;
  20722. }
  20723. });
  20724. }
  20725. }
  20726. return lastVisibleRow;
  20727. }
  20728. /**
  20729. * Get first visible column based on virtual dom and how table is visible in browser window viewport.
  20730. *
  20731. * @returns {Number}
  20732. */
  20733. }, {
  20734. key: 'getFirstVisibleColumn',
  20735. value: function getFirstVisibleColumn() {
  20736. var _getVariables5 = this._getVariables(),
  20737. leftOverlay = _getVariables5.leftOverlay,
  20738. wtTable = _getVariables5.wtTable,
  20739. wtViewport = _getVariables5.wtViewport,
  20740. totalColumns = _getVariables5.totalColumns,
  20741. fixedColumnsLeft = _getVariables5.fixedColumnsLeft;
  20742. var firstVisibleColumn = wtTable.getFirstVisibleColumn();
  20743. if (leftOverlay.mainTableScrollableElement === window) {
  20744. var rootElementOffset = (0, _element.offset)(wtTable.wtRootElement);
  20745. var totalTableWidth = (0, _element.innerWidth)(wtTable.hider);
  20746. var windowWidth = (0, _element.innerWidth)(window);
  20747. var windowScrollLeft = (0, _element.getScrollLeft)(window);
  20748. // Only calculate firstVisibleColumn when table didn't filled (from left) whole viewport space
  20749. if (rootElementOffset.left + totalTableWidth - windowWidth <= windowScrollLeft) {
  20750. var columnsWidth = wtViewport.getRowHeaderWidth();
  20751. (0, _number.rangeEachReverse)(totalColumns, 1, function (column) {
  20752. columnsWidth += leftOverlay.sumCellSizes(column - 1, column);
  20753. if (rootElementOffset.left + totalTableWidth - columnsWidth <= windowScrollLeft) {
  20754. // Return physical column + 1
  20755. firstVisibleColumn = column;
  20756. return false;
  20757. }
  20758. });
  20759. }
  20760. }
  20761. return firstVisibleColumn;
  20762. }
  20763. /**
  20764. * Get last visible column based on virtual dom and how table is visible in browser window viewport.
  20765. *
  20766. * @returns {Number}
  20767. */
  20768. }, {
  20769. key: 'getLastVisibleColumn',
  20770. value: function getLastVisibleColumn() {
  20771. var _getVariables6 = this._getVariables(),
  20772. leftOverlay = _getVariables6.leftOverlay,
  20773. wtTable = _getVariables6.wtTable,
  20774. wtViewport = _getVariables6.wtViewport,
  20775. totalColumns = _getVariables6.totalColumns;
  20776. var lastVisibleColumn = wtTable.getLastVisibleColumn();
  20777. if (leftOverlay.mainTableScrollableElement === window) {
  20778. var rootElementOffset = (0, _element.offset)(wtTable.wtRootElement);
  20779. var windowWidth = (0, _element.innerWidth)(window);
  20780. var windowScrollLeft = (0, _element.getScrollLeft)(window);
  20781. // Only calculate lastVisibleColumn when table didn't filled (from right) whole viewport space
  20782. if (rootElementOffset.left > windowScrollLeft) {
  20783. var columnsWidth = wtViewport.getRowHeaderWidth();
  20784. (0, _number.rangeEach)(1, totalColumns, function (column) {
  20785. columnsWidth += leftOverlay.sumCellSizes(column - 1, column);
  20786. if (rootElementOffset.left + columnsWidth - windowScrollLeft >= windowWidth) {
  20787. // Return physical column - 1 (-2 because rangeEach gives column index + 1 - sumCellSizes requirements)
  20788. lastVisibleColumn = column - 2;
  20789. return false;
  20790. }
  20791. });
  20792. }
  20793. }
  20794. return lastVisibleColumn;
  20795. }
  20796. /**
  20797. * Returns collection of variables used to rows and columns visibility calculations.
  20798. *
  20799. * @returns {Object}
  20800. * @private
  20801. */
  20802. }, {
  20803. key: '_getVariables',
  20804. value: function _getVariables() {
  20805. var wot = this.wot;
  20806. var topOverlay = wot.wtOverlays.topOverlay;
  20807. var leftOverlay = wot.wtOverlays.leftOverlay;
  20808. var wtTable = wot.wtTable;
  20809. var wtViewport = wot.wtViewport;
  20810. var totalRows = wot.getSetting('totalRows');
  20811. var totalColumns = wot.getSetting('totalColumns');
  20812. var fixedRowsTop = wot.getSetting('fixedRowsTop');
  20813. var fixedRowsBottom = wot.getSetting('fixedRowsBottom');
  20814. var fixedColumnsLeft = wot.getSetting('fixedColumnsLeft');
  20815. return {
  20816. topOverlay: topOverlay,
  20817. leftOverlay: leftOverlay,
  20818. wtTable: wtTable,
  20819. wtViewport: wtViewport,
  20820. totalRows: totalRows,
  20821. totalColumns: totalColumns,
  20822. fixedRowsTop: fixedRowsTop,
  20823. fixedRowsBottom: fixedRowsBottom,
  20824. fixedColumnsLeft: fixedColumnsLeft
  20825. };
  20826. }
  20827. }]);
  20828. return Scroll;
  20829. }();
  20830. exports.default = Scroll;
  20831. /***/ }),
  20832. /* 302 */
  20833. /***/ (function(module, exports, __webpack_require__) {
  20834. "use strict";
  20835. exports.__esModule = true;
  20836. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  20837. var _element = __webpack_require__(0);
  20838. var _object = __webpack_require__(2);
  20839. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  20840. /**
  20841. * @class Settings
  20842. */
  20843. var Settings = function () {
  20844. /**
  20845. * @param {Walkontable} wotInstance
  20846. * @param {Object} settings
  20847. */
  20848. function Settings(wotInstance, settings) {
  20849. var _this = this;
  20850. _classCallCheck(this, Settings);
  20851. this.wot = wotInstance;
  20852. // legacy support
  20853. this.instance = wotInstance;
  20854. // default settings. void 0 means it is required, null means it can be empty
  20855. this.defaults = {
  20856. table: void 0,
  20857. debug: false, // shows WalkontableDebugOverlay
  20858. // presentation mode
  20859. externalRowCalculator: false,
  20860. stretchH: 'none', // values: all, last, none
  20861. currentRowClassName: null,
  20862. currentColumnClassName: null,
  20863. preventOverflow: function preventOverflow() {
  20864. return false;
  20865. },
  20866. // data source
  20867. data: void 0,
  20868. freezeOverlays: false,
  20869. fixedColumnsLeft: 0,
  20870. fixedRowsTop: 0,
  20871. fixedRowsBottom: 0,
  20872. minSpareRows: 0,
  20873. // this must be array of functions: [function (row, TH) {}]
  20874. rowHeaders: function rowHeaders() {
  20875. return [];
  20876. },
  20877. // this must be array of functions: [function (column, TH) {}]
  20878. columnHeaders: function columnHeaders() {
  20879. return [];
  20880. },
  20881. totalRows: void 0,
  20882. totalColumns: void 0,
  20883. cellRenderer: function cellRenderer(row, column, TD) {
  20884. var cellData = _this.getSetting('data', row, column);
  20885. (0, _element.fastInnerText)(TD, cellData === void 0 || cellData === null ? '' : cellData);
  20886. },
  20887. // columnWidth: 50,
  20888. columnWidth: function columnWidth(col) {
  20889. // return undefined means use default size for the rendered cell content
  20890. },
  20891. rowHeight: function rowHeight(row) {
  20892. // return undefined means use default size for the rendered cell content
  20893. },
  20894. defaultRowHeight: 23,
  20895. defaultColumnWidth: 50,
  20896. selections: null,
  20897. hideBorderOnMouseDownOver: false,
  20898. viewportRowCalculatorOverride: null,
  20899. viewportColumnCalculatorOverride: null,
  20900. // callbacks
  20901. onCellMouseDown: null,
  20902. onCellMouseOver: null,
  20903. onCellMouseOut: null,
  20904. onCellMouseUp: null,
  20905. // onCellMouseOut: null,
  20906. onCellDblClick: null,
  20907. onCellCornerMouseDown: null,
  20908. onCellCornerDblClick: null,
  20909. beforeDraw: null,
  20910. onDraw: null,
  20911. onBeforeRemoveCellClassNames: null,
  20912. onAfterDrawSelection: null,
  20913. onBeforeDrawBorders: null,
  20914. onScrollVertically: null,
  20915. onScrollHorizontally: null,
  20916. onBeforeTouchScroll: null,
  20917. onAfterMomentumScroll: null,
  20918. onBeforeStretchingColumnWidth: function onBeforeStretchingColumnWidth(width) {
  20919. return width;
  20920. },
  20921. onModifyRowHeaderWidth: null,
  20922. onModifyGetCellCoords: null,
  20923. // constants
  20924. scrollbarWidth: 10,
  20925. scrollbarHeight: 10,
  20926. renderAllRows: false,
  20927. groups: false,
  20928. rowHeaderWidth: null,
  20929. columnHeaderHeight: null,
  20930. headerClassName: null
  20931. };
  20932. // reference to settings
  20933. this.settings = {};
  20934. for (var i in this.defaults) {
  20935. if ((0, _object.hasOwnProperty)(this.defaults, i)) {
  20936. if (settings[i] !== void 0) {
  20937. this.settings[i] = settings[i];
  20938. } else if (this.defaults[i] === void 0) {
  20939. throw new Error('A required setting "' + i + '" was not provided');
  20940. } else {
  20941. this.settings[i] = this.defaults[i];
  20942. }
  20943. }
  20944. }
  20945. }
  20946. /**
  20947. * Update settings
  20948. *
  20949. * @param {Object} settings
  20950. * @param {*} value
  20951. * @returns {Walkontable}
  20952. */
  20953. _createClass(Settings, [{
  20954. key: 'update',
  20955. value: function update(settings, value) {
  20956. if (value === void 0) {
  20957. // settings is object
  20958. for (var i in settings) {
  20959. if ((0, _object.hasOwnProperty)(settings, i)) {
  20960. this.settings[i] = settings[i];
  20961. }
  20962. }
  20963. } else {
  20964. // if value is defined then settings is the key
  20965. this.settings[settings] = value;
  20966. }
  20967. return this.wot;
  20968. }
  20969. /**
  20970. * Get setting by name
  20971. *
  20972. * @param {String} key
  20973. * @param {*} param1
  20974. * @param {*} param2
  20975. * @param {*} param3
  20976. * @param {*} param4
  20977. * @returns {*}
  20978. */
  20979. }, {
  20980. key: 'getSetting',
  20981. value: function getSetting(key, param1, param2, param3, param4) {
  20982. if (typeof this.settings[key] === 'function') {
  20983. // this is faster than .apply - https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips
  20984. return this.settings[key](param1, param2, param3, param4);
  20985. } else if (param1 !== void 0 && Array.isArray(this.settings[key])) {
  20986. // perhaps this can be removed, it is only used in tests
  20987. return this.settings[key][param1];
  20988. }
  20989. return this.settings[key];
  20990. }
  20991. /**
  20992. * Checks if setting exists
  20993. *
  20994. * @param {Boolean} key
  20995. * @returns {Boolean}
  20996. */
  20997. }, {
  20998. key: 'has',
  20999. value: function has(key) {
  21000. return !!this.settings[key];
  21001. }
  21002. }]);
  21003. return Settings;
  21004. }();
  21005. exports.default = Settings;
  21006. /***/ }),
  21007. /* 303 */
  21008. /***/ (function(module, exports, __webpack_require__) {
  21009. "use strict";
  21010. exports.__esModule = true;
  21011. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  21012. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  21013. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  21014. var _element = __webpack_require__(0);
  21015. var _function = __webpack_require__(43);
  21016. var _coords = __webpack_require__(55);
  21017. var _coords2 = _interopRequireDefault(_coords);
  21018. var _range = __webpack_require__(86);
  21019. var _range2 = _interopRequireDefault(_range);
  21020. var _column = __webpack_require__(177);
  21021. var _column2 = _interopRequireDefault(_column);
  21022. var _row = __webpack_require__(178);
  21023. var _row2 = _interopRequireDefault(_row);
  21024. var _tableRenderer = __webpack_require__(304);
  21025. var _tableRenderer2 = _interopRequireDefault(_tableRenderer);
  21026. var _base = __webpack_require__(35);
  21027. var _base2 = _interopRequireDefault(_base);
  21028. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  21029. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  21030. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21031. /**
  21032. *
  21033. */
  21034. var Table = function () {
  21035. /**
  21036. * @param {Walkontable} wotInstance
  21037. * @param {HTMLTableElement} table
  21038. */
  21039. function Table(wotInstance, table) {
  21040. var _this = this;
  21041. _classCallCheck(this, Table);
  21042. this.wot = wotInstance;
  21043. // legacy support
  21044. this.instance = this.wot;
  21045. this.TABLE = table;
  21046. this.TBODY = null;
  21047. this.THEAD = null;
  21048. this.COLGROUP = null;
  21049. this.tableOffset = 0;
  21050. this.holderOffset = 0;
  21051. (0, _element.removeTextNodes)(this.TABLE);
  21052. this.spreader = this.createSpreader(this.TABLE);
  21053. this.hider = this.createHider(this.spreader);
  21054. this.holder = this.createHolder(this.hider);
  21055. this.wtRootElement = this.holder.parentNode;
  21056. this.alignOverlaysWithTrimmingContainer();
  21057. this.fixTableDomTree();
  21058. this.colgroupChildrenLength = this.COLGROUP.childNodes.length;
  21059. this.theadChildrenLength = this.THEAD.firstChild ? this.THEAD.firstChild.childNodes.length : 0;
  21060. this.tbodyChildrenLength = this.TBODY.childNodes.length;
  21061. this.rowFilter = null;
  21062. this.columnFilter = null;
  21063. this.correctHeaderWidth = false;
  21064. var origRowHeaderWidth = this.wot.wtSettings.settings.rowHeaderWidth;
  21065. // Fix for jumping row headers (https://github.com/handsontable/handsontable/issues/3850)
  21066. this.wot.wtSettings.settings.rowHeaderWidth = function () {
  21067. return _this._modifyRowHeaderWidth(origRowHeaderWidth);
  21068. };
  21069. }
  21070. /**
  21071. *
  21072. */
  21073. _createClass(Table, [{
  21074. key: 'fixTableDomTree',
  21075. value: function fixTableDomTree() {
  21076. this.TBODY = this.TABLE.querySelector('tbody');
  21077. if (!this.TBODY) {
  21078. this.TBODY = document.createElement('tbody');
  21079. this.TABLE.appendChild(this.TBODY);
  21080. }
  21081. this.THEAD = this.TABLE.querySelector('thead');
  21082. if (!this.THEAD) {
  21083. this.THEAD = document.createElement('thead');
  21084. this.TABLE.insertBefore(this.THEAD, this.TBODY);
  21085. }
  21086. this.COLGROUP = this.TABLE.querySelector('colgroup');
  21087. if (!this.COLGROUP) {
  21088. this.COLGROUP = document.createElement('colgroup');
  21089. this.TABLE.insertBefore(this.COLGROUP, this.THEAD);
  21090. }
  21091. if (this.wot.getSetting('columnHeaders').length && !this.THEAD.childNodes.length) {
  21092. this.THEAD.appendChild(document.createElement('TR'));
  21093. }
  21094. }
  21095. /**
  21096. * @param table
  21097. * @returns {HTMLElement}
  21098. */
  21099. }, {
  21100. key: 'createSpreader',
  21101. value: function createSpreader(table) {
  21102. var parent = table.parentNode;
  21103. var spreader = void 0;
  21104. if (!parent || parent.nodeType !== 1 || !(0, _element.hasClass)(parent, 'wtHolder')) {
  21105. spreader = document.createElement('div');
  21106. spreader.className = 'wtSpreader';
  21107. if (parent) {
  21108. // if TABLE is detached (e.g. in Jasmine test), it has no parentNode so we cannot attach holder to it
  21109. parent.insertBefore(spreader, table);
  21110. }
  21111. spreader.appendChild(table);
  21112. }
  21113. spreader.style.position = 'relative';
  21114. return spreader;
  21115. }
  21116. /**
  21117. * @param spreader
  21118. * @returns {HTMLElement}
  21119. */
  21120. }, {
  21121. key: 'createHider',
  21122. value: function createHider(spreader) {
  21123. var parent = spreader.parentNode;
  21124. var hider = void 0;
  21125. if (!parent || parent.nodeType !== 1 || !(0, _element.hasClass)(parent, 'wtHolder')) {
  21126. hider = document.createElement('div');
  21127. hider.className = 'wtHider';
  21128. if (parent) {
  21129. // if TABLE is detached (e.g. in Jasmine test), it has no parentNode so we cannot attach holder to it
  21130. parent.insertBefore(hider, spreader);
  21131. }
  21132. hider.appendChild(spreader);
  21133. }
  21134. return hider;
  21135. }
  21136. /**
  21137. *
  21138. * @param hider
  21139. * @returns {HTMLElement}
  21140. */
  21141. }, {
  21142. key: 'createHolder',
  21143. value: function createHolder(hider) {
  21144. var parent = hider.parentNode;
  21145. var holder = void 0;
  21146. if (!parent || parent.nodeType !== 1 || !(0, _element.hasClass)(parent, 'wtHolder')) {
  21147. holder = document.createElement('div');
  21148. holder.style.position = 'relative';
  21149. holder.className = 'wtHolder';
  21150. if (parent) {
  21151. // if TABLE is detached (e.g. in Jasmine test), it has no parentNode so we cannot attach holder to it
  21152. parent.insertBefore(holder, hider);
  21153. }
  21154. if (!this.isWorkingOnClone()) {
  21155. holder.parentNode.className += 'ht_master handsontable';
  21156. }
  21157. holder.appendChild(hider);
  21158. }
  21159. return holder;
  21160. }
  21161. }, {
  21162. key: 'alignOverlaysWithTrimmingContainer',
  21163. value: function alignOverlaysWithTrimmingContainer() {
  21164. var trimmingElement = (0, _element.getTrimmingContainer)(this.wtRootElement);
  21165. if (!this.isWorkingOnClone()) {
  21166. this.holder.parentNode.style.position = 'relative';
  21167. if (trimmingElement === window) {
  21168. var preventOverflow = this.wot.getSetting('preventOverflow');
  21169. if (!preventOverflow) {
  21170. this.holder.style.overflow = 'visible';
  21171. this.wtRootElement.style.overflow = 'visible';
  21172. }
  21173. } else {
  21174. this.holder.style.width = (0, _element.getStyle)(trimmingElement, 'width');
  21175. this.holder.style.height = (0, _element.getStyle)(trimmingElement, 'height');
  21176. this.holder.style.overflow = '';
  21177. }
  21178. }
  21179. }
  21180. }, {
  21181. key: 'isWorkingOnClone',
  21182. value: function isWorkingOnClone() {
  21183. return !!this.wot.cloneSource;
  21184. }
  21185. /**
  21186. * Redraws the table
  21187. *
  21188. * @param {Boolean} fastDraw If TRUE, will try to avoid full redraw and only update the border positions. If FALSE or UNDEFINED, will perform a full redraw
  21189. * @returns {Table}
  21190. */
  21191. }, {
  21192. key: 'draw',
  21193. value: function draw(fastDraw) {
  21194. var _wot = this.wot,
  21195. wtOverlays = _wot.wtOverlays,
  21196. wtViewport = _wot.wtViewport;
  21197. var totalRows = this.instance.getSetting('totalRows');
  21198. var rowHeaders = this.wot.getSetting('rowHeaders').length;
  21199. var columnHeaders = this.wot.getSetting('columnHeaders').length;
  21200. var syncScroll = false;
  21201. if (!this.isWorkingOnClone()) {
  21202. this.holderOffset = (0, _element.offset)(this.holder);
  21203. fastDraw = wtViewport.createRenderCalculators(fastDraw);
  21204. if (rowHeaders && !this.wot.getSetting('fixedColumnsLeft')) {
  21205. var leftScrollPos = wtOverlays.leftOverlay.getScrollPosition();
  21206. var previousState = this.correctHeaderWidth;
  21207. this.correctHeaderWidth = leftScrollPos > 0;
  21208. if (previousState !== this.correctHeaderWidth) {
  21209. fastDraw = false;
  21210. }
  21211. }
  21212. }
  21213. if (!this.isWorkingOnClone()) {
  21214. syncScroll = wtOverlays.prepareOverlays();
  21215. }
  21216. if (fastDraw) {
  21217. if (!this.isWorkingOnClone()) {
  21218. // in case we only scrolled without redraw, update visible rows information in oldRowsCalculator
  21219. wtViewport.createVisibleCalculators();
  21220. }
  21221. if (wtOverlays) {
  21222. wtOverlays.refresh(true);
  21223. }
  21224. } else {
  21225. if (this.isWorkingOnClone()) {
  21226. this.tableOffset = this.wot.cloneSource.wtTable.tableOffset;
  21227. } else {
  21228. this.tableOffset = (0, _element.offset)(this.TABLE);
  21229. }
  21230. var startRow = void 0;
  21231. if (_base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_DEBUG) || _base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_TOP) || _base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_TOP_LEFT_CORNER)) {
  21232. startRow = 0;
  21233. } else if (_base2.default.isOverlayTypeOf(this.instance.cloneOverlay, _base2.default.CLONE_BOTTOM) || _base2.default.isOverlayTypeOf(this.instance.cloneOverlay, _base2.default.CLONE_BOTTOM_LEFT_CORNER)) {
  21234. startRow = Math.max(totalRows - this.wot.getSetting('fixedRowsBottom'), 0);
  21235. } else {
  21236. startRow = wtViewport.rowsRenderCalculator.startRow;
  21237. }
  21238. var startColumn = void 0;
  21239. if (_base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_DEBUG) || _base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_LEFT) || _base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_TOP_LEFT_CORNER) || _base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_BOTTOM_LEFT_CORNER)) {
  21240. startColumn = 0;
  21241. } else {
  21242. startColumn = wtViewport.columnsRenderCalculator.startColumn;
  21243. }
  21244. this.rowFilter = new _row2.default(startRow, totalRows, columnHeaders);
  21245. this.columnFilter = new _column2.default(startColumn, this.wot.getSetting('totalColumns'), rowHeaders);
  21246. this.alignOverlaysWithTrimmingContainer();
  21247. this._doDraw(); // creates calculator after draw
  21248. }
  21249. this.refreshSelections(fastDraw);
  21250. if (!this.isWorkingOnClone()) {
  21251. wtOverlays.topOverlay.resetFixedPosition();
  21252. if (wtOverlays.bottomOverlay.clone) {
  21253. wtOverlays.bottomOverlay.resetFixedPosition();
  21254. }
  21255. wtOverlays.leftOverlay.resetFixedPosition();
  21256. if (wtOverlays.topLeftCornerOverlay) {
  21257. wtOverlays.topLeftCornerOverlay.resetFixedPosition();
  21258. }
  21259. if (wtOverlays.bottomLeftCornerOverlay && wtOverlays.bottomLeftCornerOverlay.clone) {
  21260. wtOverlays.bottomLeftCornerOverlay.resetFixedPosition();
  21261. }
  21262. }
  21263. if (syncScroll) {
  21264. wtOverlays.syncScrollWithMaster();
  21265. }
  21266. this.wot.drawn = true;
  21267. return this;
  21268. }
  21269. }, {
  21270. key: '_doDraw',
  21271. value: function _doDraw() {
  21272. var wtRenderer = new _tableRenderer2.default(this);
  21273. wtRenderer.render();
  21274. }
  21275. }, {
  21276. key: 'removeClassFromCells',
  21277. value: function removeClassFromCells(className) {
  21278. var nodes = this.TABLE.querySelectorAll('.' + className);
  21279. for (var i = 0, len = nodes.length; i < len; i++) {
  21280. (0, _element.removeClass)(nodes[i], className);
  21281. }
  21282. }
  21283. /**
  21284. * Refresh the table selection by re-rendering Selection instances connected with that instance.
  21285. *
  21286. * @param {Boolean} fastDraw If fast drawing is enabled than additionally className clearing is applied.
  21287. */
  21288. }, {
  21289. key: 'refreshSelections',
  21290. value: function refreshSelections(fastDraw) {
  21291. if (!this.wot.selections) {
  21292. return;
  21293. }
  21294. var highlights = Array.from(this.wot.selections);
  21295. var len = highlights.length;
  21296. if (fastDraw) {
  21297. var classesToRemove = [];
  21298. for (var i = 0; i < len; i++) {
  21299. var _highlights$i$setting = highlights[i].settings,
  21300. highlightHeaderClassName = _highlights$i$setting.highlightHeaderClassName,
  21301. highlightRowClassName = _highlights$i$setting.highlightRowClassName,
  21302. highlightColumnClassName = _highlights$i$setting.highlightColumnClassName;
  21303. var classNames = highlights[i].classNames;
  21304. var classNamesLength = classNames.length;
  21305. for (var j = 0; j < classNamesLength; j++) {
  21306. if (!classesToRemove.includes(classNames[j])) {
  21307. classesToRemove.push(classNames[j]);
  21308. }
  21309. }
  21310. if (highlightHeaderClassName && !classesToRemove.includes(highlightHeaderClassName)) {
  21311. classesToRemove.push(highlightHeaderClassName);
  21312. }
  21313. if (highlightRowClassName && !classesToRemove.includes(highlightRowClassName)) {
  21314. classesToRemove.push(highlightRowClassName);
  21315. }
  21316. if (highlightColumnClassName && !classesToRemove.includes(highlightColumnClassName)) {
  21317. classesToRemove.push(highlightColumnClassName);
  21318. }
  21319. }
  21320. var additionalClassesToRemove = this.wot.getSetting('onBeforeRemoveCellClassNames');
  21321. if (Array.isArray(additionalClassesToRemove)) {
  21322. for (var _i = 0; _i < additionalClassesToRemove.length; _i++) {
  21323. classesToRemove.push(additionalClassesToRemove[_i]);
  21324. }
  21325. }
  21326. var classesToRemoveLength = classesToRemove.length;
  21327. for (var _i2 = 0; _i2 < classesToRemoveLength; _i2++) {
  21328. // there was no rerender, so we need to remove classNames by ourselves
  21329. this.removeClassFromCells(classesToRemove[_i2]);
  21330. }
  21331. }
  21332. for (var _i3 = 0; _i3 < len; _i3++) {
  21333. highlights[_i3].draw(this.wot, fastDraw);
  21334. }
  21335. }
  21336. /**
  21337. * Get cell element at coords.
  21338. *
  21339. * @param {CellCoords} coords
  21340. * @returns {HTMLElement|Number} HTMLElement on success or Number one of the exit codes on error:
  21341. * -1 row before viewport
  21342. * -2 row after viewport
  21343. */
  21344. }, {
  21345. key: 'getCell',
  21346. value: function getCell(coords) {
  21347. var row = coords.row;
  21348. var column = coords.col;
  21349. var hookResult = this.wot.getSetting('onModifyGetCellCoords', row, column);
  21350. if (hookResult && Array.isArray(hookResult)) {
  21351. var _hookResult = _slicedToArray(hookResult, 2);
  21352. row = _hookResult[0];
  21353. column = _hookResult[1];
  21354. }
  21355. if (this.isRowBeforeRenderedRows(row)) {
  21356. // row before rendered rows
  21357. return -1;
  21358. } else if (this.isRowAfterRenderedRows(row)) {
  21359. // row after rendered rows
  21360. return -2;
  21361. }
  21362. var TR = this.TBODY.childNodes[this.rowFilter.sourceToRendered(row)];
  21363. if (TR) {
  21364. return TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(column)];
  21365. }
  21366. }
  21367. /**
  21368. * getColumnHeader
  21369. *
  21370. * @param {Number} col Column index
  21371. * @param {Number} [level=0] Header level (0 = most distant to the table)
  21372. * @returns {Object} HTMLElement on success or undefined on error
  21373. */
  21374. }, {
  21375. key: 'getColumnHeader',
  21376. value: function getColumnHeader(col) {
  21377. var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  21378. var TR = this.THEAD.childNodes[level];
  21379. if (TR) {
  21380. return TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(col)];
  21381. }
  21382. }
  21383. /**
  21384. * getRowHeader
  21385. *
  21386. * @param {Number} row Row index
  21387. * @returns {HTMLElement} HTMLElement on success or Number one of the exit codes on error: `null table doesn't have row headers`
  21388. */
  21389. }, {
  21390. key: 'getRowHeader',
  21391. value: function getRowHeader(row) {
  21392. if (this.columnFilter.sourceColumnToVisibleRowHeadedColumn(0) === 0) {
  21393. return null;
  21394. }
  21395. var TR = this.TBODY.childNodes[this.rowFilter.sourceToRendered(row)];
  21396. if (TR) {
  21397. return TR.childNodes[0];
  21398. }
  21399. }
  21400. /**
  21401. * Returns cell coords object for a given TD (or a child element of a TD element).
  21402. *
  21403. * @param {HTMLTableCellElement} TD A cell DOM element (or a child of one).
  21404. * @returns {CellCoords|null} The coordinates of the provided TD element (or the closest TD element) or null, if the provided element is not applicable.
  21405. */
  21406. }, {
  21407. key: 'getCoords',
  21408. value: function getCoords(TD) {
  21409. if (TD.nodeName !== 'TD' && TD.nodeName !== 'TH') {
  21410. TD = (0, _element.closest)(TD, ['TD', 'TH']);
  21411. }
  21412. if (TD === null) {
  21413. return null;
  21414. }
  21415. var TR = TD.parentNode;
  21416. var CONTAINER = TR.parentNode;
  21417. var row = (0, _element.index)(TR);
  21418. var col = TD.cellIndex;
  21419. if ((0, _element.overlayContainsElement)(_base2.default.CLONE_TOP_LEFT_CORNER, TD) || (0, _element.overlayContainsElement)(_base2.default.CLONE_TOP, TD)) {
  21420. if (CONTAINER.nodeName === 'THEAD') {
  21421. row -= CONTAINER.childNodes.length;
  21422. }
  21423. } else if (CONTAINER === this.THEAD) {
  21424. row = this.rowFilter.visibleColHeadedRowToSourceRow(row);
  21425. } else {
  21426. row = this.rowFilter.renderedToSource(row);
  21427. }
  21428. if ((0, _element.overlayContainsElement)(_base2.default.CLONE_TOP_LEFT_CORNER, TD) || (0, _element.overlayContainsElement)(_base2.default.CLONE_LEFT, TD)) {
  21429. col = this.columnFilter.offsettedTH(col);
  21430. } else {
  21431. col = this.columnFilter.visibleRowHeadedColumnToSourceColumn(col);
  21432. }
  21433. return new _coords2.default(row, col);
  21434. }
  21435. }, {
  21436. key: 'getTrForRow',
  21437. value: function getTrForRow(row) {
  21438. return this.TBODY.childNodes[this.rowFilter.sourceToRendered(row)];
  21439. }
  21440. }, {
  21441. key: 'getFirstRenderedRow',
  21442. value: function getFirstRenderedRow() {
  21443. return this.wot.wtViewport.rowsRenderCalculator.startRow;
  21444. }
  21445. }, {
  21446. key: 'getFirstVisibleRow',
  21447. value: function getFirstVisibleRow() {
  21448. return this.wot.wtViewport.rowsVisibleCalculator.startRow;
  21449. }
  21450. }, {
  21451. key: 'getFirstRenderedColumn',
  21452. value: function getFirstRenderedColumn() {
  21453. return this.wot.wtViewport.columnsRenderCalculator.startColumn;
  21454. }
  21455. /**
  21456. * @returns {Number} Returns -1 if no row is visible
  21457. */
  21458. }, {
  21459. key: 'getFirstVisibleColumn',
  21460. value: function getFirstVisibleColumn() {
  21461. return this.wot.wtViewport.columnsVisibleCalculator.startColumn;
  21462. }
  21463. /**
  21464. * @returns {Number} Returns -1 if no row is visible
  21465. */
  21466. }, {
  21467. key: 'getLastRenderedRow',
  21468. value: function getLastRenderedRow() {
  21469. return this.wot.wtViewport.rowsRenderCalculator.endRow;
  21470. }
  21471. }, {
  21472. key: 'getLastVisibleRow',
  21473. value: function getLastVisibleRow() {
  21474. return this.wot.wtViewport.rowsVisibleCalculator.endRow;
  21475. }
  21476. }, {
  21477. key: 'getLastRenderedColumn',
  21478. value: function getLastRenderedColumn() {
  21479. return this.wot.wtViewport.columnsRenderCalculator.endColumn;
  21480. }
  21481. /**
  21482. * @returns {Number} Returns -1 if no column is visible
  21483. */
  21484. }, {
  21485. key: 'getLastVisibleColumn',
  21486. value: function getLastVisibleColumn() {
  21487. return this.wot.wtViewport.columnsVisibleCalculator.endColumn;
  21488. }
  21489. }, {
  21490. key: 'isRowBeforeRenderedRows',
  21491. value: function isRowBeforeRenderedRows(row) {
  21492. return this.rowFilter && this.rowFilter.sourceToRendered(row) < 0 && row >= 0;
  21493. }
  21494. }, {
  21495. key: 'isRowAfterViewport',
  21496. value: function isRowAfterViewport(row) {
  21497. return this.rowFilter && this.rowFilter.sourceToRendered(row) > this.getLastVisibleRow();
  21498. }
  21499. }, {
  21500. key: 'isRowAfterRenderedRows',
  21501. value: function isRowAfterRenderedRows(row) {
  21502. return this.rowFilter && this.rowFilter.sourceToRendered(row) > this.getLastRenderedRow();
  21503. }
  21504. }, {
  21505. key: 'isColumnBeforeViewport',
  21506. value: function isColumnBeforeViewport(column) {
  21507. return this.columnFilter && this.columnFilter.sourceToRendered(column) < 0 && column >= 0;
  21508. }
  21509. }, {
  21510. key: 'isColumnAfterViewport',
  21511. value: function isColumnAfterViewport(column) {
  21512. return this.columnFilter && this.columnFilter.sourceToRendered(column) > this.getLastVisibleColumn();
  21513. }
  21514. }, {
  21515. key: 'isLastRowFullyVisible',
  21516. value: function isLastRowFullyVisible() {
  21517. return this.getLastVisibleRow() === this.getLastRenderedRow();
  21518. }
  21519. }, {
  21520. key: 'isLastColumnFullyVisible',
  21521. value: function isLastColumnFullyVisible() {
  21522. return this.getLastVisibleColumn() === this.getLastRenderedColumn();
  21523. }
  21524. }, {
  21525. key: 'getRenderedColumnsCount',
  21526. value: function getRenderedColumnsCount() {
  21527. var columnsCount = this.wot.wtViewport.columnsRenderCalculator.count;
  21528. var totalColumns = this.wot.getSetting('totalColumns');
  21529. if (this.wot.isOverlayName(_base2.default.CLONE_DEBUG)) {
  21530. columnsCount = totalColumns;
  21531. } else if (this.wot.isOverlayName(_base2.default.CLONE_LEFT) || this.wot.isOverlayName(_base2.default.CLONE_TOP_LEFT_CORNER) || this.wot.isOverlayName(_base2.default.CLONE_BOTTOM_LEFT_CORNER)) {
  21532. return Math.min(this.wot.getSetting('fixedColumnsLeft'), totalColumns);
  21533. }
  21534. return columnsCount;
  21535. }
  21536. }, {
  21537. key: 'getRenderedRowsCount',
  21538. value: function getRenderedRowsCount() {
  21539. var rowsCount = this.wot.wtViewport.rowsRenderCalculator.count;
  21540. var totalRows = this.wot.getSetting('totalRows');
  21541. if (this.wot.isOverlayName(_base2.default.CLONE_DEBUG)) {
  21542. rowsCount = totalRows;
  21543. } else if (this.wot.isOverlayName(_base2.default.CLONE_TOP) || this.wot.isOverlayName(_base2.default.CLONE_TOP_LEFT_CORNER)) {
  21544. rowsCount = Math.min(this.wot.getSetting('fixedRowsTop'), totalRows);
  21545. } else if (this.wot.isOverlayName(_base2.default.CLONE_BOTTOM) || this.wot.isOverlayName(_base2.default.CLONE_BOTTOM_LEFT_CORNER)) {
  21546. rowsCount = Math.min(this.wot.getSetting('fixedRowsBottom'), totalRows);
  21547. }
  21548. return rowsCount;
  21549. }
  21550. }, {
  21551. key: 'getVisibleRowsCount',
  21552. value: function getVisibleRowsCount() {
  21553. return this.wot.wtViewport.rowsVisibleCalculator.count;
  21554. }
  21555. }, {
  21556. key: 'allRowsInViewport',
  21557. value: function allRowsInViewport() {
  21558. return this.wot.getSetting('totalRows') == this.getVisibleRowsCount();
  21559. }
  21560. /**
  21561. * Checks if any of the row's cells content exceeds its initial height, and if so, returns the oversized height
  21562. *
  21563. * @param {Number} sourceRow
  21564. * @returns {Number}
  21565. */
  21566. }, {
  21567. key: 'getRowHeight',
  21568. value: function getRowHeight(sourceRow) {
  21569. var height = this.wot.wtSettings.settings.rowHeight(sourceRow);
  21570. var oversizedHeight = this.wot.wtViewport.oversizedRows[sourceRow];
  21571. if (oversizedHeight !== void 0) {
  21572. height = height === void 0 ? oversizedHeight : Math.max(height, oversizedHeight);
  21573. }
  21574. return height;
  21575. }
  21576. }, {
  21577. key: 'getColumnHeaderHeight',
  21578. value: function getColumnHeaderHeight(level) {
  21579. var height = this.wot.wtSettings.settings.defaultRowHeight;
  21580. var oversizedHeight = this.wot.wtViewport.oversizedColumnHeaders[level];
  21581. if (oversizedHeight !== void 0) {
  21582. height = height ? Math.max(height, oversizedHeight) : oversizedHeight;
  21583. }
  21584. return height;
  21585. }
  21586. }, {
  21587. key: 'getVisibleColumnsCount',
  21588. value: function getVisibleColumnsCount() {
  21589. return this.wot.wtViewport.columnsVisibleCalculator.count;
  21590. }
  21591. }, {
  21592. key: 'allColumnsInViewport',
  21593. value: function allColumnsInViewport() {
  21594. return this.wot.getSetting('totalColumns') == this.getVisibleColumnsCount();
  21595. }
  21596. }, {
  21597. key: 'getColumnWidth',
  21598. value: function getColumnWidth(sourceColumn) {
  21599. var width = this.wot.wtSettings.settings.columnWidth;
  21600. if (typeof width === 'function') {
  21601. width = width(sourceColumn);
  21602. } else if ((typeof width === 'undefined' ? 'undefined' : _typeof(width)) === 'object') {
  21603. width = width[sourceColumn];
  21604. }
  21605. return width || this.wot.wtSettings.settings.defaultColumnWidth;
  21606. }
  21607. }, {
  21608. key: 'getStretchedColumnWidth',
  21609. value: function getStretchedColumnWidth(sourceColumn) {
  21610. var columnWidth = this.getColumnWidth(sourceColumn);
  21611. var width = columnWidth == null ? this.instance.wtSettings.settings.defaultColumnWidth : columnWidth;
  21612. var calculator = this.wot.wtViewport.columnsRenderCalculator;
  21613. if (calculator) {
  21614. var stretchedWidth = calculator.getStretchedColumnWidth(sourceColumn, width);
  21615. if (stretchedWidth) {
  21616. width = stretchedWidth;
  21617. }
  21618. }
  21619. return width;
  21620. }
  21621. /**
  21622. * Modify row header widths provided by user in class contructor.
  21623. *
  21624. * @private
  21625. */
  21626. }, {
  21627. key: '_modifyRowHeaderWidth',
  21628. value: function _modifyRowHeaderWidth(rowHeaderWidthFactory) {
  21629. var widths = (0, _function.isFunction)(rowHeaderWidthFactory) ? rowHeaderWidthFactory() : null;
  21630. if (Array.isArray(widths)) {
  21631. widths = [].concat(_toConsumableArray(widths));
  21632. widths[widths.length - 1] = this._correctRowHeaderWidth(widths[widths.length - 1]);
  21633. } else {
  21634. widths = this._correctRowHeaderWidth(widths);
  21635. }
  21636. return widths;
  21637. }
  21638. /**
  21639. * Correct row header width if necessary.
  21640. *
  21641. * @private
  21642. */
  21643. }, {
  21644. key: '_correctRowHeaderWidth',
  21645. value: function _correctRowHeaderWidth(width) {
  21646. if (typeof width !== 'number') {
  21647. width = this.wot.getSetting('defaultColumnWidth');
  21648. }
  21649. if (this.correctHeaderWidth) {
  21650. width++;
  21651. }
  21652. return width;
  21653. }
  21654. }]);
  21655. return Table;
  21656. }();
  21657. exports.default = Table;
  21658. /***/ }),
  21659. /* 304 */
  21660. /***/ (function(module, exports, __webpack_require__) {
  21661. "use strict";
  21662. exports.__esModule = true;
  21663. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  21664. var _templateObject = _taggedTemplateLiteral(['Performance tip: Handsontable rendered more than 1000 visible rows. Consider limiting the number \n of rendered rows by specifying the table height and/or turning off the "renderAllRows" option.'], ['Performance tip: Handsontable rendered more than 1000 visible rows. Consider limiting the number \n of rendered rows by specifying the table height and/or turning off the "renderAllRows" option.']);
  21665. var _element = __webpack_require__(0);
  21666. var _console = __webpack_require__(56);
  21667. var _templateLiteralTag = __webpack_require__(42);
  21668. var _base = __webpack_require__(35);
  21669. var _base2 = _interopRequireDefault(_base);
  21670. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  21671. function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
  21672. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21673. var performanceWarningAppeared = false;
  21674. /**
  21675. * @class TableRenderer
  21676. */
  21677. var TableRenderer = function () {
  21678. /**
  21679. * @param {WalkontableTable} wtTable
  21680. */
  21681. function TableRenderer(wtTable) {
  21682. _classCallCheck(this, TableRenderer);
  21683. this.wtTable = wtTable;
  21684. this.wot = wtTable.instance;
  21685. // legacy support
  21686. this.instance = wtTable.instance;
  21687. this.rowFilter = wtTable.rowFilter;
  21688. this.columnFilter = wtTable.columnFilter;
  21689. this.TABLE = wtTable.TABLE;
  21690. this.THEAD = wtTable.THEAD;
  21691. this.TBODY = wtTable.TBODY;
  21692. this.COLGROUP = wtTable.COLGROUP;
  21693. this.rowHeaders = [];
  21694. this.rowHeaderCount = 0;
  21695. this.columnHeaders = [];
  21696. this.columnHeaderCount = 0;
  21697. this.fixedRowsTop = 0;
  21698. this.fixedRowsBottom = 0;
  21699. }
  21700. /**
  21701. *
  21702. */
  21703. _createClass(TableRenderer, [{
  21704. key: 'render',
  21705. value: function render() {
  21706. if (!this.wtTable.isWorkingOnClone()) {
  21707. var skipRender = {};
  21708. this.wot.getSetting('beforeDraw', true, skipRender);
  21709. if (skipRender.skipRender === true) {
  21710. return;
  21711. }
  21712. }
  21713. this.rowHeaders = this.wot.getSetting('rowHeaders');
  21714. this.rowHeaderCount = this.rowHeaders.length;
  21715. this.fixedRowsTop = this.wot.getSetting('fixedRowsTop');
  21716. this.fixedRowsBottom = this.wot.getSetting('fixedRowsBottom');
  21717. this.columnHeaders = this.wot.getSetting('columnHeaders');
  21718. this.columnHeaderCount = this.columnHeaders.length;
  21719. var columnsToRender = this.wtTable.getRenderedColumnsCount();
  21720. var rowsToRender = this.wtTable.getRenderedRowsCount();
  21721. var totalColumns = this.wot.getSetting('totalColumns');
  21722. var totalRows = this.wot.getSetting('totalRows');
  21723. var workspaceWidth = void 0;
  21724. var adjusted = false;
  21725. if (_base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_BOTTOM) || _base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_BOTTOM_LEFT_CORNER)) {
  21726. // do NOT render headers on the bottom or bottom-left corner overlay
  21727. this.columnHeaders = [];
  21728. this.columnHeaderCount = 0;
  21729. }
  21730. if (totalColumns >= 0) {
  21731. // prepare COL and TH elements for rendering
  21732. this.adjustAvailableNodes();
  21733. adjusted = true;
  21734. // adjust column widths according to user widths settings
  21735. this.renderColumnHeaders();
  21736. // Render table rows
  21737. this.renderRows(totalRows, rowsToRender, columnsToRender);
  21738. if (!this.wtTable.isWorkingOnClone()) {
  21739. workspaceWidth = this.wot.wtViewport.getWorkspaceWidth();
  21740. this.wot.wtViewport.containerWidth = null;
  21741. }
  21742. this.adjustColumnWidths(columnsToRender);
  21743. this.markOversizedColumnHeaders();
  21744. this.adjustColumnHeaderHeights();
  21745. }
  21746. if (!adjusted) {
  21747. this.adjustAvailableNodes();
  21748. }
  21749. this.removeRedundantRows(rowsToRender);
  21750. if (!this.wtTable.isWorkingOnClone() || this.wot.isOverlayName(_base2.default.CLONE_BOTTOM)) {
  21751. this.markOversizedRows();
  21752. }
  21753. if (!this.wtTable.isWorkingOnClone()) {
  21754. this.wot.wtViewport.createVisibleCalculators();
  21755. this.wot.wtOverlays.refresh(false);
  21756. this.wot.wtOverlays.applyToDOM();
  21757. var hiderWidth = (0, _element.outerWidth)(this.wtTable.hider);
  21758. var tableWidth = (0, _element.outerWidth)(this.wtTable.TABLE);
  21759. if (hiderWidth !== 0 && tableWidth !== hiderWidth) {
  21760. // Recalculate the column widths, if width changes made in the overlays removed the scrollbar, thus changing the viewport width.
  21761. this.adjustColumnWidths(columnsToRender);
  21762. }
  21763. if (workspaceWidth !== this.wot.wtViewport.getWorkspaceWidth()) {
  21764. // workspace width changed though to shown/hidden vertical scrollbar. Let's reapply stretching
  21765. this.wot.wtViewport.containerWidth = null;
  21766. var firstRendered = this.wtTable.getFirstRenderedColumn();
  21767. var lastRendered = this.wtTable.getLastRenderedColumn();
  21768. var defaultColumnWidth = this.wot.getSetting('defaultColumnWidth');
  21769. var rowHeaderWidthSetting = this.wot.getSetting('rowHeaderWidth');
  21770. rowHeaderWidthSetting = this.instance.getSetting('onModifyRowHeaderWidth', rowHeaderWidthSetting);
  21771. if (rowHeaderWidthSetting != null) {
  21772. for (var i = 0; i < this.rowHeaderCount; i++) {
  21773. var width = Array.isArray(rowHeaderWidthSetting) ? rowHeaderWidthSetting[i] : rowHeaderWidthSetting;
  21774. width = width == null ? defaultColumnWidth : width;
  21775. this.COLGROUP.childNodes[i].style.width = width + 'px';
  21776. }
  21777. }
  21778. for (var _i = firstRendered; _i < lastRendered; _i++) {
  21779. var _width = this.wtTable.getStretchedColumnWidth(_i);
  21780. var renderedIndex = this.columnFilter.sourceToRendered(_i);
  21781. this.COLGROUP.childNodes[renderedIndex + this.rowHeaderCount].style.width = _width + 'px';
  21782. }
  21783. }
  21784. this.wot.getSetting('onDraw', true);
  21785. } else if (this.wot.isOverlayName(_base2.default.CLONE_BOTTOM)) {
  21786. this.wot.cloneSource.wtOverlays.adjustElementsSize();
  21787. }
  21788. }
  21789. /**
  21790. * @param {Number} renderedRowsCount
  21791. */
  21792. }, {
  21793. key: 'removeRedundantRows',
  21794. value: function removeRedundantRows(renderedRowsCount) {
  21795. while (this.wtTable.tbodyChildrenLength > renderedRowsCount) {
  21796. this.TBODY.removeChild(this.TBODY.lastChild);
  21797. this.wtTable.tbodyChildrenLength--;
  21798. }
  21799. }
  21800. /**
  21801. * @param {Number} totalRows
  21802. * @param {Number} rowsToRender
  21803. * @param {Number} columnsToRender
  21804. */
  21805. }, {
  21806. key: 'renderRows',
  21807. value: function renderRows(totalRows, rowsToRender, columnsToRender) {
  21808. var lastTD = void 0;
  21809. var TR = void 0;
  21810. var visibleRowIndex = 0;
  21811. var sourceRowIndex = this.rowFilter.renderedToSource(visibleRowIndex);
  21812. var isWorkingOnClone = this.wtTable.isWorkingOnClone();
  21813. while (sourceRowIndex < totalRows && sourceRowIndex >= 0) {
  21814. if (!performanceWarningAppeared && visibleRowIndex > 1000) {
  21815. performanceWarningAppeared = true;
  21816. (0, _console.warn)((0, _templateLiteralTag.toSingleLine)(_templateObject));
  21817. }
  21818. if (rowsToRender !== void 0 && visibleRowIndex === rowsToRender) {
  21819. // We have as much rows as needed for this clone
  21820. break;
  21821. }
  21822. TR = this.getOrCreateTrForRow(visibleRowIndex, TR);
  21823. // Render row headers
  21824. this.renderRowHeaders(sourceRowIndex, TR);
  21825. // Add and/or remove TDs to TR to match the desired number
  21826. this.adjustColumns(TR, columnsToRender + this.rowHeaderCount);
  21827. lastTD = this.renderCells(sourceRowIndex, TR, columnsToRender);
  21828. if (!isWorkingOnClone ||
  21829. // Necessary to refresh oversized row heights after editing cell in overlays
  21830. this.wot.isOverlayName(_base2.default.CLONE_BOTTOM)) {
  21831. // Reset the oversized row cache for this row
  21832. this.resetOversizedRow(sourceRowIndex);
  21833. }
  21834. if (TR.firstChild) {
  21835. // if I have 2 fixed columns with one-line content and the 3rd column has a multiline content, this is
  21836. // the way to make sure that the overlay will has same row height
  21837. var height = this.wot.wtTable.getRowHeight(sourceRowIndex);
  21838. if (height) {
  21839. // Decrease height. 1 pixel will be "replaced" by 1px border top
  21840. height--;
  21841. TR.firstChild.style.height = height + 'px';
  21842. } else {
  21843. TR.firstChild.style.height = '';
  21844. }
  21845. }
  21846. visibleRowIndex++;
  21847. sourceRowIndex = this.rowFilter.renderedToSource(visibleRowIndex);
  21848. }
  21849. }
  21850. /**
  21851. * Reset the oversized row cache for the provided index
  21852. *
  21853. * @param {Number} sourceRow Row index
  21854. */
  21855. }, {
  21856. key: 'resetOversizedRow',
  21857. value: function resetOversizedRow(sourceRow) {
  21858. if (this.wot.getSetting('externalRowCalculator')) {
  21859. return;
  21860. }
  21861. if (this.wot.wtViewport.oversizedRows && this.wot.wtViewport.oversizedRows[sourceRow]) {
  21862. this.wot.wtViewport.oversizedRows[sourceRow] = void 0;
  21863. }
  21864. }
  21865. /**
  21866. * Check if any of the rendered rows is higher than expected, and if so, cache them
  21867. */
  21868. }, {
  21869. key: 'markOversizedRows',
  21870. value: function markOversizedRows() {
  21871. if (this.wot.getSetting('externalRowCalculator')) {
  21872. return;
  21873. }
  21874. var rowCount = this.instance.wtTable.TBODY.childNodes.length;
  21875. var expectedTableHeight = rowCount * this.instance.wtSettings.settings.defaultRowHeight;
  21876. var actualTableHeight = (0, _element.innerHeight)(this.instance.wtTable.TBODY) - 1;
  21877. var previousRowHeight = void 0;
  21878. var rowInnerHeight = void 0;
  21879. var sourceRowIndex = void 0;
  21880. var currentTr = void 0;
  21881. var rowHeader = void 0;
  21882. var totalRows = this.instance.getSetting('totalRows');
  21883. if (expectedTableHeight === actualTableHeight && !this.instance.getSetting('fixedRowsBottom')) {
  21884. // If the actual table height equals rowCount * default single row height, no row is oversized -> no need to iterate over them
  21885. return;
  21886. }
  21887. while (rowCount) {
  21888. rowCount--;
  21889. sourceRowIndex = this.instance.wtTable.rowFilter.renderedToSource(rowCount);
  21890. previousRowHeight = this.instance.wtTable.getRowHeight(sourceRowIndex);
  21891. currentTr = this.instance.wtTable.getTrForRow(sourceRowIndex);
  21892. rowHeader = currentTr.querySelector('th');
  21893. if (rowHeader) {
  21894. rowInnerHeight = (0, _element.innerHeight)(rowHeader);
  21895. } else {
  21896. rowInnerHeight = (0, _element.innerHeight)(currentTr) - 1;
  21897. }
  21898. if (!previousRowHeight && this.instance.wtSettings.settings.defaultRowHeight < rowInnerHeight || previousRowHeight < rowInnerHeight) {
  21899. this.instance.wtViewport.oversizedRows[sourceRowIndex] = ++rowInnerHeight;
  21900. }
  21901. }
  21902. }
  21903. /**
  21904. * Check if any of the rendered columns is higher than expected, and if so, cache them.
  21905. */
  21906. }, {
  21907. key: 'markOversizedColumnHeaders',
  21908. value: function markOversizedColumnHeaders() {
  21909. var overlayName = this.wot.getOverlayName();
  21910. if (!this.columnHeaderCount || this.wot.wtViewport.hasOversizedColumnHeadersMarked[overlayName] || this.wtTable.isWorkingOnClone()) {
  21911. return;
  21912. }
  21913. var columnCount = this.wtTable.getRenderedColumnsCount();
  21914. for (var i = 0; i < this.columnHeaderCount; i++) {
  21915. for (var renderedColumnIndex = -1 * this.rowHeaderCount; renderedColumnIndex < columnCount; renderedColumnIndex++) {
  21916. this.markIfOversizedColumnHeader(renderedColumnIndex);
  21917. }
  21918. }
  21919. this.wot.wtViewport.hasOversizedColumnHeadersMarked[overlayName] = true;
  21920. }
  21921. /**
  21922. *
  21923. */
  21924. }, {
  21925. key: 'adjustColumnHeaderHeights',
  21926. value: function adjustColumnHeaderHeights() {
  21927. var columnHeaders = this.wot.getSetting('columnHeaders');
  21928. var children = this.wot.wtTable.THEAD.childNodes;
  21929. var oversizedColumnHeaders = this.wot.wtViewport.oversizedColumnHeaders;
  21930. for (var i = 0, len = columnHeaders.length; i < len; i++) {
  21931. if (oversizedColumnHeaders[i]) {
  21932. if (!children[i] || children[i].childNodes.length === 0) {
  21933. return;
  21934. }
  21935. children[i].childNodes[0].style.height = oversizedColumnHeaders[i] + 'px';
  21936. }
  21937. }
  21938. }
  21939. /**
  21940. * Check if column header for the specified column is higher than expected, and if so, cache it
  21941. *
  21942. * @param {Number} col Index of column
  21943. */
  21944. }, {
  21945. key: 'markIfOversizedColumnHeader',
  21946. value: function markIfOversizedColumnHeader(col) {
  21947. var sourceColIndex = this.wot.wtTable.columnFilter.renderedToSource(col);
  21948. var level = this.columnHeaderCount;
  21949. var defaultRowHeight = this.wot.wtSettings.settings.defaultRowHeight;
  21950. var previousColHeaderHeight = void 0;
  21951. var currentHeader = void 0;
  21952. var currentHeaderHeight = void 0;
  21953. var columnHeaderHeightSetting = this.wot.getSetting('columnHeaderHeight') || [];
  21954. while (level) {
  21955. level--;
  21956. previousColHeaderHeight = this.wot.wtTable.getColumnHeaderHeight(level);
  21957. currentHeader = this.wot.wtTable.getColumnHeader(sourceColIndex, level);
  21958. if (!currentHeader) {
  21959. /* eslint-disable no-continue */
  21960. continue;
  21961. }
  21962. currentHeaderHeight = (0, _element.innerHeight)(currentHeader);
  21963. if (!previousColHeaderHeight && defaultRowHeight < currentHeaderHeight || previousColHeaderHeight < currentHeaderHeight) {
  21964. this.wot.wtViewport.oversizedColumnHeaders[level] = currentHeaderHeight;
  21965. }
  21966. if (Array.isArray(columnHeaderHeightSetting)) {
  21967. if (columnHeaderHeightSetting[level] != null) {
  21968. this.wot.wtViewport.oversizedColumnHeaders[level] = columnHeaderHeightSetting[level];
  21969. }
  21970. } else if (!isNaN(columnHeaderHeightSetting)) {
  21971. this.wot.wtViewport.oversizedColumnHeaders[level] = columnHeaderHeightSetting;
  21972. }
  21973. if (this.wot.wtViewport.oversizedColumnHeaders[level] < (columnHeaderHeightSetting[level] || columnHeaderHeightSetting)) {
  21974. this.wot.wtViewport.oversizedColumnHeaders[level] = columnHeaderHeightSetting[level] || columnHeaderHeightSetting;
  21975. }
  21976. }
  21977. }
  21978. /**
  21979. * @param {Number} sourceRowIndex
  21980. * @param {HTMLTableRowElement} TR
  21981. * @param {Number} columnsToRender
  21982. * @returns {HTMLTableCellElement}
  21983. */
  21984. }, {
  21985. key: 'renderCells',
  21986. value: function renderCells(sourceRowIndex, TR, columnsToRender) {
  21987. var TD = void 0;
  21988. var sourceColIndex = void 0;
  21989. for (var visibleColIndex = 0; visibleColIndex < columnsToRender; visibleColIndex++) {
  21990. sourceColIndex = this.columnFilter.renderedToSource(visibleColIndex);
  21991. if (visibleColIndex === 0) {
  21992. TD = TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(sourceColIndex)];
  21993. } else {
  21994. TD = TD.nextSibling; // http://jsperf.com/nextsibling-vs-indexed-childnodes
  21995. }
  21996. // If the number of headers has been reduced, we need to replace excess TH with TD
  21997. if (TD.nodeName == 'TH') {
  21998. TD = replaceThWithTd(TD, TR);
  21999. }
  22000. if (!(0, _element.hasClass)(TD, 'hide')) {
  22001. TD.className = '';
  22002. }
  22003. TD.removeAttribute('style');
  22004. this.wot.wtSettings.settings.cellRenderer(sourceRowIndex, sourceColIndex, TD);
  22005. }
  22006. return TD;
  22007. }
  22008. /**
  22009. * @param {Number} columnsToRender Number of columns to render.
  22010. */
  22011. }, {
  22012. key: 'adjustColumnWidths',
  22013. value: function adjustColumnWidths(columnsToRender) {
  22014. var scrollbarCompensation = 0;
  22015. var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot;
  22016. var mainHolder = sourceInstance.wtTable.holder;
  22017. var defaultColumnWidth = this.wot.getSetting('defaultColumnWidth');
  22018. var rowHeaderWidthSetting = this.wot.getSetting('rowHeaderWidth');
  22019. if (mainHolder.offsetHeight < mainHolder.scrollHeight) {
  22020. scrollbarCompensation = (0, _element.getScrollbarWidth)();
  22021. }
  22022. this.wot.wtViewport.columnsRenderCalculator.refreshStretching(this.wot.wtViewport.getViewportWidth() - scrollbarCompensation);
  22023. rowHeaderWidthSetting = this.instance.getSetting('onModifyRowHeaderWidth', rowHeaderWidthSetting);
  22024. if (rowHeaderWidthSetting != null) {
  22025. for (var i = 0; i < this.rowHeaderCount; i++) {
  22026. var width = Array.isArray(rowHeaderWidthSetting) ? rowHeaderWidthSetting[i] : rowHeaderWidthSetting;
  22027. width = width == null ? defaultColumnWidth : width;
  22028. this.COLGROUP.childNodes[i].style.width = width + 'px';
  22029. }
  22030. }
  22031. for (var renderedColIndex = 0; renderedColIndex < columnsToRender; renderedColIndex++) {
  22032. var _width2 = this.wtTable.getStretchedColumnWidth(this.columnFilter.renderedToSource(renderedColIndex));
  22033. this.COLGROUP.childNodes[renderedColIndex + this.rowHeaderCount].style.width = _width2 + 'px';
  22034. }
  22035. }
  22036. /**
  22037. * @param {HTMLTableCellElement} TR
  22038. */
  22039. }, {
  22040. key: 'appendToTbody',
  22041. value: function appendToTbody(TR) {
  22042. this.TBODY.appendChild(TR);
  22043. this.wtTable.tbodyChildrenLength++;
  22044. }
  22045. /**
  22046. * @param {Number} rowIndex
  22047. * @param {HTMLTableRowElement} currentTr
  22048. * @returns {HTMLTableCellElement}
  22049. */
  22050. }, {
  22051. key: 'getOrCreateTrForRow',
  22052. value: function getOrCreateTrForRow(rowIndex, currentTr) {
  22053. var TR = void 0;
  22054. if (rowIndex >= this.wtTable.tbodyChildrenLength) {
  22055. TR = this.createRow();
  22056. this.appendToTbody(TR);
  22057. } else if (rowIndex === 0) {
  22058. TR = this.TBODY.firstChild;
  22059. } else {
  22060. // http://jsperf.com/nextsibling-vs-indexed-childnodes
  22061. TR = currentTr.nextSibling;
  22062. }
  22063. if (TR.className) {
  22064. TR.removeAttribute('class');
  22065. }
  22066. return TR;
  22067. }
  22068. /**
  22069. * @returns {HTMLTableCellElement}
  22070. */
  22071. }, {
  22072. key: 'createRow',
  22073. value: function createRow() {
  22074. var TR = document.createElement('TR');
  22075. for (var visibleColIndex = 0; visibleColIndex < this.rowHeaderCount; visibleColIndex++) {
  22076. TR.appendChild(document.createElement('TH'));
  22077. }
  22078. return TR;
  22079. }
  22080. /**
  22081. * @param {Number} row
  22082. * @param {Number} col
  22083. * @param {HTMLTableCellElement} TH
  22084. */
  22085. }, {
  22086. key: 'renderRowHeader',
  22087. value: function renderRowHeader(row, col, TH) {
  22088. TH.className = '';
  22089. TH.removeAttribute('style');
  22090. this.rowHeaders[col](row, TH, col);
  22091. }
  22092. /**
  22093. * @param {Number} row
  22094. * @param {HTMLTableCellElement} TR
  22095. */
  22096. }, {
  22097. key: 'renderRowHeaders',
  22098. value: function renderRowHeaders(row, TR) {
  22099. for (var TH = TR.firstChild, visibleColIndex = 0; visibleColIndex < this.rowHeaderCount; visibleColIndex++) {
  22100. // If the number of row headers increased we need to create TH or replace an existing TD node with TH
  22101. if (!TH) {
  22102. TH = document.createElement('TH');
  22103. TR.appendChild(TH);
  22104. } else if (TH.nodeName == 'TD') {
  22105. TH = replaceTdWithTh(TH, TR);
  22106. }
  22107. this.renderRowHeader(row, visibleColIndex, TH);
  22108. // http://jsperf.com/nextsibling-vs-indexed-childnodes
  22109. TH = TH.nextSibling;
  22110. }
  22111. }
  22112. /**
  22113. * Adjust the number of COL and TH elements to match the number of columns and headers that need to be rendered
  22114. */
  22115. }, {
  22116. key: 'adjustAvailableNodes',
  22117. value: function adjustAvailableNodes() {
  22118. this.adjustColGroups();
  22119. this.adjustThead();
  22120. }
  22121. /**
  22122. * Renders the column headers
  22123. */
  22124. }, {
  22125. key: 'renderColumnHeaders',
  22126. value: function renderColumnHeaders() {
  22127. if (!this.columnHeaderCount) {
  22128. return;
  22129. }
  22130. var columnCount = this.wtTable.getRenderedColumnsCount();
  22131. for (var i = 0; i < this.columnHeaderCount; i++) {
  22132. var TR = this.getTrForColumnHeaders(i);
  22133. for (var renderedColumnIndex = -1 * this.rowHeaderCount; renderedColumnIndex < columnCount; renderedColumnIndex++) {
  22134. var sourceCol = this.columnFilter.renderedToSource(renderedColumnIndex);
  22135. this.renderColumnHeader(i, sourceCol, TR.childNodes[renderedColumnIndex + this.rowHeaderCount]);
  22136. }
  22137. }
  22138. }
  22139. /**
  22140. * Adjusts the number of COL elements to match the number of columns that need to be rendered
  22141. */
  22142. }, {
  22143. key: 'adjustColGroups',
  22144. value: function adjustColGroups() {
  22145. var columnCount = this.wtTable.getRenderedColumnsCount();
  22146. while (this.wtTable.colgroupChildrenLength < columnCount + this.rowHeaderCount) {
  22147. this.COLGROUP.appendChild(document.createElement('COL'));
  22148. this.wtTable.colgroupChildrenLength++;
  22149. }
  22150. while (this.wtTable.colgroupChildrenLength > columnCount + this.rowHeaderCount) {
  22151. this.COLGROUP.removeChild(this.COLGROUP.lastChild);
  22152. this.wtTable.colgroupChildrenLength--;
  22153. }
  22154. if (this.rowHeaderCount) {
  22155. (0, _element.addClass)(this.COLGROUP.childNodes[0], 'rowHeader');
  22156. }
  22157. }
  22158. /**
  22159. * Adjusts the number of TH elements in THEAD to match the number of headers and columns that need to be rendered
  22160. */
  22161. }, {
  22162. key: 'adjustThead',
  22163. value: function adjustThead() {
  22164. var columnCount = this.wtTable.getRenderedColumnsCount();
  22165. var TR = this.THEAD.firstChild;
  22166. if (this.columnHeaders.length) {
  22167. for (var i = 0, len = this.columnHeaders.length; i < len; i++) {
  22168. TR = this.THEAD.childNodes[i];
  22169. if (!TR) {
  22170. TR = document.createElement('TR');
  22171. this.THEAD.appendChild(TR);
  22172. }
  22173. this.theadChildrenLength = TR.childNodes.length;
  22174. while (this.theadChildrenLength < columnCount + this.rowHeaderCount) {
  22175. TR.appendChild(document.createElement('TH'));
  22176. this.theadChildrenLength++;
  22177. }
  22178. while (this.theadChildrenLength > columnCount + this.rowHeaderCount) {
  22179. TR.removeChild(TR.lastChild);
  22180. this.theadChildrenLength--;
  22181. }
  22182. }
  22183. var theadChildrenLength = this.THEAD.childNodes.length;
  22184. if (theadChildrenLength > this.columnHeaders.length) {
  22185. for (var _i2 = this.columnHeaders.length; _i2 < theadChildrenLength; _i2++) {
  22186. this.THEAD.removeChild(this.THEAD.lastChild);
  22187. }
  22188. }
  22189. } else if (TR) {
  22190. (0, _element.empty)(TR);
  22191. }
  22192. }
  22193. /**
  22194. * @param {Number} index
  22195. * @returns {HTMLTableCellElement}
  22196. */
  22197. }, {
  22198. key: 'getTrForColumnHeaders',
  22199. value: function getTrForColumnHeaders(index) {
  22200. return this.THEAD.childNodes[index];
  22201. }
  22202. /**
  22203. * @param {Number} row
  22204. * @param {Number} col
  22205. * @param {HTMLTableCellElement} TH
  22206. * @returns {*}
  22207. */
  22208. }, {
  22209. key: 'renderColumnHeader',
  22210. value: function renderColumnHeader(row, col, TH) {
  22211. TH.className = '';
  22212. TH.removeAttribute('style');
  22213. return this.columnHeaders[row](col, TH, row);
  22214. }
  22215. /**
  22216. * Add and/or remove the TDs to match the desired number
  22217. *
  22218. * @param {HTMLTableCellElement} TR Table row in question
  22219. * @param {Number} desiredCount The desired number of TDs in the TR
  22220. */
  22221. }, {
  22222. key: 'adjustColumns',
  22223. value: function adjustColumns(TR, desiredCount) {
  22224. var count = TR.childNodes.length;
  22225. while (count < desiredCount) {
  22226. var TD = document.createElement('TD');
  22227. TR.appendChild(TD);
  22228. count++;
  22229. }
  22230. while (count > desiredCount) {
  22231. TR.removeChild(TR.lastChild);
  22232. count--;
  22233. }
  22234. }
  22235. /**
  22236. * @param {Number} columnsToRender
  22237. */
  22238. }, {
  22239. key: 'removeRedundantColumns',
  22240. value: function removeRedundantColumns(columnsToRender) {
  22241. while (this.wtTable.tbodyChildrenLength > columnsToRender) {
  22242. this.TBODY.removeChild(this.TBODY.lastChild);
  22243. this.wtTable.tbodyChildrenLength--;
  22244. }
  22245. }
  22246. }]);
  22247. return TableRenderer;
  22248. }();
  22249. function replaceTdWithTh(TD, TR) {
  22250. var TH = document.createElement('TH');
  22251. TR.insertBefore(TH, TD);
  22252. TR.removeChild(TD);
  22253. return TH;
  22254. }
  22255. function replaceThWithTd(TH, TR) {
  22256. var TD = document.createElement('TD');
  22257. TR.insertBefore(TD, TH);
  22258. TR.removeChild(TH);
  22259. return TD;
  22260. }
  22261. exports.default = TableRenderer;
  22262. /***/ }),
  22263. /* 305 */
  22264. /***/ (function(module, exports, __webpack_require__) {
  22265. "use strict";
  22266. exports.__esModule = true;
  22267. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  22268. var _element = __webpack_require__(0);
  22269. var _object = __webpack_require__(2);
  22270. var _eventManager = __webpack_require__(6);
  22271. var _eventManager2 = _interopRequireDefault(_eventManager);
  22272. var _viewportColumns = __webpack_require__(175);
  22273. var _viewportColumns2 = _interopRequireDefault(_viewportColumns);
  22274. var _viewportRows = __webpack_require__(176);
  22275. var _viewportRows2 = _interopRequireDefault(_viewportRows);
  22276. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  22277. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  22278. /**
  22279. * @class Viewport
  22280. */
  22281. var Viewport = function () {
  22282. /**
  22283. * @param wotInstance
  22284. */
  22285. function Viewport(wotInstance) {
  22286. var _this = this;
  22287. _classCallCheck(this, Viewport);
  22288. this.wot = wotInstance;
  22289. // legacy support
  22290. this.instance = this.wot;
  22291. this.oversizedRows = [];
  22292. this.oversizedColumnHeaders = [];
  22293. this.hasOversizedColumnHeadersMarked = {};
  22294. this.clientHeight = 0;
  22295. this.containerWidth = NaN;
  22296. this.rowHeaderWidth = NaN;
  22297. this.rowsVisibleCalculator = null;
  22298. this.columnsVisibleCalculator = null;
  22299. this.eventManager = new _eventManager2.default(this.wot);
  22300. this.eventManager.addEventListener(window, 'resize', function () {
  22301. _this.clientHeight = _this.getWorkspaceHeight();
  22302. });
  22303. }
  22304. /**
  22305. * @returns {number}
  22306. */
  22307. _createClass(Viewport, [{
  22308. key: 'getWorkspaceHeight',
  22309. value: function getWorkspaceHeight() {
  22310. var trimmingContainer = this.instance.wtOverlays.topOverlay.trimmingContainer;
  22311. var elemHeight = void 0;
  22312. var height = 0;
  22313. if (trimmingContainer === window) {
  22314. height = document.documentElement.clientHeight;
  22315. } else {
  22316. elemHeight = (0, _element.outerHeight)(trimmingContainer);
  22317. // returns height without DIV scrollbar
  22318. height = elemHeight > 0 && trimmingContainer.clientHeight > 0 ? trimmingContainer.clientHeight : Infinity;
  22319. }
  22320. return height;
  22321. }
  22322. }, {
  22323. key: 'getWorkspaceWidth',
  22324. value: function getWorkspaceWidth() {
  22325. var width = void 0;
  22326. var totalColumns = this.wot.getSetting('totalColumns');
  22327. var trimmingContainer = this.instance.wtOverlays.leftOverlay.trimmingContainer;
  22328. var overflow = void 0;
  22329. var stretchSetting = this.wot.getSetting('stretchH');
  22330. var docOffsetWidth = document.documentElement.offsetWidth;
  22331. var preventOverflow = this.wot.getSetting('preventOverflow');
  22332. if (preventOverflow) {
  22333. return (0, _element.outerWidth)(this.instance.wtTable.wtRootElement);
  22334. }
  22335. if (this.wot.getSetting('freezeOverlays')) {
  22336. width = Math.min(docOffsetWidth - this.getWorkspaceOffset().left, docOffsetWidth);
  22337. } else {
  22338. width = Math.min(this.getContainerFillWidth(), docOffsetWidth - this.getWorkspaceOffset().left, docOffsetWidth);
  22339. }
  22340. if (trimmingContainer === window && totalColumns > 0 && this.sumColumnWidths(0, totalColumns - 1) > width) {
  22341. // in case sum of column widths is higher than available stylesheet width, let's assume using the whole window
  22342. // otherwise continue below, which will allow stretching
  22343. // this is used in `scroll_window.html`
  22344. // TODO test me
  22345. return document.documentElement.clientWidth;
  22346. }
  22347. if (trimmingContainer !== window) {
  22348. overflow = (0, _element.getStyle)(this.instance.wtOverlays.leftOverlay.trimmingContainer, 'overflow');
  22349. if (overflow == 'scroll' || overflow == 'hidden' || overflow == 'auto') {
  22350. // this is used in `scroll.html`
  22351. // TODO test me
  22352. return Math.max(width, trimmingContainer.clientWidth);
  22353. }
  22354. }
  22355. if (stretchSetting === 'none' || !stretchSetting) {
  22356. // if no stretching is used, return the maximum used workspace width
  22357. return Math.max(width, (0, _element.outerWidth)(this.instance.wtTable.TABLE));
  22358. }
  22359. // if stretching is used, return the actual container width, so the columns can fit inside it
  22360. return width;
  22361. }
  22362. /**
  22363. * Checks if viewport has vertical scroll
  22364. *
  22365. * @returns {Boolean}
  22366. */
  22367. }, {
  22368. key: 'hasVerticalScroll',
  22369. value: function hasVerticalScroll() {
  22370. return this.getWorkspaceActualHeight() > this.getWorkspaceHeight();
  22371. }
  22372. /**
  22373. * Checks if viewport has horizontal scroll
  22374. *
  22375. * @returns {Boolean}
  22376. */
  22377. }, {
  22378. key: 'hasHorizontalScroll',
  22379. value: function hasHorizontalScroll() {
  22380. return this.getWorkspaceActualWidth() > this.getWorkspaceWidth();
  22381. }
  22382. /**
  22383. * @param from
  22384. * @param length
  22385. * @returns {Number}
  22386. */
  22387. }, {
  22388. key: 'sumColumnWidths',
  22389. value: function sumColumnWidths(from, length) {
  22390. var sum = 0;
  22391. while (from < length) {
  22392. sum += this.wot.wtTable.getColumnWidth(from);
  22393. from++;
  22394. }
  22395. return sum;
  22396. }
  22397. /**
  22398. * @returns {Number}
  22399. */
  22400. }, {
  22401. key: 'getContainerFillWidth',
  22402. value: function getContainerFillWidth() {
  22403. if (this.containerWidth) {
  22404. return this.containerWidth;
  22405. }
  22406. var mainContainer = this.instance.wtTable.holder;
  22407. var fillWidth = void 0;
  22408. var dummyElement = void 0;
  22409. dummyElement = document.createElement('div');
  22410. dummyElement.style.width = '100%';
  22411. dummyElement.style.height = '1px';
  22412. mainContainer.appendChild(dummyElement);
  22413. fillWidth = dummyElement.offsetWidth;
  22414. this.containerWidth = fillWidth;
  22415. mainContainer.removeChild(dummyElement);
  22416. return fillWidth;
  22417. }
  22418. /**
  22419. * @returns {Number}
  22420. */
  22421. }, {
  22422. key: 'getWorkspaceOffset',
  22423. value: function getWorkspaceOffset() {
  22424. return (0, _element.offset)(this.wot.wtTable.TABLE);
  22425. }
  22426. /**
  22427. * @returns {Number}
  22428. */
  22429. }, {
  22430. key: 'getWorkspaceActualHeight',
  22431. value: function getWorkspaceActualHeight() {
  22432. return (0, _element.outerHeight)(this.wot.wtTable.TABLE);
  22433. }
  22434. /**
  22435. * @returns {Number}
  22436. */
  22437. }, {
  22438. key: 'getWorkspaceActualWidth',
  22439. value: function getWorkspaceActualWidth() {
  22440. return (0, _element.outerWidth)(this.wot.wtTable.TABLE) || (0, _element.outerWidth)(this.wot.wtTable.TBODY) || (0, _element.outerWidth)(this.wot.wtTable.THEAD); // IE8 reports 0 as <table> offsetWidth;
  22441. }
  22442. /**
  22443. * @returns {Number}
  22444. */
  22445. }, {
  22446. key: 'getColumnHeaderHeight',
  22447. value: function getColumnHeaderHeight() {
  22448. if (isNaN(this.columnHeaderHeight)) {
  22449. this.columnHeaderHeight = (0, _element.outerHeight)(this.wot.wtTable.THEAD);
  22450. }
  22451. return this.columnHeaderHeight;
  22452. }
  22453. /**
  22454. * @returns {Number}
  22455. */
  22456. }, {
  22457. key: 'getViewportHeight',
  22458. value: function getViewportHeight() {
  22459. var containerHeight = this.getWorkspaceHeight();
  22460. var columnHeaderHeight = void 0;
  22461. if (containerHeight === Infinity) {
  22462. return containerHeight;
  22463. }
  22464. columnHeaderHeight = this.getColumnHeaderHeight();
  22465. if (columnHeaderHeight > 0) {
  22466. containerHeight -= columnHeaderHeight;
  22467. }
  22468. return containerHeight;
  22469. }
  22470. /**
  22471. * @returns {Number}
  22472. */
  22473. }, {
  22474. key: 'getRowHeaderWidth',
  22475. value: function getRowHeaderWidth() {
  22476. var rowHeadersHeightSetting = this.instance.getSetting('rowHeaderWidth');
  22477. var rowHeaders = this.instance.getSetting('rowHeaders');
  22478. if (rowHeadersHeightSetting) {
  22479. this.rowHeaderWidth = 0;
  22480. for (var i = 0, len = rowHeaders.length; i < len; i++) {
  22481. this.rowHeaderWidth += rowHeadersHeightSetting[i] || rowHeadersHeightSetting;
  22482. }
  22483. }
  22484. if (this.wot.cloneSource) {
  22485. return this.wot.cloneSource.wtViewport.getRowHeaderWidth();
  22486. }
  22487. if (isNaN(this.rowHeaderWidth)) {
  22488. if (rowHeaders.length) {
  22489. var TH = this.instance.wtTable.TABLE.querySelector('TH');
  22490. this.rowHeaderWidth = 0;
  22491. for (var _i = 0, _len = rowHeaders.length; _i < _len; _i++) {
  22492. if (TH) {
  22493. this.rowHeaderWidth += (0, _element.outerWidth)(TH);
  22494. TH = TH.nextSibling;
  22495. } else {
  22496. // yes this is a cheat but it worked like that before, just taking assumption from CSS instead of measuring.
  22497. // TODO: proper fix
  22498. this.rowHeaderWidth += 50;
  22499. }
  22500. }
  22501. } else {
  22502. this.rowHeaderWidth = 0;
  22503. }
  22504. }
  22505. this.rowHeaderWidth = this.instance.getSetting('onModifyRowHeaderWidth', this.rowHeaderWidth) || this.rowHeaderWidth;
  22506. return this.rowHeaderWidth;
  22507. }
  22508. /**
  22509. * @returns {Number}
  22510. */
  22511. }, {
  22512. key: 'getViewportWidth',
  22513. value: function getViewportWidth() {
  22514. var containerWidth = this.getWorkspaceWidth();
  22515. var rowHeaderWidth = void 0;
  22516. if (containerWidth === Infinity) {
  22517. return containerWidth;
  22518. }
  22519. rowHeaderWidth = this.getRowHeaderWidth();
  22520. if (rowHeaderWidth > 0) {
  22521. return containerWidth - rowHeaderWidth;
  22522. }
  22523. return containerWidth;
  22524. }
  22525. /**
  22526. * Creates:
  22527. * - rowsRenderCalculator (before draw, to qualify rows for rendering)
  22528. * - rowsVisibleCalculator (after draw, to measure which rows are actually visible)
  22529. *
  22530. * @returns {ViewportRowsCalculator}
  22531. */
  22532. }, {
  22533. key: 'createRowsCalculator',
  22534. value: function createRowsCalculator() {
  22535. var _this2 = this;
  22536. var visible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  22537. var height = void 0;
  22538. var pos = void 0;
  22539. var fixedRowsTop = void 0;
  22540. var scrollbarHeight = void 0;
  22541. var fixedRowsBottom = void 0;
  22542. var fixedRowsHeight = void 0;
  22543. var totalRows = void 0;
  22544. this.rowHeaderWidth = NaN;
  22545. if (this.wot.wtSettings.settings.renderAllRows && !visible) {
  22546. height = Infinity;
  22547. } else {
  22548. height = this.getViewportHeight();
  22549. }
  22550. pos = this.wot.wtOverlays.topOverlay.getScrollPosition() - this.wot.wtOverlays.topOverlay.getTableParentOffset();
  22551. if (pos < 0) {
  22552. pos = 0;
  22553. }
  22554. fixedRowsTop = this.wot.getSetting('fixedRowsTop');
  22555. fixedRowsBottom = this.wot.getSetting('fixedRowsBottom');
  22556. totalRows = this.wot.getSetting('totalRows');
  22557. if (fixedRowsTop) {
  22558. fixedRowsHeight = this.wot.wtOverlays.topOverlay.sumCellSizes(0, fixedRowsTop);
  22559. pos += fixedRowsHeight;
  22560. height -= fixedRowsHeight;
  22561. }
  22562. if (fixedRowsBottom && this.wot.wtOverlays.bottomOverlay.clone) {
  22563. fixedRowsHeight = this.wot.wtOverlays.bottomOverlay.sumCellSizes(totalRows - fixedRowsBottom, totalRows);
  22564. height -= fixedRowsHeight;
  22565. }
  22566. if (this.wot.wtTable.holder.clientHeight === this.wot.wtTable.holder.offsetHeight) {
  22567. scrollbarHeight = 0;
  22568. } else {
  22569. scrollbarHeight = (0, _element.getScrollbarWidth)();
  22570. }
  22571. return new _viewportRows2.default(height, pos, this.wot.getSetting('totalRows'), function (sourceRow) {
  22572. return _this2.wot.wtTable.getRowHeight(sourceRow);
  22573. }, visible ? null : this.wot.wtSettings.settings.viewportRowCalculatorOverride, visible, scrollbarHeight);
  22574. }
  22575. /**
  22576. * Creates:
  22577. * - columnsRenderCalculator (before draw, to qualify columns for rendering)
  22578. * - columnsVisibleCalculator (after draw, to measure which columns are actually visible)
  22579. *
  22580. * @returns {ViewportRowsCalculator}
  22581. */
  22582. }, {
  22583. key: 'createColumnsCalculator',
  22584. value: function createColumnsCalculator() {
  22585. var _this3 = this;
  22586. var visible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  22587. var width = this.getViewportWidth();
  22588. var pos = void 0;
  22589. var fixedColumnsLeft = void 0;
  22590. this.columnHeaderHeight = NaN;
  22591. pos = this.wot.wtOverlays.leftOverlay.getScrollPosition() - this.wot.wtOverlays.leftOverlay.getTableParentOffset();
  22592. if (pos < 0) {
  22593. pos = 0;
  22594. }
  22595. fixedColumnsLeft = this.wot.getSetting('fixedColumnsLeft');
  22596. if (fixedColumnsLeft) {
  22597. var fixedColumnsWidth = this.wot.wtOverlays.leftOverlay.sumCellSizes(0, fixedColumnsLeft);
  22598. pos += fixedColumnsWidth;
  22599. width -= fixedColumnsWidth;
  22600. }
  22601. if (this.wot.wtTable.holder.clientWidth !== this.wot.wtTable.holder.offsetWidth) {
  22602. width -= (0, _element.getScrollbarWidth)();
  22603. }
  22604. return new _viewportColumns2.default(width, pos, this.wot.getSetting('totalColumns'), function (sourceCol) {
  22605. return _this3.wot.wtTable.getColumnWidth(sourceCol);
  22606. }, visible ? null : this.wot.wtSettings.settings.viewportColumnCalculatorOverride, visible, this.wot.getSetting('stretchH'), function (stretchedWidth, column) {
  22607. return _this3.wot.getSetting('onBeforeStretchingColumnWidth', stretchedWidth, column);
  22608. });
  22609. }
  22610. /**
  22611. * Creates rowsRenderCalculator and columnsRenderCalculator (before draw, to determine what rows and
  22612. * cols should be rendered)
  22613. *
  22614. * @param fastDraw {Boolean} If `true`, will try to avoid full redraw and only update the border positions.
  22615. * If `false` or `undefined`, will perform a full redraw
  22616. * @returns fastDraw {Boolean} The fastDraw value, possibly modified
  22617. */
  22618. }, {
  22619. key: 'createRenderCalculators',
  22620. value: function createRenderCalculators() {
  22621. var fastDraw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  22622. if (fastDraw) {
  22623. var proposedRowsVisibleCalculator = this.createRowsCalculator(true);
  22624. var proposedColumnsVisibleCalculator = this.createColumnsCalculator(true);
  22625. if (!(this.areAllProposedVisibleRowsAlreadyRendered(proposedRowsVisibleCalculator) && this.areAllProposedVisibleColumnsAlreadyRendered(proposedColumnsVisibleCalculator))) {
  22626. fastDraw = false;
  22627. }
  22628. }
  22629. if (!fastDraw) {
  22630. this.rowsRenderCalculator = this.createRowsCalculator();
  22631. this.columnsRenderCalculator = this.createColumnsCalculator();
  22632. }
  22633. // delete temporarily to make sure that renderers always use rowsRenderCalculator, not rowsVisibleCalculator
  22634. this.rowsVisibleCalculator = null;
  22635. this.columnsVisibleCalculator = null;
  22636. return fastDraw;
  22637. }
  22638. /**
  22639. * Creates rowsVisibleCalculator and columnsVisibleCalculator (after draw, to determine what are
  22640. * the actually visible rows and columns)
  22641. */
  22642. }, {
  22643. key: 'createVisibleCalculators',
  22644. value: function createVisibleCalculators() {
  22645. this.rowsVisibleCalculator = this.createRowsCalculator(true);
  22646. this.columnsVisibleCalculator = this.createColumnsCalculator(true);
  22647. }
  22648. /**
  22649. * Returns information whether proposedRowsVisibleCalculator viewport
  22650. * is contained inside rows rendered in previous draw (cached in rowsRenderCalculator)
  22651. *
  22652. * @param {Object} proposedRowsVisibleCalculator
  22653. * @returns {Boolean} Returns `true` if all proposed visible rows are already rendered (meaning: redraw is not needed).
  22654. * Returns `false` if at least one proposed visible row is not already rendered (meaning: redraw is needed)
  22655. */
  22656. }, {
  22657. key: 'areAllProposedVisibleRowsAlreadyRendered',
  22658. value: function areAllProposedVisibleRowsAlreadyRendered(proposedRowsVisibleCalculator) {
  22659. if (this.rowsVisibleCalculator) {
  22660. if (proposedRowsVisibleCalculator.startRow < this.rowsRenderCalculator.startRow || proposedRowsVisibleCalculator.startRow === this.rowsRenderCalculator.startRow && proposedRowsVisibleCalculator.startRow > 0) {
  22661. return false;
  22662. } else if (proposedRowsVisibleCalculator.endRow > this.rowsRenderCalculator.endRow || proposedRowsVisibleCalculator.endRow === this.rowsRenderCalculator.endRow && proposedRowsVisibleCalculator.endRow < this.wot.getSetting('totalRows') - 1) {
  22663. return false;
  22664. }
  22665. return true;
  22666. }
  22667. return false;
  22668. }
  22669. /**
  22670. * Returns information whether proposedColumnsVisibleCalculator viewport
  22671. * is contained inside column rendered in previous draw (cached in columnsRenderCalculator)
  22672. *
  22673. * @param {Object} proposedColumnsVisibleCalculator
  22674. * @returns {Boolean} Returns `true` if all proposed visible columns are already rendered (meaning: redraw is not needed).
  22675. * Returns `false` if at least one proposed visible column is not already rendered (meaning: redraw is needed)
  22676. */
  22677. }, {
  22678. key: 'areAllProposedVisibleColumnsAlreadyRendered',
  22679. value: function areAllProposedVisibleColumnsAlreadyRendered(proposedColumnsVisibleCalculator) {
  22680. if (this.columnsVisibleCalculator) {
  22681. if (proposedColumnsVisibleCalculator.startColumn < this.columnsRenderCalculator.startColumn || proposedColumnsVisibleCalculator.startColumn === this.columnsRenderCalculator.startColumn && proposedColumnsVisibleCalculator.startColumn > 0) {
  22682. return false;
  22683. } else if (proposedColumnsVisibleCalculator.endColumn > this.columnsRenderCalculator.endColumn || proposedColumnsVisibleCalculator.endColumn === this.columnsRenderCalculator.endColumn && proposedColumnsVisibleCalculator.endColumn < this.wot.getSetting('totalColumns') - 1) {
  22684. return false;
  22685. }
  22686. return true;
  22687. }
  22688. return false;
  22689. }
  22690. /**
  22691. * Resets values in keys of the hasOversizedColumnHeadersMarked object after updateSettings.
  22692. */
  22693. }, {
  22694. key: 'resetHasOversizedColumnHeadersMarked',
  22695. value: function resetHasOversizedColumnHeadersMarked() {
  22696. (0, _object.objectEach)(this.hasOversizedColumnHeadersMarked, function (value, key, object) {
  22697. object[key] = void 0;
  22698. });
  22699. }
  22700. }]);
  22701. return Viewport;
  22702. }();
  22703. exports.default = Viewport;
  22704. /***/ }),
  22705. /* 306 */
  22706. /***/ (function(module, exports, __webpack_require__) {
  22707. "use strict";
  22708. exports.__esModule = true;
  22709. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  22710. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  22711. var _element = __webpack_require__(0);
  22712. var _event = __webpack_require__(12);
  22713. var _object = __webpack_require__(2);
  22714. var _browser = __webpack_require__(27);
  22715. var _eventManager = __webpack_require__(6);
  22716. var _eventManager2 = _interopRequireDefault(_eventManager);
  22717. var _coords = __webpack_require__(55);
  22718. var _coords2 = _interopRequireDefault(_coords);
  22719. var _base = __webpack_require__(35);
  22720. var _base2 = _interopRequireDefault(_base);
  22721. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  22722. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  22723. /**
  22724. *
  22725. */
  22726. var Border = function () {
  22727. /**
  22728. * @param {Walkontable} wotInstance
  22729. * @param {Object} settings
  22730. */
  22731. function Border(wotInstance, settings) {
  22732. _classCallCheck(this, Border);
  22733. if (!settings) {
  22734. return;
  22735. }
  22736. this.eventManager = new _eventManager2.default(wotInstance);
  22737. this.instance = wotInstance;
  22738. this.wot = wotInstance;
  22739. this.settings = settings;
  22740. this.mouseDown = false;
  22741. this.main = null;
  22742. this.top = null;
  22743. this.left = null;
  22744. this.bottom = null;
  22745. this.right = null;
  22746. this.topStyle = null;
  22747. this.leftStyle = null;
  22748. this.bottomStyle = null;
  22749. this.rightStyle = null;
  22750. this.cornerDefaultStyle = {
  22751. width: '6px',
  22752. height: '6px',
  22753. borderWidth: '1px',
  22754. borderStyle: 'solid',
  22755. borderColor: '#FFF'
  22756. };
  22757. this.corner = null;
  22758. this.cornerStyle = null;
  22759. this.createBorders(settings);
  22760. this.registerListeners();
  22761. }
  22762. /**
  22763. * Register all necessary events
  22764. */
  22765. _createClass(Border, [{
  22766. key: 'registerListeners',
  22767. value: function registerListeners() {
  22768. var _this2 = this;
  22769. this.eventManager.addEventListener(document.body, 'mousedown', function () {
  22770. return _this2.onMouseDown();
  22771. });
  22772. this.eventManager.addEventListener(document.body, 'mouseup', function () {
  22773. return _this2.onMouseUp();
  22774. });
  22775. var _loop = function _loop(c, len) {
  22776. _this2.eventManager.addEventListener(_this2.main.childNodes[c], 'mouseenter', function (event) {
  22777. return _this2.onMouseEnter(event, _this2.main.childNodes[c]);
  22778. });
  22779. };
  22780. for (var c = 0, len = this.main.childNodes.length; c < len; c++) {
  22781. _loop(c, len);
  22782. }
  22783. }
  22784. /**
  22785. * Mouse down listener
  22786. *
  22787. * @private
  22788. */
  22789. }, {
  22790. key: 'onMouseDown',
  22791. value: function onMouseDown() {
  22792. this.mouseDown = true;
  22793. }
  22794. /**
  22795. * Mouse up listener
  22796. *
  22797. * @private
  22798. */
  22799. }, {
  22800. key: 'onMouseUp',
  22801. value: function onMouseUp() {
  22802. this.mouseDown = false;
  22803. }
  22804. /**
  22805. * Mouse enter listener for fragment selection functionality.
  22806. *
  22807. * @private
  22808. * @param {Event} event Dom event
  22809. * @param {HTMLElement} parentElement Part of border element.
  22810. */
  22811. }, {
  22812. key: 'onMouseEnter',
  22813. value: function onMouseEnter(event, parentElement) {
  22814. if (!this.mouseDown || !this.wot.getSetting('hideBorderOnMouseDownOver')) {
  22815. return;
  22816. }
  22817. event.preventDefault();
  22818. (0, _event.stopImmediatePropagation)(event);
  22819. var _this = this;
  22820. var bounds = parentElement.getBoundingClientRect();
  22821. // Hide border to prevents selection jumping when fragmentSelection is enabled.
  22822. parentElement.style.display = 'none';
  22823. function isOutside(event) {
  22824. if (event.clientY < Math.floor(bounds.top)) {
  22825. return true;
  22826. }
  22827. if (event.clientY > Math.ceil(bounds.top + bounds.height)) {
  22828. return true;
  22829. }
  22830. if (event.clientX < Math.floor(bounds.left)) {
  22831. return true;
  22832. }
  22833. if (event.clientX > Math.ceil(bounds.left + bounds.width)) {
  22834. return true;
  22835. }
  22836. }
  22837. function handler(event) {
  22838. if (isOutside(event)) {
  22839. _this.eventManager.removeEventListener(document.body, 'mousemove', handler);
  22840. parentElement.style.display = 'block';
  22841. }
  22842. }
  22843. this.eventManager.addEventListener(document.body, 'mousemove', handler);
  22844. }
  22845. /**
  22846. * Create border elements
  22847. *
  22848. * @param {Object} settings
  22849. */
  22850. }, {
  22851. key: 'createBorders',
  22852. value: function createBorders(settings) {
  22853. this.main = document.createElement('div');
  22854. var borderDivs = ['top', 'left', 'bottom', 'right', 'corner'];
  22855. var style = this.main.style;
  22856. style.position = 'absolute';
  22857. style.top = 0;
  22858. style.left = 0;
  22859. for (var i = 0; i < 5; i++) {
  22860. var position = borderDivs[i];
  22861. var div = document.createElement('div');
  22862. div.className = 'wtBorder ' + (this.settings.className || ''); // + borderDivs[i];
  22863. if (this.settings[position] && this.settings[position].hide) {
  22864. div.className += ' hidden';
  22865. }
  22866. style = div.style;
  22867. style.backgroundColor = this.settings[position] && this.settings[position].color ? this.settings[position].color : settings.border.color;
  22868. style.height = this.settings[position] && this.settings[position].width ? this.settings[position].width + 'px' : settings.border.width + 'px';
  22869. style.width = this.settings[position] && this.settings[position].width ? this.settings[position].width + 'px' : settings.border.width + 'px';
  22870. this.main.appendChild(div);
  22871. }
  22872. this.top = this.main.childNodes[0];
  22873. this.left = this.main.childNodes[1];
  22874. this.bottom = this.main.childNodes[2];
  22875. this.right = this.main.childNodes[3];
  22876. this.topStyle = this.top.style;
  22877. this.leftStyle = this.left.style;
  22878. this.bottomStyle = this.bottom.style;
  22879. this.rightStyle = this.right.style;
  22880. this.corner = this.main.childNodes[4];
  22881. this.corner.className += ' corner';
  22882. this.cornerStyle = this.corner.style;
  22883. this.cornerStyle.width = this.cornerDefaultStyle.width;
  22884. this.cornerStyle.height = this.cornerDefaultStyle.height;
  22885. this.cornerStyle.border = [this.cornerDefaultStyle.borderWidth, this.cornerDefaultStyle.borderStyle, this.cornerDefaultStyle.borderColor].join(' ');
  22886. if ((0, _browser.isMobileBrowser)()) {
  22887. this.createMultipleSelectorHandles();
  22888. }
  22889. this.disappear();
  22890. if (!this.wot.wtTable.bordersHolder) {
  22891. this.wot.wtTable.bordersHolder = document.createElement('div');
  22892. this.wot.wtTable.bordersHolder.className = 'htBorders';
  22893. this.wot.wtTable.spreader.appendChild(this.wot.wtTable.bordersHolder);
  22894. }
  22895. this.wot.wtTable.bordersHolder.insertBefore(this.main, this.wot.wtTable.bordersHolder.firstChild);
  22896. }
  22897. /**
  22898. * Create multiple selector handler for mobile devices
  22899. */
  22900. }, {
  22901. key: 'createMultipleSelectorHandles',
  22902. value: function createMultipleSelectorHandles() {
  22903. this.selectionHandles = {
  22904. topLeft: document.createElement('DIV'),
  22905. topLeftHitArea: document.createElement('DIV'),
  22906. bottomRight: document.createElement('DIV'),
  22907. bottomRightHitArea: document.createElement('DIV')
  22908. };
  22909. var width = 10;
  22910. var hitAreaWidth = 40;
  22911. this.selectionHandles.topLeft.className = 'topLeftSelectionHandle';
  22912. this.selectionHandles.topLeftHitArea.className = 'topLeftSelectionHandle-HitArea';
  22913. this.selectionHandles.bottomRight.className = 'bottomRightSelectionHandle';
  22914. this.selectionHandles.bottomRightHitArea.className = 'bottomRightSelectionHandle-HitArea';
  22915. this.selectionHandles.styles = {
  22916. topLeft: this.selectionHandles.topLeft.style,
  22917. topLeftHitArea: this.selectionHandles.topLeftHitArea.style,
  22918. bottomRight: this.selectionHandles.bottomRight.style,
  22919. bottomRightHitArea: this.selectionHandles.bottomRightHitArea.style
  22920. };
  22921. var hitAreaStyle = {
  22922. position: 'absolute',
  22923. height: hitAreaWidth + 'px',
  22924. width: hitAreaWidth + 'px',
  22925. 'border-radius': parseInt(hitAreaWidth / 1.5, 10) + 'px'
  22926. };
  22927. for (var prop in hitAreaStyle) {
  22928. if ((0, _object.hasOwnProperty)(hitAreaStyle, prop)) {
  22929. this.selectionHandles.styles.bottomRightHitArea[prop] = hitAreaStyle[prop];
  22930. this.selectionHandles.styles.topLeftHitArea[prop] = hitAreaStyle[prop];
  22931. }
  22932. }
  22933. var handleStyle = {
  22934. position: 'absolute',
  22935. height: width + 'px',
  22936. width: width + 'px',
  22937. 'border-radius': parseInt(width / 1.5, 10) + 'px',
  22938. background: '#F5F5FF',
  22939. border: '1px solid #4285c8'
  22940. };
  22941. for (var _prop in handleStyle) {
  22942. if ((0, _object.hasOwnProperty)(handleStyle, _prop)) {
  22943. this.selectionHandles.styles.bottomRight[_prop] = handleStyle[_prop];
  22944. this.selectionHandles.styles.topLeft[_prop] = handleStyle[_prop];
  22945. }
  22946. }
  22947. this.main.appendChild(this.selectionHandles.topLeft);
  22948. this.main.appendChild(this.selectionHandles.bottomRight);
  22949. this.main.appendChild(this.selectionHandles.topLeftHitArea);
  22950. this.main.appendChild(this.selectionHandles.bottomRightHitArea);
  22951. }
  22952. }, {
  22953. key: 'isPartRange',
  22954. value: function isPartRange(row, col) {
  22955. var areaSelection = this.wot.selections.createOrGetArea();
  22956. if (areaSelection.cellRange) {
  22957. if (row != areaSelection.cellRange.to.row || col != areaSelection.cellRange.to.col) {
  22958. return true;
  22959. }
  22960. }
  22961. return false;
  22962. }
  22963. }, {
  22964. key: 'updateMultipleSelectionHandlesPosition',
  22965. value: function updateMultipleSelectionHandlesPosition(row, col, top, left, width, height) {
  22966. var handleWidth = parseInt(this.selectionHandles.styles.topLeft.width, 10);
  22967. var hitAreaWidth = parseInt(this.selectionHandles.styles.topLeftHitArea.width, 10);
  22968. this.selectionHandles.styles.topLeft.top = parseInt(top - handleWidth, 10) + 'px';
  22969. this.selectionHandles.styles.topLeft.left = parseInt(left - handleWidth, 10) + 'px';
  22970. this.selectionHandles.styles.topLeftHitArea.top = parseInt(top - hitAreaWidth / 4 * 3, 10) + 'px';
  22971. this.selectionHandles.styles.topLeftHitArea.left = parseInt(left - hitAreaWidth / 4 * 3, 10) + 'px';
  22972. this.selectionHandles.styles.bottomRight.top = parseInt(top + height, 10) + 'px';
  22973. this.selectionHandles.styles.bottomRight.left = parseInt(left + width, 10) + 'px';
  22974. this.selectionHandles.styles.bottomRightHitArea.top = parseInt(top + height - hitAreaWidth / 4, 10) + 'px';
  22975. this.selectionHandles.styles.bottomRightHitArea.left = parseInt(left + width - hitAreaWidth / 4, 10) + 'px';
  22976. if (this.settings.border.cornerVisible && this.settings.border.cornerVisible()) {
  22977. this.selectionHandles.styles.topLeft.display = 'block';
  22978. this.selectionHandles.styles.topLeftHitArea.display = 'block';
  22979. if (this.isPartRange(row, col)) {
  22980. this.selectionHandles.styles.bottomRight.display = 'none';
  22981. this.selectionHandles.styles.bottomRightHitArea.display = 'none';
  22982. } else {
  22983. this.selectionHandles.styles.bottomRight.display = 'block';
  22984. this.selectionHandles.styles.bottomRightHitArea.display = 'block';
  22985. }
  22986. } else {
  22987. this.selectionHandles.styles.topLeft.display = 'none';
  22988. this.selectionHandles.styles.bottomRight.display = 'none';
  22989. this.selectionHandles.styles.topLeftHitArea.display = 'none';
  22990. this.selectionHandles.styles.bottomRightHitArea.display = 'none';
  22991. }
  22992. if (row == this.wot.wtSettings.getSetting('fixedRowsTop') || col == this.wot.wtSettings.getSetting('fixedColumnsLeft')) {
  22993. this.selectionHandles.styles.topLeft.zIndex = '9999';
  22994. this.selectionHandles.styles.topLeftHitArea.zIndex = '9999';
  22995. } else {
  22996. this.selectionHandles.styles.topLeft.zIndex = '';
  22997. this.selectionHandles.styles.topLeftHitArea.zIndex = '';
  22998. }
  22999. }
  23000. /**
  23001. * Show border around one or many cells
  23002. *
  23003. * @param {Array} corners
  23004. */
  23005. }, {
  23006. key: 'appear',
  23007. value: function appear(corners) {
  23008. if (this.disabled) {
  23009. return;
  23010. }
  23011. var fromRow = void 0;
  23012. var toRow = void 0;
  23013. var fromColumn = void 0;
  23014. var toColumn = void 0;
  23015. var rowsCount = this.wot.wtTable.getRenderedRowsCount();
  23016. for (var i = 0; i < rowsCount; i += 1) {
  23017. var s = this.wot.wtTable.rowFilter.renderedToSource(i);
  23018. if (s >= corners[0] && s <= corners[2]) {
  23019. fromRow = s;
  23020. break;
  23021. }
  23022. }
  23023. for (var _i = rowsCount - 1; _i >= 0; _i -= 1) {
  23024. var _s = this.wot.wtTable.rowFilter.renderedToSource(_i);
  23025. if (_s >= corners[0] && _s <= corners[2]) {
  23026. toRow = _s;
  23027. break;
  23028. }
  23029. }
  23030. var columnsCount = this.wot.wtTable.getRenderedColumnsCount();
  23031. for (var _i2 = 0; _i2 < columnsCount; _i2 += 1) {
  23032. var _s2 = this.wot.wtTable.columnFilter.renderedToSource(_i2);
  23033. if (_s2 >= corners[1] && _s2 <= corners[3]) {
  23034. fromColumn = _s2;
  23035. break;
  23036. }
  23037. }
  23038. for (var _i3 = columnsCount - 1; _i3 >= 0; _i3 -= 1) {
  23039. var _s3 = this.wot.wtTable.columnFilter.renderedToSource(_i3);
  23040. if (_s3 >= corners[1] && _s3 <= corners[3]) {
  23041. toColumn = _s3;
  23042. break;
  23043. }
  23044. }
  23045. if (fromRow === void 0 || fromColumn === void 0) {
  23046. this.disappear();
  23047. return;
  23048. }
  23049. var fromTD = this.wot.wtTable.getCell(new _coords2.default(fromRow, fromColumn));
  23050. var isMultiple = fromRow !== toRow || fromColumn !== toColumn;
  23051. var toTD = isMultiple ? this.wot.wtTable.getCell(new _coords2.default(toRow, toColumn)) : fromTD;
  23052. var fromOffset = (0, _element.offset)(fromTD);
  23053. var toOffset = isMultiple ? (0, _element.offset)(toTD) : fromOffset;
  23054. var containerOffset = (0, _element.offset)(this.wot.wtTable.TABLE);
  23055. var minTop = fromOffset.top;
  23056. var minLeft = fromOffset.left;
  23057. var left = minLeft - containerOffset.left - 1;
  23058. var width = toOffset.left + (0, _element.outerWidth)(toTD) - minLeft;
  23059. if (this.isEntireColumnSelected(fromRow, toRow)) {
  23060. var modifiedValues = this.getDimensionsFromHeader('columns', fromColumn, toColumn, containerOffset);
  23061. var fromTH = null;
  23062. if (modifiedValues) {
  23063. var _modifiedValues = _slicedToArray(modifiedValues, 3);
  23064. fromTH = _modifiedValues[0];
  23065. left = _modifiedValues[1];
  23066. width = _modifiedValues[2];
  23067. }
  23068. if (fromTH) {
  23069. fromTD = fromTH;
  23070. }
  23071. }
  23072. var top = minTop - containerOffset.top - 1;
  23073. var height = toOffset.top + (0, _element.outerHeight)(toTD) - minTop;
  23074. if (this.isEntireRowSelected(fromColumn, toColumn)) {
  23075. var _modifiedValues2 = this.getDimensionsFromHeader('rows', fromRow, toRow, containerOffset);
  23076. var _fromTH = null;
  23077. if (_modifiedValues2) {
  23078. var _modifiedValues3 = _slicedToArray(_modifiedValues2, 3);
  23079. _fromTH = _modifiedValues3[0];
  23080. top = _modifiedValues3[1];
  23081. height = _modifiedValues3[2];
  23082. }
  23083. if (_fromTH) {
  23084. fromTD = _fromTH;
  23085. }
  23086. }
  23087. var style = (0, _element.getComputedStyle)(fromTD);
  23088. if (parseInt(style.borderTopWidth, 10) > 0) {
  23089. top += 1;
  23090. height = height > 0 ? height - 1 : 0;
  23091. }
  23092. if (parseInt(style.borderLeftWidth, 10) > 0) {
  23093. left += 1;
  23094. width = width > 0 ? width - 1 : 0;
  23095. }
  23096. this.topStyle.top = top + 'px';
  23097. this.topStyle.left = left + 'px';
  23098. this.topStyle.width = width + 'px';
  23099. this.topStyle.display = 'block';
  23100. this.leftStyle.top = top + 'px';
  23101. this.leftStyle.left = left + 'px';
  23102. this.leftStyle.height = height + 'px';
  23103. this.leftStyle.display = 'block';
  23104. var delta = Math.floor(this.settings.border.width / 2);
  23105. this.bottomStyle.top = top + height - delta + 'px';
  23106. this.bottomStyle.left = left + 'px';
  23107. this.bottomStyle.width = width + 'px';
  23108. this.bottomStyle.display = 'block';
  23109. this.rightStyle.top = top + 'px';
  23110. this.rightStyle.left = left + width - delta + 'px';
  23111. this.rightStyle.height = height + 1 + 'px';
  23112. this.rightStyle.display = 'block';
  23113. var cornerVisibleSetting = this.settings.border.cornerVisible;
  23114. cornerVisibleSetting = typeof cornerVisibleSetting === 'function' ? cornerVisibleSetting(this.settings.layerLevel) : cornerVisibleSetting;
  23115. var hookResult = this.wot.getSetting('onModifyGetCellCoords', toRow, toColumn);
  23116. var checkRow = toRow,
  23117. checkCol = toColumn;
  23118. if (hookResult && Array.isArray(hookResult)) {
  23119. var _hookResult = _slicedToArray(hookResult, 4);
  23120. checkRow = _hookResult[2];
  23121. checkCol = _hookResult[3];
  23122. }
  23123. if ((0, _browser.isMobileBrowser)() || !cornerVisibleSetting || this.isPartRange(checkRow, checkCol)) {
  23124. this.cornerStyle.display = 'none';
  23125. } else {
  23126. this.cornerStyle.top = top + height - 4 + 'px';
  23127. this.cornerStyle.left = left + width - 4 + 'px';
  23128. this.cornerStyle.borderRightWidth = this.cornerDefaultStyle.borderWidth;
  23129. this.cornerStyle.width = this.cornerDefaultStyle.width;
  23130. // Hide the fill handle, so the possible further adjustments won't force unneeded scrollbars.
  23131. this.cornerStyle.display = 'none';
  23132. var trimmingContainer = (0, _element.getTrimmingContainer)(this.wot.wtTable.TABLE);
  23133. if (toColumn === this.wot.getSetting('totalColumns') - 1) {
  23134. var cornerOverlappingContainer = toTD.offsetLeft + (0, _element.outerWidth)(toTD) + parseInt(this.cornerDefaultStyle.width, 10) / 2 >= (0, _element.innerWidth)(trimmingContainer);
  23135. if (cornerOverlappingContainer) {
  23136. this.cornerStyle.left = Math.floor(left + width - 3 - parseInt(this.cornerDefaultStyle.width, 10) / 2) + 'px';
  23137. this.cornerStyle.borderRightWidth = 0;
  23138. }
  23139. }
  23140. if (toRow === this.wot.getSetting('totalRows') - 1) {
  23141. var _cornerOverlappingContainer = toTD.offsetTop + (0, _element.outerHeight)(toTD) + parseInt(this.cornerDefaultStyle.height, 10) / 2 >= (0, _element.innerHeight)(trimmingContainer);
  23142. if (_cornerOverlappingContainer) {
  23143. this.cornerStyle.top = Math.floor(top + height - 3 - parseInt(this.cornerDefaultStyle.height, 10) / 2) + 'px';
  23144. this.cornerStyle.borderBottomWidth = 0;
  23145. }
  23146. }
  23147. this.cornerStyle.display = 'block';
  23148. }
  23149. if ((0, _browser.isMobileBrowser)()) {
  23150. this.updateMultipleSelectionHandlesPosition(toRow, toColumn, top, left, width, height);
  23151. }
  23152. }
  23153. /**
  23154. * Check whether an entire column of cells is selected.
  23155. *
  23156. * @private
  23157. * @param {Number} startRowIndex Start row index.
  23158. * @param {Number} endRowIndex End row index.
  23159. */
  23160. }, {
  23161. key: 'isEntireColumnSelected',
  23162. value: function isEntireColumnSelected(startRowIndex, endRowIndex) {
  23163. return startRowIndex === this.wot.wtTable.getFirstRenderedRow() && endRowIndex === this.wot.wtTable.getLastRenderedRow();
  23164. }
  23165. /**
  23166. * Check whether an entire row of cells is selected.
  23167. *
  23168. * @private
  23169. * @param {Number} startColumnIndex Start column index.
  23170. * @param {Number} endColumnIndex End column index.
  23171. */
  23172. }, {
  23173. key: 'isEntireRowSelected',
  23174. value: function isEntireRowSelected(startColumnIndex, endColumnIndex) {
  23175. return startColumnIndex === this.wot.wtTable.getFirstRenderedColumn() && endColumnIndex === this.wot.wtTable.getLastRenderedColumn();
  23176. }
  23177. /**
  23178. * Get left/top index and width/height depending on the `direction` provided.
  23179. *
  23180. * @private
  23181. * @param {String} direction `rows` or `columns`, defines if an entire column or row is selected.
  23182. * @param {Number} fromIndex Start index of the selection.
  23183. * @param {Number} toIndex End index of the selection.
  23184. * @param {Number} containerOffset offset of the container.
  23185. * @return {Array|Boolean} Returns an array of [headerElement, left, width] or [headerElement, top, height], depending on `direction` (`false` in case of an error getting the headers).
  23186. */
  23187. }, {
  23188. key: 'getDimensionsFromHeader',
  23189. value: function getDimensionsFromHeader(direction, fromIndex, toIndex, containerOffset) {
  23190. var _this3 = this;
  23191. var rootHotElement = this.wot.wtTable.wtRootElement.parentNode;
  23192. var getHeaderFn = null;
  23193. var dimensionFn = null;
  23194. var entireSelectionClassname = null;
  23195. var index = null;
  23196. var dimension = null;
  23197. var dimensionProperty = null;
  23198. var startHeader = null;
  23199. var endHeader = null;
  23200. switch (direction) {
  23201. case 'rows':
  23202. getHeaderFn = function getHeaderFn() {
  23203. var _wot$wtTable;
  23204. return (_wot$wtTable = _this3.wot.wtTable).getRowHeader.apply(_wot$wtTable, arguments);
  23205. };
  23206. dimensionFn = function dimensionFn() {
  23207. return _element.outerHeight.apply(undefined, arguments);
  23208. };
  23209. entireSelectionClassname = 'ht__selection--rows';
  23210. dimensionProperty = 'top';
  23211. break;
  23212. case 'columns':
  23213. getHeaderFn = function getHeaderFn() {
  23214. var _wot$wtTable2;
  23215. return (_wot$wtTable2 = _this3.wot.wtTable).getColumnHeader.apply(_wot$wtTable2, arguments);
  23216. };
  23217. dimensionFn = function dimensionFn() {
  23218. return _element.outerWidth.apply(undefined, arguments);
  23219. };
  23220. entireSelectionClassname = 'ht__selection--columns';
  23221. dimensionProperty = 'left';
  23222. break;
  23223. default:
  23224. }
  23225. if (rootHotElement.className.includes(entireSelectionClassname)) {
  23226. var columnHeaderLevelCount = this.wot.getSetting('columnHeaders').length;
  23227. startHeader = getHeaderFn(fromIndex, columnHeaderLevelCount - 1);
  23228. endHeader = getHeaderFn(toIndex, columnHeaderLevelCount - 1);
  23229. if (!startHeader || !endHeader) {
  23230. return false;
  23231. }
  23232. var startHeaderOffset = (0, _element.offset)(startHeader);
  23233. var endOffset = (0, _element.offset)(endHeader);
  23234. if (startHeader && endHeader) {
  23235. index = startHeaderOffset[dimensionProperty] - containerOffset[dimensionProperty] - 1;
  23236. dimension = endOffset[dimensionProperty] + dimensionFn(endHeader) - startHeaderOffset[dimensionProperty];
  23237. }
  23238. return [startHeader, index, dimension];
  23239. }
  23240. return false;
  23241. }
  23242. /**
  23243. * Hide border
  23244. */
  23245. }, {
  23246. key: 'disappear',
  23247. value: function disappear() {
  23248. this.topStyle.display = 'none';
  23249. this.leftStyle.display = 'none';
  23250. this.bottomStyle.display = 'none';
  23251. this.rightStyle.display = 'none';
  23252. this.cornerStyle.display = 'none';
  23253. if ((0, _browser.isMobileBrowser)()) {
  23254. this.selectionHandles.styles.topLeft.display = 'none';
  23255. this.selectionHandles.styles.bottomRight.display = 'none';
  23256. }
  23257. }
  23258. }]);
  23259. return Border;
  23260. }();
  23261. exports.default = Border;
  23262. /***/ }),
  23263. /* 307 */
  23264. /***/ (function(module, exports, __webpack_require__) {
  23265. "use strict";
  23266. exports.__esModule = true;
  23267. var _unicode = __webpack_require__(21);
  23268. var _mixed = __webpack_require__(16);
  23269. var _string = __webpack_require__(36);
  23270. var _array = __webpack_require__(1);
  23271. var _element = __webpack_require__(0);
  23272. var _handsontableEditor = __webpack_require__(308);
  23273. var _handsontableEditor2 = _interopRequireDefault(_handsontableEditor);
  23274. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  23275. var AutocompleteEditor = _handsontableEditor2.default.prototype.extend();
  23276. /**
  23277. * @private
  23278. * @editor AutocompleteEditor
  23279. * @class AutocompleteEditor
  23280. * @dependencies HandsontableEditor
  23281. */
  23282. AutocompleteEditor.prototype.init = function () {
  23283. _handsontableEditor2.default.prototype.init.apply(this, arguments);
  23284. this.query = null;
  23285. this.strippedChoices = [];
  23286. this.rawChoices = [];
  23287. };
  23288. AutocompleteEditor.prototype.getValue = function () {
  23289. var _this2 = this;
  23290. var selectedValue = this.rawChoices.find(function (value) {
  23291. var strippedValue = _this2.stripValueIfNeeded(value);
  23292. return strippedValue === _this2.TEXTAREA.value;
  23293. });
  23294. if ((0, _mixed.isDefined)(selectedValue)) {
  23295. return selectedValue;
  23296. }
  23297. return this.TEXTAREA.value;
  23298. };
  23299. AutocompleteEditor.prototype.createElements = function () {
  23300. _handsontableEditor2.default.prototype.createElements.apply(this, arguments);
  23301. (0, _element.addClass)(this.htContainer, 'autocompleteEditor');
  23302. (0, _element.addClass)(this.htContainer, window.navigator.platform.indexOf('Mac') === -1 ? '' : 'htMacScroll');
  23303. };
  23304. var skipOne = false;
  23305. function onBeforeKeyDown(event) {
  23306. skipOne = false;
  23307. var editor = this.getActiveEditor();
  23308. if ((0, _unicode.isPrintableChar)(event.keyCode) || event.keyCode === _unicode.KEY_CODES.BACKSPACE || event.keyCode === _unicode.KEY_CODES.DELETE || event.keyCode === _unicode.KEY_CODES.INSERT) {
  23309. var timeOffset = 0;
  23310. // on ctl+c / cmd+c don't update suggestion list
  23311. if (event.keyCode === _unicode.KEY_CODES.C && (event.ctrlKey || event.metaKey)) {
  23312. return;
  23313. }
  23314. if (!editor.isOpened()) {
  23315. timeOffset += 10;
  23316. }
  23317. if (editor.htEditor) {
  23318. editor.instance._registerTimeout(setTimeout(function () {
  23319. editor.queryChoices(editor.TEXTAREA.value);
  23320. skipOne = true;
  23321. }, timeOffset));
  23322. }
  23323. }
  23324. }
  23325. AutocompleteEditor.prototype.prepare = function () {
  23326. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  23327. _handsontableEditor2.default.prototype.prepare.apply(this, arguments);
  23328. };
  23329. AutocompleteEditor.prototype.open = function () {
  23330. // Ugly fix for handsontable which grab window object for autocomplete scroll listener instead table element.
  23331. this.TEXTAREA_PARENT.style.overflow = 'auto';
  23332. _handsontableEditor2.default.prototype.open.apply(this, arguments);
  23333. this.TEXTAREA_PARENT.style.overflow = '';
  23334. var choicesListHot = this.htEditor.getInstance();
  23335. var _this = this;
  23336. var trimDropdown = this.cellProperties.trimDropdown === void 0 ? true : this.cellProperties.trimDropdown;
  23337. this.TEXTAREA.style.visibility = 'visible';
  23338. this.focus();
  23339. choicesListHot.updateSettings({
  23340. colWidths: trimDropdown ? [(0, _element.outerWidth)(this.TEXTAREA) - 2] : void 0,
  23341. width: trimDropdown ? (0, _element.outerWidth)(this.TEXTAREA) + (0, _element.getScrollbarWidth)() + 2 : void 0,
  23342. afterRenderer: function afterRenderer(TD, row, col, prop, value, cellProperties) {
  23343. var _this$cellProperties = _this.cellProperties,
  23344. filteringCaseSensitive = _this$cellProperties.filteringCaseSensitive,
  23345. allowHtml = _this$cellProperties.allowHtml;
  23346. var indexOfMatch = void 0;
  23347. var match = void 0;
  23348. value = (0, _mixed.stringify)(value);
  23349. if (value && !allowHtml) {
  23350. indexOfMatch = filteringCaseSensitive === true ? value.indexOf(this.query) : value.toLowerCase().indexOf(_this.query.toLowerCase());
  23351. if (indexOfMatch !== -1) {
  23352. match = value.substr(indexOfMatch, _this.query.length);
  23353. value = value.replace(match, '<strong>' + match + '</strong>');
  23354. }
  23355. }
  23356. TD.innerHTML = value;
  23357. },
  23358. autoColumnSize: true,
  23359. modifyColWidth: function modifyColWidth(width, col) {
  23360. // workaround for <strong> text overlapping the dropdown, not really accurate
  23361. var autoWidths = this.getPlugin('autoColumnSize').widths;
  23362. if (autoWidths[col]) {
  23363. width = autoWidths[col];
  23364. }
  23365. return trimDropdown ? width : width + 15;
  23366. }
  23367. });
  23368. // Add additional space for autocomplete holder
  23369. this.htEditor.view.wt.wtTable.holder.parentNode.style['padding-right'] = (0, _element.getScrollbarWidth)() + 2 + 'px';
  23370. if (skipOne) {
  23371. skipOne = false;
  23372. }
  23373. _this.instance._registerTimeout(setTimeout(function () {
  23374. _this.queryChoices(_this.TEXTAREA.value);
  23375. }, 0));
  23376. };
  23377. AutocompleteEditor.prototype.close = function () {
  23378. _handsontableEditor2.default.prototype.close.apply(this, arguments);
  23379. };
  23380. AutocompleteEditor.prototype.queryChoices = function (query) {
  23381. var _this3 = this;
  23382. this.query = query;
  23383. var source = this.cellProperties.source;
  23384. if (typeof source == 'function') {
  23385. source.call(this.cellProperties, query, function (choices) {
  23386. _this3.rawChoices = choices;
  23387. _this3.updateChoicesList(_this3.stripValuesIfNeeded(choices));
  23388. });
  23389. } else if (Array.isArray(source)) {
  23390. this.rawChoices = source;
  23391. this.updateChoicesList(this.stripValuesIfNeeded(source));
  23392. } else {
  23393. this.updateChoicesList([]);
  23394. }
  23395. };
  23396. AutocompleteEditor.prototype.updateChoicesList = function (choices) {
  23397. var pos = (0, _element.getCaretPosition)(this.TEXTAREA);
  23398. var endPos = (0, _element.getSelectionEndPosition)(this.TEXTAREA);
  23399. var sortByRelevanceSetting = this.cellProperties.sortByRelevance;
  23400. var filterSetting = this.cellProperties.filter;
  23401. var orderByRelevance = null;
  23402. var highlightIndex = null;
  23403. if (sortByRelevanceSetting) {
  23404. orderByRelevance = AutocompleteEditor.sortByRelevance(this.stripValueIfNeeded(this.getValue()), choices, this.cellProperties.filteringCaseSensitive);
  23405. }
  23406. var orderByRelevanceLength = Array.isArray(orderByRelevance) ? orderByRelevance.length : 0;
  23407. if (filterSetting === false) {
  23408. if (orderByRelevanceLength) {
  23409. highlightIndex = orderByRelevance[0];
  23410. }
  23411. } else {
  23412. var sorted = [];
  23413. for (var i = 0, choicesCount = choices.length; i < choicesCount; i++) {
  23414. if (sortByRelevanceSetting && orderByRelevanceLength <= i) {
  23415. break;
  23416. }
  23417. if (orderByRelevanceLength) {
  23418. sorted.push(choices[orderByRelevance[i]]);
  23419. } else {
  23420. sorted.push(choices[i]);
  23421. }
  23422. }
  23423. highlightIndex = 0;
  23424. choices = sorted;
  23425. }
  23426. this.strippedChoices = choices;
  23427. this.htEditor.loadData((0, _array.pivot)([choices]));
  23428. this.updateDropdownHeight();
  23429. this.flipDropdownIfNeeded();
  23430. if (this.cellProperties.strict === true) {
  23431. this.highlightBestMatchingChoice(highlightIndex);
  23432. }
  23433. this.instance.listen(false);
  23434. (0, _element.setCaretPosition)(this.TEXTAREA, pos, pos === endPos ? void 0 : endPos);
  23435. };
  23436. AutocompleteEditor.prototype.flipDropdownIfNeeded = function () {
  23437. var textareaOffset = (0, _element.offset)(this.TEXTAREA);
  23438. var textareaHeight = (0, _element.outerHeight)(this.TEXTAREA);
  23439. var dropdownHeight = this.getDropdownHeight();
  23440. var trimmingContainer = (0, _element.getTrimmingContainer)(this.instance.view.wt.wtTable.TABLE);
  23441. var trimmingContainerScrollTop = trimmingContainer.scrollTop;
  23442. var headersHeight = (0, _element.outerHeight)(this.instance.view.wt.wtTable.THEAD);
  23443. var containerOffset = {
  23444. row: 0,
  23445. col: 0
  23446. };
  23447. if (trimmingContainer !== window) {
  23448. containerOffset = (0, _element.offset)(trimmingContainer);
  23449. }
  23450. var spaceAbove = textareaOffset.top - containerOffset.top - headersHeight + trimmingContainerScrollTop;
  23451. var spaceBelow = trimmingContainer.scrollHeight - spaceAbove - headersHeight - textareaHeight;
  23452. var flipNeeded = dropdownHeight > spaceBelow && spaceAbove > spaceBelow;
  23453. if (flipNeeded) {
  23454. this.flipDropdown(dropdownHeight);
  23455. } else {
  23456. this.unflipDropdown();
  23457. }
  23458. this.limitDropdownIfNeeded(flipNeeded ? spaceAbove : spaceBelow, dropdownHeight);
  23459. return flipNeeded;
  23460. };
  23461. AutocompleteEditor.prototype.limitDropdownIfNeeded = function (spaceAvailable, dropdownHeight) {
  23462. if (dropdownHeight > spaceAvailable) {
  23463. var tempHeight = 0;
  23464. var i = 0;
  23465. var lastRowHeight = 0;
  23466. var height = null;
  23467. do {
  23468. lastRowHeight = this.htEditor.getRowHeight(i) || this.htEditor.view.wt.wtSettings.settings.defaultRowHeight;
  23469. tempHeight += lastRowHeight;
  23470. i++;
  23471. } while (tempHeight < spaceAvailable);
  23472. height = tempHeight - lastRowHeight;
  23473. if (this.htEditor.flipped) {
  23474. this.htEditor.rootElement.style.top = parseInt(this.htEditor.rootElement.style.top, 10) + dropdownHeight - height + 'px';
  23475. }
  23476. this.setDropdownHeight(tempHeight - lastRowHeight);
  23477. }
  23478. };
  23479. AutocompleteEditor.prototype.flipDropdown = function (dropdownHeight) {
  23480. var dropdownStyle = this.htEditor.rootElement.style;
  23481. dropdownStyle.position = 'absolute';
  23482. dropdownStyle.top = -dropdownHeight + 'px';
  23483. this.htEditor.flipped = true;
  23484. };
  23485. AutocompleteEditor.prototype.unflipDropdown = function () {
  23486. var dropdownStyle = this.htEditor.rootElement.style;
  23487. if (dropdownStyle.position === 'absolute') {
  23488. dropdownStyle.position = '';
  23489. dropdownStyle.top = '';
  23490. }
  23491. this.htEditor.flipped = void 0;
  23492. };
  23493. AutocompleteEditor.prototype.updateDropdownHeight = function () {
  23494. var currentDropdownWidth = this.htEditor.getColWidth(0) + (0, _element.getScrollbarWidth)() + 2;
  23495. var trimDropdown = this.cellProperties.trimDropdown;
  23496. this.htEditor.updateSettings({
  23497. height: this.getDropdownHeight(),
  23498. width: trimDropdown ? void 0 : currentDropdownWidth
  23499. });
  23500. this.htEditor.view.wt.wtTable.alignOverlaysWithTrimmingContainer();
  23501. };
  23502. AutocompleteEditor.prototype.setDropdownHeight = function (height) {
  23503. this.htEditor.updateSettings({
  23504. height: height
  23505. });
  23506. };
  23507. AutocompleteEditor.prototype.finishEditing = function (restoreOriginalValue) {
  23508. if (!restoreOriginalValue) {
  23509. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  23510. }
  23511. _handsontableEditor2.default.prototype.finishEditing.apply(this, arguments);
  23512. };
  23513. AutocompleteEditor.prototype.highlightBestMatchingChoice = function (index) {
  23514. if (typeof index === 'number') {
  23515. this.htEditor.selectCell(index, 0, void 0, void 0, void 0, false);
  23516. } else {
  23517. this.htEditor.deselectCell();
  23518. }
  23519. };
  23520. /**
  23521. * Filters and sorts by relevance
  23522. * @param value
  23523. * @param choices
  23524. * @param caseSensitive
  23525. * @returns {Array} array of indexes in original choices array
  23526. */
  23527. AutocompleteEditor.sortByRelevance = function (value, choices, caseSensitive) {
  23528. var choicesRelevance = [];
  23529. var currentItem = void 0;
  23530. var valueLength = value.length;
  23531. var valueIndex = void 0;
  23532. var charsLeft = void 0;
  23533. var result = [];
  23534. var i = void 0;
  23535. var choicesCount = choices.length;
  23536. if (valueLength === 0) {
  23537. for (i = 0; i < choicesCount; i++) {
  23538. result.push(i);
  23539. }
  23540. return result;
  23541. }
  23542. for (i = 0; i < choicesCount; i++) {
  23543. currentItem = (0, _string.stripTags)((0, _mixed.stringify)(choices[i]));
  23544. if (caseSensitive) {
  23545. valueIndex = currentItem.indexOf(value);
  23546. } else {
  23547. valueIndex = currentItem.toLowerCase().indexOf(value.toLowerCase());
  23548. }
  23549. if (valueIndex !== -1) {
  23550. charsLeft = currentItem.length - valueIndex - valueLength;
  23551. choicesRelevance.push({
  23552. baseIndex: i,
  23553. index: valueIndex,
  23554. charsLeft: charsLeft,
  23555. value: currentItem
  23556. });
  23557. }
  23558. }
  23559. choicesRelevance.sort(function (a, b) {
  23560. if (b.index === -1) {
  23561. return -1;
  23562. }
  23563. if (a.index === -1) {
  23564. return 1;
  23565. }
  23566. if (a.index < b.index) {
  23567. return -1;
  23568. } else if (b.index < a.index) {
  23569. return 1;
  23570. } else if (a.index === b.index) {
  23571. if (a.charsLeft < b.charsLeft) {
  23572. return -1;
  23573. } else if (a.charsLeft > b.charsLeft) {
  23574. return 1;
  23575. }
  23576. }
  23577. return 0;
  23578. });
  23579. for (i = 0, choicesCount = choicesRelevance.length; i < choicesCount; i++) {
  23580. result.push(choicesRelevance[i].baseIndex);
  23581. }
  23582. return result;
  23583. };
  23584. AutocompleteEditor.prototype.getDropdownHeight = function () {
  23585. var firstRowHeight = this.htEditor.getInstance().getRowHeight(0) || 23;
  23586. var visibleRows = this.cellProperties.visibleRows;
  23587. return this.strippedChoices.length >= visibleRows ? visibleRows * firstRowHeight : this.strippedChoices.length * firstRowHeight + 8;
  23588. };
  23589. AutocompleteEditor.prototype.stripValueIfNeeded = function (value) {
  23590. return this.stripValuesIfNeeded([value])[0];
  23591. };
  23592. AutocompleteEditor.prototype.stripValuesIfNeeded = function (values) {
  23593. var allowHtml = this.cellProperties.allowHtml;
  23594. var stringifiedValues = (0, _array.arrayMap)(values, function (value) {
  23595. return (0, _mixed.stringify)(value);
  23596. });
  23597. var strippedValues = (0, _array.arrayMap)(stringifiedValues, function (value) {
  23598. return allowHtml ? value : (0, _string.stripTags)(value);
  23599. });
  23600. return strippedValues;
  23601. };
  23602. AutocompleteEditor.prototype.allowKeyEventPropagation = function (keyCode) {
  23603. var selectedRange = this.htEditor.getSelectedRangeLast();
  23604. var selected = { row: selectedRange ? selectedRange.from.row : -1 };
  23605. var allowed = false;
  23606. if (keyCode === _unicode.KEY_CODES.ARROW_DOWN && selected.row > 0 && selected.row < this.htEditor.countRows() - 1) {
  23607. allowed = true;
  23608. }
  23609. if (keyCode === _unicode.KEY_CODES.ARROW_UP && selected.row > -1) {
  23610. allowed = true;
  23611. }
  23612. return allowed;
  23613. };
  23614. AutocompleteEditor.prototype.discardEditor = function (result) {
  23615. _handsontableEditor2.default.prototype.discardEditor.apply(this, arguments);
  23616. this.instance.view.render();
  23617. };
  23618. exports.default = AutocompleteEditor;
  23619. /***/ }),
  23620. /* 308 */
  23621. /***/ (function(module, exports, __webpack_require__) {
  23622. "use strict";
  23623. exports.__esModule = true;
  23624. var _unicode = __webpack_require__(21);
  23625. var _object = __webpack_require__(2);
  23626. var _element = __webpack_require__(0);
  23627. var _event = __webpack_require__(12);
  23628. var _textEditor = __webpack_require__(57);
  23629. var _textEditor2 = _interopRequireDefault(_textEditor);
  23630. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  23631. var HandsontableEditor = _textEditor2.default.prototype.extend();
  23632. /**
  23633. * @private
  23634. * @editor HandsontableEditor
  23635. * @class HandsontableEditor
  23636. * @dependencies TextEditor
  23637. */
  23638. HandsontableEditor.prototype.createElements = function () {
  23639. _textEditor2.default.prototype.createElements.apply(this, arguments);
  23640. var DIV = document.createElement('DIV');
  23641. DIV.className = 'handsontableEditor';
  23642. this.TEXTAREA_PARENT.appendChild(DIV);
  23643. this.htContainer = DIV;
  23644. this.assignHooks();
  23645. };
  23646. HandsontableEditor.prototype.prepare = function (td, row, col, prop, value, cellProperties) {
  23647. _textEditor2.default.prototype.prepare.apply(this, arguments);
  23648. var parent = this;
  23649. var options = {
  23650. startRows: 0,
  23651. startCols: 0,
  23652. minRows: 0,
  23653. minCols: 0,
  23654. className: 'listbox',
  23655. copyPaste: false,
  23656. autoColumnSize: false,
  23657. autoRowSize: false,
  23658. readOnly: true,
  23659. fillHandle: false,
  23660. afterOnCellMouseDown: function afterOnCellMouseDown(_, coords) {
  23661. var value = this.getSourceData(coords.row, coords.col);
  23662. // if the value is undefined then it means we don't want to set the value
  23663. if (value !== void 0) {
  23664. parent.setValue(value);
  23665. }
  23666. parent.instance.destroyEditor();
  23667. }
  23668. };
  23669. if (this.cellProperties.handsontable) {
  23670. (0, _object.extend)(options, cellProperties.handsontable);
  23671. }
  23672. this.htOptions = options;
  23673. };
  23674. var onBeforeKeyDown = function onBeforeKeyDown(event) {
  23675. if ((0, _event.isImmediatePropagationStopped)(event)) {
  23676. return;
  23677. }
  23678. var editor = this.getActiveEditor();
  23679. var innerHOT = editor.htEditor.getInstance();
  23680. var rowToSelect;
  23681. var selectedRow;
  23682. if (event.keyCode == _unicode.KEY_CODES.ARROW_DOWN) {
  23683. if (!innerHOT.getSelectedLast() && !innerHOT.flipped) {
  23684. rowToSelect = 0;
  23685. } else if (innerHOT.getSelectedLast()) {
  23686. if (innerHOT.flipped) {
  23687. rowToSelect = innerHOT.getSelectedLast()[0] + 1;
  23688. } else if (!innerHOT.flipped) {
  23689. selectedRow = innerHOT.getSelectedLast()[0];
  23690. var lastRow = innerHOT.countRows() - 1;
  23691. rowToSelect = Math.min(lastRow, selectedRow + 1);
  23692. }
  23693. }
  23694. } else if (event.keyCode == _unicode.KEY_CODES.ARROW_UP) {
  23695. if (!innerHOT.getSelectedLast() && innerHOT.flipped) {
  23696. rowToSelect = innerHOT.countRows() - 1;
  23697. } else if (innerHOT.getSelectedLast()) {
  23698. if (innerHOT.flipped) {
  23699. selectedRow = innerHOT.getSelectedLast()[0];
  23700. rowToSelect = Math.max(0, selectedRow - 1);
  23701. } else {
  23702. selectedRow = innerHOT.getSelectedLast()[0];
  23703. rowToSelect = selectedRow - 1;
  23704. }
  23705. }
  23706. }
  23707. if (rowToSelect !== void 0) {
  23708. if (rowToSelect < 0 || innerHOT.flipped && rowToSelect > innerHOT.countRows() - 1) {
  23709. innerHOT.deselectCell();
  23710. } else {
  23711. innerHOT.selectCell(rowToSelect, 0);
  23712. }
  23713. if (innerHOT.getData().length) {
  23714. event.preventDefault();
  23715. (0, _event.stopImmediatePropagation)(event);
  23716. editor.instance.listen();
  23717. editor.TEXTAREA.focus();
  23718. }
  23719. }
  23720. };
  23721. HandsontableEditor.prototype.open = function () {
  23722. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  23723. _textEditor2.default.prototype.open.apply(this, arguments);
  23724. if (this.htEditor) {
  23725. this.htEditor.destroy();
  23726. }
  23727. // Construct and initialise a new Handsontable
  23728. this.htEditor = new this.instance.constructor(this.htContainer, this.htOptions);
  23729. this.htEditor.init();
  23730. if (this.cellProperties.strict) {
  23731. this.htEditor.selectCell(0, 0);
  23732. this.TEXTAREA.style.visibility = 'hidden';
  23733. } else {
  23734. this.htEditor.deselectCell();
  23735. this.TEXTAREA.style.visibility = 'visible';
  23736. }
  23737. (0, _element.setCaretPosition)(this.TEXTAREA, 0, this.TEXTAREA.value.length);
  23738. };
  23739. HandsontableEditor.prototype.close = function () {
  23740. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  23741. this.instance.listen();
  23742. _textEditor2.default.prototype.close.apply(this, arguments);
  23743. };
  23744. HandsontableEditor.prototype.focus = function () {
  23745. this.instance.listen();
  23746. _textEditor2.default.prototype.focus.apply(this, arguments);
  23747. };
  23748. HandsontableEditor.prototype.beginEditing = function (initialValue) {
  23749. var onBeginEditing = this.instance.getSettings().onBeginEditing;
  23750. if (onBeginEditing && onBeginEditing() === false) {
  23751. return;
  23752. }
  23753. _textEditor2.default.prototype.beginEditing.apply(this, arguments);
  23754. };
  23755. HandsontableEditor.prototype.finishEditing = function (isCancelled, ctrlDown) {
  23756. if (this.htEditor && this.htEditor.isListening()) {
  23757. // if focus is still in the HOT editor
  23758. this.instance.listen(); // return the focus to the parent HOT instance
  23759. }
  23760. if (this.htEditor && this.htEditor.getSelectedLast()) {
  23761. var value = this.htEditor.getInstance().getValue();
  23762. if (value !== void 0) {
  23763. // if the value is undefined then it means we don't want to set the value
  23764. this.setValue(value);
  23765. }
  23766. }
  23767. return _textEditor2.default.prototype.finishEditing.apply(this, arguments);
  23768. };
  23769. HandsontableEditor.prototype.assignHooks = function () {
  23770. var _this = this;
  23771. this.instance.addHook('afterDestroy', function () {
  23772. if (_this.htEditor) {
  23773. _this.htEditor.destroy();
  23774. }
  23775. });
  23776. };
  23777. exports.default = HandsontableEditor;
  23778. /***/ }),
  23779. /* 309 */
  23780. /***/ (function(module, exports, __webpack_require__) {
  23781. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  23782. * numbro.js
  23783. * version : 1.11.0
  23784. * author : Företagsplatsen AB
  23785. * license : MIT
  23786. * http://www.foretagsplatsen.se
  23787. */
  23788. (function () {
  23789. 'use strict';
  23790. /************************************
  23791. Constants
  23792. ************************************/
  23793. var numbro,
  23794. VERSION = '1.11.0',
  23795. binarySuffixes = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'],
  23796. decimalSuffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
  23797. bytes = {
  23798. general: { scale: 1024, suffixes: decimalSuffixes, marker: 'bd' },
  23799. binary: { scale: 1024, suffixes: binarySuffixes, marker: 'b' },
  23800. decimal: { scale: 1000, suffixes: decimalSuffixes, marker: 'd' }
  23801. },
  23802. // general must be before the others because it reuses their characters!
  23803. byteFormatOrder = [ bytes.general, bytes.binary, bytes.decimal ],
  23804. // internal storage for culture config files
  23805. cultures = {},
  23806. // Todo: Remove in 2.0.0
  23807. languages = cultures,
  23808. currentCulture = 'en-US',
  23809. zeroFormat = null,
  23810. defaultFormat = '0,0',
  23811. defaultCurrencyFormat = '0$',
  23812. // check for nodeJS
  23813. hasModule = (typeof module !== 'undefined' && module.exports),
  23814. // default culture
  23815. enUS = {
  23816. delimiters: {
  23817. thousands: ',',
  23818. decimal: '.'
  23819. },
  23820. abbreviations: {
  23821. thousand: 'k',
  23822. million: 'm',
  23823. billion: 'b',
  23824. trillion: 't'
  23825. },
  23826. ordinal: function(number) {
  23827. var b = number % 10;
  23828. return (~~(number % 100 / 10) === 1) ? 'th' :
  23829. (b === 1) ? 'st' :
  23830. (b === 2) ? 'nd' :
  23831. (b === 3) ? 'rd' : 'th';
  23832. },
  23833. currency: {
  23834. symbol: '$',
  23835. position: 'prefix'
  23836. },
  23837. defaults: {
  23838. currencyFormat: ',0000 a'
  23839. },
  23840. formats: {
  23841. fourDigits: '0000 a',
  23842. fullWithTwoDecimals: '$ ,0.00',
  23843. fullWithTwoDecimalsNoCurrency: ',0.00'
  23844. }
  23845. };
  23846. /************************************
  23847. Constructors
  23848. ************************************/
  23849. // Numbro prototype object
  23850. function Numbro(number) {
  23851. this._value = number;
  23852. }
  23853. function numberLength(number) {
  23854. if (number === 0) { return 1; }
  23855. return Math.floor(Math.log(Math.abs(number)) / Math.LN10) + 1;
  23856. }
  23857. function zeroes(count) {
  23858. var i, ret = '';
  23859. for (i = 0; i < count; i++) {
  23860. ret += '0';
  23861. }
  23862. return ret;
  23863. }
  23864. /**
  23865. * Implementation of toFixed() for numbers with exponents
  23866. * This function may return negative representations for zero values e.g. "-0.0"
  23867. */
  23868. function toFixedLargeSmall(value, precision) {
  23869. var mantissa,
  23870. beforeDec,
  23871. afterDec,
  23872. exponent,
  23873. prefix,
  23874. endStr,
  23875. zerosStr,
  23876. str;
  23877. str = value.toString();
  23878. mantissa = str.split('e')[0];
  23879. exponent = str.split('e')[1];
  23880. beforeDec = mantissa.split('.')[0];
  23881. afterDec = mantissa.split('.')[1] || '';
  23882. if (+exponent > 0) {
  23883. // exponent is positive - add zeros after the numbers
  23884. str = beforeDec + afterDec + zeroes(exponent - afterDec.length);
  23885. } else {
  23886. // exponent is negative
  23887. if (+beforeDec < 0) {
  23888. prefix = '-0';
  23889. } else {
  23890. prefix = '0';
  23891. }
  23892. // tack on the decimal point if needed
  23893. if (precision > 0) {
  23894. prefix += '.';
  23895. }
  23896. zerosStr = zeroes((-1 * exponent) - 1);
  23897. // substring off the end to satisfy the precision
  23898. endStr = (zerosStr + Math.abs(beforeDec) + afterDec).substr(0, precision);
  23899. str = prefix + endStr;
  23900. }
  23901. // only add percision 0's if the exponent is positive
  23902. if (+exponent > 0 && precision > 0) {
  23903. str += '.' + zeroes(precision);
  23904. }
  23905. return str;
  23906. }
  23907. /**
  23908. * Implementation of toFixed() that treats floats more like decimals
  23909. *
  23910. * Fixes binary rounding issues (eg. (0.615).toFixed(2) === '0.61') that present
  23911. * problems for accounting- and finance-related software.
  23912. *
  23913. * Also removes negative signs for zero-formatted numbers. e.g. -0.01 w/ precision 1 -> 0.0
  23914. */
  23915. function toFixed(value, precision, roundingFunction, optionals) {
  23916. var power = Math.pow(10, precision),
  23917. optionalsRegExp,
  23918. output;
  23919. if (value.toString().indexOf('e') > -1) {
  23920. // toFixed returns scientific notation for numbers above 1e21 and below 1e-7
  23921. output = toFixedLargeSmall(value, precision);
  23922. // remove the leading negative sign if it exists and should not be present (e.g. -0.00)
  23923. if (output.charAt(0) === '-' && +output >= 0) {
  23924. output = output.substr(1); // chop off the '-'
  23925. }
  23926. }
  23927. else {
  23928. // Multiply up by precision, round accurately, then divide and use native toFixed():
  23929. output = (roundingFunction(value + 'e+' + precision) / power).toFixed(precision);
  23930. }
  23931. if (optionals) {
  23932. optionalsRegExp = new RegExp('0{1,' + optionals + '}$');
  23933. output = output.replace(optionalsRegExp, '');
  23934. }
  23935. return output;
  23936. }
  23937. /************************************
  23938. Formatting
  23939. ************************************/
  23940. // determine what type of formatting we need to do
  23941. function formatNumbro(n, format, roundingFunction) {
  23942. var output,
  23943. escapedFormat = format.replace(/\{[^\{\}]*\}/g, '');
  23944. // figure out what kind of format we are dealing with
  23945. if (escapedFormat.indexOf('$') > -1) { // currency!!!!!
  23946. output = formatCurrency(n, cultures[currentCulture].currency.symbol, format, roundingFunction);
  23947. } else if (escapedFormat.indexOf('%') > -1) { // percentage
  23948. output = formatPercentage(n, format, roundingFunction);
  23949. } else if (escapedFormat.indexOf(':') > -1) { // time
  23950. output = formatTime(n, format);
  23951. } else { // plain ol' numbers or bytes
  23952. output = formatNumber(n._value, format, roundingFunction);
  23953. }
  23954. // return string
  23955. return output;
  23956. }
  23957. // revert to number
  23958. function unformatNumbro(n, string) {
  23959. var stringOriginal = string,
  23960. thousandRegExp,
  23961. millionRegExp,
  23962. billionRegExp,
  23963. trillionRegExp,
  23964. bytesMultiplier = false,
  23965. power;
  23966. if (string.indexOf(':') > -1) {
  23967. n._value = unformatTime(string);
  23968. } else {
  23969. if (string === zeroFormat) {
  23970. n._value = 0;
  23971. } else {
  23972. if (cultures[currentCulture].delimiters.decimal !== '.') {
  23973. string = string.replace(/\./g, '').replace(cultures[currentCulture].delimiters.decimal, '.');
  23974. }
  23975. // see if abbreviations are there so that we can multiply to the correct number
  23976. thousandRegExp = new RegExp('[^a-zA-Z]' + cultures[currentCulture].abbreviations.thousand +
  23977. '(?:\\)|(\\' + cultures[currentCulture].currency.symbol + ')?(?:\\))?)?$');
  23978. millionRegExp = new RegExp('[^a-zA-Z]' + cultures[currentCulture].abbreviations.million +
  23979. '(?:\\)|(\\' + cultures[currentCulture].currency.symbol + ')?(?:\\))?)?$');
  23980. billionRegExp = new RegExp('[^a-zA-Z]' + cultures[currentCulture].abbreviations.billion +
  23981. '(?:\\)|(\\' + cultures[currentCulture].currency.symbol + ')?(?:\\))?)?$');
  23982. trillionRegExp = new RegExp('[^a-zA-Z]' + cultures[currentCulture].abbreviations.trillion +
  23983. '(?:\\)|(\\' + cultures[currentCulture].currency.symbol + ')?(?:\\))?)?$');
  23984. // see if bytes are there so that we can multiply to the correct number
  23985. for (power = 1; power < binarySuffixes.length && !bytesMultiplier; ++power) {
  23986. if (string.indexOf(binarySuffixes[power]) > -1) {
  23987. bytesMultiplier = Math.pow(1024, power);
  23988. } else if (string.indexOf(decimalSuffixes[power]) > -1) {
  23989. bytesMultiplier = Math.pow(1000, power);
  23990. }
  23991. }
  23992. var str = string.replace(/[^0-9\.]+/g, '');
  23993. if (str === '') {
  23994. // An empty string is not a number.
  23995. n._value = NaN;
  23996. } else {
  23997. // do some math to create our number
  23998. n._value = ((bytesMultiplier) ? bytesMultiplier : 1) *
  23999. ((stringOriginal.match(thousandRegExp)) ? Math.pow(10, 3) : 1) *
  24000. ((stringOriginal.match(millionRegExp)) ? Math.pow(10, 6) : 1) *
  24001. ((stringOriginal.match(billionRegExp)) ? Math.pow(10, 9) : 1) *
  24002. ((stringOriginal.match(trillionRegExp)) ? Math.pow(10, 12) : 1) *
  24003. ((string.indexOf('%') > -1) ? 0.01 : 1) *
  24004. (((string.split('-').length +
  24005. Math.min(string.split('(').length - 1, string.split(')').length - 1)) % 2) ? 1 : -1) *
  24006. Number(str);
  24007. // round if we are talking about bytes
  24008. n._value = (bytesMultiplier) ? Math.ceil(n._value) : n._value;
  24009. }
  24010. }
  24011. }
  24012. return n._value;
  24013. }
  24014. function formatCurrency(n, currencySymbol, originalFormat, roundingFunction) {
  24015. var format = originalFormat,
  24016. symbolIndex = format.indexOf('$'),
  24017. openParenIndex = format.indexOf('('),
  24018. plusSignIndex = format.indexOf('+'),
  24019. minusSignIndex = format.indexOf('-'),
  24020. space = '',
  24021. decimalSeparator = '',
  24022. spliceIndex,
  24023. output;
  24024. if(format.indexOf('$') === -1){
  24025. // Use defaults instead of the format provided
  24026. if (cultures[currentCulture].currency.position === 'infix') {
  24027. decimalSeparator = currencySymbol;
  24028. if (cultures[currentCulture].currency.spaceSeparated) {
  24029. decimalSeparator = ' ' + decimalSeparator + ' ';
  24030. }
  24031. } else if (cultures[currentCulture].currency.spaceSeparated) {
  24032. space = ' ';
  24033. }
  24034. } else {
  24035. // check for space before or after currency
  24036. if (format.indexOf(' $') > -1) {
  24037. space = ' ';
  24038. format = format.replace(' $', '');
  24039. } else if (format.indexOf('$ ') > -1) {
  24040. space = ' ';
  24041. format = format.replace('$ ', '');
  24042. } else {
  24043. format = format.replace('$', '');
  24044. }
  24045. }
  24046. // Format The Number
  24047. output = formatNumber(n._value, format, roundingFunction, decimalSeparator);
  24048. if (originalFormat.indexOf('$') === -1) {
  24049. // Use defaults instead of the format provided
  24050. switch (cultures[currentCulture].currency.position) {
  24051. case 'postfix':
  24052. if (output.indexOf(')') > -1) {
  24053. output = output.split('');
  24054. output.splice(-1, 0, space + currencySymbol);
  24055. output = output.join('');
  24056. } else {
  24057. output = output + space + currencySymbol;
  24058. }
  24059. break;
  24060. case 'infix':
  24061. break;
  24062. case 'prefix':
  24063. if (output.indexOf('(') > -1 || output.indexOf('-') > -1) {
  24064. output = output.split('');
  24065. spliceIndex = Math.max(openParenIndex, minusSignIndex) + 1;
  24066. output.splice(spliceIndex, 0, currencySymbol + space);
  24067. output = output.join('');
  24068. } else {
  24069. output = currencySymbol + space + output;
  24070. }
  24071. break;
  24072. default:
  24073. throw Error('Currency position should be among ["prefix", "infix", "postfix"]');
  24074. }
  24075. } else {
  24076. // position the symbol
  24077. if (symbolIndex <= 1) {
  24078. if (output.indexOf('(') > -1 || output.indexOf('+') > -1 || output.indexOf('-') > -1) {
  24079. output = output.split('');
  24080. spliceIndex = 1;
  24081. if (symbolIndex < openParenIndex || symbolIndex < plusSignIndex || symbolIndex < minusSignIndex) {
  24082. // the symbol appears before the "(", "+" or "-"
  24083. spliceIndex = 0;
  24084. }
  24085. output.splice(spliceIndex, 0, currencySymbol + space);
  24086. output = output.join('');
  24087. } else {
  24088. output = currencySymbol + space + output;
  24089. }
  24090. } else {
  24091. if (output.indexOf(')') > -1) {
  24092. output = output.split('');
  24093. output.splice(-1, 0, space + currencySymbol);
  24094. output = output.join('');
  24095. } else {
  24096. output = output + space + currencySymbol;
  24097. }
  24098. }
  24099. }
  24100. return output;
  24101. }
  24102. function formatForeignCurrency(n, foreignCurrencySymbol, originalFormat, roundingFunction) {
  24103. return formatCurrency(n, foreignCurrencySymbol, originalFormat, roundingFunction);
  24104. }
  24105. function formatPercentage(n, format, roundingFunction) {
  24106. var space = '',
  24107. output,
  24108. value = n._value * 100;
  24109. // check for space before %
  24110. if (format.indexOf(' %') > -1) {
  24111. space = ' ';
  24112. format = format.replace(' %', '');
  24113. } else {
  24114. format = format.replace('%', '');
  24115. }
  24116. output = formatNumber(value, format, roundingFunction);
  24117. if (output.indexOf(')') > -1) {
  24118. output = output.split('');
  24119. output.splice(-1, 0, space + '%');
  24120. output = output.join('');
  24121. } else {
  24122. output = output + space + '%';
  24123. }
  24124. return output;
  24125. }
  24126. function formatTime(n) {
  24127. var hours = Math.floor(n._value / 60 / 60),
  24128. minutes = Math.floor((n._value - (hours * 60 * 60)) / 60),
  24129. seconds = Math.round(n._value - (hours * 60 * 60) - (minutes * 60));
  24130. return hours + ':' +
  24131. ((minutes < 10) ? '0' + minutes : minutes) + ':' +
  24132. ((seconds < 10) ? '0' + seconds : seconds);
  24133. }
  24134. function unformatTime(string) {
  24135. var timeArray = string.split(':'),
  24136. seconds = 0;
  24137. // turn hours and minutes into seconds and add them all up
  24138. if (timeArray.length === 3) {
  24139. // hours
  24140. seconds = seconds + (Number(timeArray[0]) * 60 * 60);
  24141. // minutes
  24142. seconds = seconds + (Number(timeArray[1]) * 60);
  24143. // seconds
  24144. seconds = seconds + Number(timeArray[2]);
  24145. } else if (timeArray.length === 2) {
  24146. // minutes
  24147. seconds = seconds + (Number(timeArray[0]) * 60);
  24148. // seconds
  24149. seconds = seconds + Number(timeArray[1]);
  24150. }
  24151. return Number(seconds);
  24152. }
  24153. function formatByteUnits (value, suffixes, scale) {
  24154. var suffix = suffixes[0],
  24155. power,
  24156. min,
  24157. max,
  24158. abs = Math.abs(value);
  24159. if (abs >= scale) {
  24160. for (power = 1; power < suffixes.length; ++power) {
  24161. min = Math.pow(scale, power);
  24162. max = Math.pow(scale, power + 1);
  24163. if (abs >= min && abs < max) {
  24164. suffix = suffixes[power];
  24165. value = value / min;
  24166. break;
  24167. }
  24168. }
  24169. // values greater than or equal to [scale] YB never set the suffix
  24170. if (suffix === suffixes[0]) {
  24171. value = value / Math.pow(scale, suffixes.length - 1);
  24172. suffix = suffixes[suffixes.length - 1];
  24173. }
  24174. }
  24175. return { value: value, suffix: suffix };
  24176. }
  24177. function formatNumber (value, format, roundingFunction, sep) {
  24178. var negP = false,
  24179. signed = false,
  24180. optDec = false,
  24181. abbr = '',
  24182. abbrK = false, // force abbreviation to thousands
  24183. abbrM = false, // force abbreviation to millions
  24184. abbrB = false, // force abbreviation to billions
  24185. abbrT = false, // force abbreviation to trillions
  24186. abbrForce = false, // force abbreviation
  24187. bytes = '',
  24188. byteFormat,
  24189. units,
  24190. ord = '',
  24191. abs = Math.abs(value),
  24192. totalLength,
  24193. length,
  24194. minimumPrecision,
  24195. pow,
  24196. w,
  24197. intPrecision,
  24198. precision,
  24199. prefix,
  24200. postfix,
  24201. thousands,
  24202. d = '',
  24203. forcedNeg = false,
  24204. neg = false,
  24205. indexOpenP,
  24206. indexMinus,
  24207. paren = '',
  24208. minlen,
  24209. i;
  24210. // check if number is zero and a custom zero format has been set
  24211. if (value === 0 && zeroFormat !== null) {
  24212. return zeroFormat;
  24213. }
  24214. if (!isFinite(value)) {
  24215. return '' + value;
  24216. }
  24217. if (format.indexOf('{') === 0) {
  24218. var end = format.indexOf('}');
  24219. if (end === -1) {
  24220. throw Error('Format should also contain a "}"');
  24221. }
  24222. prefix = format.slice(1, end);
  24223. format = format.slice(end + 1);
  24224. } else {
  24225. prefix = '';
  24226. }
  24227. if (format.indexOf('}') === format.length - 1 && format.length) {
  24228. var start = format.indexOf('{');
  24229. if (start === -1) {
  24230. throw Error('Format should also contain a "{"');
  24231. }
  24232. postfix = format.slice(start + 1, -1);
  24233. format = format.slice(0, start + 1);
  24234. } else {
  24235. postfix = '';
  24236. }
  24237. // check for min length
  24238. var info;
  24239. if (format.indexOf('.') === -1) {
  24240. info = format.match(/([0-9]+).*/);
  24241. } else {
  24242. info = format.match(/([0-9]+)\..*/);
  24243. }
  24244. minlen = info === null ? -1 : info[1].length;
  24245. // see if we should use parentheses for negative number or if we should prefix with a sign
  24246. // if both are present we default to parentheses
  24247. if (format.indexOf('-') !== -1) {
  24248. forcedNeg = true;
  24249. }
  24250. if (format.indexOf('(') > -1) {
  24251. negP = true;
  24252. format = format.slice(1, -1);
  24253. } else if (format.indexOf('+') > -1) {
  24254. signed = true;
  24255. format = format.replace(/\+/g, '');
  24256. }
  24257. // see if abbreviation is wanted
  24258. if (format.indexOf('a') > -1) {
  24259. intPrecision = format.split('.')[0].match(/[0-9]+/g) || ['0'];
  24260. intPrecision = parseInt(intPrecision[0], 10);
  24261. // check if abbreviation is specified
  24262. abbrK = format.indexOf('aK') >= 0;
  24263. abbrM = format.indexOf('aM') >= 0;
  24264. abbrB = format.indexOf('aB') >= 0;
  24265. abbrT = format.indexOf('aT') >= 0;
  24266. abbrForce = abbrK || abbrM || abbrB || abbrT;
  24267. // check for space before abbreviation
  24268. if (format.indexOf(' a') > -1) {
  24269. abbr = ' ';
  24270. format = format.replace(' a', '');
  24271. } else {
  24272. format = format.replace('a', '');
  24273. }
  24274. totalLength = numberLength(value);
  24275. minimumPrecision = totalLength % 3;
  24276. minimumPrecision = minimumPrecision === 0 ? 3 : minimumPrecision;
  24277. if (intPrecision && abs !== 0) {
  24278. pow = 3 * ~~((Math.min(intPrecision, totalLength) - minimumPrecision) / 3);
  24279. abs = abs / Math.pow(10, pow);
  24280. }
  24281. if (totalLength !== intPrecision) {
  24282. if (abs >= Math.pow(10, 12) && !abbrForce || abbrT) {
  24283. // trillion
  24284. abbr = abbr + cultures[currentCulture].abbreviations.trillion;
  24285. value = value / Math.pow(10, 12);
  24286. } else if (abs < Math.pow(10, 12) && abs >= Math.pow(10, 9) && !abbrForce || abbrB) {
  24287. // billion
  24288. abbr = abbr + cultures[currentCulture].abbreviations.billion;
  24289. value = value / Math.pow(10, 9);
  24290. } else if (abs < Math.pow(10, 9) && abs >= Math.pow(10, 6) && !abbrForce || abbrM) {
  24291. // million
  24292. abbr = abbr + cultures[currentCulture].abbreviations.million;
  24293. value = value / Math.pow(10, 6);
  24294. } else if (abs < Math.pow(10, 6) && abs >= Math.pow(10, 3) && !abbrForce || abbrK) {
  24295. // thousand
  24296. abbr = abbr + cultures[currentCulture].abbreviations.thousand;
  24297. value = value / Math.pow(10, 3);
  24298. }
  24299. }
  24300. length = numberLength(value);
  24301. if (intPrecision && length < intPrecision && format.indexOf('.') === -1) {
  24302. format += '[.]';
  24303. format += zeroes(intPrecision - length);
  24304. }
  24305. }
  24306. // see if we are formatting
  24307. // binary-decimal bytes (1024 MB), binary bytes (1024 MiB), or decimal bytes (1000 MB)
  24308. for (i = 0; i < byteFormatOrder.length; ++i) {
  24309. byteFormat = byteFormatOrder[i];
  24310. if (format.indexOf(byteFormat.marker) > -1) {
  24311. // check for space before
  24312. if (format.indexOf(' ' + byteFormat.marker) >-1) {
  24313. bytes = ' ';
  24314. }
  24315. // remove the marker (with the space if it had one)
  24316. format = format.replace(bytes + byteFormat.marker, '');
  24317. units = formatByteUnits(value, byteFormat.suffixes, byteFormat.scale);
  24318. value = units.value;
  24319. bytes = bytes + units.suffix;
  24320. break;
  24321. }
  24322. }
  24323. // see if ordinal is wanted
  24324. if (format.indexOf('o') > -1) {
  24325. // check for space before
  24326. if (format.indexOf(' o') > -1) {
  24327. ord = ' ';
  24328. format = format.replace(' o', '');
  24329. } else {
  24330. format = format.replace('o', '');
  24331. }
  24332. if (cultures[currentCulture].ordinal) {
  24333. ord = ord + cultures[currentCulture].ordinal(value);
  24334. }
  24335. }
  24336. if (format.indexOf('[.]') > -1) {
  24337. optDec = true;
  24338. format = format.replace('[.]', '.');
  24339. }
  24340. precision = format.split('.')[1];
  24341. thousands = format.indexOf(',');
  24342. if (precision) {
  24343. var dSplit = [];
  24344. if (precision.indexOf('*') !== -1) {
  24345. d = value.toString();
  24346. dSplit = d.split('.');
  24347. if (dSplit.length > 1) {
  24348. d = toFixed(value, dSplit[1].length, roundingFunction);
  24349. }
  24350. } else {
  24351. if (precision.indexOf('[') > -1) {
  24352. precision = precision.replace(']', '');
  24353. precision = precision.split('[');
  24354. d = toFixed(value, (precision[0].length + precision[1].length), roundingFunction,
  24355. precision[1].length);
  24356. } else {
  24357. d = toFixed(value, precision.length, roundingFunction);
  24358. }
  24359. }
  24360. dSplit = d.split('.');
  24361. w = dSplit[0];
  24362. if (dSplit.length > 1 && dSplit[1].length) {
  24363. var p = sep ? abbr + sep : cultures[currentCulture].delimiters.decimal;
  24364. d = p + dSplit[1];
  24365. } else {
  24366. d = '';
  24367. }
  24368. if (optDec && Number(d.slice(1)) === 0) {
  24369. d = '';
  24370. }
  24371. } else {
  24372. w = toFixed(value, 0, roundingFunction);
  24373. }
  24374. // format number
  24375. if (w.indexOf('-') > -1) {
  24376. w = w.slice(1);
  24377. neg = true;
  24378. }
  24379. if (w.length < minlen) {
  24380. w = zeroes(minlen - w.length) + w;
  24381. }
  24382. if (thousands > -1) {
  24383. w = w.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' +
  24384. cultures[currentCulture].delimiters.thousands);
  24385. }
  24386. if (format.indexOf('.') === 0) {
  24387. w = '';
  24388. }
  24389. indexOpenP = format.indexOf('(');
  24390. indexMinus = format.indexOf('-');
  24391. if (indexOpenP < indexMinus) {
  24392. paren = ((negP && neg) ? '(' : '') + (((forcedNeg && neg) || (!negP && neg)) ? '-' : '');
  24393. } else {
  24394. paren = (((forcedNeg && neg) || (!negP && neg)) ? '-' : '') + ((negP && neg) ? '(' : '');
  24395. }
  24396. return prefix +
  24397. paren + ((!neg && signed && value !== 0) ? '+' : '') +
  24398. w + d +
  24399. ((ord) ? ord : '') +
  24400. ((abbr && !sep) ? abbr : '') +
  24401. ((bytes) ? bytes : '') +
  24402. ((negP && neg) ? ')' : '') +
  24403. postfix;
  24404. }
  24405. /************************************
  24406. Top Level Functions
  24407. ************************************/
  24408. numbro = function(input) {
  24409. if (numbro.isNumbro(input)) {
  24410. input = input.value();
  24411. } else if (typeof input === 'string' || typeof input === 'number') {
  24412. input = numbro.fn.unformat(input);
  24413. } else {
  24414. input = NaN;
  24415. }
  24416. return new Numbro(Number(input));
  24417. };
  24418. // version number
  24419. numbro.version = VERSION;
  24420. // compare numbro object
  24421. numbro.isNumbro = function(obj) {
  24422. return obj instanceof Numbro;
  24423. };
  24424. /**
  24425. * This function allow the user to set a new language with a fallback if
  24426. * the language does not exist. If no fallback language is provided,
  24427. * it fallbacks to english.
  24428. *
  24429. * @deprecated Since in version 1.6.0. It will be deleted in version 2.0
  24430. * `setCulture` should be used instead.
  24431. */
  24432. numbro.setLanguage = function(newLanguage, fallbackLanguage) {
  24433. console.warn('`setLanguage` is deprecated since version 1.6.0. Use `setCulture` instead');
  24434. var key = newLanguage,
  24435. prefix = newLanguage.split('-')[0],
  24436. matchingLanguage = null;
  24437. if (!languages[key]) {
  24438. Object.keys(languages).forEach(function(language) {
  24439. if (!matchingLanguage && language.split('-')[0] === prefix) {
  24440. matchingLanguage = language;
  24441. }
  24442. });
  24443. key = matchingLanguage || fallbackLanguage || 'en-US';
  24444. }
  24445. chooseCulture(key);
  24446. };
  24447. /**
  24448. * This function allow the user to set a new culture with a fallback if
  24449. * the culture does not exist. If no fallback culture is provided,
  24450. * it falls back to "en-US".
  24451. */
  24452. numbro.setCulture = function(newCulture, fallbackCulture) {
  24453. var key = newCulture,
  24454. suffix = newCulture.split('-')[1],
  24455. matchingCulture = null;
  24456. if (!cultures[key]) {
  24457. if (suffix) {
  24458. Object.keys(cultures).forEach(function(language) {
  24459. if (!matchingCulture && language.split('-')[1] === suffix) {
  24460. matchingCulture = language;
  24461. }
  24462. });
  24463. }
  24464. key = matchingCulture || fallbackCulture || 'en-US';
  24465. }
  24466. chooseCulture(key);
  24467. };
  24468. /**
  24469. * This function will load languages and then set the global language. If
  24470. * no arguments are passed in, it will simply return the current global
  24471. * language key.
  24472. *
  24473. * @deprecated Since in version 1.6.0. It will be deleted in version 2.0
  24474. * `culture` should be used instead.
  24475. */
  24476. numbro.language = function(key, values) {
  24477. console.warn('`language` is deprecated since version 1.6.0. Use `culture` instead');
  24478. if (!key) {
  24479. return currentCulture;
  24480. }
  24481. if (key && !values) {
  24482. if (!languages[key]) {
  24483. throw new Error('Unknown language : ' + key);
  24484. }
  24485. chooseCulture(key);
  24486. }
  24487. if (values || !languages[key]) {
  24488. setCulture(key, values);
  24489. }
  24490. return numbro;
  24491. };
  24492. /**
  24493. * This function will load cultures and then set the global culture. If
  24494. * no arguments are passed in, it will simply return the current global
  24495. * culture code.
  24496. */
  24497. numbro.culture = function(code, values) {
  24498. if (!code) {
  24499. return currentCulture;
  24500. }
  24501. if (code && !values) {
  24502. if (!cultures[code]) {
  24503. throw new Error('Unknown culture : ' + code);
  24504. }
  24505. chooseCulture(code);
  24506. }
  24507. if (values || !cultures[code]) {
  24508. setCulture(code, values);
  24509. }
  24510. return numbro;
  24511. };
  24512. /**
  24513. * This function provides access to the loaded language data. If
  24514. * no arguments are passed in, it will simply return the current
  24515. * global language object.
  24516. *
  24517. * @deprecated Since in version 1.6.0. It will be deleted in version 2.0
  24518. * `culture` should be used instead.
  24519. */
  24520. numbro.languageData = function(key) {
  24521. console.warn('`languageData` is deprecated since version 1.6.0. Use `cultureData` instead');
  24522. if (!key) {
  24523. return languages[currentCulture];
  24524. }
  24525. if (!languages[key]) {
  24526. throw new Error('Unknown language : ' + key);
  24527. }
  24528. return languages[key];
  24529. };
  24530. /**
  24531. * This function provides access to the loaded culture data. If
  24532. * no arguments are passed in, it will simply return the current
  24533. * global culture object.
  24534. */
  24535. numbro.cultureData = function(code) {
  24536. if (!code) {
  24537. return cultures[currentCulture];
  24538. }
  24539. if (!cultures[code]) {
  24540. throw new Error('Unknown culture : ' + code);
  24541. }
  24542. return cultures[code];
  24543. };
  24544. numbro.culture('en-US', enUS);
  24545. /**
  24546. * @deprecated Since in version 1.6.0. It will be deleted in version 2.0
  24547. * `cultures` should be used instead.
  24548. */
  24549. numbro.languages = function() {
  24550. console.warn('`languages` is deprecated since version 1.6.0. Use `cultures` instead');
  24551. return languages;
  24552. };
  24553. numbro.cultures = function() {
  24554. return cultures;
  24555. };
  24556. numbro.zeroFormat = function(format) {
  24557. zeroFormat = typeof(format) === 'string' ? format : null;
  24558. };
  24559. numbro.defaultFormat = function(format) {
  24560. defaultFormat = typeof(format) === 'string' ? format : '0.0';
  24561. };
  24562. numbro.defaultCurrencyFormat = function (format) {
  24563. defaultCurrencyFormat = typeof(format) === 'string' ? format : '0$';
  24564. };
  24565. numbro.validate = function(val, culture) {
  24566. var _decimalSep,
  24567. _thousandSep,
  24568. _currSymbol,
  24569. _valArray,
  24570. _abbrObj,
  24571. _thousandRegEx,
  24572. cultureData,
  24573. temp;
  24574. //coerce val to string
  24575. if (typeof val !== 'string') {
  24576. val += '';
  24577. if (console.warn) {
  24578. console.warn('Numbro.js: Value is not string. It has been co-erced to: ', val);
  24579. }
  24580. }
  24581. //trim whitespaces from either sides
  24582. val = val.trim();
  24583. //replace the initial '+' or '-' sign if present
  24584. val = val.replace(/^[+-]?/, '');
  24585. //if val is just digits return true
  24586. if ( !! val.match(/^\d+$/)) {
  24587. return true;
  24588. }
  24589. //if val is empty return false
  24590. if (val === '') {
  24591. return false;
  24592. }
  24593. //get the decimal and thousands separator from numbro.cultureData
  24594. try {
  24595. //check if the culture is understood by numbro. if not, default it to current culture
  24596. cultureData = numbro.cultureData(culture);
  24597. } catch (e) {
  24598. cultureData = numbro.cultureData(numbro.culture());
  24599. }
  24600. //setup the delimiters and currency symbol based on culture
  24601. _currSymbol = cultureData.currency.symbol;
  24602. _abbrObj = cultureData.abbreviations;
  24603. _decimalSep = cultureData.delimiters.decimal;
  24604. if (cultureData.delimiters.thousands === '.') {
  24605. _thousandSep = '\\.';
  24606. } else {
  24607. _thousandSep = cultureData.delimiters.thousands;
  24608. }
  24609. // validating currency symbol
  24610. temp = val.match(/^[^\d\.\,]+/);
  24611. if (temp !== null) {
  24612. val = val.substr(1);
  24613. if (temp[0] !== _currSymbol) {
  24614. return false;
  24615. }
  24616. }
  24617. //validating abbreviation symbol
  24618. temp = val.match(/[^\d]+$/);
  24619. if (temp !== null) {
  24620. val = val.slice(0, -1);
  24621. if (temp[0] !== _abbrObj.thousand && temp[0] !== _abbrObj.million &&
  24622. temp[0] !== _abbrObj.billion && temp[0] !== _abbrObj.trillion) {
  24623. return false;
  24624. }
  24625. }
  24626. _thousandRegEx = new RegExp(_thousandSep + '{2}');
  24627. if (!val.match(/[^\d.,]/g)) {
  24628. _valArray = val.split(_decimalSep);
  24629. if (_valArray.length > 2) {
  24630. return false;
  24631. } else {
  24632. if (_valArray.length < 2) {
  24633. return ( !! _valArray[0].match(/^\d+.*\d$/) && !_valArray[0].match(_thousandRegEx));
  24634. } else {
  24635. if (_valArray[0] === '') {
  24636. // for values without leading zero eg. .984
  24637. return (!_valArray[0].match(_thousandRegEx) &&
  24638. !!_valArray[1].match(/^\d+$/));
  24639. } else if (_valArray[0].length === 1) {
  24640. return ( !! _valArray[0].match(/^\d+$/) &&
  24641. !_valArray[0].match(_thousandRegEx) &&
  24642. !! _valArray[1].match(/^\d+$/));
  24643. } else {
  24644. return ( !! _valArray[0].match(/^\d+.*\d$/) &&
  24645. !_valArray[0].match(_thousandRegEx) &&
  24646. !! _valArray[1].match(/^\d+$/));
  24647. }
  24648. }
  24649. }
  24650. }
  24651. return false;
  24652. };
  24653. /**
  24654. * * @deprecated Since in version 1.6.0. It will be deleted in version 2.0
  24655. * `loadCulturesInNode` should be used instead.
  24656. */
  24657. numbro.loadLanguagesInNode = function() {
  24658. console.warn('`loadLanguagesInNode` is deprecated since version 1.6.0. Use `loadCulturesInNode` instead');
  24659. numbro.loadCulturesInNode();
  24660. };
  24661. numbro.loadCulturesInNode = function() {
  24662. // TODO: Rename the folder in 2.0.0
  24663. var cultures = __webpack_require__(369);
  24664. for(var langLocaleCode in cultures) {
  24665. if(langLocaleCode) {
  24666. numbro.culture(langLocaleCode, cultures[langLocaleCode]);
  24667. }
  24668. }
  24669. };
  24670. /************************************
  24671. Helpers
  24672. ************************************/
  24673. function setCulture(code, values) {
  24674. cultures[code] = values;
  24675. }
  24676. function chooseCulture(code) {
  24677. currentCulture = code;
  24678. var defaults = cultures[code].defaults;
  24679. if (defaults && defaults.format) {
  24680. numbro.defaultFormat(defaults.format);
  24681. }
  24682. if (defaults && defaults.currencyFormat) {
  24683. numbro.defaultCurrencyFormat(defaults.currencyFormat);
  24684. }
  24685. }
  24686. function inNodejsRuntime() {
  24687. return (typeof process !== 'undefined') &&
  24688. (process.browser === undefined) &&
  24689. process.title &&
  24690. (
  24691. process.title.indexOf('node') !== -1 ||
  24692. process.title.indexOf('meteor-tool') > 0 ||
  24693. process.title === 'grunt' ||
  24694. process.title === 'gulp'
  24695. ) &&
  24696. ("function" !== 'undefined');
  24697. }
  24698. /************************************
  24699. Floating-point helpers
  24700. ************************************/
  24701. // The floating-point helper functions and implementation
  24702. // borrows heavily from sinful.js: http://guipn.github.io/sinful.js/
  24703. /**
  24704. * Array.prototype.reduce for browsers that don't support it
  24705. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce#Compatibility
  24706. */
  24707. if ('function' !== typeof Array.prototype.reduce) {
  24708. Array.prototype.reduce = function(callback, optInitialValue) {
  24709. if (null === this || 'undefined' === typeof this) {
  24710. // At the moment all modern browsers, that support strict mode, have
  24711. // native implementation of Array.prototype.reduce. For instance, IE8
  24712. // does not support strict mode, so this check is actually useless.
  24713. throw new TypeError('Array.prototype.reduce called on null or undefined');
  24714. }
  24715. if ('function' !== typeof callback) {
  24716. throw new TypeError(callback + ' is not a function');
  24717. }
  24718. var index,
  24719. value,
  24720. length = this.length >>> 0,
  24721. isValueSet = false;
  24722. if (1 < arguments.length) {
  24723. value = optInitialValue;
  24724. isValueSet = true;
  24725. }
  24726. for (index = 0; length > index; ++index) {
  24727. if (this.hasOwnProperty(index)) {
  24728. if (isValueSet) {
  24729. value = callback(value, this[index], index, this);
  24730. } else {
  24731. value = this[index];
  24732. isValueSet = true;
  24733. }
  24734. }
  24735. }
  24736. if (!isValueSet) {
  24737. throw new TypeError('Reduce of empty array with no initial value');
  24738. }
  24739. return value;
  24740. };
  24741. }
  24742. /**
  24743. * Computes the multiplier necessary to make x >= 1,
  24744. * effectively eliminating miscalculations caused by
  24745. * finite precision.
  24746. */
  24747. function multiplier(x) {
  24748. var parts = x.toString().split('.');
  24749. if (parts.length < 2) {
  24750. return 1;
  24751. }
  24752. return Math.pow(10, parts[1].length);
  24753. }
  24754. /**
  24755. * Given a variable number of arguments, returns the maximum
  24756. * multiplier that must be used to normalize an operation involving
  24757. * all of them.
  24758. */
  24759. function correctionFactor() {
  24760. var args = Array.prototype.slice.call(arguments);
  24761. return args.reduce(function(prev, next) {
  24762. var mp = multiplier(prev),
  24763. mn = multiplier(next);
  24764. return mp > mn ? mp : mn;
  24765. }, -Infinity);
  24766. }
  24767. /************************************
  24768. Numbro Prototype
  24769. ************************************/
  24770. numbro.fn = Numbro.prototype = {
  24771. clone: function() {
  24772. return numbro(this);
  24773. },
  24774. format: function(inputString, roundingFunction) {
  24775. return formatNumbro(this,
  24776. inputString ? inputString : defaultFormat,
  24777. (roundingFunction !== undefined) ? roundingFunction : Math.round
  24778. );
  24779. },
  24780. formatCurrency: function(inputString, roundingFunction) {
  24781. return formatCurrency(this,
  24782. cultures[currentCulture].currency.symbol,
  24783. inputString ? inputString : defaultCurrencyFormat,
  24784. (roundingFunction !== undefined) ? roundingFunction : Math.round
  24785. );
  24786. },
  24787. formatForeignCurrency: function(currencySymbol, inputString, roundingFunction) {
  24788. return formatForeignCurrency(this,
  24789. currencySymbol,
  24790. inputString ? inputString : defaultCurrencyFormat,
  24791. (roundingFunction !== undefined) ? roundingFunction : Math.round
  24792. );
  24793. },
  24794. unformat: function(inputString) {
  24795. if (typeof inputString === 'number') {
  24796. return inputString;
  24797. } else if (typeof inputString === 'string') {
  24798. var result = unformatNumbro(this, inputString);
  24799. // Any unparseable string (represented as NaN in the result) is
  24800. // converted into undefined.
  24801. return isNaN(result) ? undefined : result;
  24802. } else {
  24803. return undefined;
  24804. }
  24805. },
  24806. binaryByteUnits: function() {
  24807. return formatByteUnits(this._value, bytes.binary.suffixes, bytes.binary.scale).suffix;
  24808. },
  24809. byteUnits: function() {
  24810. return formatByteUnits(this._value, bytes.general.suffixes, bytes.general.scale).suffix;
  24811. },
  24812. decimalByteUnits: function() {
  24813. return formatByteUnits(this._value, bytes.decimal.suffixes, bytes.decimal.scale).suffix;
  24814. },
  24815. value: function() {
  24816. return this._value;
  24817. },
  24818. valueOf: function() {
  24819. return this._value;
  24820. },
  24821. set: function(value) {
  24822. this._value = Number(value);
  24823. return this;
  24824. },
  24825. add: function(value) {
  24826. var corrFactor = correctionFactor.call(null, this._value, value);
  24827. function cback(accum, curr) {
  24828. return accum + corrFactor * curr;
  24829. }
  24830. this._value = [this._value, value].reduce(cback, 0) / corrFactor;
  24831. return this;
  24832. },
  24833. subtract: function(value) {
  24834. var corrFactor = correctionFactor.call(null, this._value, value);
  24835. function cback(accum, curr) {
  24836. return accum - corrFactor * curr;
  24837. }
  24838. this._value = [value].reduce(cback, this._value * corrFactor) / corrFactor;
  24839. return this;
  24840. },
  24841. multiply: function(value) {
  24842. function cback(accum, curr) {
  24843. var corrFactor = correctionFactor(accum, curr),
  24844. result = accum * corrFactor;
  24845. result *= curr * corrFactor;
  24846. result /= corrFactor * corrFactor;
  24847. return result;
  24848. }
  24849. this._value = [this._value, value].reduce(cback, 1);
  24850. return this;
  24851. },
  24852. divide: function(value) {
  24853. function cback(accum, curr) {
  24854. var corrFactor = correctionFactor(accum, curr);
  24855. return (accum * corrFactor) / (curr * corrFactor);
  24856. }
  24857. this._value = [this._value, value].reduce(cback);
  24858. return this;
  24859. },
  24860. difference: function(value) {
  24861. return Math.abs(numbro(this._value).subtract(value).value());
  24862. }
  24863. };
  24864. /************************************
  24865. Exposing Numbro
  24866. ************************************/
  24867. if (inNodejsRuntime()) {
  24868. //Todo: Rename the folder in 2.0.0
  24869. numbro.loadCulturesInNode();
  24870. }
  24871. // CommonJS module is defined
  24872. if (hasModule) {
  24873. module.exports = numbro;
  24874. } else {
  24875. /*global ender:false */
  24876. if (typeof ender === 'undefined') {
  24877. // here, `this` means `window` in the browser, or `global` on the server
  24878. // add `numbro` as a global object via a string identifier,
  24879. // for Closure Compiler 'advanced' mode
  24880. this.numbro = numbro;
  24881. }
  24882. /*global define:false */
  24883. if (true) {
  24884. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  24885. return numbro;
  24886. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  24887. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  24888. }
  24889. }
  24890. }.call(typeof window === 'undefined' ? this : window));
  24891. /*** EXPORTS FROM exports-to-window-loader ***/
  24892. window['numbro'] = __webpack_require__(309);
  24893. /***/ }),
  24894. /* 310 */
  24895. /***/ (function(module, exports, __webpack_require__) {
  24896. "use strict";
  24897. exports.__esModule = true;
  24898. exports.getNormalizedDate = getNormalizedDate;
  24899. /* eslint-disable import/prefer-default-export */
  24900. /**
  24901. * Get normalized Date object for the ISO formatted date strings.
  24902. * Natively, the date object parsed from a ISO 8601 string will be offsetted by the timezone difference, which may result in returning a wrong date.
  24903. * See: Github issue #3338.
  24904. *
  24905. * @param {String} dateString String representing the date.
  24906. * @returns {Date} The proper Date object.
  24907. */
  24908. function getNormalizedDate(dateString) {
  24909. var nativeDate = new Date(dateString);
  24910. // NaN if dateString is not in ISO format
  24911. if (!isNaN(new Date(dateString + "T00:00").getDate())) {
  24912. // Compensate timezone offset
  24913. return new Date(nativeDate.getTime() + nativeDate.getTimezoneOffset() * 60000);
  24914. }
  24915. return nativeDate;
  24916. }
  24917. /***/ }),
  24918. /* 311 */
  24919. /***/ (function(module, exports, __webpack_require__) {
  24920. "use strict";
  24921. /**
  24922. * SheetClip - Spreadsheet Clipboard Parser
  24923. * version 0.2
  24924. *
  24925. * This tiny library transforms JavaScript arrays to strings that are pasteable by LibreOffice, OpenOffice,
  24926. * Google Docs and Microsoft Excel.
  24927. *
  24928. * Copyright 2012, Marcin Warpechowski
  24929. * Licensed under the MIT license.
  24930. * http://github.com/warpech/sheetclip/
  24931. */
  24932. /*jslint white: true*/
  24933. (function (global) {
  24934. "use strict";
  24935. function countQuotes(str) {
  24936. return str.split('"').length - 1;
  24937. }
  24938. var SheetClip = {
  24939. /**
  24940. * Decode spreadsheet string into array
  24941. *
  24942. * @param {String} str
  24943. * @returns {Array}
  24944. */
  24945. parse: function parse(str) {
  24946. var r,
  24947. rLen,
  24948. rows,
  24949. arr = [],
  24950. a = 0,
  24951. c,
  24952. cLen,
  24953. multiline,
  24954. last;
  24955. rows = str.split('\n');
  24956. if (rows.length > 1 && rows[rows.length - 1] === '') {
  24957. rows.pop();
  24958. }
  24959. for (r = 0, rLen = rows.length; r < rLen; r += 1) {
  24960. rows[r] = rows[r].split('\t');
  24961. for (c = 0, cLen = rows[r].length; c < cLen; c += 1) {
  24962. if (!arr[a]) {
  24963. arr[a] = [];
  24964. }
  24965. if (multiline && c === 0) {
  24966. last = arr[a].length - 1;
  24967. arr[a][last] = arr[a][last] + '\n' + rows[r][0];
  24968. if (multiline && countQuotes(rows[r][0]) & 1) {
  24969. //& 1 is a bitwise way of performing mod 2
  24970. multiline = false;
  24971. arr[a][last] = arr[a][last].substring(0, arr[a][last].length - 1).replace(/""/g, '"');
  24972. }
  24973. } else {
  24974. if (c === cLen - 1 && rows[r][c].indexOf('"') === 0 && countQuotes(rows[r][c]) & 1) {
  24975. arr[a].push(rows[r][c].substring(1).replace(/""/g, '"'));
  24976. multiline = true;
  24977. } else {
  24978. arr[a].push(rows[r][c].replace(/""/g, '"'));
  24979. multiline = false;
  24980. }
  24981. }
  24982. }
  24983. if (!multiline) {
  24984. a += 1;
  24985. }
  24986. }
  24987. return arr;
  24988. },
  24989. /**
  24990. * Encode array into valid spreadsheet string
  24991. *
  24992. * @param arr
  24993. * @returns {String}
  24994. */
  24995. stringify: function stringify(arr) {
  24996. var r,
  24997. rLen,
  24998. c,
  24999. cLen,
  25000. str = '',
  25001. val;
  25002. for (r = 0, rLen = arr.length; r < rLen; r += 1) {
  25003. cLen = arr[r].length;
  25004. for (c = 0; c < cLen; c += 1) {
  25005. if (c > 0) {
  25006. str += '\t';
  25007. }
  25008. val = arr[r][c];
  25009. if (typeof val === 'string') {
  25010. if (val.indexOf('\n') > -1) {
  25011. str += '"' + val.replace(/"/g, '""') + '"';
  25012. } else {
  25013. str += val;
  25014. }
  25015. } else if (val === null || val === void 0) {
  25016. // void 0 resolves to undefined
  25017. str += '';
  25018. } else {
  25019. str += val;
  25020. }
  25021. }
  25022. if (r !== rLen - 1) {
  25023. str += '\n';
  25024. }
  25025. }
  25026. return str;
  25027. }
  25028. };
  25029. if (true) {
  25030. exports.parse = SheetClip.parse;
  25031. exports.stringify = SheetClip.stringify;
  25032. } else {
  25033. global.SheetClip = SheetClip;
  25034. }
  25035. })(window);
  25036. /***/ }),
  25037. /* 312 */
  25038. /***/ (function(module, exports, __webpack_require__) {
  25039. "use strict";
  25040. exports.__esModule = true;
  25041. exports.mouseDown = mouseDown;
  25042. exports.mouseOver = mouseOver;
  25043. exports.handleMouseEvent = handleMouseEvent;
  25044. var _event = __webpack_require__(12);
  25045. var _src = __webpack_require__(4);
  25046. /**
  25047. * MouseDown handler.
  25048. *
  25049. * @param {Object} options
  25050. * @param {Boolean} options.isShiftKey The flag which indicates if the shift key is pressed.
  25051. * @param {Boolean} options.isLeftClick The flag which indicates if the left mouse button is pressed.
  25052. * @param {Boolean} options.isRightClick The flag which indicates if the right mouse button is pressed.
  25053. * @param {CellRange} options.coords The CellCoords object with defined visual coordinates.
  25054. * @param {Selection} options.selection The Selection class instance.
  25055. * @param {Object} options.controller An object with keys `row`, `column`, `cell` which indicate what
  25056. * operation will be performed in later selection stages.
  25057. */
  25058. function mouseDown(_ref) {
  25059. var isShiftKey = _ref.isShiftKey,
  25060. isLeftClick = _ref.isLeftClick,
  25061. isRightClick = _ref.isRightClick,
  25062. coords = _ref.coords,
  25063. selection = _ref.selection,
  25064. controller = _ref.controller;
  25065. var currentSelection = selection.isSelected() ? selection.getSelectedRange().current() : null;
  25066. var selectedCorner = selection.isSelectedByCorner();
  25067. var selectedRow = selection.isSelectedByRowHeader();
  25068. var selectedColumn = selection.isSelectedByColumnHeader();
  25069. if (isShiftKey && currentSelection) {
  25070. if (coords.row >= 0 && coords.col >= 0 && !controller.cells) {
  25071. selection.setRangeEnd(coords);
  25072. } else if ((selectedCorner || selectedRow) && coords.row >= 0 && coords.col >= 0 && !controller.cells) {
  25073. selection.setRangeEnd(new _src.CellCoords(coords.row, coords.col));
  25074. } else if (selectedCorner && coords.row < 0 && !controller.column) {
  25075. selection.setRangeEnd(new _src.CellCoords(currentSelection.to.row, coords.col));
  25076. } else if (selectedRow && coords.col < 0 && !controller.row) {
  25077. selection.setRangeEnd(new _src.CellCoords(coords.row, currentSelection.to.col));
  25078. } else if ((!selectedCorner && !selectedRow && coords.col < 0 || selectedCorner && coords.col < 0) && !controller.row) {
  25079. selection.selectRows(currentSelection.from.row, coords.row);
  25080. } else if ((!selectedCorner && !selectedRow && coords.row < 0 || selectedRow && coords.row < 0) && !controller.column) {
  25081. selection.selectColumns(currentSelection.from.col, coords.col);
  25082. }
  25083. } else {
  25084. var newCoord = new _src.CellCoords(coords.row, coords.col);
  25085. if (newCoord.row < 0) {
  25086. newCoord.row = 0;
  25087. }
  25088. if (newCoord.col < 0) {
  25089. newCoord.col = 0;
  25090. }
  25091. var allowRightClickSelection = !selection.inInSelection(newCoord);
  25092. var performSelection = isLeftClick || isRightClick && allowRightClickSelection;
  25093. // clicked row header and when some column was selected
  25094. if (coords.row < 0 && coords.col >= 0 && !controller.column) {
  25095. if (performSelection) {
  25096. selection.selectColumns(coords.col);
  25097. }
  25098. // clicked column header and when some row was selected
  25099. } else if (coords.col < 0 && coords.row >= 0 && !controller.row) {
  25100. if (performSelection) {
  25101. selection.selectRows(coords.row);
  25102. }
  25103. } else if (coords.col >= 0 && coords.row >= 0 && !controller.cells) {
  25104. if (performSelection) {
  25105. selection.setRangeStart(coords);
  25106. }
  25107. } else if (coords.col < 0 && coords.row < 0) {
  25108. selection.setRangeStart(coords);
  25109. }
  25110. }
  25111. }
  25112. /**
  25113. * MouseOver handler.
  25114. *
  25115. * @param {Object} options
  25116. * @param {Boolean} options.isLeftClick
  25117. * @param {CellRange} options.coords The CellCoords object with defined visual coordinates.
  25118. * @param {Selection} options.selection The Selection class instance.
  25119. * @param {Object} options.controller An object with keys `row`, `column`, `cell` which indicate what
  25120. * operation will be performed in later selection stages.
  25121. */
  25122. function mouseOver(_ref2) {
  25123. var isLeftClick = _ref2.isLeftClick,
  25124. coords = _ref2.coords,
  25125. selection = _ref2.selection,
  25126. controller = _ref2.controller;
  25127. if (!isLeftClick) {
  25128. return;
  25129. }
  25130. var selectedRow = selection.isSelectedByRowHeader();
  25131. var selectedColumn = selection.isSelectedByColumnHeader();
  25132. var countCols = selection.tableProps.countCols();
  25133. var countRows = selection.tableProps.countRows();
  25134. if (selectedColumn && !controller.column) {
  25135. selection.setRangeEnd(new _src.CellCoords(countRows - 1, coords.col));
  25136. } else if (selectedRow && !controller.row) {
  25137. selection.setRangeEnd(new _src.CellCoords(coords.row, countCols - 1));
  25138. } else if (!controller.cell) {
  25139. selection.setRangeEnd(coords);
  25140. }
  25141. }
  25142. var handlers = new Map([['mousedown', mouseDown], ['mouseover', mouseOver], ['touchstart', mouseDown]]);
  25143. /**
  25144. * Mouse handler for selection functionality.
  25145. *
  25146. * @param {Event} event An native event to handle.
  25147. * @param {Object} options
  25148. * @param {CellRange} options.coords The CellCoords object with defined visual coordinates.
  25149. * @param {Selection} options.selection The Selection class instance.
  25150. * @param {Object} options.controller An object with keys `row`, `column`, `cell` which indicate what
  25151. * operation will be performed in later selection stages.
  25152. */
  25153. function handleMouseEvent(event, _ref3) {
  25154. var coords = _ref3.coords,
  25155. selection = _ref3.selection,
  25156. controller = _ref3.controller;
  25157. handlers.get(event.type)({
  25158. coords: coords,
  25159. selection: selection,
  25160. controller: controller,
  25161. isShiftKey: event.shiftKey,
  25162. isLeftClick: (0, _event.isLeftClick)(event) || event.type === 'touchstart',
  25163. isRightClick: (0, _event.isRightClick)(event)
  25164. });
  25165. }
  25166. /***/ }),
  25167. /* 313 */
  25168. /***/ (function(module, exports, __webpack_require__) {
  25169. "use strict";
  25170. exports.__esModule = true;
  25171. exports.RecordTranslator = undefined;
  25172. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  25173. exports.registerIdentity = registerIdentity;
  25174. exports.getTranslator = getTranslator;
  25175. var _core = __webpack_require__(88);
  25176. var _core2 = _interopRequireDefault(_core);
  25177. var _object = __webpack_require__(2);
  25178. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  25179. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  25180. /**
  25181. * @class RecordTranslator
  25182. * @util
  25183. */
  25184. var RecordTranslator = function () {
  25185. function RecordTranslator(hot) {
  25186. _classCallCheck(this, RecordTranslator);
  25187. this.hot = hot;
  25188. }
  25189. /**
  25190. * Translate physical row index into visual.
  25191. *
  25192. * @param {Number} row Physical row index.
  25193. * @returns {Number} Returns visual row index.
  25194. */
  25195. _createClass(RecordTranslator, [{
  25196. key: 'toVisualRow',
  25197. value: function toVisualRow(row) {
  25198. return this.hot.runHooks('unmodifyRow', row);
  25199. }
  25200. /**
  25201. * Translate physical column index into visual.
  25202. *
  25203. * @param {Number} column Physical column index.
  25204. * @returns {Number} Returns visual column index.
  25205. */
  25206. }, {
  25207. key: 'toVisualColumn',
  25208. value: function toVisualColumn(column) {
  25209. return this.hot.runHooks('unmodifyCol', column);
  25210. }
  25211. /**
  25212. * Translate physical coordinates into visual. Can be passed as separate 2 arguments (row, column) or as an object in first
  25213. * argument with `row` and `column` keys.
  25214. *
  25215. * @param {Number|Object} row Physical coordinates or row index.
  25216. * @param {Number} [column] Physical column index.
  25217. * @returns {Object|Array} Returns an object with visual records or an array if coordinates passed as separate arguments.
  25218. */
  25219. }, {
  25220. key: 'toVisual',
  25221. value: function toVisual(row, column) {
  25222. var result = void 0;
  25223. if ((0, _object.isObject)(row)) {
  25224. result = {
  25225. row: this.toVisualRow(row.row),
  25226. column: this.toVisualColumn(row.column)
  25227. };
  25228. } else {
  25229. result = [this.toVisualRow(row), this.toVisualColumn(column)];
  25230. }
  25231. return result;
  25232. }
  25233. /**
  25234. * Translate visual row index into physical.
  25235. *
  25236. * @param {Number} row Visual row index.
  25237. * @returns {Number} Returns physical row index.
  25238. */
  25239. }, {
  25240. key: 'toPhysicalRow',
  25241. value: function toPhysicalRow(row) {
  25242. return this.hot.runHooks('modifyRow', row);
  25243. }
  25244. /**
  25245. * Translate visual column index into physical.
  25246. *
  25247. * @param {Number} column Visual column index.
  25248. * @returns {Number} Returns physical column index.
  25249. */
  25250. }, {
  25251. key: 'toPhysicalColumn',
  25252. value: function toPhysicalColumn(column) {
  25253. return this.hot.runHooks('modifyCol', column);
  25254. }
  25255. /**
  25256. * Translate visual coordinates into physical. Can be passed as separate 2 arguments (row, column) or as an object in first
  25257. * argument with `row` and `column` keys.
  25258. *
  25259. * @param {Number|Object} row Visual coordinates or row index.
  25260. * @param {Number} [column] Visual column index.
  25261. * @returns {Object|Array} Returns an object with physical records or an array if coordinates passed as separate arguments.
  25262. */
  25263. }, {
  25264. key: 'toPhysical',
  25265. value: function toPhysical(row, column) {
  25266. var result = void 0;
  25267. if ((0, _object.isObject)(row)) {
  25268. result = {
  25269. row: this.toPhysicalRow(row.row),
  25270. column: this.toPhysicalColumn(row.column)
  25271. };
  25272. } else {
  25273. result = [this.toPhysicalRow(row), this.toPhysicalColumn(column)];
  25274. }
  25275. return result;
  25276. }
  25277. }]);
  25278. return RecordTranslator;
  25279. }();
  25280. exports.RecordTranslator = RecordTranslator;
  25281. var identities = new WeakMap();
  25282. var translatorSingletons = new WeakMap();
  25283. function registerIdentity(identity, hot) {
  25284. identities.set(identity, hot);
  25285. }
  25286. function getTranslator(identity) {
  25287. var singleton = void 0;
  25288. if (!(identity instanceof _core2.default)) {
  25289. if (!identities.has(identity)) {
  25290. throw Error('Record translator was not registered for this object identity');
  25291. }
  25292. identity = identities.get(identity);
  25293. }
  25294. if (translatorSingletons.has(identity)) {
  25295. singleton = translatorSingletons.get(identity);
  25296. } else {
  25297. singleton = new RecordTranslator(identity);
  25298. translatorSingletons.set(identity, singleton);
  25299. }
  25300. return singleton;
  25301. }
  25302. /***/ }),
  25303. /* 314 */
  25304. /***/ (function(module, exports, __webpack_require__) {
  25305. "use strict";
  25306. exports.__esModule = true;
  25307. exports.registerAsRootInstance = registerAsRootInstance;
  25308. exports.hasValidParameter = hasValidParameter;
  25309. exports.isRootInstance = isRootInstance;
  25310. var holder = exports.holder = new WeakMap();
  25311. var rootInstanceSymbol = exports.rootInstanceSymbol = Symbol('rootInstance');
  25312. /**
  25313. * Register an object as a root instance.
  25314. *
  25315. * @param {Object} object An object to associate with root instance flag.
  25316. */
  25317. function registerAsRootInstance(object) {
  25318. holder.set(object, true);
  25319. }
  25320. /**
  25321. * Check if the source of the root indication call is valid.
  25322. *
  25323. * @param {Symbol} rootSymbol A symbol as a source of truth.
  25324. * @return {Boolean}
  25325. */
  25326. function hasValidParameter(rootSymbol) {
  25327. return rootSymbol === rootInstanceSymbol;
  25328. }
  25329. /**
  25330. * Check if passed an object was flagged as a root instance.
  25331. *
  25332. * @param {Object} object An object to check.
  25333. * @return {Boolean}
  25334. */
  25335. function isRootInstance(object) {
  25336. return holder.has(object);
  25337. }
  25338. /***/ }),
  25339. /* 315 */
  25340. /***/ (function(module, exports, __webpack_require__) {
  25341. "use strict";
  25342. exports.__esModule = true;
  25343. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  25344. var _mixed = __webpack_require__(16);
  25345. var _object = __webpack_require__(2);
  25346. /**
  25347. * @alias Options
  25348. * @constructor
  25349. * @description
  25350. * ## Constructor options
  25351. *
  25352. * Constructor options are applied using an object literal passed as a second argument to the Handsontable constructor.
  25353. *
  25354. * ```js
  25355. * var hot = new Handsontable(document.getElementById('example1'), {
  25356. * data: myArray,
  25357. * width: 400,
  25358. * height: 300
  25359. * });
  25360. * ```
  25361. *
  25362. * ---
  25363. * ## Cascading configuration
  25364. *
  25365. * Handsontable 0.9 and newer is using *Cascading Configuration*, which is a fast way to provide configuration options
  25366. * for the entire table, including its columns and particular cells.
  25367. *
  25368. * Consider the following example:
  25369. * ```js
  25370. * var hot = new Handsontable(document.getElementById('example'), {
  25371. * readOnly: true,
  25372. * columns: [
  25373. * {readOnly: false},
  25374. * {},
  25375. * {}
  25376. * ],
  25377. * cells: function (row, col, prop) {
  25378. * var cellProperties = {};
  25379. *
  25380. * if (row === 0 && col === 0) {
  25381. * cellProperties.readOnly = true;
  25382. * }
  25383. *
  25384. * return cellProperties;
  25385. * }
  25386. * });
  25387. * ```
  25388. *
  25389. * The above notation will result in all TDs being *read only*, except for first column TDs which will be *editable*, except for the TD in top left corner which will still be *read only*.
  25390. *
  25391. * ### The Cascading Configuration model
  25392. *
  25393. * ##### 1. Constructor
  25394. *
  25395. * Configuration options that are provided using first-level `handsontable(container, {option: "value"})` and `updateSettings` method.
  25396. *
  25397. * ##### 2. Columns
  25398. *
  25399. * Configuration options that are provided using second-level object `handsontable(container, {columns: {option: "value"}]})`
  25400. *
  25401. * ##### 3. Cells
  25402. *
  25403. * Configuration options that are provided using third-level function `handsontable(container, {cells: function: (row, col, prop){ }})`
  25404. *
  25405. * ---
  25406. * ## Architecture performance
  25407. *
  25408. * The Cascading Configuration model is based on prototypical inheritance. It is much faster and memory efficient compared
  25409. * to the previous model that used jQuery extend. See: [http://jsperf.com/extending-settings](http://jsperf.com/extending-settings).
  25410. *
  25411. * ---
  25412. * __Important notice:__ In order for the data separation to work properly, make sure that each instance of Handsontable has a unique `id`.
  25413. */
  25414. function DefaultSettings() {};
  25415. DefaultSettings.prototype = {
  25416. /**
  25417. * License key for commercial version of Handsontable.
  25418. *
  25419. * @pro
  25420. * @type {String}
  25421. * @default 'trial'
  25422. */
  25423. licenseKey: 'trial',
  25424. /**
  25425. * @description
  25426. * Initial data source that will be bound to the data grid __by reference__ (editing data grid alters the data source).
  25427. * Can be declared as an Array of Arrays, Array of Objects or a Function.
  25428. *
  25429. * See [Understanding binding as reference](http://docs.handsontable.com/tutorial-data-binding.html#page-reference).
  25430. *
  25431. * @type {Array|Function}
  25432. * @default undefined
  25433. */
  25434. data: void 0,
  25435. /**
  25436. * @description
  25437. * Defines the structure of a new row when data source is an array of objects.
  25438. *
  25439. * See [data-schema](http://docs.handsontable.com/tutorial-data-sources.html#page-data-schema) for examples.
  25440. *
  25441. * @type {Object}
  25442. * @default undefined
  25443. */
  25444. dataSchema: void 0,
  25445. /**
  25446. * Width of the grid. Can be a value or a function that returns a value.
  25447. *
  25448. * @type {Number|Function}
  25449. * @default undefined
  25450. */
  25451. width: void 0,
  25452. /**
  25453. * Height of the grid. Can be a number or a function that returns a number.
  25454. *
  25455. * @type {Number|Function}
  25456. * @default undefined
  25457. */
  25458. height: void 0,
  25459. /**
  25460. * @description
  25461. * Initial number of rows.
  25462. *
  25463. * __Notice:__ This option only has effect in Handsontable constructor and only if `data` option is not provided
  25464. *
  25465. * @type {Number}
  25466. * @default 5
  25467. */
  25468. startRows: 5,
  25469. /**
  25470. * @description
  25471. * Initial number of columns.
  25472. *
  25473. * __Notice:__ This option only has effect in Handsontable constructor and only if `data` option is not provided
  25474. *
  25475. * @type {Number}
  25476. * @default 5
  25477. */
  25478. startCols: 5,
  25479. /**
  25480. * Setting `true` or `false` will enable or disable the default row headers (1, 2, 3).
  25481. * You can also define an array `['One', 'Two', 'Three', ...]` or a function to define the headers.
  25482. * If a function is set the index of the row is passed as a parameter.
  25483. *
  25484. * @type {Boolean|Array|Function}
  25485. * @default null
  25486. * @example
  25487. * ```js
  25488. * ...
  25489. * // as boolean
  25490. * rowHeaders: true,
  25491. * ...
  25492. *
  25493. * ...
  25494. * // as array
  25495. * rowHeaders: [1, 2, 3],
  25496. * ...
  25497. *
  25498. * ...
  25499. * // as function
  25500. * rowHeaders: function(index) {
  25501. * return index + ': AB';
  25502. * },
  25503. * ...
  25504. * ```
  25505. */
  25506. rowHeaders: void 0,
  25507. /**
  25508. * Setting `true` or `false` will enable or disable the default column headers (A, B, C).
  25509. * You can also define an array `['One', 'Two', 'Three', ...]` or a function to define the headers.
  25510. * If a function is set, then the index of the column is passed as a parameter.
  25511. *
  25512. * @type {Boolean|Array|Function}
  25513. * @default null
  25514. * @example
  25515. * ```js
  25516. * ...
  25517. * // as boolean
  25518. * colHeaders: true,
  25519. * ...
  25520. *
  25521. * ...
  25522. * // as array
  25523. * colHeaders: ['A', 'B', 'C'],
  25524. * ...
  25525. *
  25526. * ...
  25527. * // as function
  25528. * colHeaders: function(index) {
  25529. * return index + ': AB';
  25530. * },
  25531. * ...
  25532. * ```
  25533. */
  25534. colHeaders: null,
  25535. /**
  25536. * Defines column widths in pixels. Accepts number, string (that will be converted to a number),
  25537. * array of numbers (if you want to define column width separately for each column) or a
  25538. * function (if you want to set column width dynamically on each render).
  25539. *
  25540. * @type {Array|Function|Number|String}
  25541. * @default undefined
  25542. * @example
  25543. * ```js
  25544. * ...
  25545. * // as numeric, for each column.
  25546. * colWidths: 100,
  25547. * ...
  25548. *
  25549. * * ...
  25550. * // as string, for each column.
  25551. * colWidths: '100px',
  25552. * ...
  25553. *
  25554. * ...
  25555. * // as array, based on visual indexes. The rest of the columns have a default width.
  25556. * colWidths: [100, 120, 90],
  25557. * ...
  25558. *
  25559. * ...
  25560. * // as function, based on visual indexes.
  25561. * colWidths: function(index) {
  25562. * return index * 10;
  25563. * },
  25564. * ...
  25565. * ```
  25566. */
  25567. colWidths: void 0,
  25568. /**
  25569. * Defines row heights in pixels. Accepts numbers, strings (that will be converted into a number),
  25570. * array of numbers (if you want to define row height separately for each row) or a
  25571. * function (if you want to set row height dynamically on each render).
  25572. * If the ManualRowResize or AutoRowSize plugins are enabled, this is also the minimum height that can be set
  25573. * via either of those two plugins.
  25574. * Height should be equal or greater than 23px. Table is rendered incorrectly if height is less than 23px.
  25575. *
  25576. * @type {Array|Function|Number|String}
  25577. * @default undefined
  25578. * @example
  25579. * ```js
  25580. * ...
  25581. * // as numeric, for each row.
  25582. * rowHeights: 100,
  25583. * ...
  25584. *
  25585. * * ...
  25586. * // as string, for each row.
  25587. * rowHeights: '100px',
  25588. * ...
  25589. *
  25590. * ...
  25591. * // as array, based on visual indexes. The rest of the rows have a default height.
  25592. * rowHeights: [100, 120, 90],
  25593. * ...
  25594. *
  25595. * ...
  25596. * // as function, based on visual indexes.
  25597. * rowHeights: function(index) {
  25598. * return index * 10;
  25599. * },
  25600. * ...
  25601. * ```
  25602. */
  25603. rowHeights: void 0,
  25604. /**
  25605. * @description
  25606. * Defines the cell properties and data binding for certain columns.
  25607. *
  25608. * __Notice:__ Using this option sets a fixed number of columns (options `startCols`, `minCols`, `maxCols` will be ignored).
  25609. *
  25610. * See [documentation -> datasources.html](http://docs.handsontable.com/tutorial-data-sources.html#page-nested) for examples.
  25611. *
  25612. * @type {Array|Function}
  25613. * @default undefined
  25614. * @example
  25615. * ```js
  25616. * ...
  25617. * // as an array of objects. Order of the objects in array is representation of physical indexes.
  25618. * columns: [
  25619. * {
  25620. * // column options for the first column
  25621. * type: 'numeric',
  25622. * numericFormat: {
  25623. * pattern: '0,0.00 $'
  25624. * }
  25625. * },
  25626. * {
  25627. * // column options for the second column
  25628. * type: 'text',
  25629. * readOnly: true
  25630. * }
  25631. * ],
  25632. * ...
  25633. *
  25634. * // or as function, based on physical indexes
  25635. * ...
  25636. * columns: function(index) {
  25637. * return {
  25638. * type: index > 0 ? 'numeric' : 'text',
  25639. * readOnly: index < 1
  25640. * }
  25641. * }
  25642. * ...
  25643. * ```
  25644. */
  25645. columns: void 0,
  25646. /**
  25647. * @description
  25648. * Defines the cell properties for given `row`, `col`, `prop` coordinates.
  25649. * Any constructor or column option may be overwritten for a particular cell (row/column combination)
  25650. * using the `cells` property in the Handsontable constructor.
  25651. *
  25652. * __Note:__ Parameters `row` and `col` always represent __physical indexes__. Example below show how to execute
  25653. * operations based on the __visual__ representation of Handsontable.
  25654. *
  25655. * Possible values of `prop`:
  25656. * - property name for column's data source object, when dataset is an [array of objects](/tutorial-data-sources.html#page-object)
  25657. * - the same number as `col`, when dataset is an [array of arrays](/tutorial-data-sources.html#page-array)
  25658. *
  25659. * @type {Function}
  25660. * @default undefined
  25661. * @example
  25662. * ```js
  25663. * ...
  25664. * cells: function (row, col, prop) {
  25665. * var cellProperties = {};
  25666. * var visualRowIndex = this.instance.toVisualRow(row);
  25667. * var visualColIndex = this.instance.toVisualColumn(col);
  25668. *
  25669. * if (visualRowIndex === 0 && visualColIndex === 0) {
  25670. * cellProperties.readOnly = true;
  25671. * }
  25672. *
  25673. * return cellProperties;
  25674. * },
  25675. * ...
  25676. * ```
  25677. */
  25678. cells: void 0,
  25679. /**
  25680. * Any constructor or column option may be overwritten for a particular cell (row/column combination), using `cell`
  25681. * array passed to the Handsontable constructor.
  25682. *
  25683. * @type {Array}
  25684. * @default []
  25685. * @example
  25686. * ```js
  25687. * ...
  25688. * cell: [
  25689. * {row: 0, col: 0, readOnly: true}
  25690. * ],
  25691. * ...
  25692. * ```
  25693. */
  25694. cell: [],
  25695. /**
  25696. * @description
  25697. * If `true`, enables the {@link Comments} plugin, which enables an option to apply cell comments through the context menu
  25698. * (configurable with context menu keys `commentsAddEdit`, `commentsRemove`).
  25699. *
  25700. * To initialize Handsontable with predefined comments, provide cell coordinates and comment text values in a form of an array.
  25701. *
  25702. * See [Comments](http://docs.handsontable.com/demo-comments_.html) demo for examples.
  25703. *
  25704. * @since 0.11.0
  25705. * @type {Boolean|Array}
  25706. * @default false
  25707. * @example
  25708. * ```js
  25709. * ...
  25710. * comments: [{row: 1, col: 1, comment: {value: "Test comment"}}],
  25711. * ...
  25712. * ```
  25713. */
  25714. comments: false,
  25715. /**
  25716. * @description
  25717. * If `true`, enables the Custom Borders plugin, which enables an option to apply custom borders through the context menu (configurable with context menu key `borders`).
  25718. *
  25719. * To initialize Handsontable with predefined custom borders, provide cell coordinates and border styles in a form of an array.
  25720. *
  25721. * See [Custom Borders](http://docs.handsontable.com/demo-custom-borders.html) demo for examples.
  25722. *
  25723. * @since 0.11.0
  25724. * @type {Boolean|Array}
  25725. * @default false
  25726. * @example
  25727. * ```js
  25728. * ...
  25729. * customBorders: [
  25730. * {range: {
  25731. * from: {row: 1, col: 1},
  25732. * to: {row: 3, col: 4}},
  25733. * left: {},
  25734. * right: {},
  25735. * top: {},
  25736. * bottom: {}
  25737. * }
  25738. * ],
  25739. * ...
  25740. *
  25741. * // or
  25742. * ...
  25743. * customBorders: [
  25744. * {row: 2, col: 2, left: {width: 2, color: 'red'},
  25745. * right: {width: 1, color: 'green'}, top: '', bottom: ''}
  25746. * ],
  25747. * ...
  25748. * ```
  25749. */
  25750. customBorders: false,
  25751. /**
  25752. * Minimum number of rows. At least that number of rows will be created during initialization.
  25753. *
  25754. * @type {Number}
  25755. * @default 0
  25756. */
  25757. minRows: 0,
  25758. /**
  25759. * Minimum number of columns. At least that number of columns will be created during initialization.
  25760. *
  25761. * @type {Number}
  25762. * @default 0
  25763. */
  25764. minCols: 0,
  25765. /**
  25766. * Maximum number of rows. If set to a value lower than the initial row count, the data will be trimmed to the provided value as the number of rows.
  25767. *
  25768. * @type {Number}
  25769. * @default Infinity
  25770. */
  25771. maxRows: Infinity,
  25772. /**
  25773. * Maximum number of cols. If set to a value lower than the initial col count, the data will be trimmed to the provided value as the number of cols.
  25774. *
  25775. * @type {Number}
  25776. * @default Infinity
  25777. */
  25778. maxCols: Infinity,
  25779. /**
  25780. * When set to 1 (or more), Handsontable will add a new row at the end of grid if there are no more empty rows.
  25781. * (unless the number of rows exceeds the one set in the `maxRows` property)
  25782. *
  25783. * @type {Number}
  25784. * @default 0
  25785. */
  25786. minSpareRows: 0,
  25787. /**
  25788. * When set to 1 (or more), Handsontable will add a new column at the end of grid if there are no more empty columns.
  25789. * (unless the number of rows exceeds the one set in the `maxCols` property)
  25790. *
  25791. * @type {Number}
  25792. * @default 0
  25793. */
  25794. minSpareCols: 0,
  25795. /**
  25796. * If set to `false`, there won't be an option to insert new rows in the Context Menu.
  25797. *
  25798. * @type {Boolean}
  25799. * @default true
  25800. */
  25801. allowInsertRow: true,
  25802. /**
  25803. * If set to `false`, there won't be an option to insert new columns in the Context Menu.
  25804. *
  25805. * @type {Boolean}
  25806. * @default true
  25807. */
  25808. allowInsertColumn: true,
  25809. /**
  25810. * If set to `false`, there won't be an option to remove rows in the Context Menu.
  25811. *
  25812. * @type {Boolean}
  25813. * @default true
  25814. */
  25815. allowRemoveRow: true,
  25816. /**
  25817. * If set to `false`, there won't be an option to remove columns in the Context Menu.
  25818. *
  25819. * @type {Boolean}
  25820. * @default true
  25821. */
  25822. allowRemoveColumn: true,
  25823. /**
  25824. * @description
  25825. * Defines how the table selection reacts. The selection support three different behaviors defined as:
  25826. * * `'single'` Only a single cell can be selected.
  25827. * * `'range'` Multiple cells within a single range can be selected.
  25828. * * `'multiple'` Multiple ranges of cells can be selected.
  25829. *
  25830. * To see how to interact with selection by getting selected data or change styles of the selected cells go to
  25831. * [https://docs.handsontable.com/demo-selecting-ranges.html](https://docs.handsontable.com/demo-selecting-ranges.html).
  25832. *
  25833. * @since 0.36.0
  25834. * @type {String}
  25835. * @default 'multiple'
  25836. */
  25837. selectionMode: 'multiple',
  25838. /**
  25839. * Enables the fill handle (drag-down and copy-down) functionality, which shows a small rectangle in bottom
  25840. * right corner of the selected area, that let's you expand values to the adjacent cells.
  25841. *
  25842. * Possible values: `true` (to enable in all directions), `'vertical'` or `'horizontal'` (to enable in one direction),
  25843. * `false` (to disable completely). Setting to `true` enables the fillHandle plugin.
  25844. *
  25845. * Since 0.23.0 you can pass object to plugin which allows you to add more options for this functionality. If `autoInsertRow`
  25846. * option is `true`, fill-handler will create new rows till it reaches the last row. It is enabled by default.
  25847. *
  25848. * @example
  25849. * ```js
  25850. * ...
  25851. * fillHandle: true // enable plugin in all directions and with autoInsertRow as true
  25852. * ...
  25853. * // or
  25854. * ...
  25855. * fillHandle: 'vertical' // enable plugin in vertical direction and with autoInsertRow as true
  25856. * ...
  25857. * // or
  25858. * ...
  25859. * fillHandle: { // enable plugin in both directions and with autoInsertRow as false
  25860. * autoInsertRow: false,
  25861. * }
  25862. * // or
  25863. * ...
  25864. * fillHandle: { // enable plugin in vertical direction and with autoInsertRow as false
  25865. * autoInsertRow: false,
  25866. * direction: 'vertical' // 'vertical' or 'horizontal'
  25867. * }
  25868. * ```
  25869. *
  25870. * @type {Boolean|String|Object}
  25871. * @default true
  25872. */
  25873. fillHandle: true,
  25874. /**
  25875. * Allows to specify the number of fixed (or *frozen*) rows at the top of the table.
  25876. *
  25877. * @type {Number}
  25878. * @default 0
  25879. * @example
  25880. * ```js
  25881. * fixedRowsTop: 3 // This would freeze the top 3 rows of the table.
  25882. * ```
  25883. */
  25884. fixedRowsTop: 0,
  25885. /**
  25886. * Allows to specify the number of fixed (or *frozen*) rows at the bottom of the table.
  25887. *
  25888. * @pro
  25889. * @type {Number}
  25890. * @default 0
  25891. * @example
  25892. * ```js
  25893. * fixedRowsBottom: 3 // This would freeze the top 3 rows of the table.
  25894. * ```
  25895. */
  25896. fixedRowsBottom: 0,
  25897. /**
  25898. * Allows to specify the number of fixed (or *frozen*) columns on the left of the table.
  25899. *
  25900. * @type {Number}
  25901. * @default 0
  25902. * @example
  25903. * ```js
  25904. * fixedColumnsLeft: 3 // This would freeze the top 3 rows of the table.
  25905. * ```
  25906. */
  25907. fixedColumnsLeft: 0,
  25908. /**
  25909. * If `true`, mouse click outside the grid will deselect the current selection.
  25910. * Can be a function that takes the click event target and returns a boolean.
  25911. *
  25912. * @type {Boolean|Function}
  25913. * @default true
  25914. */
  25915. outsideClickDeselects: true,
  25916. /**
  25917. * If `true`, <kbd>ENTER</kbd> begins editing mode (like in Google Docs). If `false`, <kbd>ENTER</kbd> moves to next
  25918. * row (like Excel) and adds a new row if necessary. <kbd>TAB</kbd> adds new column if necessary.
  25919. *
  25920. * @type {Boolean}
  25921. * @default true
  25922. */
  25923. enterBeginsEditing: true,
  25924. /**
  25925. * Defines the cursor movement after <kbd>ENTER</kbd> was pressed (<kbd>SHIFT</kbd> + <kbd>ENTER</kbd> uses a negative vector).
  25926. * Can be an object or a function that returns an object. The event argument passed to the function
  25927. * is a DOM Event object received after the <kbd>ENTER</kbd> key has been pressed. This event object can be used to check
  25928. * whether user pressed <kbd>ENTER</kbd> or <kbd>SHIFT</kbd> + <kbd>ENTER</kbd>.
  25929. *
  25930. * @type {Object|Function}
  25931. * @default {row: 1, col: 0}
  25932. */
  25933. enterMoves: { row: 1, col: 0 },
  25934. /**
  25935. * Defines the cursor movement after <kbd>TAB</kbd> is pressed (<kbd>SHIFT</kbd> + <kbd>TAB</kbd> uses a negative vector).
  25936. * Can be an object or a function that returns an object. The event argument passed to the function
  25937. * is a DOM Event object received after the <kbd>TAB</kbd> key has been pressed. This event object can be used to check
  25938. * whether user pressed <kbd>TAB</kbd> or <kbd>SHIFT</kbd> + <kbd>TAB</kbd>.
  25939. *
  25940. * @type {Object}
  25941. * @default {row: 0, col: 1}
  25942. */
  25943. tabMoves: { row: 0, col: 1 },
  25944. /**
  25945. * If `true`, pressing <kbd>TAB</kbd> or right arrow in the last column will move to first column in next row.
  25946. *
  25947. * @type {Boolean}
  25948. * @default false
  25949. */
  25950. autoWrapRow: false,
  25951. /**
  25952. * If `true`, pressing <kbd>ENTER</kbd> or down arrow in the last row will move to the first row in the next column.
  25953. *
  25954. * @type {Boolean}
  25955. * @default false
  25956. */
  25957. autoWrapCol: false,
  25958. /**
  25959. * @description
  25960. * Turns on saving the state of column sorting, column positions and column sizes in local storage.
  25961. *
  25962. * You can save any sort of data in local storage to preserve table state between page reloads.
  25963. * In order to enable data storage mechanism, `persistentState` option must be set to `true` (you can set it
  25964. * either during Handsontable initialization or using the `updateSettings` method). When `persistentState` is enabled it exposes 3 hooks:
  25965. *
  25966. * __persistentStateSave__ (key: String, value: Mixed)
  25967. *
  25968. * * Saves value under given key in browser local storage.
  25969. *
  25970. * __persistentStateLoad__ (key: String, valuePlaceholder: Object)
  25971. *
  25972. * * Loads `value`, saved under given key, form browser local storage. The loaded `value` will be saved in `valuePlaceholder.value`
  25973. * (this is due to specific behaviour of `Hooks.run()` method). If no value have been saved under key `valuePlaceholder.value`
  25974. * will be `undefined`.
  25975. *
  25976. * __persistentStateReset__ (key: String)
  25977. *
  25978. * * Clears the value saved under `key`. If no `key` is given, all values associated with table will be cleared.
  25979. *
  25980. * __Note:__ The main reason behind using `persistentState` hooks rather than regular LocalStorage API is that it
  25981. * ensures separation of data stored by multiple Handsontable instances. In other words, if you have two (or more)
  25982. * instances of Handsontable on one page, data saved by one instance won't be accessible by the second instance.
  25983. * Those two instances can store data under the same key and no data would be overwritten.
  25984. *
  25985. * __Important:__ In order for the data separation to work properly, make sure that each instance of Handsontable has a unique `id`.
  25986. *
  25987. * @type {Boolean}
  25988. * @default false
  25989. */
  25990. persistentState: void 0,
  25991. /**
  25992. * Class name for all visible rows in the current selection.
  25993. *
  25994. * @type {String}
  25995. * @default undefined
  25996. * @example
  25997. * ```js
  25998. * currentRowClassName: 'currentRow' // This will add a 'currentRow' class name to appropriate table cells.
  25999. * ```
  26000. */
  26001. currentRowClassName: void 0,
  26002. /**
  26003. * Class name for all visible columns in the current selection.
  26004. *
  26005. * @type {String}
  26006. * @default undefined
  26007. * @example
  26008. * ```js
  26009. * currentColClassName: 'currentColumn' // This will add a 'currentColumn' class name to appropriate table cells.
  26010. * ```
  26011. */
  26012. currentColClassName: void 0,
  26013. /**
  26014. * Class name for all visible headers in current selection.
  26015. *
  26016. * @type {String}
  26017. * @since 0.27.0
  26018. * @default 'ht__highlight'
  26019. * @example
  26020. * ```js
  26021. * currentHeaderClassName: 'ht__highlight' // This will add a 'ht__highlight' class name to appropriate table headers.
  26022. * ```
  26023. */
  26024. currentHeaderClassName: 'ht__highlight',
  26025. /**
  26026. * Class name for all active headers in selections. The header will be marked with this class name
  26027. * only when a whole column or row will be selected.
  26028. *
  26029. * @type {String}
  26030. * @since 0.38.2
  26031. * @default 'ht__active_highlight'
  26032. * @example
  26033. * ```js
  26034. * activeHeaderClassName: 'ht__active_highlight' // This will add a 'ht__active_highlight' class name to appropriate table headers.
  26035. * ```
  26036. */
  26037. activeHeaderClassName: 'ht__active_highlight',
  26038. /**
  26039. * Class name for the Handsontable container element.
  26040. *
  26041. * @type {String|Array}
  26042. * @default undefined
  26043. */
  26044. className: void 0,
  26045. /**
  26046. * Class name for all tables inside container element.
  26047. *
  26048. * @since 0.17.0
  26049. * @type {String|Array}
  26050. * @default undefined
  26051. */
  26052. tableClassName: void 0,
  26053. /**
  26054. * @description
  26055. * Defines how the columns react, when the declared table width is different than the calculated sum of all column widths.
  26056. * [See more](http://docs.handsontable.com/demo-stretching.html) mode. Possible values:
  26057. * * `'none'` Disable stretching
  26058. * * `'last'` Stretch only the last column
  26059. * * `'all'` Stretch all the columns evenly
  26060. *
  26061. * @type {String}
  26062. * @default 'none'
  26063. */
  26064. stretchH: 'none',
  26065. /**
  26066. * Lets you overwrite the default `isEmptyRow` method, which checks if row at the provided index is empty.
  26067. *
  26068. * @type {Function}
  26069. * @param {Number} row Visual row index.
  26070. * @returns {Boolean}
  26071. */
  26072. isEmptyRow: function isEmptyRow(row) {
  26073. var col, colLen, value, meta;
  26074. for (col = 0, colLen = this.countCols(); col < colLen; col++) {
  26075. value = this.getDataAtCell(row, col);
  26076. if (value !== '' && value !== null && (0, _mixed.isDefined)(value)) {
  26077. if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
  26078. meta = this.getCellMeta(row, col);
  26079. return (0, _object.isObjectEqual)(this.getSchema()[meta.prop], value);
  26080. }
  26081. return false;
  26082. }
  26083. }
  26084. return true;
  26085. },
  26086. /**
  26087. * Lets you overwrite the default `isEmptyCol` method, which checks if column at the provided index is empty.
  26088. *
  26089. * @type {Function}
  26090. * @param {Number} col Visual column index
  26091. * @returns {Boolean}
  26092. */
  26093. isEmptyCol: function isEmptyCol(col) {
  26094. var row, rowLen, value;
  26095. for (row = 0, rowLen = this.countRows(); row < rowLen; row++) {
  26096. value = this.getDataAtCell(row, col);
  26097. if (value !== '' && value !== null && (0, _mixed.isDefined)(value)) {
  26098. return false;
  26099. }
  26100. }
  26101. return true;
  26102. },
  26103. /**
  26104. * When set to `true`, the table is re-rendered when it is detected that it was made visible in DOM.
  26105. *
  26106. * @type {Boolean}
  26107. * @default true
  26108. */
  26109. observeDOMVisibility: true,
  26110. /**
  26111. * If set to `true`, Handsontable will accept values that were marked as invalid by the cell `validator`.
  26112. * It will result with *invalid* cells being treated as *valid* (will save the *invalid* value into the Handsontable data source).
  26113. * If set to `false`, Handsontable will *not* accept the invalid values and won't allow the user to close the editor.
  26114. * This option will be particularly useful when used with the Autocomplete's `strict` mode.
  26115. *
  26116. * @type {Boolean}
  26117. * @default true
  26118. * @since 0.9.5
  26119. */
  26120. allowInvalid: true,
  26121. /**
  26122. * If set to `true`, Handsontable will accept values that are empty (`null`, `undefined` or `''`).
  26123. * If set to `false`, Handsontable will *not* accept the empty values and mark cell as invalid.
  26124. *
  26125. * @example
  26126. * ```js
  26127. * ...
  26128. * allowEmpty: true // allow empty values for all cells (whole table)
  26129. * ...
  26130. * // or
  26131. * ...
  26132. * columns: [
  26133. * // allow empty values only for 'date' column
  26134. * {data: 'date', dateFormat: 'DD/MM/YYYY', allowEmpty: true}
  26135. * ]
  26136. * ...
  26137. * ```
  26138. *
  26139. * @type {Boolean}
  26140. * @default true
  26141. * @since 0.23.0
  26142. */
  26143. allowEmpty: true,
  26144. /**
  26145. * CSS class name for cells that did not pass validation.
  26146. *
  26147. * @type {String}
  26148. * @default 'htInvalid'
  26149. */
  26150. invalidCellClassName: 'htInvalid',
  26151. /**
  26152. * When set to an non-empty string, displayed as the cell content for empty cells. If a value of a different type is provided,
  26153. * it will be stringified and applied as a string.
  26154. *
  26155. * @type {Mixed}
  26156. * @default false
  26157. */
  26158. placeholder: false,
  26159. /**
  26160. * CSS class name for cells that have a placeholder in use.
  26161. *
  26162. * @type {String}
  26163. * @default 'htPlaceholder'
  26164. */
  26165. placeholderCellClassName: 'htPlaceholder',
  26166. /**
  26167. * CSS class name for read-only cells.
  26168. *
  26169. * @type {String}
  26170. * @default 'htDimmed'
  26171. */
  26172. readOnlyCellClassName: 'htDimmed',
  26173. /**
  26174. * @description
  26175. * If a string is provided, it may be one of the following predefined values:
  26176. * * `autocomplete`,
  26177. * * `checkbox`,
  26178. * * `html`,
  26179. * * `numeric`,
  26180. * * `password`.
  26181. * * `text`.
  26182. *
  26183. * Or you can [register](http://docs.handsontable.com/demo-custom-renderers.html) the custom renderer under specified name and use
  26184. * its name as an alias in your configuration.
  26185. *
  26186. * If a function is provided, it will receive the following arguments:
  26187. * ```js
  26188. * function(instance, TD, row, col, prop, value, cellProperties) {}
  26189. * ```
  26190. *
  26191. * You can read more about custom renderes [in the documentation](http://docs.handsontable.com/demo-custom-renderers.html).
  26192. *
  26193. * @example
  26194. * ```js
  26195. * ...
  26196. * Handsontable.renderers.registerRenderer('my.renderer', function(instance, TD, row, col, prop, value, cellProperties) {
  26197. * TD.innerHTML = value;
  26198. * });
  26199. * ...
  26200. * columns: [
  26201. * {
  26202. * editor: 'select',
  26203. * renderer: 'autocomplete' // as string
  26204. * },
  26205. * {
  26206. * renderer: 'my.renderer' // custom renderer as an alias
  26207. * },
  26208. * {
  26209. * // renderer as custom function
  26210. * renderer: function(hotInstance, TD, row, col, prop, value, cellProperties) {
  26211. * TD.style.color = 'blue';
  26212. * TD.innerHTML = value;
  26213. * }
  26214. * }
  26215. * ]
  26216. * ...
  26217. * ```
  26218. *
  26219. * @type {String|Function}
  26220. * @default undefined
  26221. */
  26222. renderer: void 0,
  26223. /**
  26224. * CSS class name added to the commented cells.
  26225. *
  26226. * @type {String}
  26227. * @default 'htCommentCell'
  26228. */
  26229. commentedCellClassName: 'htCommentCell',
  26230. /**
  26231. * If set to `true`, it enables the browser's native selection of a fragment of the text within a single cell, between adjacent cells or in a whole table.
  26232. * If set to `'cell'`, it enables the possibility of selecting a fragment of the text within a single cell's body.
  26233. *
  26234. * @type {Boolean|String}
  26235. * @default false
  26236. */
  26237. fragmentSelection: false,
  26238. /**
  26239. * @description
  26240. * Make cell [read only](http://docs.handsontable.com/demo-read-only.html).
  26241. *
  26242. * @type {Boolean}
  26243. * @default false
  26244. */
  26245. readOnly: false,
  26246. /**
  26247. * @description
  26248. * When added to a `column` property, it skips the column on paste and pastes the data on the next column to the right.
  26249. *
  26250. * @type {Boolean}
  26251. * @default false
  26252. */
  26253. skipColumnOnPaste: false,
  26254. /**
  26255. * @description
  26256. * Setting to true enables the search plugin (see [demo](http://docs.handsontable.com/demo-search-for-values.html)).
  26257. *
  26258. * @type {Boolean}
  26259. * @default false
  26260. */
  26261. search: false,
  26262. /**
  26263. * @description
  26264. * Shortcut to define the combination of the cell renderer, editor and validator for the column, cell or whole table.
  26265. *
  26266. * Possible values:
  26267. * * [autocomplete](http://docs.handsontable.com/demo-autocomplete.html)
  26268. * * [checkbox](http://docs.handsontable.com/demo-checkbox.html)
  26269. * * [date](http://docs.handsontable.com/demo-date.html)
  26270. * * [dropdown](http://docs.handsontable.com/demo-dropdown.html)
  26271. * * [handsontable](http://docs.handsontable.com/demo-handsontable.html)
  26272. * * [numeric](http://docs.handsontable.com/demo-numeric.html)
  26273. * * [password](http://docs.handsontable.com/demo-password.html)
  26274. * * text
  26275. * * [time](http://docs.handsontable.com/demo-time.html)
  26276. *
  26277. * Or you can register the custom cell type under specified name and use
  26278. * its name as an alias in your configuration.
  26279. *
  26280. * @example
  26281. * ```js
  26282. * ...
  26283. * Handsontable.cellTypes.registerCellType('my.type', {
  26284. * editor: MyEditorClass,
  26285. * renderer: function(hot, td, row, col, prop, value, cellProperties) {
  26286. * td.innerHTML = value;
  26287. * },
  26288. * validator: function(value, callback) {
  26289. * callback(value === 'foo' ? true : false);
  26290. * }
  26291. * });
  26292. * ...
  26293. * columns: [
  26294. * {
  26295. * type: 'text'
  26296. * },
  26297. * {
  26298. * type: 'my.type' // an alias to custom type
  26299. * },
  26300. * {
  26301. * type: 'checkbox'
  26302. * }
  26303. * ]
  26304. * ...
  26305. * ```
  26306. *
  26307. * @type {String}
  26308. * @default 'text'
  26309. */
  26310. type: 'text',
  26311. /**
  26312. * @description
  26313. * Make cell copyable (pressing <kbd>CTRL</kbd> + <kbd>C</kbd> on your keyboard moves its value to system clipboard).
  26314. *
  26315. * __Note:__ this setting is `false` by default for cells with type `password`.
  26316. *
  26317. * @type {Boolean}
  26318. * @default true
  26319. * @since 0.10.2
  26320. */
  26321. copyable: true,
  26322. /**
  26323. * Defines the editor for the table/column/cell.
  26324. *
  26325. * If a string is provided, it may be one of the following predefined values:
  26326. * * [autocomplete](http://docs.handsontable.com/demo-autocomplete.html)
  26327. * * [checkbox](http://docs.handsontable.com/demo-checkbox.html)
  26328. * * [date](http://docs.handsontable.com/demo-date.html)
  26329. * * [dropdown](http://docs.handsontable.com/demo-dropdown.html)
  26330. * * [handsontable](http://docs.handsontable.com/demo-handsontable.html)
  26331. * * [mobile](http://docs.handsontable.com/demo-mobiles-and-tablets.html)
  26332. * * [password](http://docs.handsontable.com/demo-password.html)
  26333. * * [select](http://docs.handsontable.com/demo-select.html)
  26334. * * text
  26335. *
  26336. * Or you can [register](http://docs.handsontable.com/tutorial-cell-editor.html#registering-an-editor) the custom editor under specified name and use
  26337. * its name as an alias in your configuration.
  26338. *
  26339. * To disable cell editing completely set `editor` property to `false`.
  26340. *
  26341. * @example
  26342. * ```js
  26343. * ...
  26344. * columns: [
  26345. * {
  26346. * editor: 'select'
  26347. * },
  26348. * {
  26349. * editor: false
  26350. * }
  26351. * ]
  26352. * ...
  26353. * ```
  26354. *
  26355. * @type {String|Function|Boolean}
  26356. * @default 'text'
  26357. */
  26358. editor: void 0,
  26359. /**
  26360. * @description
  26361. * Autocomplete definitions. See [autocomplete demo](http://docs.handsontable.com/demo-autocomplete.html) for examples and definitions.
  26362. *
  26363. * @type {Array}
  26364. * @default undefined
  26365. */
  26366. autoComplete: void 0,
  26367. /**
  26368. * Control number of choices for the autocomplete (or dropdown) typed cells. After exceeding it, a scrollbar for the dropdown list of choices will appear.
  26369. *
  26370. * @since 0.18.0
  26371. * @type {Number}
  26372. * @default 10
  26373. */
  26374. visibleRows: 10,
  26375. /**
  26376. * Makes autocomplete or dropdown width the same as the edited cell width. If `false` then editor will be scaled
  26377. * according to its content.
  26378. *
  26379. * @since 0.17.0
  26380. * @type {Boolean}
  26381. * @default true
  26382. */
  26383. trimDropdown: true,
  26384. /**
  26385. * Setting to true enables the debug mode, currently used to test the correctness of the row and column
  26386. * header fixed positioning on a layer above the master table.
  26387. *
  26388. * @type {Boolean}
  26389. * @default false
  26390. */
  26391. debug: false,
  26392. /**
  26393. * When set to `true`, the text of the cell content is wrapped if it does not fit in the fixed column width.
  26394. *
  26395. * @type {Boolean}
  26396. * @default true
  26397. * @since 0.11.0
  26398. */
  26399. wordWrap: true,
  26400. /**
  26401. * CSS class name added to cells with cell meta `wordWrap: false`.
  26402. *
  26403. * @type {String}
  26404. * @default 'htNoWrap'
  26405. * @since 0.11.0
  26406. */
  26407. noWordWrapClassName: 'htNoWrap',
  26408. /**
  26409. * @description
  26410. * Defines if the right-click context menu should be enabled. Context menu allows to create new row or
  26411. * column at any place in the grid among [other features](http://docs.handsontable.com/demo-context-menu.html).
  26412. * Possible values:
  26413. * * `true` (to enable default options),
  26414. * * `false` (to disable completely)
  26415. * * an array of [predefined options](https://docs.handsontable.com/demo-context-menu.html#page-specific),
  26416. * * an object [with defined structure](http://docs.handsontable.com/demo-context-menu.html#page-custom)
  26417. *
  26418. * See [the context menu demo](http://docs.handsontable.com/demo-context-menu.html) for examples.
  26419. *
  26420. * @example
  26421. * ```js
  26422. * ...
  26423. * // as a boolean
  26424. * contextMenu: true
  26425. * ...
  26426. * // as an array
  26427. * contextMenu: ['row_above', 'row_below', '--------', 'undo', 'redo']
  26428. * ...
  26429. * ```
  26430. * ...
  26431. * // as an object (`name` attribute is required in the custom keys)
  26432. * contextMenu: {
  26433. * items: {
  26434. * "option1": {
  26435. * name: "option1"
  26436. * },
  26437. * "option2": {
  26438. * name: "option2",
  26439. * submenu: {
  26440. * items: [
  26441. * {
  26442. * key: "option2:suboption1",
  26443. * name: "option2:suboption1",
  26444. * callback: function(key, options) {
  26445. * ...
  26446. * }
  26447. * },
  26448. * ...
  26449. * ]
  26450. * }
  26451. * }
  26452. * }
  26453. * }
  26454. * ...
  26455. * ```
  26456. * @type {Boolean|Array|Object}
  26457. * @default undefined
  26458. */
  26459. contextMenu: void 0,
  26460. /**
  26461. * @description
  26462. * Disable or enable the copy/paste functionality.
  26463. *
  26464. * @example
  26465. * ```js
  26466. * ...
  26467. * copyPaste: false,
  26468. * ...
  26469. * ```
  26470. *
  26471. * @type {Boolean}
  26472. * @default true
  26473. */
  26474. copyPaste: true,
  26475. /**
  26476. * If `true`, undo/redo functionality is enabled.
  26477. *
  26478. * @type {Boolean}
  26479. * @default undefined
  26480. */
  26481. undo: void 0,
  26482. /**
  26483. * @description
  26484. * Turns on [Column sorting](http://docs.handsontable.com/demo-sorting-data.html).
  26485. * Can be either a boolean (true/false) or an object with a declared sorting options. See the below example:
  26486. *
  26487. * @example
  26488. * ```js
  26489. * ...
  26490. * // as boolean
  26491. * columnSorting: true
  26492. * ...
  26493. * // as a object with initial order (sort ascending column at index 2)
  26494. * columnSorting: {
  26495. * column: 2,
  26496. * sortOrder: true, // true = ascending, false = descending, undefined = original order
  26497. * sortEmptyCells: true // true = the table sorts empty cells, false = the table moves all empty cells to the end of the table
  26498. * }
  26499. * ...
  26500. * ```
  26501. *
  26502. * @type {Boolean|Object}
  26503. * @default undefined
  26504. */
  26505. columnSorting: void 0,
  26506. /**
  26507. * @description
  26508. * Turns on [Manual column move](http://docs.handsontable.com/demo-moving-rows-and-columns.html), if set to a boolean or define initial
  26509. * column order, if set to an array of column indexes.
  26510. *
  26511. * @example
  26512. * ```js
  26513. * ...
  26514. * // as boolean
  26515. * manualColumnMove: true
  26516. * ...
  26517. * // as a array with initial order (move column index at 0 to 1 and move column index at 1 to 4)
  26518. * manualColumnMove: [1, 4]
  26519. * ...
  26520. * ```
  26521. *
  26522. * @type {Boolean|Array}
  26523. * @default undefined
  26524. */
  26525. manualColumnMove: void 0,
  26526. /**
  26527. * @description
  26528. * Turns on [Manual column resize](http://docs.handsontable.com/demo-resizing.html), if set to a boolean or define initial
  26529. * column resized widths, if set to an array of numbers.
  26530. *
  26531. * @example
  26532. * ```js
  26533. * ...
  26534. * // as boolean
  26535. * manualColumnResize: true
  26536. * ...
  26537. * // as a array with initial widths (column at 0 index has 40px and column at 1 index has 50px)
  26538. * manualColumnResize: [40, 50]
  26539. * ...
  26540. * ```
  26541. *
  26542. * @type {Boolean|Array}
  26543. * @default undefined
  26544. */
  26545. manualColumnResize: void 0,
  26546. /**
  26547. * @description
  26548. * Turns on [Manual row move](http://docs.handsontable.com/demo-moving-rows-and-columns.html), if set to a boolean or define initial
  26549. * row order, if set to an array of row indexes.
  26550. *
  26551. * @example
  26552. * ```js
  26553. * ...
  26554. * // as boolean
  26555. * manualRowMove: true
  26556. * ...
  26557. * // as a array with initial order (move row index at 0 to 1 and move row index at 1 to 4)
  26558. * manualRowMove: [1, 4]
  26559. * ...
  26560. * ```
  26561. *
  26562. * @type {Boolean|Array}
  26563. * @default undefined
  26564. * @since 0.11.0
  26565. */
  26566. manualRowMove: void 0,
  26567. /**
  26568. * @description
  26569. * Turns on [Manual row resize](http://docs.handsontable.com/demo-resizing.html), if set to a boolean or define initial
  26570. * row resized heights, if set to an array of numbers.
  26571. *
  26572. * @example
  26573. * ```js
  26574. * ...
  26575. * // as boolean
  26576. * manualRowResize: true
  26577. * ...
  26578. * // as a array with initial heights (row at 0 index has 40px and row at 1 index has 50px)
  26579. * manualRowResize: [40, 50]
  26580. * ...
  26581. * ```
  26582. *
  26583. * @type {Boolean|Array}
  26584. * @default undefined
  26585. * @since 0.11.0
  26586. */
  26587. manualRowResize: void 0,
  26588. /**
  26589. * @description
  26590. * If set to `true`, it enables a possibility to merge cells. If set to an array of objects, it merges the cells provided in the objects (see the example below).
  26591. * [More information on the demo page.](http://docs.handsontable.com/demo-merge-cells.html)
  26592. *
  26593. * @example
  26594. * ```js
  26595. * // enables the mergeCells plugin:
  26596. * margeCells: true
  26597. * ...
  26598. * // declares a list of merged sections:
  26599. * mergeCells: [
  26600. * {row: 1, col: 1, rowspan: 3, colspan: 3}, // rowspan and colspan properties declare the width and height of a merged section in cells
  26601. * {row: 3, col: 4, rowspan: 2, colspan: 2},
  26602. * {row: 5, col: 6, rowspan: 3, colspan: 3}
  26603. * ]
  26604. * ```
  26605. * @type {Boolean|Array}
  26606. * @default false
  26607. */
  26608. mergeCells: false,
  26609. /**
  26610. * Number of rows to be rendered outside of the visible part of the table.
  26611. * By default, it's set to `'auto'`, which makes Handsontable to attempt to calculate the best offset performance-wise.
  26612. *
  26613. * You may test out different values to find the best one that works for your specific implementation.
  26614. *
  26615. * @type {Number|String}
  26616. * @default 'auto'
  26617. */
  26618. viewportRowRenderingOffset: 'auto',
  26619. /**
  26620. * Number of columns to be rendered outside of the visible part of the table.
  26621. * By default, it's set to `'auto'`, which makes Handsontable try calculating the best offset performance-wise.
  26622. *
  26623. * You may experiment with the value to find the one that works best for your specific implementation.
  26624. *
  26625. * @type {Number|String}
  26626. * @default 'auto'
  26627. */
  26628. viewportColumnRenderingOffset: 'auto',
  26629. /**
  26630. * A function, regular expression or a string, which will be used in the process of cell validation.
  26631. * If a function is used, be sure to execute the callback argument with either `true` (`callback(true)`) if the validation passed
  26632. * or with `false` (`callback(false)`), if the validation failed.
  26633. * Note, that `this` in the function points to the `cellProperties` object.
  26634. *
  26635. * If a string is provided, it may be one of the following predefined values:
  26636. * * `autocomplete`,
  26637. * * `date`,
  26638. * * `numeric`,
  26639. * * `time`.
  26640. *
  26641. * Or you can [register](http://docs.handsontable.com/demo-data-validation.html) the validator function under specified name and use
  26642. * its name as an alias in your configuration.
  26643. *
  26644. * See more [in the demo](http://docs.handsontable.com/demo-data-validation.html).
  26645. *
  26646. * @example
  26647. * ```js
  26648. * // as a function
  26649. * columns: [
  26650. * {
  26651. * validator: function(value, callback) { // validation rules }
  26652. * }
  26653. * ]
  26654. * ...
  26655. * // as a regexp
  26656. * columns: [
  26657. * {
  26658. * validator: /^[0-9]$/ // regular expression
  26659. * }
  26660. * ]
  26661. * // as a string
  26662. * columns: [
  26663. * {
  26664. * validator: 'numeric'
  26665. * }
  26666. * ]
  26667. * ```
  26668. * @type {Function|RegExp|String}
  26669. * @default undefined
  26670. * @since 0.9.5
  26671. */
  26672. validator: void 0,
  26673. /**
  26674. * @description
  26675. * Disable visual cells selection.
  26676. *
  26677. * Possible values:
  26678. * * `true` - Disables any type of visual selection (current and area selection),
  26679. * * `false` - Enables any type of visual selection. This is default value.
  26680. * * `'current'` - Disables the selection of a currently selected cell, the area selection is still present.
  26681. * * `'area'` - Disables the area selection, the currently selected cell selection is still present.
  26682. * * `'header'` - Disables the headers selection, the currently selected cell selection is still present (available since 0.36.0).
  26683. *
  26684. * @type {Boolean|String|Array}
  26685. * @default false
  26686. * @since 0.13.2
  26687. * @example
  26688. * ```js
  26689. * ...
  26690. * // as boolean
  26691. * disableVisualSelection: true,
  26692. * ...
  26693. *
  26694. * ...
  26695. * // as string ('current', 'area' or 'header')
  26696. * disableVisualSelection: 'current',
  26697. * ...
  26698. *
  26699. * ...
  26700. * // as array
  26701. * disableVisualSelection: ['current', 'area'],
  26702. * ...
  26703. * ```
  26704. */
  26705. disableVisualSelection: false,
  26706. /**
  26707. * @description
  26708. * Set whether to display the current sorting order indicator (a triangle icon in the column header, specifying the sorting order).
  26709. *
  26710. * @type {Boolean}
  26711. * @default false
  26712. * @since 0.15.0-beta3
  26713. */
  26714. sortIndicator: void 0,
  26715. /**
  26716. * Disable or enable ManualColumnFreeze plugin.
  26717. *
  26718. * @type {Boolean}
  26719. * @default false
  26720. */
  26721. manualColumnFreeze: void 0,
  26722. /**
  26723. * @description
  26724. * Defines whether Handsontable should trim the whitespace at the beginning and the end of the cell contents.
  26725. *
  26726. * @type {Boolean}
  26727. * @default true
  26728. */
  26729. trimWhitespace: true,
  26730. settings: void 0,
  26731. /**
  26732. * @description
  26733. * Defines data source for Autocomplete or Dropdown cell types.
  26734. *
  26735. * @example
  26736. * ```js
  26737. * ...
  26738. * // source as a array
  26739. * columns: [{
  26740. * type: 'autocomplete',
  26741. * source: ['A', 'B', 'C', 'D']
  26742. * }]
  26743. * ...
  26744. * // source as a function
  26745. * columns: [{
  26746. * type: 'autocomplete',
  26747. * source: function(query, callback) {
  26748. * fetch('http://example.com/query?q=' + query, function(response) {
  26749. * callback(response.items);
  26750. * })
  26751. * }
  26752. * }]
  26753. * ...
  26754. * ```
  26755. *
  26756. * @type {Array|Function}
  26757. * @default undefined
  26758. */
  26759. source: void 0,
  26760. /**
  26761. * @description
  26762. * Defines the column header name.
  26763. *
  26764. * @example
  26765. * ```js
  26766. * ...
  26767. * columns: [{
  26768. * title: 'First name',
  26769. * type: 'text',
  26770. * },
  26771. * {
  26772. * title: 'Last name',
  26773. * type: 'text',
  26774. * }]
  26775. * ...
  26776. * ```
  26777. *
  26778. * @type {String}
  26779. * @default undefined
  26780. */
  26781. title: void 0,
  26782. /**
  26783. * Data template for `'checkbox'` type when checkbox is checked.
  26784. *
  26785. * @example
  26786. * ```js
  26787. * checkedTemplate: 'good'
  26788. *
  26789. * // if a checkbox-typed cell is checked, then getDataAtCell(x,y), where x and y are the coordinates of the cell
  26790. * // will return 'good'.
  26791. * ```
  26792. * @type {Boolean|String}
  26793. * @default true
  26794. */
  26795. checkedTemplate: void 0,
  26796. /**
  26797. * Data template for `'checkbox'` type when checkbox is unchecked.
  26798. *
  26799. * @example
  26800. * ```js
  26801. * uncheckedTemplate: 'bad'
  26802. *
  26803. * // if a checkbox-typed cell is not checked, then getDataAtCell(x,y), where x and y are the coordinates of the cell
  26804. * // will return 'bad'.
  26805. * ```
  26806. * @type {Boolean|String}
  26807. * @default false
  26808. */
  26809. uncheckedTemplate: void 0,
  26810. /**
  26811. * @description
  26812. * Object which describes if renderer should create checkbox element with label element as a parent. Option desired for
  26813. * [checkbox](http://docs.handsontable.com/demo-checkbox.html)-typed cells.
  26814. *
  26815. * By default the [checkbox](http://docs.handsontable.com/demo-checkbox.html) renderer renders the checkbox without a label.
  26816. *
  26817. * Possible object properties:
  26818. * * `property` - Defines the property name of the data object, which will to be used as a label.
  26819. * (eg. `label: {property: 'name.last'}`). This option works only if data was passed as an array of objects.
  26820. * * `position` - String which describes where to place the label text (before or after checkbox element).
  26821. * Valid values are `'before'` and '`after`' (defaults to `'after'`).
  26822. * * `value` - String or a Function which will be used as label text.
  26823. *
  26824. * @example
  26825. * ```js
  26826. * ...
  26827. * columns: [{
  26828. * type: 'checkbox',
  26829. * label: {position: 'after', value: 'My label: '}
  26830. * }]
  26831. * ...
  26832. * ```
  26833. *
  26834. * @since 0.19.0
  26835. * @type {Object}
  26836. * @default undefined
  26837. */
  26838. label: void 0,
  26839. /**
  26840. * Display format. This option is desired for [numeric-typed](http://docs.handsontable.com/demo-numeric.html) cells. Format is described by two properties:
  26841. *
  26842. * - pattern, which is handled by `numbro` for purpose of formatting numbers to desired pattern. List of supported patterns can be found [here](http://numbrojs.com/format.html#numbers).
  26843. * - culture, which is handled by `numbro` for purpose of formatting currencies. Examples showing how it works can be found [here](http://numbrojs.com/format.html#currency). List of supported cultures can be found [here](http://numbrojs.com/languages.html#supported-languages).
  26844. *
  26845. * __Note:__ Please keep in mind that this option is used only to format the displayed output! It has no effect on the input data provided for the cell. The numeric data can be entered to the table only as floats (separated by a dot or a comma) or integers, and are stored in the source dataset as JavaScript numbers.
  26846. *
  26847. * Since 0.26.0 Handsontable uses [numbro](http://numbrojs.com/) as a main library for numbers formatting.
  26848. *
  26849. * @example
  26850. * ```js
  26851. * ...
  26852. * columns: [{
  26853. * type: 'numeric',
  26854. * numericFormat: {
  26855. * pattern: '0,00',
  26856. * culture: 'en-US'
  26857. * }
  26858. * }]
  26859. * ...
  26860. * ```
  26861. *
  26862. * @since 0.35.0
  26863. * @type {Object}
  26864. */
  26865. numericFormat: void 0,
  26866. /**
  26867. * Language for Handsontable translation. Possible language codes are: `en-US`, `pl-PL`.
  26868. *
  26869. * @type {String}
  26870. * @default 'en-US'
  26871. */
  26872. language: void 0,
  26873. /**
  26874. * @description
  26875. * Data source for [select](http://docs.handsontable.com/demo-select.html)-typed cells.
  26876. *
  26877. * @example
  26878. * ```js
  26879. * ...
  26880. * columns: [{
  26881. * editor: 'select',
  26882. * selectOptions: ['A', 'B', 'C'],
  26883. * }]
  26884. * ...
  26885. * ```
  26886. *
  26887. * @type {Array}
  26888. */
  26889. selectOptions: void 0,
  26890. /**
  26891. * Enables or disables the autoColumnSize plugin. Default value is `undefined`, which has the same effect as `true`.
  26892. * Disabling this plugin can increase performance, as no size-related calculations would be done.
  26893. *
  26894. * Column width calculations are divided into sync and async part. Each of this parts has their own advantages and
  26895. * disadvantages. Synchronous calculations are faster but they block the browser UI, while the slower asynchronous operations don't
  26896. * block the browser UI.
  26897. *
  26898. * To configure the sync/async distribution, you can pass an absolute value (number of columns) or a percentage value.
  26899. * `syncLimit` option is available since 0.16.0.
  26900. *
  26901. * You can also use the `useHeaders` option to take the column headers with into calculation.
  26902. *
  26903. * @example
  26904. * ```js
  26905. * ...
  26906. * // as a number (300 columns in sync, rest async)
  26907. * autoColumnSize: {syncLimit: 300},
  26908. * ...
  26909. *
  26910. * ...
  26911. * // as a string (percent)
  26912. * autoColumnSize: {syncLimit: '40%'},
  26913. * ...
  26914. *
  26915. * ...
  26916. * // use headers width while calculation the column width
  26917. * autoColumnSize: {useHeaders: true},
  26918. * ...
  26919. *
  26920. * ```
  26921. *
  26922. * @type {Object|Boolean}
  26923. * @default {syncLimit: 50}
  26924. */
  26925. autoColumnSize: void 0,
  26926. /**
  26927. * Enables or disables autoRowSize plugin. Default value is `undefined`, which has the same effect as `false` (disabled).
  26928. * Enabling this plugin can decrease performance, as size-related calculations would be performed.
  26929. *
  26930. * Row height calculations are divided into sync and async stages. Each of these stages has their own advantages and
  26931. * disadvantages. Synchronous calculations are faster but they block the browser UI, while the slower asynchronous operations don't
  26932. * block the browser UI.
  26933. *
  26934. * To configure the sync/async distribution, you can pass an absolute value (number of columns) or a percentage value.
  26935. * `syncLimit` options is available since 0.16.0.
  26936. *
  26937. * @example
  26938. * ```js
  26939. * ...
  26940. * // as number (300 columns in sync, rest async)
  26941. * autoRowSize: {syncLimit: 300},
  26942. * ...
  26943. *
  26944. * ...
  26945. * // as string (percent)
  26946. * autoRowSize: {syncLimit: '40%'},
  26947. * ...
  26948. * ```
  26949. * @type {Object|Boolean}
  26950. * @default {syncLimit: 1000}
  26951. */
  26952. autoRowSize: void 0,
  26953. /**
  26954. * Date validation format.
  26955. *
  26956. * Option desired for `'date'` - typed cells.
  26957. *
  26958. * @example
  26959. * ```js
  26960. * ...
  26961. * columns: [{
  26962. * type: 'date',
  26963. * dateFormat: 'MM/DD/YYYY'
  26964. * }]
  26965. * ...
  26966. * ```
  26967. *
  26968. * @type {String}
  26969. * @default 'DD/MM/YYYY'
  26970. */
  26971. dateFormat: void 0,
  26972. /**
  26973. * If `true` then dates will be automatically formatted to match the desired format.
  26974. *
  26975. * Option desired for `'date'`-typed typed cells.
  26976. *
  26977. * @example
  26978. * ```js
  26979. * ...
  26980. * columns: [{
  26981. * type: 'date',
  26982. * dateFormat: 'YYYY-MM-DD',
  26983. * correctFormat: true
  26984. * }]
  26985. * ...
  26986. * ```
  26987. *
  26988. * @type {Boolean}
  26989. * @default false
  26990. */
  26991. correctFormat: false,
  26992. /**
  26993. * Definition of default value which will fill the empty cells.
  26994. *
  26995. * Option desired for `'date'`-typed cells.
  26996. *
  26997. * @example
  26998. * ```js
  26999. * ...
  27000. * columns: [{
  27001. * type: 'date',
  27002. * defaultData: '2015-02-02'
  27003. * }]
  27004. * ...
  27005. * ```
  27006. *
  27007. * @type {String}
  27008. */
  27009. defaultDate: void 0,
  27010. /**
  27011. * If set to `true`, the value entered into the cell must match (case-sensitive) the autocomplete source. Otherwise, cell won't pass the validation.
  27012. * When filtering the autocomplete source list, the editor will be working in case-insensitive mode.
  27013. *
  27014. * Option desired for `autocomplete`-typed cells.
  27015. *
  27016. * @example
  27017. * ```js
  27018. * ...
  27019. * columns: [{
  27020. * type: 'autocomplete',
  27021. * source: ['A', 'B', 'C'],
  27022. * strict: true
  27023. * }]
  27024. * ...
  27025. * ```
  27026. *
  27027. * @type {Boolean}
  27028. */
  27029. strict: void 0,
  27030. /**
  27031. * @description
  27032. * If typed `true`, data defined in `source` of the autocomplete or dropdown cell will be treated as HTML.
  27033. *
  27034. * __Warning:__ Enabling this option can cause serious XSS vulnerabilities.
  27035. *
  27036. * Option desired for `'autocomplete'`-typed cells.
  27037. * @example
  27038. * ```js
  27039. * ...
  27040. * columns: [{
  27041. * type: 'autocomplete',
  27042. * allowHtml: true,
  27043. * source: ['<b>foo</b>', '<b>bar</b>']
  27044. * }]
  27045. * ...
  27046. * ```
  27047. * @type {Boolean}
  27048. * @default false
  27049. */
  27050. allowHtml: false,
  27051. /**
  27052. * If typed `true` then virtual rendering mechanism for handsontable will be disabled.
  27053. *
  27054. * @type {Boolean}
  27055. */
  27056. renderAllRows: void 0,
  27057. /**
  27058. * Prevents table to overlap outside the parent element. If `'horizontal'` option is chosen then table will appear horizontal
  27059. * scrollbar in case where parent's width is narrower then table's width.
  27060. *
  27061. * Possible values:
  27062. * * `false` - Disables functionality (Default option).
  27063. * * `horizontal` - Prevents horizontal overflow table.
  27064. * * `vertical` - Prevents vertical overflow table (Not implemented yet).
  27065. *
  27066. * @since 0.20.3
  27067. * @example
  27068. * ```js
  27069. * ...
  27070. * preventOverflow: 'horizontal'
  27071. * ...
  27072. * ```
  27073. *
  27074. * @type {String|Boolean}
  27075. */
  27076. preventOverflow: false,
  27077. /**
  27078. * @description
  27079. * Plugin allowing binding the table rows with their headers.
  27080. * If the plugin is enabled, the table row headers will "stick" to the rows, when they are hidden/moved. Basically, if at the initialization
  27081. * row 0 has a header titled "A", it will have it no matter what you do with the table.
  27082. *
  27083. * @pro
  27084. * @since 1.0.0-beta1
  27085. * @type {Boolean|String}
  27086. * @example
  27087. *
  27088. * ```js
  27089. * ...
  27090. * var hot = new Handsontable(document.getElementById('example'), {
  27091. * date: getData(),
  27092. * bindRowsWithHeaders: true
  27093. * });
  27094. * ...
  27095. * ```
  27096. *
  27097. */
  27098. bindRowsWithHeaders: void 0,
  27099. /**
  27100. * @description
  27101. * The CollapsibleColumns plugin allows collapsing of columns, covered by a header with the `colspan` property defined.
  27102. *
  27103. * Clicking the "collapse/expand" button collapses (or expands) all "child" headers except the first one.
  27104. *
  27105. * Setting the `collapsibleColumns` property to `true` will display a "collapse/expand" button in every header with a defined
  27106. * `colspan` property.
  27107. *
  27108. * To limit this functionality to a smaller group of headers, define the `collapsibleColumns` property as an array of objects, as in
  27109. * the example below.
  27110. *
  27111. * @pro
  27112. * @since 1.0.0-beta1
  27113. * @type {Boolean|Array}
  27114. * @example
  27115. * ```js
  27116. * ...
  27117. * collapsibleColumns: [
  27118. * {row: -4, col: 1, collapsible: true},
  27119. * {row: -3, col: 5, collapsible: true}
  27120. * ]
  27121. * ...
  27122. * // or
  27123. * ...
  27124. * collapsibleColumns: true
  27125. * ...
  27126. * ```
  27127. */
  27128. collapsibleColumns: void 0,
  27129. /**
  27130. * @description
  27131. * Allows making pre-defined calculations on the cell values and display the results within Handsontable.
  27132. * See the demo for more information.
  27133. *
  27134. * @pro
  27135. * @since 1.0.0-beta1
  27136. * @type {Object}
  27137. */
  27138. columnSummary: void 0,
  27139. /**
  27140. * This plugin allows adding a configurable dropdown menu to the table's column headers.
  27141. * The dropdown menu acts like the Context Menu, but is triggered by clicking the button in the header.
  27142. *
  27143. * @pro
  27144. * @since 1.0.0-beta1
  27145. * @type {Boolean|Object|Array}
  27146. */
  27147. dropdownMenu: void 0,
  27148. /**
  27149. * The filters plugin.
  27150. * It allows filtering the table data either by the built-in component or with the API.
  27151. *
  27152. * @pro
  27153. * @since 1.0.0-beta1
  27154. * @type {Boolean}
  27155. */
  27156. filters: void 0,
  27157. /**
  27158. * It allows Handsontable to process formula expressions defined in the provided data.
  27159. *
  27160. * @pro
  27161. * @since 1.7.0
  27162. * @type {Boolean}
  27163. */
  27164. formulas: void 0,
  27165. /**
  27166. * @description
  27167. * GanttChart plugin enables a possibility to create a Gantt chart using a Handsontable instance.
  27168. * In this case, the whole table becomes read-only.
  27169. *
  27170. * @pro
  27171. * @since 1.0.0-beta1
  27172. * @type {Object}
  27173. */
  27174. ganttChart: void 0,
  27175. /**
  27176. * @description
  27177. * Allows adding a tooltip to the table headers.
  27178. *
  27179. * Available options:
  27180. * * the `rows` property defines if tooltips should be added to row headers,
  27181. * * the `columns` property defines if tooltips should be added to column headers,
  27182. * * the `onlyTrimmed` property defines if tooltips should be added only to headers, which content is trimmed by the header itself (the content being wider then the header).
  27183. *
  27184. * @pro
  27185. * @since 1.0.0-beta1
  27186. * @type {Boolean|Object}
  27187. */
  27188. headerTooltips: void 0,
  27189. /**
  27190. * Plugin allowing hiding of certain columns.
  27191. *
  27192. * @pro
  27193. * @since 1.0.0-beta1
  27194. * @type {Boolean|Object}
  27195. */
  27196. hiddenColumns: void 0,
  27197. /**
  27198. * @description
  27199. * Plugin allowing hiding of certain rows.
  27200. *
  27201. * @pro
  27202. * @since 1.0.0-beta1
  27203. * @type {Boolean|Object}
  27204. */
  27205. hiddenRows: void 0,
  27206. /**
  27207. * @description
  27208. * Allows creating a nested header structure, using the HTML's colspan attribute.
  27209. *
  27210. * @pro
  27211. * @since 1.0.0-beta1
  27212. * @type {Array}
  27213. */
  27214. nestedHeaders: void 0,
  27215. /**
  27216. * @description
  27217. * Plugin allowing hiding of certain rows.
  27218. *
  27219. * @pro
  27220. * @since 1.0.0-beta1
  27221. * @type {Boolean|Array}
  27222. */
  27223. trimRows: void 0,
  27224. /**
  27225. * @description
  27226. * Allows setting a custom width of the row headers. You can provide a number or an array of widths, if many row header levels are defined.
  27227. *
  27228. * @since 0.22.0
  27229. * @type {Number|Array}
  27230. */
  27231. rowHeaderWidth: void 0,
  27232. /**
  27233. * @description
  27234. * Allows setting a custom height of the column headers. You can provide a number or an array of heights, if many column header levels are defined.
  27235. *
  27236. * @since 0.22.0
  27237. * @type {Number|Array}
  27238. */
  27239. columnHeaderHeight: void 0,
  27240. /**
  27241. * @description
  27242. * Enabling this plugin switches table into one-way data binding where changes are applied into data source (from outside table)
  27243. * will be automatically reflected in the table.
  27244. *
  27245. * For every data change [afterChangesObserved](Hooks.html#event:afterChangesObserved) hook will be fired.
  27246. *
  27247. * @type {Boolean}
  27248. * @default false
  27249. */
  27250. observeChanges: void 0,
  27251. /**
  27252. * @description
  27253. * When passed to the `column` property, allows specifying a custom sorting function for the desired column.
  27254. *
  27255. * @since 0.24.0
  27256. * @type {Function}
  27257. * @example
  27258. * ```js
  27259. * columns: [
  27260. * {
  27261. * sortFunction: function(sortOrder) {
  27262. * return function(a, b) {
  27263. * // sorting function body.
  27264. * //
  27265. * // Function parameters:
  27266. * // sortOrder: If true, the order is ascending, if false - descending. undefined = original order
  27267. * // a, b: Two compared elements. These are 2-element arrays, with the first element being the row index, the second - cell value.
  27268. * }
  27269. * }
  27270. * }
  27271. * ]
  27272. * ```
  27273. */
  27274. sortFunction: void 0,
  27275. /**
  27276. * If defined as 'true', the Autocomplete's suggestion list would be sorted by relevance (the closer to the left the match is, the higher the suggestion).
  27277. *
  27278. * Option desired for cells of the `'autocomplete'` type.
  27279. *
  27280. * @type {Boolean}
  27281. * @default true
  27282. */
  27283. sortByRelevance: true,
  27284. /**
  27285. * If defined as 'true', when the user types into the input area the Autocomplete's suggestion list is updated to only
  27286. * include those choices starting with what has been typed; if defined as 'false' all suggestions remain shown, with
  27287. * those matching what has been typed marked in bold.
  27288. *
  27289. * @type {Boolean}
  27290. * @default true
  27291. */
  27292. filter: true,
  27293. /**
  27294. * If defined as 'true', filtering in the Autocomplete Editor will be case-sensitive.
  27295. *
  27296. * @type {Boolean}
  27297. * @default: false
  27298. */
  27299. filteringCaseSensitive: false,
  27300. /**
  27301. * @description
  27302. * Disable or enable the drag to scroll functionality.
  27303. *
  27304. * @example
  27305. * ```js
  27306. * ...
  27307. * dragToScroll: false,
  27308. * ...
  27309. * ```
  27310. *
  27311. * @type {Boolean}
  27312. * @default true
  27313. */
  27314. dragToScroll: true
  27315. };
  27316. exports.default = DefaultSettings;
  27317. /***/ }),
  27318. /* 316 */
  27319. /***/ (function(module, exports, __webpack_require__) {
  27320. "use strict";
  27321. exports.__esModule = true;
  27322. exports.getTranslatedPhrase = getTranslatedPhrase;
  27323. var _array = __webpack_require__(1);
  27324. var _dictionariesManager = __webpack_require__(71);
  27325. var _phraseFormatters = __webpack_require__(392);
  27326. var _mixed = __webpack_require__(16);
  27327. /**
  27328. * Get phrase for specified dictionary key.
  27329. *
  27330. * @param {String} languageCode Language code for specific language i.e. 'en-US', 'pt-BR', 'de-DE'.
  27331. * @param {String} dictionaryKey Constant which is dictionary key.
  27332. * @param {*} argumentsForFormatters Arguments which will be handled by formatters.
  27333. *
  27334. * @returns {String}
  27335. */
  27336. // eslint-disable-next-line import/prefer-default-export
  27337. function getTranslatedPhrase(languageCode, dictionaryKey, argumentsForFormatters) {
  27338. var languageDictionary = (0, _dictionariesManager.getLanguageDictionary)(languageCode);
  27339. if (languageDictionary === null) {
  27340. return null;
  27341. }
  27342. var phrasePropositions = languageDictionary[dictionaryKey];
  27343. if ((0, _mixed.isUndefined)(phrasePropositions)) {
  27344. return null;
  27345. }
  27346. var formattedPhrase = getFormattedPhrase(phrasePropositions, argumentsForFormatters);
  27347. if (Array.isArray(formattedPhrase)) {
  27348. return formattedPhrase[0];
  27349. }
  27350. return formattedPhrase;
  27351. }
  27352. /**
  27353. * Get formatted phrase from phrases propositions for specified dictionary key.
  27354. *
  27355. * @private
  27356. * @param {Array|string} phrasePropositions List of phrase propositions.
  27357. * @param {*} argumentsForFormatters Arguments which will be handled by formatters.
  27358. *
  27359. * @returns {Array|string}
  27360. */
  27361. function getFormattedPhrase(phrasePropositions, argumentsForFormatters) {
  27362. var formattedPhrasePropositions = phrasePropositions;
  27363. (0, _array.arrayEach)((0, _phraseFormatters.getPhraseFormatters)(), function (formatter) {
  27364. formattedPhrasePropositions = formatter(phrasePropositions, argumentsForFormatters);
  27365. });
  27366. return formattedPhrasePropositions;
  27367. }
  27368. /***/ }),
  27369. /* 317 */
  27370. /***/ (function(module, exports, __webpack_require__) {
  27371. "use strict";
  27372. exports.__esModule = true;
  27373. var _templateObject = _taggedTemplateLiteral(['Language with code "', '" was not found. You should register particular language \n before using it. Read more about this issue at: https://docs.handsontable.com/i18n/missing-language-code.'], ['Language with code "', '" was not found. You should register particular language \n before using it. Read more about this issue at: https://docs.handsontable.com/i18n/missing-language-code.']);
  27374. exports.extendNotExistingKeys = extendNotExistingKeys;
  27375. exports.createCellHeadersRange = createCellHeadersRange;
  27376. exports.normalizeLanguageCode = normalizeLanguageCode;
  27377. exports.applyLanguageSetting = applyLanguageSetting;
  27378. exports.warnUserAboutLanguageRegistration = warnUserAboutLanguageRegistration;
  27379. var _mixed = __webpack_require__(16);
  27380. var _object = __webpack_require__(2);
  27381. var _console = __webpack_require__(56);
  27382. var _templateLiteralTag = __webpack_require__(42);
  27383. var _dictionariesManager = __webpack_require__(71);
  27384. function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
  27385. /**
  27386. * Perform shallow extend of a target object with only this extension's properties which doesn't exist in the target.
  27387. *
  27388. * @param {Object} target An object that will receive the new properties.
  27389. * @param {Object} extension An object containing additional properties to merge into the target.
  27390. */
  27391. // TODO: Maybe it should be moved to global helpers? It's changed `extend` function.
  27392. function extendNotExistingKeys(target, extension) {
  27393. (0, _object.objectEach)(extension, function (value, key) {
  27394. if ((0, _mixed.isUndefined)(target[key])) {
  27395. target[key] = value;
  27396. }
  27397. });
  27398. return target;
  27399. }
  27400. /**
  27401. * Create range of values basing on cell indexes. For example, it will create below ranges for specified function arguments:
  27402. *
  27403. * createCellHeadersRange(2, 7) => `2-7`
  27404. * createCellHeadersRange(7, 2) => `2-7`
  27405. * createCellHeadersRange(0, 4, 'A', 'D') => `A-D`
  27406. * createCellHeadersRange(4, 0, 'D', 'A') => `A-D`
  27407. *
  27408. * @param {number} firstRowIndex Index of "first" cell
  27409. * @param {number} nextRowIndex Index of "next" cell
  27410. * @param {*} fromValue Value which will represent "first" cell
  27411. * @param {*} toValue Value which will represent "next" cell
  27412. * @returns {String} Value representing range i.e. A-Z, 11-15.
  27413. */
  27414. function createCellHeadersRange(firstRowIndex, nextRowIndex) {
  27415. var fromValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : firstRowIndex;
  27416. var toValue = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : nextRowIndex;
  27417. // Will swap `fromValue` with `toValue` if it's necessary.
  27418. if (firstRowIndex > nextRowIndex) {
  27419. var _ref = [toValue, fromValue];
  27420. fromValue = _ref[0];
  27421. toValue = _ref[1];
  27422. }
  27423. return fromValue + '-' + toValue;
  27424. }
  27425. /**
  27426. * Normalize language code. It takes handled languageCode proposition and change it to proper languageCode.
  27427. * For example, when it takes `eN-us` as parameter it return `en-US`
  27428. *
  27429. * @param {String} languageCode Language code for specific language i.e. 'en-US', 'pt-BR', 'de-DE'.
  27430. * @returns {String}
  27431. */
  27432. function normalizeLanguageCode(languageCode) {
  27433. var languageCodePattern = /^([a-zA-Z]{2})-([a-zA-Z]{2})$/;
  27434. var partsOfLanguageCode = languageCodePattern.exec(languageCode);
  27435. if (partsOfLanguageCode) {
  27436. return partsOfLanguageCode[1].toLowerCase() + '-' + partsOfLanguageCode[2].toUpperCase();
  27437. }
  27438. return languageCode;
  27439. }
  27440. /**
  27441. * Set proper start language code. User may set language code which is not proper.
  27442. *
  27443. * @param {Object} settings Settings object.
  27444. * @param {String} languageCode Language code for specific language i.e. 'en-US', 'pt-BR', 'de-DE'.
  27445. * @returns {String}
  27446. */
  27447. function applyLanguageSetting(settings, languageCode) {
  27448. var normalizedLanguageCode = normalizeLanguageCode(languageCode);
  27449. if ((0, _dictionariesManager.hasLanguageDictionary)(normalizedLanguageCode)) {
  27450. settings.language = normalizedLanguageCode;
  27451. } else {
  27452. settings.language = _dictionariesManager.DEFAULT_LANGUAGE_CODE;
  27453. warnUserAboutLanguageRegistration(languageCode);
  27454. }
  27455. }
  27456. /**
  27457. *
  27458. * Warn user if there is no registered language.
  27459. *
  27460. * @param {String} languageCode Language code for specific language i.e. 'en-US', 'pt-BR', 'de-DE'.
  27461. */
  27462. function warnUserAboutLanguageRegistration(languageCode) {
  27463. if ((0, _mixed.isDefined)(languageCode)) {
  27464. (0, _console.error)((0, _templateLiteralTag.toSingleLine)(_templateObject, languageCode));
  27465. }
  27466. }
  27467. /***/ }),
  27468. /* 318 */
  27469. /***/ (function(module, exports, __webpack_require__) {
  27470. "use strict";
  27471. exports.__esModule = true;
  27472. exports.stopObserving = exports.startObserving = exports.isPressedCtrlKey = exports.isPressed = exports._resetState = exports._getRefCount = undefined;
  27473. var _eventManager = __webpack_require__(6);
  27474. var _eventManager2 = _interopRequireDefault(_eventManager);
  27475. var _unicode = __webpack_require__(21);
  27476. var _array = __webpack_require__(1);
  27477. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  27478. var eventManager = new _eventManager2.default();
  27479. var pressedKeys = new Set();
  27480. var refCount = 0;
  27481. /**
  27482. * Begins observing keyboard keys states.
  27483. */
  27484. function startObserving() {
  27485. if (refCount === 0) {
  27486. eventManager.addEventListener(document, 'keydown', function (event) {
  27487. if (!pressedKeys.has(event.keyCode)) {
  27488. pressedKeys.add(event.keyCode);
  27489. }
  27490. });
  27491. eventManager.addEventListener(document, 'keyup', function (event) {
  27492. if (pressedKeys.has(event.keyCode)) {
  27493. pressedKeys.delete(event.keyCode);
  27494. }
  27495. });
  27496. eventManager.addEventListener(document, 'visibilitychange', function () {
  27497. if (document.hidden) {
  27498. pressedKeys.clear();
  27499. }
  27500. });
  27501. }
  27502. refCount += 1;
  27503. }
  27504. /**
  27505. * Stops observing keyboard keys states and clear all previously saved states.
  27506. */
  27507. function stopObserving() {
  27508. if (refCount > 0) {
  27509. refCount -= 1;
  27510. }
  27511. if (refCount === 0) {
  27512. _resetState();
  27513. }
  27514. }
  27515. /**
  27516. * Remove all listeners attached to the DOM and clear all previously saved states.
  27517. */
  27518. function _resetState() {
  27519. eventManager.clearEvents();
  27520. pressedKeys.clear();
  27521. refCount = 0;
  27522. }
  27523. /**
  27524. * Checks if provided keyCode or keyCodes are pressed.
  27525. *
  27526. * @param {String} keyCodes The key codes passed as a string defined in helpers/unicode.js file delimited with '|'.
  27527. * @return {Boolean}
  27528. */
  27529. function isPressed(keyCodes) {
  27530. return Array.from(pressedKeys.values()).some(function (_keyCode) {
  27531. return (0, _unicode.isKey)(_keyCode, keyCodes);
  27532. });
  27533. }
  27534. /**
  27535. * Checks if ctrl keys are pressed.
  27536. *
  27537. * @return {Boolean}
  27538. */
  27539. function isPressedCtrlKey() {
  27540. return Array.from(pressedKeys.values()).some(function (_keyCode) {
  27541. return (0, _unicode.isCtrlMetaKey)(_keyCode);
  27542. });
  27543. }
  27544. /**
  27545. * Returns reference count. Useful for debugging and testing purposes.
  27546. *
  27547. * @return {Number}
  27548. */
  27549. function _getRefCount() {
  27550. return refCount;
  27551. }
  27552. exports._getRefCount = _getRefCount;
  27553. exports._resetState = _resetState;
  27554. exports.isPressed = isPressed;
  27555. exports.isPressedCtrlKey = isPressedCtrlKey;
  27556. exports.startObserving = startObserving;
  27557. exports.stopObserving = stopObserving;
  27558. /***/ }),
  27559. /* 319 */
  27560. /***/ (function(module, exports, __webpack_require__) {
  27561. "use strict";
  27562. exports.__esModule = true;
  27563. exports.HEADER_TYPE = exports.FILL_TYPE = exports.CELL_TYPE = exports.AREA_TYPE = exports.ACTIVE_HEADER_TYPE = undefined;
  27564. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  27565. var _types = __webpack_require__(395);
  27566. var _array = __webpack_require__(1);
  27567. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  27568. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  27569. var ACTIVE_HEADER_TYPE = exports.ACTIVE_HEADER_TYPE = 'active-header';
  27570. var AREA_TYPE = exports.AREA_TYPE = 'area';
  27571. var CELL_TYPE = exports.CELL_TYPE = 'cell';
  27572. var FILL_TYPE = exports.FILL_TYPE = 'fill';
  27573. var HEADER_TYPE = exports.HEADER_TYPE = 'header';
  27574. /**
  27575. * Highlight class responsible for managing Walkontable Selection classes.
  27576. *
  27577. * With Highlight object you can manipulate four different highlight types:
  27578. * - `cell` can be added only to a single cell at a time and it defines currently selected cell;
  27579. * - `fill` can occur only once and its highlight defines selection of autofill functionality (managed by the plugin with the same name);
  27580. * - `areas` can be added to multiple cells at a time. This type highlights selected cell or multiple cells.
  27581. * The multiple cells have to be defined as an uninterrupted order (regular shape). Otherwise, the new layer of
  27582. * that type should be created to manage not-consecutive selection;
  27583. * - `header` can occur multiple times. This type is designed to highlight only headers. Like `area` type it
  27584. * can appear with multiple highlights (accessed under different level layers).
  27585. *
  27586. * @class Highlight
  27587. * @util
  27588. */
  27589. var Highlight = function () {
  27590. function Highlight(options) {
  27591. _classCallCheck(this, Highlight);
  27592. /**
  27593. * Options consumed by Highlight class and Walkontable Selection classes.
  27594. *
  27595. * @type {Object}
  27596. */
  27597. this.options = options;
  27598. /**
  27599. * The property which describes which layer level of the visual selection will be modified.
  27600. * This option is valid only for `area` and `header` highlight types which occurs multiple times on
  27601. * the table (as a non-consecutive selection).
  27602. *
  27603. * An order of the layers is the same as the order of added new non-consecutive selections.
  27604. *
  27605. * @type {Number}
  27606. * @default 0
  27607. */
  27608. this.layerLevel = 0;
  27609. /**
  27610. * `cell` highlight object which describes attributes for the currently selected cell.
  27611. * It can only occur only once on the table.
  27612. *
  27613. * @type {Selection}
  27614. */
  27615. this.cell = (0, _types.createHighlight)(CELL_TYPE, options);
  27616. /**
  27617. * `fill` highlight object which describes attributes for the borders for autofill functionality.
  27618. * It can only occur only once on the table.
  27619. *
  27620. * @type {Selection}
  27621. */
  27622. this.fill = (0, _types.createHighlight)(FILL_TYPE, options);
  27623. /**
  27624. * Collection of the `area` highlights. That objects describes attributes for the borders and selection of
  27625. * the multiple selected cells. It can occur multiple times on the table.
  27626. *
  27627. * @type {Map.<number, Selection>}
  27628. */
  27629. this.areas = new Map();
  27630. /**
  27631. * Collection of the `header` highlights. That objects describes attributes for the selection of
  27632. * the multiple selected rows and columns in the table header. It can occur multiple times on the table.
  27633. *
  27634. * @type {Map.<number, Selection>}
  27635. */
  27636. this.headers = new Map();
  27637. /**
  27638. * Collection of the `active-header` highlights. That objects describes attributes for the selection of
  27639. * the multiple selected rows and columns in the table header. The table headers which have selected all items in
  27640. * a row will be marked as `active-header`.
  27641. *
  27642. * @type {Map.<number, Selection>}
  27643. */
  27644. this.activeHeaders = new Map();
  27645. /**
  27646. * The temporary property, holder for borders added through CustomBorders plugin.
  27647. *
  27648. * @type {Selection[]}
  27649. */
  27650. this.borders = [];
  27651. }
  27652. /**
  27653. * Check if highlight cell rendering is disabled for specyfied highlight type.
  27654. *
  27655. * @param {String} highlightType Highlight type. Possible values are: `cell`, `area`, `fill` or `header`.
  27656. * @return {Boolean}
  27657. */
  27658. _createClass(Highlight, [{
  27659. key: 'isEnabledFor',
  27660. value: function isEnabledFor(highlightType) {
  27661. var disableHighlight = this.options.disableHighlight;
  27662. // Legacy compatibility.
  27663. if (highlightType === 'current') {
  27664. highlightType = CELL_TYPE;
  27665. }
  27666. if (typeof disableHighlight === 'string') {
  27667. disableHighlight = [disableHighlight];
  27668. }
  27669. return disableHighlight === false || Array.isArray(disableHighlight) && !disableHighlight.includes(highlightType);
  27670. }
  27671. /**
  27672. * Set a new layer level to make access to the desire `area` and `header` highlights.
  27673. *
  27674. * @param {Number} [level=0] Layer level to use.
  27675. * @returns {Highlight}
  27676. */
  27677. }, {
  27678. key: 'useLayerLevel',
  27679. value: function useLayerLevel() {
  27680. var level = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  27681. this.layerLevel = level;
  27682. return this;
  27683. }
  27684. /**
  27685. * Get Walkontable Selection instance created for controlling highlight of the currently selected/edited cell.
  27686. *
  27687. * @return {Selection}
  27688. */
  27689. }, {
  27690. key: 'getCell',
  27691. value: function getCell() {
  27692. return this.cell;
  27693. }
  27694. /**
  27695. * Get Walkontable Selection instance created for controlling highlight of the autofill functionality.
  27696. *
  27697. * @return {Selection}
  27698. */
  27699. }, {
  27700. key: 'getFill',
  27701. value: function getFill() {
  27702. return this.fill;
  27703. }
  27704. /**
  27705. * Get or create (if not exist in the cache) Walkontable Selection instance created for controlling highlight
  27706. * of the multiple selected cells.
  27707. *
  27708. * @return {Selection}
  27709. */
  27710. }, {
  27711. key: 'createOrGetArea',
  27712. value: function createOrGetArea() {
  27713. var layerLevel = this.layerLevel;
  27714. var area = void 0;
  27715. if (this.areas.has(layerLevel)) {
  27716. area = this.areas.get(layerLevel);
  27717. } else {
  27718. area = (0, _types.createHighlight)(AREA_TYPE, Object.assign({ layerLevel: layerLevel }, this.options));
  27719. this.areas.set(layerLevel, area);
  27720. }
  27721. return area;
  27722. }
  27723. /**
  27724. * Get all Walkontable Selection instances which describes the state of the visual highlight of the cells.
  27725. *
  27726. * @return {Selection[]}
  27727. */
  27728. }, {
  27729. key: 'getAreas',
  27730. value: function getAreas() {
  27731. return [].concat(_toConsumableArray(this.areas.values()));
  27732. }
  27733. /**
  27734. * Get or create (if not exist in the cache) Walkontable Selection instance created for controlling highlight
  27735. * of the multiple selected header cells.
  27736. *
  27737. * @return {Selection}
  27738. */
  27739. }, {
  27740. key: 'createOrGetHeader',
  27741. value: function createOrGetHeader() {
  27742. var layerLevel = this.layerLevel;
  27743. var header = void 0;
  27744. if (this.headers.has(layerLevel)) {
  27745. header = this.headers.get(layerLevel);
  27746. } else {
  27747. header = (0, _types.createHighlight)(HEADER_TYPE, Object.assign({}, this.options));
  27748. this.headers.set(layerLevel, header);
  27749. }
  27750. return header;
  27751. }
  27752. /**
  27753. * Get all Walkontable Selection instances which describes the state of the visual highlight of the headers.
  27754. *
  27755. * @return {Selection[]}
  27756. */
  27757. }, {
  27758. key: 'getHeaders',
  27759. value: function getHeaders() {
  27760. return [].concat(_toConsumableArray(this.headers.values()));
  27761. }
  27762. /**
  27763. * Get or create (if not exist in the cache) Walkontable Selection instance created for controlling highlight
  27764. * of the multiple selected active header cells.
  27765. *
  27766. * @return {Selection}
  27767. */
  27768. }, {
  27769. key: 'createOrGetActiveHeader',
  27770. value: function createOrGetActiveHeader() {
  27771. var layerLevel = this.layerLevel;
  27772. var header = void 0;
  27773. if (this.activeHeaders.has(layerLevel)) {
  27774. header = this.activeHeaders.get(layerLevel);
  27775. } else {
  27776. header = (0, _types.createHighlight)(ACTIVE_HEADER_TYPE, Object.assign({}, this.options));
  27777. this.activeHeaders.set(layerLevel, header);
  27778. }
  27779. return header;
  27780. }
  27781. /**
  27782. * Get all Walkontable Selection instances which describes the state of the visual highlight of the active headers.
  27783. *
  27784. * @return {Selection[]}
  27785. */
  27786. }, {
  27787. key: 'getActiveHeaders',
  27788. value: function getActiveHeaders() {
  27789. return [].concat(_toConsumableArray(this.activeHeaders.values()));
  27790. }
  27791. /**
  27792. * Perform cleaning visual highlights for the whole table.
  27793. */
  27794. }, {
  27795. key: 'clear',
  27796. value: function clear() {
  27797. this.cell.clear();
  27798. this.fill.clear();
  27799. (0, _array.arrayEach)(this.areas.values(), function (highlight) {
  27800. return void highlight.clear();
  27801. });
  27802. (0, _array.arrayEach)(this.headers.values(), function (highlight) {
  27803. return void highlight.clear();
  27804. });
  27805. (0, _array.arrayEach)(this.activeHeaders.values(), function (highlight) {
  27806. return void highlight.clear();
  27807. });
  27808. }
  27809. /**
  27810. * This object can be iterate over using `for of` syntax or using internal `arrayEach` helper.
  27811. */
  27812. }, {
  27813. key: Symbol.iterator,
  27814. value: function value() {
  27815. return [this.cell, this.fill].concat(_toConsumableArray(this.areas.values()), _toConsumableArray(this.headers.values()), _toConsumableArray(this.activeHeaders.values()), _toConsumableArray(this.borders))[Symbol.iterator]();
  27816. }
  27817. }]);
  27818. return Highlight;
  27819. }();
  27820. exports.default = Highlight;
  27821. /***/ }),
  27822. /* 320 */
  27823. /***/ (function(module, exports, __webpack_require__) {
  27824. "use strict";
  27825. exports.__esModule = true;
  27826. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  27827. var _object = __webpack_require__(2);
  27828. var _number = __webpack_require__(5);
  27829. var _mixed = __webpack_require__(16);
  27830. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  27831. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  27832. /**
  27833. * @class SamplesGenerator
  27834. * @util
  27835. */
  27836. var SamplesGenerator = function () {
  27837. _createClass(SamplesGenerator, null, [{
  27838. key: 'SAMPLE_COUNT',
  27839. /**
  27840. * Number of samples to take of each value length.
  27841. *
  27842. * @type {Number}
  27843. */
  27844. get: function get() {
  27845. return 3;
  27846. }
  27847. }]);
  27848. function SamplesGenerator(dataFactory) {
  27849. _classCallCheck(this, SamplesGenerator);
  27850. /**
  27851. * Samples prepared for calculations.
  27852. *
  27853. * @type {Map}
  27854. * @default {null}
  27855. */
  27856. this.samples = null;
  27857. /**
  27858. * Function which give the data to collect samples.
  27859. *
  27860. * @type {Function}
  27861. */
  27862. this.dataFactory = dataFactory;
  27863. /**
  27864. * Custom number of samples to take of each value length.
  27865. *
  27866. * @type {Number}
  27867. * @default {null}
  27868. */
  27869. this.customSampleCount = null;
  27870. /**
  27871. * `true` if duplicate samples collection should be allowed, `false` otherwise.
  27872. *
  27873. * @type {Boolean}
  27874. * @default {false}
  27875. */
  27876. this.allowDuplicates = false;
  27877. }
  27878. /**
  27879. * Get the sample count for this instance.
  27880. *
  27881. * @returns {Number}
  27882. */
  27883. _createClass(SamplesGenerator, [{
  27884. key: 'getSampleCount',
  27885. value: function getSampleCount() {
  27886. if (this.customSampleCount) {
  27887. return this.customSampleCount;
  27888. }
  27889. return SamplesGenerator.SAMPLE_COUNT;
  27890. }
  27891. }, {
  27892. key: 'setSampleCount',
  27893. /**
  27894. * Set the sample count.
  27895. *
  27896. * @param {Number} sampleCount Number of samples to be collected.
  27897. */
  27898. value: function setSampleCount(sampleCount) {
  27899. this.customSampleCount = sampleCount;
  27900. }
  27901. /**
  27902. * Set if the generator should accept duplicate values.
  27903. *
  27904. * @param {Boolean} allowDuplicates `true` to allow duplicate values.
  27905. */
  27906. }, {
  27907. key: 'setAllowDuplicates',
  27908. value: function setAllowDuplicates(allowDuplicates) {
  27909. this.allowDuplicates = allowDuplicates;
  27910. }
  27911. /**
  27912. * Generate samples for row. You can control which area should be sampled by passing `rowRange` object and `colRange` object.
  27913. *
  27914. * @param {Object|Number} rowRange
  27915. * @param {Object} colRange
  27916. * @returns {Object}
  27917. */
  27918. }, {
  27919. key: 'generateRowSamples',
  27920. value: function generateRowSamples(rowRange, colRange) {
  27921. return this.generateSamples('row', colRange, rowRange);
  27922. }
  27923. /**
  27924. * Generate samples for column. You can control which area should be sampled by passing `colRange` object and `rowRange` object.
  27925. *
  27926. * @param {Object} colRange Column index.
  27927. * @param {Object} rowRange Column index.
  27928. * @returns {Object}
  27929. */
  27930. }, {
  27931. key: 'generateColumnSamples',
  27932. value: function generateColumnSamples(colRange, rowRange) {
  27933. return this.generateSamples('col', rowRange, colRange);
  27934. }
  27935. /**
  27936. * Generate collection of samples.
  27937. *
  27938. * @param {String} type Type to generate. Can be `col` or `row`.
  27939. * @param {Object} range
  27940. * @param {Object|Number} specifierRange
  27941. * @returns {Map}
  27942. */
  27943. }, {
  27944. key: 'generateSamples',
  27945. value: function generateSamples(type, range, specifierRange) {
  27946. var _this = this;
  27947. var samples = new Map();
  27948. if (typeof specifierRange === 'number') {
  27949. specifierRange = { from: specifierRange, to: specifierRange };
  27950. }
  27951. (0, _number.rangeEach)(specifierRange.from, specifierRange.to, function (index) {
  27952. var sample = _this.generateSample(type, range, index);
  27953. samples.set(index, sample);
  27954. });
  27955. return samples;
  27956. }
  27957. /**
  27958. * Generate sample for specified type (`row` or `col`).
  27959. *
  27960. * @param {String} type Samples type `row` or `col`.
  27961. * @param {Object} range
  27962. * @param {Number} specifierValue
  27963. * @returns {Map}
  27964. */
  27965. }, {
  27966. key: 'generateSample',
  27967. value: function generateSample(type, range, specifierValue) {
  27968. var _this2 = this;
  27969. var samples = new Map();
  27970. var sampledValues = [];
  27971. var length = void 0;
  27972. (0, _number.rangeEach)(range.from, range.to, function (index) {
  27973. var value = void 0;
  27974. if (type === 'row') {
  27975. value = _this2.dataFactory(specifierValue, index);
  27976. } else if (type === 'col') {
  27977. value = _this2.dataFactory(index, specifierValue);
  27978. } else {
  27979. throw new Error('Unsupported sample type');
  27980. }
  27981. if ((0, _object.isObject)(value)) {
  27982. length = Object.keys(value).length;
  27983. } else if (Array.isArray(value)) {
  27984. length = value.length;
  27985. } else {
  27986. length = (0, _mixed.stringify)(value).length;
  27987. }
  27988. if (!samples.has(length)) {
  27989. samples.set(length, {
  27990. needed: _this2.getSampleCount(),
  27991. strings: []
  27992. });
  27993. }
  27994. var sample = samples.get(length);
  27995. if (sample.needed) {
  27996. var duplicate = sampledValues.indexOf(value) > -1;
  27997. if (!duplicate || _this2.allowDuplicates) {
  27998. var computedKey = type === 'row' ? 'col' : 'row';
  27999. sample.strings.push(_defineProperty({ value: value }, computedKey, index));
  28000. sampledValues.push(value);
  28001. sample.needed--;
  28002. }
  28003. }
  28004. });
  28005. return samples;
  28006. }
  28007. }]);
  28008. return SamplesGenerator;
  28009. }();
  28010. exports.default = SamplesGenerator;
  28011. /***/ }),
  28012. /* 321 */
  28013. /***/ (function(module, exports, __webpack_require__) {
  28014. "use strict";
  28015. exports.__esModule = true;
  28016. var _array = __webpack_require__(1);
  28017. var _object = __webpack_require__(2);
  28018. var _number = __webpack_require__(5);
  28019. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  28020. var MIXIN_NAME = 'arrayMapper';
  28021. /**
  28022. * @type {Object}
  28023. */
  28024. var arrayMapper = {
  28025. _arrayMap: [],
  28026. /**
  28027. * Get translated index by its physical index.
  28028. *
  28029. * @param {Number} physicalIndex Physical index.
  28030. * @return {Number|null} Returns translated index mapped by passed physical index.
  28031. */
  28032. getValueByIndex: function getValueByIndex(physicalIndex) {
  28033. var length = this._arrayMap.length;
  28034. var translatedIndex = null;
  28035. if (physicalIndex < length) {
  28036. translatedIndex = this._arrayMap[physicalIndex];
  28037. }
  28038. return translatedIndex;
  28039. },
  28040. /**
  28041. * Get physical index by its translated index.
  28042. *
  28043. * @param {*} translatedIndex Value to search.
  28044. * @returns {Number|null} Returns a physical index of the array mapper.
  28045. */
  28046. getIndexByValue: function getIndexByValue(translatedIndex) {
  28047. var physicalIndex = void 0;
  28048. // eslint-disable-next-line no-cond-assign, no-return-assign
  28049. return (physicalIndex = this._arrayMap.indexOf(translatedIndex)) === -1 ? null : physicalIndex;
  28050. },
  28051. /**
  28052. * Insert new items to array mapper starting at passed index. New entries will be a continuation of last value in the array.
  28053. *
  28054. * @param {Number} physicalIndex Array index.
  28055. * @param {Number} [amount=1] Defines how many items will be created to an array.
  28056. * @returns {Array} Returns added items.
  28057. */
  28058. insertItems: function insertItems(physicalIndex) {
  28059. var _this = this;
  28060. var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  28061. var newIndex = (0, _array.arrayMax)(this._arrayMap) + 1;
  28062. var addedItems = [];
  28063. (0, _number.rangeEach)(amount - 1, function (count) {
  28064. addedItems.push(_this._arrayMap.splice(physicalIndex + count, 0, newIndex + count));
  28065. });
  28066. return addedItems;
  28067. },
  28068. /**
  28069. * Remove items from array mapper.
  28070. *
  28071. * @param {Number} physicalIndex Array index.
  28072. * @param {Number} [amount=1] Defines how many items will be created to an array.
  28073. * @returns {Array} Returns removed items.
  28074. */
  28075. removeItems: function removeItems(physicalIndex) {
  28076. var _this2 = this;
  28077. var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  28078. var removedItems = [];
  28079. if (Array.isArray(physicalIndex)) {
  28080. var mapCopy = [].concat(this._arrayMap);
  28081. // Sort descending
  28082. physicalIndex.sort(function (a, b) {
  28083. return b - a;
  28084. });
  28085. removedItems = (0, _array.arrayReduce)(physicalIndex, function (acc, item) {
  28086. _this2._arrayMap.splice(item, 1);
  28087. return acc.concat(mapCopy.slice(item, item + 1));
  28088. }, []);
  28089. } else {
  28090. removedItems = this._arrayMap.splice(physicalIndex, amount);
  28091. }
  28092. return removedItems;
  28093. },
  28094. /**
  28095. * Unshift items (remove and shift chunk of array to the left).
  28096. *
  28097. * @param {Number|Array} physicalIndex Array index or Array of indexes to unshift.
  28098. * @param {Number} [amount=1] Defines how many items will be removed from an array (when index is passed as number).
  28099. */
  28100. unshiftItems: function unshiftItems(physicalIndex) {
  28101. var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  28102. var removedItems = this.removeItems(physicalIndex, amount);
  28103. function countRowShift(logicalRow) {
  28104. // Todo: compare perf between reduce vs sort->each->brake
  28105. return (0, _array.arrayReduce)(removedItems, function (count, removedLogicalRow) {
  28106. if (logicalRow > removedLogicalRow) {
  28107. count++;
  28108. }
  28109. return count;
  28110. }, 0);
  28111. }
  28112. this._arrayMap = (0, _array.arrayMap)(this._arrayMap, function (logicalRow, physicalRow) {
  28113. var rowShift = countRowShift(logicalRow);
  28114. if (rowShift) {
  28115. logicalRow -= rowShift;
  28116. }
  28117. return logicalRow;
  28118. });
  28119. },
  28120. /**
  28121. * Shift (right shifting) items starting at passed index.
  28122. *
  28123. * @param {Number} physicalIndex Array index.
  28124. * @param {Number} [amount=1] Defines how many items will be created to an array.
  28125. */
  28126. shiftItems: function shiftItems(physicalIndex) {
  28127. var _this3 = this;
  28128. var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  28129. this._arrayMap = (0, _array.arrayMap)(this._arrayMap, function (row) {
  28130. if (row >= physicalIndex) {
  28131. row += amount;
  28132. }
  28133. return row;
  28134. });
  28135. (0, _number.rangeEach)(amount - 1, function (count) {
  28136. _this3._arrayMap.splice(physicalIndex + count, 0, physicalIndex + count);
  28137. });
  28138. },
  28139. /**
  28140. * Swap indexes in arrayMapper.
  28141. *
  28142. * @param {Number} physicalIndexFrom index to move.
  28143. * @param {Number} physicalIndexTo index to.
  28144. */
  28145. swapIndexes: function swapIndexes(physicalIndexFrom, physicalIndexTo) {
  28146. var _arrayMap;
  28147. (_arrayMap = this._arrayMap).splice.apply(_arrayMap, [physicalIndexTo, 0].concat(_toConsumableArray(this._arrayMap.splice(physicalIndexFrom, 1))));
  28148. },
  28149. /**
  28150. * Clear all stored index<->value information from an array.
  28151. */
  28152. clearMap: function clearMap() {
  28153. this._arrayMap.length = 0;
  28154. }
  28155. };
  28156. (0, _object.defineGetter)(arrayMapper, 'MIXIN_NAME', MIXIN_NAME, {
  28157. writable: false,
  28158. enumerable: false
  28159. });
  28160. exports.default = arrayMapper;
  28161. /***/ }),
  28162. /* 322 */
  28163. /***/ (function(module, exports, __webpack_require__) {
  28164. "use strict";
  28165. exports.__esModule = true;
  28166. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  28167. var _number = __webpack_require__(5);
  28168. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  28169. var STATE_INITIALIZED = 0;
  28170. var STATE_BUILT = 1;
  28171. var STATE_APPENDED = 2;
  28172. var UNIT = 'px';
  28173. /**
  28174. * @class
  28175. * @private
  28176. */
  28177. var BaseUI = function () {
  28178. function BaseUI(hotInstance) {
  28179. _classCallCheck(this, BaseUI);
  28180. /**
  28181. * Instance of Handsontable.
  28182. *
  28183. * @type {Core}
  28184. */
  28185. this.hot = hotInstance;
  28186. /**
  28187. * DOM element representing the ui element.
  28188. *
  28189. * @type {HTMLElement}
  28190. * @private
  28191. */
  28192. this._element = null;
  28193. /**
  28194. * Flag which determines build state of element.
  28195. *
  28196. * @type {Boolean}
  28197. */
  28198. this.state = STATE_INITIALIZED;
  28199. }
  28200. /**
  28201. * Add created UI elements to table.
  28202. *
  28203. * @param {HTMLElement} wrapper Element which are parent for our UI element.
  28204. */
  28205. _createClass(BaseUI, [{
  28206. key: 'appendTo',
  28207. value: function appendTo(wrapper) {
  28208. wrapper.appendChild(this._element);
  28209. this.state = STATE_APPENDED;
  28210. }
  28211. /**
  28212. * Method for create UI element. Only create, without append to table.
  28213. */
  28214. }, {
  28215. key: 'build',
  28216. value: function build() {
  28217. this._element = document.createElement('div');
  28218. this.state = STATE_BUILT;
  28219. }
  28220. /**
  28221. * Method for remove UI element.
  28222. */
  28223. }, {
  28224. key: 'destroy',
  28225. value: function destroy() {
  28226. if (this.isAppended()) {
  28227. this._element.parentElement.removeChild(this._element);
  28228. }
  28229. this._element = null;
  28230. this.state = STATE_INITIALIZED;
  28231. }
  28232. /**
  28233. * Check if UI element are appended.
  28234. *
  28235. * @returns {Boolean}
  28236. */
  28237. }, {
  28238. key: 'isAppended',
  28239. value: function isAppended() {
  28240. return this.state === STATE_APPENDED;
  28241. }
  28242. /**
  28243. * Check if UI element are built.
  28244. *
  28245. * @returns {Boolean}
  28246. */
  28247. }, {
  28248. key: 'isBuilt',
  28249. value: function isBuilt() {
  28250. return this.state >= STATE_BUILT;
  28251. }
  28252. /**
  28253. * Setter for position.
  28254. *
  28255. * @param {Number} top New top position of the element.
  28256. * @param {Number} left New left position of the element.
  28257. */
  28258. }, {
  28259. key: 'setPosition',
  28260. value: function setPosition(top, left) {
  28261. if ((0, _number.isNumeric)(top)) {
  28262. this._element.style.top = top + UNIT;
  28263. }
  28264. if ((0, _number.isNumeric)(left)) {
  28265. this._element.style.left = left + UNIT;
  28266. }
  28267. }
  28268. /**
  28269. * Getter for the element position.
  28270. *
  28271. * @returns {Object} Object contains left and top position of the element.
  28272. */
  28273. }, {
  28274. key: 'getPosition',
  28275. value: function getPosition() {
  28276. return {
  28277. top: this._element.style.top ? parseInt(this._element.style.top, 10) : 0,
  28278. left: this._element.style.left ? parseInt(this._element.style.left, 10) : 0
  28279. };
  28280. }
  28281. /**
  28282. * Setter for the element size.
  28283. *
  28284. * @param {Number} width New width of the element.
  28285. * @param {Number} height New height of the element.
  28286. */
  28287. }, {
  28288. key: 'setSize',
  28289. value: function setSize(width, height) {
  28290. if ((0, _number.isNumeric)(width)) {
  28291. this._element.style.width = width + UNIT;
  28292. }
  28293. if ((0, _number.isNumeric)(height)) {
  28294. this._element.style.height = height + UNIT;
  28295. }
  28296. }
  28297. /**
  28298. * Getter for the element position.
  28299. *
  28300. * @returns {Object} Object contains height and width of the element.
  28301. */
  28302. }, {
  28303. key: 'getSize',
  28304. value: function getSize() {
  28305. return {
  28306. width: this._element.style.width ? parseInt(this._element.style.width, 10) : 0,
  28307. height: this._element.style.height ? parseInt(this._element.style.height, 10) : 0
  28308. };
  28309. }
  28310. /**
  28311. * Setter for the element offset. Offset means marginTop and marginLeft of the element.
  28312. *
  28313. * @param {Number} top New margin top of the element.
  28314. * @param {Number} left New margin left of the element.
  28315. */
  28316. }, {
  28317. key: 'setOffset',
  28318. value: function setOffset(top, left) {
  28319. if ((0, _number.isNumeric)(top)) {
  28320. this._element.style.marginTop = top + UNIT;
  28321. }
  28322. if ((0, _number.isNumeric)(left)) {
  28323. this._element.style.marginLeft = left + UNIT;
  28324. }
  28325. }
  28326. /**
  28327. * Getter for the element offset.
  28328. *
  28329. * @returns {Object} Object contains top and left offset of the element.
  28330. */
  28331. }, {
  28332. key: 'getOffset',
  28333. value: function getOffset() {
  28334. return {
  28335. top: this._element.style.marginTop ? parseInt(this._element.style.marginTop, 10) : 0,
  28336. left: this._element.style.marginLeft ? parseInt(this._element.style.marginLeft, 10) : 0
  28337. };
  28338. }
  28339. }]);
  28340. return BaseUI;
  28341. }();
  28342. exports.default = BaseUI;
  28343. /***/ }),
  28344. /* 323 */
  28345. /***/ (function(module, exports, __webpack_require__) {
  28346. "use strict";
  28347. exports.__esModule = true;
  28348. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  28349. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  28350. var STATE_INITIALIZED = 0;
  28351. var STATE_BUILT = 1;
  28352. var STATE_APPENDED = 2;
  28353. var UNIT = 'px';
  28354. /**
  28355. * @class
  28356. * @private
  28357. */
  28358. var BaseUI = function () {
  28359. function BaseUI(hotInstance) {
  28360. _classCallCheck(this, BaseUI);
  28361. /**
  28362. * Instance of Handsontable.
  28363. *
  28364. * @type {Core}
  28365. */
  28366. this.hot = hotInstance;
  28367. /**
  28368. * DOM element representing the ui element.
  28369. *
  28370. * @type {HTMLElement}
  28371. * @private
  28372. */
  28373. this._element = null;
  28374. /**
  28375. * Flag which determines build state of element.
  28376. *
  28377. * @type {Boolean}
  28378. */
  28379. this.state = STATE_INITIALIZED;
  28380. }
  28381. /**
  28382. * Add created UI elements to table.
  28383. *
  28384. * @param {HTMLElement} wrapper Element which are parent for our UI element.
  28385. */
  28386. _createClass(BaseUI, [{
  28387. key: 'appendTo',
  28388. value: function appendTo(wrapper) {
  28389. wrapper.appendChild(this._element);
  28390. this.state = STATE_APPENDED;
  28391. }
  28392. /**
  28393. * Method for create UI element. Only create, without append to table.
  28394. */
  28395. }, {
  28396. key: 'build',
  28397. value: function build() {
  28398. this._element = document.createElement('div');
  28399. this.state = STATE_BUILT;
  28400. }
  28401. /**
  28402. * Method for remove UI element.
  28403. */
  28404. }, {
  28405. key: 'destroy',
  28406. value: function destroy() {
  28407. if (this.isAppended()) {
  28408. this._element.parentElement.removeChild(this._element);
  28409. }
  28410. this._element = null;
  28411. this.state = STATE_INITIALIZED;
  28412. }
  28413. /**
  28414. * Check if UI element are appended.
  28415. *
  28416. * @returns {Boolean}
  28417. */
  28418. }, {
  28419. key: 'isAppended',
  28420. value: function isAppended() {
  28421. return this.state === STATE_APPENDED;
  28422. }
  28423. /**
  28424. * Check if UI element are built.
  28425. *
  28426. * @returns {Boolean}
  28427. */
  28428. }, {
  28429. key: 'isBuilt',
  28430. value: function isBuilt() {
  28431. return this.state >= STATE_BUILT;
  28432. }
  28433. /**
  28434. * Setter for position.
  28435. *
  28436. * @param {Number} top New top position of the element.
  28437. * @param {Number} left New left position of the element.
  28438. */
  28439. }, {
  28440. key: 'setPosition',
  28441. value: function setPosition(top, left) {
  28442. if (top !== void 0) {
  28443. this._element.style.top = top + UNIT;
  28444. }
  28445. if (left !== void 0) {
  28446. this._element.style.left = left + UNIT;
  28447. }
  28448. }
  28449. /**
  28450. * Getter for the element position.
  28451. *
  28452. * @returns {Object} Object contains left and top position of the element.
  28453. */
  28454. }, {
  28455. key: 'getPosition',
  28456. value: function getPosition() {
  28457. return {
  28458. top: this._element.style.top ? parseInt(this._element.style.top, 10) : 0,
  28459. left: this._element.style.left ? parseInt(this._element.style.left, 10) : 0
  28460. };
  28461. }
  28462. /**
  28463. * Setter for the element size.
  28464. *
  28465. * @param {Number} width New width of the element.
  28466. * @param {Number} height New height of the element.
  28467. */
  28468. }, {
  28469. key: 'setSize',
  28470. value: function setSize(width, height) {
  28471. if (width) {
  28472. this._element.style.width = width + UNIT;
  28473. }
  28474. if (height) {
  28475. this._element.style.height = height + UNIT;
  28476. }
  28477. }
  28478. /**
  28479. * Getter for the element position.
  28480. *
  28481. * @returns {Object} Object contains height and width of the element.
  28482. */
  28483. }, {
  28484. key: 'getSize',
  28485. value: function getSize() {
  28486. return {
  28487. width: this._element.style.width ? parseInt(this._element.style.width, 10) : 0,
  28488. height: this._element.style.height ? parseInt(this._element.style.height, 10) : 0
  28489. };
  28490. }
  28491. /**
  28492. * Setter for the element offset. Offset means marginTop and marginLeft of the element.
  28493. *
  28494. * @param {Number} top New margin top of the element.
  28495. * @param {Number} left New margin left of the element.
  28496. */
  28497. }, {
  28498. key: 'setOffset',
  28499. value: function setOffset(top, left) {
  28500. if (top) {
  28501. this._element.style.marginTop = top + UNIT;
  28502. }
  28503. if (left) {
  28504. this._element.style.marginLeft = left + UNIT;
  28505. }
  28506. }
  28507. /**
  28508. * Getter for the element offset.
  28509. *
  28510. * @returns {Object} Object contains top and left offset of the element.
  28511. */
  28512. }, {
  28513. key: 'getOffset',
  28514. value: function getOffset() {
  28515. return {
  28516. top: this._element.style.marginTop ? parseInt(this._element.style.marginTop, 10) : 0,
  28517. left: this._element.style.marginLeft ? parseInt(this._element.style.marginLeft, 10) : 0
  28518. };
  28519. }
  28520. }]);
  28521. return BaseUI;
  28522. }();
  28523. exports.default = BaseUI;
  28524. /***/ }),
  28525. /* 324 */
  28526. /***/ (function(module, exports, __webpack_require__) {
  28527. "use strict";
  28528. exports.__esModule = true;
  28529. exports.applySpanProperties = applySpanProperties;
  28530. /**
  28531. * Apply the `colspan`/`rowspan` properties.
  28532. *
  28533. * @param {HTMLElement} TD The soon-to-be-modified cell.
  28534. * @param {MergedCellCoords} merged cellInfo The merged cell in question.
  28535. * @param {Number} row Row index.
  28536. * @param {Number} col Column index.
  28537. */
  28538. // eslint-disable-next-line import/prefer-default-export
  28539. function applySpanProperties(TD, mergedCellInfo, row, col) {
  28540. if (mergedCellInfo) {
  28541. if (mergedCellInfo.row === row && mergedCellInfo.col === col) {
  28542. TD.setAttribute('rowspan', mergedCellInfo.rowspan.toString());
  28543. TD.setAttribute('colspan', mergedCellInfo.colspan.toString());
  28544. } else {
  28545. TD.removeAttribute('rowspan');
  28546. TD.removeAttribute('colspan');
  28547. TD.style.display = 'none';
  28548. }
  28549. } else {
  28550. TD.removeAttribute('rowspan');
  28551. TD.removeAttribute('colspan');
  28552. TD.style.display = '';
  28553. }
  28554. }
  28555. /***/ }),
  28556. /* 325 */
  28557. /***/ (function(module, exports, __webpack_require__) {
  28558. "use strict";
  28559. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  28560. /*!
  28561. * https://github.com/Starcounter-Jack/JSON-Patch
  28562. * json-patch-duplex.js version: 0.5.7
  28563. * (c) 2013 Joachim Wester
  28564. * MIT license
  28565. */
  28566. var __extends = undefined && undefined.__extends || function (d, b) {
  28567. for (var p in b) {
  28568. if (b.hasOwnProperty(p)) d[p] = b[p];
  28569. }function __() {
  28570. this.constructor = d;
  28571. }
  28572. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  28573. };
  28574. var OriginalError = Error;
  28575. var jsonpatch;
  28576. (function (jsonpatch) {
  28577. var _objectKeys = function _objectKeys(obj) {
  28578. if (_isArray(obj)) {
  28579. var keys = new Array(obj.length);
  28580. for (var k = 0; k < keys.length; k++) {
  28581. keys[k] = "" + k;
  28582. }
  28583. return keys;
  28584. }
  28585. if (Object.keys) {
  28586. return Object.keys(obj);
  28587. }
  28588. var keys = [];
  28589. for (var i in obj) {
  28590. if (obj.hasOwnProperty(i)) {
  28591. keys.push(i);
  28592. }
  28593. }
  28594. return keys;
  28595. };
  28596. function _equals(a, b) {
  28597. switch (typeof a === 'undefined' ? 'undefined' : _typeof(a)) {
  28598. case 'undefined': //backward compatibility, but really I think we should return false
  28599. case 'boolean':
  28600. case 'string':
  28601. case 'number':
  28602. return a === b;
  28603. case 'object':
  28604. if (a === null) return b === null;
  28605. if (_isArray(a)) {
  28606. if (!_isArray(b) || a.length !== b.length) return false;
  28607. for (var i = 0, l = a.length; i < l; i++) {
  28608. if (!_equals(a[i], b[i])) return false;
  28609. }return true;
  28610. }
  28611. var bKeys = _objectKeys(b);
  28612. var bLength = bKeys.length;
  28613. if (_objectKeys(a).length !== bLength) return false;
  28614. for (var i = 0; i < bLength; i++) {
  28615. if (!_equals(a[i], b[i])) return false;
  28616. }return true;
  28617. default:
  28618. return false;
  28619. }
  28620. }
  28621. /* We use a Javascript hash to store each
  28622. function. Each hash entry (property) uses
  28623. the operation identifiers specified in rfc6902.
  28624. In this way, we can map each patch operation
  28625. to its dedicated function in efficient way.
  28626. */
  28627. /* The operations applicable to an object */
  28628. var objOps = {
  28629. add: function add(obj, key) {
  28630. obj[key] = this.value;
  28631. return true;
  28632. },
  28633. remove: function remove(obj, key) {
  28634. delete obj[key];
  28635. return true;
  28636. },
  28637. replace: function replace(obj, key) {
  28638. obj[key] = this.value;
  28639. return true;
  28640. },
  28641. move: function move(obj, key, tree) {
  28642. var temp = { op: "_get", path: this.from };
  28643. apply(tree, [temp]);
  28644. apply(tree, [{ op: "remove", path: this.from }]);
  28645. apply(tree, [{ op: "add", path: this.path, value: temp.value }]);
  28646. return true;
  28647. },
  28648. copy: function copy(obj, key, tree) {
  28649. var temp = { op: "_get", path: this.from };
  28650. apply(tree, [temp]);
  28651. apply(tree, [{ op: "add", path: this.path, value: temp.value }]);
  28652. return true;
  28653. },
  28654. test: function test(obj, key) {
  28655. return _equals(obj[key], this.value);
  28656. },
  28657. _get: function _get(obj, key) {
  28658. this.value = obj[key];
  28659. }
  28660. };
  28661. /* The operations applicable to an array. Many are the same as for the object */
  28662. var arrOps = {
  28663. add: function add(arr, i) {
  28664. arr.splice(i, 0, this.value);
  28665. return true;
  28666. },
  28667. remove: function remove(arr, i) {
  28668. arr.splice(i, 1);
  28669. return true;
  28670. },
  28671. replace: function replace(arr, i) {
  28672. arr[i] = this.value;
  28673. return true;
  28674. },
  28675. move: objOps.move,
  28676. copy: objOps.copy,
  28677. test: objOps.test,
  28678. _get: objOps._get
  28679. };
  28680. /* The operations applicable to object root. Many are the same as for the object */
  28681. var rootOps = {
  28682. add: function add(obj) {
  28683. rootOps.remove.call(this, obj);
  28684. for (var key in this.value) {
  28685. if (this.value.hasOwnProperty(key)) {
  28686. obj[key] = this.value[key];
  28687. }
  28688. }
  28689. return true;
  28690. },
  28691. remove: function remove(obj) {
  28692. for (var key in obj) {
  28693. if (obj.hasOwnProperty(key)) {
  28694. objOps.remove.call(this, obj, key);
  28695. }
  28696. }
  28697. return true;
  28698. },
  28699. replace: function replace(obj) {
  28700. apply(obj, [{ op: "remove", path: this.path }]);
  28701. apply(obj, [{ op: "add", path: this.path, value: this.value }]);
  28702. return true;
  28703. },
  28704. move: objOps.move,
  28705. copy: objOps.copy,
  28706. test: function test(obj) {
  28707. return JSON.stringify(obj) === JSON.stringify(this.value);
  28708. },
  28709. _get: function _get(obj) {
  28710. this.value = obj;
  28711. }
  28712. };
  28713. var observeOps = {
  28714. add: function add(patches, path) {
  28715. var patch = {
  28716. op: "add",
  28717. path: path + escapePathComponent(this.name),
  28718. value: this.object[this.name] };
  28719. patches.push(patch);
  28720. },
  28721. 'delete': function _delete(patches, path) {
  28722. var patch = {
  28723. op: "remove",
  28724. path: path + escapePathComponent(this.name)
  28725. };
  28726. patches.push(patch);
  28727. },
  28728. update: function update(patches, path) {
  28729. var patch = {
  28730. op: "replace",
  28731. path: path + escapePathComponent(this.name),
  28732. value: this.object[this.name]
  28733. };
  28734. patches.push(patch);
  28735. }
  28736. };
  28737. function escapePathComponent(str) {
  28738. if (str.indexOf('/') === -1 && str.indexOf('~') === -1) return str;
  28739. return str.replace(/~/g, '~0').replace(/\//g, '~1');
  28740. }
  28741. function _getPathRecursive(root, obj) {
  28742. var found;
  28743. for (var key in root) {
  28744. if (root.hasOwnProperty(key)) {
  28745. if (root[key] === obj) {
  28746. return escapePathComponent(key) + '/';
  28747. } else if (_typeof(root[key]) === 'object') {
  28748. found = _getPathRecursive(root[key], obj);
  28749. if (found != '') {
  28750. return escapePathComponent(key) + '/' + found;
  28751. }
  28752. }
  28753. }
  28754. }
  28755. return '';
  28756. }
  28757. function getPath(root, obj) {
  28758. if (root === obj) {
  28759. return '/';
  28760. }
  28761. var path = _getPathRecursive(root, obj);
  28762. if (path === '') {
  28763. throw new OriginalError("Object not found in root");
  28764. }
  28765. return '/' + path;
  28766. }
  28767. var beforeDict = [];
  28768. var Mirror = function () {
  28769. function Mirror(obj) {
  28770. this.observers = [];
  28771. this.obj = obj;
  28772. }
  28773. return Mirror;
  28774. }();
  28775. var ObserverInfo = function () {
  28776. function ObserverInfo(callback, observer) {
  28777. this.callback = callback;
  28778. this.observer = observer;
  28779. }
  28780. return ObserverInfo;
  28781. }();
  28782. function getMirror(obj) {
  28783. for (var i = 0, ilen = beforeDict.length; i < ilen; i++) {
  28784. if (beforeDict[i].obj === obj) {
  28785. return beforeDict[i];
  28786. }
  28787. }
  28788. }
  28789. function getObserverFromMirror(mirror, callback) {
  28790. for (var j = 0, jlen = mirror.observers.length; j < jlen; j++) {
  28791. if (mirror.observers[j].callback === callback) {
  28792. return mirror.observers[j].observer;
  28793. }
  28794. }
  28795. }
  28796. function removeObserverFromMirror(mirror, observer) {
  28797. for (var j = 0, jlen = mirror.observers.length; j < jlen; j++) {
  28798. if (mirror.observers[j].observer === observer) {
  28799. mirror.observers.splice(j, 1);
  28800. return;
  28801. }
  28802. }
  28803. }
  28804. function unobserve(root, observer) {
  28805. observer.unobserve();
  28806. }
  28807. jsonpatch.unobserve = unobserve;
  28808. function deepClone(obj) {
  28809. if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === "object") {
  28810. return JSON.parse(JSON.stringify(obj)); //Faster than ES5 clone - http://jsperf.com/deep-cloning-of-objects/5
  28811. } else {
  28812. return obj; //no need to clone primitives
  28813. }
  28814. }
  28815. function observe(obj, callback) {
  28816. var patches = [];
  28817. var root = obj;
  28818. var observer;
  28819. var mirror = getMirror(obj);
  28820. if (!mirror) {
  28821. mirror = new Mirror(obj);
  28822. beforeDict.push(mirror);
  28823. } else {
  28824. observer = getObserverFromMirror(mirror, callback);
  28825. }
  28826. if (observer) {
  28827. return observer;
  28828. }
  28829. observer = {};
  28830. mirror.value = deepClone(obj);
  28831. if (callback) {
  28832. observer.callback = callback;
  28833. observer.next = null;
  28834. var intervals = this.intervals || [100, 1000, 10000, 60000];
  28835. if (intervals.push === void 0) {
  28836. throw new OriginalError("jsonpatch.intervals must be an array");
  28837. }
  28838. var currentInterval = 0;
  28839. var dirtyCheck = function dirtyCheck() {
  28840. generate(observer);
  28841. };
  28842. var fastCheck = function fastCheck() {
  28843. clearTimeout(observer.next);
  28844. observer.next = setTimeout(function () {
  28845. dirtyCheck();
  28846. currentInterval = 0;
  28847. observer.next = setTimeout(slowCheck, intervals[currentInterval++]);
  28848. }, 0);
  28849. };
  28850. var slowCheck = function slowCheck() {
  28851. dirtyCheck();
  28852. if (currentInterval == intervals.length) currentInterval = intervals.length - 1;
  28853. observer.next = setTimeout(slowCheck, intervals[currentInterval++]);
  28854. };
  28855. if (typeof window !== 'undefined') {
  28856. if (window.addEventListener) {
  28857. window.addEventListener('mousedown', fastCheck);
  28858. window.addEventListener('mouseup', fastCheck);
  28859. window.addEventListener('keydown', fastCheck);
  28860. } else {
  28861. document.documentElement.attachEvent('onmousedown', fastCheck);
  28862. document.documentElement.attachEvent('onmouseup', fastCheck);
  28863. document.documentElement.attachEvent('onkeydown', fastCheck);
  28864. }
  28865. }
  28866. observer.next = setTimeout(slowCheck, intervals[currentInterval++]);
  28867. }
  28868. observer.patches = patches;
  28869. observer.object = obj;
  28870. observer.unobserve = function () {
  28871. generate(observer);
  28872. clearTimeout(observer.next);
  28873. removeObserverFromMirror(mirror, observer);
  28874. if (typeof window !== 'undefined') {
  28875. if (window.removeEventListener) {
  28876. window.removeEventListener('mousedown', fastCheck);
  28877. window.removeEventListener('mouseup', fastCheck);
  28878. window.removeEventListener('keydown', fastCheck);
  28879. } else {
  28880. document.documentElement.detachEvent('onmousedown', fastCheck);
  28881. document.documentElement.detachEvent('onmouseup', fastCheck);
  28882. document.documentElement.detachEvent('onkeydown', fastCheck);
  28883. }
  28884. }
  28885. };
  28886. mirror.observers.push(new ObserverInfo(callback, observer));
  28887. return observer;
  28888. }
  28889. jsonpatch.observe = observe;
  28890. function generate(observer) {
  28891. var mirror;
  28892. for (var i = 0, ilen = beforeDict.length; i < ilen; i++) {
  28893. if (beforeDict[i].obj === observer.object) {
  28894. mirror = beforeDict[i];
  28895. break;
  28896. }
  28897. }
  28898. _generate(mirror.value, observer.object, observer.patches, "");
  28899. if (observer.patches.length) {
  28900. apply(mirror.value, observer.patches);
  28901. }
  28902. var temp = observer.patches;
  28903. if (temp.length > 0) {
  28904. observer.patches = [];
  28905. if (observer.callback) {
  28906. observer.callback(temp);
  28907. }
  28908. }
  28909. return temp;
  28910. }
  28911. jsonpatch.generate = generate;
  28912. // Dirty check if obj is different from mirror, generate patches and update mirror
  28913. function _generate(mirror, obj, patches, path) {
  28914. var newKeys = _objectKeys(obj);
  28915. var oldKeys = _objectKeys(mirror);
  28916. var changed = false;
  28917. var deleted = false;
  28918. //if ever "move" operation is implemented here, make sure this test runs OK: "should not generate the same patch twice (move)"
  28919. for (var t = oldKeys.length - 1; t >= 0; t--) {
  28920. var key = oldKeys[t];
  28921. var oldVal = mirror[key];
  28922. if (obj.hasOwnProperty(key)) {
  28923. var newVal = obj[key];
  28924. if ((typeof oldVal === 'undefined' ? 'undefined' : _typeof(oldVal)) == "object" && oldVal != null && (typeof newVal === 'undefined' ? 'undefined' : _typeof(newVal)) == "object" && newVal != null) {
  28925. _generate(oldVal, newVal, patches, path + "/" + escapePathComponent(key));
  28926. } else {
  28927. if (oldVal != newVal) {
  28928. changed = true;
  28929. patches.push({ op: "replace", path: path + "/" + escapePathComponent(key), value: deepClone(newVal) });
  28930. }
  28931. }
  28932. } else {
  28933. patches.push({ op: "remove", path: path + "/" + escapePathComponent(key) });
  28934. deleted = true; // property has been deleted
  28935. }
  28936. }
  28937. if (!deleted && newKeys.length == oldKeys.length) {
  28938. return;
  28939. }
  28940. for (var t = 0; t < newKeys.length; t++) {
  28941. var key = newKeys[t];
  28942. if (!mirror.hasOwnProperty(key)) {
  28943. patches.push({ op: "add", path: path + "/" + escapePathComponent(key), value: deepClone(obj[key]) });
  28944. }
  28945. }
  28946. }
  28947. var _isArray;
  28948. if (Array.isArray) {
  28949. _isArray = Array.isArray;
  28950. } else {
  28951. _isArray = function _isArray(obj) {
  28952. return obj.push && typeof obj.length === 'number';
  28953. };
  28954. }
  28955. //3x faster than cached /^\d+$/.test(str)
  28956. function isInteger(str) {
  28957. var i = 0;
  28958. var len = str.length;
  28959. var charCode;
  28960. while (i < len) {
  28961. charCode = str.charCodeAt(i);
  28962. if (charCode >= 48 && charCode <= 57) {
  28963. i++;
  28964. continue;
  28965. }
  28966. return false;
  28967. }
  28968. return true;
  28969. }
  28970. /// Apply a json-patch operation on an object tree
  28971. function apply(tree, patches, validate) {
  28972. var result = false,
  28973. p = 0,
  28974. plen = patches.length,
  28975. patch,
  28976. key;
  28977. while (p < plen) {
  28978. patch = patches[p];
  28979. p++;
  28980. // Find the object
  28981. var path = patch.path || "";
  28982. var keys = path.split('/');
  28983. var obj = tree;
  28984. var t = 1; //skip empty element - http://jsperf.com/to-shift-or-not-to-shift
  28985. var len = keys.length;
  28986. var existingPathFragment = undefined;
  28987. while (true) {
  28988. key = keys[t];
  28989. if (validate) {
  28990. if (existingPathFragment === undefined) {
  28991. if (obj[key] === undefined) {
  28992. existingPathFragment = keys.slice(0, t).join('/');
  28993. } else if (t == len - 1) {
  28994. existingPathFragment = patch.path;
  28995. }
  28996. if (existingPathFragment !== undefined) {
  28997. this.validator(patch, p - 1, tree, existingPathFragment);
  28998. }
  28999. }
  29000. }
  29001. t++;
  29002. if (key === undefined) {
  29003. if (t >= len) {
  29004. result = rootOps[patch.op].call(patch, obj, key, tree); // Apply patch
  29005. break;
  29006. }
  29007. }
  29008. if (_isArray(obj)) {
  29009. if (key === '-') {
  29010. key = obj.length;
  29011. } else {
  29012. if (validate && !isInteger(key)) {
  29013. throw new JsonPatchError("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index", "OPERATION_PATH_ILLEGAL_ARRAY_INDEX", p - 1, patch.path, patch);
  29014. }
  29015. key = parseInt(key, 10);
  29016. }
  29017. if (t >= len) {
  29018. if (validate && patch.op === "add" && key > obj.length) {
  29019. throw new JsonPatchError("The specified index MUST NOT be greater than the number of elements in the array", "OPERATION_VALUE_OUT_OF_BOUNDS", p - 1, patch.path, patch);
  29020. }
  29021. result = arrOps[patch.op].call(patch, obj, key, tree); // Apply patch
  29022. break;
  29023. }
  29024. } else {
  29025. if (key && key.indexOf('~') != -1) key = key.replace(/~1/g, '/').replace(/~0/g, '~'); // escape chars
  29026. if (t >= len) {
  29027. result = objOps[patch.op].call(patch, obj, key, tree); // Apply patch
  29028. break;
  29029. }
  29030. }
  29031. obj = obj[key];
  29032. }
  29033. }
  29034. return result;
  29035. }
  29036. jsonpatch.apply = apply;
  29037. function compare(tree1, tree2) {
  29038. var patches = [];
  29039. _generate(tree1, tree2, patches, '');
  29040. return patches;
  29041. }
  29042. jsonpatch.compare = compare;
  29043. var JsonPatchError = function (_super) {
  29044. __extends(JsonPatchError, _super);
  29045. function JsonPatchError(message, name, index, operation, tree) {
  29046. _super.call(this, message);
  29047. this.message = message;
  29048. this.name = name;
  29049. this.index = index;
  29050. this.operation = operation;
  29051. this.tree = tree;
  29052. }
  29053. return JsonPatchError;
  29054. }(OriginalError);
  29055. jsonpatch.JsonPatchError = JsonPatchError;
  29056. jsonpatch.Error = JsonPatchError;
  29057. /**
  29058. * Recursively checks whether an object has any undefined values inside.
  29059. */
  29060. function hasUndefined(obj) {
  29061. if (obj === undefined) {
  29062. return true;
  29063. }
  29064. if (typeof obj == "array" || (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) == "object") {
  29065. for (var i in obj) {
  29066. if (hasUndefined(obj[i])) {
  29067. return true;
  29068. }
  29069. }
  29070. }
  29071. return false;
  29072. }
  29073. /**
  29074. * Validates a single operation. Called from `jsonpatch.validate`. Throws `JsonPatchError` in case of an error.
  29075. * @param {object} operation - operation object (patch)
  29076. * @param {number} index - index of operation in the sequence
  29077. * @param {object} [tree] - object where the operation is supposed to be applied
  29078. * @param {string} [existingPathFragment] - comes along with `tree`
  29079. */
  29080. function validator(operation, index, tree, existingPathFragment) {
  29081. if ((typeof operation === 'undefined' ? 'undefined' : _typeof(operation)) !== 'object' || operation === null || _isArray(operation)) {
  29082. throw new JsonPatchError('Operation is not an object', 'OPERATION_NOT_AN_OBJECT', index, operation, tree);
  29083. } else if (!objOps[operation.op]) {
  29084. throw new JsonPatchError('Operation `op` property is not one of operations defined in RFC-6902', 'OPERATION_OP_INVALID', index, operation, tree);
  29085. } else if (typeof operation.path !== 'string') {
  29086. throw new JsonPatchError('Operation `path` property is not a string', 'OPERATION_PATH_INVALID', index, operation, tree);
  29087. } else if ((operation.op === 'move' || operation.op === 'copy') && typeof operation.from !== 'string') {
  29088. throw new JsonPatchError('Operation `from` property is not present (applicable in `move` and `copy` operations)', 'OPERATION_FROM_REQUIRED', index, operation, tree);
  29089. } else if ((operation.op === 'add' || operation.op === 'replace' || operation.op === 'test') && operation.value === undefined) {
  29090. throw new JsonPatchError('Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)', 'OPERATION_VALUE_REQUIRED', index, operation, tree);
  29091. } else if ((operation.op === 'add' || operation.op === 'replace' || operation.op === 'test') && hasUndefined(operation.value)) {
  29092. throw new JsonPatchError('Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)', 'OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED', index, operation, tree);
  29093. } else if (tree) {
  29094. if (operation.op == "add") {
  29095. var pathLen = operation.path.split("/").length;
  29096. var existingPathLen = existingPathFragment.split("/").length;
  29097. if (pathLen !== existingPathLen + 1 && pathLen !== existingPathLen) {
  29098. throw new JsonPatchError('Cannot perform an `add` operation at the desired path', 'OPERATION_PATH_CANNOT_ADD', index, operation, tree);
  29099. }
  29100. } else if (operation.op === 'replace' || operation.op === 'remove' || operation.op === '_get') {
  29101. if (operation.path !== existingPathFragment) {
  29102. throw new JsonPatchError('Cannot perform the operation at a path that does not exist', 'OPERATION_PATH_UNRESOLVABLE', index, operation, tree);
  29103. }
  29104. } else if (operation.op === 'move' || operation.op === 'copy') {
  29105. var existingValue = { op: "_get", path: operation.from, value: undefined };
  29106. var error = jsonpatch.validate([existingValue], tree);
  29107. if (error && error.name === 'OPERATION_PATH_UNRESOLVABLE') {
  29108. throw new JsonPatchError('Cannot perform the operation from a path that does not exist', 'OPERATION_FROM_UNRESOLVABLE', index, operation, tree);
  29109. }
  29110. }
  29111. }
  29112. }
  29113. jsonpatch.validator = validator;
  29114. /**
  29115. * Validates a sequence of operations. If `tree` parameter is provided, the sequence is additionally validated against the object tree.
  29116. * If error is encountered, returns a JsonPatchError object
  29117. * @param sequence
  29118. * @param tree
  29119. * @returns {JsonPatchError|undefined}
  29120. */
  29121. function validate(sequence, tree) {
  29122. try {
  29123. if (!_isArray(sequence)) {
  29124. throw new JsonPatchError('Patch sequence must be an array', 'SEQUENCE_NOT_AN_ARRAY');
  29125. }
  29126. if (tree) {
  29127. tree = JSON.parse(JSON.stringify(tree)); //clone tree so that we can safely try applying operations
  29128. apply.call(this, tree, sequence, true);
  29129. } else {
  29130. for (var i = 0; i < sequence.length; i++) {
  29131. this.validator(sequence[i], i);
  29132. }
  29133. }
  29134. } catch (e) {
  29135. if (e instanceof JsonPatchError) {
  29136. return e;
  29137. } else {
  29138. throw e;
  29139. }
  29140. }
  29141. }
  29142. jsonpatch.validate = validate;
  29143. })(jsonpatch || (jsonpatch = {}));
  29144. if (true) {
  29145. exports.apply = jsonpatch.apply;
  29146. exports.observe = jsonpatch.observe;
  29147. exports.unobserve = jsonpatch.unobserve;
  29148. exports.generate = jsonpatch.generate;
  29149. exports.compare = jsonpatch.compare;
  29150. exports.validate = jsonpatch.validate;
  29151. exports.validator = jsonpatch.validator;
  29152. exports.JsonPatchError = jsonpatch.JsonPatchError;
  29153. exports.Error = jsonpatch.Error;
  29154. }
  29155. /***/ }),
  29156. /* 326 */
  29157. /***/ (function(module, exports, __webpack_require__) {
  29158. "use strict";
  29159. exports.__esModule = true;
  29160. __webpack_require__(96);
  29161. __webpack_require__(111);
  29162. __webpack_require__(112);
  29163. __webpack_require__(116);
  29164. __webpack_require__(117);
  29165. __webpack_require__(119);
  29166. __webpack_require__(122);
  29167. __webpack_require__(123);
  29168. __webpack_require__(124);
  29169. __webpack_require__(125);
  29170. __webpack_require__(126);
  29171. __webpack_require__(127);
  29172. __webpack_require__(128);
  29173. __webpack_require__(129);
  29174. __webpack_require__(130);
  29175. __webpack_require__(131);
  29176. __webpack_require__(132);
  29177. __webpack_require__(133);
  29178. __webpack_require__(134);
  29179. __webpack_require__(135);
  29180. __webpack_require__(136);
  29181. __webpack_require__(137);
  29182. __webpack_require__(138);
  29183. __webpack_require__(139);
  29184. __webpack_require__(141);
  29185. __webpack_require__(143);
  29186. __webpack_require__(144);
  29187. __webpack_require__(145);
  29188. __webpack_require__(146);
  29189. __webpack_require__(147);
  29190. __webpack_require__(148);
  29191. __webpack_require__(149);
  29192. __webpack_require__(150);
  29193. __webpack_require__(151);
  29194. __webpack_require__(152);
  29195. __webpack_require__(153);
  29196. __webpack_require__(154);
  29197. __webpack_require__(155);
  29198. __webpack_require__(85);
  29199. __webpack_require__(156);
  29200. __webpack_require__(157);
  29201. __webpack_require__(159);
  29202. __webpack_require__(160);
  29203. __webpack_require__(161);
  29204. __webpack_require__(162);
  29205. __webpack_require__(163);
  29206. __webpack_require__(164);
  29207. __webpack_require__(165);
  29208. __webpack_require__(167);
  29209. __webpack_require__(168);
  29210. __webpack_require__(169);
  29211. __webpack_require__(172);
  29212. __webpack_require__(173);
  29213. __webpack_require__(174);
  29214. __webpack_require__(345);
  29215. __webpack_require__(346);
  29216. __webpack_require__(347);
  29217. var _editors = __webpack_require__(17);
  29218. var _renderers = __webpack_require__(13);
  29219. var _validators = __webpack_require__(28);
  29220. var _cellTypes = __webpack_require__(87);
  29221. var _core = __webpack_require__(88);
  29222. var _core2 = _interopRequireDefault(_core);
  29223. var _jquery = __webpack_require__(404);
  29224. var _jquery2 = _interopRequireDefault(_jquery);
  29225. var _eventManager = __webpack_require__(6);
  29226. var _eventManager2 = _interopRequireDefault(_eventManager);
  29227. var _pluginHooks = __webpack_require__(15);
  29228. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  29229. var _ghostTable = __webpack_require__(92);
  29230. var _ghostTable2 = _interopRequireDefault(_ghostTable);
  29231. var _array = __webpack_require__(1);
  29232. var arrayHelpers = _interopRequireWildcard(_array);
  29233. var _browser = __webpack_require__(27);
  29234. var browserHelpers = _interopRequireWildcard(_browser);
  29235. var _data = __webpack_require__(90);
  29236. var dataHelpers = _interopRequireWildcard(_data);
  29237. var _date = __webpack_require__(310);
  29238. var dateHelpers = _interopRequireWildcard(_date);
  29239. var _feature = __webpack_require__(40);
  29240. var featureHelpers = _interopRequireWildcard(_feature);
  29241. var _function = __webpack_require__(43);
  29242. var functionHelpers = _interopRequireWildcard(_function);
  29243. var _mixed = __webpack_require__(16);
  29244. var mixedHelpers = _interopRequireWildcard(_mixed);
  29245. var _number = __webpack_require__(5);
  29246. var numberHelpers = _interopRequireWildcard(_number);
  29247. var _object = __webpack_require__(2);
  29248. var objectHelpers = _interopRequireWildcard(_object);
  29249. var _setting = __webpack_require__(89);
  29250. var settingHelpers = _interopRequireWildcard(_setting);
  29251. var _string = __webpack_require__(36);
  29252. var stringHelpers = _interopRequireWildcard(_string);
  29253. var _unicode = __webpack_require__(21);
  29254. var unicodeHelpers = _interopRequireWildcard(_unicode);
  29255. var _element = __webpack_require__(0);
  29256. var domHelpers = _interopRequireWildcard(_element);
  29257. var _event = __webpack_require__(12);
  29258. var domEventHelpers = _interopRequireWildcard(_event);
  29259. var _index = __webpack_require__(405);
  29260. var plugins = _interopRequireWildcard(_index);
  29261. var _plugins = __webpack_require__(8);
  29262. var _defaultSettings = __webpack_require__(315);
  29263. var _defaultSettings2 = _interopRequireDefault(_defaultSettings);
  29264. var _rootInstance = __webpack_require__(314);
  29265. var _i18n = __webpack_require__(316);
  29266. var _constants = __webpack_require__(7);
  29267. var constants = _interopRequireWildcard(_constants);
  29268. var _dictionariesManager = __webpack_require__(71);
  29269. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  29270. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  29271. function Handsontable(rootElement, userSettings) {
  29272. var instance = new _core2.default(rootElement, userSettings || {}, _rootInstance.rootInstanceSymbol);
  29273. instance.init();
  29274. return instance;
  29275. }
  29276. (0, _jquery2.default)(Handsontable);
  29277. Handsontable.Core = _core2.default;
  29278. Handsontable.DefaultSettings = _defaultSettings2.default;
  29279. Handsontable.EventManager = _eventManager2.default;
  29280. Handsontable._getListenersCounter = _eventManager.getListenersCounter; // For MemoryLeak tests
  29281. Handsontable.buildDate = '10/04/2018 11:38:33';
  29282. Handsontable.packageName = 'handsontable';
  29283. Handsontable.version = '2.0.0';
  29284. var baseVersion = '';
  29285. if (baseVersion) {
  29286. Handsontable.baseVersion = baseVersion;
  29287. }
  29288. // Export Hooks singleton
  29289. Handsontable.hooks = _pluginHooks2.default.getSingleton();
  29290. // TODO: Remove this exports after rewrite tests about this module
  29291. Handsontable.__GhostTable = _ghostTable2.default;
  29292. //
  29293. // Export all helpers to the Handsontable object
  29294. var HELPERS = [arrayHelpers, browserHelpers, dataHelpers, dateHelpers, featureHelpers, functionHelpers, mixedHelpers, numberHelpers, objectHelpers, settingHelpers, stringHelpers, unicodeHelpers];
  29295. var DOM = [domHelpers, domEventHelpers];
  29296. Handsontable.helper = {};
  29297. Handsontable.dom = {};
  29298. // Fill general helpers.
  29299. arrayHelpers.arrayEach(HELPERS, function (helper) {
  29300. arrayHelpers.arrayEach(Object.getOwnPropertyNames(helper), function (key) {
  29301. if (key.charAt(0) !== '_') {
  29302. Handsontable.helper[key] = helper[key];
  29303. }
  29304. });
  29305. });
  29306. // Fill DOM helpers.
  29307. arrayHelpers.arrayEach(DOM, function (helper) {
  29308. arrayHelpers.arrayEach(Object.getOwnPropertyNames(helper), function (key) {
  29309. if (key.charAt(0) !== '_') {
  29310. Handsontable.dom[key] = helper[key];
  29311. }
  29312. });
  29313. });
  29314. // Export cell types.
  29315. Handsontable.cellTypes = {};
  29316. arrayHelpers.arrayEach((0, _cellTypes.getRegisteredCellTypeNames)(), function (cellTypeName) {
  29317. Handsontable.cellTypes[cellTypeName] = (0, _cellTypes.getCellType)(cellTypeName);
  29318. });
  29319. Handsontable.cellTypes.registerCellType = _cellTypes.registerCellType;
  29320. Handsontable.cellTypes.getCellType = _cellTypes.getCellType;
  29321. // Export all registered editors from the Handsontable.
  29322. Handsontable.editors = {};
  29323. arrayHelpers.arrayEach((0, _editors.getRegisteredEditorNames)(), function (editorName) {
  29324. Handsontable.editors[stringHelpers.toUpperCaseFirst(editorName) + 'Editor'] = (0, _editors.getEditor)(editorName);
  29325. });
  29326. Handsontable.editors.registerEditor = _editors.registerEditor;
  29327. Handsontable.editors.getEditor = _editors.getEditor;
  29328. // Export all registered renderers from the Handsontable.
  29329. Handsontable.renderers = {};
  29330. arrayHelpers.arrayEach((0, _renderers.getRegisteredRendererNames)(), function (rendererName) {
  29331. var renderer = (0, _renderers.getRenderer)(rendererName);
  29332. if (rendererName === 'base') {
  29333. Handsontable.renderers.cellDecorator = renderer;
  29334. }
  29335. Handsontable.renderers[stringHelpers.toUpperCaseFirst(rendererName) + 'Renderer'] = renderer;
  29336. });
  29337. Handsontable.renderers.registerRenderer = _renderers.registerRenderer;
  29338. Handsontable.renderers.getRenderer = _renderers.getRenderer;
  29339. // Export all registered validators from the Handsontable.
  29340. Handsontable.validators = {};
  29341. arrayHelpers.arrayEach((0, _validators.getRegisteredValidatorNames)(), function (validatorName) {
  29342. Handsontable.validators[stringHelpers.toUpperCaseFirst(validatorName) + 'Validator'] = (0, _validators.getValidator)(validatorName);
  29343. });
  29344. Handsontable.validators.registerValidator = _validators.registerValidator;
  29345. Handsontable.validators.getValidator = _validators.getValidator;
  29346. // Export all registered plugins from the Handsontable.
  29347. Handsontable.plugins = {};
  29348. arrayHelpers.arrayEach(Object.getOwnPropertyNames(plugins), function (pluginName) {
  29349. var plugin = plugins[pluginName];
  29350. if (pluginName === 'Base') {
  29351. Handsontable.plugins[pluginName + 'Plugin'] = plugin;
  29352. } else {
  29353. Handsontable.plugins[pluginName] = plugin;
  29354. }
  29355. });
  29356. Handsontable.plugins.registerPlugin = _plugins.registerPlugin;
  29357. Handsontable.languages = {};
  29358. Handsontable.languages.dictionaryKeys = constants;
  29359. Handsontable.languages.getLanguageDictionary = _dictionariesManager.getLanguageDictionary;
  29360. Handsontable.languages.getLanguagesDictionaries = _dictionariesManager.getLanguagesDictionaries;
  29361. Handsontable.languages.registerLanguageDictionary = _dictionariesManager.registerLanguageDictionary;
  29362. // Alias to `getTranslatedPhrase` function, for more information check it API.
  29363. Handsontable.languages.getTranslatedPhrase = function () {
  29364. return _i18n.getTranslatedPhrase.apply(undefined, arguments);
  29365. };
  29366. exports.default = Handsontable;
  29367. /***/ }),
  29368. /* 327 */
  29369. /***/ (function(module, exports, __webpack_require__) {
  29370. var dP = __webpack_require__(20);
  29371. var anObject = __webpack_require__(18);
  29372. var getKeys = __webpack_require__(37);
  29373. module.exports = __webpack_require__(22) ? Object.defineProperties : function defineProperties(O, Properties) {
  29374. anObject(O);
  29375. var keys = getKeys(Properties);
  29376. var length = keys.length;
  29377. var i = 0;
  29378. var P;
  29379. while (length > i) dP.f(O, P = keys[i++], Properties[P]);
  29380. return O;
  29381. };
  29382. /***/ }),
  29383. /* 328 */
  29384. /***/ (function(module, exports, __webpack_require__) {
  29385. "use strict";
  29386. var create = __webpack_require__(74);
  29387. var descriptor = __webpack_require__(50);
  29388. var setToStringTag = __webpack_require__(52);
  29389. var IteratorPrototype = {};
  29390. // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
  29391. __webpack_require__(31)(IteratorPrototype, __webpack_require__(11)('iterator'), function () { return this; });
  29392. module.exports = function (Constructor, NAME, next) {
  29393. Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });
  29394. setToStringTag(Constructor, NAME + ' Iterator');
  29395. };
  29396. /***/ }),
  29397. /* 329 */
  29398. /***/ (function(module, exports, __webpack_require__) {
  29399. var isObject = __webpack_require__(9);
  29400. var setPrototypeOf = __webpack_require__(110).set;
  29401. module.exports = function (that, target, C) {
  29402. var S = target.constructor;
  29403. var P;
  29404. if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && setPrototypeOf) {
  29405. setPrototypeOf(that, P);
  29406. } return that;
  29407. };
  29408. /***/ }),
  29409. /* 330 */
  29410. /***/ (function(module, exports, __webpack_require__) {
  29411. // 9.4.2.3 ArraySpeciesCreate(originalArray, length)
  29412. var speciesConstructor = __webpack_require__(331);
  29413. module.exports = function (original, length) {
  29414. return new (speciesConstructor(original))(length);
  29415. };
  29416. /***/ }),
  29417. /* 331 */
  29418. /***/ (function(module, exports, __webpack_require__) {
  29419. var isObject = __webpack_require__(9);
  29420. var isArray = __webpack_require__(113);
  29421. var SPECIES = __webpack_require__(11)('species');
  29422. module.exports = function (original) {
  29423. var C;
  29424. if (isArray(original)) {
  29425. C = original.constructor;
  29426. // cross-realm fallback
  29427. if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
  29428. if (isObject(C)) {
  29429. C = C[SPECIES];
  29430. if (C === null) C = undefined;
  29431. }
  29432. } return C === undefined ? Array : C;
  29433. };
  29434. /***/ }),
  29435. /* 332 */
  29436. /***/ (function(module, exports, __webpack_require__) {
  29437. // 7.3.20 SpeciesConstructor(O, defaultConstructor)
  29438. var anObject = __webpack_require__(18);
  29439. var aFunction = __webpack_require__(62);
  29440. var SPECIES = __webpack_require__(11)('species');
  29441. module.exports = function (O, D) {
  29442. var C = anObject(O).constructor;
  29443. var S;
  29444. return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
  29445. };
  29446. /***/ }),
  29447. /* 333 */
  29448. /***/ (function(module, exports) {
  29449. // fast apply, http://jsperf.lnkit.com/fast-apply/5
  29450. module.exports = function (fn, args, that) {
  29451. var un = that === undefined;
  29452. switch (args.length) {
  29453. case 0: return un ? fn()
  29454. : fn.call(that);
  29455. case 1: return un ? fn(args[0])
  29456. : fn.call(that, args[0]);
  29457. case 2: return un ? fn(args[0], args[1])
  29458. : fn.call(that, args[0], args[1]);
  29459. case 3: return un ? fn(args[0], args[1], args[2])
  29460. : fn.call(that, args[0], args[1], args[2]);
  29461. case 4: return un ? fn(args[0], args[1], args[2], args[3])
  29462. : fn.call(that, args[0], args[1], args[2], args[3]);
  29463. } return fn.apply(that, args);
  29464. };
  29465. /***/ }),
  29466. /* 334 */
  29467. /***/ (function(module, exports, __webpack_require__) {
  29468. var global = __webpack_require__(14);
  29469. var macrotask = __webpack_require__(80).set;
  29470. var Observer = global.MutationObserver || global.WebKitMutationObserver;
  29471. var process = global.process;
  29472. var Promise = global.Promise;
  29473. var isNode = __webpack_require__(44)(process) == 'process';
  29474. module.exports = function () {
  29475. var head, last, notify;
  29476. var flush = function () {
  29477. var parent, fn;
  29478. if (isNode && (parent = process.domain)) parent.exit();
  29479. while (head) {
  29480. fn = head.fn;
  29481. head = head.next;
  29482. try {
  29483. fn();
  29484. } catch (e) {
  29485. if (head) notify();
  29486. else last = undefined;
  29487. throw e;
  29488. }
  29489. } last = undefined;
  29490. if (parent) parent.enter();
  29491. };
  29492. // Node.js
  29493. if (isNode) {
  29494. notify = function () {
  29495. process.nextTick(flush);
  29496. };
  29497. // browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339
  29498. } else if (Observer && !(global.navigator && global.navigator.standalone)) {
  29499. var toggle = true;
  29500. var node = document.createTextNode('');
  29501. new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new
  29502. notify = function () {
  29503. node.data = toggle = !toggle;
  29504. };
  29505. // environments with maybe non-completely correct, but existent Promise
  29506. } else if (Promise && Promise.resolve) {
  29507. var promise = Promise.resolve();
  29508. notify = function () {
  29509. promise.then(flush);
  29510. };
  29511. // for other environments - macrotask based on:
  29512. // - setImmediate
  29513. // - MessageChannel
  29514. // - window.postMessag
  29515. // - onreadystatechange
  29516. // - setTimeout
  29517. } else {
  29518. notify = function () {
  29519. // strange IE + webpack dev server bug - use .call(global)
  29520. macrotask.call(global, flush);
  29521. };
  29522. }
  29523. return function (fn) {
  29524. var task = { fn: fn, next: undefined };
  29525. if (last) last.next = task;
  29526. if (!head) {
  29527. head = task;
  29528. notify();
  29529. } last = task;
  29530. };
  29531. };
  29532. /***/ }),
  29533. /* 335 */
  29534. /***/ (function(module, exports) {
  29535. module.exports = function (exec) {
  29536. try {
  29537. return { e: false, v: exec() };
  29538. } catch (e) {
  29539. return { e: true, v: e };
  29540. }
  29541. };
  29542. /***/ }),
  29543. /* 336 */
  29544. /***/ (function(module, exports, __webpack_require__) {
  29545. var anObject = __webpack_require__(18);
  29546. var isObject = __webpack_require__(9);
  29547. var newPromiseCapability = __webpack_require__(118);
  29548. module.exports = function (C, x) {
  29549. anObject(C);
  29550. if (isObject(x) && x.constructor === C) return x;
  29551. var promiseCapability = newPromiseCapability.f(C);
  29552. var resolve = promiseCapability.resolve;
  29553. resolve(x);
  29554. return promiseCapability.promise;
  29555. };
  29556. /***/ }),
  29557. /* 337 */
  29558. /***/ (function(module, exports, __webpack_require__) {
  29559. var global = __webpack_require__(14);
  29560. var core = __webpack_require__(45);
  29561. var LIBRARY = __webpack_require__(65);
  29562. var wksExt = __webpack_require__(120);
  29563. var defineProperty = __webpack_require__(20).f;
  29564. module.exports = function (name) {
  29565. var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
  29566. if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) });
  29567. };
  29568. /***/ }),
  29569. /* 338 */
  29570. /***/ (function(module, exports, __webpack_require__) {
  29571. // all enumerable object keys, includes symbols
  29572. var getKeys = __webpack_require__(37);
  29573. var gOPS = __webpack_require__(69);
  29574. var pIE = __webpack_require__(53);
  29575. module.exports = function (it) {
  29576. var result = getKeys(it);
  29577. var getSymbols = gOPS.f;
  29578. if (getSymbols) {
  29579. var symbols = getSymbols(it);
  29580. var isEnum = pIE.f;
  29581. var i = 0;
  29582. var key;
  29583. while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key);
  29584. } return result;
  29585. };
  29586. /***/ }),
  29587. /* 339 */
  29588. /***/ (function(module, exports) {
  29589. // 7.2.9 SameValue(x, y)
  29590. module.exports = Object.is || function is(x, y) {
  29591. // eslint-disable-next-line no-self-compare
  29592. return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;
  29593. };
  29594. /***/ }),
  29595. /* 340 */
  29596. /***/ (function(module, exports, __webpack_require__) {
  29597. var toInteger = __webpack_require__(59);
  29598. var defined = __webpack_require__(38);
  29599. // true -> String#at
  29600. // false -> String#codePointAt
  29601. module.exports = function (TO_STRING) {
  29602. return function (that, pos) {
  29603. var s = String(defined(that));
  29604. var i = toInteger(pos);
  29605. var l = s.length;
  29606. var a, b;
  29607. if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
  29608. a = s.charCodeAt(i);
  29609. return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
  29610. ? TO_STRING ? s.charAt(i) : a
  29611. : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
  29612. };
  29613. };
  29614. /***/ }),
  29615. /* 341 */
  29616. /***/ (function(module, exports, __webpack_require__) {
  29617. "use strict";
  29618. // 21.2.5.3 get RegExp.prototype.flags
  29619. var anObject = __webpack_require__(18);
  29620. module.exports = function () {
  29621. var that = anObject(this);
  29622. var result = '';
  29623. if (that.global) result += 'g';
  29624. if (that.ignoreCase) result += 'i';
  29625. if (that.multiline) result += 'm';
  29626. if (that.unicode) result += 'u';
  29627. if (that.sticky) result += 'y';
  29628. return result;
  29629. };
  29630. /***/ }),
  29631. /* 342 */
  29632. /***/ (function(module, exports, __webpack_require__) {
  29633. "use strict";
  29634. // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
  29635. var toObject = __webpack_require__(33);
  29636. var toAbsoluteIndex = __webpack_require__(60);
  29637. var toLength = __webpack_require__(25);
  29638. module.exports = [].copyWithin || function copyWithin(target /* = 0 */, start /* = 0, end = @length */) {
  29639. var O = toObject(this);
  29640. var len = toLength(O.length);
  29641. var to = toAbsoluteIndex(target, len);
  29642. var from = toAbsoluteIndex(start, len);
  29643. var end = arguments.length > 2 ? arguments[2] : undefined;
  29644. var count = Math.min((end === undefined ? len : toAbsoluteIndex(end, len)) - from, len - to);
  29645. var inc = 1;
  29646. if (from < to && to < from + count) {
  29647. inc = -1;
  29648. from += count - 1;
  29649. to += count - 1;
  29650. }
  29651. while (count-- > 0) {
  29652. if (from in O) O[to] = O[from];
  29653. else delete O[to];
  29654. to += inc;
  29655. from += inc;
  29656. } return O;
  29657. };
  29658. /***/ }),
  29659. /* 343 */
  29660. /***/ (function(module, exports, __webpack_require__) {
  29661. "use strict";
  29662. // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
  29663. var toObject = __webpack_require__(33);
  29664. var toAbsoluteIndex = __webpack_require__(60);
  29665. var toLength = __webpack_require__(25);
  29666. module.exports = function fill(value /* , start = 0, end = @length */) {
  29667. var O = toObject(this);
  29668. var length = toLength(O.length);
  29669. var aLen = arguments.length;
  29670. var index = toAbsoluteIndex(aLen > 1 ? arguments[1] : undefined, length);
  29671. var end = aLen > 2 ? arguments[2] : undefined;
  29672. var endPos = end === undefined ? length : toAbsoluteIndex(end, length);
  29673. while (endPos > index) O[index++] = value;
  29674. return O;
  29675. };
  29676. /***/ }),
  29677. /* 344 */
  29678. /***/ (function(module, exports, __webpack_require__) {
  29679. // all object keys, includes non-enumerable and symbols
  29680. var gOPN = __webpack_require__(81);
  29681. var gOPS = __webpack_require__(69);
  29682. var anObject = __webpack_require__(18);
  29683. var Reflect = __webpack_require__(14).Reflect;
  29684. module.exports = Reflect && Reflect.ownKeys || function ownKeys(it) {
  29685. var keys = gOPN.f(anObject(it));
  29686. var getSymbols = gOPS.f;
  29687. return getSymbols ? keys.concat(getSymbols(it)) : keys;
  29688. };
  29689. /***/ }),
  29690. /* 345 */
  29691. /***/ (function(module, exports) {
  29692. // removed by extract-text-webpack-plugin
  29693. /***/ }),
  29694. /* 346 */
  29695. /***/ (function(module, exports) {
  29696. // removed by extract-text-webpack-plugin
  29697. /***/ }),
  29698. /* 347 */
  29699. /***/ (function(module, exports) {
  29700. // removed by extract-text-webpack-plugin
  29701. /***/ }),
  29702. /* 348 */
  29703. /***/ (function(module, exports, __webpack_require__) {
  29704. "use strict";
  29705. exports.__esModule = true;
  29706. var _element = __webpack_require__(0);
  29707. var _base = __webpack_require__(35);
  29708. var _base2 = _interopRequireDefault(_base);
  29709. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  29710. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  29711. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  29712. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  29713. /**
  29714. * A overlay that renders ALL available rows & columns positioned on top of the original Walkontable instance and all other overlays.
  29715. * Used for debugging purposes to see if the other overlays (that render only part of the rows & columns) are positioned correctly
  29716. *
  29717. * @class DebugOverlay
  29718. */
  29719. var DebugOverlay = function (_Overlay) {
  29720. _inherits(DebugOverlay, _Overlay);
  29721. /**
  29722. * @param {Walkontable} wotInstance
  29723. */
  29724. function DebugOverlay(wotInstance) {
  29725. _classCallCheck(this, DebugOverlay);
  29726. var _this = _possibleConstructorReturn(this, (DebugOverlay.__proto__ || Object.getPrototypeOf(DebugOverlay)).call(this, wotInstance));
  29727. _this.clone = _this.makeClone(_base2.default.CLONE_DEBUG);
  29728. _this.clone.wtTable.holder.style.opacity = 0.4;
  29729. _this.clone.wtTable.holder.style.textShadow = '0 0 2px #ff0000';
  29730. (0, _element.addClass)(_this.clone.wtTable.holder.parentNode, 'wtDebugVisible');
  29731. return _this;
  29732. }
  29733. return DebugOverlay;
  29734. }(_base2.default);
  29735. _base2.default.registerOverlay(_base2.default.CLONE_DEBUG, DebugOverlay);
  29736. exports.default = DebugOverlay;
  29737. /***/ }),
  29738. /* 349 */
  29739. /***/ (function(module, exports) {
  29740. module.exports = function(module) {
  29741. if(!module.webpackPolyfill) {
  29742. module.deprecate = function() {};
  29743. module.paths = [];
  29744. // module.parent = undefined by default
  29745. if(!module.children) module.children = [];
  29746. Object.defineProperty(module, "loaded", {
  29747. enumerable: true,
  29748. get: function() {
  29749. return module.l;
  29750. }
  29751. });
  29752. Object.defineProperty(module, "id", {
  29753. enumerable: true,
  29754. get: function() {
  29755. return module.i;
  29756. }
  29757. });
  29758. module.webpackPolyfill = 1;
  29759. }
  29760. return module;
  29761. };
  29762. /***/ }),
  29763. /* 350 */
  29764. /***/ (function(module, exports, __webpack_require__) {
  29765. var map = {
  29766. "./af": 180,
  29767. "./af.js": 180,
  29768. "./ar": 181,
  29769. "./ar-dz": 182,
  29770. "./ar-dz.js": 182,
  29771. "./ar-kw": 183,
  29772. "./ar-kw.js": 183,
  29773. "./ar-ly": 184,
  29774. "./ar-ly.js": 184,
  29775. "./ar-ma": 185,
  29776. "./ar-ma.js": 185,
  29777. "./ar-sa": 186,
  29778. "./ar-sa.js": 186,
  29779. "./ar-tn": 187,
  29780. "./ar-tn.js": 187,
  29781. "./ar.js": 181,
  29782. "./az": 188,
  29783. "./az.js": 188,
  29784. "./be": 189,
  29785. "./be.js": 189,
  29786. "./bg": 190,
  29787. "./bg.js": 190,
  29788. "./bm": 191,
  29789. "./bm.js": 191,
  29790. "./bn": 192,
  29791. "./bn.js": 192,
  29792. "./bo": 193,
  29793. "./bo.js": 193,
  29794. "./br": 194,
  29795. "./br.js": 194,
  29796. "./bs": 195,
  29797. "./bs.js": 195,
  29798. "./ca": 196,
  29799. "./ca.js": 196,
  29800. "./cs": 197,
  29801. "./cs.js": 197,
  29802. "./cv": 198,
  29803. "./cv.js": 198,
  29804. "./cy": 199,
  29805. "./cy.js": 199,
  29806. "./da": 200,
  29807. "./da.js": 200,
  29808. "./de": 201,
  29809. "./de-at": 202,
  29810. "./de-at.js": 202,
  29811. "./de-ch": 203,
  29812. "./de-ch.js": 203,
  29813. "./de.js": 201,
  29814. "./dv": 204,
  29815. "./dv.js": 204,
  29816. "./el": 205,
  29817. "./el.js": 205,
  29818. "./en-au": 206,
  29819. "./en-au.js": 206,
  29820. "./en-ca": 207,
  29821. "./en-ca.js": 207,
  29822. "./en-gb": 208,
  29823. "./en-gb.js": 208,
  29824. "./en-ie": 209,
  29825. "./en-ie.js": 209,
  29826. "./en-nz": 210,
  29827. "./en-nz.js": 210,
  29828. "./eo": 211,
  29829. "./eo.js": 211,
  29830. "./es": 212,
  29831. "./es-do": 213,
  29832. "./es-do.js": 213,
  29833. "./es-us": 214,
  29834. "./es-us.js": 214,
  29835. "./es.js": 212,
  29836. "./et": 215,
  29837. "./et.js": 215,
  29838. "./eu": 216,
  29839. "./eu.js": 216,
  29840. "./fa": 217,
  29841. "./fa.js": 217,
  29842. "./fi": 218,
  29843. "./fi.js": 218,
  29844. "./fo": 219,
  29845. "./fo.js": 219,
  29846. "./fr": 220,
  29847. "./fr-ca": 221,
  29848. "./fr-ca.js": 221,
  29849. "./fr-ch": 222,
  29850. "./fr-ch.js": 222,
  29851. "./fr.js": 220,
  29852. "./fy": 223,
  29853. "./fy.js": 223,
  29854. "./gd": 224,
  29855. "./gd.js": 224,
  29856. "./gl": 225,
  29857. "./gl.js": 225,
  29858. "./gom-latn": 226,
  29859. "./gom-latn.js": 226,
  29860. "./gu": 227,
  29861. "./gu.js": 227,
  29862. "./he": 228,
  29863. "./he.js": 228,
  29864. "./hi": 229,
  29865. "./hi.js": 229,
  29866. "./hr": 230,
  29867. "./hr.js": 230,
  29868. "./hu": 231,
  29869. "./hu.js": 231,
  29870. "./hy-am": 232,
  29871. "./hy-am.js": 232,
  29872. "./id": 233,
  29873. "./id.js": 233,
  29874. "./is": 234,
  29875. "./is.js": 234,
  29876. "./it": 235,
  29877. "./it.js": 235,
  29878. "./ja": 236,
  29879. "./ja.js": 236,
  29880. "./jv": 237,
  29881. "./jv.js": 237,
  29882. "./ka": 238,
  29883. "./ka.js": 238,
  29884. "./kk": 239,
  29885. "./kk.js": 239,
  29886. "./km": 240,
  29887. "./km.js": 240,
  29888. "./kn": 241,
  29889. "./kn.js": 241,
  29890. "./ko": 242,
  29891. "./ko.js": 242,
  29892. "./ky": 243,
  29893. "./ky.js": 243,
  29894. "./lb": 244,
  29895. "./lb.js": 244,
  29896. "./lo": 245,
  29897. "./lo.js": 245,
  29898. "./lt": 246,
  29899. "./lt.js": 246,
  29900. "./lv": 247,
  29901. "./lv.js": 247,
  29902. "./me": 248,
  29903. "./me.js": 248,
  29904. "./mi": 249,
  29905. "./mi.js": 249,
  29906. "./mk": 250,
  29907. "./mk.js": 250,
  29908. "./ml": 251,
  29909. "./ml.js": 251,
  29910. "./mr": 252,
  29911. "./mr.js": 252,
  29912. "./ms": 253,
  29913. "./ms-my": 254,
  29914. "./ms-my.js": 254,
  29915. "./ms.js": 253,
  29916. "./mt": 255,
  29917. "./mt.js": 255,
  29918. "./my": 256,
  29919. "./my.js": 256,
  29920. "./nb": 257,
  29921. "./nb.js": 257,
  29922. "./ne": 258,
  29923. "./ne.js": 258,
  29924. "./nl": 259,
  29925. "./nl-be": 260,
  29926. "./nl-be.js": 260,
  29927. "./nl.js": 259,
  29928. "./nn": 261,
  29929. "./nn.js": 261,
  29930. "./pa-in": 262,
  29931. "./pa-in.js": 262,
  29932. "./pl": 263,
  29933. "./pl.js": 263,
  29934. "./pt": 264,
  29935. "./pt-br": 265,
  29936. "./pt-br.js": 265,
  29937. "./pt.js": 264,
  29938. "./ro": 266,
  29939. "./ro.js": 266,
  29940. "./ru": 267,
  29941. "./ru.js": 267,
  29942. "./sd": 268,
  29943. "./sd.js": 268,
  29944. "./se": 269,
  29945. "./se.js": 269,
  29946. "./si": 270,
  29947. "./si.js": 270,
  29948. "./sk": 271,
  29949. "./sk.js": 271,
  29950. "./sl": 272,
  29951. "./sl.js": 272,
  29952. "./sq": 273,
  29953. "./sq.js": 273,
  29954. "./sr": 274,
  29955. "./sr-cyrl": 275,
  29956. "./sr-cyrl.js": 275,
  29957. "./sr.js": 274,
  29958. "./ss": 276,
  29959. "./ss.js": 276,
  29960. "./sv": 277,
  29961. "./sv.js": 277,
  29962. "./sw": 278,
  29963. "./sw.js": 278,
  29964. "./ta": 279,
  29965. "./ta.js": 279,
  29966. "./te": 280,
  29967. "./te.js": 280,
  29968. "./tet": 281,
  29969. "./tet.js": 281,
  29970. "./th": 282,
  29971. "./th.js": 282,
  29972. "./tl-ph": 283,
  29973. "./tl-ph.js": 283,
  29974. "./tlh": 284,
  29975. "./tlh.js": 284,
  29976. "./tr": 285,
  29977. "./tr.js": 285,
  29978. "./tzl": 286,
  29979. "./tzl.js": 286,
  29980. "./tzm": 287,
  29981. "./tzm-latn": 288,
  29982. "./tzm-latn.js": 288,
  29983. "./tzm.js": 287,
  29984. "./uk": 289,
  29985. "./uk.js": 289,
  29986. "./ur": 290,
  29987. "./ur.js": 290,
  29988. "./uz": 291,
  29989. "./uz-latn": 292,
  29990. "./uz-latn.js": 292,
  29991. "./uz.js": 291,
  29992. "./vi": 293,
  29993. "./vi.js": 293,
  29994. "./x-pseudo": 294,
  29995. "./x-pseudo.js": 294,
  29996. "./yo": 295,
  29997. "./yo.js": 295,
  29998. "./zh-cn": 296,
  29999. "./zh-cn.js": 296,
  30000. "./zh-hk": 297,
  30001. "./zh-hk.js": 297,
  30002. "./zh-tw": 298,
  30003. "./zh-tw.js": 298
  30004. };
  30005. function webpackContext(req) {
  30006. return __webpack_require__(webpackContextResolve(req));
  30007. };
  30008. function webpackContextResolve(req) {
  30009. var id = map[req];
  30010. if(!(id + 1)) // check for number or string
  30011. throw new Error("Cannot find module '" + req + "'.");
  30012. return id;
  30013. };
  30014. webpackContext.keys = function webpackContextKeys() {
  30015. return Object.keys(map);
  30016. };
  30017. webpackContext.resolve = webpackContextResolve;
  30018. module.exports = webpackContext;
  30019. webpackContext.id = 350;
  30020. /***/ }),
  30021. /* 351 */
  30022. /***/ (function(module, exports, __webpack_require__) {
  30023. "use strict";
  30024. exports.__esModule = true;
  30025. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  30026. var _element = __webpack_require__(0);
  30027. var _base = __webpack_require__(35);
  30028. var _base2 = _interopRequireDefault(_base);
  30029. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  30030. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  30031. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  30032. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  30033. /**
  30034. * @class LeftOverlay
  30035. */
  30036. var LeftOverlay = function (_Overlay) {
  30037. _inherits(LeftOverlay, _Overlay);
  30038. /**
  30039. * @param {Walkontable} wotInstance
  30040. */
  30041. function LeftOverlay(wotInstance) {
  30042. _classCallCheck(this, LeftOverlay);
  30043. var _this = _possibleConstructorReturn(this, (LeftOverlay.__proto__ || Object.getPrototypeOf(LeftOverlay)).call(this, wotInstance));
  30044. _this.clone = _this.makeClone(_base2.default.CLONE_LEFT);
  30045. return _this;
  30046. }
  30047. /**
  30048. * Checks if overlay should be fully rendered
  30049. *
  30050. * @returns {Boolean}
  30051. */
  30052. _createClass(LeftOverlay, [{
  30053. key: 'shouldBeRendered',
  30054. value: function shouldBeRendered() {
  30055. return !!(this.wot.getSetting('fixedColumnsLeft') || this.wot.getSetting('rowHeaders').length);
  30056. }
  30057. /**
  30058. * Updates the left overlay position
  30059. */
  30060. }, {
  30061. key: 'resetFixedPosition',
  30062. value: function resetFixedPosition() {
  30063. if (!this.needFullRender || !this.wot.wtTable.holder.parentNode) {
  30064. // removed from DOM
  30065. return;
  30066. }
  30067. var overlayRoot = this.clone.wtTable.holder.parentNode;
  30068. var headerPosition = 0;
  30069. var preventOverflow = this.wot.getSetting('preventOverflow');
  30070. if (this.trimmingContainer === window && (!preventOverflow || preventOverflow !== 'horizontal')) {
  30071. var box = this.wot.wtTable.hider.getBoundingClientRect();
  30072. var left = Math.ceil(box.left);
  30073. var right = Math.ceil(box.right);
  30074. var finalLeft = void 0;
  30075. var finalTop = void 0;
  30076. finalTop = this.wot.wtTable.hider.style.top;
  30077. finalTop = finalTop === '' ? 0 : finalTop;
  30078. if (left < 0 && right - overlayRoot.offsetWidth > 0) {
  30079. finalLeft = -left;
  30080. } else {
  30081. finalLeft = 0;
  30082. }
  30083. headerPosition = finalLeft;
  30084. finalLeft += 'px';
  30085. (0, _element.setOverlayPosition)(overlayRoot, finalLeft, finalTop);
  30086. } else {
  30087. headerPosition = this.getScrollPosition();
  30088. (0, _element.resetCssTransform)(overlayRoot);
  30089. }
  30090. this.adjustHeaderBordersPosition(headerPosition);
  30091. this.adjustElementsSize();
  30092. }
  30093. /**
  30094. * Sets the main overlay's horizontal scroll position
  30095. *
  30096. * @param {Number} pos
  30097. */
  30098. }, {
  30099. key: 'setScrollPosition',
  30100. value: function setScrollPosition(pos) {
  30101. if (this.mainTableScrollableElement === window) {
  30102. window.scrollTo(pos, (0, _element.getWindowScrollTop)());
  30103. } else {
  30104. this.mainTableScrollableElement.scrollLeft = pos;
  30105. }
  30106. }
  30107. /**
  30108. * Triggers onScroll hook callback
  30109. */
  30110. }, {
  30111. key: 'onScroll',
  30112. value: function onScroll() {
  30113. this.wot.getSetting('onScrollVertically');
  30114. }
  30115. /**
  30116. * Calculates total sum cells width
  30117. *
  30118. * @param {Number} from Column index which calculates started from
  30119. * @param {Number} to Column index where calculation is finished
  30120. * @returns {Number} Width sum
  30121. */
  30122. }, {
  30123. key: 'sumCellSizes',
  30124. value: function sumCellSizes(from, to) {
  30125. var sum = 0;
  30126. var defaultColumnWidth = this.wot.wtSettings.defaultColumnWidth;
  30127. while (from < to) {
  30128. sum += this.wot.wtTable.getStretchedColumnWidth(from) || defaultColumnWidth;
  30129. from++;
  30130. }
  30131. return sum;
  30132. }
  30133. /**
  30134. * Adjust overlay root element, childs and master table element sizes (width, height).
  30135. *
  30136. * @param {Boolean} [force=false]
  30137. */
  30138. }, {
  30139. key: 'adjustElementsSize',
  30140. value: function adjustElementsSize() {
  30141. var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  30142. this.updateTrimmingContainer();
  30143. if (this.needFullRender || force) {
  30144. this.adjustRootElementSize();
  30145. this.adjustRootChildrenSize();
  30146. if (!force) {
  30147. this.areElementSizesAdjusted = true;
  30148. }
  30149. }
  30150. }
  30151. /**
  30152. * Adjust overlay root element size (width and height).
  30153. */
  30154. }, {
  30155. key: 'adjustRootElementSize',
  30156. value: function adjustRootElementSize() {
  30157. var masterHolder = this.wot.wtTable.holder;
  30158. var scrollbarHeight = masterHolder.clientHeight === masterHolder.offsetHeight ? 0 : (0, _element.getScrollbarWidth)();
  30159. var overlayRoot = this.clone.wtTable.holder.parentNode;
  30160. var overlayRootStyle = overlayRoot.style;
  30161. var preventOverflow = this.wot.getSetting('preventOverflow');
  30162. var tableWidth = void 0;
  30163. if (this.trimmingContainer !== window || preventOverflow === 'vertical') {
  30164. var height = this.wot.wtViewport.getWorkspaceHeight() - scrollbarHeight;
  30165. height = Math.min(height, (0, _element.innerHeight)(this.wot.wtTable.wtRootElement));
  30166. overlayRootStyle.height = height + 'px';
  30167. } else {
  30168. overlayRootStyle.height = '';
  30169. }
  30170. this.clone.wtTable.holder.style.height = overlayRootStyle.height;
  30171. tableWidth = (0, _element.outerWidth)(this.clone.wtTable.TABLE);
  30172. overlayRootStyle.width = (tableWidth === 0 ? tableWidth : tableWidth + 4) + 'px';
  30173. }
  30174. /**
  30175. * Adjust overlay root childs size
  30176. */
  30177. }, {
  30178. key: 'adjustRootChildrenSize',
  30179. value: function adjustRootChildrenSize() {
  30180. var scrollbarWidth = (0, _element.getScrollbarWidth)();
  30181. this.clone.wtTable.hider.style.height = this.hider.style.height;
  30182. this.clone.wtTable.holder.style.height = this.clone.wtTable.holder.parentNode.style.height;
  30183. if (scrollbarWidth === 0) {
  30184. scrollbarWidth = 30;
  30185. }
  30186. this.clone.wtTable.holder.style.width = parseInt(this.clone.wtTable.holder.parentNode.style.width, 10) + scrollbarWidth + 'px';
  30187. }
  30188. /**
  30189. * Adjust the overlay dimensions and position
  30190. */
  30191. }, {
  30192. key: 'applyToDOM',
  30193. value: function applyToDOM() {
  30194. var total = this.wot.getSetting('totalColumns');
  30195. if (!this.areElementSizesAdjusted) {
  30196. this.adjustElementsSize();
  30197. }
  30198. if (typeof this.wot.wtViewport.columnsRenderCalculator.startPosition === 'number') {
  30199. this.spreader.style.left = this.wot.wtViewport.columnsRenderCalculator.startPosition + 'px';
  30200. } else if (total === 0) {
  30201. this.spreader.style.left = '0';
  30202. } else {
  30203. throw new Error('Incorrect value of the columnsRenderCalculator');
  30204. }
  30205. this.spreader.style.right = '';
  30206. if (this.needFullRender) {
  30207. this.syncOverlayOffset();
  30208. }
  30209. }
  30210. /**
  30211. * Synchronize calculated top position to an element
  30212. */
  30213. }, {
  30214. key: 'syncOverlayOffset',
  30215. value: function syncOverlayOffset() {
  30216. if (typeof this.wot.wtViewport.rowsRenderCalculator.startPosition === 'number') {
  30217. this.clone.wtTable.spreader.style.top = this.wot.wtViewport.rowsRenderCalculator.startPosition + 'px';
  30218. } else {
  30219. this.clone.wtTable.spreader.style.top = '';
  30220. }
  30221. }
  30222. /**
  30223. * Scrolls horizontally to a column at the left edge of the viewport
  30224. *
  30225. * @param sourceCol {Number} Column index which you want to scroll to
  30226. * @param [beyondRendered=false] {Boolean} if `true`, scrolls according to the bottom edge (top edge is by default)
  30227. */
  30228. }, {
  30229. key: 'scrollTo',
  30230. value: function scrollTo(sourceCol, beyondRendered) {
  30231. var newX = this.getTableParentOffset();
  30232. var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot;
  30233. var mainHolder = sourceInstance.wtTable.holder;
  30234. var scrollbarCompensation = 0;
  30235. if (beyondRendered && mainHolder.offsetWidth !== mainHolder.clientWidth) {
  30236. scrollbarCompensation = (0, _element.getScrollbarWidth)();
  30237. }
  30238. if (beyondRendered) {
  30239. newX += this.sumCellSizes(0, sourceCol + 1);
  30240. newX -= this.wot.wtViewport.getViewportWidth();
  30241. } else {
  30242. newX += this.sumCellSizes(this.wot.getSetting('fixedColumnsLeft'), sourceCol);
  30243. }
  30244. newX += scrollbarCompensation;
  30245. this.setScrollPosition(newX);
  30246. }
  30247. /**
  30248. * Gets table parent left position
  30249. *
  30250. * @returns {Number}
  30251. */
  30252. }, {
  30253. key: 'getTableParentOffset',
  30254. value: function getTableParentOffset() {
  30255. var preventOverflow = this.wot.getSetting('preventOverflow');
  30256. var offset = 0;
  30257. if (!preventOverflow && this.trimmingContainer === window) {
  30258. offset = this.wot.wtTable.holderOffset.left;
  30259. }
  30260. return offset;
  30261. }
  30262. /**
  30263. * Gets the main overlay's horizontal scroll position
  30264. *
  30265. * @returns {Number} Main table's vertical scroll position
  30266. */
  30267. }, {
  30268. key: 'getScrollPosition',
  30269. value: function getScrollPosition() {
  30270. return (0, _element.getScrollLeft)(this.mainTableScrollableElement);
  30271. }
  30272. /**
  30273. * Adds css classes to hide the header border's header (cell-selection border hiding issue)
  30274. *
  30275. * @param {Number} position Header X position if trimming container is window or scroll top if not
  30276. */
  30277. }, {
  30278. key: 'adjustHeaderBordersPosition',
  30279. value: function adjustHeaderBordersPosition(position) {
  30280. var masterParent = this.wot.wtTable.holder.parentNode;
  30281. var rowHeaders = this.wot.getSetting('rowHeaders');
  30282. var fixedColumnsLeft = this.wot.getSetting('fixedColumnsLeft');
  30283. var totalRows = this.wot.getSetting('totalRows');
  30284. if (totalRows) {
  30285. (0, _element.removeClass)(masterParent, 'emptyRows');
  30286. } else {
  30287. (0, _element.addClass)(masterParent, 'emptyRows');
  30288. }
  30289. if (fixedColumnsLeft && !rowHeaders.length) {
  30290. (0, _element.addClass)(masterParent, 'innerBorderLeft');
  30291. } else if (!fixedColumnsLeft && rowHeaders.length) {
  30292. var previousState = (0, _element.hasClass)(masterParent, 'innerBorderLeft');
  30293. if (position) {
  30294. (0, _element.addClass)(masterParent, 'innerBorderLeft');
  30295. } else {
  30296. (0, _element.removeClass)(masterParent, 'innerBorderLeft');
  30297. }
  30298. if (!previousState && position || previousState && !position) {
  30299. this.wot.wtOverlays.adjustElementsSize();
  30300. }
  30301. }
  30302. }
  30303. }]);
  30304. return LeftOverlay;
  30305. }(_base2.default);
  30306. _base2.default.registerOverlay(_base2.default.CLONE_LEFT, LeftOverlay);
  30307. exports.default = LeftOverlay;
  30308. /***/ }),
  30309. /* 352 */
  30310. /***/ (function(module, exports, __webpack_require__) {
  30311. "use strict";
  30312. exports.__esModule = true;
  30313. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  30314. var _element = __webpack_require__(0);
  30315. var _array = __webpack_require__(1);
  30316. var _base = __webpack_require__(35);
  30317. var _base2 = _interopRequireDefault(_base);
  30318. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  30319. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  30320. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  30321. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  30322. /**
  30323. * @class TopOverlay
  30324. */
  30325. var TopOverlay = function (_Overlay) {
  30326. _inherits(TopOverlay, _Overlay);
  30327. /**
  30328. * @param {Walkontable} wotInstance
  30329. */
  30330. function TopOverlay(wotInstance) {
  30331. _classCallCheck(this, TopOverlay);
  30332. var _this = _possibleConstructorReturn(this, (TopOverlay.__proto__ || Object.getPrototypeOf(TopOverlay)).call(this, wotInstance));
  30333. _this.clone = _this.makeClone(_base2.default.CLONE_TOP);
  30334. return _this;
  30335. }
  30336. /**
  30337. * Checks if overlay should be fully rendered
  30338. *
  30339. * @returns {Boolean}
  30340. */
  30341. _createClass(TopOverlay, [{
  30342. key: 'shouldBeRendered',
  30343. value: function shouldBeRendered() {
  30344. return !!(this.wot.getSetting('fixedRowsTop') || this.wot.getSetting('columnHeaders').length);
  30345. }
  30346. /**
  30347. * Updates the top overlay position
  30348. */
  30349. }, {
  30350. key: 'resetFixedPosition',
  30351. value: function resetFixedPosition() {
  30352. if (!this.needFullRender || !this.wot.wtTable.holder.parentNode) {
  30353. // removed from DOM
  30354. return;
  30355. }
  30356. var overlayRoot = this.clone.wtTable.holder.parentNode;
  30357. var headerPosition = 0;
  30358. var preventOverflow = this.wot.getSetting('preventOverflow');
  30359. if (this.trimmingContainer === window && (!preventOverflow || preventOverflow !== 'vertical')) {
  30360. var box = this.wot.wtTable.hider.getBoundingClientRect();
  30361. var top = Math.ceil(box.top);
  30362. var bottom = Math.ceil(box.bottom);
  30363. var finalLeft = void 0;
  30364. var finalTop = void 0;
  30365. finalLeft = this.wot.wtTable.hider.style.left;
  30366. finalLeft = finalLeft === '' ? 0 : finalLeft;
  30367. if (top < 0 && bottom - overlayRoot.offsetHeight > 0) {
  30368. finalTop = -top;
  30369. } else {
  30370. finalTop = 0;
  30371. }
  30372. headerPosition = finalTop;
  30373. finalTop += 'px';
  30374. (0, _element.setOverlayPosition)(overlayRoot, finalLeft, finalTop);
  30375. } else {
  30376. headerPosition = this.getScrollPosition();
  30377. (0, _element.resetCssTransform)(overlayRoot);
  30378. }
  30379. this.adjustHeaderBordersPosition(headerPosition);
  30380. this.adjustElementsSize();
  30381. }
  30382. /**
  30383. * Sets the main overlay's vertical scroll position
  30384. *
  30385. * @param {Number} pos
  30386. */
  30387. }, {
  30388. key: 'setScrollPosition',
  30389. value: function setScrollPosition(pos) {
  30390. if (this.mainTableScrollableElement === window) {
  30391. window.scrollTo((0, _element.getWindowScrollLeft)(), pos);
  30392. } else {
  30393. this.mainTableScrollableElement.scrollTop = pos;
  30394. }
  30395. }
  30396. /**
  30397. * Triggers onScroll hook callback
  30398. */
  30399. }, {
  30400. key: 'onScroll',
  30401. value: function onScroll() {
  30402. this.wot.getSetting('onScrollHorizontally');
  30403. }
  30404. /**
  30405. * Calculates total sum cells height
  30406. *
  30407. * @param {Number} from Row index which calculates started from
  30408. * @param {Number} to Row index where calculation is finished
  30409. * @returns {Number} Height sum
  30410. */
  30411. }, {
  30412. key: 'sumCellSizes',
  30413. value: function sumCellSizes(from, to) {
  30414. var sum = 0;
  30415. var defaultRowHeight = this.wot.wtSettings.settings.defaultRowHeight;
  30416. while (from < to) {
  30417. var height = this.wot.wtTable.getRowHeight(from);
  30418. sum += height === void 0 ? defaultRowHeight : height;
  30419. from++;
  30420. }
  30421. return sum;
  30422. }
  30423. /**
  30424. * Adjust overlay root element, childs and master table element sizes (width, height).
  30425. *
  30426. * @param {Boolean} [force=false]
  30427. */
  30428. }, {
  30429. key: 'adjustElementsSize',
  30430. value: function adjustElementsSize() {
  30431. var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  30432. this.updateTrimmingContainer();
  30433. if (this.needFullRender || force) {
  30434. this.adjustRootElementSize();
  30435. this.adjustRootChildrenSize();
  30436. if (!force) {
  30437. this.areElementSizesAdjusted = true;
  30438. }
  30439. }
  30440. }
  30441. /**
  30442. * Adjust overlay root element size (width and height).
  30443. */
  30444. }, {
  30445. key: 'adjustRootElementSize',
  30446. value: function adjustRootElementSize() {
  30447. var masterHolder = this.wot.wtTable.holder;
  30448. var scrollbarWidth = masterHolder.clientWidth === masterHolder.offsetWidth ? 0 : (0, _element.getScrollbarWidth)();
  30449. var overlayRoot = this.clone.wtTable.holder.parentNode;
  30450. var overlayRootStyle = overlayRoot.style;
  30451. var preventOverflow = this.wot.getSetting('preventOverflow');
  30452. var tableHeight = void 0;
  30453. if (this.trimmingContainer !== window || preventOverflow === 'horizontal') {
  30454. var width = this.wot.wtViewport.getWorkspaceWidth() - scrollbarWidth;
  30455. width = Math.min(width, (0, _element.innerWidth)(this.wot.wtTable.wtRootElement));
  30456. overlayRootStyle.width = width + 'px';
  30457. } else {
  30458. overlayRootStyle.width = '';
  30459. }
  30460. this.clone.wtTable.holder.style.width = overlayRootStyle.width;
  30461. tableHeight = (0, _element.outerHeight)(this.clone.wtTable.TABLE);
  30462. overlayRootStyle.height = (tableHeight === 0 ? tableHeight : tableHeight + 4) + 'px';
  30463. }
  30464. /**
  30465. * Adjust overlay root childs size
  30466. */
  30467. }, {
  30468. key: 'adjustRootChildrenSize',
  30469. value: function adjustRootChildrenSize() {
  30470. var scrollbarWidth = (0, _element.getScrollbarWidth)();
  30471. this.clone.wtTable.hider.style.width = this.hider.style.width;
  30472. this.clone.wtTable.holder.style.width = this.clone.wtTable.holder.parentNode.style.width;
  30473. if (scrollbarWidth === 0) {
  30474. scrollbarWidth = 30;
  30475. }
  30476. this.clone.wtTable.holder.style.height = parseInt(this.clone.wtTable.holder.parentNode.style.height, 10) + scrollbarWidth + 'px';
  30477. }
  30478. /**
  30479. * Adjust the overlay dimensions and position
  30480. */
  30481. }, {
  30482. key: 'applyToDOM',
  30483. value: function applyToDOM() {
  30484. var total = this.wot.getSetting('totalRows');
  30485. if (!this.areElementSizesAdjusted) {
  30486. this.adjustElementsSize();
  30487. }
  30488. if (typeof this.wot.wtViewport.rowsRenderCalculator.startPosition === 'number') {
  30489. this.spreader.style.top = this.wot.wtViewport.rowsRenderCalculator.startPosition + 'px';
  30490. } else if (total === 0) {
  30491. // can happen if there are 0 rows
  30492. this.spreader.style.top = '0';
  30493. } else {
  30494. throw new Error('Incorrect value of the rowsRenderCalculator');
  30495. }
  30496. this.spreader.style.bottom = '';
  30497. if (this.needFullRender) {
  30498. this.syncOverlayOffset();
  30499. }
  30500. }
  30501. /**
  30502. * Synchronize calculated left position to an element
  30503. */
  30504. }, {
  30505. key: 'syncOverlayOffset',
  30506. value: function syncOverlayOffset() {
  30507. if (typeof this.wot.wtViewport.columnsRenderCalculator.startPosition === 'number') {
  30508. this.clone.wtTable.spreader.style.left = this.wot.wtViewport.columnsRenderCalculator.startPosition + 'px';
  30509. } else {
  30510. this.clone.wtTable.spreader.style.left = '';
  30511. }
  30512. }
  30513. /**
  30514. * Scrolls vertically to a row
  30515. *
  30516. * @param sourceRow {Number} Row index which you want to scroll to
  30517. * @param [bottomEdge=false] {Boolean} if `true`, scrolls according to the bottom edge (top edge is by default)
  30518. */
  30519. }, {
  30520. key: 'scrollTo',
  30521. value: function scrollTo(sourceRow, bottomEdge) {
  30522. var newY = this.getTableParentOffset();
  30523. var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot;
  30524. var mainHolder = sourceInstance.wtTable.holder;
  30525. var scrollbarCompensation = 0;
  30526. if (bottomEdge && mainHolder.offsetHeight !== mainHolder.clientHeight) {
  30527. scrollbarCompensation = (0, _element.getScrollbarWidth)();
  30528. }
  30529. if (bottomEdge) {
  30530. var fixedRowsBottom = this.wot.getSetting('fixedRowsBottom');
  30531. var fixedRowsTop = this.wot.getSetting('fixedRowsTop');
  30532. var totalRows = this.wot.getSetting('totalRows');
  30533. newY += this.sumCellSizes(0, sourceRow + 1);
  30534. newY -= this.wot.wtViewport.getViewportHeight() - this.sumCellSizes(totalRows - fixedRowsBottom, totalRows);
  30535. // Fix 1 pixel offset when cell is selected
  30536. newY += 1;
  30537. } else {
  30538. newY += this.sumCellSizes(this.wot.getSetting('fixedRowsTop'), sourceRow);
  30539. }
  30540. newY += scrollbarCompensation;
  30541. this.setScrollPosition(newY);
  30542. }
  30543. /**
  30544. * Gets table parent top position
  30545. *
  30546. * @returns {Number}
  30547. */
  30548. }, {
  30549. key: 'getTableParentOffset',
  30550. value: function getTableParentOffset() {
  30551. if (this.mainTableScrollableElement === window) {
  30552. return this.wot.wtTable.holderOffset.top;
  30553. }
  30554. return 0;
  30555. }
  30556. /**
  30557. * Gets the main overlay's vertical scroll position
  30558. *
  30559. * @returns {Number} Main table's vertical scroll position
  30560. */
  30561. }, {
  30562. key: 'getScrollPosition',
  30563. value: function getScrollPosition() {
  30564. return (0, _element.getScrollTop)(this.mainTableScrollableElement);
  30565. }
  30566. /**
  30567. * Redraw borders of selection
  30568. *
  30569. * @param {WalkontableSelection} selection Selection for redraw
  30570. */
  30571. }, {
  30572. key: 'redrawSelectionBorders',
  30573. value: function redrawSelectionBorders(selection) {
  30574. if (selection && selection.cellRange) {
  30575. var border = selection.getBorder(this.wot);
  30576. var corners = selection.getCorners();
  30577. border.disappear();
  30578. border.appear(corners);
  30579. }
  30580. }
  30581. /**
  30582. * Redrawing borders of all selections
  30583. */
  30584. }, {
  30585. key: 'redrawAllSelectionsBorders',
  30586. value: function redrawAllSelectionsBorders() {
  30587. var _this2 = this;
  30588. var selections = this.wot.selections;
  30589. this.redrawSelectionBorders(selections.getCell());
  30590. (0, _array.arrayEach)(selections.getAreas(), function (area) {
  30591. _this2.redrawSelectionBorders(area);
  30592. });
  30593. this.redrawSelectionBorders(selections.getFill());
  30594. this.wot.wtTable.wot.wtOverlays.leftOverlay.refresh();
  30595. }
  30596. /**
  30597. * Adds css classes to hide the header border's header (cell-selection border hiding issue)
  30598. *
  30599. * @param {Number} position Header Y position if trimming container is window or scroll top if not
  30600. */
  30601. }, {
  30602. key: 'adjustHeaderBordersPosition',
  30603. value: function adjustHeaderBordersPosition(position) {
  30604. var masterParent = this.wot.wtTable.holder.parentNode;
  30605. var totalColumns = this.wot.getSetting('totalColumns');
  30606. if (totalColumns) {
  30607. (0, _element.removeClass)(masterParent, 'emptyColumns');
  30608. } else {
  30609. (0, _element.addClass)(masterParent, 'emptyColumns');
  30610. }
  30611. if (this.wot.getSetting('fixedRowsTop') === 0 && this.wot.getSetting('columnHeaders').length > 0) {
  30612. var previousState = (0, _element.hasClass)(masterParent, 'innerBorderTop');
  30613. if (position || this.wot.getSetting('totalRows') === 0) {
  30614. (0, _element.addClass)(masterParent, 'innerBorderTop');
  30615. } else {
  30616. (0, _element.removeClass)(masterParent, 'innerBorderTop');
  30617. }
  30618. if (!previousState && position || previousState && !position) {
  30619. this.wot.wtOverlays.adjustElementsSize();
  30620. // cell borders should be positioned once again,
  30621. // because we added / removed 1px border from table header
  30622. this.redrawAllSelectionsBorders();
  30623. }
  30624. }
  30625. // nasty workaround for double border in the header, TODO: find a pure-css solution
  30626. if (this.wot.getSetting('rowHeaders').length === 0) {
  30627. var secondHeaderCell = this.clone.wtTable.THEAD.querySelectorAll('th:nth-of-type(2)');
  30628. if (secondHeaderCell) {
  30629. for (var i = 0; i < secondHeaderCell.length; i++) {
  30630. secondHeaderCell[i].style['border-left-width'] = 0;
  30631. }
  30632. }
  30633. }
  30634. }
  30635. }]);
  30636. return TopOverlay;
  30637. }(_base2.default);
  30638. _base2.default.registerOverlay(_base2.default.CLONE_TOP, TopOverlay);
  30639. exports.default = TopOverlay;
  30640. /***/ }),
  30641. /* 353 */
  30642. /***/ (function(module, exports, __webpack_require__) {
  30643. "use strict";
  30644. exports.__esModule = true;
  30645. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  30646. var _element = __webpack_require__(0);
  30647. var _base = __webpack_require__(35);
  30648. var _base2 = _interopRequireDefault(_base);
  30649. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  30650. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  30651. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  30652. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  30653. /**
  30654. * @class TopLeftCornerOverlay
  30655. */
  30656. var TopLeftCornerOverlay = function (_Overlay) {
  30657. _inherits(TopLeftCornerOverlay, _Overlay);
  30658. /**
  30659. * @param {Walkontable} wotInstance
  30660. */
  30661. function TopLeftCornerOverlay(wotInstance) {
  30662. _classCallCheck(this, TopLeftCornerOverlay);
  30663. var _this = _possibleConstructorReturn(this, (TopLeftCornerOverlay.__proto__ || Object.getPrototypeOf(TopLeftCornerOverlay)).call(this, wotInstance));
  30664. _this.clone = _this.makeClone(_base2.default.CLONE_TOP_LEFT_CORNER);
  30665. return _this;
  30666. }
  30667. /**
  30668. * Checks if overlay should be fully rendered
  30669. *
  30670. * @returns {Boolean}
  30671. */
  30672. _createClass(TopLeftCornerOverlay, [{
  30673. key: 'shouldBeRendered',
  30674. value: function shouldBeRendered() {
  30675. return !!((this.wot.getSetting('fixedRowsTop') || this.wot.getSetting('columnHeaders').length) && (this.wot.getSetting('fixedColumnsLeft') || this.wot.getSetting('rowHeaders').length));
  30676. }
  30677. /**
  30678. * Updates the corner overlay position
  30679. */
  30680. }, {
  30681. key: 'resetFixedPosition',
  30682. value: function resetFixedPosition() {
  30683. this.updateTrimmingContainer();
  30684. if (!this.wot.wtTable.holder.parentNode) {
  30685. // removed from DOM
  30686. return;
  30687. }
  30688. var overlayRoot = this.clone.wtTable.holder.parentNode;
  30689. var tableHeight = (0, _element.outerHeight)(this.clone.wtTable.TABLE);
  30690. var tableWidth = (0, _element.outerWidth)(this.clone.wtTable.TABLE);
  30691. var preventOverflow = this.wot.getSetting('preventOverflow');
  30692. if (this.trimmingContainer === window) {
  30693. var box = this.wot.wtTable.hider.getBoundingClientRect();
  30694. var top = Math.ceil(box.top);
  30695. var left = Math.ceil(box.left);
  30696. var bottom = Math.ceil(box.bottom);
  30697. var right = Math.ceil(box.right);
  30698. var finalLeft = '0';
  30699. var finalTop = '0';
  30700. if (!preventOverflow || preventOverflow === 'vertical') {
  30701. if (left < 0 && right - overlayRoot.offsetWidth > 0) {
  30702. finalLeft = -left + 'px';
  30703. }
  30704. }
  30705. if (!preventOverflow || preventOverflow === 'horizontal') {
  30706. if (top < 0 && bottom - overlayRoot.offsetHeight > 0) {
  30707. finalTop = -top + 'px';
  30708. }
  30709. }
  30710. (0, _element.setOverlayPosition)(overlayRoot, finalLeft, finalTop);
  30711. } else {
  30712. (0, _element.resetCssTransform)(overlayRoot);
  30713. }
  30714. overlayRoot.style.height = (tableHeight === 0 ? tableHeight : tableHeight + 4) + 'px';
  30715. overlayRoot.style.width = (tableWidth === 0 ? tableWidth : tableWidth + 4) + 'px';
  30716. }
  30717. }]);
  30718. return TopLeftCornerOverlay;
  30719. }(_base2.default);
  30720. _base2.default.registerOverlay(_base2.default.CLONE_TOP_LEFT_CORNER, TopLeftCornerOverlay);
  30721. exports.default = TopLeftCornerOverlay;
  30722. /***/ }),
  30723. /* 354 */
  30724. /***/ (function(module, exports, __webpack_require__) {
  30725. "use strict";
  30726. exports.__esModule = true;
  30727. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  30728. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  30729. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  30730. var _element = __webpack_require__(0);
  30731. var _border = __webpack_require__(306);
  30732. var _border2 = _interopRequireDefault(_border);
  30733. var _coords = __webpack_require__(55);
  30734. var _coords2 = _interopRequireDefault(_coords);
  30735. var _range = __webpack_require__(86);
  30736. var _range2 = _interopRequireDefault(_range);
  30737. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  30738. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  30739. /**
  30740. * @class Selection
  30741. */
  30742. var Selection = function () {
  30743. /**
  30744. * @param {Object} settings
  30745. * @param {CellRange} cellRange
  30746. */
  30747. function Selection(settings, cellRange) {
  30748. _classCallCheck(this, Selection);
  30749. this.settings = settings;
  30750. this.cellRange = cellRange || null;
  30751. this.instanceBorders = {};
  30752. this.classNames = [this.settings.className];
  30753. this.classNameGenerator = this.linearClassNameGenerator(this.settings.className, this.settings.layerLevel);
  30754. }
  30755. /**
  30756. * Each Walkontable clone requires it's own border for every selection. This method creates and returns selection
  30757. * borders per instance
  30758. *
  30759. * @param {Walkontable} wotInstance
  30760. * @returns {Border}
  30761. */
  30762. _createClass(Selection, [{
  30763. key: 'getBorder',
  30764. value: function getBorder(wotInstance) {
  30765. if (!this.instanceBorders[wotInstance.guid]) {
  30766. this.instanceBorders[wotInstance.guid] = new _border2.default(wotInstance, this.settings);
  30767. }
  30768. return this.instanceBorders[wotInstance.guid];
  30769. }
  30770. /**
  30771. * Checks if selection is empty
  30772. *
  30773. * @returns {Boolean}
  30774. */
  30775. }, {
  30776. key: 'isEmpty',
  30777. value: function isEmpty() {
  30778. return this.cellRange === null;
  30779. }
  30780. /**
  30781. * Adds a cell coords to the selection
  30782. *
  30783. * @param {CellCoords} coords
  30784. */
  30785. }, {
  30786. key: 'add',
  30787. value: function add(coords) {
  30788. if (this.isEmpty()) {
  30789. this.cellRange = new _range2.default(coords);
  30790. } else {
  30791. this.cellRange.expand(coords);
  30792. }
  30793. return this;
  30794. }
  30795. /**
  30796. * If selection range from or to property equals oldCoords, replace it with newCoords. Return boolean
  30797. * information about success
  30798. *
  30799. * @param {CellCoords} oldCoords
  30800. * @param {CellCoords} newCoords
  30801. * @returns {Boolean}
  30802. */
  30803. }, {
  30804. key: 'replace',
  30805. value: function replace(oldCoords, newCoords) {
  30806. if (!this.isEmpty()) {
  30807. if (this.cellRange.from.isEqual(oldCoords)) {
  30808. this.cellRange.from = newCoords;
  30809. return true;
  30810. }
  30811. if (this.cellRange.to.isEqual(oldCoords)) {
  30812. this.cellRange.to = newCoords;
  30813. return true;
  30814. }
  30815. }
  30816. return false;
  30817. }
  30818. /**
  30819. * Clears selection
  30820. *
  30821. * @returns {Selection}
  30822. */
  30823. }, {
  30824. key: 'clear',
  30825. value: function clear() {
  30826. this.cellRange = null;
  30827. return this;
  30828. }
  30829. /**
  30830. * Returns the top left (TL) and bottom right (BR) selection coordinates
  30831. *
  30832. * @returns {Array} Returns array of coordinates for example `[1, 1, 5, 5]`
  30833. */
  30834. }, {
  30835. key: 'getCorners',
  30836. value: function getCorners() {
  30837. var topLeft = this.cellRange.getTopLeftCorner();
  30838. var bottomRight = this.cellRange.getBottomRightCorner();
  30839. return [topLeft.row, topLeft.col, bottomRight.row, bottomRight.col];
  30840. }
  30841. /**
  30842. * Adds class name to cell element at given coords
  30843. *
  30844. * @param {Walkontable} wotInstance Walkontable instance
  30845. * @param {Number} sourceRow Cell row coord
  30846. * @param {Number} sourceColumn Cell column coord
  30847. * @param {String} className Class name
  30848. * @param {Boolean} [markIntersections=false] If `true`, linear className generator will be used to add CSS classes
  30849. * in a continuous way.
  30850. * @returns {Selection}
  30851. */
  30852. }, {
  30853. key: 'addClassAtCoords',
  30854. value: function addClassAtCoords(wotInstance, sourceRow, sourceColumn, className) {
  30855. var markIntersections = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  30856. var TD = wotInstance.wtTable.getCell(new _coords2.default(sourceRow, sourceColumn));
  30857. if ((typeof TD === 'undefined' ? 'undefined' : _typeof(TD)) === 'object') {
  30858. if (markIntersections) {
  30859. className = this.classNameGenerator(TD);
  30860. if (!this.classNames.includes(className)) {
  30861. this.classNames.push(className);
  30862. }
  30863. }
  30864. (0, _element.addClass)(TD, className);
  30865. }
  30866. return this;
  30867. }
  30868. /**
  30869. * Generate helper for calculating classNames based on previously added base className.
  30870. * The generated className is always generated as a continuation of the previous className. For example, when
  30871. * the currently checked element has 'area-2' className the generated new className will be 'area-3'. When
  30872. * the element doesn't have any classNames than the base className will be returned ('area');
  30873. *
  30874. * @param {String} baseClassName Base className to be used.
  30875. * @param {Number} layerLevelOwner Layer level which the instance of the Selection belongs to.
  30876. * @return {Function}
  30877. */
  30878. }, {
  30879. key: 'linearClassNameGenerator',
  30880. value: function linearClassNameGenerator(baseClassName, layerLevelOwner) {
  30881. // TODO: Make this recursive function Proper Tail Calls (TCO/PTC) friendly.
  30882. return function calcClassName(element) {
  30883. var previousIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
  30884. if (layerLevelOwner === 0 || previousIndex === 0) {
  30885. return baseClassName;
  30886. }
  30887. var index = previousIndex >= 0 ? previousIndex : layerLevelOwner;
  30888. var className = baseClassName;
  30889. index -= 1;
  30890. var previousClassName = index === 0 ? baseClassName : baseClassName + '-' + index;
  30891. if ((0, _element.hasClass)(element, previousClassName)) {
  30892. var currentLayer = index + 1;
  30893. className = baseClassName + '-' + currentLayer;
  30894. } else {
  30895. className = calcClassName(element, index);
  30896. }
  30897. return className;
  30898. };
  30899. }
  30900. /**
  30901. * @param wotInstance
  30902. */
  30903. }, {
  30904. key: 'draw',
  30905. value: function draw(wotInstance) {
  30906. if (this.isEmpty()) {
  30907. if (this.settings.border) {
  30908. this.getBorder(wotInstance).disappear();
  30909. }
  30910. return;
  30911. }
  30912. var renderedRows = wotInstance.wtTable.getRenderedRowsCount();
  30913. var renderedColumns = wotInstance.wtTable.getRenderedColumnsCount();
  30914. var corners = this.getCorners();
  30915. var _corners = _slicedToArray(corners, 4),
  30916. topRow = _corners[0],
  30917. topColumn = _corners[1],
  30918. bottomRow = _corners[2],
  30919. bottomColumn = _corners[3];
  30920. for (var column = 0; column < renderedColumns; column += 1) {
  30921. var sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(column);
  30922. if (sourceCol >= topColumn && sourceCol <= bottomColumn) {
  30923. var TH = wotInstance.wtTable.getColumnHeader(sourceCol);
  30924. if (TH) {
  30925. var newClasses = [];
  30926. if (this.settings.highlightHeaderClassName) {
  30927. newClasses.push(this.settings.highlightHeaderClassName);
  30928. }
  30929. if (this.settings.highlightColumnClassName) {
  30930. newClasses.push(this.settings.highlightColumnClassName);
  30931. }
  30932. (0, _element.addClass)(TH, newClasses);
  30933. }
  30934. }
  30935. }
  30936. for (var row = 0; row < renderedRows; row += 1) {
  30937. var sourceRow = wotInstance.wtTable.rowFilter.renderedToSource(row);
  30938. if (sourceRow >= topRow && sourceRow <= bottomRow) {
  30939. var _TH = wotInstance.wtTable.getRowHeader(sourceRow);
  30940. if (_TH) {
  30941. var _newClasses = [];
  30942. if (this.settings.highlightHeaderClassName) {
  30943. _newClasses.push(this.settings.highlightHeaderClassName);
  30944. }
  30945. if (this.settings.highlightRowClassName) {
  30946. _newClasses.push(this.settings.highlightRowClassName);
  30947. }
  30948. (0, _element.addClass)(_TH, _newClasses);
  30949. }
  30950. }
  30951. for (var _column = 0; _column < renderedColumns; _column += 1) {
  30952. var _sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(_column);
  30953. if (sourceRow >= topRow && sourceRow <= bottomRow && _sourceCol >= topColumn && _sourceCol <= bottomColumn) {
  30954. // selected cell
  30955. if (this.settings.className) {
  30956. this.addClassAtCoords(wotInstance, sourceRow, _sourceCol, this.settings.className, this.settings.markIntersections);
  30957. }
  30958. } else if (sourceRow >= topRow && sourceRow <= bottomRow) {
  30959. // selection is in this row
  30960. if (this.settings.highlightRowClassName) {
  30961. this.addClassAtCoords(wotInstance, sourceRow, _sourceCol, this.settings.highlightRowClassName);
  30962. }
  30963. } else if (_sourceCol >= topColumn && _sourceCol <= bottomColumn) {
  30964. // selection is in this column
  30965. if (this.settings.highlightColumnClassName) {
  30966. this.addClassAtCoords(wotInstance, sourceRow, _sourceCol, this.settings.highlightColumnClassName);
  30967. }
  30968. }
  30969. var additionalSelectionClass = wotInstance.getSetting('onAfterDrawSelection', sourceRow, _sourceCol, corners, this.settings.layerLevel);
  30970. if (typeof additionalSelectionClass === 'string') {
  30971. this.addClassAtCoords(wotInstance, sourceRow, _sourceCol, additionalSelectionClass);
  30972. }
  30973. }
  30974. }
  30975. wotInstance.getSetting('onBeforeDrawBorders', corners, this.settings.className);
  30976. if (this.settings.border) {
  30977. // warning! border.appear modifies corners!
  30978. this.getBorder(wotInstance).appear(corners);
  30979. }
  30980. }
  30981. }]);
  30982. return Selection;
  30983. }();
  30984. exports.default = Selection;
  30985. /***/ }),
  30986. /* 355 */
  30987. /***/ (function(module, exports, __webpack_require__) {
  30988. "use strict";
  30989. /**
  30990. * autoResize - resizes a DOM element to the width and height of another DOM element
  30991. *
  30992. * Copyright 2014, Marcin Warpechowski
  30993. * Licensed under the MIT license
  30994. */
  30995. function autoResize() {
  30996. var defaults = {
  30997. minHeight: 200,
  30998. maxHeight: 300,
  30999. minWidth: 100,
  31000. maxWidth: 300
  31001. },
  31002. el,
  31003. body = document.body,
  31004. text = document.createTextNode(''),
  31005. span = document.createElement('SPAN'),
  31006. observe = function observe(element, event, handler) {
  31007. if (element.attachEvent) {
  31008. element.attachEvent('on' + event, handler);
  31009. } else {
  31010. element.addEventListener(event, handler, false);
  31011. }
  31012. },
  31013. _unObserve = function _unObserve(element, event, handler) {
  31014. if (element.removeEventListener) {
  31015. element.removeEventListener(event, handler, false);
  31016. } else {
  31017. element.detachEvent('on' + event, handler);
  31018. }
  31019. },
  31020. resize = function resize(newChar) {
  31021. var width, scrollHeight;
  31022. if (!newChar) {
  31023. newChar = "";
  31024. } else if (!/^[a-zA-Z \.,\\\/\|0-9]$/.test(newChar)) {
  31025. newChar = ".";
  31026. }
  31027. if (text.textContent !== void 0) {
  31028. text.textContent = el.value + newChar;
  31029. } else {
  31030. text.data = el.value + newChar; //IE8
  31031. }
  31032. span.style.fontSize = getComputedStyle(el).fontSize;
  31033. span.style.fontFamily = getComputedStyle(el).fontFamily;
  31034. span.style.whiteSpace = "pre";
  31035. body.appendChild(span);
  31036. width = span.clientWidth + 2;
  31037. body.removeChild(span);
  31038. el.style.height = defaults.minHeight + 'px';
  31039. if (defaults.minWidth > width) {
  31040. el.style.width = defaults.minWidth + 'px';
  31041. } else if (width > defaults.maxWidth) {
  31042. el.style.width = defaults.maxWidth + 'px';
  31043. } else {
  31044. el.style.width = width + 'px';
  31045. }
  31046. scrollHeight = el.scrollHeight ? el.scrollHeight - 1 : 0;
  31047. if (defaults.minHeight > scrollHeight) {
  31048. el.style.height = defaults.minHeight + 'px';
  31049. } else if (defaults.maxHeight < scrollHeight) {
  31050. el.style.height = defaults.maxHeight + 'px';
  31051. el.style.overflowY = 'visible';
  31052. } else {
  31053. el.style.height = scrollHeight + 'px';
  31054. }
  31055. },
  31056. delayedResize = function delayedResize() {
  31057. window.setTimeout(resize, 0);
  31058. },
  31059. extendDefaults = function extendDefaults(config) {
  31060. if (config && config.minHeight) {
  31061. if (config.minHeight == 'inherit') {
  31062. defaults.minHeight = el.clientHeight;
  31063. } else {
  31064. var minHeight = parseInt(config.minHeight);
  31065. if (!isNaN(minHeight)) {
  31066. defaults.minHeight = minHeight;
  31067. }
  31068. }
  31069. }
  31070. if (config && config.maxHeight) {
  31071. if (config.maxHeight == 'inherit') {
  31072. defaults.maxHeight = el.clientHeight;
  31073. } else {
  31074. var maxHeight = parseInt(config.maxHeight);
  31075. if (!isNaN(maxHeight)) {
  31076. defaults.maxHeight = maxHeight;
  31077. }
  31078. }
  31079. }
  31080. if (config && config.minWidth) {
  31081. if (config.minWidth == 'inherit') {
  31082. defaults.minWidth = el.clientWidth;
  31083. } else {
  31084. var minWidth = parseInt(config.minWidth);
  31085. if (!isNaN(minWidth)) {
  31086. defaults.minWidth = minWidth;
  31087. }
  31088. }
  31089. }
  31090. if (config && config.maxWidth) {
  31091. if (config.maxWidth == 'inherit') {
  31092. defaults.maxWidth = el.clientWidth;
  31093. } else {
  31094. var maxWidth = parseInt(config.maxWidth);
  31095. if (!isNaN(maxWidth)) {
  31096. defaults.maxWidth = maxWidth;
  31097. }
  31098. }
  31099. }
  31100. if (!span.firstChild) {
  31101. span.className = "autoResize";
  31102. span.style.display = 'inline-block';
  31103. span.appendChild(text);
  31104. }
  31105. },
  31106. _init = function _init(el_, config, doObserve) {
  31107. el = el_;
  31108. extendDefaults(config);
  31109. if (el.nodeName == 'TEXTAREA') {
  31110. el.style.resize = 'none';
  31111. el.style.overflowY = '';
  31112. el.style.height = defaults.minHeight + 'px';
  31113. el.style.minWidth = defaults.minWidth + 'px';
  31114. el.style.maxWidth = defaults.maxWidth + 'px';
  31115. el.style.overflowY = 'hidden';
  31116. }
  31117. if (doObserve) {
  31118. observe(el, 'change', resize);
  31119. observe(el, 'cut', delayedResize);
  31120. observe(el, 'paste', delayedResize);
  31121. observe(el, 'drop', delayedResize);
  31122. observe(el, 'keydown', delayedResize);
  31123. observe(el, 'focus', resize);
  31124. }
  31125. resize();
  31126. };
  31127. function getComputedStyle(element) {
  31128. return element.currentStyle || document.defaultView.getComputedStyle(element);
  31129. }
  31130. return {
  31131. init: function init(el_, config, doObserve) {
  31132. _init(el_, config, doObserve);
  31133. },
  31134. unObserve: function unObserve() {
  31135. _unObserve(el, 'change', resize);
  31136. _unObserve(el, 'cut', delayedResize);
  31137. _unObserve(el, 'paste', delayedResize);
  31138. _unObserve(el, 'drop', delayedResize);
  31139. _unObserve(el, 'keydown', delayedResize);
  31140. _unObserve(el, 'focus', resize);
  31141. },
  31142. resize: resize
  31143. };
  31144. }
  31145. if (true) {
  31146. module.exports = autoResize;
  31147. }
  31148. /***/ }),
  31149. /* 356 */
  31150. /***/ (function(module, exports, __webpack_require__) {
  31151. "use strict";
  31152. exports.__esModule = true;
  31153. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  31154. var _baseEditor = __webpack_require__(54);
  31155. var _baseEditor2 = _interopRequireDefault(_baseEditor);
  31156. var _element = __webpack_require__(0);
  31157. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  31158. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  31159. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  31160. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  31161. /**
  31162. * @private
  31163. * @editor CheckboxEditor
  31164. * @class CheckboxEditor
  31165. */
  31166. var CheckboxEditor = function (_BaseEditor) {
  31167. _inherits(CheckboxEditor, _BaseEditor);
  31168. function CheckboxEditor() {
  31169. _classCallCheck(this, CheckboxEditor);
  31170. return _possibleConstructorReturn(this, (CheckboxEditor.__proto__ || Object.getPrototypeOf(CheckboxEditor)).apply(this, arguments));
  31171. }
  31172. _createClass(CheckboxEditor, [{
  31173. key: 'beginEditing',
  31174. value: function beginEditing(initialValue, event) {
  31175. // Just some events connected with checkbox editor are delegated here. Some `keydown` events like `enter` and `space` key press
  31176. // are handled inside `checkboxRenderer`. Some events come here from `editorManager`. Below `if` statement was created by author
  31177. // for purpose of handling only `doubleclick` event which may be done on a cell with checkbox.
  31178. if (event.type === 'mouseup') {
  31179. var checkbox = this.TD.querySelector('input[type="checkbox"]');
  31180. if (!(0, _element.hasClass)(checkbox, 'htBadValue')) {
  31181. checkbox.click();
  31182. }
  31183. }
  31184. }
  31185. }, {
  31186. key: 'finishEditing',
  31187. value: function finishEditing() {}
  31188. }, {
  31189. key: 'init',
  31190. value: function init() {}
  31191. }, {
  31192. key: 'open',
  31193. value: function open() {}
  31194. }, {
  31195. key: 'close',
  31196. value: function close() {}
  31197. }, {
  31198. key: 'getValue',
  31199. value: function getValue() {}
  31200. }, {
  31201. key: 'setValue',
  31202. value: function setValue() {}
  31203. }, {
  31204. key: 'focus',
  31205. value: function focus() {}
  31206. }]);
  31207. return CheckboxEditor;
  31208. }(_baseEditor2.default);
  31209. exports.default = CheckboxEditor;
  31210. /***/ }),
  31211. /* 357 */
  31212. /***/ (function(module, exports, __webpack_require__) {
  31213. "use strict";
  31214. exports.__esModule = true;
  31215. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  31216. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  31217. var _moment = __webpack_require__(41);
  31218. var _moment2 = _interopRequireDefault(_moment);
  31219. var _pikaday = __webpack_require__(358);
  31220. var _pikaday2 = _interopRequireDefault(_pikaday);
  31221. __webpack_require__(359);
  31222. var _element = __webpack_require__(0);
  31223. var _object = __webpack_require__(2);
  31224. var _eventManager = __webpack_require__(6);
  31225. var _eventManager2 = _interopRequireDefault(_eventManager);
  31226. var _unicode = __webpack_require__(21);
  31227. var _event = __webpack_require__(12);
  31228. var _textEditor = __webpack_require__(57);
  31229. var _textEditor2 = _interopRequireDefault(_textEditor);
  31230. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  31231. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  31232. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  31233. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  31234. /**
  31235. * @private
  31236. * @editor DateEditor
  31237. * @class DateEditor
  31238. * @dependencies TextEditor moment pikaday
  31239. */
  31240. var DateEditor = function (_TextEditor) {
  31241. _inherits(DateEditor, _TextEditor);
  31242. /**
  31243. * @param {Core} hotInstance Handsontable instance
  31244. * @private
  31245. */
  31246. function DateEditor(hotInstance) {
  31247. _classCallCheck(this, DateEditor);
  31248. // TODO: Move this option to general settings
  31249. var _this = _possibleConstructorReturn(this, (DateEditor.__proto__ || Object.getPrototypeOf(DateEditor)).call(this, hotInstance));
  31250. _this.defaultDateFormat = 'DD/MM/YYYY';
  31251. _this.isCellEdited = false;
  31252. _this.parentDestroyed = false;
  31253. return _this;
  31254. }
  31255. _createClass(DateEditor, [{
  31256. key: 'init',
  31257. value: function init() {
  31258. var _this2 = this;
  31259. if (typeof _moment2.default !== 'function') {
  31260. throw new Error('You need to include moment.js to your project.');
  31261. }
  31262. if (typeof _pikaday2.default !== 'function') {
  31263. throw new Error('You need to include Pikaday to your project.');
  31264. }
  31265. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'init', this).call(this);
  31266. this.instance.addHook('afterDestroy', function () {
  31267. _this2.parentDestroyed = true;
  31268. _this2.destroyElements();
  31269. });
  31270. }
  31271. /**
  31272. * Create data picker instance
  31273. */
  31274. }, {
  31275. key: 'createElements',
  31276. value: function createElements() {
  31277. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'createElements', this).call(this);
  31278. this.datePicker = document.createElement('DIV');
  31279. this.datePickerStyle = this.datePicker.style;
  31280. this.datePickerStyle.position = 'absolute';
  31281. this.datePickerStyle.top = 0;
  31282. this.datePickerStyle.left = 0;
  31283. this.datePickerStyle.zIndex = 9999;
  31284. (0, _element.addClass)(this.datePicker, 'htDatepickerHolder');
  31285. document.body.appendChild(this.datePicker);
  31286. this.$datePicker = new _pikaday2.default(this.getDatePickerConfig());
  31287. var eventManager = new _eventManager2.default(this);
  31288. /**
  31289. * Prevent recognizing clicking on datepicker as clicking outside of table
  31290. */
  31291. eventManager.addEventListener(this.datePicker, 'mousedown', function (event) {
  31292. return (0, _event.stopPropagation)(event);
  31293. });
  31294. this.hideDatepicker();
  31295. }
  31296. /**
  31297. * Destroy data picker instance
  31298. */
  31299. }, {
  31300. key: 'destroyElements',
  31301. value: function destroyElements() {
  31302. this.$datePicker.destroy();
  31303. }
  31304. /**
  31305. * Prepare editor to appear
  31306. *
  31307. * @param {Number} row Row index
  31308. * @param {Number} col Column index
  31309. * @param {String} prop Property name (passed when datasource is an array of objects)
  31310. * @param {HTMLTableCellElement} td Table cell element
  31311. * @param {*} originalValue Original value
  31312. * @param {Object} cellProperties Object with cell properties ({@see Core#getCellMeta})
  31313. */
  31314. }, {
  31315. key: 'prepare',
  31316. value: function prepare(row, col, prop, td, originalValue, cellProperties) {
  31317. this._opened = false;
  31318. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'prepare', this).call(this, row, col, prop, td, originalValue, cellProperties);
  31319. }
  31320. /**
  31321. * Open editor
  31322. *
  31323. * @param {Event} [event=null]
  31324. */
  31325. }, {
  31326. key: 'open',
  31327. value: function open() {
  31328. var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  31329. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'open', this).call(this);
  31330. this.showDatepicker(event);
  31331. }
  31332. /**
  31333. * Close editor
  31334. */
  31335. }, {
  31336. key: 'close',
  31337. value: function close() {
  31338. var _this3 = this;
  31339. this._opened = false;
  31340. this.instance._registerTimeout(setTimeout(function () {
  31341. _this3.instance._refreshBorders();
  31342. }, 0));
  31343. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'close', this).call(this);
  31344. }
  31345. /**
  31346. * @param {Boolean} [isCancelled=false]
  31347. * @param {Boolean} [ctrlDown=false]
  31348. */
  31349. }, {
  31350. key: 'finishEditing',
  31351. value: function finishEditing() {
  31352. var isCancelled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  31353. var ctrlDown = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  31354. if (isCancelled) {
  31355. // pressed ESC, restore original value
  31356. // var value = this.instance.getDataAtCell(this.row, this.col);
  31357. var value = this.originalValue;
  31358. if (value !== void 0) {
  31359. this.setValue(value);
  31360. }
  31361. }
  31362. this.hideDatepicker();
  31363. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'finishEditing', this).call(this, isCancelled, ctrlDown);
  31364. }
  31365. /**
  31366. * Show data picker
  31367. *
  31368. * @param {Event} event
  31369. */
  31370. }, {
  31371. key: 'showDatepicker',
  31372. value: function showDatepicker(event) {
  31373. this.$datePicker.config(this.getDatePickerConfig());
  31374. var offset = this.TD.getBoundingClientRect();
  31375. var dateFormat = this.cellProperties.dateFormat || this.defaultDateFormat;
  31376. var datePickerConfig = this.$datePicker.config();
  31377. var dateStr = void 0;
  31378. var isMouseDown = this.instance.view.isMouseDown();
  31379. var isMeta = event ? (0, _unicode.isMetaKey)(event.keyCode) : false;
  31380. this.datePickerStyle.top = window.pageYOffset + offset.top + (0, _element.outerHeight)(this.TD) + 'px';
  31381. this.datePickerStyle.left = window.pageXOffset + offset.left + 'px';
  31382. this.$datePicker._onInputFocus = function () {};
  31383. datePickerConfig.format = dateFormat;
  31384. if (this.originalValue) {
  31385. dateStr = this.originalValue;
  31386. if ((0, _moment2.default)(dateStr, dateFormat, true).isValid()) {
  31387. this.$datePicker.setMoment((0, _moment2.default)(dateStr, dateFormat), true);
  31388. }
  31389. // workaround for date/time cells - pikaday resets the cell value to 12:00 AM by default, this will overwrite the value.
  31390. if (this.getValue() !== this.originalValue) {
  31391. this.setValue(this.originalValue);
  31392. }
  31393. if (!isMeta && !isMouseDown) {
  31394. this.setValue('');
  31395. }
  31396. } else if (this.cellProperties.defaultDate) {
  31397. dateStr = this.cellProperties.defaultDate;
  31398. datePickerConfig.defaultDate = dateStr;
  31399. if ((0, _moment2.default)(dateStr, dateFormat, true).isValid()) {
  31400. this.$datePicker.setMoment((0, _moment2.default)(dateStr, dateFormat), true);
  31401. }
  31402. if (!isMeta && !isMouseDown) {
  31403. this.setValue('');
  31404. }
  31405. } else {
  31406. // if a default date is not defined, set a soft-default-date: display the current day and month in the
  31407. // datepicker, but don't fill the editor input
  31408. this.$datePicker.gotoToday();
  31409. }
  31410. this.datePickerStyle.display = 'block';
  31411. this.$datePicker.show();
  31412. }
  31413. /**
  31414. * Hide data picker
  31415. */
  31416. }, {
  31417. key: 'hideDatepicker',
  31418. value: function hideDatepicker() {
  31419. this.datePickerStyle.display = 'none';
  31420. this.$datePicker.hide();
  31421. }
  31422. /**
  31423. * Get date picker options.
  31424. *
  31425. * @returns {Object}
  31426. */
  31427. }, {
  31428. key: 'getDatePickerConfig',
  31429. value: function getDatePickerConfig() {
  31430. var _this4 = this;
  31431. var htInput = this.TEXTAREA;
  31432. var options = {};
  31433. if (this.cellProperties && this.cellProperties.datePickerConfig) {
  31434. (0, _object.deepExtend)(options, this.cellProperties.datePickerConfig);
  31435. }
  31436. var origOnSelect = options.onSelect;
  31437. var origOnClose = options.onClose;
  31438. options.field = htInput;
  31439. options.trigger = htInput;
  31440. options.container = this.datePicker;
  31441. options.bound = false;
  31442. options.format = options.format || this.defaultDateFormat;
  31443. options.reposition = options.reposition || false;
  31444. options.onSelect = function (dateStr) {
  31445. if (!isNaN(dateStr.getTime())) {
  31446. dateStr = (0, _moment2.default)(dateStr).format(_this4.cellProperties.dateFormat || _this4.defaultDateFormat);
  31447. }
  31448. _this4.setValue(dateStr);
  31449. _this4.hideDatepicker();
  31450. if (origOnSelect) {
  31451. origOnSelect();
  31452. }
  31453. };
  31454. options.onClose = function () {
  31455. if (!_this4.parentDestroyed) {
  31456. _this4.finishEditing(false);
  31457. }
  31458. if (origOnClose) {
  31459. origOnClose();
  31460. }
  31461. };
  31462. return options;
  31463. }
  31464. }]);
  31465. return DateEditor;
  31466. }(_textEditor2.default);
  31467. exports.default = DateEditor;
  31468. /***/ }),
  31469. /* 358 */
  31470. /***/ (function(module, exports, __webpack_require__) {
  31471. /*!
  31472. * Pikaday
  31473. *
  31474. * Copyright © 2014 David Bushell | BSD & MIT license | https://github.com/dbushell/Pikaday
  31475. */
  31476. (function (root, factory)
  31477. {
  31478. 'use strict';
  31479. var moment;
  31480. if (true) {
  31481. // CommonJS module
  31482. // Load moment.js as an optional dependency
  31483. try { moment = __webpack_require__(41); } catch (e) {}
  31484. module.exports = factory(moment);
  31485. } else if (typeof define === 'function' && define.amd) {
  31486. // AMD. Register as an anonymous module.
  31487. define(function (req)
  31488. {
  31489. // Load moment.js as an optional dependency
  31490. var id = 'moment';
  31491. try { moment = req(id); } catch (e) {}
  31492. return factory(moment);
  31493. });
  31494. } else {
  31495. root.Pikaday = factory(root.moment);
  31496. }
  31497. }(this, function (moment)
  31498. {
  31499. 'use strict';
  31500. /**
  31501. * feature detection and helper functions
  31502. */
  31503. var hasMoment = typeof moment === 'function',
  31504. hasEventListeners = !!window.addEventListener,
  31505. document = window.document,
  31506. sto = window.setTimeout,
  31507. addEvent = function(el, e, callback, capture)
  31508. {
  31509. if (hasEventListeners) {
  31510. el.addEventListener(e, callback, !!capture);
  31511. } else {
  31512. el.attachEvent('on' + e, callback);
  31513. }
  31514. },
  31515. removeEvent = function(el, e, callback, capture)
  31516. {
  31517. if (hasEventListeners) {
  31518. el.removeEventListener(e, callback, !!capture);
  31519. } else {
  31520. el.detachEvent('on' + e, callback);
  31521. }
  31522. },
  31523. fireEvent = function(el, eventName, data)
  31524. {
  31525. var ev;
  31526. if (document.createEvent) {
  31527. ev = document.createEvent('HTMLEvents');
  31528. ev.initEvent(eventName, true, false);
  31529. ev = extend(ev, data);
  31530. el.dispatchEvent(ev);
  31531. } else if (document.createEventObject) {
  31532. ev = document.createEventObject();
  31533. ev = extend(ev, data);
  31534. el.fireEvent('on' + eventName, ev);
  31535. }
  31536. },
  31537. trim = function(str)
  31538. {
  31539. return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g,'');
  31540. },
  31541. hasClass = function(el, cn)
  31542. {
  31543. return (' ' + el.className + ' ').indexOf(' ' + cn + ' ') !== -1;
  31544. },
  31545. addClass = function(el, cn)
  31546. {
  31547. if (!hasClass(el, cn)) {
  31548. el.className = (el.className === '') ? cn : el.className + ' ' + cn;
  31549. }
  31550. },
  31551. removeClass = function(el, cn)
  31552. {
  31553. el.className = trim((' ' + el.className + ' ').replace(' ' + cn + ' ', ' '));
  31554. },
  31555. isArray = function(obj)
  31556. {
  31557. return (/Array/).test(Object.prototype.toString.call(obj));
  31558. },
  31559. isDate = function(obj)
  31560. {
  31561. return (/Date/).test(Object.prototype.toString.call(obj)) && !isNaN(obj.getTime());
  31562. },
  31563. isWeekend = function(date)
  31564. {
  31565. var day = date.getDay();
  31566. return day === 0 || day === 6;
  31567. },
  31568. isLeapYear = function(year)
  31569. {
  31570. // solution by Matti Virkkunen: http://stackoverflow.com/a/4881951
  31571. return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
  31572. },
  31573. getDaysInMonth = function(year, month)
  31574. {
  31575. return [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
  31576. },
  31577. setToStartOfDay = function(date)
  31578. {
  31579. if (isDate(date)) date.setHours(0,0,0,0);
  31580. },
  31581. compareDates = function(a,b)
  31582. {
  31583. // weak date comparison (use setToStartOfDay(date) to ensure correct result)
  31584. return a.getTime() === b.getTime();
  31585. },
  31586. extend = function(to, from, overwrite)
  31587. {
  31588. var prop, hasProp;
  31589. for (prop in from) {
  31590. hasProp = to[prop] !== undefined;
  31591. if (hasProp && typeof from[prop] === 'object' && from[prop] !== null && from[prop].nodeName === undefined) {
  31592. if (isDate(from[prop])) {
  31593. if (overwrite) {
  31594. to[prop] = new Date(from[prop].getTime());
  31595. }
  31596. }
  31597. else if (isArray(from[prop])) {
  31598. if (overwrite) {
  31599. to[prop] = from[prop].slice(0);
  31600. }
  31601. } else {
  31602. to[prop] = extend({}, from[prop], overwrite);
  31603. }
  31604. } else if (overwrite || !hasProp) {
  31605. to[prop] = from[prop];
  31606. }
  31607. }
  31608. return to;
  31609. },
  31610. adjustCalendar = function(calendar) {
  31611. if (calendar.month < 0) {
  31612. calendar.year -= Math.ceil(Math.abs(calendar.month)/12);
  31613. calendar.month += 12;
  31614. }
  31615. if (calendar.month > 11) {
  31616. calendar.year += Math.floor(Math.abs(calendar.month)/12);
  31617. calendar.month -= 12;
  31618. }
  31619. return calendar;
  31620. },
  31621. /**
  31622. * defaults and localisation
  31623. */
  31624. defaults = {
  31625. // bind the picker to a form field
  31626. field: null,
  31627. // automatically show/hide the picker on `field` focus (default `true` if `field` is set)
  31628. bound: undefined,
  31629. // position of the datepicker, relative to the field (default to bottom & left)
  31630. // ('bottom' & 'left' keywords are not used, 'top' & 'right' are modifier on the bottom/left position)
  31631. position: 'bottom left',
  31632. // automatically fit in the viewport even if it means repositioning from the position option
  31633. reposition: true,
  31634. // the default output format for `.toString()` and `field` value
  31635. format: 'YYYY-MM-DD',
  31636. // the initial date to view when first opened
  31637. defaultDate: null,
  31638. // make the `defaultDate` the initial selected value
  31639. setDefaultDate: false,
  31640. // first day of week (0: Sunday, 1: Monday etc)
  31641. firstDay: 0,
  31642. // the default flag for moment's strict date parsing
  31643. formatStrict: false,
  31644. // the minimum/earliest date that can be selected
  31645. minDate: null,
  31646. // the maximum/latest date that can be selected
  31647. maxDate: null,
  31648. // number of years either side, or array of upper/lower range
  31649. yearRange: 10,
  31650. // show week numbers at head of row
  31651. showWeekNumber: false,
  31652. // used internally (don't config outside)
  31653. minYear: 0,
  31654. maxYear: 9999,
  31655. minMonth: undefined,
  31656. maxMonth: undefined,
  31657. startRange: null,
  31658. endRange: null,
  31659. isRTL: false,
  31660. // Additional text to append to the year in the calendar title
  31661. yearSuffix: '',
  31662. // Render the month after year in the calendar title
  31663. showMonthAfterYear: false,
  31664. // Render days of the calendar grid that fall in the next or previous month
  31665. showDaysInNextAndPreviousMonths: false,
  31666. // how many months are visible
  31667. numberOfMonths: 1,
  31668. // when numberOfMonths is used, this will help you to choose where the main calendar will be (default `left`, can be set to `right`)
  31669. // only used for the first display or when a selected date is not visible
  31670. mainCalendar: 'left',
  31671. // Specify a DOM element to render the calendar in
  31672. container: undefined,
  31673. // internationalization
  31674. i18n: {
  31675. previousMonth : 'Previous Month',
  31676. nextMonth : 'Next Month',
  31677. months : ['January','February','March','April','May','June','July','August','September','October','November','December'],
  31678. weekdays : ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
  31679. weekdaysShort : ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
  31680. },
  31681. // Theme Classname
  31682. theme: null,
  31683. // callback function
  31684. onSelect: null,
  31685. onOpen: null,
  31686. onClose: null,
  31687. onDraw: null
  31688. },
  31689. /**
  31690. * templating functions to abstract HTML rendering
  31691. */
  31692. renderDayName = function(opts, day, abbr)
  31693. {
  31694. day += opts.firstDay;
  31695. while (day >= 7) {
  31696. day -= 7;
  31697. }
  31698. return abbr ? opts.i18n.weekdaysShort[day] : opts.i18n.weekdays[day];
  31699. },
  31700. renderDay = function(opts)
  31701. {
  31702. var arr = [];
  31703. var ariaSelected = 'false';
  31704. if (opts.isEmpty) {
  31705. if (opts.showDaysInNextAndPreviousMonths) {
  31706. arr.push('is-outside-current-month');
  31707. } else {
  31708. return '<td class="is-empty"></td>';
  31709. }
  31710. }
  31711. if (opts.isDisabled) {
  31712. arr.push('is-disabled');
  31713. }
  31714. if (opts.isToday) {
  31715. arr.push('is-today');
  31716. }
  31717. if (opts.isSelected) {
  31718. arr.push('is-selected');
  31719. ariaSelected = 'true';
  31720. }
  31721. if (opts.isInRange) {
  31722. arr.push('is-inrange');
  31723. }
  31724. if (opts.isStartRange) {
  31725. arr.push('is-startrange');
  31726. }
  31727. if (opts.isEndRange) {
  31728. arr.push('is-endrange');
  31729. }
  31730. return '<td data-day="' + opts.day + '" class="' + arr.join(' ') + '" aria-selected="' + ariaSelected + '">' +
  31731. '<button class="pika-button pika-day" type="button" ' +
  31732. 'data-pika-year="' + opts.year + '" data-pika-month="' + opts.month + '" data-pika-day="' + opts.day + '">' +
  31733. opts.day +
  31734. '</button>' +
  31735. '</td>';
  31736. },
  31737. renderWeek = function (d, m, y) {
  31738. // Lifted from http://javascript.about.com/library/blweekyear.htm, lightly modified.
  31739. var onejan = new Date(y, 0, 1),
  31740. weekNum = Math.ceil((((new Date(y, m, d) - onejan) / 86400000) + onejan.getDay()+1)/7);
  31741. return '<td class="pika-week">' + weekNum + '</td>';
  31742. },
  31743. renderRow = function(days, isRTL)
  31744. {
  31745. return '<tr>' + (isRTL ? days.reverse() : days).join('') + '</tr>';
  31746. },
  31747. renderBody = function(rows)
  31748. {
  31749. return '<tbody>' + rows.join('') + '</tbody>';
  31750. },
  31751. renderHead = function(opts)
  31752. {
  31753. var i, arr = [];
  31754. if (opts.showWeekNumber) {
  31755. arr.push('<th></th>');
  31756. }
  31757. for (i = 0; i < 7; i++) {
  31758. arr.push('<th scope="col"><abbr title="' + renderDayName(opts, i) + '">' + renderDayName(opts, i, true) + '</abbr></th>');
  31759. }
  31760. return '<thead><tr>' + (opts.isRTL ? arr.reverse() : arr).join('') + '</tr></thead>';
  31761. },
  31762. renderTitle = function(instance, c, year, month, refYear, randId)
  31763. {
  31764. var i, j, arr,
  31765. opts = instance._o,
  31766. isMinYear = year === opts.minYear,
  31767. isMaxYear = year === opts.maxYear,
  31768. html = '<div id="' + randId + '" class="pika-title" role="heading" aria-live="assertive">',
  31769. monthHtml,
  31770. yearHtml,
  31771. prev = true,
  31772. next = true;
  31773. for (arr = [], i = 0; i < 12; i++) {
  31774. arr.push('<option value="' + (year === refYear ? i - c : 12 + i - c) + '"' +
  31775. (i === month ? ' selected="selected"': '') +
  31776. ((isMinYear && i < opts.minMonth) || (isMaxYear && i > opts.maxMonth) ? 'disabled="disabled"' : '') + '>' +
  31777. opts.i18n.months[i] + '</option>');
  31778. }
  31779. monthHtml = '<div class="pika-label">' + opts.i18n.months[month] + '<select class="pika-select pika-select-month" tabindex="-1">' + arr.join('') + '</select></div>';
  31780. if (isArray(opts.yearRange)) {
  31781. i = opts.yearRange[0];
  31782. j = opts.yearRange[1] + 1;
  31783. } else {
  31784. i = year - opts.yearRange;
  31785. j = 1 + year + opts.yearRange;
  31786. }
  31787. for (arr = []; i < j && i <= opts.maxYear; i++) {
  31788. if (i >= opts.minYear) {
  31789. arr.push('<option value="' + i + '"' + (i === year ? ' selected="selected"': '') + '>' + (i) + '</option>');
  31790. }
  31791. }
  31792. yearHtml = '<div class="pika-label">' + year + opts.yearSuffix + '<select class="pika-select pika-select-year" tabindex="-1">' + arr.join('') + '</select></div>';
  31793. if (opts.showMonthAfterYear) {
  31794. html += yearHtml + monthHtml;
  31795. } else {
  31796. html += monthHtml + yearHtml;
  31797. }
  31798. if (isMinYear && (month === 0 || opts.minMonth >= month)) {
  31799. prev = false;
  31800. }
  31801. if (isMaxYear && (month === 11 || opts.maxMonth <= month)) {
  31802. next = false;
  31803. }
  31804. if (c === 0) {
  31805. html += '<button class="pika-prev' + (prev ? '' : ' is-disabled') + '" type="button">' + opts.i18n.previousMonth + '</button>';
  31806. }
  31807. if (c === (instance._o.numberOfMonths - 1) ) {
  31808. html += '<button class="pika-next' + (next ? '' : ' is-disabled') + '" type="button">' + opts.i18n.nextMonth + '</button>';
  31809. }
  31810. return html += '</div>';
  31811. },
  31812. renderTable = function(opts, data, randId)
  31813. {
  31814. return '<table cellpadding="0" cellspacing="0" class="pika-table" role="grid" aria-labelledby="' + randId + '">' + renderHead(opts) + renderBody(data) + '</table>';
  31815. },
  31816. /**
  31817. * Pikaday constructor
  31818. */
  31819. Pikaday = function(options)
  31820. {
  31821. var self = this,
  31822. opts = self.config(options);
  31823. self._onMouseDown = function(e)
  31824. {
  31825. if (!self._v) {
  31826. return;
  31827. }
  31828. e = e || window.event;
  31829. var target = e.target || e.srcElement;
  31830. if (!target) {
  31831. return;
  31832. }
  31833. if (!hasClass(target, 'is-disabled')) {
  31834. if (hasClass(target, 'pika-button') && !hasClass(target, 'is-empty') && !hasClass(target.parentNode, 'is-disabled')) {
  31835. self.setDate(new Date(target.getAttribute('data-pika-year'), target.getAttribute('data-pika-month'), target.getAttribute('data-pika-day')));
  31836. if (opts.bound) {
  31837. sto(function() {
  31838. self.hide();
  31839. if (opts.field) {
  31840. opts.field.blur();
  31841. }
  31842. }, 100);
  31843. }
  31844. }
  31845. else if (hasClass(target, 'pika-prev')) {
  31846. self.prevMonth();
  31847. }
  31848. else if (hasClass(target, 'pika-next')) {
  31849. self.nextMonth();
  31850. }
  31851. }
  31852. if (!hasClass(target, 'pika-select')) {
  31853. // if this is touch event prevent mouse events emulation
  31854. if (e.preventDefault) {
  31855. e.preventDefault();
  31856. } else {
  31857. e.returnValue = false;
  31858. return false;
  31859. }
  31860. } else {
  31861. self._c = true;
  31862. }
  31863. };
  31864. self._onChange = function(e)
  31865. {
  31866. e = e || window.event;
  31867. var target = e.target || e.srcElement;
  31868. if (!target) {
  31869. return;
  31870. }
  31871. if (hasClass(target, 'pika-select-month')) {
  31872. self.gotoMonth(target.value);
  31873. }
  31874. else if (hasClass(target, 'pika-select-year')) {
  31875. self.gotoYear(target.value);
  31876. }
  31877. };
  31878. self._onKeyChange = function(e)
  31879. {
  31880. e = e || window.event;
  31881. if (self.isVisible()) {
  31882. switch(e.keyCode){
  31883. case 13:
  31884. case 27:
  31885. opts.field.blur();
  31886. break;
  31887. case 37:
  31888. e.preventDefault();
  31889. self.adjustDate('subtract', 1);
  31890. break;
  31891. case 38:
  31892. self.adjustDate('subtract', 7);
  31893. break;
  31894. case 39:
  31895. self.adjustDate('add', 1);
  31896. break;
  31897. case 40:
  31898. self.adjustDate('add', 7);
  31899. break;
  31900. }
  31901. }
  31902. };
  31903. self._onInputChange = function(e)
  31904. {
  31905. var date;
  31906. if (e.firedBy === self) {
  31907. return;
  31908. }
  31909. if (hasMoment) {
  31910. date = moment(opts.field.value, opts.format, opts.formatStrict);
  31911. date = (date && date.isValid()) ? date.toDate() : null;
  31912. }
  31913. else {
  31914. date = new Date(Date.parse(opts.field.value));
  31915. }
  31916. if (isDate(date)) {
  31917. self.setDate(date);
  31918. }
  31919. if (!self._v) {
  31920. self.show();
  31921. }
  31922. };
  31923. self._onInputFocus = function()
  31924. {
  31925. self.show();
  31926. };
  31927. self._onInputClick = function()
  31928. {
  31929. self.show();
  31930. };
  31931. self._onInputBlur = function()
  31932. {
  31933. // IE allows pika div to gain focus; catch blur the input field
  31934. var pEl = document.activeElement;
  31935. do {
  31936. if (hasClass(pEl, 'pika-single')) {
  31937. return;
  31938. }
  31939. }
  31940. while ((pEl = pEl.parentNode));
  31941. if (!self._c) {
  31942. self._b = sto(function() {
  31943. self.hide();
  31944. }, 50);
  31945. }
  31946. self._c = false;
  31947. };
  31948. self._onClick = function(e)
  31949. {
  31950. e = e || window.event;
  31951. var target = e.target || e.srcElement,
  31952. pEl = target;
  31953. if (!target) {
  31954. return;
  31955. }
  31956. if (!hasEventListeners && hasClass(target, 'pika-select')) {
  31957. if (!target.onchange) {
  31958. target.setAttribute('onchange', 'return;');
  31959. addEvent(target, 'change', self._onChange);
  31960. }
  31961. }
  31962. do {
  31963. if (hasClass(pEl, 'pika-single') || pEl === opts.trigger) {
  31964. return;
  31965. }
  31966. }
  31967. while ((pEl = pEl.parentNode));
  31968. if (self._v && target !== opts.trigger && pEl !== opts.trigger) {
  31969. self.hide();
  31970. }
  31971. };
  31972. self.el = document.createElement('div');
  31973. self.el.className = 'pika-single' + (opts.isRTL ? ' is-rtl' : '') + (opts.theme ? ' ' + opts.theme : '');
  31974. addEvent(self.el, 'mousedown', self._onMouseDown, true);
  31975. addEvent(self.el, 'touchend', self._onMouseDown, true);
  31976. addEvent(self.el, 'change', self._onChange);
  31977. addEvent(document, 'keydown', self._onKeyChange);
  31978. if (opts.field) {
  31979. if (opts.container) {
  31980. opts.container.appendChild(self.el);
  31981. } else if (opts.bound) {
  31982. document.body.appendChild(self.el);
  31983. } else {
  31984. opts.field.parentNode.insertBefore(self.el, opts.field.nextSibling);
  31985. }
  31986. addEvent(opts.field, 'change', self._onInputChange);
  31987. if (!opts.defaultDate) {
  31988. if (hasMoment && opts.field.value) {
  31989. opts.defaultDate = moment(opts.field.value, opts.format).toDate();
  31990. } else {
  31991. opts.defaultDate = new Date(Date.parse(opts.field.value));
  31992. }
  31993. opts.setDefaultDate = true;
  31994. }
  31995. }
  31996. var defDate = opts.defaultDate;
  31997. if (isDate(defDate)) {
  31998. if (opts.setDefaultDate) {
  31999. self.setDate(defDate, true);
  32000. } else {
  32001. self.gotoDate(defDate);
  32002. }
  32003. } else {
  32004. self.gotoDate(new Date());
  32005. }
  32006. if (opts.bound) {
  32007. this.hide();
  32008. self.el.className += ' is-bound';
  32009. addEvent(opts.trigger, 'click', self._onInputClick);
  32010. addEvent(opts.trigger, 'focus', self._onInputFocus);
  32011. addEvent(opts.trigger, 'blur', self._onInputBlur);
  32012. } else {
  32013. this.show();
  32014. }
  32015. };
  32016. /**
  32017. * public Pikaday API
  32018. */
  32019. Pikaday.prototype = {
  32020. /**
  32021. * configure functionality
  32022. */
  32023. config: function(options)
  32024. {
  32025. if (!this._o) {
  32026. this._o = extend({}, defaults, true);
  32027. }
  32028. var opts = extend(this._o, options, true);
  32029. opts.isRTL = !!opts.isRTL;
  32030. opts.field = (opts.field && opts.field.nodeName) ? opts.field : null;
  32031. opts.theme = (typeof opts.theme) === 'string' && opts.theme ? opts.theme : null;
  32032. opts.bound = !!(opts.bound !== undefined ? opts.field && opts.bound : opts.field);
  32033. opts.trigger = (opts.trigger && opts.trigger.nodeName) ? opts.trigger : opts.field;
  32034. opts.disableWeekends = !!opts.disableWeekends;
  32035. opts.disableDayFn = (typeof opts.disableDayFn) === 'function' ? opts.disableDayFn : null;
  32036. var nom = parseInt(opts.numberOfMonths, 10) || 1;
  32037. opts.numberOfMonths = nom > 4 ? 4 : nom;
  32038. if (!isDate(opts.minDate)) {
  32039. opts.minDate = false;
  32040. }
  32041. if (!isDate(opts.maxDate)) {
  32042. opts.maxDate = false;
  32043. }
  32044. if ((opts.minDate && opts.maxDate) && opts.maxDate < opts.minDate) {
  32045. opts.maxDate = opts.minDate = false;
  32046. }
  32047. if (opts.minDate) {
  32048. this.setMinDate(opts.minDate);
  32049. }
  32050. if (opts.maxDate) {
  32051. this.setMaxDate(opts.maxDate);
  32052. }
  32053. if (isArray(opts.yearRange)) {
  32054. var fallback = new Date().getFullYear() - 10;
  32055. opts.yearRange[0] = parseInt(opts.yearRange[0], 10) || fallback;
  32056. opts.yearRange[1] = parseInt(opts.yearRange[1], 10) || fallback;
  32057. } else {
  32058. opts.yearRange = Math.abs(parseInt(opts.yearRange, 10)) || defaults.yearRange;
  32059. if (opts.yearRange > 100) {
  32060. opts.yearRange = 100;
  32061. }
  32062. }
  32063. return opts;
  32064. },
  32065. /**
  32066. * return a formatted string of the current selection (using Moment.js if available)
  32067. */
  32068. toString: function(format)
  32069. {
  32070. return !isDate(this._d) ? '' : hasMoment ? moment(this._d).format(format || this._o.format) : this._d.toDateString();
  32071. },
  32072. /**
  32073. * return a Moment.js object of the current selection (if available)
  32074. */
  32075. getMoment: function()
  32076. {
  32077. return hasMoment ? moment(this._d) : null;
  32078. },
  32079. /**
  32080. * set the current selection from a Moment.js object (if available)
  32081. */
  32082. setMoment: function(date, preventOnSelect)
  32083. {
  32084. if (hasMoment && moment.isMoment(date)) {
  32085. this.setDate(date.toDate(), preventOnSelect);
  32086. }
  32087. },
  32088. /**
  32089. * return a Date object of the current selection with fallback for the current date
  32090. */
  32091. getDate: function()
  32092. {
  32093. return isDate(this._d) ? new Date(this._d.getTime()) : new Date();
  32094. },
  32095. /**
  32096. * set the current selection
  32097. */
  32098. setDate: function(date, preventOnSelect)
  32099. {
  32100. if (!date) {
  32101. this._d = null;
  32102. if (this._o.field) {
  32103. this._o.field.value = '';
  32104. fireEvent(this._o.field, 'change', { firedBy: this });
  32105. }
  32106. return this.draw();
  32107. }
  32108. if (typeof date === 'string') {
  32109. date = new Date(Date.parse(date));
  32110. }
  32111. if (!isDate(date)) {
  32112. return;
  32113. }
  32114. var min = this._o.minDate,
  32115. max = this._o.maxDate;
  32116. if (isDate(min) && date < min) {
  32117. date = min;
  32118. } else if (isDate(max) && date > max) {
  32119. date = max;
  32120. }
  32121. this._d = new Date(date.getTime());
  32122. setToStartOfDay(this._d);
  32123. this.gotoDate(this._d);
  32124. if (this._o.field) {
  32125. this._o.field.value = this.toString();
  32126. fireEvent(this._o.field, 'change', { firedBy: this });
  32127. }
  32128. if (!preventOnSelect && typeof this._o.onSelect === 'function') {
  32129. this._o.onSelect.call(this, this.getDate());
  32130. }
  32131. },
  32132. /**
  32133. * change view to a specific date
  32134. */
  32135. gotoDate: function(date)
  32136. {
  32137. var newCalendar = true;
  32138. if (!isDate(date)) {
  32139. return;
  32140. }
  32141. if (this.calendars) {
  32142. var firstVisibleDate = new Date(this.calendars[0].year, this.calendars[0].month, 1),
  32143. lastVisibleDate = new Date(this.calendars[this.calendars.length-1].year, this.calendars[this.calendars.length-1].month, 1),
  32144. visibleDate = date.getTime();
  32145. // get the end of the month
  32146. lastVisibleDate.setMonth(lastVisibleDate.getMonth()+1);
  32147. lastVisibleDate.setDate(lastVisibleDate.getDate()-1);
  32148. newCalendar = (visibleDate < firstVisibleDate.getTime() || lastVisibleDate.getTime() < visibleDate);
  32149. }
  32150. if (newCalendar) {
  32151. this.calendars = [{
  32152. month: date.getMonth(),
  32153. year: date.getFullYear()
  32154. }];
  32155. if (this._o.mainCalendar === 'right') {
  32156. this.calendars[0].month += 1 - this._o.numberOfMonths;
  32157. }
  32158. }
  32159. this.adjustCalendars();
  32160. },
  32161. adjustDate: function(sign, days) {
  32162. var day = this.getDate();
  32163. var difference = parseInt(days)*24*60*60*1000;
  32164. var newDay;
  32165. if (sign === 'add') {
  32166. newDay = new Date(day.valueOf() + difference);
  32167. } else if (sign === 'subtract') {
  32168. newDay = new Date(day.valueOf() - difference);
  32169. }
  32170. if (hasMoment) {
  32171. if (sign === 'add') {
  32172. newDay = moment(day).add(days, "days").toDate();
  32173. } else if (sign === 'subtract') {
  32174. newDay = moment(day).subtract(days, "days").toDate();
  32175. }
  32176. }
  32177. this.setDate(newDay);
  32178. },
  32179. adjustCalendars: function() {
  32180. this.calendars[0] = adjustCalendar(this.calendars[0]);
  32181. for (var c = 1; c < this._o.numberOfMonths; c++) {
  32182. this.calendars[c] = adjustCalendar({
  32183. month: this.calendars[0].month + c,
  32184. year: this.calendars[0].year
  32185. });
  32186. }
  32187. this.draw();
  32188. },
  32189. gotoToday: function()
  32190. {
  32191. this.gotoDate(new Date());
  32192. },
  32193. /**
  32194. * change view to a specific month (zero-index, e.g. 0: January)
  32195. */
  32196. gotoMonth: function(month)
  32197. {
  32198. if (!isNaN(month)) {
  32199. this.calendars[0].month = parseInt(month, 10);
  32200. this.adjustCalendars();
  32201. }
  32202. },
  32203. nextMonth: function()
  32204. {
  32205. this.calendars[0].month++;
  32206. this.adjustCalendars();
  32207. },
  32208. prevMonth: function()
  32209. {
  32210. this.calendars[0].month--;
  32211. this.adjustCalendars();
  32212. },
  32213. /**
  32214. * change view to a specific full year (e.g. "2012")
  32215. */
  32216. gotoYear: function(year)
  32217. {
  32218. if (!isNaN(year)) {
  32219. this.calendars[0].year = parseInt(year, 10);
  32220. this.adjustCalendars();
  32221. }
  32222. },
  32223. /**
  32224. * change the minDate
  32225. */
  32226. setMinDate: function(value)
  32227. {
  32228. if(value instanceof Date) {
  32229. setToStartOfDay(value);
  32230. this._o.minDate = value;
  32231. this._o.minYear = value.getFullYear();
  32232. this._o.minMonth = value.getMonth();
  32233. } else {
  32234. this._o.minDate = defaults.minDate;
  32235. this._o.minYear = defaults.minYear;
  32236. this._o.minMonth = defaults.minMonth;
  32237. this._o.startRange = defaults.startRange;
  32238. }
  32239. this.draw();
  32240. },
  32241. /**
  32242. * change the maxDate
  32243. */
  32244. setMaxDate: function(value)
  32245. {
  32246. if(value instanceof Date) {
  32247. setToStartOfDay(value);
  32248. this._o.maxDate = value;
  32249. this._o.maxYear = value.getFullYear();
  32250. this._o.maxMonth = value.getMonth();
  32251. } else {
  32252. this._o.maxDate = defaults.maxDate;
  32253. this._o.maxYear = defaults.maxYear;
  32254. this._o.maxMonth = defaults.maxMonth;
  32255. this._o.endRange = defaults.endRange;
  32256. }
  32257. this.draw();
  32258. },
  32259. setStartRange: function(value)
  32260. {
  32261. this._o.startRange = value;
  32262. },
  32263. setEndRange: function(value)
  32264. {
  32265. this._o.endRange = value;
  32266. },
  32267. /**
  32268. * refresh the HTML
  32269. */
  32270. draw: function(force)
  32271. {
  32272. if (!this._v && !force) {
  32273. return;
  32274. }
  32275. var opts = this._o,
  32276. minYear = opts.minYear,
  32277. maxYear = opts.maxYear,
  32278. minMonth = opts.minMonth,
  32279. maxMonth = opts.maxMonth,
  32280. html = '',
  32281. randId;
  32282. if (this._y <= minYear) {
  32283. this._y = minYear;
  32284. if (!isNaN(minMonth) && this._m < minMonth) {
  32285. this._m = minMonth;
  32286. }
  32287. }
  32288. if (this._y >= maxYear) {
  32289. this._y = maxYear;
  32290. if (!isNaN(maxMonth) && this._m > maxMonth) {
  32291. this._m = maxMonth;
  32292. }
  32293. }
  32294. randId = 'pika-title-' + Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 2);
  32295. for (var c = 0; c < opts.numberOfMonths; c++) {
  32296. html += '<div class="pika-lendar">' + renderTitle(this, c, this.calendars[c].year, this.calendars[c].month, this.calendars[0].year, randId) + this.render(this.calendars[c].year, this.calendars[c].month, randId) + '</div>';
  32297. }
  32298. this.el.innerHTML = html;
  32299. if (opts.bound) {
  32300. if(opts.field.type !== 'hidden') {
  32301. sto(function() {
  32302. opts.trigger.focus();
  32303. }, 1);
  32304. }
  32305. }
  32306. if (typeof this._o.onDraw === 'function') {
  32307. this._o.onDraw(this);
  32308. }
  32309. if (opts.bound) {
  32310. // let the screen reader user know to use arrow keys
  32311. opts.field.setAttribute('aria-label', 'Use the arrow keys to pick a date');
  32312. }
  32313. },
  32314. adjustPosition: function()
  32315. {
  32316. var field, pEl, width, height, viewportWidth, viewportHeight, scrollTop, left, top, clientRect;
  32317. if (this._o.container) return;
  32318. this.el.style.position = 'absolute';
  32319. field = this._o.trigger;
  32320. pEl = field;
  32321. width = this.el.offsetWidth;
  32322. height = this.el.offsetHeight;
  32323. viewportWidth = window.innerWidth || document.documentElement.clientWidth;
  32324. viewportHeight = window.innerHeight || document.documentElement.clientHeight;
  32325. scrollTop = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
  32326. if (typeof field.getBoundingClientRect === 'function') {
  32327. clientRect = field.getBoundingClientRect();
  32328. left = clientRect.left + window.pageXOffset;
  32329. top = clientRect.bottom + window.pageYOffset;
  32330. } else {
  32331. left = pEl.offsetLeft;
  32332. top = pEl.offsetTop + pEl.offsetHeight;
  32333. while((pEl = pEl.offsetParent)) {
  32334. left += pEl.offsetLeft;
  32335. top += pEl.offsetTop;
  32336. }
  32337. }
  32338. // default position is bottom & left
  32339. if ((this._o.reposition && left + width > viewportWidth) ||
  32340. (
  32341. this._o.position.indexOf('right') > -1 &&
  32342. left - width + field.offsetWidth > 0
  32343. )
  32344. ) {
  32345. left = left - width + field.offsetWidth;
  32346. }
  32347. if ((this._o.reposition && top + height > viewportHeight + scrollTop) ||
  32348. (
  32349. this._o.position.indexOf('top') > -1 &&
  32350. top - height - field.offsetHeight > 0
  32351. )
  32352. ) {
  32353. top = top - height - field.offsetHeight;
  32354. }
  32355. this.el.style.left = left + 'px';
  32356. this.el.style.top = top + 'px';
  32357. },
  32358. /**
  32359. * render HTML for a particular month
  32360. */
  32361. render: function(year, month, randId)
  32362. {
  32363. var opts = this._o,
  32364. now = new Date(),
  32365. days = getDaysInMonth(year, month),
  32366. before = new Date(year, month, 1).getDay(),
  32367. data = [],
  32368. row = [];
  32369. setToStartOfDay(now);
  32370. if (opts.firstDay > 0) {
  32371. before -= opts.firstDay;
  32372. if (before < 0) {
  32373. before += 7;
  32374. }
  32375. }
  32376. var previousMonth = month === 0 ? 11 : month - 1,
  32377. nextMonth = month === 11 ? 0 : month + 1,
  32378. yearOfPreviousMonth = month === 0 ? year - 1 : year,
  32379. yearOfNextMonth = month === 11 ? year + 1 : year,
  32380. daysInPreviousMonth = getDaysInMonth(yearOfPreviousMonth, previousMonth);
  32381. var cells = days + before,
  32382. after = cells;
  32383. while(after > 7) {
  32384. after -= 7;
  32385. }
  32386. cells += 7 - after;
  32387. for (var i = 0, r = 0; i < cells; i++)
  32388. {
  32389. var day = new Date(year, month, 1 + (i - before)),
  32390. isSelected = isDate(this._d) ? compareDates(day, this._d) : false,
  32391. isToday = compareDates(day, now),
  32392. isEmpty = i < before || i >= (days + before),
  32393. dayNumber = 1 + (i - before),
  32394. monthNumber = month,
  32395. yearNumber = year,
  32396. isStartRange = opts.startRange && compareDates(opts.startRange, day),
  32397. isEndRange = opts.endRange && compareDates(opts.endRange, day),
  32398. isInRange = opts.startRange && opts.endRange && opts.startRange < day && day < opts.endRange,
  32399. isDisabled = (opts.minDate && day < opts.minDate) ||
  32400. (opts.maxDate && day > opts.maxDate) ||
  32401. (opts.disableWeekends && isWeekend(day)) ||
  32402. (opts.disableDayFn && opts.disableDayFn(day));
  32403. if (isEmpty) {
  32404. if (i < before) {
  32405. dayNumber = daysInPreviousMonth + dayNumber;
  32406. monthNumber = previousMonth;
  32407. yearNumber = yearOfPreviousMonth;
  32408. } else {
  32409. dayNumber = dayNumber - days;
  32410. monthNumber = nextMonth;
  32411. yearNumber = yearOfNextMonth;
  32412. }
  32413. }
  32414. var dayConfig = {
  32415. day: dayNumber,
  32416. month: monthNumber,
  32417. year: yearNumber,
  32418. isSelected: isSelected,
  32419. isToday: isToday,
  32420. isDisabled: isDisabled,
  32421. isEmpty: isEmpty,
  32422. isStartRange: isStartRange,
  32423. isEndRange: isEndRange,
  32424. isInRange: isInRange,
  32425. showDaysInNextAndPreviousMonths: opts.showDaysInNextAndPreviousMonths
  32426. };
  32427. row.push(renderDay(dayConfig));
  32428. if (++r === 7) {
  32429. if (opts.showWeekNumber) {
  32430. row.unshift(renderWeek(i - before, month, year));
  32431. }
  32432. data.push(renderRow(row, opts.isRTL));
  32433. row = [];
  32434. r = 0;
  32435. }
  32436. }
  32437. return renderTable(opts, data, randId);
  32438. },
  32439. isVisible: function()
  32440. {
  32441. return this._v;
  32442. },
  32443. show: function()
  32444. {
  32445. if (!this.isVisible()) {
  32446. removeClass(this.el, 'is-hidden');
  32447. this._v = true;
  32448. this.draw();
  32449. if (this._o.bound) {
  32450. addEvent(document, 'click', this._onClick);
  32451. this.adjustPosition();
  32452. }
  32453. if (typeof this._o.onOpen === 'function') {
  32454. this._o.onOpen.call(this);
  32455. }
  32456. }
  32457. },
  32458. hide: function()
  32459. {
  32460. var v = this._v;
  32461. if (v !== false) {
  32462. if (this._o.bound) {
  32463. removeEvent(document, 'click', this._onClick);
  32464. }
  32465. this.el.style.position = 'static'; // reset
  32466. this.el.style.left = 'auto';
  32467. this.el.style.top = 'auto';
  32468. addClass(this.el, 'is-hidden');
  32469. this._v = false;
  32470. if (v !== undefined && typeof this._o.onClose === 'function') {
  32471. this._o.onClose.call(this);
  32472. }
  32473. }
  32474. },
  32475. /**
  32476. * GAME OVER
  32477. */
  32478. destroy: function()
  32479. {
  32480. this.hide();
  32481. removeEvent(this.el, 'mousedown', this._onMouseDown, true);
  32482. removeEvent(this.el, 'touchend', this._onMouseDown, true);
  32483. removeEvent(this.el, 'change', this._onChange);
  32484. if (this._o.field) {
  32485. removeEvent(this._o.field, 'change', this._onInputChange);
  32486. if (this._o.bound) {
  32487. removeEvent(this._o.trigger, 'click', this._onInputClick);
  32488. removeEvent(this._o.trigger, 'focus', this._onInputFocus);
  32489. removeEvent(this._o.trigger, 'blur', this._onInputBlur);
  32490. }
  32491. }
  32492. if (this.el.parentNode) {
  32493. this.el.parentNode.removeChild(this.el);
  32494. }
  32495. }
  32496. };
  32497. return Pikaday;
  32498. }));
  32499. /***/ }),
  32500. /* 359 */
  32501. /***/ (function(module, exports) {
  32502. // removed by extract-text-webpack-plugin
  32503. /***/ }),
  32504. /* 360 */
  32505. /***/ (function(module, exports, __webpack_require__) {
  32506. "use strict";
  32507. exports.__esModule = true;
  32508. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  32509. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  32510. var _autocompleteEditor = __webpack_require__(307);
  32511. var _autocompleteEditor2 = _interopRequireDefault(_autocompleteEditor);
  32512. var _pluginHooks = __webpack_require__(15);
  32513. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  32514. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  32515. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  32516. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  32517. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  32518. /**
  32519. * @private
  32520. * @editor DropdownEditor
  32521. * @class DropdownEditor
  32522. * @dependencies AutocompleteEditor
  32523. */
  32524. var DropdownEditor = function (_AutocompleteEditor) {
  32525. _inherits(DropdownEditor, _AutocompleteEditor);
  32526. function DropdownEditor() {
  32527. _classCallCheck(this, DropdownEditor);
  32528. return _possibleConstructorReturn(this, (DropdownEditor.__proto__ || Object.getPrototypeOf(DropdownEditor)).apply(this, arguments));
  32529. }
  32530. _createClass(DropdownEditor, [{
  32531. key: 'prepare',
  32532. value: function prepare(row, col, prop, td, originalValue, cellProperties) {
  32533. _get(DropdownEditor.prototype.__proto__ || Object.getPrototypeOf(DropdownEditor.prototype), 'prepare', this).call(this, row, col, prop, td, originalValue, cellProperties);
  32534. this.cellProperties.filter = false;
  32535. this.cellProperties.strict = true;
  32536. }
  32537. }]);
  32538. return DropdownEditor;
  32539. }(_autocompleteEditor2.default);
  32540. _pluginHooks2.default.getSingleton().add('beforeValidate', function (value, row, col, source) {
  32541. var cellMeta = this.getCellMeta(row, this.propToCol(col));
  32542. if (cellMeta.editor === DropdownEditor) {
  32543. if (cellMeta.strict === void 0) {
  32544. cellMeta.filter = false;
  32545. cellMeta.strict = true;
  32546. }
  32547. }
  32548. });
  32549. exports.default = DropdownEditor;
  32550. /***/ }),
  32551. /* 361 */
  32552. /***/ (function(module, exports, __webpack_require__) {
  32553. "use strict";
  32554. exports.__esModule = true;
  32555. var _textEditor = __webpack_require__(57);
  32556. var _textEditor2 = _interopRequireDefault(_textEditor);
  32557. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  32558. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  32559. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  32560. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  32561. /**
  32562. * @private
  32563. * @editor NumericEditor
  32564. * @class NumericEditor
  32565. */
  32566. var NumericEditor = function (_TextEditor) {
  32567. _inherits(NumericEditor, _TextEditor);
  32568. function NumericEditor() {
  32569. _classCallCheck(this, NumericEditor);
  32570. return _possibleConstructorReturn(this, (NumericEditor.__proto__ || Object.getPrototypeOf(NumericEditor)).apply(this, arguments));
  32571. }
  32572. return NumericEditor;
  32573. }(_textEditor2.default);
  32574. exports.default = NumericEditor;
  32575. /***/ }),
  32576. /* 362 */
  32577. /***/ (function(module, exports, __webpack_require__) {
  32578. "use strict";
  32579. exports.__esModule = true;
  32580. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  32581. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  32582. var _element = __webpack_require__(0);
  32583. var _textEditor = __webpack_require__(57);
  32584. var _textEditor2 = _interopRequireDefault(_textEditor);
  32585. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  32586. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  32587. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  32588. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  32589. /**
  32590. * @private
  32591. * @editor PasswordEditor
  32592. * @class PasswordEditor
  32593. * @dependencies TextEditor
  32594. */
  32595. var PasswordEditor = function (_TextEditor) {
  32596. _inherits(PasswordEditor, _TextEditor);
  32597. function PasswordEditor() {
  32598. _classCallCheck(this, PasswordEditor);
  32599. return _possibleConstructorReturn(this, (PasswordEditor.__proto__ || Object.getPrototypeOf(PasswordEditor)).apply(this, arguments));
  32600. }
  32601. _createClass(PasswordEditor, [{
  32602. key: 'createElements',
  32603. value: function createElements() {
  32604. _get(PasswordEditor.prototype.__proto__ || Object.getPrototypeOf(PasswordEditor.prototype), 'createElements', this).call(this);
  32605. this.TEXTAREA = document.createElement('input');
  32606. this.TEXTAREA.setAttribute('type', 'password');
  32607. this.TEXTAREA.className = 'handsontableInput';
  32608. this.textareaStyle = this.TEXTAREA.style;
  32609. this.textareaStyle.width = 0;
  32610. this.textareaStyle.height = 0;
  32611. (0, _element.empty)(this.TEXTAREA_PARENT);
  32612. this.TEXTAREA_PARENT.appendChild(this.TEXTAREA);
  32613. }
  32614. }]);
  32615. return PasswordEditor;
  32616. }(_textEditor2.default);
  32617. exports.default = PasswordEditor;
  32618. /***/ }),
  32619. /* 363 */
  32620. /***/ (function(module, exports, __webpack_require__) {
  32621. "use strict";
  32622. exports.__esModule = true;
  32623. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  32624. var _element = __webpack_require__(0);
  32625. var _event = __webpack_require__(12);
  32626. var _unicode = __webpack_require__(21);
  32627. var _baseEditor = __webpack_require__(54);
  32628. var _baseEditor2 = _interopRequireDefault(_baseEditor);
  32629. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  32630. var SelectEditor = _baseEditor2.default.prototype.extend();
  32631. /**
  32632. * @private
  32633. * @editor SelectEditor
  32634. * @class SelectEditor
  32635. */
  32636. SelectEditor.prototype.init = function () {
  32637. this.select = document.createElement('SELECT');
  32638. (0, _element.addClass)(this.select, 'htSelectEditor');
  32639. this.select.style.display = 'none';
  32640. this.instance.rootElement.appendChild(this.select);
  32641. this.registerHooks();
  32642. };
  32643. SelectEditor.prototype.registerHooks = function () {
  32644. var _this = this;
  32645. this.instance.addHook('afterScrollHorizontally', function () {
  32646. return _this.refreshDimensions();
  32647. });
  32648. this.instance.addHook('afterScrollVertically', function () {
  32649. return _this.refreshDimensions();
  32650. });
  32651. this.instance.addHook('afterColumnResize', function () {
  32652. return _this.refreshDimensions();
  32653. });
  32654. this.instance.addHook('afterRowResize', function () {
  32655. return _this.refreshDimensions();
  32656. });
  32657. };
  32658. SelectEditor.prototype.prepare = function () {
  32659. _baseEditor2.default.prototype.prepare.apply(this, arguments);
  32660. var selectOptions = this.cellProperties.selectOptions;
  32661. var options;
  32662. if (typeof selectOptions == 'function') {
  32663. options = this.prepareOptions(selectOptions(this.row, this.col, this.prop));
  32664. } else {
  32665. options = this.prepareOptions(selectOptions);
  32666. }
  32667. (0, _element.empty)(this.select);
  32668. for (var option in options) {
  32669. if (Object.prototype.hasOwnProperty.call(options, option)) {
  32670. var optionElement = document.createElement('OPTION');
  32671. optionElement.value = option;
  32672. (0, _element.fastInnerHTML)(optionElement, options[option]);
  32673. this.select.appendChild(optionElement);
  32674. }
  32675. }
  32676. };
  32677. SelectEditor.prototype.prepareOptions = function (optionsToPrepare) {
  32678. var preparedOptions = {};
  32679. if (Array.isArray(optionsToPrepare)) {
  32680. for (var i = 0, len = optionsToPrepare.length; i < len; i++) {
  32681. preparedOptions[optionsToPrepare[i]] = optionsToPrepare[i];
  32682. }
  32683. } else if ((typeof optionsToPrepare === 'undefined' ? 'undefined' : _typeof(optionsToPrepare)) == 'object') {
  32684. preparedOptions = optionsToPrepare;
  32685. }
  32686. return preparedOptions;
  32687. };
  32688. SelectEditor.prototype.getValue = function () {
  32689. return this.select.value;
  32690. };
  32691. SelectEditor.prototype.setValue = function (value) {
  32692. this.select.value = value;
  32693. };
  32694. var onBeforeKeyDown = function onBeforeKeyDown(event) {
  32695. var instance = this;
  32696. var editor = instance.getActiveEditor();
  32697. switch (event.keyCode) {
  32698. case _unicode.KEY_CODES.ARROW_UP:
  32699. var previousOptionIndex = editor.select.selectedIndex - 1;
  32700. if (previousOptionIndex >= 0) {
  32701. editor.select[previousOptionIndex].selected = true;
  32702. }
  32703. (0, _event.stopImmediatePropagation)(event);
  32704. event.preventDefault();
  32705. break;
  32706. case _unicode.KEY_CODES.ARROW_DOWN:
  32707. var nextOptionIndex = editor.select.selectedIndex + 1;
  32708. if (nextOptionIndex <= editor.select.length - 1) {
  32709. editor.select[nextOptionIndex].selected = true;
  32710. }
  32711. (0, _event.stopImmediatePropagation)(event);
  32712. event.preventDefault();
  32713. break;
  32714. default:
  32715. break;
  32716. }
  32717. };
  32718. SelectEditor.prototype.open = function () {
  32719. this._opened = true;
  32720. this.refreshDimensions();
  32721. this.select.style.display = '';
  32722. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  32723. };
  32724. SelectEditor.prototype.close = function () {
  32725. this._opened = false;
  32726. this.select.style.display = 'none';
  32727. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  32728. };
  32729. SelectEditor.prototype.focus = function () {
  32730. this.select.focus();
  32731. };
  32732. SelectEditor.prototype.refreshValue = function () {
  32733. var sourceData = this.instance.getSourceDataAtCell(this.row, this.prop);
  32734. this.originalValue = sourceData;
  32735. this.setValue(sourceData);
  32736. this.refreshDimensions();
  32737. };
  32738. SelectEditor.prototype.refreshDimensions = function () {
  32739. if (this.state !== _baseEditor.EditorState.EDITING) {
  32740. return;
  32741. }
  32742. this.TD = this.getEditedCell();
  32743. // TD is outside of the viewport.
  32744. if (!this.TD) {
  32745. this.close();
  32746. return;
  32747. }
  32748. var width = (0, _element.outerWidth)(this.TD) + 1,
  32749. height = (0, _element.outerHeight)(this.TD) + 1,
  32750. currentOffset = (0, _element.offset)(this.TD),
  32751. containerOffset = (0, _element.offset)(this.instance.rootElement),
  32752. scrollableContainer = (0, _element.getScrollableElement)(this.TD),
  32753. editTop = currentOffset.top - containerOffset.top - 1 - (scrollableContainer.scrollTop || 0),
  32754. editLeft = currentOffset.left - containerOffset.left - 1 - (scrollableContainer.scrollLeft || 0),
  32755. editorSection = this.checkEditorSection(),
  32756. cssTransformOffset;
  32757. var settings = this.instance.getSettings();
  32758. var rowHeadersCount = settings.rowHeaders ? 1 : 0;
  32759. var colHeadersCount = settings.colHeaders ? 1 : 0;
  32760. switch (editorSection) {
  32761. case 'top':
  32762. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.holder.parentNode);
  32763. break;
  32764. case 'left':
  32765. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.holder.parentNode);
  32766. break;
  32767. case 'top-left-corner':
  32768. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.holder.parentNode);
  32769. break;
  32770. case 'bottom-left-corner':
  32771. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.holder.parentNode);
  32772. break;
  32773. case 'bottom':
  32774. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.bottomOverlay.clone.wtTable.holder.parentNode);
  32775. break;
  32776. default:
  32777. break;
  32778. }
  32779. if (this.instance.getSelectedLast()[0] === 0) {
  32780. editTop += 1;
  32781. }
  32782. if (this.instance.getSelectedLast()[1] === 0) {
  32783. editLeft += 1;
  32784. }
  32785. var selectStyle = this.select.style;
  32786. if (cssTransformOffset && cssTransformOffset != -1) {
  32787. selectStyle[cssTransformOffset[0]] = cssTransformOffset[1];
  32788. } else {
  32789. (0, _element.resetCssTransform)(this.select);
  32790. }
  32791. var cellComputedStyle = (0, _element.getComputedStyle)(this.TD);
  32792. if (parseInt(cellComputedStyle.borderTopWidth, 10) > 0) {
  32793. height -= 1;
  32794. }
  32795. if (parseInt(cellComputedStyle.borderLeftWidth, 10) > 0) {
  32796. width -= 1;
  32797. }
  32798. selectStyle.height = height + 'px';
  32799. selectStyle.minWidth = width + 'px';
  32800. selectStyle.top = editTop + 'px';
  32801. selectStyle.left = editLeft + 'px';
  32802. selectStyle.margin = '0px';
  32803. };
  32804. SelectEditor.prototype.getEditedCell = function () {
  32805. var editorSection = this.checkEditorSection(),
  32806. editedCell;
  32807. switch (editorSection) {
  32808. case 'top':
  32809. editedCell = this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.getCell({
  32810. row: this.row,
  32811. col: this.col
  32812. });
  32813. this.select.style.zIndex = 101;
  32814. break;
  32815. case 'corner':
  32816. editedCell = this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.getCell({
  32817. row: this.row,
  32818. col: this.col
  32819. });
  32820. this.select.style.zIndex = 103;
  32821. break;
  32822. case 'left':
  32823. editedCell = this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.getCell({
  32824. row: this.row,
  32825. col: this.col
  32826. });
  32827. this.select.style.zIndex = 102;
  32828. break;
  32829. default:
  32830. editedCell = this.instance.getCell(this.row, this.col);
  32831. this.select.style.zIndex = '';
  32832. break;
  32833. }
  32834. return editedCell != -1 && editedCell != -2 ? editedCell : void 0;
  32835. };
  32836. exports.default = SelectEditor;
  32837. /***/ }),
  32838. /* 364 */
  32839. /***/ (function(module, exports, __webpack_require__) {
  32840. "use strict";
  32841. exports.__esModule = true;
  32842. var _element = __webpack_require__(0);
  32843. function cellDecorator(instance, TD, row, col, prop, value, cellProperties) {
  32844. var classesToAdd = [];
  32845. var classesToRemove = [];
  32846. if (cellProperties.className) {
  32847. if (TD.className) {
  32848. TD.className = TD.className + ' ' + cellProperties.className;
  32849. } else {
  32850. TD.className = cellProperties.className;
  32851. }
  32852. }
  32853. if (cellProperties.readOnly) {
  32854. classesToAdd.push(cellProperties.readOnlyCellClassName);
  32855. }
  32856. if (cellProperties.valid === false && cellProperties.invalidCellClassName) {
  32857. classesToAdd.push(cellProperties.invalidCellClassName);
  32858. } else {
  32859. classesToRemove.push(cellProperties.invalidCellClassName);
  32860. }
  32861. if (cellProperties.wordWrap === false && cellProperties.noWordWrapClassName) {
  32862. classesToAdd.push(cellProperties.noWordWrapClassName);
  32863. }
  32864. if (!value && cellProperties.placeholder) {
  32865. classesToAdd.push(cellProperties.placeholderCellClassName);
  32866. }
  32867. (0, _element.removeClass)(TD, classesToRemove);
  32868. (0, _element.addClass)(TD, classesToAdd);
  32869. } /**
  32870. * Adds appropriate CSS class to table cell, based on cellProperties
  32871. */
  32872. exports.default = cellDecorator;
  32873. /***/ }),
  32874. /* 365 */
  32875. /***/ (function(module, exports, __webpack_require__) {
  32876. "use strict";
  32877. exports.__esModule = true;
  32878. var _element = __webpack_require__(0);
  32879. var _eventManager = __webpack_require__(6);
  32880. var _eventManager2 = _interopRequireDefault(_eventManager);
  32881. var _src = __webpack_require__(4);
  32882. var _index = __webpack_require__(13);
  32883. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  32884. var clonableWRAPPER = document.createElement('DIV');
  32885. clonableWRAPPER.className = 'htAutocompleteWrapper';
  32886. var clonableARROW = document.createElement('DIV');
  32887. clonableARROW.className = 'htAutocompleteArrow';
  32888. // workaround for https://github.com/handsontable/handsontable/issues/1946
  32889. // this is faster than innerHTML. See: https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips
  32890. clonableARROW.appendChild(document.createTextNode(String.fromCharCode(9660)));
  32891. var wrapTdContentWithWrapper = function wrapTdContentWithWrapper(TD, WRAPPER) {
  32892. WRAPPER.innerHTML = TD.innerHTML;
  32893. (0, _element.empty)(TD);
  32894. TD.appendChild(WRAPPER);
  32895. };
  32896. /**
  32897. * Autocomplete renderer
  32898. *
  32899. * @private
  32900. * @renderer AutocompleteRenderer
  32901. * @param {Object} instance Handsontable instance
  32902. * @param {Element} TD Table cell where to render
  32903. * @param {Number} row
  32904. * @param {Number} col
  32905. * @param {String|Number} prop Row object property name
  32906. * @param value Value to render (remember to escape unsafe HTML before inserting to DOM!)
  32907. * @param {Object} cellProperties Cell properites (shared by cell renderer and editor)
  32908. */
  32909. function autocompleteRenderer(instance, TD, row, col, prop, value, cellProperties) {
  32910. var WRAPPER = clonableWRAPPER.cloneNode(true); // this is faster than createElement
  32911. var ARROW = clonableARROW.cloneNode(true); // this is faster than createElement
  32912. if (cellProperties.allowHtml) {
  32913. (0, _index.getRenderer)('html').apply(this, arguments);
  32914. } else {
  32915. (0, _index.getRenderer)('text').apply(this, arguments);
  32916. }
  32917. TD.appendChild(ARROW);
  32918. (0, _element.addClass)(TD, 'htAutocomplete');
  32919. if (!TD.firstChild) {
  32920. // http://jsperf.com/empty-node-if-needed
  32921. // otherwise empty fields appear borderless in demo/renderers.html (IE)
  32922. TD.appendChild(document.createTextNode(String.fromCharCode(160))); // workaround for https://github.com/handsontable/handsontable/issues/1946
  32923. // this is faster than innerHTML. See: https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips
  32924. }
  32925. if (!instance.acArrowListener) {
  32926. var eventManager = new _eventManager2.default(instance);
  32927. // not very elegant but easy and fast
  32928. instance.acArrowListener = function (event) {
  32929. if ((0, _element.hasClass)(event.target, 'htAutocompleteArrow')) {
  32930. instance.view.wt.getSetting('onCellDblClick', null, new _src.CellCoords(row, col), TD);
  32931. }
  32932. };
  32933. eventManager.addEventListener(instance.rootElement, 'mousedown', instance.acArrowListener);
  32934. // We need to unbind the listener after the table has been destroyed
  32935. instance.addHookOnce('afterDestroy', function () {
  32936. eventManager.destroy();
  32937. });
  32938. }
  32939. }
  32940. exports.default = autocompleteRenderer;
  32941. /***/ }),
  32942. /* 366 */
  32943. /***/ (function(module, exports, __webpack_require__) {
  32944. "use strict";
  32945. exports.__esModule = true;
  32946. var _element = __webpack_require__(0);
  32947. var _string = __webpack_require__(36);
  32948. var _eventManager = __webpack_require__(6);
  32949. var _eventManager2 = _interopRequireDefault(_eventManager);
  32950. var _unicode = __webpack_require__(21);
  32951. var _function = __webpack_require__(43);
  32952. var _event = __webpack_require__(12);
  32953. var _index = __webpack_require__(13);
  32954. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  32955. var isListeningKeyDownEvent = new WeakMap();
  32956. var isCheckboxListenerAdded = new WeakMap();
  32957. var BAD_VALUE_CLASS = 'htBadValue';
  32958. /**
  32959. * Checkbox renderer
  32960. *
  32961. * @private
  32962. * @param {Object} instance Handsontable instance
  32963. * @param {Element} TD Table cell where to render
  32964. * @param {Number} row
  32965. * @param {Number} col
  32966. * @param {String|Number} prop Row object property name
  32967. * @param value Value to render (remember to escape unsafe HTML before inserting to DOM!)
  32968. * @param {Object} cellProperties Cell properties (shared by cell renderer and editor)
  32969. */
  32970. function checkboxRenderer(instance, TD, row, col, prop, value, cellProperties) {
  32971. (0, _index.getRenderer)('base').apply(this, arguments);
  32972. var eventManager = registerEvents(instance);
  32973. var input = createInput();
  32974. var labelOptions = cellProperties.label;
  32975. var badValue = false;
  32976. if (typeof cellProperties.checkedTemplate === 'undefined') {
  32977. cellProperties.checkedTemplate = true;
  32978. }
  32979. if (typeof cellProperties.uncheckedTemplate === 'undefined') {
  32980. cellProperties.uncheckedTemplate = false;
  32981. }
  32982. (0, _element.empty)(TD); // TODO identify under what circumstances this line can be removed
  32983. if (value === cellProperties.checkedTemplate || (0, _string.equalsIgnoreCase)(value, cellProperties.checkedTemplate)) {
  32984. input.checked = true;
  32985. } else if (value === cellProperties.uncheckedTemplate || (0, _string.equalsIgnoreCase)(value, cellProperties.uncheckedTemplate)) {
  32986. input.checked = false;
  32987. } else if (value === null) {
  32988. // default value
  32989. (0, _element.addClass)(input, 'noValue');
  32990. } else {
  32991. input.style.display = 'none';
  32992. (0, _element.addClass)(input, BAD_VALUE_CLASS);
  32993. badValue = true;
  32994. }
  32995. input.setAttribute('data-row', row);
  32996. input.setAttribute('data-col', col);
  32997. if (!badValue && labelOptions) {
  32998. var labelText = '';
  32999. if (labelOptions.value) {
  33000. labelText = typeof labelOptions.value === 'function' ? labelOptions.value.call(this, row, col, prop, value) : labelOptions.value;
  33001. } else if (labelOptions.property) {
  33002. labelText = instance.getDataAtRowProp(row, labelOptions.property);
  33003. }
  33004. var label = createLabel(labelText);
  33005. if (labelOptions.position === 'before') {
  33006. label.appendChild(input);
  33007. } else {
  33008. label.insertBefore(input, label.firstChild);
  33009. }
  33010. input = label;
  33011. }
  33012. TD.appendChild(input);
  33013. if (badValue) {
  33014. TD.appendChild(document.createTextNode('#bad-value#'));
  33015. }
  33016. if (!isListeningKeyDownEvent.has(instance)) {
  33017. isListeningKeyDownEvent.set(instance, true);
  33018. instance.addHook('beforeKeyDown', onBeforeKeyDown);
  33019. }
  33020. /**
  33021. * On before key down DOM listener.
  33022. *
  33023. * @private
  33024. * @param {Event} event
  33025. */
  33026. function onBeforeKeyDown(event) {
  33027. var toggleKeys = 'SPACE|ENTER';
  33028. var switchOffKeys = 'DELETE|BACKSPACE';
  33029. var isKeyCode = (0, _function.partial)(_unicode.isKey, event.keyCode);
  33030. if (isKeyCode(toggleKeys + '|' + switchOffKeys) && !(0, _event.isImmediatePropagationStopped)(event)) {
  33031. eachSelectedCheckboxCell(function () {
  33032. (0, _event.stopImmediatePropagation)(event);
  33033. event.preventDefault();
  33034. });
  33035. }
  33036. if (isKeyCode(toggleKeys)) {
  33037. changeSelectedCheckboxesState();
  33038. }
  33039. if (isKeyCode(switchOffKeys)) {
  33040. changeSelectedCheckboxesState(true);
  33041. }
  33042. }
  33043. /**
  33044. * Change checkbox checked property
  33045. *
  33046. * @private
  33047. * @param {Boolean} [uncheckCheckbox=false]
  33048. */
  33049. function changeSelectedCheckboxesState() {
  33050. var uncheckCheckbox = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  33051. var selRange = instance.getSelectedRangeLast();
  33052. if (!selRange) {
  33053. return;
  33054. }
  33055. var _selRange$getTopLeftC = selRange.getTopLeftCorner(),
  33056. startRow = _selRange$getTopLeftC.row,
  33057. startColumn = _selRange$getTopLeftC.col;
  33058. var _selRange$getBottomRi = selRange.getBottomRightCorner(),
  33059. endRow = _selRange$getBottomRi.row,
  33060. endColumn = _selRange$getBottomRi.col;
  33061. var changes = [];
  33062. for (var _row = startRow; _row <= endRow; _row += 1) {
  33063. for (var _col = startColumn; _col <= endColumn; _col += 1) {
  33064. var _cellProperties = instance.getCellMeta(_row, _col);
  33065. if (_cellProperties.type !== 'checkbox') {
  33066. return;
  33067. }
  33068. /* eslint-disable no-continue */
  33069. if (_cellProperties.readOnly === true) {
  33070. continue;
  33071. }
  33072. if (typeof _cellProperties.checkedTemplate === 'undefined') {
  33073. _cellProperties.checkedTemplate = true;
  33074. }
  33075. if (typeof _cellProperties.uncheckedTemplate === 'undefined') {
  33076. _cellProperties.uncheckedTemplate = false;
  33077. }
  33078. var dataAtCell = instance.getDataAtCell(_row, _col);
  33079. if (uncheckCheckbox === false) {
  33080. if ([_cellProperties.checkedTemplate, _cellProperties.checkedTemplate.toString()].includes(dataAtCell)) {
  33081. changes.push([_row, _col, _cellProperties.uncheckedTemplate]);
  33082. } else if ([_cellProperties.uncheckedTemplate, _cellProperties.uncheckedTemplate.toString(), null, void 0].includes(dataAtCell)) {
  33083. changes.push([_row, _col, _cellProperties.checkedTemplate]);
  33084. }
  33085. } else {
  33086. changes.push([_row, _col, _cellProperties.uncheckedTemplate]);
  33087. }
  33088. }
  33089. }
  33090. if (changes.length > 0) {
  33091. instance.setDataAtCell(changes);
  33092. }
  33093. }
  33094. /**
  33095. * Call callback for each found selected cell with checkbox type.
  33096. *
  33097. * @private
  33098. * @param {Function} callback
  33099. */
  33100. function eachSelectedCheckboxCell(callback) {
  33101. var selRange = instance.getSelectedRangeLast();
  33102. if (!selRange) {
  33103. return;
  33104. }
  33105. var topLeft = selRange.getTopLeftCorner();
  33106. var bottomRight = selRange.getBottomRightCorner();
  33107. for (var _row2 = topLeft.row; _row2 <= bottomRight.row; _row2++) {
  33108. for (var _col2 = topLeft.col; _col2 <= bottomRight.col; _col2++) {
  33109. var _cellProperties2 = instance.getCellMeta(_row2, _col2);
  33110. if (_cellProperties2.type !== 'checkbox') {
  33111. return;
  33112. }
  33113. var cell = instance.getCell(_row2, _col2);
  33114. if (cell == null) {
  33115. callback(_row2, _col2, _cellProperties2);
  33116. } else {
  33117. var checkboxes = cell.querySelectorAll('input[type=checkbox]');
  33118. if (checkboxes.length > 0 && !_cellProperties2.readOnly) {
  33119. callback(checkboxes);
  33120. }
  33121. }
  33122. }
  33123. }
  33124. }
  33125. }
  33126. /**
  33127. * Register checkbox listeners.
  33128. *
  33129. * @param {Handsontable} instance Handsontable instance.
  33130. * @returns {EventManager}
  33131. */
  33132. function registerEvents(instance) {
  33133. var eventManager = isCheckboxListenerAdded.get(instance);
  33134. if (!eventManager) {
  33135. eventManager = new _eventManager2.default(instance);
  33136. eventManager.addEventListener(instance.rootElement, 'click', function (event) {
  33137. return onClick(event, instance);
  33138. });
  33139. eventManager.addEventListener(instance.rootElement, 'mouseup', function (event) {
  33140. return onMouseUp(event, instance);
  33141. });
  33142. eventManager.addEventListener(instance.rootElement, 'change', function (event) {
  33143. return onChange(event, instance);
  33144. });
  33145. isCheckboxListenerAdded.set(instance, eventManager);
  33146. }
  33147. return eventManager;
  33148. }
  33149. /**
  33150. * Create input element.
  33151. *
  33152. * @returns {Node}
  33153. */
  33154. function createInput() {
  33155. var input = document.createElement('input');
  33156. input.className = 'htCheckboxRendererInput';
  33157. input.type = 'checkbox';
  33158. input.setAttribute('autocomplete', 'off');
  33159. input.setAttribute('tabindex', '-1');
  33160. return input.cloneNode(false);
  33161. }
  33162. /**
  33163. * Create label element.
  33164. *
  33165. * @returns {Node}
  33166. */
  33167. function createLabel(text) {
  33168. var label = document.createElement('label');
  33169. label.className = 'htCheckboxRendererLabel';
  33170. label.appendChild(document.createTextNode(text));
  33171. return label.cloneNode(true);
  33172. }
  33173. /**
  33174. * `mouseup` callback.
  33175. *
  33176. * @private
  33177. * @param {Event} event `mouseup` event.
  33178. * @param {Object} instance Handsontable instance.
  33179. */
  33180. function onMouseUp(event, instance) {
  33181. if (!isCheckboxInput(event.target)) {
  33182. return;
  33183. }
  33184. setTimeout(instance.listen, 10);
  33185. }
  33186. /**
  33187. * `click` callback.
  33188. *
  33189. * @private
  33190. * @param {Event} event `click` event.
  33191. * @param {Object} instance Handsontable instance.
  33192. */
  33193. function onClick(event, instance) {
  33194. if (!isCheckboxInput(event.target)) {
  33195. return false;
  33196. }
  33197. var row = parseInt(event.target.getAttribute('data-row'), 10);
  33198. var col = parseInt(event.target.getAttribute('data-col'), 10);
  33199. var cellProperties = instance.getCellMeta(row, col);
  33200. if (cellProperties.readOnly) {
  33201. event.preventDefault();
  33202. }
  33203. }
  33204. /**
  33205. * `change` callback.
  33206. *
  33207. * @param {Event} event `change` event.
  33208. * @param {Object} instance Handsontable instance.
  33209. * @param {Object} cellProperties Reference to cell properties.
  33210. * @returns {Boolean}
  33211. */
  33212. function onChange(event, instance) {
  33213. if (!isCheckboxInput(event.target)) {
  33214. return false;
  33215. }
  33216. var row = parseInt(event.target.getAttribute('data-row'), 10);
  33217. var col = parseInt(event.target.getAttribute('data-col'), 10);
  33218. var cellProperties = instance.getCellMeta(row, col);
  33219. if (!cellProperties.readOnly) {
  33220. var newCheckboxValue = null;
  33221. if (event.target.checked) {
  33222. newCheckboxValue = cellProperties.uncheckedTemplate === void 0 ? true : cellProperties.checkedTemplate;
  33223. } else {
  33224. newCheckboxValue = cellProperties.uncheckedTemplate === void 0 ? false : cellProperties.uncheckedTemplate;
  33225. }
  33226. instance.setDataAtCell(row, col, newCheckboxValue);
  33227. }
  33228. }
  33229. /**
  33230. * Check if the provided element is the checkbox input.
  33231. *
  33232. * @private
  33233. * @param {HTMLElement} element The element in question.
  33234. * @returns {Boolean}
  33235. */
  33236. function isCheckboxInput(element) {
  33237. return element.tagName === 'INPUT' && element.getAttribute('type') === 'checkbox';
  33238. }
  33239. exports.default = checkboxRenderer;
  33240. /***/ }),
  33241. /* 367 */
  33242. /***/ (function(module, exports, __webpack_require__) {
  33243. "use strict";
  33244. exports.__esModule = true;
  33245. var _element = __webpack_require__(0);
  33246. var _index = __webpack_require__(13);
  33247. /**
  33248. * @private
  33249. * @renderer HtmlRenderer
  33250. * @param instance
  33251. * @param TD
  33252. * @param row
  33253. * @param col
  33254. * @param prop
  33255. * @param value
  33256. * @param cellProperties
  33257. */
  33258. function htmlRenderer(instance, TD, row, col, prop, value, cellProperties) {
  33259. (0, _index.getRenderer)('base').apply(this, arguments);
  33260. if (value === null || value === void 0) {
  33261. value = '';
  33262. }
  33263. (0, _element.fastInnerHTML)(TD, value);
  33264. }
  33265. exports.default = htmlRenderer;
  33266. /***/ }),
  33267. /* 368 */
  33268. /***/ (function(module, exports, __webpack_require__) {
  33269. "use strict";
  33270. exports.__esModule = true;
  33271. var _numbro = __webpack_require__(309);
  33272. var _numbro2 = _interopRequireDefault(_numbro);
  33273. var _index = __webpack_require__(13);
  33274. var _number = __webpack_require__(5);
  33275. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  33276. /**
  33277. * Numeric cell renderer
  33278. *
  33279. * @private
  33280. * @renderer NumericRenderer
  33281. * @dependencies numbro
  33282. * @param {Object} instance Handsontable instance
  33283. * @param {Element} TD Table cell where to render
  33284. * @param {Number} row
  33285. * @param {Number} col
  33286. * @param {String|Number} prop Row object property name
  33287. * @param value Value to render (remember to escape unsafe HTML before inserting to DOM!)
  33288. * @param {Object} cellProperties Cell properties (shared by cell renderer and editor)
  33289. */
  33290. function numericRenderer(instance, TD, row, col, prop, value, cellProperties) {
  33291. if ((0, _number.isNumeric)(value)) {
  33292. var numericFormat = cellProperties.numericFormat;
  33293. var cellCulture = numericFormat && numericFormat.culture;
  33294. var cellFormatPattern = numericFormat && numericFormat.pattern;
  33295. var className = cellProperties.className || '';
  33296. var classArr = className.length ? className.split(' ') : [];
  33297. if (typeof cellCulture !== 'undefined') {
  33298. _numbro2.default.culture(cellCulture);
  33299. }
  33300. value = (0, _numbro2.default)(value).format(cellFormatPattern || '0');
  33301. if (classArr.indexOf('htLeft') < 0 && classArr.indexOf('htCenter') < 0 && classArr.indexOf('htRight') < 0 && classArr.indexOf('htJustify') < 0) {
  33302. classArr.push('htRight');
  33303. }
  33304. if (classArr.indexOf('htNumeric') < 0) {
  33305. classArr.push('htNumeric');
  33306. }
  33307. cellProperties.className = classArr.join(' ');
  33308. }
  33309. (0, _index.getRenderer)('text')(instance, TD, row, col, prop, value, cellProperties);
  33310. }
  33311. exports.default = numericRenderer;
  33312. /***/ }),
  33313. /* 369 */
  33314. /***/ (function(module, exports) {
  33315. /***/ }),
  33316. /* 370 */
  33317. /***/ (function(module, exports, __webpack_require__) {
  33318. "use strict";
  33319. exports.__esModule = true;
  33320. var _element = __webpack_require__(0);
  33321. var _index = __webpack_require__(13);
  33322. var _number = __webpack_require__(5);
  33323. /**
  33324. * @private
  33325. * @renderer PasswordRenderer
  33326. * @param instance
  33327. * @param TD
  33328. * @param row
  33329. * @param col
  33330. * @param prop
  33331. * @param value
  33332. * @param cellProperties
  33333. */
  33334. function passwordRenderer(instance, TD, row, col, prop, value, cellProperties) {
  33335. (0, _index.getRenderer)('text').apply(this, arguments);
  33336. value = TD.innerHTML;
  33337. var hashLength = cellProperties.hashLength || value.length;
  33338. var hashSymbol = cellProperties.hashSymbol || '*';
  33339. var hash = '';
  33340. (0, _number.rangeEach)(hashLength - 1, function () {
  33341. hash += hashSymbol;
  33342. });
  33343. (0, _element.fastInnerHTML)(TD, hash);
  33344. }
  33345. exports.default = passwordRenderer;
  33346. /***/ }),
  33347. /* 371 */
  33348. /***/ (function(module, exports, __webpack_require__) {
  33349. "use strict";
  33350. exports.__esModule = true;
  33351. var _element = __webpack_require__(0);
  33352. var _mixed = __webpack_require__(16);
  33353. var _index = __webpack_require__(13);
  33354. /**
  33355. * Default text renderer
  33356. *
  33357. * @private
  33358. * @renderer TextRenderer
  33359. * @param {Object} instance Handsontable instance
  33360. * @param {Element} TD Table cell where to render
  33361. * @param {Number} row
  33362. * @param {Number} col
  33363. * @param {String|Number} prop Row object property name
  33364. * @param value Value to render (remember to escape unsafe HTML before inserting to DOM!)
  33365. * @param {Object} cellProperties Cell properties (shared by cell renderer and editor)
  33366. */
  33367. function textRenderer(instance, TD, row, col, prop, value, cellProperties) {
  33368. (0, _index.getRenderer)('base').apply(this, arguments);
  33369. if (!value && cellProperties.placeholder) {
  33370. value = cellProperties.placeholder;
  33371. }
  33372. var escaped = (0, _mixed.stringify)(value);
  33373. if (!instance.getSettings().trimWhitespace) {
  33374. escaped = escaped.replace(/ /g, String.fromCharCode(160));
  33375. }
  33376. if (cellProperties.rendererTemplate) {
  33377. (0, _element.empty)(TD);
  33378. var TEMPLATE = document.createElement('TEMPLATE');
  33379. TEMPLATE.setAttribute('bind', '{{}}');
  33380. TEMPLATE.innerHTML = cellProperties.rendererTemplate;
  33381. HTMLTemplateElement.decorate(TEMPLATE);
  33382. TEMPLATE.model = instance.getSourceDataAtRow(row);
  33383. TD.appendChild(TEMPLATE);
  33384. } else {
  33385. // this is faster than innerHTML. See: https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips
  33386. (0, _element.fastInnerText)(TD, escaped);
  33387. }
  33388. }
  33389. exports.default = textRenderer;
  33390. /***/ }),
  33391. /* 372 */
  33392. /***/ (function(module, exports, __webpack_require__) {
  33393. "use strict";
  33394. exports.__esModule = true;
  33395. exports.default = autocompleteValidator;
  33396. /**
  33397. * Autocomplete cell validator.
  33398. *
  33399. * @private
  33400. * @validator AutocompleteValidator
  33401. * @param {*} value - Value of edited cell
  33402. * @param {Function} callback - Callback called with validation result
  33403. */
  33404. function autocompleteValidator(value, callback) {
  33405. if (value == null) {
  33406. value = '';
  33407. }
  33408. if (this.allowEmpty && value === '') {
  33409. callback(true);
  33410. return;
  33411. }
  33412. if (this.strict && this.source) {
  33413. if (typeof this.source === 'function') {
  33414. this.source(value, process(value, callback));
  33415. } else {
  33416. process(value, callback)(this.source);
  33417. }
  33418. } else {
  33419. callback(true);
  33420. }
  33421. };
  33422. /**
  33423. * Function responsible for validation of autocomplete value.
  33424. *
  33425. * @param {*} value - Value of edited cell
  33426. * @param {Function} callback - Callback called with validation result
  33427. */
  33428. function process(value, callback) {
  33429. var originalVal = value;
  33430. return function (source) {
  33431. var found = false;
  33432. for (var s = 0, slen = source.length; s < slen; s++) {
  33433. if (originalVal === source[s]) {
  33434. found = true; // perfect match
  33435. break;
  33436. }
  33437. }
  33438. callback(found);
  33439. };
  33440. }
  33441. /***/ }),
  33442. /* 373 */
  33443. /***/ (function(module, exports, __webpack_require__) {
  33444. "use strict";
  33445. exports.__esModule = true;
  33446. exports.default = dateValidator;
  33447. exports.correctFormat = correctFormat;
  33448. var _moment = __webpack_require__(41);
  33449. var _moment2 = _interopRequireDefault(_moment);
  33450. var _date = __webpack_require__(310);
  33451. var _editors = __webpack_require__(17);
  33452. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  33453. /**
  33454. * Date cell validator
  33455. *
  33456. * @private
  33457. * @validator DateValidator
  33458. * @dependencies moment
  33459. * @param {*} value - Value of edited cell
  33460. * @param {Function} callback - Callback called with validation result
  33461. */
  33462. function dateValidator(value, callback) {
  33463. var valid = true;
  33464. var dateEditor = (0, _editors.getEditorInstance)('date', this.instance);
  33465. if (value == null) {
  33466. value = '';
  33467. }
  33468. var isValidDate = (0, _moment2.default)(new Date(value)).isValid() || (0, _moment2.default)(value, dateEditor.defaultDateFormat).isValid();
  33469. // is it in the specified format
  33470. var isValidFormat = (0, _moment2.default)(value, this.dateFormat || dateEditor.defaultDateFormat, true).isValid();
  33471. if (this.allowEmpty && value === '') {
  33472. isValidDate = true;
  33473. isValidFormat = true;
  33474. }
  33475. if (!isValidDate) {
  33476. valid = false;
  33477. }
  33478. if (!isValidDate && isValidFormat) {
  33479. valid = true;
  33480. }
  33481. if (isValidDate && !isValidFormat) {
  33482. if (this.correctFormat === true) {
  33483. // if format correction is enabled
  33484. var correctedValue = correctFormat(value, this.dateFormat);
  33485. var row = this.instance.runHooks('unmodifyRow', this.row);
  33486. var column = this.instance.runHooks('unmodifyCol', this.col);
  33487. this.instance.setDataAtCell(row, column, correctedValue, 'dateValidator');
  33488. valid = true;
  33489. } else {
  33490. valid = false;
  33491. }
  33492. }
  33493. callback(valid);
  33494. };
  33495. /**
  33496. * Format the given string using moment.js' format feature
  33497. *
  33498. * @param {String} value
  33499. * @param {String} dateFormat
  33500. * @returns {String}
  33501. */
  33502. function correctFormat(value, dateFormat) {
  33503. var dateFromDate = (0, _moment2.default)((0, _date.getNormalizedDate)(value));
  33504. var dateFromMoment = (0, _moment2.default)(value, dateFormat);
  33505. var isAlphanumeric = value.search(/[A-z]/g) > -1;
  33506. var date = void 0;
  33507. if (dateFromDate.isValid() && dateFromDate.format('x') === dateFromMoment.format('x') || !dateFromMoment.isValid() || isAlphanumeric) {
  33508. date = dateFromDate;
  33509. } else {
  33510. date = dateFromMoment;
  33511. }
  33512. return date.format(dateFormat);
  33513. };
  33514. /***/ }),
  33515. /* 374 */
  33516. /***/ (function(module, exports, __webpack_require__) {
  33517. "use strict";
  33518. exports.__esModule = true;
  33519. exports.default = numericValidator;
  33520. /**
  33521. * Numeric cell validator
  33522. *
  33523. * @private
  33524. * @validator NumericValidator
  33525. * @param {*} value - Value of edited cell
  33526. * @param {*} callback - Callback called with validation result
  33527. */
  33528. function numericValidator(value, callback) {
  33529. if (value == null) {
  33530. value = '';
  33531. }
  33532. if (this.allowEmpty && value === '') {
  33533. callback(true);
  33534. } else if (value === '') {
  33535. callback(false);
  33536. } else {
  33537. callback(/^-?\d*(\.|,)?\d*$/.test(value));
  33538. }
  33539. };
  33540. /***/ }),
  33541. /* 375 */
  33542. /***/ (function(module, exports, __webpack_require__) {
  33543. "use strict";
  33544. exports.__esModule = true;
  33545. exports.default = timeValidator;
  33546. var _moment = __webpack_require__(41);
  33547. var _moment2 = _interopRequireDefault(_moment);
  33548. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  33549. // Formats which are correctly parsed to time (supported by momentjs)
  33550. var STRICT_FORMATS = ['YYYY-MM-DDTHH:mm:ss.SSSZ', 'X', // Unix timestamp
  33551. 'x' // Unix ms timestamp
  33552. ];
  33553. /**
  33554. * Time cell validator
  33555. *
  33556. * @private
  33557. * @validator TimeValidator
  33558. * @dependencies moment
  33559. * @param {*} value - Value of edited cell
  33560. * @param {Function} callback - Callback called with validation result
  33561. */
  33562. function timeValidator(value, callback) {
  33563. var valid = true;
  33564. var timeFormat = this.timeFormat || 'h:mm:ss a';
  33565. if (value === null) {
  33566. value = '';
  33567. }
  33568. value = /^\d{3,}$/.test(value) ? parseInt(value, 10) : value;
  33569. var twoDigitValue = /^\d{1,2}$/.test(value);
  33570. if (twoDigitValue) {
  33571. value += ':00';
  33572. }
  33573. var date = (0, _moment2.default)(value, STRICT_FORMATS, true).isValid() ? (0, _moment2.default)(value) : (0, _moment2.default)(value, timeFormat);
  33574. var isValidTime = date.isValid();
  33575. // is it in the specified format
  33576. var isValidFormat = (0, _moment2.default)(value, timeFormat, true).isValid() && !twoDigitValue;
  33577. if (this.allowEmpty && value === '') {
  33578. isValidTime = true;
  33579. isValidFormat = true;
  33580. }
  33581. if (!isValidTime) {
  33582. valid = false;
  33583. }
  33584. if (!isValidTime && isValidFormat) {
  33585. valid = true;
  33586. }
  33587. if (isValidTime && !isValidFormat) {
  33588. if (this.correctFormat === true) {
  33589. // if format correction is enabled
  33590. var correctedValue = date.format(timeFormat);
  33591. var row = this.instance.runHooks('unmodifyRow', this.row);
  33592. var column = this.instance.runHooks('unmodifyCol', this.col);
  33593. this.instance.setDataAtCell(row, column, correctedValue, 'timeValidator');
  33594. valid = true;
  33595. } else {
  33596. valid = false;
  33597. }
  33598. }
  33599. callback(valid);
  33600. };
  33601. /***/ }),
  33602. /* 376 */
  33603. /***/ (function(module, exports, __webpack_require__) {
  33604. "use strict";
  33605. exports.__esModule = true;
  33606. var _editors = __webpack_require__(17);
  33607. var _renderers = __webpack_require__(13);
  33608. var _validators = __webpack_require__(28);
  33609. var CELL_TYPE = 'autocomplete';
  33610. exports.default = {
  33611. editor: (0, _editors.getEditor)(CELL_TYPE),
  33612. renderer: (0, _renderers.getRenderer)(CELL_TYPE),
  33613. validator: (0, _validators.getValidator)(CELL_TYPE)
  33614. };
  33615. /***/ }),
  33616. /* 377 */
  33617. /***/ (function(module, exports, __webpack_require__) {
  33618. "use strict";
  33619. exports.__esModule = true;
  33620. var _editors = __webpack_require__(17);
  33621. var _renderers = __webpack_require__(13);
  33622. var CELL_TYPE = 'checkbox';
  33623. exports.default = {
  33624. editor: (0, _editors.getEditor)(CELL_TYPE),
  33625. renderer: (0, _renderers.getRenderer)(CELL_TYPE)
  33626. };
  33627. /***/ }),
  33628. /* 378 */
  33629. /***/ (function(module, exports, __webpack_require__) {
  33630. "use strict";
  33631. exports.__esModule = true;
  33632. var _editors = __webpack_require__(17);
  33633. var _renderers = __webpack_require__(13);
  33634. var _validators = __webpack_require__(28);
  33635. var CELL_TYPE = 'date';
  33636. exports.default = {
  33637. editor: (0, _editors.getEditor)(CELL_TYPE),
  33638. // displays small gray arrow on right side of the cell
  33639. renderer: (0, _renderers.getRenderer)('autocomplete'),
  33640. validator: (0, _validators.getValidator)(CELL_TYPE)
  33641. };
  33642. /***/ }),
  33643. /* 379 */
  33644. /***/ (function(module, exports, __webpack_require__) {
  33645. "use strict";
  33646. exports.__esModule = true;
  33647. var _editors = __webpack_require__(17);
  33648. var _renderers = __webpack_require__(13);
  33649. var _validators = __webpack_require__(28);
  33650. var CELL_TYPE = 'dropdown';
  33651. exports.default = {
  33652. editor: (0, _editors.getEditor)(CELL_TYPE),
  33653. // displays small gray arrow on right side of the cell
  33654. renderer: (0, _renderers.getRenderer)('autocomplete'),
  33655. validator: (0, _validators.getValidator)('autocomplete')
  33656. };
  33657. /***/ }),
  33658. /* 380 */
  33659. /***/ (function(module, exports, __webpack_require__) {
  33660. "use strict";
  33661. exports.__esModule = true;
  33662. var _editors = __webpack_require__(17);
  33663. var _renderers = __webpack_require__(13);
  33664. var CELL_TYPE = 'handsontable';
  33665. exports.default = {
  33666. editor: (0, _editors.getEditor)(CELL_TYPE),
  33667. // displays small gray arrow on right side of the cell
  33668. renderer: (0, _renderers.getRenderer)('autocomplete')
  33669. };
  33670. /***/ }),
  33671. /* 381 */
  33672. /***/ (function(module, exports, __webpack_require__) {
  33673. "use strict";
  33674. exports.__esModule = true;
  33675. var _editors = __webpack_require__(17);
  33676. var _renderers = __webpack_require__(13);
  33677. var _validators = __webpack_require__(28);
  33678. var CELL_TYPE = 'numeric';
  33679. exports.default = {
  33680. editor: (0, _editors.getEditor)(CELL_TYPE),
  33681. renderer: (0, _renderers.getRenderer)(CELL_TYPE),
  33682. validator: (0, _validators.getValidator)(CELL_TYPE),
  33683. dataType: 'number'
  33684. };
  33685. /***/ }),
  33686. /* 382 */
  33687. /***/ (function(module, exports, __webpack_require__) {
  33688. "use strict";
  33689. exports.__esModule = true;
  33690. var _editors = __webpack_require__(17);
  33691. var _renderers = __webpack_require__(13);
  33692. var _validators = __webpack_require__(28);
  33693. var CELL_TYPE = 'password';
  33694. exports.default = {
  33695. editor: (0, _editors.getEditor)(CELL_TYPE),
  33696. renderer: (0, _renderers.getRenderer)(CELL_TYPE),
  33697. copyable: false
  33698. };
  33699. /***/ }),
  33700. /* 383 */
  33701. /***/ (function(module, exports, __webpack_require__) {
  33702. "use strict";
  33703. exports.__esModule = true;
  33704. var _browser = __webpack_require__(27);
  33705. var _editors = __webpack_require__(17);
  33706. var _renderers = __webpack_require__(13);
  33707. var CELL_TYPE = 'text';
  33708. exports.default = {
  33709. editor: (0, _editors.getEditor)(CELL_TYPE),
  33710. renderer: (0, _renderers.getRenderer)(CELL_TYPE)
  33711. };
  33712. /***/ }),
  33713. /* 384 */
  33714. /***/ (function(module, exports, __webpack_require__) {
  33715. "use strict";
  33716. exports.__esModule = true;
  33717. var _editors = __webpack_require__(17);
  33718. var _renderers = __webpack_require__(13);
  33719. var _validators = __webpack_require__(28);
  33720. var CELL_TYPE = 'time';
  33721. exports.default = {
  33722. editor: (0, _editors.getEditor)('text'),
  33723. // displays small gray arrow on right side of the cell
  33724. renderer: (0, _renderers.getRenderer)('text'),
  33725. validator: (0, _validators.getValidator)(CELL_TYPE)
  33726. };
  33727. /***/ }),
  33728. /* 385 */
  33729. /***/ (function(module, exports, __webpack_require__) {
  33730. "use strict";
  33731. exports.__esModule = true;
  33732. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  33733. var _SheetClip = __webpack_require__(311);
  33734. var _SheetClip2 = _interopRequireDefault(_SheetClip);
  33735. var _data = __webpack_require__(90);
  33736. var _setting = __webpack_require__(89);
  33737. var _object = __webpack_require__(2);
  33738. var _array = __webpack_require__(1);
  33739. var _interval = __webpack_require__(386);
  33740. var _interval2 = _interopRequireDefault(_interval);
  33741. var _number = __webpack_require__(5);
  33742. var _multiMap = __webpack_require__(387);
  33743. var _multiMap2 = _interopRequireDefault(_multiMap);
  33744. var _pluginHooks = __webpack_require__(15);
  33745. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  33746. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  33747. /**
  33748. * Utility class that gets and saves data from/to the data source using mapping of columns numbers to object property names
  33749. * @todo refactor arguments of methods getRange, getText to be numbers (not objects)
  33750. * @todo remove priv, GridSettings from object constructor
  33751. *
  33752. * @param {Object} instance Instance of Handsontable
  33753. * @param {*} priv
  33754. * @param {*} GridSettings Grid settings
  33755. * @util
  33756. * @class DataMap
  33757. */
  33758. function DataMap(instance, priv, GridSettings) {
  33759. var _this = this;
  33760. this.instance = instance;
  33761. this.priv = priv;
  33762. this.GridSettings = GridSettings;
  33763. this.dataSource = this.instance.getSettings().data;
  33764. this.cachedLength = null;
  33765. this.skipCache = false;
  33766. this.latestSourceRowsCount = 0;
  33767. if (this.dataSource && this.dataSource[0]) {
  33768. this.duckSchema = this.recursiveDuckSchema(this.dataSource[0]);
  33769. } else {
  33770. this.duckSchema = {};
  33771. }
  33772. this.createMap();
  33773. this.interval = _interval2.default.create(function () {
  33774. return _this.clearLengthCache();
  33775. }, '15fps');
  33776. this.instance.addHook('skipLengthCache', function (delay) {
  33777. return _this.onSkipLengthCache(delay);
  33778. });
  33779. this.onSkipLengthCache(500);
  33780. }
  33781. DataMap.prototype.DESTINATION_RENDERER = 1;
  33782. DataMap.prototype.DESTINATION_CLIPBOARD_GENERATOR = 2;
  33783. /**
  33784. * @param {Object|Array} object
  33785. * @returns {Object|Array}
  33786. */
  33787. DataMap.prototype.recursiveDuckSchema = function (object) {
  33788. return (0, _object.duckSchema)(object);
  33789. };
  33790. /**
  33791. * @param {Object} schema
  33792. * @param {Number} lastCol
  33793. * @param {Number} parent
  33794. * @returns {Number}
  33795. */
  33796. DataMap.prototype.recursiveDuckColumns = function (schema, lastCol, parent) {
  33797. var prop, i;
  33798. if (typeof lastCol === 'undefined') {
  33799. lastCol = 0;
  33800. parent = '';
  33801. }
  33802. if ((typeof schema === 'undefined' ? 'undefined' : _typeof(schema)) === 'object' && !Array.isArray(schema)) {
  33803. for (i in schema) {
  33804. if ((0, _object.hasOwnProperty)(schema, i)) {
  33805. if (schema[i] === null) {
  33806. prop = parent + i;
  33807. this.colToPropCache.push(prop);
  33808. this.propToColCache.set(prop, lastCol);
  33809. lastCol++;
  33810. } else {
  33811. lastCol = this.recursiveDuckColumns(schema[i], lastCol, i + '.');
  33812. }
  33813. }
  33814. }
  33815. }
  33816. return lastCol;
  33817. };
  33818. DataMap.prototype.createMap = function () {
  33819. var i = void 0;
  33820. var schema = this.getSchema();
  33821. if (typeof schema === 'undefined') {
  33822. throw new Error('trying to create `columns` definition but you didn\'t provide `schema` nor `data`');
  33823. }
  33824. this.colToPropCache = [];
  33825. this.propToColCache = new _multiMap2.default();
  33826. var columns = this.instance.getSettings().columns;
  33827. if (columns) {
  33828. var maxCols = this.instance.getSettings().maxCols;
  33829. var columnsLen = Math.min(maxCols, columns.length);
  33830. var filteredIndex = 0;
  33831. var columnsAsFunc = false;
  33832. var schemaLen = (0, _object.deepObjectSize)(schema);
  33833. if (typeof columns === 'function') {
  33834. columnsLen = schemaLen > 0 ? schemaLen : this.instance.countSourceCols();
  33835. columnsAsFunc = true;
  33836. }
  33837. for (i = 0; i < columnsLen; i++) {
  33838. var column = columnsAsFunc ? columns(i) : columns[i];
  33839. if ((0, _object.isObject)(column)) {
  33840. if (typeof column.data !== 'undefined') {
  33841. var index = columnsAsFunc ? filteredIndex : i;
  33842. this.colToPropCache[index] = column.data;
  33843. this.propToColCache.set(column.data, index);
  33844. }
  33845. filteredIndex++;
  33846. }
  33847. }
  33848. } else {
  33849. this.recursiveDuckColumns(schema);
  33850. }
  33851. };
  33852. /**
  33853. * Returns property name that corresponds with the given column index.
  33854. *
  33855. * @param {Number} col Visual column index.
  33856. * @returns {Number} Physical column index.
  33857. */
  33858. DataMap.prototype.colToProp = function (col) {
  33859. col = this.instance.runHooks('modifyCol', col);
  33860. if (!isNaN(col) && this.colToPropCache && typeof this.colToPropCache[col] !== 'undefined') {
  33861. return this.colToPropCache[col];
  33862. }
  33863. return col;
  33864. };
  33865. /**
  33866. * @param {Object} prop
  33867. * @fires Hooks#modifyCol
  33868. * @returns {*}
  33869. */
  33870. DataMap.prototype.propToCol = function (prop) {
  33871. var col;
  33872. if (typeof this.propToColCache.get(prop) === 'undefined') {
  33873. col = prop;
  33874. } else {
  33875. col = this.propToColCache.get(prop);
  33876. }
  33877. col = this.instance.runHooks('unmodifyCol', col);
  33878. return col;
  33879. };
  33880. /**
  33881. * @returns {Object}
  33882. */
  33883. DataMap.prototype.getSchema = function () {
  33884. var schema = this.instance.getSettings().dataSchema;
  33885. if (schema) {
  33886. if (typeof schema === 'function') {
  33887. return schema();
  33888. }
  33889. return schema;
  33890. }
  33891. return this.duckSchema;
  33892. };
  33893. /**
  33894. * Creates row at the bottom of the data array.
  33895. *
  33896. * @param {Number} [index] Physical index of the row before which the new row will be inserted.
  33897. * @param {Number} [amount=1] An amount of rows to add.
  33898. * @param {String} [source] Source of method call.
  33899. * @fires Hooks#afterCreateRow
  33900. * @returns {Number} Returns number of created rows.
  33901. */
  33902. DataMap.prototype.createRow = function (index) {
  33903. var _this2 = this;
  33904. var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  33905. var source = arguments[2];
  33906. var numberOfCreatedRows = 0;
  33907. if (typeof index !== 'number' || index >= this.instance.countSourceRows()) {
  33908. index = this.instance.countSourceRows();
  33909. }
  33910. var continueProcess = this.instance.runHooks('beforeCreateRow', index, amount, source);
  33911. if (continueProcess === false) {
  33912. return 0;
  33913. }
  33914. var maxRows = this.instance.getSettings().maxRows;
  33915. var columnCount = this.instance.countCols();
  33916. var _loop = function _loop() {
  33917. var row = null;
  33918. if (_this2.instance.dataType === 'array') {
  33919. if (_this2.instance.getSettings().dataSchema) {
  33920. // Clone template array
  33921. row = (0, _object.deepClone)(_this2.getSchema());
  33922. } else {
  33923. row = [];
  33924. /* eslint-disable no-loop-func */
  33925. (0, _number.rangeEach)(columnCount - 1, function () {
  33926. return row.push(null);
  33927. });
  33928. }
  33929. } else if (_this2.instance.dataType === 'function') {
  33930. row = _this2.instance.getSettings().dataSchema(index);
  33931. } else {
  33932. row = {};
  33933. (0, _object.deepExtend)(row, _this2.getSchema());
  33934. }
  33935. if (index === _this2.instance.countSourceRows()) {
  33936. _this2.dataSource.push(row);
  33937. } else {
  33938. _this2.spliceData(index, 0, row);
  33939. }
  33940. numberOfCreatedRows++;
  33941. };
  33942. while (numberOfCreatedRows < amount && this.instance.countSourceRows() < maxRows) {
  33943. _loop();
  33944. }
  33945. this.instance.runHooks('afterCreateRow', index, numberOfCreatedRows, source);
  33946. this.instance.forceFullRender = true; // used when data was changed
  33947. return numberOfCreatedRows;
  33948. };
  33949. /**
  33950. * Creates col at the right of the data array.
  33951. *
  33952. * @param {Number} [index] Visual index of the column before which the new column will be inserted
  33953. * @param {Number} [amount] An amount of columns to add.
  33954. * @param {String} [source] Source of method call.
  33955. * @fires Hooks#afterCreateCol
  33956. * @returns {Number} Returns number of created columns
  33957. */
  33958. DataMap.prototype.createCol = function (index, amount, source) {
  33959. if (!this.instance.isColumnModificationAllowed()) {
  33960. throw new Error('Cannot create new column. When data source in an object, ' + 'you can only have as much columns as defined in first data row, data schema or in the \'columns\' setting.' + 'If you want to be able to add new columns, you have to use array datasource.');
  33961. }
  33962. var rlen = this.instance.countSourceRows(),
  33963. data = this.dataSource,
  33964. constructor,
  33965. numberOfCreatedCols = 0,
  33966. currentIndex;
  33967. if (!amount) {
  33968. amount = 1;
  33969. }
  33970. if (typeof index !== 'number' || index >= this.instance.countCols()) {
  33971. index = this.instance.countCols();
  33972. }
  33973. this.instance.runHooks('beforeCreateCol', index, amount, source);
  33974. currentIndex = index;
  33975. var maxCols = this.instance.getSettings().maxCols;
  33976. while (numberOfCreatedCols < amount && this.instance.countCols() < maxCols) {
  33977. constructor = (0, _setting.columnFactory)(this.GridSettings, this.priv.columnsSettingConflicts);
  33978. if (typeof index !== 'number' || index >= this.instance.countCols()) {
  33979. if (rlen > 0) {
  33980. for (var r = 0; r < rlen; r++) {
  33981. if (typeof data[r] === 'undefined') {
  33982. data[r] = [];
  33983. }
  33984. data[r].push(null);
  33985. }
  33986. } else {
  33987. data.push([null]);
  33988. }
  33989. // Add new column constructor
  33990. this.priv.columnSettings.push(constructor);
  33991. } else {
  33992. for (var _r = 0; _r < rlen; _r++) {
  33993. data[_r].splice(currentIndex, 0, null);
  33994. }
  33995. // Add new column constructor at given index
  33996. this.priv.columnSettings.splice(currentIndex, 0, constructor);
  33997. }
  33998. numberOfCreatedCols++;
  33999. currentIndex++;
  34000. }
  34001. this.instance.runHooks('afterCreateCol', index, numberOfCreatedCols, source);
  34002. this.instance.forceFullRender = true; // used when data was changed
  34003. return numberOfCreatedCols;
  34004. };
  34005. /**
  34006. * Removes row from the data array.
  34007. *
  34008. * @param {Number} [index] Visual index of the row to be removed. If not provided, the last row will be removed
  34009. * @param {Number} [amount] Amount of the rows to be removed. If not provided, one row will be removed
  34010. * @param {String} [source] Source of method call.
  34011. * @fires Hooks#beforeRemoveRow
  34012. * @fires Hooks#afterRemoveRow
  34013. */
  34014. DataMap.prototype.removeRow = function (index, amount, source) {
  34015. if (!amount) {
  34016. amount = 1;
  34017. }
  34018. if (typeof index !== 'number') {
  34019. index = -amount;
  34020. }
  34021. amount = this.instance.runHooks('modifyRemovedAmount', amount, index);
  34022. index = (this.instance.countSourceRows() + index) % this.instance.countSourceRows();
  34023. var logicRows = this.visualRowsToPhysical(index, amount);
  34024. var actionWasNotCancelled = this.instance.runHooks('beforeRemoveRow', index, amount, logicRows, source);
  34025. if (actionWasNotCancelled === false) {
  34026. return;
  34027. }
  34028. var data = this.dataSource;
  34029. var newData = void 0;
  34030. newData = this.filterData(index, amount);
  34031. if (newData) {
  34032. data.length = 0;
  34033. Array.prototype.push.apply(data, newData);
  34034. }
  34035. this.instance.runHooks('afterRemoveRow', index, amount, logicRows, source);
  34036. this.instance.forceFullRender = true; // used when data was changed
  34037. };
  34038. /**
  34039. * Removes column from the data array.
  34040. *
  34041. * @param {Number} [index] Visual index of the column to be removed. If not provided, the last column will be removed
  34042. * @param {Number} [amount] Amount of the columns to be removed. If not provided, one column will be removed
  34043. * @param {String} [source] Source of method call.
  34044. * @fires Hooks#beforeRemoveCol
  34045. * @fires Hooks#afterRemoveCol
  34046. */
  34047. DataMap.prototype.removeCol = function (index, amount, source) {
  34048. if (this.instance.dataType === 'object' || this.instance.getSettings().columns) {
  34049. throw new Error('cannot remove column with object data source or columns option specified');
  34050. }
  34051. if (!amount) {
  34052. amount = 1;
  34053. }
  34054. if (typeof index !== 'number') {
  34055. index = -amount;
  34056. }
  34057. index = (this.instance.countCols() + index) % this.instance.countCols();
  34058. var logicColumns = this.visualColumnsToPhysical(index, amount);
  34059. var descendingLogicColumns = logicColumns.slice(0).sort(function (a, b) {
  34060. return b - a;
  34061. });
  34062. var actionWasNotCancelled = this.instance.runHooks('beforeRemoveCol', index, amount, logicColumns, source);
  34063. if (actionWasNotCancelled === false) {
  34064. return;
  34065. }
  34066. var isTableUniform = true;
  34067. var removedColumnsCount = descendingLogicColumns.length;
  34068. var data = this.dataSource;
  34069. for (var c = 0; c < removedColumnsCount; c++) {
  34070. if (isTableUniform && logicColumns[0] !== logicColumns[c] - c) {
  34071. isTableUniform = false;
  34072. }
  34073. }
  34074. if (isTableUniform) {
  34075. for (var r = 0, rlen = this.instance.countSourceRows(); r < rlen; r++) {
  34076. data[r].splice(logicColumns[0], amount);
  34077. }
  34078. } else {
  34079. for (var _r2 = 0, _rlen = this.instance.countSourceRows(); _r2 < _rlen; _r2++) {
  34080. for (var _c = 0; _c < removedColumnsCount; _c++) {
  34081. data[_r2].splice(descendingLogicColumns[_c], 1);
  34082. }
  34083. }
  34084. for (var _c2 = 0; _c2 < removedColumnsCount; _c2++) {
  34085. this.priv.columnSettings.splice(logicColumns[_c2], 1);
  34086. }
  34087. }
  34088. this.instance.runHooks('afterRemoveCol', index, amount, logicColumns, source);
  34089. this.instance.forceFullRender = true; // used when data was changed
  34090. };
  34091. /**
  34092. * Add/Removes data from the column.
  34093. *
  34094. * @param {Number} col Physical index of column in which do you want to do splice
  34095. * @param {Number} index Index at which to start changing the array. If negative, will begin that many elements from the end
  34096. * @param {Number} amount An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed
  34097. * @returns {Array} Returns removed portion of columns
  34098. */
  34099. DataMap.prototype.spliceCol = function (col, index, amount /* , elements... */) {
  34100. var elements = arguments.length >= 4 ? [].slice.call(arguments, 3) : [];
  34101. var colData = this.instance.getDataAtCol(col);
  34102. var removed = colData.slice(index, index + amount);
  34103. var after = colData.slice(index + amount);
  34104. (0, _array.extendArray)(elements, after);
  34105. var i = 0;
  34106. while (i < amount) {
  34107. elements.push(null); // add null in place of removed elements
  34108. i++;
  34109. }
  34110. (0, _array.to2dArray)(elements);
  34111. this.instance.populateFromArray(index, col, elements, null, null, 'spliceCol');
  34112. return removed;
  34113. };
  34114. /**
  34115. * Add/Removes data from the row.
  34116. *
  34117. * @param {Number} row Physical index of row in which do you want to do splice
  34118. * @param {Number} index Index at which to start changing the array. If negative, will begin that many elements from the end.
  34119. * @param {Number} amount An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed.
  34120. * @returns {Array} Returns removed portion of rows
  34121. */
  34122. DataMap.prototype.spliceRow = function (row, index, amount /* , elements... */) {
  34123. var elements = arguments.length >= 4 ? [].slice.call(arguments, 3) : [];
  34124. var rowData = this.instance.getSourceDataAtRow(row);
  34125. var removed = rowData.slice(index, index + amount);
  34126. var after = rowData.slice(index + amount);
  34127. (0, _array.extendArray)(elements, after);
  34128. var i = 0;
  34129. while (i < amount) {
  34130. elements.push(null); // add null in place of removed elements
  34131. i++;
  34132. }
  34133. this.instance.populateFromArray(row, index, [elements], null, null, 'spliceRow');
  34134. return removed;
  34135. };
  34136. /**
  34137. * Add/remove row(s) to/from the data source.
  34138. *
  34139. * @param {Number} index Physical index of the element to remove.
  34140. * @param {Number} amount Number of rows to add/remove.
  34141. * @param {Object} element Row to add.
  34142. */
  34143. DataMap.prototype.spliceData = function (index, amount, element) {
  34144. var continueSplicing = this.instance.runHooks('beforeDataSplice', index, amount, element);
  34145. if (continueSplicing !== false) {
  34146. this.dataSource.splice(index, amount, element);
  34147. }
  34148. };
  34149. /**
  34150. * Filter unwanted data elements from the data source.
  34151. *
  34152. * @param {Number} index Visual index of the element to remove.
  34153. * @param {Number} amount Number of rows to add/remove.
  34154. * @returns {Array}
  34155. */
  34156. DataMap.prototype.filterData = function (index, amount) {
  34157. var physicalRows = this.visualRowsToPhysical(index, amount);
  34158. var continueSplicing = this.instance.runHooks('beforeDataFilter', index, amount, physicalRows);
  34159. if (continueSplicing !== false) {
  34160. var newData = this.dataSource.filter(function (row, index) {
  34161. return physicalRows.indexOf(index) == -1;
  34162. });
  34163. return newData;
  34164. }
  34165. };
  34166. /**
  34167. * Returns single value from the data array.
  34168. *
  34169. * @param {Number} row Visual row index.
  34170. * @param {Number} prop
  34171. */
  34172. DataMap.prototype.get = function (row, prop) {
  34173. row = this.instance.runHooks('modifyRow', row);
  34174. var dataRow = this.dataSource[row];
  34175. // TODO: To remove, use 'modifyData' hook instead (see below)
  34176. var modifiedRowData = this.instance.runHooks('modifyRowData', row);
  34177. dataRow = isNaN(modifiedRowData) ? modifiedRowData : dataRow;
  34178. //
  34179. var value = null;
  34180. // try to get value under property `prop` (includes dot)
  34181. if (dataRow && dataRow.hasOwnProperty && (0, _object.hasOwnProperty)(dataRow, prop)) {
  34182. value = dataRow[prop];
  34183. } else if (typeof prop === 'string' && prop.indexOf('.') > -1) {
  34184. var sliced = prop.split('.');
  34185. var out = dataRow;
  34186. if (!out) {
  34187. return null;
  34188. }
  34189. for (var i = 0, ilen = sliced.length; i < ilen; i++) {
  34190. out = out[sliced[i]];
  34191. if (typeof out === 'undefined') {
  34192. return null;
  34193. }
  34194. }
  34195. value = out;
  34196. } else if (typeof prop === 'function') {
  34197. /**
  34198. * allows for interacting with complex structures, for example
  34199. * d3/jQuery getter/setter properties:
  34200. *
  34201. * {columns: [{
  34202. * data: function(row, value){
  34203. * if(arguments.length === 1){
  34204. * return row.property();
  34205. * }
  34206. * row.property(value);
  34207. * }
  34208. * }]}
  34209. */
  34210. value = prop(this.dataSource.slice(row, row + 1)[0]);
  34211. }
  34212. if (this.instance.hasHook('modifyData')) {
  34213. var valueHolder = (0, _object.createObjectPropListener)(value);
  34214. this.instance.runHooks('modifyData', row, this.propToCol(prop), valueHolder, 'get');
  34215. if (valueHolder.isTouched()) {
  34216. value = valueHolder.value;
  34217. }
  34218. }
  34219. return value;
  34220. };
  34221. var copyableLookup = (0, _data.cellMethodLookupFactory)('copyable', false);
  34222. /**
  34223. * Returns single value from the data array (intended for clipboard copy to an external application).
  34224. *
  34225. * @param {Number} row Physical row index.
  34226. * @param {Number} prop
  34227. * @returns {String}
  34228. */
  34229. DataMap.prototype.getCopyable = function (row, prop) {
  34230. if (copyableLookup.call(this.instance, row, this.propToCol(prop))) {
  34231. return this.get(row, prop);
  34232. }
  34233. return '';
  34234. };
  34235. /**
  34236. * Saves single value to the data array.
  34237. *
  34238. * @param {Number} row Visual row index.
  34239. * @param {Number} prop
  34240. * @param {String} value
  34241. * @param {String} [source] Source of hook runner.
  34242. */
  34243. DataMap.prototype.set = function (row, prop, value, source) {
  34244. row = this.instance.runHooks('modifyRow', row, source || 'datamapGet');
  34245. var dataRow = this.dataSource[row];
  34246. // TODO: To remove, use 'modifyData' hook instead (see below)
  34247. var modifiedRowData = this.instance.runHooks('modifyRowData', row);
  34248. dataRow = isNaN(modifiedRowData) ? modifiedRowData : dataRow;
  34249. //
  34250. if (this.instance.hasHook('modifyData')) {
  34251. var valueHolder = (0, _object.createObjectPropListener)(value);
  34252. this.instance.runHooks('modifyData', row, this.propToCol(prop), valueHolder, 'set');
  34253. if (valueHolder.isTouched()) {
  34254. value = valueHolder.value;
  34255. }
  34256. }
  34257. // try to set value under property `prop` (includes dot)
  34258. if (dataRow && dataRow.hasOwnProperty && (0, _object.hasOwnProperty)(dataRow, prop)) {
  34259. dataRow[prop] = value;
  34260. } else if (typeof prop === 'string' && prop.indexOf('.') > -1) {
  34261. var sliced = prop.split('.');
  34262. var out = dataRow;
  34263. var i = 0;
  34264. var ilen = void 0;
  34265. for (i = 0, ilen = sliced.length - 1; i < ilen; i++) {
  34266. if (typeof out[sliced[i]] === 'undefined') {
  34267. out[sliced[i]] = {};
  34268. }
  34269. out = out[sliced[i]];
  34270. }
  34271. out[sliced[i]] = value;
  34272. } else if (typeof prop === 'function') {
  34273. /* see the `function` handler in `get` */
  34274. prop(this.dataSource.slice(row, row + 1)[0], value);
  34275. } else {
  34276. dataRow[prop] = value;
  34277. }
  34278. };
  34279. /**
  34280. * This ridiculous piece of code maps rows Id that are present in table data to those displayed for user.
  34281. * The trick is, the physical row id (stored in settings.data) is not necessary the same
  34282. * as the visual (displayed) row id (e.g. when sorting is applied).
  34283. *
  34284. * @param {Number} index Visual row index.
  34285. * @param {Number} amount
  34286. * @fires Hooks#modifyRow
  34287. * @returns {Number}
  34288. */
  34289. DataMap.prototype.visualRowsToPhysical = function (index, amount) {
  34290. var totalRows = this.instance.countSourceRows();
  34291. var physicRow = (totalRows + index) % totalRows;
  34292. var logicRows = [];
  34293. var rowsToRemove = amount;
  34294. var row;
  34295. while (physicRow < totalRows && rowsToRemove) {
  34296. row = this.instance.runHooks('modifyRow', physicRow);
  34297. logicRows.push(row);
  34298. rowsToRemove--;
  34299. physicRow++;
  34300. }
  34301. return logicRows;
  34302. };
  34303. /**
  34304. *
  34305. * @param index Visual column index.
  34306. * @param amount
  34307. * @returns {Array}
  34308. */
  34309. DataMap.prototype.visualColumnsToPhysical = function (index, amount) {
  34310. var totalCols = this.instance.countCols();
  34311. var physicalCol = (totalCols + index) % totalCols;
  34312. var visualCols = [];
  34313. var colsToRemove = amount;
  34314. while (physicalCol < totalCols && colsToRemove) {
  34315. var col = this.instance.runHooks('modifyCol', physicalCol);
  34316. visualCols.push(col);
  34317. colsToRemove--;
  34318. physicalCol++;
  34319. }
  34320. return visualCols;
  34321. };
  34322. /**
  34323. * Clears the data array.
  34324. */
  34325. DataMap.prototype.clear = function () {
  34326. for (var r = 0; r < this.instance.countSourceRows(); r++) {
  34327. for (var c = 0; c < this.instance.countCols(); c++) {
  34328. this.set(r, this.colToProp(c), '');
  34329. }
  34330. }
  34331. };
  34332. /**
  34333. * Clear cached data length.
  34334. */
  34335. DataMap.prototype.clearLengthCache = function () {
  34336. this.cachedLength = null;
  34337. };
  34338. /**
  34339. * Get data length.
  34340. *
  34341. * @returns {Number}
  34342. */
  34343. DataMap.prototype.getLength = function () {
  34344. var _this3 = this;
  34345. var maxRows = void 0,
  34346. maxRowsFromSettings = this.instance.getSettings().maxRows;
  34347. if (maxRowsFromSettings < 0 || maxRowsFromSettings === 0) {
  34348. maxRows = 0;
  34349. } else {
  34350. maxRows = maxRowsFromSettings || Infinity;
  34351. }
  34352. var length = this.instance.countSourceRows();
  34353. if (this.instance.hasHook('modifyRow')) {
  34354. var reValidate = this.skipCache;
  34355. this.interval.start();
  34356. if (length !== this.latestSourceRowsCount) {
  34357. reValidate = true;
  34358. }
  34359. this.latestSourceRowsCount = length;
  34360. if (this.cachedLength === null || reValidate) {
  34361. (0, _number.rangeEach)(length - 1, function (row) {
  34362. row = _this3.instance.runHooks('modifyRow', row);
  34363. if (row === null) {
  34364. --length;
  34365. }
  34366. });
  34367. this.cachedLength = length;
  34368. } else {
  34369. length = this.cachedLength;
  34370. }
  34371. } else {
  34372. this.interval.stop();
  34373. }
  34374. return Math.min(length, maxRows);
  34375. };
  34376. /**
  34377. * Returns the data array.
  34378. *
  34379. * @returns {Array}
  34380. */
  34381. DataMap.prototype.getAll = function () {
  34382. var start = {
  34383. row: 0,
  34384. col: 0
  34385. };
  34386. var end = {
  34387. row: Math.max(this.instance.countSourceRows() - 1, 0),
  34388. col: Math.max(this.instance.countCols() - 1, 0)
  34389. };
  34390. if (start.row - end.row === 0 && !this.instance.countSourceRows()) {
  34391. return [];
  34392. }
  34393. return this.getRange(start, end, DataMap.prototype.DESTINATION_RENDERER);
  34394. };
  34395. /**
  34396. * Returns data range as array.
  34397. *
  34398. * @param {Object} [start] Start selection position. Visual indexes.
  34399. * @param {Object} [end] End selection position. Visual indexes.
  34400. * @param {Number} destination Destination of datamap.get
  34401. * @returns {Array}
  34402. */
  34403. DataMap.prototype.getRange = function (start, end, destination) {
  34404. var r,
  34405. rlen,
  34406. c,
  34407. clen,
  34408. output = [],
  34409. row;
  34410. var maxRows = this.instance.getSettings().maxRows;
  34411. var maxCols = this.instance.getSettings().maxCols;
  34412. if (maxRows === 0 || maxCols === 0) {
  34413. return [];
  34414. }
  34415. var getFn = destination === this.DESTINATION_CLIPBOARD_GENERATOR ? this.getCopyable : this.get;
  34416. rlen = Math.min(Math.max(maxRows - 1, 0), Math.max(start.row, end.row));
  34417. clen = Math.min(Math.max(maxCols - 1, 0), Math.max(start.col, end.col));
  34418. for (r = Math.min(start.row, end.row); r <= rlen; r++) {
  34419. row = [];
  34420. var physicalRow = this.instance.runHooks('modifyRow', r);
  34421. for (c = Math.min(start.col, end.col); c <= clen; c++) {
  34422. if (physicalRow === null) {
  34423. break;
  34424. }
  34425. row.push(getFn.call(this, r, this.colToProp(c)));
  34426. }
  34427. if (physicalRow !== null) {
  34428. output.push(row);
  34429. }
  34430. }
  34431. return output;
  34432. };
  34433. /**
  34434. * Return data as text (tab separated columns).
  34435. *
  34436. * @param {Object} [start] Start selection position. Visual indexes.
  34437. * @param {Object} [end] End selection position. Visual indexes.
  34438. * @returns {String}
  34439. */
  34440. DataMap.prototype.getText = function (start, end) {
  34441. return _SheetClip2.default.stringify(this.getRange(start, end, this.DESTINATION_RENDERER));
  34442. };
  34443. /**
  34444. * Return data as copyable text (tab separated columns intended for clipboard copy to an external application).
  34445. *
  34446. * @param {Object} [start] Start selection position. Visual indexes.
  34447. * @param {Object} [end] End selection position. Visual indexes.
  34448. * @returns {String}
  34449. */
  34450. DataMap.prototype.getCopyableText = function (start, end) {
  34451. return _SheetClip2.default.stringify(this.getRange(start, end, this.DESTINATION_CLIPBOARD_GENERATOR));
  34452. };
  34453. /**
  34454. * `skipLengthCache` callback.
  34455. * @private
  34456. * @param {Number} delay Time of the delay in milliseconds.
  34457. */
  34458. DataMap.prototype.onSkipLengthCache = function (delay) {
  34459. var _this4 = this;
  34460. this.skipCache = true;
  34461. setTimeout(function () {
  34462. _this4.skipCache = false;
  34463. }, delay);
  34464. };
  34465. /**
  34466. * Destroy instance.
  34467. */
  34468. DataMap.prototype.destroy = function () {
  34469. this.interval.stop();
  34470. this.interval = null;
  34471. this.instance = null;
  34472. this.priv = null;
  34473. this.GridSettings = null;
  34474. this.dataSource = null;
  34475. this.cachedLength = null;
  34476. this.duckSchema = null;
  34477. };
  34478. exports.default = DataMap;
  34479. /***/ }),
  34480. /* 386 */
  34481. /***/ (function(module, exports, __webpack_require__) {
  34482. "use strict";
  34483. exports.__esModule = true;
  34484. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  34485. exports.parseDelay = parseDelay;
  34486. var _feature = __webpack_require__(40);
  34487. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  34488. /**
  34489. * @class Interval
  34490. * @util
  34491. */
  34492. var Interval = function () {
  34493. _createClass(Interval, null, [{
  34494. key: 'create',
  34495. value: function create(func, delay) {
  34496. return new Interval(func, delay);
  34497. }
  34498. }]);
  34499. function Interval(func, delay) {
  34500. var _this = this;
  34501. _classCallCheck(this, Interval);
  34502. /**
  34503. * Animation frame request id.
  34504. *
  34505. * @type {Number}
  34506. */
  34507. this.timer = null;
  34508. /**
  34509. * Function to invoke repeatedly.
  34510. *
  34511. * @type {Function}
  34512. */
  34513. this.func = func;
  34514. /**
  34515. * Number of milliseconds that function should wait before next call.
  34516. */
  34517. this.delay = parseDelay(delay);
  34518. /**
  34519. * Flag which indicates if interval object was stopped.
  34520. *
  34521. * @type {Boolean}
  34522. * @default true
  34523. */
  34524. this.stopped = true;
  34525. /**
  34526. * Interval time (in milliseconds) of the last callback call.
  34527. *
  34528. * @private
  34529. * @type {Number}
  34530. */
  34531. this._then = null;
  34532. /**
  34533. * Bounded function `func`.
  34534. *
  34535. * @private
  34536. * @type {Function}
  34537. */
  34538. this._callback = function () {
  34539. return _this.__callback();
  34540. };
  34541. }
  34542. /**
  34543. * Start loop.
  34544. *
  34545. * @returns {Interval}
  34546. */
  34547. _createClass(Interval, [{
  34548. key: 'start',
  34549. value: function start() {
  34550. if (this.stopped) {
  34551. this._then = Date.now();
  34552. this.stopped = false;
  34553. this.timer = (0, _feature.requestAnimationFrame)(this._callback);
  34554. }
  34555. return this;
  34556. }
  34557. /**
  34558. * Stop looping.
  34559. *
  34560. * @returns {Interval}
  34561. */
  34562. }, {
  34563. key: 'stop',
  34564. value: function stop() {
  34565. if (!this.stopped) {
  34566. this.stopped = true;
  34567. (0, _feature.cancelAnimationFrame)(this.timer);
  34568. this.timer = null;
  34569. }
  34570. return this;
  34571. }
  34572. /**
  34573. * Loop callback, fired on every animation frame.
  34574. *
  34575. * @private
  34576. */
  34577. }, {
  34578. key: '__callback',
  34579. value: function __callback() {
  34580. this.timer = (0, _feature.requestAnimationFrame)(this._callback);
  34581. if (this.delay) {
  34582. var now = Date.now();
  34583. var elapsed = now - this._then;
  34584. if (elapsed > this.delay) {
  34585. this._then = now - elapsed % this.delay;
  34586. this.func();
  34587. }
  34588. } else {
  34589. this.func();
  34590. }
  34591. }
  34592. }]);
  34593. return Interval;
  34594. }();
  34595. exports.default = Interval;
  34596. function parseDelay(delay) {
  34597. if (typeof delay === 'string' && /fps$/.test(delay)) {
  34598. delay = 1000 / parseInt(delay.replace('fps', '') || 0, 10);
  34599. }
  34600. return delay;
  34601. }
  34602. /***/ }),
  34603. /* 387 */
  34604. /***/ (function(module, exports, __webpack_require__) {
  34605. "use strict";
  34606. exports.__esModule = true;
  34607. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  34608. function MultiMap() {
  34609. var map = {
  34610. arrayMap: [],
  34611. weakMap: new WeakMap()
  34612. };
  34613. return {
  34614. get: function get(key) {
  34615. if (canBeAnArrayMapKey(key)) {
  34616. return map.arrayMap[key];
  34617. } else if (canBeAWeakMapKey(key)) {
  34618. return map.weakMap.get(key);
  34619. }
  34620. },
  34621. set: function set(key, value) {
  34622. if (canBeAnArrayMapKey(key)) {
  34623. map.arrayMap[key] = value;
  34624. } else if (canBeAWeakMapKey(key)) {
  34625. map.weakMap.set(key, value);
  34626. } else {
  34627. throw new Error('Invalid key type');
  34628. }
  34629. },
  34630. delete: function _delete(key) {
  34631. if (canBeAnArrayMapKey(key)) {
  34632. delete map.arrayMap[key];
  34633. } else if (canBeAWeakMapKey(key)) {
  34634. map.weakMap.delete(key);
  34635. }
  34636. }
  34637. };
  34638. function canBeAnArrayMapKey(obj) {
  34639. return obj !== null && !isNaNSymbol(obj) && (typeof obj == 'string' || typeof obj == 'number');
  34640. }
  34641. function canBeAWeakMapKey(obj) {
  34642. return obj !== null && ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) == 'object' || typeof obj == 'function');
  34643. }
  34644. function isNaNSymbol(obj) {
  34645. /* eslint-disable no-self-compare */
  34646. return obj !== obj; // NaN === NaN is always false
  34647. }
  34648. }
  34649. exports.default = MultiMap;
  34650. /***/ }),
  34651. /* 388 */
  34652. /***/ (function(module, exports, __webpack_require__) {
  34653. "use strict";
  34654. exports.__esModule = true;
  34655. var _src = __webpack_require__(4);
  34656. var _unicode = __webpack_require__(21);
  34657. var _event = __webpack_require__(12);
  34658. var _editors = __webpack_require__(17);
  34659. var _eventManager = __webpack_require__(6);
  34660. var _eventManager2 = _interopRequireDefault(_eventManager);
  34661. var _baseEditor = __webpack_require__(54);
  34662. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  34663. function EditorManager(instance, priv, selection) {
  34664. var _this = this,
  34665. destroyed = false,
  34666. lock = false,
  34667. eventManager,
  34668. activeEditor;
  34669. eventManager = new _eventManager2.default(instance);
  34670. function moveSelectionAfterEnter(shiftKey) {
  34671. var enterMoves = typeof priv.settings.enterMoves === 'function' ? priv.settings.enterMoves(event) : priv.settings.enterMoves;
  34672. if (shiftKey) {
  34673. // move selection up
  34674. selection.transformStart(-enterMoves.row, -enterMoves.col);
  34675. } else {
  34676. // move selection down (add a new row if needed)
  34677. selection.transformStart(enterMoves.row, enterMoves.col, true);
  34678. }
  34679. }
  34680. function moveSelectionUp(shiftKey) {
  34681. if (shiftKey) {
  34682. selection.transformEnd(-1, 0);
  34683. } else {
  34684. selection.transformStart(-1, 0);
  34685. }
  34686. }
  34687. function moveSelectionDown(shiftKey) {
  34688. if (shiftKey) {
  34689. // expanding selection down with shift
  34690. selection.transformEnd(1, 0);
  34691. } else {
  34692. selection.transformStart(1, 0);
  34693. }
  34694. }
  34695. function moveSelectionRight(shiftKey) {
  34696. if (shiftKey) {
  34697. selection.transformEnd(0, 1);
  34698. } else {
  34699. selection.transformStart(0, 1);
  34700. }
  34701. }
  34702. function moveSelectionLeft(shiftKey) {
  34703. if (shiftKey) {
  34704. selection.transformEnd(0, -1);
  34705. } else {
  34706. selection.transformStart(0, -1);
  34707. }
  34708. }
  34709. function onKeyDown(event) {
  34710. if (!instance.isListening()) {
  34711. return;
  34712. }
  34713. instance.runHooks('beforeKeyDown', event);
  34714. if (destroyed) {
  34715. return;
  34716. }
  34717. if ((0, _event.isImmediatePropagationStopped)(event)) {
  34718. return;
  34719. }
  34720. priv.lastKeyCode = event.keyCode;
  34721. if (!selection.isSelected()) {
  34722. return;
  34723. }
  34724. // catch CTRL but not right ALT (which in some systems triggers ALT+CTRL)
  34725. var ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  34726. if (activeEditor && !activeEditor.isWaiting()) {
  34727. if (!(0, _unicode.isMetaKey)(event.keyCode) && !(0, _unicode.isCtrlMetaKey)(event.keyCode) && !ctrlDown && !_this.isEditorOpened()) {
  34728. _this.openEditor('', event);
  34729. return;
  34730. }
  34731. }
  34732. var rangeModifier = event.shiftKey ? selection.setRangeEnd : selection.setRangeStart;
  34733. var tabMoves = void 0;
  34734. switch (event.keyCode) {
  34735. case _unicode.KEY_CODES.A:
  34736. if (!_this.isEditorOpened() && ctrlDown) {
  34737. instance.selectAll();
  34738. event.preventDefault();
  34739. (0, _event.stopPropagation)(event);
  34740. }
  34741. break;
  34742. case _unicode.KEY_CODES.ARROW_UP:
  34743. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  34744. _this.closeEditorAndSaveChanges(ctrlDown);
  34745. }
  34746. moveSelectionUp(event.shiftKey);
  34747. event.preventDefault();
  34748. (0, _event.stopPropagation)(event);
  34749. break;
  34750. case _unicode.KEY_CODES.ARROW_DOWN:
  34751. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  34752. _this.closeEditorAndSaveChanges(ctrlDown);
  34753. }
  34754. moveSelectionDown(event.shiftKey);
  34755. event.preventDefault();
  34756. (0, _event.stopPropagation)(event);
  34757. break;
  34758. case _unicode.KEY_CODES.ARROW_RIGHT:
  34759. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  34760. _this.closeEditorAndSaveChanges(ctrlDown);
  34761. }
  34762. moveSelectionRight(event.shiftKey);
  34763. event.preventDefault();
  34764. (0, _event.stopPropagation)(event);
  34765. break;
  34766. case _unicode.KEY_CODES.ARROW_LEFT:
  34767. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  34768. _this.closeEditorAndSaveChanges(ctrlDown);
  34769. }
  34770. moveSelectionLeft(event.shiftKey);
  34771. event.preventDefault();
  34772. (0, _event.stopPropagation)(event);
  34773. break;
  34774. case _unicode.KEY_CODES.TAB:
  34775. tabMoves = typeof priv.settings.tabMoves === 'function' ? priv.settings.tabMoves(event) : priv.settings.tabMoves;
  34776. if (event.shiftKey) {
  34777. // move selection left
  34778. selection.transformStart(-tabMoves.row, -tabMoves.col);
  34779. } else {
  34780. // move selection right (add a new column if needed)
  34781. selection.transformStart(tabMoves.row, tabMoves.col, true);
  34782. }
  34783. event.preventDefault();
  34784. (0, _event.stopPropagation)(event);
  34785. break;
  34786. case _unicode.KEY_CODES.BACKSPACE:
  34787. case _unicode.KEY_CODES.DELETE:
  34788. instance.emptySelectedCells();
  34789. _this.prepareEditor();
  34790. event.preventDefault();
  34791. break;
  34792. case _unicode.KEY_CODES.F2:
  34793. /* F2 */
  34794. _this.openEditor(null, event);
  34795. if (activeEditor) {
  34796. activeEditor.enableFullEditMode();
  34797. }
  34798. event.preventDefault(); // prevent Opera from opening 'Go to Page dialog'
  34799. break;
  34800. case _unicode.KEY_CODES.ENTER:
  34801. /* return/enter */
  34802. if (_this.isEditorOpened()) {
  34803. if (activeEditor && activeEditor.state !== _baseEditor.EditorState.WAITING) {
  34804. _this.closeEditorAndSaveChanges(ctrlDown);
  34805. }
  34806. moveSelectionAfterEnter(event.shiftKey);
  34807. } else if (instance.getSettings().enterBeginsEditing) {
  34808. _this.openEditor(null, event);
  34809. if (activeEditor) {
  34810. activeEditor.enableFullEditMode();
  34811. }
  34812. } else {
  34813. moveSelectionAfterEnter(event.shiftKey);
  34814. }
  34815. event.preventDefault(); // don't add newline to field
  34816. (0, _event.stopImmediatePropagation)(event); // required by HandsontableEditor
  34817. break;
  34818. case _unicode.KEY_CODES.ESCAPE:
  34819. if (_this.isEditorOpened()) {
  34820. _this.closeEditorAndRestoreOriginalValue(ctrlDown);
  34821. }
  34822. event.preventDefault();
  34823. break;
  34824. case _unicode.KEY_CODES.HOME:
  34825. if (event.ctrlKey || event.metaKey) {
  34826. rangeModifier.call(selection, new _src.CellCoords(0, selection.selectedRange.current().from.col));
  34827. } else {
  34828. rangeModifier.call(selection, new _src.CellCoords(selection.selectedRange.current().from.row, 0));
  34829. }
  34830. event.preventDefault(); // don't scroll the window
  34831. (0, _event.stopPropagation)(event);
  34832. break;
  34833. case _unicode.KEY_CODES.END:
  34834. if (event.ctrlKey || event.metaKey) {
  34835. rangeModifier.call(selection, new _src.CellCoords(instance.countRows() - 1, selection.selectedRange.current().from.col));
  34836. } else {
  34837. rangeModifier.call(selection, new _src.CellCoords(selection.selectedRange.current().from.row, instance.countCols() - 1));
  34838. }
  34839. event.preventDefault(); // don't scroll the window
  34840. (0, _event.stopPropagation)(event);
  34841. break;
  34842. case _unicode.KEY_CODES.PAGE_UP:
  34843. selection.transformStart(-instance.countVisibleRows(), 0);
  34844. event.preventDefault(); // don't page up the window
  34845. (0, _event.stopPropagation)(event);
  34846. break;
  34847. case _unicode.KEY_CODES.PAGE_DOWN:
  34848. selection.transformStart(instance.countVisibleRows(), 0);
  34849. event.preventDefault(); // don't page down the window
  34850. (0, _event.stopPropagation)(event);
  34851. break;
  34852. default:
  34853. break;
  34854. }
  34855. }
  34856. function init() {
  34857. instance.addHook('afterDocumentKeyDown', onKeyDown);
  34858. eventManager.addEventListener(document.documentElement, 'keydown', function (event) {
  34859. if (!destroyed) {
  34860. instance.runHooks('afterDocumentKeyDown', event);
  34861. }
  34862. });
  34863. function onDblClick(event, coords, elem) {
  34864. // may be TD or TH
  34865. if (elem.nodeName === 'TD') {
  34866. _this.openEditor(null, event);
  34867. if (activeEditor) {
  34868. activeEditor.enableFullEditMode();
  34869. }
  34870. }
  34871. }
  34872. instance.view.wt.update('onCellDblClick', onDblClick);
  34873. }
  34874. /**
  34875. * Lock the editor from being prepared and closed. Locking the editor prevents its closing and
  34876. * reinitialized after selecting the new cell. This feature is necessary for a mobile editor.
  34877. *
  34878. * @function lockEditor
  34879. * @memberof! Handsontable.EditorManager#
  34880. */
  34881. this.lockEditor = function () {
  34882. lock = true;
  34883. };
  34884. /**
  34885. * Unlock the editor from being prepared and closed. This method restores the original behavior of
  34886. * the editors where for every new selection its instances are closed.
  34887. *
  34888. * @function unlockEditor
  34889. * @memberof! Handsontable.EditorManager#
  34890. */
  34891. this.unlockEditor = function () {
  34892. lock = false;
  34893. };
  34894. /**
  34895. * Destroy current editor, if exists.
  34896. *
  34897. * @function destroyEditor
  34898. * @memberof! Handsontable.EditorManager#
  34899. * @param {Boolean} revertOriginal
  34900. */
  34901. this.destroyEditor = function (revertOriginal) {
  34902. if (!lock) {
  34903. this.closeEditor(revertOriginal);
  34904. }
  34905. };
  34906. /**
  34907. * Get active editor.
  34908. *
  34909. * @function getActiveEditor
  34910. * @memberof! Handsontable.EditorManager#
  34911. * @returns {*}
  34912. */
  34913. this.getActiveEditor = function () {
  34914. return activeEditor;
  34915. };
  34916. /**
  34917. * Prepare text input to be displayed at given grid cell.
  34918. *
  34919. * @function prepareEditor
  34920. * @memberof! Handsontable.EditorManager#
  34921. */
  34922. this.prepareEditor = function () {
  34923. if (lock) {
  34924. return;
  34925. }
  34926. var row, col, prop, td, originalValue, cellProperties, editorClass;
  34927. if (activeEditor && activeEditor.isWaiting()) {
  34928. this.closeEditor(false, false, function (dataSaved) {
  34929. if (dataSaved) {
  34930. _this.prepareEditor();
  34931. }
  34932. });
  34933. return;
  34934. }
  34935. row = instance.selection.selectedRange.current().highlight.row;
  34936. col = instance.selection.selectedRange.current().highlight.col;
  34937. prop = instance.colToProp(col);
  34938. td = instance.getCell(row, col);
  34939. originalValue = instance.getSourceDataAtCell(instance.runHooks('modifyRow', row), col);
  34940. cellProperties = instance.getCellMeta(row, col);
  34941. editorClass = instance.getCellEditor(cellProperties);
  34942. if (editorClass) {
  34943. activeEditor = (0, _editors.getEditorInstance)(editorClass, instance);
  34944. activeEditor.prepare(row, col, prop, td, originalValue, cellProperties);
  34945. } else {
  34946. activeEditor = void 0;
  34947. }
  34948. };
  34949. /**
  34950. * Check is editor is opened/showed.
  34951. *
  34952. * @function isEditorOpened
  34953. * @memberof! Handsontable.EditorManager#
  34954. * @returns {Boolean}
  34955. */
  34956. this.isEditorOpened = function () {
  34957. return activeEditor && activeEditor.isOpened();
  34958. };
  34959. /**
  34960. * Open editor with initial value.
  34961. *
  34962. * @function openEditor
  34963. * @memberof! Handsontable.EditorManager#
  34964. * @param {null|String} newInitialValue new value from which editor will start if handled property it's not the `null`.
  34965. * @param {DOMEvent} event
  34966. */
  34967. this.openEditor = function (newInitialValue, event) {
  34968. if (activeEditor && !activeEditor.cellProperties.readOnly) {
  34969. activeEditor.beginEditing(newInitialValue, event);
  34970. } else if (activeEditor && activeEditor.cellProperties.readOnly) {
  34971. // move the selection after opening the editor with ENTER key
  34972. if (event && event.keyCode === _unicode.KEY_CODES.ENTER) {
  34973. moveSelectionAfterEnter();
  34974. }
  34975. }
  34976. };
  34977. /**
  34978. * Close editor, finish editing cell.
  34979. *
  34980. * @function closeEditor
  34981. * @memberof! Handsontable.EditorManager#
  34982. * @param {Boolean} restoreOriginalValue
  34983. * @param {Boolean} [ctrlDown]
  34984. * @param {Function} [callback]
  34985. */
  34986. this.closeEditor = function (restoreOriginalValue, ctrlDown, callback) {
  34987. if (activeEditor) {
  34988. activeEditor.finishEditing(restoreOriginalValue, ctrlDown, callback);
  34989. } else if (callback) {
  34990. callback(false);
  34991. }
  34992. };
  34993. /**
  34994. * Close editor and save changes.
  34995. *
  34996. * @function closeEditorAndSaveChanges
  34997. * @memberof! Handsontable.EditorManager#
  34998. * @param {Boolean} ctrlDown
  34999. */
  35000. this.closeEditorAndSaveChanges = function (ctrlDown) {
  35001. return this.closeEditor(false, ctrlDown);
  35002. };
  35003. /**
  35004. * Close editor and restore original value.
  35005. *
  35006. * @function closeEditorAndRestoreOriginalValue
  35007. * @memberof! Handsontable.EditorManager#
  35008. * @param {Boolean} ctrlDown
  35009. */
  35010. this.closeEditorAndRestoreOriginalValue = function (ctrlDown) {
  35011. return this.closeEditor(true, ctrlDown);
  35012. };
  35013. /**
  35014. * Destroy the instance.
  35015. */
  35016. this.destroy = function () {
  35017. destroyed = true;
  35018. };
  35019. init();
  35020. }
  35021. var instances = new WeakMap();
  35022. EditorManager.getInstance = function (hotInstance, hotSettings, selection, datamap) {
  35023. var editorManager = instances.get(hotInstance);
  35024. if (!editorManager) {
  35025. editorManager = new EditorManager(hotInstance, hotSettings, selection, datamap);
  35026. instances.set(hotInstance, editorManager);
  35027. }
  35028. return editorManager;
  35029. };
  35030. exports.default = EditorManager;
  35031. /***/ }),
  35032. /* 389 */
  35033. /***/ (function(module, exports, __webpack_require__) {
  35034. "use strict";
  35035. exports.__esModule = true;
  35036. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  35037. var _element = __webpack_require__(0);
  35038. var _browser = __webpack_require__(27);
  35039. var _eventManager = __webpack_require__(6);
  35040. var _eventManager2 = _interopRequireDefault(_eventManager);
  35041. var _event = __webpack_require__(12);
  35042. var _src = __webpack_require__(4);
  35043. var _src2 = _interopRequireDefault(_src);
  35044. var _mouseEventHandler = __webpack_require__(312);
  35045. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  35046. /**
  35047. * Handsontable TableView constructor
  35048. * @param {Object} instance
  35049. */
  35050. function TableView(instance) {
  35051. var _this = this;
  35052. var that = this;
  35053. this.eventManager = new _eventManager2.default(instance);
  35054. this.instance = instance;
  35055. this.settings = instance.getSettings();
  35056. this.selectionMouseDown = false;
  35057. var originalStyle = instance.rootElement.getAttribute('style');
  35058. if (originalStyle) {
  35059. instance.rootElement.setAttribute('data-originalstyle', originalStyle); // needed to retrieve original style in jsFiddle link generator in HT examples. may be removed in future versions
  35060. }
  35061. (0, _element.addClass)(instance.rootElement, 'handsontable');
  35062. var table = document.createElement('TABLE');
  35063. (0, _element.addClass)(table, 'htCore');
  35064. if (instance.getSettings().tableClassName) {
  35065. (0, _element.addClass)(table, instance.getSettings().tableClassName);
  35066. }
  35067. this.THEAD = document.createElement('THEAD');
  35068. table.appendChild(this.THEAD);
  35069. this.TBODY = document.createElement('TBODY');
  35070. table.appendChild(this.TBODY);
  35071. instance.table = table;
  35072. instance.container.insertBefore(table, instance.container.firstChild);
  35073. this.eventManager.addEventListener(instance.rootElement, 'mousedown', function (event) {
  35074. this.selectionMouseDown = true;
  35075. if (!that.isTextSelectionAllowed(event.target)) {
  35076. clearTextSelection();
  35077. event.preventDefault();
  35078. window.focus(); // make sure that window that contains HOT is active. Important when HOT is in iframe.
  35079. }
  35080. });
  35081. this.eventManager.addEventListener(instance.rootElement, 'mouseup', function (event) {
  35082. this.selectionMouseDown = false;
  35083. });
  35084. this.eventManager.addEventListener(instance.rootElement, 'mousemove', function (event) {
  35085. if (this.selectionMouseDown && !that.isTextSelectionAllowed(event.target)) {
  35086. clearTextSelection();
  35087. event.preventDefault();
  35088. }
  35089. });
  35090. this.eventManager.addEventListener(document.documentElement, 'keyup', function (event) {
  35091. if (instance.selection.isInProgress() && !event.shiftKey) {
  35092. instance.selection.finish();
  35093. }
  35094. });
  35095. var isMouseDown;
  35096. this.isMouseDown = function () {
  35097. return isMouseDown;
  35098. };
  35099. this.eventManager.addEventListener(document.documentElement, 'mouseup', function (event) {
  35100. if (instance.selection.isInProgress() && (0, _event.isLeftClick)(event)) {
  35101. // is left mouse button
  35102. instance.selection.finish();
  35103. }
  35104. isMouseDown = false;
  35105. if ((0, _element.isOutsideInput)(document.activeElement) || !instance.selection.isSelected() && !(0, _event.isRightClick)(event)) {
  35106. instance.unlisten();
  35107. }
  35108. });
  35109. this.eventManager.addEventListener(document.documentElement, 'mousedown', function (event) {
  35110. var originalTarget = event.target;
  35111. var next = event.target;
  35112. var eventX = event.x || event.clientX;
  35113. var eventY = event.y || event.clientY;
  35114. if (isMouseDown || !instance.rootElement) {
  35115. return; // it must have been started in a cell
  35116. }
  35117. // immediate click on "holder" means click on the right side of vertical scrollbar
  35118. if (next === instance.view.wt.wtTable.holder) {
  35119. var scrollbarWidth = (0, _element.getScrollbarWidth)();
  35120. if (document.elementFromPoint(eventX + scrollbarWidth, eventY) !== instance.view.wt.wtTable.holder || document.elementFromPoint(eventX, eventY + scrollbarWidth) !== instance.view.wt.wtTable.holder) {
  35121. return;
  35122. }
  35123. } else {
  35124. while (next !== document.documentElement) {
  35125. if (next === null) {
  35126. if (event.isTargetWebComponent) {
  35127. break;
  35128. }
  35129. // click on something that was a row but now is detached (possibly because your click triggered a rerender)
  35130. return;
  35131. }
  35132. if (next === instance.rootElement) {
  35133. // click inside container
  35134. return;
  35135. }
  35136. next = next.parentNode;
  35137. }
  35138. }
  35139. // function did not return until here, we have an outside click!
  35140. var outsideClickDeselects = typeof that.settings.outsideClickDeselects === 'function' ? that.settings.outsideClickDeselects(originalTarget) : that.settings.outsideClickDeselects;
  35141. if (outsideClickDeselects) {
  35142. instance.deselectCell();
  35143. } else {
  35144. instance.destroyEditor();
  35145. }
  35146. });
  35147. this.eventManager.addEventListener(table, 'selectstart', function (event) {
  35148. if (that.settings.fragmentSelection || (0, _element.isInput)(event.target)) {
  35149. return;
  35150. }
  35151. // https://github.com/handsontable/handsontable/issues/160
  35152. // Prevent text from being selected when performing drag down.
  35153. event.preventDefault();
  35154. });
  35155. var clearTextSelection = function clearTextSelection() {
  35156. // http://stackoverflow.com/questions/3169786/clear-text-selection-with-javascript
  35157. if (window.getSelection) {
  35158. if (window.getSelection().empty) {
  35159. // Chrome
  35160. window.getSelection().empty();
  35161. } else if (window.getSelection().removeAllRanges) {
  35162. // Firefox
  35163. window.getSelection().removeAllRanges();
  35164. }
  35165. } else if (document.selection) {
  35166. // IE?
  35167. document.selection.empty();
  35168. }
  35169. };
  35170. var walkontableConfig = {
  35171. debug: function debug() {
  35172. return that.settings.debug;
  35173. },
  35174. externalRowCalculator: this.instance.getPlugin('autoRowSize') && this.instance.getPlugin('autoRowSize').isEnabled(),
  35175. table: table,
  35176. preventOverflow: function preventOverflow() {
  35177. return _this.settings.preventOverflow;
  35178. },
  35179. stretchH: function stretchH() {
  35180. return that.settings.stretchH;
  35181. },
  35182. data: instance.getDataAtCell,
  35183. totalRows: function totalRows() {
  35184. return instance.countRows();
  35185. },
  35186. totalColumns: function totalColumns() {
  35187. return instance.countCols();
  35188. },
  35189. fixedColumnsLeft: function fixedColumnsLeft() {
  35190. return that.settings.fixedColumnsLeft;
  35191. },
  35192. fixedRowsTop: function fixedRowsTop() {
  35193. return that.settings.fixedRowsTop;
  35194. },
  35195. fixedRowsBottom: function fixedRowsBottom() {
  35196. return that.settings.fixedRowsBottom;
  35197. },
  35198. minSpareRows: function minSpareRows() {
  35199. return that.settings.minSpareRows;
  35200. },
  35201. renderAllRows: that.settings.renderAllRows,
  35202. rowHeaders: function rowHeaders() {
  35203. var headerRenderers = [];
  35204. if (instance.hasRowHeaders()) {
  35205. headerRenderers.push(function (row, TH) {
  35206. that.appendRowHeader(row, TH);
  35207. });
  35208. }
  35209. instance.runHooks('afterGetRowHeaderRenderers', headerRenderers);
  35210. return headerRenderers;
  35211. },
  35212. columnHeaders: function columnHeaders() {
  35213. var headerRenderers = [];
  35214. if (instance.hasColHeaders()) {
  35215. headerRenderers.push(function (column, TH) {
  35216. that.appendColHeader(column, TH);
  35217. });
  35218. }
  35219. instance.runHooks('afterGetColumnHeaderRenderers', headerRenderers);
  35220. return headerRenderers;
  35221. },
  35222. columnWidth: instance.getColWidth,
  35223. rowHeight: instance.getRowHeight,
  35224. cellRenderer: function cellRenderer(row, col, TD) {
  35225. var cellProperties = that.instance.getCellMeta(row, col);
  35226. var prop = that.instance.colToProp(col);
  35227. var value = that.instance.getDataAtRowProp(row, prop);
  35228. if (that.instance.hasHook('beforeValueRender')) {
  35229. value = that.instance.runHooks('beforeValueRender', value, cellProperties);
  35230. }
  35231. that.instance.runHooks('beforeRenderer', TD, row, col, prop, value, cellProperties);
  35232. that.instance.getCellRenderer(cellProperties)(that.instance, TD, row, col, prop, value, cellProperties);
  35233. that.instance.runHooks('afterRenderer', TD, row, col, prop, value, cellProperties);
  35234. },
  35235. selections: that.instance.selection.highlight,
  35236. hideBorderOnMouseDownOver: function hideBorderOnMouseDownOver() {
  35237. return that.settings.fragmentSelection;
  35238. },
  35239. onCellMouseDown: function onCellMouseDown(event, coords, TD, wt) {
  35240. var blockCalculations = {
  35241. row: false,
  35242. column: false,
  35243. cell: false
  35244. };
  35245. instance.listen();
  35246. that.activeWt = wt;
  35247. isMouseDown = true;
  35248. instance.runHooks('beforeOnCellMouseDown', event, coords, TD, blockCalculations);
  35249. if ((0, _event.isImmediatePropagationStopped)(event)) {
  35250. return;
  35251. }
  35252. (0, _mouseEventHandler.handleMouseEvent)(event, {
  35253. coords: coords,
  35254. selection: instance.selection,
  35255. controller: blockCalculations
  35256. });
  35257. instance.runHooks('afterOnCellMouseDown', event, coords, TD);
  35258. that.activeWt = that.wt;
  35259. },
  35260. onCellMouseOut: function onCellMouseOut(event, coords, TD, wt) {
  35261. that.activeWt = wt;
  35262. instance.runHooks('beforeOnCellMouseOut', event, coords, TD);
  35263. if ((0, _event.isImmediatePropagationStopped)(event)) {
  35264. return;
  35265. }
  35266. instance.runHooks('afterOnCellMouseOut', event, coords, TD);
  35267. that.activeWt = that.wt;
  35268. },
  35269. onCellMouseOver: function onCellMouseOver(event, coords, TD, wt) {
  35270. var blockCalculations = {
  35271. row: false,
  35272. column: false,
  35273. cell: false
  35274. };
  35275. that.activeWt = wt;
  35276. instance.runHooks('beforeOnCellMouseOver', event, coords, TD, blockCalculations);
  35277. if ((0, _event.isImmediatePropagationStopped)(event)) {
  35278. return;
  35279. }
  35280. if (isMouseDown) {
  35281. (0, _mouseEventHandler.handleMouseEvent)(event, {
  35282. coords: coords,
  35283. selection: instance.selection,
  35284. controller: blockCalculations
  35285. });
  35286. }
  35287. instance.runHooks('afterOnCellMouseOver', event, coords, TD);
  35288. that.activeWt = that.wt;
  35289. },
  35290. onCellMouseUp: function onCellMouseUp(event, coords, TD, wt) {
  35291. that.activeWt = wt;
  35292. instance.runHooks('beforeOnCellMouseUp', event, coords, TD);
  35293. instance.runHooks('afterOnCellMouseUp', event, coords, TD);
  35294. that.activeWt = that.wt;
  35295. },
  35296. onCellCornerMouseDown: function onCellCornerMouseDown(event) {
  35297. event.preventDefault();
  35298. instance.runHooks('afterOnCellCornerMouseDown', event);
  35299. },
  35300. onCellCornerDblClick: function onCellCornerDblClick(event) {
  35301. event.preventDefault();
  35302. instance.runHooks('afterOnCellCornerDblClick', event);
  35303. },
  35304. beforeDraw: function beforeDraw(force, skipRender) {
  35305. that.beforeRender(force, skipRender);
  35306. },
  35307. onDraw: function onDraw(force) {
  35308. that.onDraw(force);
  35309. },
  35310. onScrollVertically: function onScrollVertically() {
  35311. instance.runHooks('afterScrollVertically');
  35312. },
  35313. onScrollHorizontally: function onScrollHorizontally() {
  35314. instance.runHooks('afterScrollHorizontally');
  35315. },
  35316. onBeforeRemoveCellClassNames: function onBeforeRemoveCellClassNames() {
  35317. return instance.runHooks('beforeRemoveCellClassNames');
  35318. },
  35319. onAfterDrawSelection: function onAfterDrawSelection(currentRow, currentColumn, cornersOfSelection, layerLevel) {
  35320. return instance.runHooks('afterDrawSelection', currentRow, currentColumn, cornersOfSelection, layerLevel);
  35321. },
  35322. onBeforeDrawBorders: function onBeforeDrawBorders(corners, borderClassName) {
  35323. instance.runHooks('beforeDrawBorders', corners, borderClassName);
  35324. },
  35325. onBeforeTouchScroll: function onBeforeTouchScroll() {
  35326. instance.runHooks('beforeTouchScroll');
  35327. },
  35328. onAfterMomentumScroll: function onAfterMomentumScroll() {
  35329. instance.runHooks('afterMomentumScroll');
  35330. },
  35331. onBeforeStretchingColumnWidth: function onBeforeStretchingColumnWidth(stretchedWidth, column) {
  35332. return instance.runHooks('beforeStretchingColumnWidth', stretchedWidth, column);
  35333. },
  35334. onModifyRowHeaderWidth: function onModifyRowHeaderWidth(rowHeaderWidth) {
  35335. return instance.runHooks('modifyRowHeaderWidth', rowHeaderWidth);
  35336. },
  35337. onModifyGetCellCoords: function onModifyGetCellCoords(row, column, topmost) {
  35338. return instance.runHooks('modifyGetCellCoords', row, column, topmost);
  35339. },
  35340. viewportRowCalculatorOverride: function viewportRowCalculatorOverride(calc) {
  35341. var rows = instance.countRows();
  35342. var viewportOffset = that.settings.viewportRowRenderingOffset;
  35343. if (viewportOffset === 'auto' && that.settings.fixedRowsTop) {
  35344. viewportOffset = 10;
  35345. }
  35346. if (typeof viewportOffset === 'number') {
  35347. calc.startRow = Math.max(calc.startRow - viewportOffset, 0);
  35348. calc.endRow = Math.min(calc.endRow + viewportOffset, rows - 1);
  35349. }
  35350. if (viewportOffset === 'auto') {
  35351. var center = calc.startRow + calc.endRow - calc.startRow;
  35352. var offset = Math.ceil(center / rows * 12);
  35353. calc.startRow = Math.max(calc.startRow - offset, 0);
  35354. calc.endRow = Math.min(calc.endRow + offset, rows - 1);
  35355. }
  35356. instance.runHooks('afterViewportRowCalculatorOverride', calc);
  35357. },
  35358. viewportColumnCalculatorOverride: function viewportColumnCalculatorOverride(calc) {
  35359. var cols = instance.countCols();
  35360. var viewportOffset = that.settings.viewportColumnRenderingOffset;
  35361. if (viewportOffset === 'auto' && that.settings.fixedColumnsLeft) {
  35362. viewportOffset = 10;
  35363. }
  35364. if (typeof viewportOffset === 'number') {
  35365. calc.startColumn = Math.max(calc.startColumn - viewportOffset, 0);
  35366. calc.endColumn = Math.min(calc.endColumn + viewportOffset, cols - 1);
  35367. }
  35368. if (viewportOffset === 'auto') {
  35369. var center = calc.startColumn + calc.endColumn - calc.startColumn;
  35370. var offset = Math.ceil(center / cols * 12);
  35371. calc.startRow = Math.max(calc.startColumn - offset, 0);
  35372. calc.endColumn = Math.min(calc.endColumn + offset, cols - 1);
  35373. }
  35374. instance.runHooks('afterViewportColumnCalculatorOverride', calc);
  35375. },
  35376. rowHeaderWidth: function rowHeaderWidth() {
  35377. return that.settings.rowHeaderWidth;
  35378. },
  35379. columnHeaderHeight: function columnHeaderHeight() {
  35380. var columnHeaderHeight = instance.runHooks('modifyColumnHeaderHeight');
  35381. return that.settings.columnHeaderHeight || columnHeaderHeight;
  35382. }
  35383. };
  35384. instance.runHooks('beforeInitWalkontable', walkontableConfig);
  35385. this.wt = new _src2.default(walkontableConfig);
  35386. this.activeWt = this.wt;
  35387. this.eventManager.addEventListener(that.wt.wtTable.spreader, 'mousedown', function (event) {
  35388. // right mouse button exactly on spreader means right click on the right hand side of vertical scrollbar
  35389. if (event.target === that.wt.wtTable.spreader && event.which === 3) {
  35390. (0, _event.stopPropagation)(event);
  35391. }
  35392. });
  35393. this.eventManager.addEventListener(that.wt.wtTable.spreader, 'contextmenu', function (event) {
  35394. // right mouse button exactly on spreader means right click on the right hand side of vertical scrollbar
  35395. if (event.target === that.wt.wtTable.spreader && event.which === 3) {
  35396. (0, _event.stopPropagation)(event);
  35397. }
  35398. });
  35399. this.eventManager.addEventListener(document.documentElement, 'click', function () {
  35400. if (that.settings.observeDOMVisibility) {
  35401. if (that.wt.drawInterrupted) {
  35402. that.instance.forceFullRender = true;
  35403. that.render();
  35404. }
  35405. }
  35406. });
  35407. }
  35408. TableView.prototype.isTextSelectionAllowed = function (el) {
  35409. if ((0, _element.isInput)(el)) {
  35410. return true;
  35411. }
  35412. var isChildOfTableBody = (0, _element.isChildOf)(el, this.instance.view.wt.wtTable.spreader);
  35413. if (this.settings.fragmentSelection === true && isChildOfTableBody) {
  35414. return true;
  35415. }
  35416. if (this.settings.fragmentSelection === 'cell' && this.isSelectedOnlyCell() && isChildOfTableBody) {
  35417. return true;
  35418. }
  35419. if (!this.settings.fragmentSelection && this.isCellEdited() && this.isSelectedOnlyCell()) {
  35420. return true;
  35421. }
  35422. return false;
  35423. };
  35424. /**
  35425. * Check if selected only one cell.
  35426. *
  35427. * @returns {Boolean}
  35428. */
  35429. TableView.prototype.isSelectedOnlyCell = function () {
  35430. var _ref = this.instance.getSelectedLast() || [],
  35431. _ref2 = _slicedToArray(_ref, 4),
  35432. row = _ref2[0],
  35433. col = _ref2[1],
  35434. rowEnd = _ref2[2],
  35435. colEnd = _ref2[3];
  35436. return row !== void 0 && row === rowEnd && col === colEnd;
  35437. };
  35438. TableView.prototype.isCellEdited = function () {
  35439. var activeEditor = this.instance.getActiveEditor();
  35440. return activeEditor && activeEditor.isOpened();
  35441. };
  35442. TableView.prototype.beforeRender = function (force, skipRender) {
  35443. if (force) {
  35444. // this.instance.forceFullRender = did Handsontable request full render?
  35445. this.instance.runHooks('beforeRender', this.instance.forceFullRender, skipRender);
  35446. }
  35447. };
  35448. TableView.prototype.onDraw = function (force) {
  35449. if (force) {
  35450. // this.instance.forceFullRender = did Handsontable request full render?
  35451. this.instance.runHooks('afterRender', this.instance.forceFullRender);
  35452. }
  35453. };
  35454. TableView.prototype.render = function () {
  35455. this.wt.draw(!this.instance.forceFullRender);
  35456. this.instance.forceFullRender = false;
  35457. this.instance.renderCall = false;
  35458. };
  35459. /**
  35460. * Returns td object given coordinates
  35461. *
  35462. * @param {CellCoords} coords
  35463. * @param {Boolean} topmost
  35464. */
  35465. TableView.prototype.getCellAtCoords = function (coords, topmost) {
  35466. var td = this.wt.getCell(coords, topmost);
  35467. if (td < 0) {
  35468. // there was an exit code (cell is out of bounds)
  35469. return null;
  35470. }
  35471. return td;
  35472. };
  35473. /**
  35474. * Scroll viewport to selection.
  35475. *
  35476. * @param {CellCoords} coords
  35477. */
  35478. TableView.prototype.scrollViewport = function (coords) {
  35479. this.wt.scrollViewport(coords);
  35480. };
  35481. /**
  35482. * Append row header to a TH element
  35483. * @param row
  35484. * @param TH
  35485. */
  35486. TableView.prototype.appendRowHeader = function (row, TH) {
  35487. if (TH.firstChild) {
  35488. var container = TH.firstChild;
  35489. if (!(0, _element.hasClass)(container, 'relative')) {
  35490. (0, _element.empty)(TH);
  35491. this.appendRowHeader(row, TH);
  35492. return;
  35493. }
  35494. this.updateCellHeader(container.querySelector('.rowHeader'), row, this.instance.getRowHeader);
  35495. } else {
  35496. var div = document.createElement('div');
  35497. var span = document.createElement('span');
  35498. div.className = 'relative';
  35499. span.className = 'rowHeader';
  35500. this.updateCellHeader(span, row, this.instance.getRowHeader);
  35501. div.appendChild(span);
  35502. TH.appendChild(div);
  35503. }
  35504. this.instance.runHooks('afterGetRowHeader', row, TH);
  35505. };
  35506. /**
  35507. * Append column header to a TH element
  35508. * @param col
  35509. * @param TH
  35510. */
  35511. TableView.prototype.appendColHeader = function (col, TH) {
  35512. if (TH.firstChild) {
  35513. var container = TH.firstChild;
  35514. if ((0, _element.hasClass)(container, 'relative')) {
  35515. this.updateCellHeader(container.querySelector('.colHeader'), col, this.instance.getColHeader);
  35516. } else {
  35517. (0, _element.empty)(TH);
  35518. this.appendColHeader(col, TH);
  35519. }
  35520. } else {
  35521. var div = document.createElement('div');
  35522. var span = document.createElement('span');
  35523. div.className = 'relative';
  35524. span.className = 'colHeader';
  35525. this.updateCellHeader(span, col, this.instance.getColHeader);
  35526. div.appendChild(span);
  35527. TH.appendChild(div);
  35528. }
  35529. this.instance.runHooks('afterGetColHeader', col, TH);
  35530. };
  35531. /**
  35532. * Update header cell content
  35533. *
  35534. * @since 0.15.0-beta4
  35535. * @param {HTMLElement} element Element to update
  35536. * @param {Number} index Row index or column index
  35537. * @param {Function} content Function which should be returns content for this cell
  35538. */
  35539. TableView.prototype.updateCellHeader = function (element, index, content) {
  35540. var renderedIndex = index;
  35541. var parentOverlay = this.wt.wtOverlays.getParentOverlay(element) || this.wt;
  35542. // prevent wrong calculations from SampleGenerator
  35543. if (element.parentNode) {
  35544. if ((0, _element.hasClass)(element, 'colHeader')) {
  35545. renderedIndex = parentOverlay.wtTable.columnFilter.sourceToRendered(index);
  35546. } else if ((0, _element.hasClass)(element, 'rowHeader')) {
  35547. renderedIndex = parentOverlay.wtTable.rowFilter.sourceToRendered(index);
  35548. }
  35549. }
  35550. if (renderedIndex > -1) {
  35551. (0, _element.fastInnerHTML)(element, content(index));
  35552. } else {
  35553. // workaround for https://github.com/handsontable/handsontable/issues/1946
  35554. (0, _element.fastInnerText)(element, String.fromCharCode(160));
  35555. (0, _element.addClass)(element, 'cornerHeader');
  35556. }
  35557. };
  35558. /**
  35559. * Given a element's left position relative to the viewport, returns maximum element width until the right
  35560. * edge of the viewport (before scrollbar)
  35561. *
  35562. * @param {Number} leftOffset
  35563. * @return {Number}
  35564. */
  35565. TableView.prototype.maximumVisibleElementWidth = function (leftOffset) {
  35566. var workspaceWidth = this.wt.wtViewport.getWorkspaceWidth();
  35567. var maxWidth = workspaceWidth - leftOffset;
  35568. return maxWidth > 0 ? maxWidth : 0;
  35569. };
  35570. /**
  35571. * Given a element's top position relative to the viewport, returns maximum element height until the bottom
  35572. * edge of the viewport (before scrollbar)
  35573. *
  35574. * @param {Number} topOffset
  35575. * @return {Number}
  35576. */
  35577. TableView.prototype.maximumVisibleElementHeight = function (topOffset) {
  35578. var workspaceHeight = this.wt.wtViewport.getWorkspaceHeight();
  35579. var maxHeight = workspaceHeight - topOffset;
  35580. return maxHeight > 0 ? maxHeight : 0;
  35581. };
  35582. TableView.prototype.mainViewIsActive = function () {
  35583. return this.wt === this.activeWt;
  35584. };
  35585. TableView.prototype.destroy = function () {
  35586. this.wt.destroy();
  35587. this.eventManager.destroy();
  35588. };
  35589. exports.default = TableView;
  35590. /***/ }),
  35591. /* 390 */
  35592. /***/ (function(module, exports, __webpack_require__) {
  35593. "use strict";
  35594. exports.__esModule = true;
  35595. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  35596. var _object = __webpack_require__(2);
  35597. var _array = __webpack_require__(1);
  35598. var _number = __webpack_require__(5);
  35599. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  35600. /**
  35601. * @class DataSource
  35602. * @private
  35603. */
  35604. var DataSource = function () {
  35605. function DataSource(hotInstance) {
  35606. var dataSource = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  35607. _classCallCheck(this, DataSource);
  35608. /**
  35609. * Instance of Handsontable.
  35610. *
  35611. * @type {Handsontable}
  35612. */
  35613. this.hot = hotInstance;
  35614. /**
  35615. * Data source
  35616. *
  35617. * @type {Array}
  35618. */
  35619. this.data = dataSource;
  35620. /**
  35621. * Type of data source.
  35622. *
  35623. * @type {String}
  35624. * @default 'array'
  35625. */
  35626. this.dataType = 'array';
  35627. this.colToProp = function () {};
  35628. this.propToCol = function () {};
  35629. }
  35630. /**
  35631. * Get all data.
  35632. *
  35633. * @param {Boolean} [toArray=false] If `true` return source data as an array of arrays even when source data was provided
  35634. * in another format.
  35635. * @returns {Array}
  35636. */
  35637. _createClass(DataSource, [{
  35638. key: 'getData',
  35639. value: function getData() {
  35640. var toArray = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  35641. var result = this.data;
  35642. if (toArray) {
  35643. result = this.getByRange({ row: 0, col: 0 }, { row: Math.max(this.countRows() - 1, 0), col: Math.max(this.countColumns() - 1, 0) }, true);
  35644. }
  35645. return result;
  35646. }
  35647. /**
  35648. * Set new data source.
  35649. *
  35650. * @param data {Array}
  35651. */
  35652. }, {
  35653. key: 'setData',
  35654. value: function setData(data) {
  35655. this.data = data;
  35656. }
  35657. /**
  35658. * Returns array of column values from the data source. `column` is the index of the row in the data source.
  35659. *
  35660. * @param {Number} column Visual column index.
  35661. * @returns {Array}
  35662. */
  35663. }, {
  35664. key: 'getAtColumn',
  35665. value: function getAtColumn(column) {
  35666. var _this = this;
  35667. var result = [];
  35668. (0, _array.arrayEach)(this.data, function (row) {
  35669. var property = _this.colToProp(column);
  35670. if (typeof property === 'string') {
  35671. row = (0, _object.getProperty)(row, property);
  35672. } else {
  35673. row = row[property];
  35674. }
  35675. result.push(row);
  35676. });
  35677. return result;
  35678. }
  35679. /**
  35680. * Returns a single row of the data (array or object, depending on what you have). `row` is the index of the row in the data source.
  35681. *
  35682. * @param {Number} row Physical row index.
  35683. * @returns {Array|Object}
  35684. */
  35685. }, {
  35686. key: 'getAtRow',
  35687. value: function getAtRow(row) {
  35688. return this.data[row];
  35689. }
  35690. /**
  35691. * Returns a single value from the data.
  35692. *
  35693. * @param {Number} row Physical row index.
  35694. * @param {Number} column Visual column index.
  35695. * @returns {*}
  35696. */
  35697. }, {
  35698. key: 'getAtCell',
  35699. value: function getAtCell(row, column) {
  35700. var result = null;
  35701. var modifyRowData = this.hot.runHooks('modifyRowData', row);
  35702. var dataRow = isNaN(modifyRowData) ? modifyRowData : this.data[row];
  35703. if (dataRow) {
  35704. var prop = this.colToProp(column);
  35705. if (typeof prop === 'string') {
  35706. result = (0, _object.getProperty)(dataRow, prop);
  35707. } else if (typeof prop === 'function') {
  35708. result = prop(this.data.slice(row, row + 1)[0]);
  35709. } else {
  35710. result = dataRow[prop];
  35711. }
  35712. }
  35713. return result;
  35714. }
  35715. /**
  35716. * Returns source data by passed range.
  35717. *
  35718. * @param {Object} start Object with physical `row` and `col` keys (or visual column index, if data type is an array of objects).
  35719. * @param {Object} end Object with physical `row` and `col` keys (or visual column index, if data type is an array of objects).
  35720. * @param {Boolean} [toArray=false] If `true` return source data as an array of arrays even when source data was provided
  35721. * in another format.
  35722. * @returns {Array}
  35723. */
  35724. }, {
  35725. key: 'getByRange',
  35726. value: function getByRange(start, end) {
  35727. var _this2 = this;
  35728. var toArray = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  35729. var startRow = Math.min(start.row, end.row);
  35730. var startCol = Math.min(start.col, end.col);
  35731. var endRow = Math.max(start.row, end.row);
  35732. var endCol = Math.max(start.col, end.col);
  35733. var result = [];
  35734. (0, _number.rangeEach)(startRow, endRow, function (currentRow) {
  35735. var row = _this2.getAtRow(currentRow);
  35736. var newRow = void 0;
  35737. if (_this2.dataType === 'array') {
  35738. newRow = row.slice(startCol, endCol + 1);
  35739. } else if (_this2.dataType === 'object') {
  35740. newRow = toArray ? [] : {};
  35741. (0, _number.rangeEach)(startCol, endCol, function (column) {
  35742. var prop = _this2.colToProp(column);
  35743. if (toArray) {
  35744. newRow.push(row[prop]);
  35745. } else {
  35746. newRow[prop] = row[prop];
  35747. }
  35748. });
  35749. }
  35750. result.push(newRow);
  35751. });
  35752. return result;
  35753. }
  35754. /**
  35755. * Count number of rows.
  35756. *
  35757. * @returns {Number}
  35758. */
  35759. }, {
  35760. key: 'countRows',
  35761. value: function countRows() {
  35762. return Array.isArray(this.data) ? this.data.length : 0;
  35763. }
  35764. /**
  35765. * Count number of columns.
  35766. *
  35767. * @returns {Number}
  35768. */
  35769. }, {
  35770. key: 'countColumns',
  35771. value: function countColumns() {
  35772. var result = 0;
  35773. if (Array.isArray(this.data)) {
  35774. if (this.dataType === 'array') {
  35775. result = this.data[0].length;
  35776. } else if (this.dataType === 'object') {
  35777. result = Object.keys(this.data[0]).length;
  35778. }
  35779. }
  35780. return result;
  35781. }
  35782. /**
  35783. * Destroy instance.
  35784. */
  35785. }, {
  35786. key: 'destroy',
  35787. value: function destroy() {
  35788. this.data = null;
  35789. this.hot = null;
  35790. }
  35791. }]);
  35792. return DataSource;
  35793. }();
  35794. exports.default = DataSource;
  35795. /***/ }),
  35796. /* 391 */
  35797. /***/ (function(module, exports, __webpack_require__) {
  35798. "use strict";
  35799. exports.__esModule = true;
  35800. var _dictionary;
  35801. var _constants = __webpack_require__(7);
  35802. var C = _interopRequireWildcard(_constants);
  35803. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  35804. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /**
  35805. * @preserve
  35806. * Authors: Handsoncode
  35807. * Last updated: Nov 15, 2017
  35808. *
  35809. * Description: Definition file for English - United States language-country.
  35810. */
  35811. var dictionary = (_dictionary = {
  35812. languageCode: 'en-US'
  35813. }, _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_ROW_ABOVE, 'Insert row above'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_ROW_BELOW, 'Insert row below'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_INSERT_LEFT, 'Insert column left'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_INSERT_RIGHT, 'Insert column right'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_REMOVE_ROW, ['Remove row', 'Remove rows']), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_REMOVE_COLUMN, ['Remove column', 'Remove columns']), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_UNDO, 'Undo'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_REDO, 'Redo'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_READ_ONLY, 'Read only'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_CLEAR_COLUMN, 'Clear column'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_ALIGNMENT, 'Alignment'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_ALIGNMENT_LEFT, 'Left'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_ALIGNMENT_CENTER, 'Center'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_ALIGNMENT_RIGHT, 'Right'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_ALIGNMENT_JUSTIFY, 'Justify'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_ALIGNMENT_TOP, 'Top'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_ALIGNMENT_MIDDLE, 'Middle'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_ALIGNMENT_BOTTOM, 'Bottom'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_FREEZE_COLUMN, 'Freeze column'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_UNFREEZE_COLUMN, 'Unfreeze column'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_BORDERS, 'Borders'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_BORDERS_TOP, 'Top'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_BORDERS_RIGHT, 'Right'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_BORDERS_BOTTOM, 'Bottom'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_BORDERS_LEFT, 'Left'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_REMOVE_BORDERS, 'Remove border(s)'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_ADD_COMMENT, 'Add comment'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_EDIT_COMMENT, 'Edit comment'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_REMOVE_COMMENT, 'Delete comment'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_READ_ONLY_COMMENT, 'Read-only comment'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_MERGE_CELLS, 'Merge cells'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_UNMERGE_CELLS, 'Unmerge cells'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_COPY, 'Copy'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_CUT, 'Cut'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_NESTED_ROWS_INSERT_CHILD, 'Insert child row'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_NESTED_ROWS_DETACH_CHILD, 'Detach from parent'), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_HIDE_COLUMN, ['Hide column', 'Hide columns']), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_SHOW_COLUMN, ['Show column', 'Show columns']), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_HIDE_ROW, ['Hide row', 'Hide rows']), _defineProperty(_dictionary, C.CONTEXTMENU_ITEMS_SHOW_ROW, ['Show row', 'Show rows']), _defineProperty(_dictionary, C.FILTERS_CONDITIONS_NONE, 'None'), _defineProperty(_dictionary, C.FILTERS_CONDITIONS_EMPTY, 'Is empty'), _defineProperty(_dictionary, C.FILTERS_CONDITIONS_NOT_EMPTY, 'Is not empty'), _defineProperty(_dictionary, C.FILTERS_CONDITIONS_EQUAL, 'Is equal to'), _defineProperty(_dictionary, C.FILTERS_CONDITIONS_NOT_EQUAL, 'Is not equal to'), _defineProperty(_dictionary, C.FILTERS_CONDITIONS_BEGINS_WITH, 'Begins with'), _defineProperty(_dictionary, C.FILTERS_CONDITIONS_ENDS_WITH, 'Ends with'), _defineProperty(_dictionary, C.FILTERS_CONDITIONS_CONTAINS, 'Contains'), _defineProperty(_dictionary, C.FILTERS_CONDITIONS_NOT_CONTAIN, 'Does not contain'), _defineProperty(_dictionary, C.FILTERS_CONDITIONS_GREATER_THAN, 'Greater than'), _defineProperty(_dictionary, C.FILTERS_CONDITIONS_GREATER_THAN_OR_EQUAL, 'Greater than or equal to'), _defineProperty(_dictionary, C.FILTERS_CONDITIONS_LESS_THAN, 'Less than'), _defineProperty(_dictionary, C.FILTERS_CONDITIONS_LESS_THAN_OR_EQUAL, 'Less than or equal to'), _defineProperty(_dictionary, C.FILTERS_CONDITIONS_BETWEEN, 'Is between'), _defineProperty(_dictionary, C.FILTERS_CONDITIONS_NOT_BETWEEN, 'Is not between'), _defineProperty(_dictionary, C.FILTERS_CONDITIONS_AFTER, 'After'), _defineProperty(_dictionary, C.FILTERS_CONDITIONS_BEFORE, 'Before'), _defineProperty(_dictionary, C.FILTERS_CONDITIONS_TODAY, 'Today'), _defineProperty(_dictionary, C.FILTERS_CONDITIONS_TOMORROW, 'Tomorrow'), _defineProperty(_dictionary, C.FILTERS_CONDITIONS_YESTERDAY, 'Yesterday'), _defineProperty(_dictionary, C.FILTERS_VALUES_BLANK_CELLS, 'Blank cells'), _defineProperty(_dictionary, C.FILTERS_DIVS_FILTER_BY_CONDITION, 'Filter by condition'), _defineProperty(_dictionary, C.FILTERS_DIVS_FILTER_BY_VALUE, 'Filter by value'), _defineProperty(_dictionary, C.FILTERS_LABELS_CONJUNCTION, 'And'), _defineProperty(_dictionary, C.FILTERS_LABELS_DISJUNCTION, 'Or'), _defineProperty(_dictionary, C.FILTERS_BUTTONS_SELECT_ALL, 'Select all'), _defineProperty(_dictionary, C.FILTERS_BUTTONS_CLEAR, 'Clear'), _defineProperty(_dictionary, C.FILTERS_BUTTONS_OK, 'OK'), _defineProperty(_dictionary, C.FILTERS_BUTTONS_CANCEL, 'Cancel'), _defineProperty(_dictionary, C.FILTERS_BUTTONS_PLACEHOLDER_SEARCH, 'Search'), _defineProperty(_dictionary, C.FILTERS_BUTTONS_PLACEHOLDER_VALUE, 'Value'), _defineProperty(_dictionary, C.FILTERS_BUTTONS_PLACEHOLDER_SECOND_VALUE, 'Second value'), _dictionary);
  35814. exports.default = dictionary;
  35815. /***/ }),
  35816. /* 392 */
  35817. /***/ (function(module, exports, __webpack_require__) {
  35818. "use strict";
  35819. exports.__esModule = true;
  35820. exports.getPhraseFormatters = exports.registerPhraseFormatter = undefined;
  35821. exports.register = register;
  35822. exports.getAll = getAll;
  35823. var _staticRegister2 = __webpack_require__(39);
  35824. var _staticRegister3 = _interopRequireDefault(_staticRegister2);
  35825. var _pluralize = __webpack_require__(393);
  35826. var _pluralize2 = _interopRequireDefault(_pluralize);
  35827. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  35828. var _staticRegister = (0, _staticRegister3.default)('phraseFormatters'),
  35829. registerGloballyPhraseFormatter = _staticRegister.register,
  35830. getGlobalPhraseFormatters = _staticRegister.getValues;
  35831. /**
  35832. * Register phrase formatter.
  35833. *
  35834. * @param {String} name Name of formatter.
  35835. * @param {Function} formatterFn Function which will be applied on phrase propositions. It will transform them if it's possible.
  35836. */
  35837. function register(name, formatterFn) {
  35838. registerGloballyPhraseFormatter(name, formatterFn);
  35839. }
  35840. /**
  35841. * Get all registered previously formatters.
  35842. *
  35843. * @returns {Array}
  35844. */
  35845. function getAll() {
  35846. return getGlobalPhraseFormatters();
  35847. }
  35848. exports.registerPhraseFormatter = register;
  35849. exports.getPhraseFormatters = getAll;
  35850. register('pluralize', _pluralize2.default);
  35851. /***/ }),
  35852. /* 393 */
  35853. /***/ (function(module, exports, __webpack_require__) {
  35854. "use strict";
  35855. exports.__esModule = true;
  35856. exports.default = pluralize;
  35857. /**
  35858. * Try to choose plural form from available phrase propositions.
  35859. *
  35860. * @param {Array} phrasePropositions List of phrases propositions.
  35861. * @param {number} pluralForm Number determining which phrase form should be used.
  35862. *
  35863. * @returns {String|Array} One particular phrase if it's possible, list of unchanged phrase propositions otherwise.
  35864. */
  35865. function pluralize(phrasePropositions, pluralForm) {
  35866. var isPluralizable = Array.isArray(phrasePropositions) && Number.isInteger(pluralForm);
  35867. if (isPluralizable) {
  35868. return phrasePropositions[pluralForm];
  35869. }
  35870. return phrasePropositions;
  35871. };
  35872. /***/ }),
  35873. /* 394 */
  35874. /***/ (function(module, exports, __webpack_require__) {
  35875. "use strict";
  35876. exports.__esModule = true;
  35877. exports.Selection = exports.Highlight = exports.handleMouseEvent = undefined;
  35878. var _highlight = __webpack_require__(319);
  35879. var _highlight2 = _interopRequireDefault(_highlight);
  35880. var _selection = __webpack_require__(401);
  35881. var _selection2 = _interopRequireDefault(_selection);
  35882. var _mouseEventHandler = __webpack_require__(312);
  35883. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  35884. exports.handleMouseEvent = _mouseEventHandler.handleMouseEvent;
  35885. exports.Highlight = _highlight2.default;
  35886. exports.Selection = _selection2.default;
  35887. /***/ }),
  35888. /* 395 */
  35889. /***/ (function(module, exports, __webpack_require__) {
  35890. "use strict";
  35891. exports.__esModule = true;
  35892. exports.createHighlight = undefined;
  35893. var _staticRegister2 = __webpack_require__(39);
  35894. var _staticRegister3 = _interopRequireDefault(_staticRegister2);
  35895. var _activeHeader = __webpack_require__(396);
  35896. var _activeHeader2 = _interopRequireDefault(_activeHeader);
  35897. var _area = __webpack_require__(397);
  35898. var _area2 = _interopRequireDefault(_area);
  35899. var _cell = __webpack_require__(398);
  35900. var _cell2 = _interopRequireDefault(_cell);
  35901. var _fill = __webpack_require__(399);
  35902. var _fill2 = _interopRequireDefault(_fill);
  35903. var _header = __webpack_require__(400);
  35904. var _header2 = _interopRequireDefault(_header);
  35905. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  35906. /* eslint-disable import/prefer-default-export */
  35907. var _staticRegister = (0, _staticRegister3.default)('highlight/types'),
  35908. register = _staticRegister.register,
  35909. getItem = _staticRegister.getItem;
  35910. register('active-header', _activeHeader2.default);
  35911. register('area', _area2.default);
  35912. register('cell', _cell2.default);
  35913. register('fill', _fill2.default);
  35914. register('header', _header2.default);
  35915. function createHighlight(highlightType, options) {
  35916. return getItem(highlightType)(options);
  35917. }
  35918. exports.createHighlight = createHighlight;
  35919. /***/ }),
  35920. /* 396 */
  35921. /***/ (function(module, exports, __webpack_require__) {
  35922. "use strict";
  35923. exports.__esModule = true;
  35924. var _src = __webpack_require__(4);
  35925. /**
  35926. * @return {Selection}
  35927. */
  35928. function createHighlight(_ref) {
  35929. var activeHeaderClassName = _ref.activeHeaderClassName;
  35930. var s = new _src.Selection({
  35931. highlightHeaderClassName: activeHeaderClassName
  35932. });
  35933. return s;
  35934. }
  35935. exports.default = createHighlight;
  35936. /***/ }),
  35937. /* 397 */
  35938. /***/ (function(module, exports, __webpack_require__) {
  35939. "use strict";
  35940. exports.__esModule = true;
  35941. var _src = __webpack_require__(4);
  35942. /**
  35943. * Creates the new instance of Selection responsible for highlighting area of the selected multiple cells.
  35944. *
  35945. * @return {Selection}
  35946. */
  35947. function createHighlight(_ref) {
  35948. var layerLevel = _ref.layerLevel,
  35949. areaCornerVisible = _ref.areaCornerVisible;
  35950. var s = new _src.Selection({
  35951. className: 'area',
  35952. markIntersections: true,
  35953. layerLevel: Math.min(layerLevel, 7),
  35954. border: {
  35955. width: 1,
  35956. color: '#4b89ff',
  35957. cornerVisible: areaCornerVisible
  35958. }
  35959. });
  35960. return s;
  35961. }
  35962. exports.default = createHighlight;
  35963. /***/ }),
  35964. /* 398 */
  35965. /***/ (function(module, exports, __webpack_require__) {
  35966. "use strict";
  35967. exports.__esModule = true;
  35968. var _src = __webpack_require__(4);
  35969. /**
  35970. * Creates the new instance of Selection responsible for highlighting currently selected cell. This type of selection
  35971. * can present on the table only one at the time.
  35972. *
  35973. * @return {Selection}
  35974. */
  35975. function createHighlight(_ref) {
  35976. var cellCornerVisible = _ref.cellCornerVisible;
  35977. var s = new _src.Selection({
  35978. className: 'current',
  35979. border: {
  35980. width: 2,
  35981. color: '#4b89ff',
  35982. cornerVisible: cellCornerVisible
  35983. }
  35984. });
  35985. return s;
  35986. }
  35987. exports.default = createHighlight;
  35988. /***/ }),
  35989. /* 399 */
  35990. /***/ (function(module, exports, __webpack_require__) {
  35991. "use strict";
  35992. exports.__esModule = true;
  35993. var _src = __webpack_require__(4);
  35994. /**
  35995. * Creates the new instance of Selection, responsible for highlighting cells which are covered by fill handle
  35996. * functionality. This type of selection can present on the table only one at the time.
  35997. *
  35998. * @return {Selection}
  35999. */
  36000. function createHighlight() {
  36001. var s = new _src.Selection({
  36002. className: 'fill',
  36003. border: {
  36004. width: 1,
  36005. color: '#ff0000'
  36006. }
  36007. });
  36008. return s;
  36009. }
  36010. exports.default = createHighlight;
  36011. /***/ }),
  36012. /* 400 */
  36013. /***/ (function(module, exports, __webpack_require__) {
  36014. "use strict";
  36015. exports.__esModule = true;
  36016. var _src = __webpack_require__(4);
  36017. /**
  36018. * Creates the new instance of Selection, responsible for highlighting row and column headers. This type of selection
  36019. * can occur multiple times.
  36020. *
  36021. * @return {Selection}
  36022. */
  36023. function createHighlight(_ref) {
  36024. var headerClassName = _ref.headerClassName,
  36025. rowClassName = _ref.rowClassName,
  36026. columnClassName = _ref.columnClassName;
  36027. var s = new _src.Selection({
  36028. className: 'highlight',
  36029. highlightHeaderClassName: headerClassName,
  36030. highlightRowClassName: rowClassName,
  36031. highlightColumnClassName: columnClassName
  36032. });
  36033. return s;
  36034. }
  36035. exports.default = createHighlight;
  36036. /***/ }),
  36037. /* 401 */
  36038. /***/ (function(module, exports, __webpack_require__) {
  36039. "use strict";
  36040. exports.__esModule = true;
  36041. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  36042. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  36043. var _templateObject = _taggedTemplateLiteral(['Unsupported format of the selection ranges was passed. To select cells pass \n the coordinates as an array of arrays ([[rowStart, columnStart/columnPropStart, rowEnd, columnEnd/columnPropEnd]]) \n or as an array of CellRange objects.'], ['Unsupported format of the selection ranges was passed. To select cells pass\\x20\n the coordinates as an array of arrays ([[rowStart, columnStart/columnPropStart, rowEnd, columnEnd/columnPropEnd]])\\x20\n or as an array of CellRange objects.']);
  36044. var _highlight = __webpack_require__(319);
  36045. var _highlight2 = _interopRequireDefault(_highlight);
  36046. var _range = __webpack_require__(402);
  36047. var _range2 = _interopRequireDefault(_range);
  36048. var _src = __webpack_require__(4);
  36049. var _keyStateObserver = __webpack_require__(318);
  36050. var _object = __webpack_require__(2);
  36051. var _mixed = __webpack_require__(16);
  36052. var _array = __webpack_require__(1);
  36053. var _localHooks = __webpack_require__(58);
  36054. var _localHooks2 = _interopRequireDefault(_localHooks);
  36055. var _transformation = __webpack_require__(403);
  36056. var _transformation2 = _interopRequireDefault(_transformation);
  36057. var _utils = __webpack_require__(91);
  36058. var _templateLiteralTag = __webpack_require__(42);
  36059. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  36060. function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
  36061. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  36062. /**
  36063. * @class Selection
  36064. * @util
  36065. */
  36066. var Selection = function () {
  36067. function Selection(settings, tableProps) {
  36068. var _this = this;
  36069. _classCallCheck(this, Selection);
  36070. /**
  36071. * Handsontable settings instance.
  36072. *
  36073. * @type {GridSettings}
  36074. */
  36075. this.settings = settings;
  36076. /**
  36077. * An additional object with dynamically defined properties which describes table state.
  36078. *
  36079. * @type {Object}
  36080. */
  36081. this.tableProps = tableProps;
  36082. /**
  36083. * The flag which determines if the selection is in progress.
  36084. *
  36085. * @type {Boolean}
  36086. */
  36087. this.inProgress = false;
  36088. /**
  36089. * The flag indicates that selection was performed by clicking the corner overlay.
  36090. *
  36091. * @type {Boolean}
  36092. */
  36093. this.selectedByCorner = false;
  36094. /**
  36095. * The collection of the selection layer levels where the whole row was selected using the row header.
  36096. *
  36097. * @type {Set.<Number>}
  36098. */
  36099. this.selectedByRowHeader = new Set();
  36100. /**
  36101. * The collection of the selection layer levels where the whole column was selected using the column header.
  36102. *
  36103. * @type {Set.<Number>}
  36104. */
  36105. this.selectedByColumnHeader = new Set();
  36106. /**
  36107. * Selection data layer.
  36108. *
  36109. * @type {SelectionRange}
  36110. */
  36111. this.selectedRange = new _range2.default();
  36112. /**
  36113. * Visualization layer.
  36114. *
  36115. * @type {Highlight}
  36116. */
  36117. this.highlight = new _highlight2.default({
  36118. headerClassName: settings.currentHeaderClassName,
  36119. activeHeaderClassName: settings.activeHeaderClassName,
  36120. rowClassName: settings.currentRowClassName,
  36121. columnClassName: settings.currentColClassName,
  36122. disableHighlight: this.settings.disableVisualSelection,
  36123. cellCornerVisible: function cellCornerVisible() {
  36124. return _this.isCellCornerVisible.apply(_this, arguments);
  36125. },
  36126. areaCornerVisible: function areaCornerVisible() {
  36127. return _this.isAreaCornerVisible.apply(_this, arguments);
  36128. }
  36129. });
  36130. /**
  36131. * The module for modifying coordinates.
  36132. *
  36133. * @type {Transformation}
  36134. */
  36135. this.transformation = new _transformation2.default(this.selectedRange, {
  36136. countRows: function countRows() {
  36137. return _this.tableProps.countRows();
  36138. },
  36139. countCols: function countCols() {
  36140. return _this.tableProps.countCols();
  36141. },
  36142. fixedRowsBottom: function fixedRowsBottom() {
  36143. return settings.fixedRowsBottom;
  36144. },
  36145. minSpareRows: function minSpareRows() {
  36146. return settings.minSpareRows;
  36147. },
  36148. minSpareCols: function minSpareCols() {
  36149. return settings.minSpareCols;
  36150. },
  36151. autoWrapRow: function autoWrapRow() {
  36152. return settings.autoWrapRow;
  36153. },
  36154. autoWrapCol: function autoWrapCol() {
  36155. return settings.autoWrapCol;
  36156. }
  36157. });
  36158. this.transformation.addLocalHook('beforeTransformStart', function () {
  36159. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  36160. args[_key] = arguments[_key];
  36161. }
  36162. return _this.runLocalHooks.apply(_this, ['beforeModifyTransformStart'].concat(args));
  36163. });
  36164. this.transformation.addLocalHook('afterTransformStart', function () {
  36165. for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  36166. args[_key2] = arguments[_key2];
  36167. }
  36168. return _this.runLocalHooks.apply(_this, ['afterModifyTransformStart'].concat(args));
  36169. });
  36170. this.transformation.addLocalHook('beforeTransformEnd', function () {
  36171. for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  36172. args[_key3] = arguments[_key3];
  36173. }
  36174. return _this.runLocalHooks.apply(_this, ['beforeModifyTransformEnd'].concat(args));
  36175. });
  36176. this.transformation.addLocalHook('afterTransformEnd', function () {
  36177. for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
  36178. args[_key4] = arguments[_key4];
  36179. }
  36180. return _this.runLocalHooks.apply(_this, ['afterModifyTransformEnd'].concat(args));
  36181. });
  36182. this.transformation.addLocalHook('insertRowRequire', function () {
  36183. for (var _len5 = arguments.length, args = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
  36184. args[_key5] = arguments[_key5];
  36185. }
  36186. return _this.runLocalHooks.apply(_this, ['insertRowRequire'].concat(args));
  36187. });
  36188. this.transformation.addLocalHook('insertColRequire', function () {
  36189. for (var _len6 = arguments.length, args = Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
  36190. args[_key6] = arguments[_key6];
  36191. }
  36192. return _this.runLocalHooks.apply(_this, ['insertColRequire'].concat(args));
  36193. });
  36194. }
  36195. /**
  36196. * Get data layer for current selection.
  36197. *
  36198. * @return {SelectionRange}
  36199. */
  36200. _createClass(Selection, [{
  36201. key: 'getSelectedRange',
  36202. value: function getSelectedRange() {
  36203. return this.selectedRange;
  36204. }
  36205. /**
  36206. * Indicate that selection process began. It sets internaly `.inProgress` property to `true`.
  36207. */
  36208. }, {
  36209. key: 'begin',
  36210. value: function begin() {
  36211. this.inProgress = true;
  36212. }
  36213. /**
  36214. * Indicate that selection process finished. It sets internaly `.inProgress` property to `false`.
  36215. */
  36216. }, {
  36217. key: 'finish',
  36218. value: function finish() {
  36219. this.runLocalHooks('afterSelectionFinished', Array.from(this.selectedRange));
  36220. this.inProgress = false;
  36221. }
  36222. /**
  36223. * Check if the process of selecting the cell/cells is in progress.
  36224. *
  36225. * @returns {Boolean}
  36226. */
  36227. }, {
  36228. key: 'isInProgress',
  36229. value: function isInProgress() {
  36230. return this.inProgress;
  36231. }
  36232. /**
  36233. * Starts selection range on given coordinate object.
  36234. *
  36235. * @param {CellCoords} coords Visual coords.
  36236. * @param {Boolean} [multipleSelection] If `true`, selection will be worked in 'multiple' mode. This option works
  36237. * only when 'selectionMode' is set as 'multiple'. If the argument is not defined
  36238. * the default trigger will be used (isPressedCtrlKey() helper).
  36239. * @param {Boolean} [fragment=false] If `true`, the selection will be treated as a partial selection where the
  36240. * `setRangeEnd` method won't be called on every `setRangeStart` call.
  36241. */
  36242. }, {
  36243. key: 'setRangeStart',
  36244. value: function setRangeStart(coords, multipleSelection) {
  36245. var fragment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  36246. var isMultipleMode = this.settings.selectionMode === 'multiple';
  36247. var isMultipleSelection = (0, _mixed.isUndefined)(multipleSelection) ? (0, _keyStateObserver.isPressedCtrlKey)() : multipleSelection;
  36248. var isRowNegative = coords.row < 0;
  36249. var isColumnNegative = coords.col < 0;
  36250. var selectedByCorner = isRowNegative && isColumnNegative;
  36251. if (isRowNegative) {
  36252. coords.row = 0;
  36253. }
  36254. if (isColumnNegative) {
  36255. coords.col = 0;
  36256. }
  36257. this.selectedByCorner = selectedByCorner;
  36258. this.runLocalHooks('beforeSetRangeStart' + (fragment ? 'Only' : ''), coords);
  36259. if (!isMultipleMode || isMultipleMode && !isMultipleSelection && (0, _mixed.isUndefined)(multipleSelection)) {
  36260. this.selectedRange.clear();
  36261. }
  36262. this.selectedRange.add(coords);
  36263. if (this.getLayerLevel() === 0) {
  36264. this.selectedByRowHeader.clear();
  36265. this.selectedByColumnHeader.clear();
  36266. }
  36267. if (!selectedByCorner && isColumnNegative) {
  36268. this.selectedByRowHeader.add(this.getLayerLevel());
  36269. }
  36270. if (!selectedByCorner && isRowNegative) {
  36271. this.selectedByColumnHeader.add(this.getLayerLevel());
  36272. }
  36273. if (!fragment) {
  36274. this.setRangeEnd(coords);
  36275. }
  36276. }
  36277. /**
  36278. * Starts selection range on given coordinate object.
  36279. *
  36280. * @param {CellCoords} coords Visual coords.
  36281. * @param {Boolean} [multipleSelection] If `true`, selection will be worked in 'multiple' mode. This option works
  36282. * only when 'selectionMode' is set as 'multiple'. If the argument is not defined
  36283. * the default trigger will be used (isPressedCtrlKey() helper).
  36284. */
  36285. }, {
  36286. key: 'setRangeStartOnly',
  36287. value: function setRangeStartOnly(coords, multipleSelection) {
  36288. this.setRangeStart(coords, multipleSelection, true);
  36289. }
  36290. /**
  36291. * Ends selection range on given coordinate object.
  36292. *
  36293. * @param {CellCoords} coords Visual coords.
  36294. */
  36295. }, {
  36296. key: 'setRangeEnd',
  36297. value: function setRangeEnd(coords) {
  36298. if (this.selectedRange.isEmpty()) {
  36299. return;
  36300. }
  36301. this.runLocalHooks('beforeSetRangeEnd', coords);
  36302. this.begin();
  36303. var cellRange = this.selectedRange.current();
  36304. if (this.settings.selectionMode !== 'single') {
  36305. cellRange.setTo(new _src.CellCoords(coords.row, coords.col));
  36306. }
  36307. // Set up current selection.
  36308. this.highlight.getCell().clear();
  36309. if (this.highlight.isEnabledFor(_highlight.CELL_TYPE)) {
  36310. this.highlight.getCell().add(this.selectedRange.current().highlight);
  36311. }
  36312. var layerLevel = this.getLayerLevel();
  36313. // If the next layer level is lower than previous then clear all area and header highlights. This is the
  36314. // indication that the new selection is performing.
  36315. if (layerLevel < this.highlight.layerLevel) {
  36316. (0, _array.arrayEach)(this.highlight.getAreas(), function (highlight) {
  36317. return void highlight.clear();
  36318. });
  36319. (0, _array.arrayEach)(this.highlight.getHeaders(), function (highlight) {
  36320. return void highlight.clear();
  36321. });
  36322. (0, _array.arrayEach)(this.highlight.getActiveHeaders(), function (highlight) {
  36323. return void highlight.clear();
  36324. });
  36325. }
  36326. this.highlight.useLayerLevel(layerLevel);
  36327. var areaHighlight = this.highlight.createOrGetArea();
  36328. var headerHighlight = this.highlight.createOrGetHeader();
  36329. var activeHeaderHighlight = this.highlight.createOrGetActiveHeader();
  36330. areaHighlight.clear();
  36331. headerHighlight.clear();
  36332. activeHeaderHighlight.clear();
  36333. if (this.highlight.isEnabledFor(_highlight.AREA_TYPE) && (this.isMultiple() || layerLevel >= 1)) {
  36334. areaHighlight.add(cellRange.from).add(cellRange.to);
  36335. if (layerLevel === 1) {
  36336. // For single cell selection in the same layer, we do not create area selection to prevent blue background.
  36337. // When non-consecutive selection is performed we have to add that missing area selection to the previous layer
  36338. // based on previous coordinates. It only occurs when the previous selection wasn't select multiple cells.
  36339. this.highlight.useLayerLevel(layerLevel - 1).createOrGetArea().add(this.selectedRange.previous().from);
  36340. this.highlight.useLayerLevel(layerLevel);
  36341. }
  36342. }
  36343. if (this.highlight.isEnabledFor(_highlight.HEADER_TYPE)) {
  36344. if (this.settings.selectionMode === 'single') {
  36345. headerHighlight.add(cellRange.highlight);
  36346. } else {
  36347. headerHighlight.add(cellRange.from).add(cellRange.to);
  36348. }
  36349. }
  36350. if (this.isSelectedByRowHeader()) {
  36351. var isRowSelected = this.tableProps.countCols() === cellRange.getWidth();
  36352. // Make sure that the whole row is selected (in case where selectionMode is set to 'single')
  36353. if (isRowSelected) {
  36354. activeHeaderHighlight.add(new _src.CellCoords(cellRange.from.row, -1)).add(new _src.CellCoords(cellRange.to.row, -1));
  36355. }
  36356. }
  36357. if (this.isSelectedByColumnHeader()) {
  36358. var isColumnSelected = this.tableProps.countRows() === cellRange.getHeight();
  36359. // Make sure that the whole column is selected (in case where selectionMode is set to 'single')
  36360. if (isColumnSelected) {
  36361. activeHeaderHighlight.add(new _src.CellCoords(-1, cellRange.from.col)).add(new _src.CellCoords(-1, cellRange.to.col));
  36362. }
  36363. }
  36364. this.runLocalHooks('afterSetRangeEnd', coords);
  36365. }
  36366. /**
  36367. * Returns information if we have a multiselection. This method check multiselection only on the latest layer of
  36368. * the selection.
  36369. *
  36370. * @returns {Boolean}
  36371. */
  36372. }, {
  36373. key: 'isMultiple',
  36374. value: function isMultiple() {
  36375. var isMultipleListener = (0, _object.createObjectPropListener)(!this.selectedRange.current().isSingle());
  36376. this.runLocalHooks('afterIsMultipleSelection', isMultipleListener);
  36377. return isMultipleListener.value;
  36378. }
  36379. /**
  36380. * Selects cell relative to the current cell (if possible).
  36381. *
  36382. * @param {Number} rowDelta Rows number to move, value can be passed as negative number.
  36383. * @param {Number} colDelta Columns number to move, value can be passed as negative number.
  36384. * @param {Boolean} force If `true` the new rows/columns will be created if necessary. Otherwise, row/column will
  36385. * be created according to `minSpareRows/minSpareCols` settings of Handsontable.
  36386. */
  36387. }, {
  36388. key: 'transformStart',
  36389. value: function transformStart(rowDelta, colDelta, force) {
  36390. this.setRangeStart(this.transformation.transformStart(rowDelta, colDelta, force));
  36391. }
  36392. /**
  36393. * Sets selection end cell relative to the current selection end cell (if possible).
  36394. *
  36395. * @param {Number} rowDelta Rows number to move, value can be passed as negative number.
  36396. * @param {Number} colDelta Columns number to move, value can be passed as negative number.
  36397. */
  36398. }, {
  36399. key: 'transformEnd',
  36400. value: function transformEnd(rowDelta, colDelta) {
  36401. this.setRangeEnd(this.transformation.transformEnd(rowDelta, colDelta));
  36402. }
  36403. /**
  36404. * Returns currently used layer level.
  36405. *
  36406. * @return {Number} Returns layer level starting from 0. If no selection was added to the table -1 is returned.
  36407. */
  36408. }, {
  36409. key: 'getLayerLevel',
  36410. value: function getLayerLevel() {
  36411. return this.selectedRange.size() - 1;
  36412. }
  36413. /**
  36414. * Returns `true` if currently there is a selection on the screen, `false` otherwise.
  36415. *
  36416. * @returns {Boolean}
  36417. */
  36418. }, {
  36419. key: 'isSelected',
  36420. value: function isSelected() {
  36421. return !this.selectedRange.isEmpty();
  36422. }
  36423. /**
  36424. * Returns `true` if the selection was applied by clicking to the row header. If the `layerLevel`
  36425. * argument is passed then only that layer will be checked. Otherwise, it checks if any row header
  36426. * was clicked on any selection layer level.
  36427. *
  36428. * @param {Number} [layerLevel=this.getLayerLevel()] Selection layer level to check.
  36429. * @return {Boolean}
  36430. */
  36431. }, {
  36432. key: 'isSelectedByRowHeader',
  36433. value: function isSelectedByRowHeader() {
  36434. var layerLevel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getLayerLevel();
  36435. return layerLevel === -1 ? this.selectedByRowHeader.size > 0 : this.selectedByRowHeader.has(layerLevel);
  36436. }
  36437. /**
  36438. * Returns `true` if the selection was applied by clicking to the column header. If the `layerLevel`
  36439. * argument is passed then only that layer will be checked. Otherwise, it checks if any column header
  36440. * was clicked on any selection layer level.
  36441. *
  36442. * @param {Number} [layerLevel=this.getLayerLevel()] Selection layer level to check.
  36443. * @return {Boolean}
  36444. */
  36445. }, {
  36446. key: 'isSelectedByColumnHeader',
  36447. value: function isSelectedByColumnHeader() {
  36448. var layerLevel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getLayerLevel();
  36449. return layerLevel === -1 ? this.selectedByColumnHeader.size > 0 : this.selectedByColumnHeader.has(layerLevel);
  36450. }
  36451. /**
  36452. * Returns `true` if the selection was applied by clicking on the row or column header on any layer level.
  36453. *
  36454. * @return {Boolean}
  36455. */
  36456. }, {
  36457. key: 'isSelectedByAnyHeader',
  36458. value: function isSelectedByAnyHeader() {
  36459. return this.isSelectedByRowHeader(-1) || this.isSelectedByColumnHeader(-1);
  36460. }
  36461. /**
  36462. * Returns `true` if the selection was applied by clicking on the left-top corner overlay.
  36463. *
  36464. * @return {Boolean}
  36465. */
  36466. }, {
  36467. key: 'isSelectedByCorner',
  36468. value: function isSelectedByCorner() {
  36469. return this.selectedByCorner;
  36470. }
  36471. /**
  36472. * Returns `true` if coords is within selection coords. This method iterates through all selection layers to check if
  36473. * the coords object is within selection range.
  36474. *
  36475. * @param {CellCoords} coords The CellCoords instance with defined visual coordinates.
  36476. * @returns {Boolean}
  36477. */
  36478. }, {
  36479. key: 'inInSelection',
  36480. value: function inInSelection(coords) {
  36481. return this.selectedRange.includes(coords);
  36482. }
  36483. /**
  36484. * Returns `true` if the cell corner should be visible.
  36485. *
  36486. * @private
  36487. * @return {Boolean} `true` if the corner element has to be visible, `false` otherwise.
  36488. */
  36489. }, {
  36490. key: 'isCellCornerVisible',
  36491. value: function isCellCornerVisible() {
  36492. return this.settings.fillHandle && !this.tableProps.isEditorOpened() && !this.isMultiple();
  36493. }
  36494. /**
  36495. * Returns `true` if the area corner should be visible.
  36496. *
  36497. * @param {Number} layerLevel The layer level.
  36498. * @return {Boolean} `true` if the corner element has to be visible, `false` otherwise.
  36499. */
  36500. }, {
  36501. key: 'isAreaCornerVisible',
  36502. value: function isAreaCornerVisible(layerLevel) {
  36503. if (Number.isInteger(layerLevel) && layerLevel !== this.getLayerLevel()) {
  36504. return false;
  36505. }
  36506. return this.settings.fillHandle && !this.tableProps.isEditorOpened() && this.isMultiple();
  36507. }
  36508. /**
  36509. * Clear the selection by resetting the collected ranges and highlights.
  36510. */
  36511. }, {
  36512. key: 'clear',
  36513. value: function clear() {
  36514. this.selectedRange.clear();
  36515. this.highlight.clear();
  36516. }
  36517. /**
  36518. * Deselects all selected cells.
  36519. */
  36520. }, {
  36521. key: 'deselect',
  36522. value: function deselect() {
  36523. if (!this.isSelected()) {
  36524. return;
  36525. }
  36526. this.inProgress = false;
  36527. this.clear();
  36528. this.runLocalHooks('afterDeselect');
  36529. }
  36530. /**
  36531. * Select all cells.
  36532. */
  36533. }, {
  36534. key: 'selectAll',
  36535. value: function selectAll() {
  36536. this.clear();
  36537. this.setRangeStart(new _src.CellCoords(-1, -1));
  36538. this.selectedByRowHeader.add(this.getLayerLevel());
  36539. this.selectedByColumnHeader.add(this.getLayerLevel());
  36540. this.setRangeEnd(new _src.CellCoords(this.tableProps.countRows() - 1, this.tableProps.countCols() - 1));
  36541. }
  36542. /**
  36543. * Make multiple, non-contiguous selection specified by `row` and `column` values or a range of cells
  36544. * finishing at `endRow`, `endColumn`. The method supports two input formats, first as an array of arrays such
  36545. * as `[[rowStart, columnStart, rowEnd, columnEnd]]` and second format as an array of CellRange objects.
  36546. * If the passed ranges have another format the exception will be thrown.
  36547. *
  36548. * @param {Array[]|CellRange[]} selectionRanges The coordinates which define what the cells should be selected.
  36549. * @return {Boolean} Returns `true` if selection was successful, `false` otherwise.
  36550. */
  36551. }, {
  36552. key: 'selectCells',
  36553. value: function selectCells(selectionRanges) {
  36554. var _this2 = this;
  36555. var selectionType = (0, _utils.detectSelectionType)(selectionRanges);
  36556. if (selectionType === _utils.SELECTION_TYPE_EMPTY) {
  36557. return false;
  36558. } else if (selectionType === _utils.SELECTION_TYPE_UNRECOGNIZED) {
  36559. throw new Error((0, _templateLiteralTag.toSingleLine)(_templateObject));
  36560. }
  36561. var selectionSchemaNormalizer = (0, _utils.normalizeSelectionFactory)(selectionType, {
  36562. propToCol: function propToCol(prop) {
  36563. return _this2.tableProps.propToCol(prop);
  36564. },
  36565. keepDirection: true
  36566. });
  36567. var countRows = this.tableProps.countRows();
  36568. var countCols = this.tableProps.countCols();
  36569. // Check if every layer of the coordinates are valid.
  36570. var isValid = !selectionRanges.some(function (selection) {
  36571. var _selectionSchemaNorma = selectionSchemaNormalizer(selection),
  36572. _selectionSchemaNorma2 = _slicedToArray(_selectionSchemaNorma, 4),
  36573. rowStart = _selectionSchemaNorma2[0],
  36574. columnStart = _selectionSchemaNorma2[1],
  36575. rowEnd = _selectionSchemaNorma2[2],
  36576. columnEnd = _selectionSchemaNorma2[3];
  36577. var _isValid = (0, _utils.isValidCoord)(rowStart, countRows) && (0, _utils.isValidCoord)(columnStart, countCols) && (0, _utils.isValidCoord)(rowEnd, countRows) && (0, _utils.isValidCoord)(columnEnd, countCols);
  36578. return !_isValid;
  36579. });
  36580. if (isValid) {
  36581. this.clear();
  36582. (0, _array.arrayEach)(selectionRanges, function (selection) {
  36583. var _selectionSchemaNorma3 = selectionSchemaNormalizer(selection),
  36584. _selectionSchemaNorma4 = _slicedToArray(_selectionSchemaNorma3, 4),
  36585. rowStart = _selectionSchemaNorma4[0],
  36586. columnStart = _selectionSchemaNorma4[1],
  36587. rowEnd = _selectionSchemaNorma4[2],
  36588. columnEnd = _selectionSchemaNorma4[3];
  36589. _this2.setRangeStartOnly(new _src.CellCoords(rowStart, columnStart), false);
  36590. _this2.setRangeEnd(new _src.CellCoords(rowEnd, columnEnd));
  36591. _this2.finish();
  36592. });
  36593. }
  36594. return isValid;
  36595. }
  36596. /**
  36597. * Select column specified by `startColumn` visual index or column property or a range of columns finishing at `endColumn`.
  36598. *
  36599. * @param {Number|String} startColumn Visual column index or column property from which the selection starts.
  36600. * @param {Number|String} [endColumn] Visual column index or column property from to the selection finishes.
  36601. * @returns {Boolean} Returns `true` if selection was successful, `false` otherwise.
  36602. */
  36603. }, {
  36604. key: 'selectColumns',
  36605. value: function selectColumns(startColumn) {
  36606. var endColumn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startColumn;
  36607. startColumn = typeof startColumn === 'string' ? this.tableProps.propToCol(startColumn) : startColumn;
  36608. endColumn = typeof endColumn === 'string' ? this.tableProps.propToCol(endColumn) : endColumn;
  36609. var countCols = this.tableProps.countCols();
  36610. var isValid = (0, _utils.isValidCoord)(startColumn, countCols) && (0, _utils.isValidCoord)(endColumn, countCols);
  36611. if (isValid) {
  36612. this.setRangeStartOnly(new _src.CellCoords(-1, startColumn));
  36613. this.setRangeEnd(new _src.CellCoords(this.tableProps.countRows() - 1, endColumn));
  36614. this.finish();
  36615. }
  36616. return isValid;
  36617. }
  36618. /**
  36619. * Select row specified by `startRow` visual index or a range of rows finishing at `endRow`.
  36620. *
  36621. * @param {Number} startRow Visual row index from which the selection starts.
  36622. * @param {Number} [endRow] Visual row index from to the selection finishes.
  36623. * @returns {Boolean} Returns `true` if selection was successful, `false` otherwise.
  36624. */
  36625. }, {
  36626. key: 'selectRows',
  36627. value: function selectRows(startRow) {
  36628. var endRow = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startRow;
  36629. var countRows = this.tableProps.countRows();
  36630. var isValid = (0, _utils.isValidCoord)(startRow, countRows) && (0, _utils.isValidCoord)(endRow, countRows);
  36631. if (isValid) {
  36632. this.setRangeStartOnly(new _src.CellCoords(startRow, -1));
  36633. this.setRangeEnd(new _src.CellCoords(endRow, this.tableProps.countCols() - 1));
  36634. this.finish();
  36635. }
  36636. return isValid;
  36637. }
  36638. }]);
  36639. return Selection;
  36640. }();
  36641. (0, _object.mixin)(Selection, _localHooks2.default);
  36642. exports.default = Selection;
  36643. /***/ }),
  36644. /* 402 */
  36645. /***/ (function(module, exports, __webpack_require__) {
  36646. "use strict";
  36647. exports.__esModule = true;
  36648. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  36649. var _src = __webpack_require__(4);
  36650. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  36651. /**
  36652. * The SelectionRange class is a simple CellRanges collection designed for easy manipulation of the multiple
  36653. * consecutive and non-consecutive selections.
  36654. *
  36655. * @class SelectionRange
  36656. * @util
  36657. */
  36658. var SelectionRange = function () {
  36659. function SelectionRange() {
  36660. _classCallCheck(this, SelectionRange);
  36661. /**
  36662. * List of all CellRanges added to the class instance.
  36663. *
  36664. * @type {CellRange[]}
  36665. */
  36666. this.ranges = [];
  36667. }
  36668. /**
  36669. * Check if selected range is empty.
  36670. *
  36671. * @return {Boolean}
  36672. */
  36673. _createClass(SelectionRange, [{
  36674. key: 'isEmpty',
  36675. value: function isEmpty() {
  36676. return this.size() === 0;
  36677. }
  36678. /**
  36679. * Set coordinates to the class instance. It clears all previously added coordinates and push `coords`
  36680. * to the collection.
  36681. *
  36682. * @param {CellCoords} coords The CellCoords instance with defined visual coordinates.
  36683. * @returns {SelectionRange}
  36684. */
  36685. }, {
  36686. key: 'set',
  36687. value: function set(coords) {
  36688. this.clear();
  36689. this.ranges.push(new _src.CellRange(coords));
  36690. return this;
  36691. }
  36692. /**
  36693. * Add coordinates to the class instance. The new coordinates are added to the end of the range collection.
  36694. *
  36695. * @param {CellCoords} coords The CellCoords instance with defined visual coordinates.
  36696. * @returns {SelectionRange}
  36697. */
  36698. }, {
  36699. key: 'add',
  36700. value: function add(coords) {
  36701. this.ranges.push(new _src.CellRange(coords));
  36702. return this;
  36703. }
  36704. /**
  36705. * Get last added coordinates from ranges, it returns a CellRange instance.
  36706. *
  36707. * @return {CellRange|undefined}
  36708. */
  36709. }, {
  36710. key: 'current',
  36711. value: function current() {
  36712. return this.peekByIndex(0);
  36713. }
  36714. /**
  36715. * Get previously added coordinates from ranges, it returns a CellRange instance.
  36716. *
  36717. * @return {CellRange|undefined}
  36718. */
  36719. }, {
  36720. key: 'previous',
  36721. value: function previous() {
  36722. return this.peekByIndex(-1);
  36723. }
  36724. /**
  36725. * Returns `true` if coords is within selection coords. This method iterates through all selection layers to check if
  36726. * the coords object is within selection range.
  36727. *
  36728. * @param {CellCoords} coords The CellCoords instance with defined visual coordinates.
  36729. * @returns {Boolean}
  36730. */
  36731. }, {
  36732. key: 'includes',
  36733. value: function includes(coords) {
  36734. return this.ranges.some(function (cellRange) {
  36735. return cellRange.includes(coords);
  36736. });
  36737. }
  36738. /**
  36739. * Clear collection.
  36740. *
  36741. * @return {SelectionRange}
  36742. */
  36743. }, {
  36744. key: 'clear',
  36745. value: function clear() {
  36746. this.ranges.length = 0;
  36747. return this;
  36748. }
  36749. /**
  36750. * Get count of added all coordinates added to the selection.
  36751. *
  36752. * @return {Number}
  36753. */
  36754. }, {
  36755. key: 'size',
  36756. value: function size() {
  36757. return this.ranges.length;
  36758. }
  36759. /**
  36760. * Peek the coordinates based on the offset where that coordinate resides in the collection.
  36761. *
  36762. * @param {Number} [offset=0] An offset where the coordinate will be retrieved from.
  36763. * @return {CellRange|undefined}
  36764. */
  36765. }, {
  36766. key: 'peekByIndex',
  36767. value: function peekByIndex() {
  36768. var offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  36769. var rangeIndex = this.size() + offset - 1;
  36770. var cellRange = void 0;
  36771. if (rangeIndex >= 0) {
  36772. cellRange = this.ranges[rangeIndex];
  36773. }
  36774. return cellRange;
  36775. }
  36776. }, {
  36777. key: Symbol.iterator,
  36778. value: function value() {
  36779. return this.ranges[Symbol.iterator]();
  36780. }
  36781. }]);
  36782. return SelectionRange;
  36783. }();
  36784. exports.default = SelectionRange;
  36785. /***/ }),
  36786. /* 403 */
  36787. /***/ (function(module, exports, __webpack_require__) {
  36788. "use strict";
  36789. exports.__esModule = true;
  36790. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  36791. var _src = __webpack_require__(4);
  36792. var _object = __webpack_require__(2);
  36793. var _localHooks = __webpack_require__(58);
  36794. var _localHooks2 = _interopRequireDefault(_localHooks);
  36795. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  36796. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  36797. /**
  36798. * The Transformation class implements algorithms for transforming coordinates based on current settings
  36799. * passed to the Handsontable.
  36800. *
  36801. * Transformation is always applied relative to the current selection.
  36802. *
  36803. * @class Transformation
  36804. * @util
  36805. */
  36806. var Transformation = function () {
  36807. function Transformation(range, options) {
  36808. _classCallCheck(this, Transformation);
  36809. /**
  36810. * Instance of the SelectionRange, holder for coordinates applied to the table.
  36811. *
  36812. * @type {SelectionRange}
  36813. */
  36814. this.range = range;
  36815. /**
  36816. * Additional options which define the state of the settings which can infer transformation.
  36817. *
  36818. * @type {Object}
  36819. */
  36820. this.options = options;
  36821. }
  36822. /**
  36823. * Selects cell relative to current cell (if possible).
  36824. *
  36825. * @param {Number} rowDelta Rows number to move, value can be passed as negative number.
  36826. * @param {Number} colDelta Columns number to move, value can be passed as negative number.
  36827. * @param {Boolean} force If `true` the new rows/columns will be created if necessary. Otherwise, row/column will
  36828. * be created according to `minSpareRows/minSpareCols` settings of Handsontable.
  36829. * @returns {CellCoords}
  36830. */
  36831. _createClass(Transformation, [{
  36832. key: 'transformStart',
  36833. value: function transformStart(rowDelta, colDelta, force) {
  36834. var delta = new _src.CellCoords(rowDelta, colDelta);
  36835. this.runLocalHooks('beforeTransformStart', delta);
  36836. var totalRows = this.options.countRows();
  36837. var totalCols = this.options.countCols();
  36838. var fixedRowsBottom = this.options.fixedRowsBottom();
  36839. var minSpareRows = this.options.minSpareRows();
  36840. var minSpareCols = this.options.minSpareCols();
  36841. var autoWrapRow = this.options.autoWrapRow();
  36842. var autoWrapCol = this.options.autoWrapCol();
  36843. var highlightCoords = this.range.current().highlight;
  36844. if (highlightCoords.row + rowDelta > totalRows - 1) {
  36845. if (force && minSpareRows > 0 && !(fixedRowsBottom && highlightCoords.row >= totalRows - fixedRowsBottom - 1)) {
  36846. this.runLocalHooks('insertRowRequire', totalRows);
  36847. totalRows = this.options.countRows();
  36848. } else if (autoWrapCol) {
  36849. delta.row = 1 - totalRows;
  36850. delta.col = highlightCoords.col + delta.col == totalCols - 1 ? 1 - totalCols : 1;
  36851. }
  36852. } else if (autoWrapCol && highlightCoords.row + delta.row < 0 && highlightCoords.col + delta.col >= 0) {
  36853. delta.row = totalRows - 1;
  36854. delta.col = highlightCoords.col + delta.col == 0 ? totalCols - 1 : -1;
  36855. }
  36856. if (highlightCoords.col + delta.col > totalCols - 1) {
  36857. if (force && minSpareCols > 0) {
  36858. this.runLocalHooks('insertColRequire', totalRows);
  36859. totalCols = this.options.countCols();
  36860. } else if (autoWrapRow) {
  36861. delta.row = highlightCoords.row + delta.row == totalRows - 1 ? 1 - totalRows : 1;
  36862. delta.col = 1 - totalCols;
  36863. }
  36864. } else if (autoWrapRow && highlightCoords.col + delta.col < 0 && highlightCoords.row + delta.row >= 0) {
  36865. delta.row = highlightCoords.row + delta.row == 0 ? totalRows - 1 : -1;
  36866. delta.col = totalCols - 1;
  36867. }
  36868. var coords = new _src.CellCoords(highlightCoords.row + delta.row, highlightCoords.col + delta.col);
  36869. var rowTransformDir = 0;
  36870. var colTransformDir = 0;
  36871. if (coords.row < 0) {
  36872. rowTransformDir = -1;
  36873. coords.row = 0;
  36874. } else if (coords.row > 0 && coords.row >= totalRows) {
  36875. rowTransformDir = 1;
  36876. coords.row = totalRows - 1;
  36877. }
  36878. if (coords.col < 0) {
  36879. colTransformDir = -1;
  36880. coords.col = 0;
  36881. } else if (coords.col > 0 && coords.col >= totalCols) {
  36882. colTransformDir = 1;
  36883. coords.col = totalCols - 1;
  36884. }
  36885. this.runLocalHooks('afterTransformStart', coords, rowTransformDir, colTransformDir);
  36886. return coords;
  36887. }
  36888. /**
  36889. * Sets selection end cell relative to current selection end cell (if possible).
  36890. *
  36891. * @param {Number} rowDelta Rows number to move, value can be passed as negative number.
  36892. * @param {Number} colDelta Columns number to move, value can be passed as negative number.
  36893. * @returns {CellCoords}
  36894. */
  36895. }, {
  36896. key: 'transformEnd',
  36897. value: function transformEnd(rowDelta, colDelta) {
  36898. var delta = new _src.CellCoords(rowDelta, colDelta);
  36899. this.runLocalHooks('beforeTransformEnd', delta);
  36900. var totalRows = this.options.countRows();
  36901. var totalCols = this.options.countCols();
  36902. var cellRange = this.range.current();
  36903. var coords = new _src.CellCoords(cellRange.to.row + delta.row, cellRange.to.col + delta.col);
  36904. var rowTransformDir = 0;
  36905. var colTransformDir = 0;
  36906. if (coords.row < 0) {
  36907. rowTransformDir = -1;
  36908. coords.row = 0;
  36909. } else if (coords.row > 0 && coords.row >= totalRows) {
  36910. rowTransformDir = 1;
  36911. coords.row = totalRows - 1;
  36912. }
  36913. if (coords.col < 0) {
  36914. colTransformDir = -1;
  36915. coords.col = 0;
  36916. } else if (coords.col > 0 && coords.col >= totalCols) {
  36917. colTransformDir = 1;
  36918. coords.col = totalCols - 1;
  36919. }
  36920. this.runLocalHooks('afterTransformEnd', coords, rowTransformDir, colTransformDir);
  36921. return coords;
  36922. }
  36923. }]);
  36924. return Transformation;
  36925. }();
  36926. (0, _object.mixin)(Transformation, _localHooks2.default);
  36927. exports.default = Transformation;
  36928. /***/ }),
  36929. /* 404 */
  36930. /***/ (function(module, exports, __webpack_require__) {
  36931. "use strict";
  36932. exports.__esModule = true;
  36933. exports.default = jQueryWrapper;
  36934. function jQueryWrapper(Handsontable) {
  36935. var jQuery = typeof window === 'undefined' ? false : window.jQuery;
  36936. if (!jQuery) {
  36937. return;
  36938. }
  36939. jQuery.fn.handsontable = function (action) {
  36940. var $this = this.first(); // Use only first element from list
  36941. var instance = $this.data('handsontable');
  36942. // Init case
  36943. if (typeof action !== 'string') {
  36944. var userSettings = action || {};
  36945. if (instance) {
  36946. instance.updateSettings(userSettings);
  36947. } else {
  36948. instance = new Handsontable.Core($this[0], userSettings);
  36949. $this.data('handsontable', instance);
  36950. instance.init();
  36951. }
  36952. return $this;
  36953. }
  36954. // Action case
  36955. var args = [];
  36956. var output = void 0;
  36957. if (arguments.length > 1) {
  36958. for (var i = 1, ilen = arguments.length; i < ilen; i++) {
  36959. args.push(arguments[i]);
  36960. }
  36961. }
  36962. if (instance) {
  36963. if (typeof instance[action] !== 'undefined') {
  36964. output = instance[action].apply(instance, args);
  36965. if (action === 'destroy') {
  36966. $this.removeData();
  36967. }
  36968. } else {
  36969. throw new Error('Handsontable do not provide action: ' + action);
  36970. }
  36971. }
  36972. return output;
  36973. };
  36974. };
  36975. /***/ }),
  36976. /* 405 */
  36977. /***/ (function(module, exports, __webpack_require__) {
  36978. "use strict";
  36979. exports.__esModule = true;
  36980. exports.Base = exports.UndoRedo = exports.TouchScroll = exports.Search = exports.PersistentState = exports.ObserveChanges = exports.MultipleSelectionHandles = exports.MergeCells = exports.ManualRowResize = exports.ManualRowMove = exports.ManualColumnResize = exports.ManualColumnMove = exports.ManualColumnFreeze = exports.DragToScroll = exports.CustomBorders = exports.CopyPaste = exports.ContextMenu = exports.Comments = exports.ColumnSorting = exports.AutoRowSize = exports.AutoFill = exports.AutoColumnSize = undefined;
  36981. var _persistentState = __webpack_require__(406);
  36982. var _persistentState2 = _interopRequireDefault(_persistentState);
  36983. var _autoColumnSize = __webpack_require__(408);
  36984. var _autoColumnSize2 = _interopRequireDefault(_autoColumnSize);
  36985. var _autofill = __webpack_require__(409);
  36986. var _autofill2 = _interopRequireDefault(_autofill);
  36987. var _autoRowSize = __webpack_require__(411);
  36988. var _autoRowSize2 = _interopRequireDefault(_autoRowSize);
  36989. var _columnSorting = __webpack_require__(412);
  36990. var _columnSorting2 = _interopRequireDefault(_columnSorting);
  36991. var _comments = __webpack_require__(415);
  36992. var _comments2 = _interopRequireDefault(_comments);
  36993. var _contextMenu = __webpack_require__(419);
  36994. var _contextMenu2 = _interopRequireDefault(_contextMenu);
  36995. var _copyPaste = __webpack_require__(436);
  36996. var _copyPaste2 = _interopRequireDefault(_copyPaste);
  36997. var _customBorders = __webpack_require__(443);
  36998. var _customBorders2 = _interopRequireDefault(_customBorders);
  36999. var _dragToScroll = __webpack_require__(449);
  37000. var _dragToScroll2 = _interopRequireDefault(_dragToScroll);
  37001. var _manualColumnFreeze = __webpack_require__(450);
  37002. var _manualColumnFreeze2 = _interopRequireDefault(_manualColumnFreeze);
  37003. var _manualColumnMove = __webpack_require__(454);
  37004. var _manualColumnMove2 = _interopRequireDefault(_manualColumnMove);
  37005. var _manualColumnResize = __webpack_require__(459);
  37006. var _manualColumnResize2 = _interopRequireDefault(_manualColumnResize);
  37007. var _manualRowMove = __webpack_require__(460);
  37008. var _manualRowMove2 = _interopRequireDefault(_manualRowMove);
  37009. var _manualRowResize = __webpack_require__(465);
  37010. var _manualRowResize2 = _interopRequireDefault(_manualRowResize);
  37011. var _mergeCells = __webpack_require__(466);
  37012. var _mergeCells2 = _interopRequireDefault(_mergeCells);
  37013. var _multipleSelectionHandles = __webpack_require__(472);
  37014. var _multipleSelectionHandles2 = _interopRequireDefault(_multipleSelectionHandles);
  37015. var _observeChanges = __webpack_require__(473);
  37016. var _observeChanges2 = _interopRequireDefault(_observeChanges);
  37017. var _search = __webpack_require__(476);
  37018. var _search2 = _interopRequireDefault(_search);
  37019. var _touchScroll = __webpack_require__(477);
  37020. var _touchScroll2 = _interopRequireDefault(_touchScroll);
  37021. var _undoRedo = __webpack_require__(478);
  37022. var _undoRedo2 = _interopRequireDefault(_undoRedo);
  37023. var _base = __webpack_require__(10);
  37024. var _base2 = _interopRequireDefault(_base);
  37025. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  37026. exports.AutoColumnSize = _autoColumnSize2.default;
  37027. exports.AutoFill = _autofill2.default;
  37028. exports.AutoRowSize = _autoRowSize2.default;
  37029. exports.ColumnSorting = _columnSorting2.default;
  37030. exports.Comments = _comments2.default;
  37031. exports.ContextMenu = _contextMenu2.default;
  37032. exports.CopyPaste = _copyPaste2.default;
  37033. exports.CustomBorders = _customBorders2.default;
  37034. exports.DragToScroll = _dragToScroll2.default;
  37035. exports.ManualColumnFreeze = _manualColumnFreeze2.default;
  37036. exports.ManualColumnMove = _manualColumnMove2.default;
  37037. exports.ManualColumnResize = _manualColumnResize2.default;
  37038. exports.ManualRowMove = _manualRowMove2.default;
  37039. exports.ManualRowResize = _manualRowResize2.default;
  37040. exports.MergeCells = _mergeCells2.default;
  37041. exports.MultipleSelectionHandles = _multipleSelectionHandles2.default;
  37042. exports.ObserveChanges = _observeChanges2.default;
  37043. exports.PersistentState = _persistentState2.default;
  37044. exports.Search = _search2.default;
  37045. exports.TouchScroll = _touchScroll2.default;
  37046. exports.UndoRedo = _undoRedo2.default;
  37047. exports.Base = _base2.default;
  37048. /***/ }),
  37049. /* 406 */
  37050. /***/ (function(module, exports, __webpack_require__) {
  37051. "use strict";
  37052. exports.__esModule = true;
  37053. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  37054. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  37055. var _base = __webpack_require__(10);
  37056. var _base2 = _interopRequireDefault(_base);
  37057. var _plugins = __webpack_require__(8);
  37058. var _storage = __webpack_require__(407);
  37059. var _storage2 = _interopRequireDefault(_storage);
  37060. var _pluginHooks = __webpack_require__(15);
  37061. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  37062. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  37063. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  37064. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  37065. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  37066. _pluginHooks2.default.getSingleton().register('persistentStateSave');
  37067. _pluginHooks2.default.getSingleton().register('persistentStateLoad');
  37068. _pluginHooks2.default.getSingleton().register('persistentStateReset');
  37069. /**
  37070. * Save the state of column sorting, column positions and column sizes in local storage
  37071. * to preserve table state between page reloads.
  37072. *
  37073. * In order to enable data storage mechanism, persistentState option must be set to true.
  37074. *
  37075. * When persistentState is enabled it exposes 3 hooks:
  37076. *
  37077. * persistentStateSave (key: String, value: Mixed) -
  37078. * Saves value under given key in browser local storage.
  37079. *
  37080. * persistentStateLoad (key: String, saveTo: Object) -
  37081. * Loads value, saved under given key, form browser local storage.
  37082. * The loaded value will be saved in saveTo.value.
  37083. *
  37084. * persistentStateReset (key: String) -
  37085. * Clears the value saved under key.
  37086. * If no key is given, all values associated with table will be cleared.
  37087. *
  37088. * @plugin persistentState
  37089. */
  37090. var PersistentState = function (_BasePlugin) {
  37091. _inherits(PersistentState, _BasePlugin);
  37092. function PersistentState(hotInstance) {
  37093. _classCallCheck(this, PersistentState);
  37094. /**
  37095. * Instance of {@link Storage}.
  37096. *
  37097. * @type {Storage}
  37098. */
  37099. var _this = _possibleConstructorReturn(this, (PersistentState.__proto__ || Object.getPrototypeOf(PersistentState)).call(this, hotInstance));
  37100. _this.storage = void 0;
  37101. return _this;
  37102. }
  37103. /**
  37104. * Check if the plugin is enabled in the Handsontable settings.
  37105. *
  37106. * @returns {Boolean}
  37107. */
  37108. _createClass(PersistentState, [{
  37109. key: 'isEnabled',
  37110. value: function isEnabled() {
  37111. return !!this.hot.getSettings().persistentState;
  37112. }
  37113. /**
  37114. * Enable plugin for this Handsontable instance.
  37115. */
  37116. }, {
  37117. key: 'enablePlugin',
  37118. value: function enablePlugin() {
  37119. var _this2 = this;
  37120. if (this.enabled) {
  37121. return;
  37122. }
  37123. if (!this.storage) {
  37124. this.storage = new _storage2.default(this.hot.rootElement.id);
  37125. }
  37126. this.addHook('persistentStateSave', function (key, value) {
  37127. return _this2.saveValue(key, value);
  37128. });
  37129. this.addHook('persistentStateLoad', function (key, saveTo) {
  37130. return _this2.loadValue(key, saveTo);
  37131. });
  37132. this.addHook('persistentStateReset', function () {
  37133. return _this2.resetValue();
  37134. });
  37135. _get(PersistentState.prototype.__proto__ || Object.getPrototypeOf(PersistentState.prototype), 'enablePlugin', this).call(this);
  37136. }
  37137. /**
  37138. * Disable plugin for this Handsontable instance.
  37139. */
  37140. }, {
  37141. key: 'disablePlugin',
  37142. value: function disablePlugin() {
  37143. this.storage = void 0;
  37144. _get(PersistentState.prototype.__proto__ || Object.getPrototypeOf(PersistentState.prototype), 'disablePlugin', this).call(this);
  37145. }
  37146. /**
  37147. * Updates the plugin to use the latest options you have specified.
  37148. */
  37149. }, {
  37150. key: 'updatePlugin',
  37151. value: function updatePlugin() {
  37152. this.disablePlugin();
  37153. this.enablePlugin();
  37154. _get(PersistentState.prototype.__proto__ || Object.getPrototypeOf(PersistentState.prototype), 'updatePlugin', this).call(this);
  37155. }
  37156. /**
  37157. * Load value from localStorage.
  37158. *
  37159. * @param {String} key Key string.
  37160. * @param {Object} saveTo Saved value from browser local storage.
  37161. */
  37162. }, {
  37163. key: 'loadValue',
  37164. value: function loadValue(key, saveTo) {
  37165. saveTo.value = this.storage.loadValue(key);
  37166. }
  37167. /**
  37168. * Save data to localStorage.
  37169. *
  37170. * @param {String} key Key string.
  37171. * @param {Mixed} value Value to save.
  37172. */
  37173. }, {
  37174. key: 'saveValue',
  37175. value: function saveValue(key, value) {
  37176. this.storage.saveValue(key, value);
  37177. }
  37178. /**
  37179. * Reset given data or all data from localStorage.
  37180. *
  37181. * @param {String} key [optional] Key string.
  37182. */
  37183. }, {
  37184. key: 'resetValue',
  37185. value: function resetValue(key) {
  37186. if (typeof key === 'undefined') {
  37187. this.storage.resetAll();
  37188. } else {
  37189. this.storage.reset(key);
  37190. }
  37191. }
  37192. /**
  37193. * Destroy plugin instance.
  37194. */
  37195. }, {
  37196. key: 'destroy',
  37197. value: function destroy() {
  37198. _get(PersistentState.prototype.__proto__ || Object.getPrototypeOf(PersistentState.prototype), 'destroy', this).call(this);
  37199. }
  37200. }]);
  37201. return PersistentState;
  37202. }(_base2.default);
  37203. (0, _plugins.registerPlugin)('persistentState', PersistentState);
  37204. exports.default = PersistentState;
  37205. /***/ }),
  37206. /* 407 */
  37207. /***/ (function(module, exports, __webpack_require__) {
  37208. "use strict";
  37209. exports.__esModule = true;
  37210. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  37211. var _array = __webpack_require__(1);
  37212. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  37213. /**
  37214. * @class Storage
  37215. * @plugin PersistentState
  37216. */
  37217. var Storage = function () {
  37218. function Storage(prefix) {
  37219. _classCallCheck(this, Storage);
  37220. /**
  37221. * Prefix for key (id element).
  37222. *
  37223. * @type {String}
  37224. */
  37225. this.prefix = prefix;
  37226. /**
  37227. * Saved keys.
  37228. *
  37229. * @type {Array}
  37230. */
  37231. this.savedKeys = [];
  37232. this.loadSavedKeys();
  37233. }
  37234. /**
  37235. * Save data to localStorage.
  37236. *
  37237. * @param {String} key Key string.
  37238. * @param {Mixed} value Value to save.
  37239. */
  37240. _createClass(Storage, [{
  37241. key: 'saveValue',
  37242. value: function saveValue(key, value) {
  37243. window.localStorage.setItem(this.prefix + '_' + key, JSON.stringify(value));
  37244. if (this.savedKeys.indexOf(key) === -1) {
  37245. this.savedKeys.push(key);
  37246. this.saveSavedKeys();
  37247. }
  37248. }
  37249. /**
  37250. * Load data from localStorage.
  37251. *
  37252. * @param {String} key Key string.
  37253. * @param {Object} defaultValue Object containing the loaded data.
  37254. *
  37255. * @returns {}
  37256. */
  37257. }, {
  37258. key: 'loadValue',
  37259. value: function loadValue(key, defaultValue) {
  37260. key = typeof key === 'undefined' ? defaultValue : key;
  37261. var value = window.localStorage.getItem(this.prefix + '_' + key);
  37262. return value === null ? void 0 : JSON.parse(value);
  37263. }
  37264. /**
  37265. * Reset given data from localStorage.
  37266. *
  37267. * @param {String} key Key string.
  37268. */
  37269. }, {
  37270. key: 'reset',
  37271. value: function reset(key) {
  37272. window.localStorage.removeItem(this.prefix + '_' + key);
  37273. }
  37274. /**
  37275. * Reset all data from localStorage.
  37276. *
  37277. */
  37278. }, {
  37279. key: 'resetAll',
  37280. value: function resetAll() {
  37281. var _this = this;
  37282. (0, _array.arrayEach)(this.savedKeys, function (value, index) {
  37283. window.localStorage.removeItem(_this.prefix + '_' + _this.savedKeys[index]);
  37284. });
  37285. this.clearSavedKeys();
  37286. }
  37287. /**
  37288. * Load and save all keys from localStorage.
  37289. *
  37290. * @private
  37291. */
  37292. }, {
  37293. key: 'loadSavedKeys',
  37294. value: function loadSavedKeys() {
  37295. var keysJSON = window.localStorage.getItem(this.prefix + '__persistentStateKeys');
  37296. var keys = typeof keysJSON === 'string' ? JSON.parse(keysJSON) : void 0;
  37297. this.savedKeys = keys ? keys : [];
  37298. }
  37299. }, {
  37300. key: 'saveSavedKeys',
  37301. /**
  37302. * Save saved key in localStorage.
  37303. *
  37304. * @private
  37305. */
  37306. value: function saveSavedKeys() {
  37307. window.localStorage.setItem(this.prefix + '__persistentStateKeys', JSON.stringify(this.savedKeys));
  37308. }
  37309. }, {
  37310. key: 'clearSavedKeys',
  37311. /**
  37312. * Clear saved key from localStorage.
  37313. *
  37314. * @private
  37315. */
  37316. value: function clearSavedKeys() {
  37317. this.savedKeys.length = 0;
  37318. this.saveSavedKeys();
  37319. }
  37320. }]);
  37321. return Storage;
  37322. }();
  37323. exports.default = Storage;
  37324. /***/ }),
  37325. /* 408 */
  37326. /***/ (function(module, exports, __webpack_require__) {
  37327. "use strict";
  37328. exports.__esModule = true;
  37329. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  37330. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  37331. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  37332. var _base = __webpack_require__(10);
  37333. var _base2 = _interopRequireDefault(_base);
  37334. var _array = __webpack_require__(1);
  37335. var _feature = __webpack_require__(40);
  37336. var _element = __webpack_require__(0);
  37337. var _ghostTable = __webpack_require__(92);
  37338. var _ghostTable2 = _interopRequireDefault(_ghostTable);
  37339. var _object = __webpack_require__(2);
  37340. var _number = __webpack_require__(5);
  37341. var _plugins = __webpack_require__(8);
  37342. var _samplesGenerator = __webpack_require__(320);
  37343. var _samplesGenerator2 = _interopRequireDefault(_samplesGenerator);
  37344. var _string = __webpack_require__(36);
  37345. var _src = __webpack_require__(4);
  37346. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  37347. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  37348. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  37349. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  37350. var privatePool = new WeakMap();
  37351. /**
  37352. * @plugin AutoColumnSize
  37353. *
  37354. * @description
  37355. * This plugin allows to set column widths based on their widest cells.
  37356. *
  37357. * By default, the plugin is declared as `undefined`, which makes it enabled (same as if it was declared as `true`).
  37358. * Enabling this plugin may decrease the overall table performance, as it needs to calculate the widths of all cells to
  37359. * resize the columns accordingly.
  37360. * If you experience problems with the performance, try turning this feature off and declaring the column widths manually.
  37361. *
  37362. * Column width calculations are divided into sync and async part. Each of this parts has their own advantages and
  37363. * disadvantages. Synchronous calculations are faster but they block the browser UI, while the slower asynchronous operations don't
  37364. * block the browser UI.
  37365. *
  37366. * To configure the sync/async distribution, you can pass an absolute value (number of columns) or a percentage value to a config object:
  37367. * ```js
  37368. * ...
  37369. * // as a number (300 columns in sync, rest async)
  37370. * autoColumnSize: {syncLimit: 300},
  37371. * ...
  37372. *
  37373. * ...
  37374. * // as a string (percent)
  37375. * autoColumnSize: {syncLimit: '40%'},
  37376. * ...
  37377. * ```
  37378. *
  37379. * To configure this plugin see {@link Options#autoColumnSize}.
  37380. *
  37381. * @example
  37382. * ```js
  37383. * ...
  37384. * var hot = new Handsontable(document.getElementById('example'), {
  37385. * date: getData(),
  37386. * autoColumnSize: true
  37387. * });
  37388. * // Access to plugin instance:
  37389. * var plugin = hot.getPlugin('autoColumnSize');
  37390. *
  37391. * plugin.getColumnWidth(4);
  37392. *
  37393. * if (plugin.isEnabled()) {
  37394. * // code...
  37395. * }
  37396. * ...
  37397. * ```
  37398. */
  37399. var AutoColumnSize = function (_BasePlugin) {
  37400. _inherits(AutoColumnSize, _BasePlugin);
  37401. _createClass(AutoColumnSize, null, [{
  37402. key: 'CALCULATION_STEP',
  37403. get: function get() {
  37404. return 50;
  37405. }
  37406. }, {
  37407. key: 'SYNC_CALCULATION_LIMIT',
  37408. get: function get() {
  37409. return 50;
  37410. }
  37411. }]);
  37412. function AutoColumnSize(hotInstance) {
  37413. _classCallCheck(this, AutoColumnSize);
  37414. var _this = _possibleConstructorReturn(this, (AutoColumnSize.__proto__ || Object.getPrototypeOf(AutoColumnSize)).call(this, hotInstance));
  37415. privatePool.set(_this, {
  37416. /**
  37417. * Cached column header names. It is used to diff current column headers with previous state and detect which
  37418. * columns width should be updated.
  37419. *
  37420. * @private
  37421. * @type {Array}
  37422. */
  37423. cachedColumnHeaders: []
  37424. });
  37425. /**
  37426. * Cached columns widths.
  37427. *
  37428. * @type {Array}
  37429. */
  37430. _this.widths = [];
  37431. /**
  37432. * Instance of {@link GhostTable} for rows and columns size calculations.
  37433. *
  37434. * @type {GhostTable}
  37435. */
  37436. _this.ghostTable = new _ghostTable2.default(_this.hot);
  37437. /**
  37438. * Instance of {@link SamplesGenerator} for generating samples necessary for columns width calculations.
  37439. *
  37440. * @type {SamplesGenerator}
  37441. */
  37442. _this.samplesGenerator = new _samplesGenerator2.default(function (row, col) {
  37443. return _this.hot.getCellMeta(row, col).spanned ? '' : _this.hot.getDataAtCell(row, col);
  37444. });
  37445. /**
  37446. * `true` only if the first calculation was performed
  37447. *
  37448. * @type {Boolean}
  37449. */
  37450. _this.firstCalculation = true;
  37451. /**
  37452. * `true` if the size calculation is in progress.
  37453. *
  37454. * @type {Boolean}
  37455. */
  37456. _this.inProgress = false;
  37457. // moved to constructor to allow auto-sizing the columns when the plugin is disabled
  37458. _this.addHook('beforeColumnResize', function (col, size, isDblClick) {
  37459. return _this.onBeforeColumnResize(col, size, isDblClick);
  37460. });
  37461. return _this;
  37462. }
  37463. /**
  37464. * Check if the plugin is enabled in the handsontable settings.
  37465. *
  37466. * @returns {Boolean}
  37467. */
  37468. _createClass(AutoColumnSize, [{
  37469. key: 'isEnabled',
  37470. value: function isEnabled() {
  37471. return this.hot.getSettings().autoColumnSize !== false && !this.hot.getSettings().colWidths;
  37472. }
  37473. /**
  37474. * Enable plugin for this Handsontable instance.
  37475. */
  37476. }, {
  37477. key: 'enablePlugin',
  37478. value: function enablePlugin() {
  37479. var _this2 = this;
  37480. if (this.enabled) {
  37481. return;
  37482. }
  37483. var setting = this.hot.getSettings().autoColumnSize;
  37484. if (setting && setting.useHeaders != null) {
  37485. this.ghostTable.setSetting('useHeaders', setting.useHeaders);
  37486. }
  37487. this.addHook('afterLoadData', function () {
  37488. return _this2.onAfterLoadData();
  37489. });
  37490. this.addHook('beforeChange', function (changes) {
  37491. return _this2.onBeforeChange(changes);
  37492. });
  37493. this.addHook('beforeRender', function (force) {
  37494. return _this2.onBeforeRender(force);
  37495. });
  37496. this.addHook('modifyColWidth', function (width, col) {
  37497. return _this2.getColumnWidth(col, width);
  37498. });
  37499. this.addHook('afterInit', function () {
  37500. return _this2.onAfterInit();
  37501. });
  37502. _get(AutoColumnSize.prototype.__proto__ || Object.getPrototypeOf(AutoColumnSize.prototype), 'enablePlugin', this).call(this);
  37503. }
  37504. /**
  37505. * Update plugin state.
  37506. */
  37507. }, {
  37508. key: 'updatePlugin',
  37509. value: function updatePlugin() {
  37510. var changedColumns = this.findColumnsWhereHeaderWasChanged();
  37511. if (changedColumns.length) {
  37512. this.clearCache(changedColumns);
  37513. }
  37514. _get(AutoColumnSize.prototype.__proto__ || Object.getPrototypeOf(AutoColumnSize.prototype), 'updatePlugin', this).call(this);
  37515. }
  37516. /**
  37517. * Disable plugin for this Handsontable instance.
  37518. */
  37519. }, {
  37520. key: 'disablePlugin',
  37521. value: function disablePlugin() {
  37522. _get(AutoColumnSize.prototype.__proto__ || Object.getPrototypeOf(AutoColumnSize.prototype), 'disablePlugin', this).call(this);
  37523. }
  37524. /**
  37525. * Calculate a columns width.
  37526. *
  37527. * @param {Number|Object} colRange Column range object.
  37528. * @param {Number|Object} rowRange Row range object.
  37529. * @param {Boolean} [force=false] If `true` force calculate width even when value was cached earlier.
  37530. */
  37531. }, {
  37532. key: 'calculateColumnsWidth',
  37533. value: function calculateColumnsWidth() {
  37534. var colRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { from: 0, to: this.hot.countCols() - 1 };
  37535. var _this3 = this;
  37536. var rowRange = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { from: 0, to: this.hot.countRows() - 1 };
  37537. var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  37538. if (typeof colRange === 'number') {
  37539. colRange = { from: colRange, to: colRange };
  37540. }
  37541. if (typeof rowRange === 'number') {
  37542. rowRange = { from: rowRange, to: rowRange };
  37543. }
  37544. (0, _number.rangeEach)(colRange.from, colRange.to, function (col) {
  37545. if (force || _this3.widths[col] === void 0 && !_this3.hot._getColWidthFromSettings(col)) {
  37546. var samples = _this3.samplesGenerator.generateColumnSamples(col, rowRange);
  37547. samples.forEach(function (sample, col) {
  37548. return _this3.ghostTable.addColumn(col, sample);
  37549. });
  37550. }
  37551. });
  37552. if (this.ghostTable.columns.length) {
  37553. this.ghostTable.getWidths(function (col, width) {
  37554. _this3.widths[col] = width;
  37555. });
  37556. this.ghostTable.clean();
  37557. }
  37558. }
  37559. /**
  37560. * Calculate all columns width.
  37561. *
  37562. * @param {Object|Number} rowRange Row range object.
  37563. */
  37564. }, {
  37565. key: 'calculateAllColumnsWidth',
  37566. value: function calculateAllColumnsWidth() {
  37567. var _this4 = this;
  37568. var rowRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { from: 0, to: this.hot.countRows() - 1 };
  37569. var current = 0;
  37570. var length = this.hot.countCols() - 1;
  37571. var timer = null;
  37572. this.inProgress = true;
  37573. var loop = function loop() {
  37574. // When hot was destroyed after calculating finished cancel frame
  37575. if (!_this4.hot) {
  37576. (0, _feature.cancelAnimationFrame)(timer);
  37577. _this4.inProgress = false;
  37578. return;
  37579. }
  37580. _this4.calculateColumnsWidth({
  37581. from: current,
  37582. to: Math.min(current + AutoColumnSize.CALCULATION_STEP, length)
  37583. }, rowRange);
  37584. current = current + AutoColumnSize.CALCULATION_STEP + 1;
  37585. if (current < length) {
  37586. timer = (0, _feature.requestAnimationFrame)(loop);
  37587. } else {
  37588. (0, _feature.cancelAnimationFrame)(timer);
  37589. _this4.inProgress = false;
  37590. // @TODO Should call once per render cycle, currently fired separately in different plugins
  37591. _this4.hot.view.wt.wtOverlays.adjustElementsSize(true);
  37592. // tmp
  37593. if (_this4.hot.view.wt.wtOverlays.leftOverlay.needFullRender) {
  37594. _this4.hot.view.wt.wtOverlays.leftOverlay.clone.draw();
  37595. }
  37596. }
  37597. };
  37598. // sync
  37599. if (this.firstCalculation && this.getSyncCalculationLimit()) {
  37600. this.calculateColumnsWidth({ from: 0, to: this.getSyncCalculationLimit() }, rowRange);
  37601. this.firstCalculation = false;
  37602. current = this.getSyncCalculationLimit() + 1;
  37603. }
  37604. // async
  37605. if (current < length) {
  37606. loop();
  37607. } else {
  37608. this.inProgress = false;
  37609. }
  37610. }
  37611. /**
  37612. * Set the sampling options.
  37613. *
  37614. * @private
  37615. */
  37616. }, {
  37617. key: 'setSamplingOptions',
  37618. value: function setSamplingOptions() {
  37619. var setting = this.hot.getSettings().autoColumnSize;
  37620. var samplingRatio = setting && (0, _object.hasOwnProperty)(setting, 'samplingRatio') ? this.hot.getSettings().autoColumnSize.samplingRatio : void 0;
  37621. var allowSampleDuplicates = setting && (0, _object.hasOwnProperty)(setting, 'allowSampleDuplicates') ? this.hot.getSettings().autoColumnSize.allowSampleDuplicates : void 0;
  37622. if (samplingRatio && !isNaN(samplingRatio)) {
  37623. this.samplesGenerator.setSampleCount(parseInt(samplingRatio, 10));
  37624. }
  37625. if (allowSampleDuplicates) {
  37626. this.samplesGenerator.setAllowDuplicates(allowSampleDuplicates);
  37627. }
  37628. }
  37629. /**
  37630. * Recalculate all columns width (overwrite cache values).
  37631. */
  37632. }, {
  37633. key: 'recalculateAllColumnsWidth',
  37634. value: function recalculateAllColumnsWidth() {
  37635. if (this.hot.view && (0, _element.isVisible)(this.hot.view.wt.wtTable.TABLE)) {
  37636. this.clearCache();
  37637. this.calculateAllColumnsWidth();
  37638. }
  37639. }
  37640. /**
  37641. * Get value which tells how many columns should be calculated synchronously. Rest of the columns will be calculated asynchronously.
  37642. *
  37643. * @returns {Number}
  37644. */
  37645. }, {
  37646. key: 'getSyncCalculationLimit',
  37647. value: function getSyncCalculationLimit() {
  37648. /* eslint-disable no-bitwise */
  37649. var limit = AutoColumnSize.SYNC_CALCULATION_LIMIT;
  37650. var colsLimit = this.hot.countCols() - 1;
  37651. if ((0, _object.isObject)(this.hot.getSettings().autoColumnSize)) {
  37652. limit = this.hot.getSettings().autoColumnSize.syncLimit;
  37653. if ((0, _string.isPercentValue)(limit)) {
  37654. limit = (0, _number.valueAccordingPercent)(colsLimit, limit);
  37655. } else {
  37656. // Force to Number
  37657. limit >>= 0;
  37658. }
  37659. }
  37660. return Math.min(limit, colsLimit);
  37661. }
  37662. /**
  37663. * Get the calculated column width.
  37664. *
  37665. * @param {Number} col Column index.
  37666. * @param {Number} [defaultWidth] Default column width. It will be picked up if no calculated width found.
  37667. * @param {Boolean} [keepMinimum=true] If `true` then returned value won't be smaller then 50 (default column width).
  37668. * @returns {Number}
  37669. */
  37670. }, {
  37671. key: 'getColumnWidth',
  37672. value: function getColumnWidth(col) {
  37673. var defaultWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : void 0;
  37674. var keepMinimum = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  37675. var width = defaultWidth;
  37676. if (width === void 0) {
  37677. width = this.widths[col];
  37678. if (keepMinimum && typeof width === 'number') {
  37679. width = Math.max(width, _src.ViewportColumnsCalculator.DEFAULT_WIDTH);
  37680. }
  37681. }
  37682. return width;
  37683. }
  37684. /**
  37685. * Get the first visible column.
  37686. *
  37687. * @returns {Number} Returns column index or -1 if table is not rendered.
  37688. */
  37689. }, {
  37690. key: 'getFirstVisibleColumn',
  37691. value: function getFirstVisibleColumn() {
  37692. var wot = this.hot.view.wt;
  37693. if (wot.wtViewport.columnsVisibleCalculator) {
  37694. return wot.wtTable.getFirstVisibleColumn();
  37695. }
  37696. if (wot.wtViewport.columnsRenderCalculator) {
  37697. return wot.wtTable.getFirstRenderedColumn();
  37698. }
  37699. return -1;
  37700. }
  37701. /**
  37702. * Get the last visible column.
  37703. *
  37704. * @returns {Number} Returns column index or -1 if table is not rendered.
  37705. */
  37706. }, {
  37707. key: 'getLastVisibleColumn',
  37708. value: function getLastVisibleColumn() {
  37709. var wot = this.hot.view.wt;
  37710. if (wot.wtViewport.columnsVisibleCalculator) {
  37711. return wot.wtTable.getLastVisibleColumn();
  37712. }
  37713. if (wot.wtViewport.columnsRenderCalculator) {
  37714. return wot.wtTable.getLastRenderedColumn();
  37715. }
  37716. return -1;
  37717. }
  37718. /**
  37719. * Collects all columns which titles has been changed in comparison to the previous state.
  37720. *
  37721. * @returns {Array} It returns an array of physical column indexes.
  37722. */
  37723. }, {
  37724. key: 'findColumnsWhereHeaderWasChanged',
  37725. value: function findColumnsWhereHeaderWasChanged() {
  37726. var columnHeaders = this.hot.getColHeader();
  37727. var _privatePool$get = privatePool.get(this),
  37728. cachedColumnHeaders = _privatePool$get.cachedColumnHeaders;
  37729. var changedColumns = (0, _array.arrayReduce)(columnHeaders, function (acc, columnTitle, physicalColumn) {
  37730. var cachedColumnsLength = cachedColumnHeaders.length;
  37731. if (cachedColumnsLength - 1 < physicalColumn || cachedColumnHeaders[physicalColumn] !== columnTitle) {
  37732. acc.push(physicalColumn);
  37733. }
  37734. if (cachedColumnsLength - 1 < physicalColumn) {
  37735. cachedColumnHeaders.push(columnTitle);
  37736. } else {
  37737. cachedColumnHeaders[physicalColumn] = columnTitle;
  37738. }
  37739. return acc;
  37740. }, []);
  37741. return changedColumns;
  37742. }
  37743. /**
  37744. * Clear cache of calculated column widths. If you want to clear only selected columns pass an array with their indexes.
  37745. * Otherwise whole cache will be cleared.
  37746. *
  37747. * @param {Array} [columns=[]] List of column indexes (physical indexes) to clear.
  37748. */
  37749. }, {
  37750. key: 'clearCache',
  37751. value: function clearCache() {
  37752. var _this5 = this;
  37753. var columns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  37754. if (columns.length) {
  37755. (0, _array.arrayEach)(columns, function (physicalIndex) {
  37756. _this5.widths[physicalIndex] = void 0;
  37757. });
  37758. } else {
  37759. this.widths.length = 0;
  37760. }
  37761. }
  37762. /**
  37763. * Check if all widths were calculated. If not then return `true` (need recalculate).
  37764. *
  37765. * @returns {Boolean}
  37766. */
  37767. }, {
  37768. key: 'isNeedRecalculate',
  37769. value: function isNeedRecalculate() {
  37770. return !!(0, _array.arrayFilter)(this.widths, function (item) {
  37771. return item === void 0;
  37772. }).length;
  37773. }
  37774. /**
  37775. * On before render listener.
  37776. *
  37777. * @private
  37778. */
  37779. }, {
  37780. key: 'onBeforeRender',
  37781. value: function onBeforeRender() {
  37782. var force = this.hot.renderCall;
  37783. var rowsCount = this.hot.countRows();
  37784. // Keep last column widths unchanged for situation when all rows was deleted or trimmed (pro #6)
  37785. if (!rowsCount) {
  37786. return;
  37787. }
  37788. this.calculateColumnsWidth({ from: this.getFirstVisibleColumn(), to: this.getLastVisibleColumn() }, void 0, force);
  37789. if (this.isNeedRecalculate() && !this.inProgress) {
  37790. this.calculateAllColumnsWidth();
  37791. }
  37792. }
  37793. /**
  37794. * On after load data listener.
  37795. *
  37796. * @private
  37797. */
  37798. }, {
  37799. key: 'onAfterLoadData',
  37800. value: function onAfterLoadData() {
  37801. var _this6 = this;
  37802. if (this.hot.view) {
  37803. this.recalculateAllColumnsWidth();
  37804. } else {
  37805. // first load - initialization
  37806. setTimeout(function () {
  37807. if (_this6.hot) {
  37808. _this6.recalculateAllColumnsWidth();
  37809. }
  37810. }, 0);
  37811. }
  37812. }
  37813. /**
  37814. * On before change listener.
  37815. *
  37816. * @private
  37817. * @param {Array} changes
  37818. */
  37819. }, {
  37820. key: 'onBeforeChange',
  37821. value: function onBeforeChange(changes) {
  37822. var _this7 = this;
  37823. var changedColumns = (0, _array.arrayMap)(changes, function (_ref) {
  37824. var _ref2 = _slicedToArray(_ref, 2),
  37825. row = _ref2[0],
  37826. column = _ref2[1];
  37827. return _this7.hot.propToCol(column);
  37828. });
  37829. this.clearCache(changedColumns);
  37830. }
  37831. /**
  37832. * On before column resize listener.
  37833. *
  37834. * @private
  37835. * @param {Number} col
  37836. * @param {Number} size
  37837. * @param {Boolean} isDblClick
  37838. * @returns {Number}
  37839. */
  37840. }, {
  37841. key: 'onBeforeColumnResize',
  37842. value: function onBeforeColumnResize(col, size, isDblClick) {
  37843. if (isDblClick) {
  37844. this.calculateColumnsWidth(col, void 0, true);
  37845. size = this.getColumnWidth(col, void 0, false);
  37846. }
  37847. return size;
  37848. }
  37849. /**
  37850. * On after Handsontable init fill plugin with all necessary values.
  37851. *
  37852. * @private
  37853. */
  37854. }, {
  37855. key: 'onAfterInit',
  37856. value: function onAfterInit() {
  37857. privatePool.get(this).cachedColumnHeaders = this.hot.getColHeader();
  37858. }
  37859. /**
  37860. * Destroy plugin instance.
  37861. */
  37862. }, {
  37863. key: 'destroy',
  37864. value: function destroy() {
  37865. this.ghostTable.clean();
  37866. _get(AutoColumnSize.prototype.__proto__ || Object.getPrototypeOf(AutoColumnSize.prototype), 'destroy', this).call(this);
  37867. }
  37868. }]);
  37869. return AutoColumnSize;
  37870. }(_base2.default);
  37871. (0, _plugins.registerPlugin)('autoColumnSize', AutoColumnSize);
  37872. exports.default = AutoColumnSize;
  37873. /***/ }),
  37874. /* 409 */
  37875. /***/ (function(module, exports, __webpack_require__) {
  37876. "use strict";
  37877. exports.__esModule = true;
  37878. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  37879. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  37880. var _base = __webpack_require__(10);
  37881. var _base2 = _interopRequireDefault(_base);
  37882. var _pluginHooks = __webpack_require__(15);
  37883. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  37884. var _element = __webpack_require__(0);
  37885. var _eventManager = __webpack_require__(6);
  37886. var _eventManager2 = _interopRequireDefault(_eventManager);
  37887. var _plugins = __webpack_require__(8);
  37888. var _src = __webpack_require__(4);
  37889. var _utils = __webpack_require__(410);
  37890. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  37891. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  37892. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  37893. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  37894. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  37895. _pluginHooks2.default.getSingleton().register('modifyAutofillRange');
  37896. _pluginHooks2.default.getSingleton().register('beforeAutofill');
  37897. var INSERT_ROW_ALTER_ACTION_NAME = 'insert_row';
  37898. var INTERVAL_FOR_ADDING_ROW = 200;
  37899. /**
  37900. * This plugin provides "drag-down" and "copy-down" functionalities, both operated
  37901. * using the small square in the right bottom of the cell selection.
  37902. *
  37903. * "Drag-down" expands the value of the selected cells to the neighbouring
  37904. * cells when you drag the small square in the corner.
  37905. *
  37906. * "Copy-down" copies the value of the selection to all empty cells
  37907. * below when you double click the small square.
  37908. *
  37909. * @class Autofill
  37910. * @plugin Autofill
  37911. */
  37912. var Autofill = function (_BasePlugin) {
  37913. _inherits(Autofill, _BasePlugin);
  37914. function Autofill(hotInstance) {
  37915. _classCallCheck(this, Autofill);
  37916. /**
  37917. * Event manager
  37918. *
  37919. * @type {EventManager}
  37920. */
  37921. var _this = _possibleConstructorReturn(this, (Autofill.__proto__ || Object.getPrototypeOf(Autofill)).call(this, hotInstance));
  37922. _this.eventManager = new _eventManager2.default(_this);
  37923. /**
  37924. * Specifies if adding new row started.
  37925. *
  37926. * @type {Boolean}
  37927. */
  37928. _this.addingStarted = false;
  37929. /**
  37930. * Specifies if there was mouse down on the cell corner.
  37931. *
  37932. * @type {Boolean}
  37933. */
  37934. _this.mouseDownOnCellCorner = false;
  37935. /**
  37936. * Specifies if mouse was dragged outside Handsontable.
  37937. *
  37938. * @type {Boolean}
  37939. */
  37940. _this.mouseDragOutside = false;
  37941. /**
  37942. * Specifies how many cell levels were dragged using the handle.
  37943. *
  37944. * @type {Boolean}
  37945. */
  37946. _this.handleDraggedCells = 0;
  37947. /**
  37948. * Specifies allowed directions of drag.
  37949. *
  37950. * @type {Array}
  37951. */
  37952. _this.directions = [];
  37953. /**
  37954. * Specifies if can insert new rows if needed.
  37955. *
  37956. * @type {Boolean}
  37957. */
  37958. _this.autoInsertRow = false;
  37959. return _this;
  37960. }
  37961. /**
  37962. * Check if the plugin is enabled in the Handsontable settings.
  37963. *
  37964. * @returns {Boolean}
  37965. */
  37966. _createClass(Autofill, [{
  37967. key: 'isEnabled',
  37968. value: function isEnabled() {
  37969. return this.hot.getSettings().fillHandle;
  37970. }
  37971. /**
  37972. * Enable plugin for this Handsontable instance.
  37973. */
  37974. }, {
  37975. key: 'enablePlugin',
  37976. value: function enablePlugin() {
  37977. var _this2 = this;
  37978. if (this.enabled) {
  37979. return;
  37980. }
  37981. this.mapSettings();
  37982. this.registerEvents();
  37983. this.addHook('afterOnCellCornerMouseDown', function (event) {
  37984. return _this2.onAfterCellCornerMouseDown(event);
  37985. });
  37986. this.addHook('afterOnCellCornerDblClick', function (event) {
  37987. return _this2.onCellCornerDblClick(event);
  37988. });
  37989. this.addHook('beforeOnCellMouseOver', function (event, coords, TD) {
  37990. return _this2.onBeforeCellMouseOver(coords);
  37991. });
  37992. _get(Autofill.prototype.__proto__ || Object.getPrototypeOf(Autofill.prototype), 'enablePlugin', this).call(this);
  37993. }
  37994. /**
  37995. * Update plugin for this Handsontable instance.
  37996. */
  37997. }, {
  37998. key: 'updatePlugin',
  37999. value: function updatePlugin() {
  38000. this.disablePlugin();
  38001. this.enablePlugin();
  38002. _get(Autofill.prototype.__proto__ || Object.getPrototypeOf(Autofill.prototype), 'updatePlugin', this).call(this);
  38003. }
  38004. /**
  38005. * Disable plugin for this Handsontable instance.
  38006. */
  38007. }, {
  38008. key: 'disablePlugin',
  38009. value: function disablePlugin() {
  38010. this.clearMappedSettings();
  38011. _get(Autofill.prototype.__proto__ || Object.getPrototypeOf(Autofill.prototype), 'disablePlugin', this).call(this);
  38012. }
  38013. /**
  38014. * Get selection data
  38015. *
  38016. * @private
  38017. * @returns {Array} Array with the data.
  38018. */
  38019. }, {
  38020. key: 'getSelectionData',
  38021. value: function getSelectionData() {
  38022. var selRange = {
  38023. from: this.hot.getSelectedRangeLast().from,
  38024. to: this.hot.getSelectedRangeLast().to
  38025. };
  38026. return this.hot.getData(selRange.from.row, selRange.from.col, selRange.to.row, selRange.to.col);
  38027. }
  38028. /**
  38029. * Try to apply fill values to the area in fill border, omitting the selection border.
  38030. *
  38031. * @private
  38032. * @returns {Boolean} reports if fill was applied.
  38033. */
  38034. }, {
  38035. key: 'fillIn',
  38036. value: function fillIn() {
  38037. if (this.hot.selection.highlight.getFill().isEmpty()) {
  38038. return false;
  38039. }
  38040. var cornersOfSelectionAndDragAreas = this.hot.selection.highlight.getFill().getCorners();
  38041. this.resetSelectionOfDraggedArea();
  38042. var cornersOfSelectedCells = this.getCornersOfSelectedCells();
  38043. cornersOfSelectionAndDragAreas = this.hot.runHooks('modifyAutofillRange', cornersOfSelectionAndDragAreas, cornersOfSelectedCells);
  38044. var _getDragDirectionAndR = (0, _utils.getDragDirectionAndRange)(cornersOfSelectedCells, cornersOfSelectionAndDragAreas),
  38045. directionOfDrag = _getDragDirectionAndR.directionOfDrag,
  38046. startOfDragCoords = _getDragDirectionAndR.startOfDragCoords,
  38047. endOfDragCoords = _getDragDirectionAndR.endOfDragCoords;
  38048. if (startOfDragCoords && startOfDragCoords.row > -1 && startOfDragCoords.col > -1) {
  38049. var selectionData = this.getSelectionData();
  38050. this.hot.runHooks('beforeAutofill', startOfDragCoords, endOfDragCoords, selectionData);
  38051. var deltas = (0, _utils.getDeltas)(startOfDragCoords, endOfDragCoords, selectionData, directionOfDrag);
  38052. var fillData = selectionData;
  38053. if (['up', 'left'].indexOf(directionOfDrag) > -1) {
  38054. fillData = [];
  38055. var dragLength = null;
  38056. var fillOffset = null;
  38057. if (directionOfDrag === 'up') {
  38058. dragLength = endOfDragCoords.row - startOfDragCoords.row + 1;
  38059. fillOffset = dragLength % selectionData.length;
  38060. for (var i = 0; i < dragLength; i++) {
  38061. fillData.push(selectionData[(i + (selectionData.length - fillOffset)) % selectionData.length]);
  38062. }
  38063. } else {
  38064. dragLength = endOfDragCoords.col - startOfDragCoords.col + 1;
  38065. fillOffset = dragLength % selectionData[0].length;
  38066. for (var _i = 0; _i < selectionData.length; _i++) {
  38067. fillData.push([]);
  38068. for (var j = 0; j < dragLength; j++) {
  38069. fillData[_i].push(selectionData[_i][(j + (selectionData[_i].length - fillOffset)) % selectionData[_i].length]);
  38070. }
  38071. }
  38072. }
  38073. }
  38074. this.hot.populateFromArray(startOfDragCoords.row, startOfDragCoords.col, fillData, endOfDragCoords.row, endOfDragCoords.col, this.pluginName + '.fill', null, directionOfDrag, deltas);
  38075. this.setSelection(cornersOfSelectionAndDragAreas);
  38076. } else {
  38077. // reset to avoid some range bug
  38078. this.hot._refreshBorders();
  38079. }
  38080. return true;
  38081. }
  38082. /**
  38083. * Reduce the selection area if the handle was dragged outside of the table or on headers.
  38084. *
  38085. * @private
  38086. * @param {CellCoords} coords indexes of selection corners.
  38087. * @returns {CellCoords}
  38088. */
  38089. }, {
  38090. key: 'reduceSelectionAreaIfNeeded',
  38091. value: function reduceSelectionAreaIfNeeded(coords) {
  38092. if (coords.row < 0) {
  38093. coords.row = 0;
  38094. }
  38095. if (coords.col < 0) {
  38096. coords.col = 0;
  38097. }
  38098. return coords;
  38099. }
  38100. /**
  38101. * Get the coordinates of the drag & drop borders.
  38102. *
  38103. * @private
  38104. * @param {CellCoords} coordsOfSelection `CellCoords` coord object.
  38105. * @returns {Array}
  38106. */
  38107. }, {
  38108. key: 'getCoordsOfDragAndDropBorders',
  38109. value: function getCoordsOfDragAndDropBorders(coordsOfSelection) {
  38110. var topLeftCorner = this.hot.getSelectedRangeLast().getTopLeftCorner();
  38111. var bottomRightCorner = this.hot.getSelectedRangeLast().getBottomRightCorner();
  38112. var coords = void 0;
  38113. if (this.directions.includes(_utils.DIRECTIONS.vertical) && (bottomRightCorner.row < coordsOfSelection.row || topLeftCorner.row > coordsOfSelection.row)) {
  38114. coords = new _src.CellCoords(coordsOfSelection.row, bottomRightCorner.col);
  38115. } else if (this.directions.includes(_utils.DIRECTIONS.horizontal)) {
  38116. coords = new _src.CellCoords(bottomRightCorner.row, coordsOfSelection.col);
  38117. } else {
  38118. // wrong direction
  38119. return;
  38120. }
  38121. return this.reduceSelectionAreaIfNeeded(coords);
  38122. }
  38123. /**
  38124. * Show the fill border.
  38125. *
  38126. * @private
  38127. * @param {CellCoords} coordsOfSelection `CellCoords` coord object.
  38128. */
  38129. }, {
  38130. key: 'showBorder',
  38131. value: function showBorder(coordsOfSelection) {
  38132. var coordsOfDragAndDropBorders = this.getCoordsOfDragAndDropBorders(coordsOfSelection);
  38133. if (coordsOfDragAndDropBorders) {
  38134. this.redrawBorders(coordsOfDragAndDropBorders);
  38135. }
  38136. }
  38137. /**
  38138. * Add new row
  38139. *
  38140. * @private
  38141. */
  38142. }, {
  38143. key: 'addRow',
  38144. value: function addRow() {
  38145. var _this3 = this;
  38146. this.hot._registerTimeout(setTimeout(function () {
  38147. _this3.hot.alter(INSERT_ROW_ALTER_ACTION_NAME, void 0, 1, _this3.pluginName + '.fill');
  38148. _this3.addingStarted = false;
  38149. }, INTERVAL_FOR_ADDING_ROW));
  38150. }
  38151. /**
  38152. * Add new rows if they are needed to continue auto-filling values.
  38153. *
  38154. * @private
  38155. */
  38156. }, {
  38157. key: 'addNewRowIfNeeded',
  38158. value: function addNewRowIfNeeded() {
  38159. if (this.hot.selection.highlight.getFill().cellRange && this.addingStarted === false && this.autoInsertRow) {
  38160. var cornersOfSelectedCells = this.hot.getSelectedLast();
  38161. var cornersOfSelectedDragArea = this.hot.selection.highlight.getFill().getCorners();
  38162. var nrOfTableRows = this.hot.countRows();
  38163. if (cornersOfSelectedCells[2] < nrOfTableRows - 1 && cornersOfSelectedDragArea[2] === nrOfTableRows - 1) {
  38164. this.addingStarted = true;
  38165. this.addRow();
  38166. }
  38167. }
  38168. }
  38169. /**
  38170. * Get corners of selected cells.
  38171. *
  38172. * @private
  38173. * @returns {Array}
  38174. */
  38175. }, {
  38176. key: 'getCornersOfSelectedCells',
  38177. value: function getCornersOfSelectedCells() {
  38178. if (this.hot.selection.isMultiple()) {
  38179. return this.hot.selection.highlight.createOrGetArea().getCorners();
  38180. }
  38181. return this.hot.selection.highlight.getCell().getCorners();
  38182. }
  38183. /**
  38184. * Get index of last adjacent filled in row
  38185. *
  38186. * @private
  38187. * @param {Array} cornersOfSelectedCells indexes of selection corners.
  38188. * @returns {Number} gives number greater than or equal to zero when selection adjacent can be applied.
  38189. * or -1 when selection adjacent can't be applied
  38190. */
  38191. }, {
  38192. key: 'getIndexOfLastAdjacentFilledInRow',
  38193. value: function getIndexOfLastAdjacentFilledInRow(cornersOfSelectedCells) {
  38194. var data = this.hot.getData();
  38195. var nrOfTableRows = this.hot.countRows();
  38196. var lastFilledInRowIndex = void 0;
  38197. for (var rowIndex = cornersOfSelectedCells[2] + 1; rowIndex < nrOfTableRows; rowIndex++) {
  38198. for (var columnIndex = cornersOfSelectedCells[1]; columnIndex <= cornersOfSelectedCells[3]; columnIndex++) {
  38199. var dataInCell = data[rowIndex][columnIndex];
  38200. if (dataInCell) {
  38201. return -1;
  38202. }
  38203. }
  38204. var dataInNextLeftCell = data[rowIndex][cornersOfSelectedCells[1] - 1];
  38205. var dataInNextRightCell = data[rowIndex][cornersOfSelectedCells[3] + 1];
  38206. if (!!dataInNextLeftCell || !!dataInNextRightCell) {
  38207. lastFilledInRowIndex = rowIndex;
  38208. }
  38209. }
  38210. return lastFilledInRowIndex;
  38211. }
  38212. /**
  38213. * Add a selection from the start area to the specific row index.
  38214. *
  38215. * @private
  38216. * @param {Array} selectStartArea selection area from which we start to create more comprehensive selection.
  38217. * @param {Number} rowIndex
  38218. */
  38219. }, {
  38220. key: 'addSelectionFromStartAreaToSpecificRowIndex',
  38221. value: function addSelectionFromStartAreaToSpecificRowIndex(selectStartArea, rowIndex) {
  38222. this.hot.selection.highlight.getFill().clear().add(new _src.CellCoords(selectStartArea[0], selectStartArea[1])).add(new _src.CellCoords(rowIndex, selectStartArea[3]));
  38223. }
  38224. /**
  38225. * Set selection based on passed corners.
  38226. *
  38227. * @private
  38228. * @param {Array} cornersOfArea
  38229. */
  38230. }, {
  38231. key: 'setSelection',
  38232. value: function setSelection(cornersOfArea) {
  38233. var _hot;
  38234. (_hot = this.hot).selectCell.apply(_hot, _toConsumableArray(cornersOfArea).concat([false, false]));
  38235. }
  38236. /**
  38237. * Try to select cells down to the last row in the left column and then returns if selection was applied.
  38238. *
  38239. * @private
  38240. * @returns {Boolean}
  38241. */
  38242. }, {
  38243. key: 'selectAdjacent',
  38244. value: function selectAdjacent() {
  38245. var cornersOfSelectedCells = this.getCornersOfSelectedCells();
  38246. var lastFilledInRowIndex = this.getIndexOfLastAdjacentFilledInRow(cornersOfSelectedCells);
  38247. if (lastFilledInRowIndex === -1) {
  38248. return false;
  38249. }
  38250. this.addSelectionFromStartAreaToSpecificRowIndex(cornersOfSelectedCells, lastFilledInRowIndex);
  38251. return true;
  38252. }
  38253. /**
  38254. * Reset selection of dragged area.
  38255. *
  38256. * @private
  38257. */
  38258. }, {
  38259. key: 'resetSelectionOfDraggedArea',
  38260. value: function resetSelectionOfDraggedArea() {
  38261. this.handleDraggedCells = 0;
  38262. this.hot.selection.highlight.getFill().clear();
  38263. }
  38264. /**
  38265. * Redraw borders.
  38266. *
  38267. * @private
  38268. * @param {CellCoords} coords `CellCoords` coord object.
  38269. */
  38270. }, {
  38271. key: 'redrawBorders',
  38272. value: function redrawBorders(coords) {
  38273. this.hot.selection.highlight.getFill().clear().add(this.hot.getSelectedRangeLast().from).add(this.hot.getSelectedRangeLast().to).add(coords);
  38274. this.hot.view.render();
  38275. }
  38276. /**
  38277. * Get if mouse was dragged outside.
  38278. *
  38279. * @private
  38280. * @param {MouseEvent} event `mousemove` event properties.
  38281. * @returns {Boolean}
  38282. */
  38283. }, {
  38284. key: 'getIfMouseWasDraggedOutside',
  38285. value: function getIfMouseWasDraggedOutside(event) {
  38286. var tableBottom = (0, _element.offset)(this.hot.table).top - (window.pageYOffset || document.documentElement.scrollTop) + (0, _element.outerHeight)(this.hot.table);
  38287. var tableRight = (0, _element.offset)(this.hot.table).left - (window.pageXOffset || document.documentElement.scrollLeft) + (0, _element.outerWidth)(this.hot.table);
  38288. return event.clientY > tableBottom && event.clientX <= tableRight;
  38289. }
  38290. /**
  38291. * Bind the events used by the plugin.
  38292. *
  38293. * @private
  38294. */
  38295. }, {
  38296. key: 'registerEvents',
  38297. value: function registerEvents() {
  38298. var _this4 = this;
  38299. this.eventManager.addEventListener(document.documentElement, 'mouseup', function () {
  38300. return _this4.onMouseUp();
  38301. });
  38302. this.eventManager.addEventListener(document.documentElement, 'mousemove', function (event) {
  38303. return _this4.onMouseMove(event);
  38304. });
  38305. }
  38306. /**
  38307. * On cell corner double click callback.
  38308. *
  38309. * @private
  38310. */
  38311. }, {
  38312. key: 'onCellCornerDblClick',
  38313. value: function onCellCornerDblClick() {
  38314. var selectionApplied = this.selectAdjacent();
  38315. if (selectionApplied) {
  38316. this.fillIn();
  38317. }
  38318. }
  38319. /**
  38320. * On after cell corner mouse down listener.
  38321. *
  38322. * @private
  38323. */
  38324. }, {
  38325. key: 'onAfterCellCornerMouseDown',
  38326. value: function onAfterCellCornerMouseDown() {
  38327. this.handleDraggedCells = 1;
  38328. this.mouseDownOnCellCorner = true;
  38329. }
  38330. /**
  38331. * On before cell mouse over listener.
  38332. *
  38333. * @private
  38334. * @param {CellCoords} coords `CellCoords` coord object.
  38335. */
  38336. }, {
  38337. key: 'onBeforeCellMouseOver',
  38338. value: function onBeforeCellMouseOver(coords) {
  38339. if (this.mouseDownOnCellCorner && !this.hot.view.isMouseDown() && this.handleDraggedCells) {
  38340. this.handleDraggedCells++;
  38341. this.showBorder(coords);
  38342. this.addNewRowIfNeeded();
  38343. }
  38344. }
  38345. /**
  38346. * On mouse up listener.
  38347. *
  38348. * @private
  38349. */
  38350. }, {
  38351. key: 'onMouseUp',
  38352. value: function onMouseUp() {
  38353. if (this.handleDraggedCells) {
  38354. if (this.handleDraggedCells > 1) {
  38355. this.fillIn();
  38356. }
  38357. this.handleDraggedCells = 0;
  38358. this.mouseDownOnCellCorner = false;
  38359. }
  38360. }
  38361. /**
  38362. * On mouse move listener.
  38363. *
  38364. * @private
  38365. * @param {MouseEvent} event `mousemove` event properties.
  38366. */
  38367. }, {
  38368. key: 'onMouseMove',
  38369. value: function onMouseMove(event) {
  38370. var mouseWasDraggedOutside = this.getIfMouseWasDraggedOutside(event);
  38371. if (this.addingStarted === false && this.handleDraggedCells > 0 && mouseWasDraggedOutside) {
  38372. this.mouseDragOutside = true;
  38373. this.addingStarted = true;
  38374. } else {
  38375. this.mouseDragOutside = false;
  38376. }
  38377. if (this.mouseDragOutside && this.autoInsertRow) {
  38378. this.addRow();
  38379. }
  38380. }
  38381. /**
  38382. * Clear mapped settings.
  38383. *
  38384. * @private
  38385. */
  38386. }, {
  38387. key: 'clearMappedSettings',
  38388. value: function clearMappedSettings() {
  38389. this.directions.length = 0;
  38390. this.autoInsertRow = false;
  38391. }
  38392. /**
  38393. * Map settings.
  38394. *
  38395. * @private
  38396. */
  38397. }, {
  38398. key: 'mapSettings',
  38399. value: function mapSettings() {
  38400. var mappedSettings = (0, _utils.getMappedFillHandleSetting)(this.hot.getSettings().fillHandle);
  38401. this.directions = mappedSettings.directions;
  38402. this.autoInsertRow = mappedSettings.autoInsertRow;
  38403. }
  38404. /**
  38405. * Destroy plugin instance.
  38406. */
  38407. }, {
  38408. key: 'destroy',
  38409. value: function destroy() {
  38410. _get(Autofill.prototype.__proto__ || Object.getPrototypeOf(Autofill.prototype), 'destroy', this).call(this);
  38411. }
  38412. }]);
  38413. return Autofill;
  38414. }(_base2.default);
  38415. (0, _plugins.registerPlugin)('autofill', Autofill);
  38416. exports.default = Autofill;
  38417. /***/ }),
  38418. /* 410 */
  38419. /***/ (function(module, exports, __webpack_require__) {
  38420. "use strict";
  38421. exports.__esModule = true;
  38422. exports.DIRECTIONS = undefined;
  38423. exports.getDeltas = getDeltas;
  38424. exports.getDragDirectionAndRange = getDragDirectionAndRange;
  38425. exports.getMappedFillHandleSetting = getMappedFillHandleSetting;
  38426. var _object = __webpack_require__(2);
  38427. var _mixed = __webpack_require__(16);
  38428. var _src = __webpack_require__(4);
  38429. var DIRECTIONS = exports.DIRECTIONS = {
  38430. horizontal: 'horizontal',
  38431. vertical: 'vertical'
  38432. };
  38433. /**
  38434. * Get deltas array.
  38435. *
  38436. * @param {CellCoords} start
  38437. * @param {CellCoords} end
  38438. * @param {Array} data
  38439. * @param {String} direction
  38440. * @returns {Array}
  38441. */
  38442. function getDeltas(start, end, data, direction) {
  38443. var rowsLength = data.length;
  38444. var columnsLength = data ? data[0].length : 0;
  38445. var deltas = [];
  38446. var diffRow = end.row - start.row;
  38447. var diffCol = end.col - start.col;
  38448. if (['down', 'up'].indexOf(direction) !== -1) {
  38449. var arr = [];
  38450. for (var col = 0; col <= diffCol; col++) {
  38451. var startValue = parseInt(data[0][col], 10);
  38452. var endValue = parseInt(data[rowsLength - 1][col], 10);
  38453. var delta = (direction === 'down' ? endValue - startValue : startValue - endValue) / (rowsLength - 1) || 0;
  38454. arr.push(delta);
  38455. }
  38456. deltas.push(arr);
  38457. }
  38458. if (['right', 'left'].indexOf(direction) !== -1) {
  38459. for (var row = 0; row <= diffRow; row++) {
  38460. var _startValue = parseInt(data[row][0], 10);
  38461. var _endValue = parseInt(data[row][columnsLength - 1], 10);
  38462. var _delta = (direction === 'right' ? _endValue - _startValue : _startValue - _endValue) / (columnsLength - 1) || 0;
  38463. deltas.push([_delta]);
  38464. }
  38465. }
  38466. return deltas;
  38467. }
  38468. /**
  38469. * Get direction between positions and cords of selections difference (drag area)
  38470. *
  38471. * @param {Array} startSelection
  38472. * @param {Array} endSelection
  38473. * @returns {{direction: String, start: CellCoords, end: CellCoords}}
  38474. */
  38475. function getDragDirectionAndRange(startSelection, endSelection) {
  38476. var startOfDragCoords = void 0,
  38477. endOfDragCoords = void 0,
  38478. directionOfDrag = void 0;
  38479. if (endSelection[0] === startSelection[0] && endSelection[1] < startSelection[1]) {
  38480. directionOfDrag = 'left';
  38481. startOfDragCoords = new _src.CellCoords(endSelection[0], endSelection[1]);
  38482. endOfDragCoords = new _src.CellCoords(endSelection[2], startSelection[1] - 1);
  38483. } else if (endSelection[2] === startSelection[2] && endSelection[0] === startSelection[0] && endSelection[3] > startSelection[3]) {
  38484. directionOfDrag = 'right';
  38485. startOfDragCoords = new _src.CellCoords(endSelection[0], startSelection[3] + 1);
  38486. endOfDragCoords = new _src.CellCoords(endSelection[2], endSelection[3]);
  38487. } else if (endSelection[0] < startSelection[0] && endSelection[1] === startSelection[1]) {
  38488. directionOfDrag = 'up';
  38489. startOfDragCoords = new _src.CellCoords(endSelection[0], endSelection[1]);
  38490. endOfDragCoords = new _src.CellCoords(startSelection[0] - 1, endSelection[3]);
  38491. } else if (endSelection[2] > startSelection[2] && endSelection[1] === startSelection[1]) {
  38492. directionOfDrag = 'down';
  38493. startOfDragCoords = new _src.CellCoords(startSelection[2] + 1, endSelection[1]);
  38494. endOfDragCoords = new _src.CellCoords(endSelection[2], endSelection[3]);
  38495. }
  38496. return {
  38497. directionOfDrag: directionOfDrag,
  38498. startOfDragCoords: startOfDragCoords,
  38499. endOfDragCoords: endOfDragCoords
  38500. };
  38501. }
  38502. /**
  38503. * Get mapped FillHandle setting containing information about
  38504. * allowed FillHandle directions and if allowed is automatic insertion of rows on drag
  38505. *
  38506. * @param {Boolean|Object} fillHandle property of Handsontable settings
  38507. * @returns {{directions: Array, autoInsertRow: Boolean}} object allowing access to information
  38508. * about FillHandle in more useful way
  38509. */
  38510. function getMappedFillHandleSetting(fillHandle) {
  38511. var mappedSettings = {};
  38512. if (fillHandle === true) {
  38513. mappedSettings.directions = Object.keys(DIRECTIONS);
  38514. mappedSettings.autoInsertRow = true;
  38515. } else if ((0, _object.isObject)(fillHandle)) {
  38516. if ((0, _mixed.isDefined)(fillHandle.autoInsertRow)) {
  38517. // autoInsertRow for horizontal direction will be always false
  38518. if (fillHandle.direction === DIRECTIONS.horizontal) {
  38519. mappedSettings.autoInsertRow = false;
  38520. } else {
  38521. mappedSettings.autoInsertRow = fillHandle.autoInsertRow;
  38522. }
  38523. } else {
  38524. mappedSettings.autoInsertRow = false;
  38525. }
  38526. if ((0, _mixed.isDefined)(fillHandle.direction)) {
  38527. mappedSettings.directions = [fillHandle.direction];
  38528. } else {
  38529. mappedSettings.directions = Object.keys(DIRECTIONS);
  38530. }
  38531. } else if (typeof fillHandle === 'string') {
  38532. mappedSettings.directions = [fillHandle];
  38533. mappedSettings.autoInsertRow = true;
  38534. } else {
  38535. mappedSettings.directions = [];
  38536. mappedSettings.autoInsertRow = false;
  38537. }
  38538. return mappedSettings;
  38539. }
  38540. /***/ }),
  38541. /* 411 */
  38542. /***/ (function(module, exports, __webpack_require__) {
  38543. "use strict";
  38544. exports.__esModule = true;
  38545. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  38546. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  38547. var _base = __webpack_require__(10);
  38548. var _base2 = _interopRequireDefault(_base);
  38549. var _array = __webpack_require__(1);
  38550. var _feature = __webpack_require__(40);
  38551. var _element = __webpack_require__(0);
  38552. var _ghostTable = __webpack_require__(92);
  38553. var _ghostTable2 = _interopRequireDefault(_ghostTable);
  38554. var _object = __webpack_require__(2);
  38555. var _number = __webpack_require__(5);
  38556. var _plugins = __webpack_require__(8);
  38557. var _samplesGenerator = __webpack_require__(320);
  38558. var _samplesGenerator2 = _interopRequireDefault(_samplesGenerator);
  38559. var _string = __webpack_require__(36);
  38560. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  38561. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  38562. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  38563. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  38564. /**
  38565. * @plugin AutoRowSize
  38566. *
  38567. * @description
  38568. * This plugin allows to set row heights based on their highest cells.
  38569. *
  38570. * By default, the plugin is declared as `undefined`, which makes it disabled (same as if it was declared as `false`).
  38571. * Enabling this plugin may decrease the overall table performance, as it needs to calculate the heights of all cells to
  38572. * resize the rows accordingly.
  38573. * If you experience problems with the performance, try turning this feature off and declaring the row heights manually.
  38574. *
  38575. * Row height calculations are divided into sync and async part. Each of this parts has their own advantages and
  38576. * disadvantages. Synchronous calculations are faster but they block the browser UI, while the slower asynchronous operations don't
  38577. * block the browser UI.
  38578. *
  38579. * To configure the sync/async distribution, you can pass an absolute value (number of columns) or a percentage value to a config object:
  38580. * ```js
  38581. * ...
  38582. * // as a number (300 columns in sync, rest async)
  38583. * autoRowSize: {syncLimit: 300},
  38584. * ...
  38585. *
  38586. * ...
  38587. * // as a string (percent)
  38588. * autoRowSize: {syncLimit: '40%'},
  38589. * ...
  38590. * ```
  38591. *
  38592. * You can also use the `allowSampleDuplicates` option to allow sampling duplicate values when calculating the row height. Note, that this might have
  38593. * a negative impact on performance.
  38594. *
  38595. * To configure this plugin see {@link Options#autoRowSize}.
  38596. *
  38597. * @example
  38598. *
  38599. * ```js
  38600. * ...
  38601. * var hot = new Handsontable(document.getElementById('example'), {
  38602. * date: getData(),
  38603. * autoRowSize: true
  38604. * });
  38605. * // Access to plugin instance:
  38606. * var plugin = hot.getPlugin('autoRowSize');
  38607. *
  38608. * plugin.getRowHeight(4);
  38609. *
  38610. * if (plugin.isEnabled()) {
  38611. * // code...
  38612. * }
  38613. * ...
  38614. * ```
  38615. */
  38616. var AutoRowSize = function (_BasePlugin) {
  38617. _inherits(AutoRowSize, _BasePlugin);
  38618. _createClass(AutoRowSize, null, [{
  38619. key: 'CALCULATION_STEP',
  38620. get: function get() {
  38621. return 50;
  38622. }
  38623. }, {
  38624. key: 'SYNC_CALCULATION_LIMIT',
  38625. get: function get() {
  38626. return 500;
  38627. }
  38628. }]);
  38629. function AutoRowSize(hotInstance) {
  38630. _classCallCheck(this, AutoRowSize);
  38631. /**
  38632. * Cached rows heights.
  38633. *
  38634. * @type {Array}
  38635. */
  38636. var _this = _possibleConstructorReturn(this, (AutoRowSize.__proto__ || Object.getPrototypeOf(AutoRowSize)).call(this, hotInstance));
  38637. _this.heights = [];
  38638. /**
  38639. * Instance of {@link GhostTable} for rows and columns size calculations.
  38640. *
  38641. * @type {GhostTable}
  38642. */
  38643. _this.ghostTable = new _ghostTable2.default(_this.hot);
  38644. /**
  38645. * Instance of {@link SamplesGenerator} for generating samples necessary for rows height calculations.
  38646. *
  38647. * @type {SamplesGenerator}
  38648. */
  38649. _this.samplesGenerator = new _samplesGenerator2.default(function (row, col) {
  38650. if (row >= 0) {
  38651. return _this.hot.getDataAtCell(row, col);
  38652. } else if (row === -1) {
  38653. return _this.hot.getColHeader(col);
  38654. }
  38655. return null;
  38656. });
  38657. /**
  38658. * `true` if only the first calculation was performed.
  38659. *
  38660. * @type {Boolean}
  38661. */
  38662. _this.firstCalculation = true;
  38663. /**
  38664. * `true` if the size calculation is in progress.
  38665. *
  38666. * @type {Boolean}
  38667. */
  38668. _this.inProgress = false;
  38669. // moved to constructor to allow auto-sizing the rows when the plugin is disabled
  38670. _this.addHook('beforeRowResize', function (row, size, isDblClick) {
  38671. return _this.onBeforeRowResize(row, size, isDblClick);
  38672. });
  38673. return _this;
  38674. }
  38675. /**
  38676. * Check if the plugin is enabled in the Handsontable settings.
  38677. *
  38678. * @returns {Boolean}
  38679. */
  38680. _createClass(AutoRowSize, [{
  38681. key: 'isEnabled',
  38682. value: function isEnabled() {
  38683. return this.hot.getSettings().autoRowSize === true || (0, _object.isObject)(this.hot.getSettings().autoRowSize);
  38684. }
  38685. /**
  38686. * Enable plugin for this Handsontable instance.
  38687. */
  38688. }, {
  38689. key: 'enablePlugin',
  38690. value: function enablePlugin() {
  38691. var _this2 = this;
  38692. if (this.enabled) {
  38693. return;
  38694. }
  38695. this.setSamplingOptions();
  38696. this.addHook('afterLoadData', function () {
  38697. return _this2.onAfterLoadData();
  38698. });
  38699. this.addHook('beforeChange', function (changes) {
  38700. return _this2.onBeforeChange(changes);
  38701. });
  38702. this.addHook('beforeColumnMove', function () {
  38703. return _this2.recalculateAllRowsHeight();
  38704. });
  38705. this.addHook('beforeColumnResize', function () {
  38706. return _this2.recalculateAllRowsHeight();
  38707. });
  38708. this.addHook('beforeColumnSort', function () {
  38709. return _this2.clearCache();
  38710. });
  38711. this.addHook('beforeRender', function (force) {
  38712. return _this2.onBeforeRender(force);
  38713. });
  38714. this.addHook('beforeRowMove', function (rowStart, rowEnd) {
  38715. return _this2.onBeforeRowMove(rowStart, rowEnd);
  38716. });
  38717. this.addHook('modifyRowHeight', function (height, row) {
  38718. return _this2.getRowHeight(row, height);
  38719. });
  38720. this.addHook('modifyColumnHeaderHeight', function () {
  38721. return _this2.getColumnHeaderHeight();
  38722. });
  38723. _get(AutoRowSize.prototype.__proto__ || Object.getPrototypeOf(AutoRowSize.prototype), 'enablePlugin', this).call(this);
  38724. }
  38725. /**
  38726. * Disable plugin for this Handsontable instance.
  38727. */
  38728. }, {
  38729. key: 'disablePlugin',
  38730. value: function disablePlugin() {
  38731. _get(AutoRowSize.prototype.__proto__ || Object.getPrototypeOf(AutoRowSize.prototype), 'disablePlugin', this).call(this);
  38732. }
  38733. /**
  38734. * Calculate a given rows height.
  38735. *
  38736. * @param {Number|Object} rowRange Row range object.
  38737. * @param {Number|Object} colRange Column range object.
  38738. * @param {Boolean} [force=false] If `true` force calculate height even when value was cached earlier.
  38739. */
  38740. }, {
  38741. key: 'calculateRowsHeight',
  38742. value: function calculateRowsHeight() {
  38743. var rowRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { from: 0, to: this.hot.countRows() - 1 };
  38744. var _this3 = this;
  38745. var colRange = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { from: 0, to: this.hot.countCols() - 1 };
  38746. var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  38747. if (typeof rowRange === 'number') {
  38748. rowRange = { from: rowRange, to: rowRange };
  38749. }
  38750. if (typeof colRange === 'number') {
  38751. colRange = { from: colRange, to: colRange };
  38752. }
  38753. if (this.hot.getColHeader(0) !== null) {
  38754. var samples = this.samplesGenerator.generateRowSamples(-1, colRange);
  38755. this.ghostTable.addColumnHeadersRow(samples.get(-1));
  38756. }
  38757. (0, _number.rangeEach)(rowRange.from, rowRange.to, function (row) {
  38758. // For rows we must calculate row height even when user had set height value manually.
  38759. // We can shrink column but cannot shrink rows!
  38760. if (force || _this3.heights[row] === void 0) {
  38761. var _samples = _this3.samplesGenerator.generateRowSamples(row, colRange);
  38762. _samples.forEach(function (sample, row) {
  38763. _this3.ghostTable.addRow(row, sample);
  38764. });
  38765. }
  38766. });
  38767. if (this.ghostTable.rows.length) {
  38768. this.ghostTable.getHeights(function (row, height) {
  38769. _this3.heights[row] = height;
  38770. });
  38771. this.ghostTable.clean();
  38772. }
  38773. }
  38774. /**
  38775. * Calculate the height of all the rows.
  38776. *
  38777. * @param {Object|Number} colRange Column range object.
  38778. */
  38779. }, {
  38780. key: 'calculateAllRowsHeight',
  38781. value: function calculateAllRowsHeight() {
  38782. var _this4 = this;
  38783. var colRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { from: 0, to: this.hot.countCols() - 1 };
  38784. var current = 0;
  38785. var length = this.hot.countRows() - 1;
  38786. var timer = null;
  38787. this.inProgress = true;
  38788. var loop = function loop() {
  38789. // When hot was destroyed after calculating finished cancel frame
  38790. if (!_this4.hot) {
  38791. (0, _feature.cancelAnimationFrame)(timer);
  38792. _this4.inProgress = false;
  38793. return;
  38794. }
  38795. _this4.calculateRowsHeight({ from: current, to: Math.min(current + AutoRowSize.CALCULATION_STEP, length) }, colRange);
  38796. current = current + AutoRowSize.CALCULATION_STEP + 1;
  38797. if (current < length) {
  38798. timer = (0, _feature.requestAnimationFrame)(loop);
  38799. } else {
  38800. (0, _feature.cancelAnimationFrame)(timer);
  38801. _this4.inProgress = false;
  38802. // @TODO Should call once per render cycle, currently fired separately in different plugins
  38803. _this4.hot.view.wt.wtOverlays.adjustElementsSize(true);
  38804. // tmp
  38805. if (_this4.hot.view.wt.wtOverlays.leftOverlay.needFullRender) {
  38806. _this4.hot.view.wt.wtOverlays.leftOverlay.clone.draw();
  38807. }
  38808. }
  38809. };
  38810. // sync
  38811. if (this.firstCalculation && this.getSyncCalculationLimit()) {
  38812. this.calculateRowsHeight({ from: 0, to: this.getSyncCalculationLimit() }, colRange);
  38813. this.firstCalculation = false;
  38814. current = this.getSyncCalculationLimit() + 1;
  38815. }
  38816. // async
  38817. if (current < length) {
  38818. loop();
  38819. } else {
  38820. this.inProgress = false;
  38821. this.hot.view.wt.wtOverlays.adjustElementsSize(false);
  38822. }
  38823. }
  38824. /**
  38825. * Set the sampling options.
  38826. *
  38827. * @private
  38828. */
  38829. }, {
  38830. key: 'setSamplingOptions',
  38831. value: function setSamplingOptions() {
  38832. var setting = this.hot.getSettings().autoRowSize;
  38833. var samplingRatio = setting && (0, _object.hasOwnProperty)(setting, 'samplingRatio') ? this.hot.getSettings().autoRowSize.samplingRatio : void 0;
  38834. var allowSampleDuplicates = setting && (0, _object.hasOwnProperty)(setting, 'allowSampleDuplicates') ? this.hot.getSettings().autoRowSize.allowSampleDuplicates : void 0;
  38835. if (samplingRatio && !isNaN(samplingRatio)) {
  38836. this.samplesGenerator.setSampleCount(parseInt(samplingRatio, 10));
  38837. }
  38838. if (allowSampleDuplicates) {
  38839. this.samplesGenerator.setAllowDuplicates(allowSampleDuplicates);
  38840. }
  38841. }
  38842. /**
  38843. * Recalculate all rows height (overwrite cache values).
  38844. */
  38845. }, {
  38846. key: 'recalculateAllRowsHeight',
  38847. value: function recalculateAllRowsHeight() {
  38848. if ((0, _element.isVisible)(this.hot.view.wt.wtTable.TABLE)) {
  38849. this.clearCache();
  38850. this.calculateAllRowsHeight();
  38851. }
  38852. }
  38853. /**
  38854. * Get value which tells how much rows will be calculated synchronously. Rest rows will be calculated asynchronously.
  38855. *
  38856. * @returns {Number}
  38857. */
  38858. }, {
  38859. key: 'getSyncCalculationLimit',
  38860. value: function getSyncCalculationLimit() {
  38861. /* eslint-disable no-bitwise */
  38862. var limit = AutoRowSize.SYNC_CALCULATION_LIMIT;
  38863. var rowsLimit = this.hot.countRows() - 1;
  38864. if ((0, _object.isObject)(this.hot.getSettings().autoRowSize)) {
  38865. limit = this.hot.getSettings().autoRowSize.syncLimit;
  38866. if ((0, _string.isPercentValue)(limit)) {
  38867. limit = (0, _number.valueAccordingPercent)(rowsLimit, limit);
  38868. } else {
  38869. // Force to Number
  38870. limit >>= 0;
  38871. }
  38872. }
  38873. return Math.min(limit, rowsLimit);
  38874. }
  38875. /**
  38876. * Get the calculated row height.
  38877. *
  38878. * @param {Number} row Visual row index.
  38879. * @param {Number} [defaultHeight] Default row height. It will be pick up if no calculated height found.
  38880. * @returns {Number}
  38881. */
  38882. }, {
  38883. key: 'getRowHeight',
  38884. value: function getRowHeight(row) {
  38885. var defaultHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : void 0;
  38886. var height = defaultHeight;
  38887. if (this.heights[row] !== void 0 && this.heights[row] > (defaultHeight || 0)) {
  38888. height = this.heights[row];
  38889. }
  38890. return height;
  38891. }
  38892. /**
  38893. * Get the calculated column header height.
  38894. *
  38895. * @returns {Number|undefined}
  38896. */
  38897. }, {
  38898. key: 'getColumnHeaderHeight',
  38899. value: function getColumnHeaderHeight() {
  38900. return this.heights[-1];
  38901. }
  38902. /**
  38903. * Get the first visible row.
  38904. *
  38905. * @returns {Number} Returns row index or -1 if table is not rendered.
  38906. */
  38907. }, {
  38908. key: 'getFirstVisibleRow',
  38909. value: function getFirstVisibleRow() {
  38910. var wot = this.hot.view.wt;
  38911. if (wot.wtViewport.rowsVisibleCalculator) {
  38912. return wot.wtTable.getFirstVisibleRow();
  38913. }
  38914. if (wot.wtViewport.rowsRenderCalculator) {
  38915. return wot.wtTable.getFirstRenderedRow();
  38916. }
  38917. return -1;
  38918. }
  38919. /**
  38920. * Get the last visible row.
  38921. *
  38922. * @returns {Number} Returns row index or -1 if table is not rendered.
  38923. */
  38924. }, {
  38925. key: 'getLastVisibleRow',
  38926. value: function getLastVisibleRow() {
  38927. var wot = this.hot.view.wt;
  38928. if (wot.wtViewport.rowsVisibleCalculator) {
  38929. return wot.wtTable.getLastVisibleRow();
  38930. }
  38931. if (wot.wtViewport.rowsRenderCalculator) {
  38932. return wot.wtTable.getLastRenderedRow();
  38933. }
  38934. return -1;
  38935. }
  38936. /**
  38937. * Clear cached heights.
  38938. */
  38939. }, {
  38940. key: 'clearCache',
  38941. value: function clearCache() {
  38942. this.heights.length = 0;
  38943. this.heights[-1] = void 0;
  38944. }
  38945. /**
  38946. * Clear cache by range.
  38947. *
  38948. * @param {Object|Number} range Row range object.
  38949. */
  38950. }, {
  38951. key: 'clearCacheByRange',
  38952. value: function clearCacheByRange(range) {
  38953. var _this5 = this;
  38954. if (typeof range === 'number') {
  38955. range = { from: range, to: range };
  38956. }
  38957. (0, _number.rangeEach)(Math.min(range.from, range.to), Math.max(range.from, range.to), function (row) {
  38958. _this5.heights[row] = void 0;
  38959. });
  38960. }
  38961. /**
  38962. * @returns {Boolean}
  38963. */
  38964. }, {
  38965. key: 'isNeedRecalculate',
  38966. value: function isNeedRecalculate() {
  38967. return !!(0, _array.arrayFilter)(this.heights, function (item) {
  38968. return item === void 0;
  38969. }).length;
  38970. }
  38971. /**
  38972. * On before render listener.
  38973. *
  38974. * @private
  38975. */
  38976. }, {
  38977. key: 'onBeforeRender',
  38978. value: function onBeforeRender() {
  38979. var force = this.hot.renderCall;
  38980. this.calculateRowsHeight({ from: this.getFirstVisibleRow(), to: this.getLastVisibleRow() }, void 0, force);
  38981. var fixedRowsBottom = this.hot.getSettings().fixedRowsBottom;
  38982. // Calculate rows height synchronously for bottom overlay
  38983. if (fixedRowsBottom) {
  38984. var totalRows = this.hot.countRows() - 1;
  38985. this.calculateRowsHeight({ from: totalRows - fixedRowsBottom, to: totalRows });
  38986. }
  38987. if (this.isNeedRecalculate() && !this.inProgress) {
  38988. this.calculateAllRowsHeight();
  38989. }
  38990. }
  38991. /**
  38992. * On before row move listener.
  38993. *
  38994. * @private
  38995. * @param {Number} from Row index where was grabbed.
  38996. * @param {Number} to Destination row index.
  38997. */
  38998. }, {
  38999. key: 'onBeforeRowMove',
  39000. value: function onBeforeRowMove(from, to) {
  39001. this.clearCacheByRange({ from: from, to: to });
  39002. this.calculateAllRowsHeight();
  39003. }
  39004. /**
  39005. * On before row resize listener.
  39006. *
  39007. * @private
  39008. * @param {Number} row
  39009. * @param {Number} size
  39010. * @param {Boolean} isDblClick
  39011. * @returns {Number}
  39012. */
  39013. }, {
  39014. key: 'onBeforeRowResize',
  39015. value: function onBeforeRowResize(row, size, isDblClick) {
  39016. if (isDblClick) {
  39017. this.calculateRowsHeight(row, void 0, true);
  39018. size = this.getRowHeight(row);
  39019. }
  39020. return size;
  39021. }
  39022. /**
  39023. * On after load data listener.
  39024. *
  39025. * @private
  39026. */
  39027. }, {
  39028. key: 'onAfterLoadData',
  39029. value: function onAfterLoadData() {
  39030. var _this6 = this;
  39031. if (this.hot.view) {
  39032. this.recalculateAllRowsHeight();
  39033. } else {
  39034. // first load - initialization
  39035. setTimeout(function () {
  39036. if (_this6.hot) {
  39037. _this6.recalculateAllRowsHeight();
  39038. }
  39039. }, 0);
  39040. }
  39041. }
  39042. /**
  39043. * On before change listener.
  39044. *
  39045. * @private
  39046. * @param {Array} changes
  39047. */
  39048. }, {
  39049. key: 'onBeforeChange',
  39050. value: function onBeforeChange(changes) {
  39051. var range = null;
  39052. if (changes.length === 1) {
  39053. range = changes[0][0];
  39054. } else if (changes.length > 1) {
  39055. range = {
  39056. from: changes[0][0],
  39057. to: changes[changes.length - 1][0]
  39058. };
  39059. }
  39060. if (range !== null) {
  39061. this.clearCacheByRange(range);
  39062. }
  39063. }
  39064. /**
  39065. * Destroy plugin instance.
  39066. */
  39067. }, {
  39068. key: 'destroy',
  39069. value: function destroy() {
  39070. this.ghostTable.clean();
  39071. _get(AutoRowSize.prototype.__proto__ || Object.getPrototypeOf(AutoRowSize.prototype), 'destroy', this).call(this);
  39072. }
  39073. }]);
  39074. return AutoRowSize;
  39075. }(_base2.default);
  39076. (0, _plugins.registerPlugin)('autoRowSize', AutoRowSize);
  39077. exports.default = AutoRowSize;
  39078. /***/ }),
  39079. /* 412 */
  39080. /***/ (function(module, exports, __webpack_require__) {
  39081. "use strict";
  39082. exports.__esModule = true;
  39083. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  39084. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  39085. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  39086. var _moment = __webpack_require__(41);
  39087. var _moment2 = _interopRequireDefault(_moment);
  39088. var _element = __webpack_require__(0);
  39089. var _array = __webpack_require__(1);
  39090. var _mixed = __webpack_require__(16);
  39091. var _object = __webpack_require__(2);
  39092. var _base = __webpack_require__(10);
  39093. var _base2 = _interopRequireDefault(_base);
  39094. var _plugins = __webpack_require__(8);
  39095. var _mergeSort = __webpack_require__(413);
  39096. var _mergeSort2 = _interopRequireDefault(_mergeSort);
  39097. var _pluginHooks = __webpack_require__(15);
  39098. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  39099. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  39100. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  39101. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  39102. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  39103. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  39104. _pluginHooks2.default.getSingleton().register('beforeColumnSort');
  39105. _pluginHooks2.default.getSingleton().register('afterColumnSort');
  39106. // TODO: Implement mixin arrayMapper to ColumnSorting plugin.
  39107. /**
  39108. * @plugin ColumnSorting
  39109. *
  39110. * @description
  39111. * This plugin sorts the view by a column (but does not sort the data source!).
  39112. * To enable the plugin, set the `columnSorting` property to either:
  39113. * * a boolean value (`true`/`false`),
  39114. * * an object defining the initial sorting order (see the example below).
  39115. *
  39116. * @example
  39117. * ```js
  39118. * ...
  39119. * // as boolean
  39120. * columnSorting: true
  39121. * ...
  39122. * // as a object with initial order (sort ascending column at index 2)
  39123. * columnSorting: {
  39124. * column: 2,
  39125. * sortOrder: true, // true = ascending, false = descending, undefined = original order
  39126. * sortEmptyCells: true // true = the table sorts empty cells, false = the table moves all empty cells to the end of the table
  39127. * }
  39128. * ...
  39129. * ```
  39130. * @dependencies ObserveChanges
  39131. */
  39132. var ColumnSorting = function (_BasePlugin) {
  39133. _inherits(ColumnSorting, _BasePlugin);
  39134. function ColumnSorting(hotInstance) {
  39135. _classCallCheck(this, ColumnSorting);
  39136. var _this2 = _possibleConstructorReturn(this, (ColumnSorting.__proto__ || Object.getPrototypeOf(ColumnSorting)).call(this, hotInstance));
  39137. _this2.sortIndicators = [];
  39138. _this2.lastSortedColumn = null;
  39139. _this2.sortEmptyCells = false;
  39140. return _this2;
  39141. }
  39142. /**
  39143. * Check if the plugin is enabled in the handsontable settings.
  39144. *
  39145. * @returns {Boolean}
  39146. */
  39147. _createClass(ColumnSorting, [{
  39148. key: 'isEnabled',
  39149. value: function isEnabled() {
  39150. return !!this.hot.getSettings().columnSorting;
  39151. }
  39152. /**
  39153. * Enable plugin for this Handsontable instance.
  39154. */
  39155. }, {
  39156. key: 'enablePlugin',
  39157. value: function enablePlugin() {
  39158. var _this3 = this;
  39159. if (this.enabled) {
  39160. return;
  39161. }
  39162. this.setPluginOptions();
  39163. var _this = this;
  39164. this.hot.sortIndex = [];
  39165. this.hot.sort = function () {
  39166. var args = Array.prototype.slice.call(arguments);
  39167. return _this.sortByColumn.apply(_this, _toConsumableArray(args));
  39168. };
  39169. if (typeof this.hot.getSettings().observeChanges === 'undefined') {
  39170. this.enableObserveChangesPlugin();
  39171. }
  39172. this.addHook('afterTrimRow', function (row) {
  39173. return _this3.sort();
  39174. });
  39175. this.addHook('afterUntrimRow', function (row) {
  39176. return _this3.sort();
  39177. });
  39178. this.addHook('modifyRow', function (row) {
  39179. return _this3.translateRow(row);
  39180. });
  39181. this.addHook('unmodifyRow', function (row) {
  39182. return _this3.untranslateRow(row);
  39183. });
  39184. this.addHook('afterUpdateSettings', function () {
  39185. return _this3.onAfterUpdateSettings();
  39186. });
  39187. this.addHook('afterGetColHeader', function (col, TH) {
  39188. return _this3.getColHeader(col, TH);
  39189. });
  39190. this.addHook('afterOnCellMouseDown', function (event, target) {
  39191. return _this3.onAfterOnCellMouseDown(event, target);
  39192. });
  39193. this.addHook('afterCreateRow', function () {
  39194. _this.afterCreateRow.apply(_this, arguments);
  39195. });
  39196. this.addHook('afterRemoveRow', function () {
  39197. _this.afterRemoveRow.apply(_this, arguments);
  39198. });
  39199. this.addHook('afterInit', function () {
  39200. return _this3.sortBySettings();
  39201. });
  39202. this.addHook('afterLoadData', function () {
  39203. _this3.hot.sortIndex = [];
  39204. if (_this3.hot.view) {
  39205. _this3.sortBySettings();
  39206. }
  39207. });
  39208. if (this.hot.view) {
  39209. this.sortBySettings();
  39210. }
  39211. _get(ColumnSorting.prototype.__proto__ || Object.getPrototypeOf(ColumnSorting.prototype), 'enablePlugin', this).call(this);
  39212. }
  39213. /**
  39214. * Disable plugin for this Handsontable instance.
  39215. */
  39216. }, {
  39217. key: 'disablePlugin',
  39218. value: function disablePlugin() {
  39219. this.hot.sort = void 0;
  39220. _get(ColumnSorting.prototype.__proto__ || Object.getPrototypeOf(ColumnSorting.prototype), 'disablePlugin', this).call(this);
  39221. }
  39222. /**
  39223. * afterUpdateSettings callback.
  39224. *
  39225. * @private
  39226. */
  39227. }, {
  39228. key: 'onAfterUpdateSettings',
  39229. value: function onAfterUpdateSettings() {
  39230. this.sortBySettings();
  39231. }
  39232. }, {
  39233. key: 'sortBySettings',
  39234. value: function sortBySettings() {
  39235. var sortingSettings = this.hot.getSettings().columnSorting;
  39236. var loadedSortingState = this.loadSortingState();
  39237. var sortingColumn = void 0;
  39238. var sortingOrder = void 0;
  39239. if (typeof loadedSortingState === 'undefined') {
  39240. sortingColumn = sortingSettings.column;
  39241. sortingOrder = sortingSettings.sortOrder;
  39242. } else {
  39243. sortingColumn = loadedSortingState.sortColumn;
  39244. sortingOrder = loadedSortingState.sortOrder;
  39245. }
  39246. if (typeof sortingColumn === 'number') {
  39247. this.lastSortedColumn = sortingColumn;
  39248. this.sortByColumn(sortingColumn, sortingOrder);
  39249. }
  39250. }
  39251. /**
  39252. * Set sorted column and order info
  39253. *
  39254. * @param {number} col Sorted visual column index.
  39255. * @param {boolean|undefined} order Sorting order (`true` for ascending, `false` for descending).
  39256. */
  39257. }, {
  39258. key: 'setSortingColumn',
  39259. value: function setSortingColumn(col, order) {
  39260. if (typeof col == 'undefined') {
  39261. this.hot.sortColumn = void 0;
  39262. this.hot.sortOrder = void 0;
  39263. return;
  39264. } else if (this.hot.sortColumn === col && typeof order == 'undefined') {
  39265. if (this.hot.sortOrder === false) {
  39266. this.hot.sortOrder = void 0;
  39267. } else {
  39268. this.hot.sortOrder = !this.hot.sortOrder;
  39269. }
  39270. } else {
  39271. this.hot.sortOrder = typeof order === 'undefined' ? true : order;
  39272. }
  39273. this.hot.sortColumn = col;
  39274. }
  39275. }, {
  39276. key: 'sortByColumn',
  39277. value: function sortByColumn(col, order) {
  39278. this.setSortingColumn(col, order);
  39279. if (typeof this.hot.sortColumn == 'undefined') {
  39280. return;
  39281. }
  39282. var allowSorting = this.hot.runHooks('beforeColumnSort', this.hot.sortColumn, this.hot.sortOrder);
  39283. if (allowSorting !== false) {
  39284. this.sort();
  39285. }
  39286. this.updateOrderClass();
  39287. this.updateSortIndicator();
  39288. this.hot.runHooks('afterColumnSort', this.hot.sortColumn, this.hot.sortOrder);
  39289. this.hot.render();
  39290. this.saveSortingState();
  39291. }
  39292. /**
  39293. * Save the sorting state
  39294. */
  39295. }, {
  39296. key: 'saveSortingState',
  39297. value: function saveSortingState() {
  39298. var sortingState = {};
  39299. if (typeof this.hot.sortColumn != 'undefined') {
  39300. sortingState.sortColumn = this.hot.sortColumn;
  39301. }
  39302. if (typeof this.hot.sortOrder != 'undefined') {
  39303. sortingState.sortOrder = this.hot.sortOrder;
  39304. }
  39305. if ((0, _object.hasOwnProperty)(sortingState, 'sortColumn') || (0, _object.hasOwnProperty)(sortingState, 'sortOrder')) {
  39306. this.hot.runHooks('persistentStateSave', 'columnSorting', sortingState);
  39307. }
  39308. }
  39309. /**
  39310. * Load the sorting state.
  39311. *
  39312. * @returns {*} Previously saved sorting state.
  39313. */
  39314. }, {
  39315. key: 'loadSortingState',
  39316. value: function loadSortingState() {
  39317. var storedState = {};
  39318. this.hot.runHooks('persistentStateLoad', 'columnSorting', storedState);
  39319. return storedState.value;
  39320. }
  39321. /**
  39322. * Update sorting class name state.
  39323. */
  39324. }, {
  39325. key: 'updateOrderClass',
  39326. value: function updateOrderClass() {
  39327. var orderClass = void 0;
  39328. if (this.hot.sortOrder === true) {
  39329. orderClass = 'ascending';
  39330. } else if (this.hot.sortOrder === false) {
  39331. orderClass = 'descending';
  39332. }
  39333. this.sortOrderClass = orderClass;
  39334. }
  39335. }, {
  39336. key: 'enableObserveChangesPlugin',
  39337. value: function enableObserveChangesPlugin() {
  39338. var _this = this;
  39339. this.hot._registerTimeout(setTimeout(function () {
  39340. _this.hot.updateSettings({
  39341. observeChanges: true
  39342. });
  39343. }, 0));
  39344. }
  39345. /**
  39346. * Default sorting algorithm.
  39347. *
  39348. * @param {Boolean} sortOrder Sorting order - `true` for ascending, `false` for descending.
  39349. * @param {Object} columnMeta Column meta object.
  39350. * @returns {Function} The comparing function.
  39351. */
  39352. }, {
  39353. key: 'defaultSort',
  39354. value: function defaultSort(sortOrder, columnMeta) {
  39355. return function (a, b) {
  39356. if (typeof a[1] == 'string') {
  39357. a[1] = a[1].toLowerCase();
  39358. }
  39359. if (typeof b[1] == 'string') {
  39360. b[1] = b[1].toLowerCase();
  39361. }
  39362. if (a[1] === b[1]) {
  39363. return 0;
  39364. }
  39365. if ((0, _mixed.isEmpty)(a[1])) {
  39366. if ((0, _mixed.isEmpty)(b[1])) {
  39367. return 0;
  39368. }
  39369. if (columnMeta.columnSorting.sortEmptyCells) {
  39370. return sortOrder ? -1 : 1;
  39371. }
  39372. return 1;
  39373. }
  39374. if ((0, _mixed.isEmpty)(b[1])) {
  39375. if ((0, _mixed.isEmpty)(a[1])) {
  39376. return 0;
  39377. }
  39378. if (columnMeta.columnSorting.sortEmptyCells) {
  39379. return sortOrder ? 1 : -1;
  39380. }
  39381. return -1;
  39382. }
  39383. if (isNaN(a[1]) && !isNaN(b[1])) {
  39384. return sortOrder ? 1 : -1;
  39385. } else if (!isNaN(a[1]) && isNaN(b[1])) {
  39386. return sortOrder ? -1 : 1;
  39387. } else if (!(isNaN(a[1]) || isNaN(b[1]))) {
  39388. a[1] = parseFloat(a[1]);
  39389. b[1] = parseFloat(b[1]);
  39390. }
  39391. if (a[1] < b[1]) {
  39392. return sortOrder ? -1 : 1;
  39393. }
  39394. if (a[1] > b[1]) {
  39395. return sortOrder ? 1 : -1;
  39396. }
  39397. return 0;
  39398. };
  39399. }
  39400. /**
  39401. * Date sorting algorithm
  39402. * @param {Boolean} sortOrder Sorting order (`true` for ascending, `false` for descending).
  39403. * @param {Object} columnMeta Column meta object.
  39404. * @returns {Function} The compare function.
  39405. */
  39406. }, {
  39407. key: 'dateSort',
  39408. value: function dateSort(sortOrder, columnMeta) {
  39409. return function (a, b) {
  39410. if (a[1] === b[1]) {
  39411. return 0;
  39412. }
  39413. if ((0, _mixed.isEmpty)(a[1])) {
  39414. if ((0, _mixed.isEmpty)(b[1])) {
  39415. return 0;
  39416. }
  39417. if (columnMeta.columnSorting.sortEmptyCells) {
  39418. return sortOrder ? -1 : 1;
  39419. }
  39420. return 1;
  39421. }
  39422. if ((0, _mixed.isEmpty)(b[1])) {
  39423. if ((0, _mixed.isEmpty)(a[1])) {
  39424. return 0;
  39425. }
  39426. if (columnMeta.columnSorting.sortEmptyCells) {
  39427. return sortOrder ? 1 : -1;
  39428. }
  39429. return -1;
  39430. }
  39431. var aDate = (0, _moment2.default)(a[1], columnMeta.dateFormat);
  39432. var bDate = (0, _moment2.default)(b[1], columnMeta.dateFormat);
  39433. if (!aDate.isValid()) {
  39434. return 1;
  39435. }
  39436. if (!bDate.isValid()) {
  39437. return -1;
  39438. }
  39439. if (bDate.isAfter(aDate)) {
  39440. return sortOrder ? -1 : 1;
  39441. }
  39442. if (bDate.isBefore(aDate)) {
  39443. return sortOrder ? 1 : -1;
  39444. }
  39445. return 0;
  39446. };
  39447. }
  39448. /**
  39449. * Numeric sorting algorithm.
  39450. *
  39451. * @param {Boolean} sortOrder Sorting order (`true` for ascending, `false` for descending).
  39452. * @param {Object} columnMeta Column meta object.
  39453. * @returns {Function} The compare function.
  39454. */
  39455. }, {
  39456. key: 'numericSort',
  39457. value: function numericSort(sortOrder, columnMeta) {
  39458. return function (a, b) {
  39459. var parsedA = parseFloat(a[1]);
  39460. var parsedB = parseFloat(b[1]);
  39461. // Watch out when changing this part of code!
  39462. // Check below returns 0 (as expected) when comparing empty string, null, undefined
  39463. if (parsedA === parsedB || isNaN(parsedA) && isNaN(parsedB)) {
  39464. return 0;
  39465. }
  39466. if (columnMeta.columnSorting.sortEmptyCells) {
  39467. if ((0, _mixed.isEmpty)(a[1])) {
  39468. return sortOrder ? -1 : 1;
  39469. }
  39470. if ((0, _mixed.isEmpty)(b[1])) {
  39471. return sortOrder ? 1 : -1;
  39472. }
  39473. }
  39474. if (isNaN(parsedA)) {
  39475. return 1;
  39476. }
  39477. if (isNaN(parsedB)) {
  39478. return -1;
  39479. }
  39480. if (parsedA < parsedB) {
  39481. return sortOrder ? -1 : 1;
  39482. } else if (parsedA > parsedB) {
  39483. return sortOrder ? 1 : -1;
  39484. }
  39485. return 0;
  39486. };
  39487. }
  39488. /**
  39489. * Perform the sorting.
  39490. */
  39491. }, {
  39492. key: 'sort',
  39493. value: function sort() {
  39494. if (typeof this.hot.sortOrder == 'undefined') {
  39495. this.hot.sortIndex.length = 0;
  39496. return;
  39497. }
  39498. var colMeta = this.hot.getCellMeta(0, this.hot.sortColumn);
  39499. var emptyRows = this.hot.countEmptyRows();
  39500. var sortFunction = void 0;
  39501. var nrOfRows = void 0;
  39502. this.hot.sortingEnabled = false; // this is required by translateRow plugin hook
  39503. this.hot.sortIndex.length = 0;
  39504. if (typeof colMeta.columnSorting.sortEmptyCells === 'undefined') {
  39505. colMeta.columnSorting = { sortEmptyCells: this.sortEmptyCells };
  39506. }
  39507. if (this.hot.getSettings().maxRows === Number.POSITIVE_INFINITY) {
  39508. nrOfRows = this.hot.countRows() - this.hot.getSettings().minSpareRows;
  39509. } else {
  39510. nrOfRows = this.hot.countRows() - emptyRows;
  39511. }
  39512. for (var i = 0, ilen = nrOfRows; i < ilen; i++) {
  39513. this.hot.sortIndex.push([i, this.hot.getDataAtCell(i, this.hot.sortColumn)]);
  39514. }
  39515. if (colMeta.sortFunction) {
  39516. sortFunction = colMeta.sortFunction;
  39517. } else {
  39518. switch (colMeta.type) {
  39519. case 'date':
  39520. sortFunction = this.dateSort;
  39521. break;
  39522. case 'numeric':
  39523. sortFunction = this.numericSort;
  39524. break;
  39525. default:
  39526. sortFunction = this.defaultSort;
  39527. }
  39528. }
  39529. (0, _mergeSort2.default)(this.hot.sortIndex, sortFunction(this.hot.sortOrder, colMeta));
  39530. // Append spareRows
  39531. for (var _i = this.hot.sortIndex.length; _i < this.hot.countRows(); _i++) {
  39532. this.hot.sortIndex.push([_i, this.hot.getDataAtCell(_i, this.hot.sortColumn)]);
  39533. }
  39534. this.hot.sortingEnabled = true; // this is required by translateRow plugin hook
  39535. }
  39536. /**
  39537. * Update indicator states.
  39538. */
  39539. }, {
  39540. key: 'updateSortIndicator',
  39541. value: function updateSortIndicator() {
  39542. if (typeof this.hot.sortOrder == 'undefined') {
  39543. return;
  39544. }
  39545. var colMeta = this.hot.getCellMeta(0, this.hot.sortColumn);
  39546. this.sortIndicators[this.hot.sortColumn] = colMeta.sortIndicator;
  39547. }
  39548. /**
  39549. * `modifyRow` hook callback. Translates physical row index to the sorted row index.
  39550. *
  39551. * @param {Number} row Row index.
  39552. * @returns {Number} Sorted row index.
  39553. */
  39554. }, {
  39555. key: 'translateRow',
  39556. value: function translateRow(row) {
  39557. if (this.hot.sortingEnabled && typeof this.hot.sortOrder !== 'undefined' && this.hot.sortIndex && this.hot.sortIndex.length && this.hot.sortIndex[row]) {
  39558. return this.hot.sortIndex[row][0];
  39559. }
  39560. return row;
  39561. }
  39562. /**
  39563. * Translates sorted row index to physical row index.
  39564. *
  39565. * @param {Number} row Sorted (visual) row index.
  39566. * @returns {number} Physical row index.
  39567. */
  39568. }, {
  39569. key: 'untranslateRow',
  39570. value: function untranslateRow(row) {
  39571. if (this.hot.sortingEnabled && this.hot.sortIndex && this.hot.sortIndex.length) {
  39572. for (var i = 0; i < this.hot.sortIndex.length; i++) {
  39573. if (this.hot.sortIndex[i][0] == row) {
  39574. return i;
  39575. }
  39576. }
  39577. }
  39578. }
  39579. /**
  39580. * `afterGetColHeader` callback. Adds column sorting css classes to clickable headers.
  39581. *
  39582. * @private
  39583. * @param {Number} col Visual column index.
  39584. * @param {Element} TH TH HTML element.
  39585. */
  39586. }, {
  39587. key: 'getColHeader',
  39588. value: function getColHeader(col, TH) {
  39589. if (col < 0 || !TH.parentNode) {
  39590. return false;
  39591. }
  39592. var headerLink = TH.querySelector('.colHeader');
  39593. var colspan = TH.getAttribute('colspan');
  39594. var TRs = TH.parentNode.parentNode.childNodes;
  39595. var headerLevel = Array.prototype.indexOf.call(TRs, TH.parentNode);
  39596. headerLevel -= TRs.length;
  39597. if (!headerLink) {
  39598. return;
  39599. }
  39600. if (this.hot.getSettings().columnSorting && col >= 0 && headerLevel === -1) {
  39601. (0, _element.addClass)(headerLink, 'columnSorting');
  39602. }
  39603. (0, _element.removeClass)(headerLink, 'descending');
  39604. (0, _element.removeClass)(headerLink, 'ascending');
  39605. if (this.sortIndicators[col]) {
  39606. if (col === this.hot.sortColumn) {
  39607. if (this.sortOrderClass === 'ascending') {
  39608. (0, _element.addClass)(headerLink, 'ascending');
  39609. } else if (this.sortOrderClass === 'descending') {
  39610. (0, _element.addClass)(headerLink, 'descending');
  39611. }
  39612. }
  39613. }
  39614. }
  39615. /**
  39616. * Check if any column is in a sorted state.
  39617. *
  39618. * @returns {Boolean}
  39619. */
  39620. }, {
  39621. key: 'isSorted',
  39622. value: function isSorted() {
  39623. return typeof this.hot.sortColumn != 'undefined';
  39624. }
  39625. /**
  39626. * `afterCreateRow` callback. Updates the sorting state after a row have been created.
  39627. *
  39628. * @private
  39629. * @param {Number} index Visual row index.
  39630. * @param {Number} amount
  39631. */
  39632. }, {
  39633. key: 'afterCreateRow',
  39634. value: function afterCreateRow(index, amount) {
  39635. if (!this.isSorted()) {
  39636. return;
  39637. }
  39638. for (var i = 0; i < this.hot.sortIndex.length; i++) {
  39639. if (this.hot.sortIndex[i][0] >= index) {
  39640. this.hot.sortIndex[i][0] += amount;
  39641. }
  39642. }
  39643. for (var _i2 = 0; _i2 < amount; _i2++) {
  39644. this.hot.sortIndex.splice(index + _i2, 0, [index + _i2, this.hot.getSourceData()[index + _i2][this.hot.sortColumn + this.hot.colOffset()]]);
  39645. }
  39646. this.saveSortingState();
  39647. }
  39648. /**
  39649. * `afterRemoveRow` hook callback.
  39650. *
  39651. * @private
  39652. * @param {Number} index Visual row index.
  39653. * @param {Number} amount
  39654. */
  39655. }, {
  39656. key: 'afterRemoveRow',
  39657. value: function afterRemoveRow(index, amount) {
  39658. if (!this.isSorted()) {
  39659. return;
  39660. }
  39661. var removedRows = this.hot.sortIndex.splice(index, amount);
  39662. removedRows = (0, _array.arrayMap)(removedRows, function (row) {
  39663. return row[0];
  39664. });
  39665. function countRowShift(logicalRow) {
  39666. // Todo: compare perf between reduce vs sort->each->brake
  39667. return (0, _array.arrayReduce)(removedRows, function (count, removedLogicalRow) {
  39668. if (logicalRow > removedLogicalRow) {
  39669. count++;
  39670. }
  39671. return count;
  39672. }, 0);
  39673. }
  39674. this.hot.sortIndex = (0, _array.arrayMap)(this.hot.sortIndex, function (logicalRow, physicalRow) {
  39675. var rowShift = countRowShift(logicalRow[0]);
  39676. if (rowShift) {
  39677. logicalRow[0] -= rowShift;
  39678. }
  39679. return logicalRow;
  39680. });
  39681. this.saveSortingState();
  39682. }
  39683. /**
  39684. * Set options by passed settings
  39685. *
  39686. * @private
  39687. */
  39688. }, {
  39689. key: 'setPluginOptions',
  39690. value: function setPluginOptions() {
  39691. var columnSorting = this.hot.getSettings().columnSorting;
  39692. if ((typeof columnSorting === 'undefined' ? 'undefined' : _typeof(columnSorting)) === 'object') {
  39693. this.sortEmptyCells = columnSorting.sortEmptyCells || false;
  39694. } else {
  39695. this.sortEmptyCells = false;
  39696. }
  39697. }
  39698. /**
  39699. * `onAfterOnCellMouseDown` hook callback.
  39700. *
  39701. * @private
  39702. * @param {Event} event Event which are provided by hook.
  39703. * @param {CellCoords} coords Visual coords of the selected cell.
  39704. */
  39705. }, {
  39706. key: 'onAfterOnCellMouseDown',
  39707. value: function onAfterOnCellMouseDown(event, coords) {
  39708. if (coords.row > -1) {
  39709. return;
  39710. }
  39711. if ((0, _element.hasClass)(event.realTarget, 'columnSorting')) {
  39712. // reset order state on every new column header click
  39713. if (coords.col !== this.lastSortedColumn) {
  39714. this.hot.sortOrder = true;
  39715. }
  39716. this.lastSortedColumn = coords.col;
  39717. this.sortByColumn(coords.col);
  39718. }
  39719. }
  39720. }]);
  39721. return ColumnSorting;
  39722. }(_base2.default);
  39723. (0, _plugins.registerPlugin)('columnSorting', ColumnSorting);
  39724. exports.default = ColumnSorting;
  39725. /***/ }),
  39726. /* 413 */
  39727. /***/ (function(module, exports, __webpack_require__) {
  39728. "use strict";
  39729. exports.__esModule = true;
  39730. exports.default = mergeSort;
  39731. exports.merge = merge;
  39732. var _linkedList = __webpack_require__(414);
  39733. var _linkedList2 = _interopRequireDefault(_linkedList);
  39734. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  39735. /**
  39736. * Refactored implementation of mergeSort (part of javascript-algorithms project) by Github users:
  39737. * mgechev, AndriiHeonia and lekkas (part of javascript-algorithms project - all project contributors
  39738. * at repository website)
  39739. *
  39740. * Link to repository: https://github.com/mgechev/javascript-algorithms
  39741. */
  39742. /**
  39743. * Specifies a function that defines the sort order. The array is sorted according to each
  39744. * character's Unicode code point value, according to the string conversion of each element.
  39745. *
  39746. * @param a {*} first compared element.
  39747. * @param b {*} second compared element.
  39748. * @returns {Number}
  39749. */
  39750. var defaultCompareFunction = function defaultCompareFunction(a, b) {
  39751. // sort lexically
  39752. var firstValue = a.toString();
  39753. var secondValue = b.toString();
  39754. if (firstValue === secondValue) {
  39755. return 0;
  39756. } else if (firstValue < secondValue) {
  39757. return -1;
  39758. }
  39759. return 1;
  39760. };
  39761. /**
  39762. * Mergesort method which is recursively called for sorting the input array.
  39763. *
  39764. * @param {Array} array The array which should be sorted.
  39765. * @param {Function} compareFunction Compares two items in an array. If compareFunction is not supplied,
  39766. * elements are sorted by converting them to strings and comparing strings in Unicode code point order.
  39767. * @param {Number} startIndex Left side of the subarray.
  39768. * @param {Number} endIndex Right side of the subarray.
  39769. * @returns {Array} Array with sorted subarray.
  39770. */
  39771. function mergeSort(array) {
  39772. var compareFunction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultCompareFunction;
  39773. var startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  39774. var endIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : array.length;
  39775. if (Math.abs(endIndex - startIndex) <= 1) {
  39776. return [];
  39777. }
  39778. var middleIndex = Math.ceil((startIndex + endIndex) / 2);
  39779. mergeSort(array, compareFunction, startIndex, middleIndex);
  39780. mergeSort(array, compareFunction, middleIndex, endIndex);
  39781. return merge(array, compareFunction, startIndex, middleIndex, endIndex);
  39782. }
  39783. /**
  39784. * Devides and sort merges two subarrays of given array
  39785. *
  39786. * @param {Array} array The array which subarrays should be sorted.
  39787. * @param {Number} startIndex The start of the first subarray.
  39788. * This subarray is with end middle - 1.
  39789. * @param {Number} middleIndex The start of the second array.
  39790. * @param {Number} endIndex end - 1 is the end of the second array.
  39791. * @returns {Array} The array with sorted subarray.
  39792. */
  39793. function merge(array, compareFunction, startIndex, middleIndex, endIndex) {
  39794. var leftElements = new _linkedList2.default();
  39795. var rightElements = new _linkedList2.default();
  39796. var leftSize = middleIndex - startIndex;
  39797. var rightSize = endIndex - middleIndex;
  39798. var maxSize = Math.max(leftSize, rightSize);
  39799. var size = endIndex - startIndex;
  39800. for (var _i = 0; _i < maxSize; _i += 1) {
  39801. if (_i < leftSize) {
  39802. leftElements.push(array[startIndex + _i]);
  39803. }
  39804. if (_i < rightSize) {
  39805. rightElements.push(array[middleIndex + _i]);
  39806. }
  39807. }
  39808. var i = 0;
  39809. while (i < size) {
  39810. if (leftElements.first && rightElements.first) {
  39811. if (compareFunction(leftElements.first.data, rightElements.first.data) > 0) {
  39812. array[startIndex + i] = rightElements.shift().data;
  39813. } else {
  39814. array[startIndex + i] = leftElements.shift().data;
  39815. }
  39816. } else if (leftElements.first) {
  39817. array[startIndex + i] = leftElements.shift().data;
  39818. } else {
  39819. array[startIndex + i] = rightElements.shift().data;
  39820. }
  39821. i += 1;
  39822. }
  39823. return array;
  39824. };
  39825. /***/ }),
  39826. /* 414 */
  39827. /***/ (function(module, exports, __webpack_require__) {
  39828. "use strict";
  39829. exports.__esModule = true;
  39830. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  39831. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  39832. /**
  39833. * Refactored implementation of LinkedList (part of javascript-algorithms project) by Github users:
  39834. * mgechev, AndriiHeonia, Microfed and Jakeh (part of javascript-algorithms project - all project contributors
  39835. * at repository website)
  39836. *
  39837. * Link to repository: https://github.com/mgechev/javascript-algorithms
  39838. */
  39839. /**
  39840. * Linked list node.
  39841. *
  39842. * @class NodeStructure
  39843. * @util
  39844. */
  39845. var NodeStructure = function NodeStructure(data) {
  39846. _classCallCheck(this, NodeStructure);
  39847. /**
  39848. * Data of the node.
  39849. * @member {Object}
  39850. */
  39851. this.data = data;
  39852. /**
  39853. * Next node.
  39854. * @member {NodeStructure}
  39855. */
  39856. this.next = null;
  39857. /**
  39858. * Previous node.
  39859. * @member {NodeStructure}
  39860. */
  39861. this.prev = null;
  39862. };
  39863. /**
  39864. * Linked list.
  39865. *
  39866. * @class LinkedList
  39867. * @util
  39868. */
  39869. var LinkedList = function () {
  39870. function LinkedList() {
  39871. _classCallCheck(this, LinkedList);
  39872. this.first = null;
  39873. this.last = null;
  39874. }
  39875. /**
  39876. * Add data to the end of linked list.
  39877. *
  39878. * @param {Object} data Data which should be added.
  39879. */
  39880. _createClass(LinkedList, [{
  39881. key: "push",
  39882. value: function push(data) {
  39883. var node = new NodeStructure(data);
  39884. if (this.first === null) {
  39885. this.first = node;
  39886. this.last = node;
  39887. } else {
  39888. var temp = this.last;
  39889. this.last = node;
  39890. node.prev = temp;
  39891. temp.next = node;
  39892. }
  39893. }
  39894. /**
  39895. * Add data to the beginning of linked list.
  39896. *
  39897. * @param {Object} data Data which should be added.
  39898. */
  39899. }, {
  39900. key: "unshift",
  39901. value: function unshift(data) {
  39902. var node = new NodeStructure(data);
  39903. if (this.first === null) {
  39904. this.first = node;
  39905. this.last = node;
  39906. } else {
  39907. var temp = this.first;
  39908. this.first = node;
  39909. node.next = temp;
  39910. temp.prev = node;
  39911. }
  39912. }
  39913. /**
  39914. * In order traversal of the linked list.
  39915. *
  39916. * @param {Function} callback Callback which should be executed on each node.
  39917. */
  39918. }, {
  39919. key: "inorder",
  39920. value: function inorder(callback) {
  39921. var temp = this.first;
  39922. while (temp) {
  39923. callback(temp);
  39924. temp = temp.next;
  39925. }
  39926. }
  39927. /**
  39928. * Remove data from the linked list.
  39929. *
  39930. * @param {Object} data Data which should be removed.
  39931. * @returns {Boolean} Returns true if data has been removed.
  39932. */
  39933. }, {
  39934. key: "remove",
  39935. value: function remove(data) {
  39936. if (this.first === null) {
  39937. return false;
  39938. }
  39939. var temp = this.first;
  39940. var next = void 0;
  39941. var prev = void 0;
  39942. while (temp) {
  39943. if (temp.data === data) {
  39944. next = temp.next;
  39945. prev = temp.prev;
  39946. if (next) {
  39947. next.prev = prev;
  39948. }
  39949. if (prev) {
  39950. prev.next = next;
  39951. }
  39952. if (temp === this.first) {
  39953. this.first = next;
  39954. }
  39955. if (temp === this.last) {
  39956. this.last = prev;
  39957. }
  39958. return true;
  39959. }
  39960. temp = temp.next;
  39961. }
  39962. return false;
  39963. }
  39964. /**
  39965. * Check if linked list contains cycle.
  39966. *
  39967. * @returns {Boolean} Returns true if linked list contains cycle.
  39968. */
  39969. }, {
  39970. key: "hasCycle",
  39971. value: function hasCycle() {
  39972. var fast = this.first;
  39973. var slow = this.first;
  39974. while (true) {
  39975. if (fast === null) {
  39976. return false;
  39977. }
  39978. fast = fast.next;
  39979. if (fast === null) {
  39980. return false;
  39981. }
  39982. fast = fast.next;
  39983. slow = slow.next;
  39984. if (fast === slow) {
  39985. return true;
  39986. }
  39987. }
  39988. }
  39989. }, {
  39990. key: "pop",
  39991. /**
  39992. * Return last node from the linked list.
  39993. *
  39994. * @returns {NodeStructure} Last node.
  39995. */
  39996. value: function pop() {
  39997. if (this.last === null) {
  39998. return null;
  39999. }
  40000. var temp = this.last;
  40001. this.last = this.last.prev;
  40002. return temp;
  40003. }
  40004. }, {
  40005. key: "shift",
  40006. /**
  40007. * Return first node from the linked list.
  40008. *
  40009. * @returns {NodeStructure} First node.
  40010. */
  40011. value: function shift() {
  40012. if (this.first === null) {
  40013. return null;
  40014. }
  40015. var temp = this.first;
  40016. this.first = this.first.next;
  40017. return temp;
  40018. }
  40019. }, {
  40020. key: "recursiveReverse",
  40021. /**
  40022. * Reverses the linked list recursively
  40023. */
  40024. value: function recursiveReverse() {
  40025. function inverse(current, next) {
  40026. if (!next) {
  40027. return;
  40028. }
  40029. inverse(next, next.next);
  40030. next.next = current;
  40031. }
  40032. if (!this.first) {
  40033. return;
  40034. }
  40035. inverse(this.first, this.first.next);
  40036. this.first.next = null;
  40037. var temp = this.first;
  40038. this.first = this.last;
  40039. this.last = temp;
  40040. }
  40041. }, {
  40042. key: "reverse",
  40043. /**
  40044. * Reverses the linked list iteratively
  40045. */
  40046. value: function reverse() {
  40047. if (!this.first || !this.first.next) {
  40048. return;
  40049. }
  40050. var current = this.first.next;
  40051. var prev = this.first;
  40052. var temp = void 0;
  40053. while (current) {
  40054. temp = current.next;
  40055. current.next = prev;
  40056. prev.prev = current;
  40057. prev = current;
  40058. current = temp;
  40059. }
  40060. this.first.next = null;
  40061. this.last.prev = null;
  40062. temp = this.first;
  40063. this.first = prev;
  40064. this.last = temp;
  40065. }
  40066. }]);
  40067. return LinkedList;
  40068. }();
  40069. ;
  40070. exports.NodeStructure = NodeStructure;
  40071. exports.default = LinkedList;
  40072. /***/ }),
  40073. /* 415 */
  40074. /***/ (function(module, exports, __webpack_require__) {
  40075. "use strict";
  40076. exports.__esModule = true;
  40077. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  40078. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  40079. var _element = __webpack_require__(0);
  40080. var _object = __webpack_require__(2);
  40081. var _eventManager = __webpack_require__(6);
  40082. var _eventManager2 = _interopRequireDefault(_eventManager);
  40083. var _src = __webpack_require__(4);
  40084. var _plugins = __webpack_require__(8);
  40085. var _base = __webpack_require__(10);
  40086. var _base2 = _interopRequireDefault(_base);
  40087. var _commentEditor = __webpack_require__(416);
  40088. var _commentEditor2 = _interopRequireDefault(_commentEditor);
  40089. var _utils = __webpack_require__(19);
  40090. var _displaySwitch = __webpack_require__(417);
  40091. var _displaySwitch2 = _interopRequireDefault(_displaySwitch);
  40092. var _constants = __webpack_require__(7);
  40093. var C = _interopRequireWildcard(_constants);
  40094. __webpack_require__(418);
  40095. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  40096. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  40097. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  40098. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  40099. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  40100. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  40101. var privatePool = new WeakMap();
  40102. var META_COMMENT = 'comment';
  40103. var META_COMMENT_VALUE = 'value';
  40104. var META_STYLE = 'style';
  40105. var META_READONLY = 'readOnly';
  40106. /**
  40107. * @plugin Comments
  40108. *
  40109. * @description
  40110. * This plugin allows setting and managing cell comments by either an option in the context menu or with the use of the API.
  40111. *
  40112. * To enable the plugin, you'll need to set the comments property of the config object to `true`:
  40113. * ```js
  40114. * ...
  40115. * comments: true
  40116. * ...
  40117. * ```
  40118. *
  40119. * or object with extra predefined plugin config:
  40120. *
  40121. * ```js
  40122. * ...
  40123. * comments: {
  40124. * displayDelay: 1000
  40125. * }
  40126. * ...
  40127. * ```
  40128. *
  40129. * To add comments at the table initialization, define the `comment` property in the `cell` config array as in an example below.
  40130. *
  40131. * @example
  40132. *
  40133. * ```js
  40134. * ...
  40135. * var hot = new Handsontable(document.getElementById('example'), {
  40136. * date: getData(),
  40137. * comments: true,
  40138. * cell: [
  40139. * {row: 1, col: 1, comment: {value: 'Foo'}},
  40140. * {row: 2, col: 2, comment: {value: 'Bar'}}
  40141. * ]
  40142. * });
  40143. *
  40144. * // Access to the Comments plugin instance:
  40145. * var commentsPlugin = hot.getPlugin('comments');
  40146. *
  40147. * // Manage comments programmatically:
  40148. * commentsPlugin.setCommentAtCell(1, 6, 'Comment contents');
  40149. * commentsPlugin.showAtCell(1, 6);
  40150. * commentsPlugin.removeCommentAtCell(1, 6);
  40151. *
  40152. * // You can also set range once and use proper methods:
  40153. * commentsPlugin.setRange({row: 1, col: 6});
  40154. * commentsPlugin.setComment('Comment contents');
  40155. * commentsPlugin.show();
  40156. * commentsPlugin.removeComment();
  40157. * ...
  40158. * ```
  40159. */
  40160. var Comments = function (_BasePlugin) {
  40161. _inherits(Comments, _BasePlugin);
  40162. function Comments(hotInstance) {
  40163. _classCallCheck(this, Comments);
  40164. /**
  40165. * Instance of {@link CommentEditor}.
  40166. *
  40167. * @type {CommentEditor}
  40168. */
  40169. var _this = _possibleConstructorReturn(this, (Comments.__proto__ || Object.getPrototypeOf(Comments)).call(this, hotInstance));
  40170. _this.editor = null;
  40171. /**
  40172. * Instance of {@link DisplaySwitch}.
  40173. *
  40174. * @type {DisplaySwitch}
  40175. */
  40176. _this.displaySwitch = null;
  40177. /**
  40178. * Instance of {@link EventManager}.
  40179. *
  40180. * @private
  40181. * @type {EventManager}
  40182. */
  40183. _this.eventManager = null;
  40184. /**
  40185. * Current cell range.
  40186. *
  40187. * @type {Object}
  40188. */
  40189. _this.range = {};
  40190. /**
  40191. * @private
  40192. * @type {Boolean}
  40193. */
  40194. _this.mouseDown = false;
  40195. /**
  40196. * @private
  40197. * @type {Boolean}
  40198. */
  40199. _this.contextMenuEvent = false;
  40200. /**
  40201. * @private
  40202. * @type {*}
  40203. */
  40204. _this.timer = null;
  40205. privatePool.set(_this, {
  40206. tempEditorDimensions: {},
  40207. cellBelowCursor: null
  40208. });
  40209. return _this;
  40210. }
  40211. /**
  40212. * Check if the plugin is enabled in the Handsontable settings.
  40213. *
  40214. * @returns {Boolean}
  40215. */
  40216. _createClass(Comments, [{
  40217. key: 'isEnabled',
  40218. value: function isEnabled() {
  40219. return !!this.hot.getSettings().comments;
  40220. }
  40221. /**
  40222. * Enable plugin for this Handsontable instance.
  40223. */
  40224. }, {
  40225. key: 'enablePlugin',
  40226. value: function enablePlugin() {
  40227. var _this2 = this;
  40228. if (this.enabled) {
  40229. return;
  40230. }
  40231. if (!this.editor) {
  40232. this.editor = new _commentEditor2.default();
  40233. }
  40234. if (!this.eventManager) {
  40235. this.eventManager = new _eventManager2.default(this);
  40236. }
  40237. if (!this.displaySwitch) {
  40238. this.displaySwitch = new _displaySwitch2.default(this.getDisplayDelaySetting());
  40239. }
  40240. this.addHook('afterContextMenuDefaultOptions', function (options) {
  40241. return _this2.addToContextMenu(options);
  40242. });
  40243. this.addHook('afterRenderer', function (TD, row, col, prop, value, cellProperties) {
  40244. return _this2.onAfterRenderer(TD, cellProperties);
  40245. });
  40246. this.addHook('afterScrollHorizontally', function () {
  40247. return _this2.hide();
  40248. });
  40249. this.addHook('afterScrollVertically', function () {
  40250. return _this2.hide();
  40251. });
  40252. this.addHook('afterBeginEditing', function (args) {
  40253. return _this2.onAfterBeginEditing(args);
  40254. });
  40255. this.displaySwitch.addLocalHook('hide', function () {
  40256. return _this2.hide();
  40257. });
  40258. this.displaySwitch.addLocalHook('show', function (row, col) {
  40259. return _this2.showAtCell(row, col);
  40260. });
  40261. this.registerListeners();
  40262. _get(Comments.prototype.__proto__ || Object.getPrototypeOf(Comments.prototype), 'enablePlugin', this).call(this);
  40263. }
  40264. /**
  40265. * Update plugin for this Handsontable instance.
  40266. */
  40267. }, {
  40268. key: 'updatePlugin',
  40269. value: function updatePlugin() {
  40270. this.disablePlugin();
  40271. this.enablePlugin();
  40272. _get(Comments.prototype.__proto__ || Object.getPrototypeOf(Comments.prototype), 'updatePlugin', this).call(this);
  40273. this.displaySwitch.updateDelay(this.getDisplayDelaySetting());
  40274. }
  40275. /**
  40276. * Disable plugin for this Handsontable instance.
  40277. */
  40278. }, {
  40279. key: 'disablePlugin',
  40280. value: function disablePlugin() {
  40281. _get(Comments.prototype.__proto__ || Object.getPrototypeOf(Comments.prototype), 'disablePlugin', this).call(this);
  40282. }
  40283. /**
  40284. * Register all necessary DOM listeners.
  40285. *
  40286. * @private
  40287. */
  40288. }, {
  40289. key: 'registerListeners',
  40290. value: function registerListeners() {
  40291. var _this3 = this;
  40292. this.eventManager.addEventListener(document, 'mouseover', function (event) {
  40293. return _this3.onMouseOver(event);
  40294. });
  40295. this.eventManager.addEventListener(document, 'mousedown', function (event) {
  40296. return _this3.onMouseDown(event);
  40297. });
  40298. this.eventManager.addEventListener(document, 'mouseup', function (event) {
  40299. return _this3.onMouseUp(event);
  40300. });
  40301. this.eventManager.addEventListener(this.editor.getInputElement(), 'blur', function (event) {
  40302. return _this3.onEditorBlur(event);
  40303. });
  40304. this.eventManager.addEventListener(this.editor.getInputElement(), 'mousedown', function (event) {
  40305. return _this3.onEditorMouseDown(event);
  40306. });
  40307. this.eventManager.addEventListener(this.editor.getInputElement(), 'mouseup', function (event) {
  40308. return _this3.onEditorMouseUp(event);
  40309. });
  40310. }
  40311. /**
  40312. * Set current cell range to be able to use general methods like {@link Comments#setComment},
  40313. * {@link Comments#removeComment}, {@link Comments#show}.
  40314. *
  40315. * @param {Object} range Object with `from` and `to` properties, each with `row` and `col` properties.
  40316. */
  40317. }, {
  40318. key: 'setRange',
  40319. value: function setRange(range) {
  40320. this.range = range;
  40321. }
  40322. /**
  40323. * Clear the currently selected cell.
  40324. */
  40325. }, {
  40326. key: 'clearRange',
  40327. value: function clearRange() {
  40328. this.range = {};
  40329. }
  40330. /**
  40331. * Check if the event target is a cell containing a comment.
  40332. *
  40333. * @param {Event} event DOM event
  40334. * @returns {Boolean}
  40335. */
  40336. }, {
  40337. key: 'targetIsCellWithComment',
  40338. value: function targetIsCellWithComment(event) {
  40339. var closestCell = (0, _element.closest)(event.target, 'TD', 'TBODY');
  40340. return !!(closestCell && (0, _element.hasClass)(closestCell, 'htCommentCell') && (0, _element.closest)(closestCell, [this.hot.rootElement]));
  40341. }
  40342. /**
  40343. * Check if the event target is a comment textarea.
  40344. *
  40345. * @param {Event} event DOM event.
  40346. * @returns {Boolean}
  40347. */
  40348. }, {
  40349. key: 'targetIsCommentTextArea',
  40350. value: function targetIsCommentTextArea(event) {
  40351. return this.editor.getInputElement() === event.target;
  40352. }
  40353. /**
  40354. * Set a comment for a cell according to the previously set range (see {@link Comments#setRange}).
  40355. *
  40356. * @param {String} value Comment contents.
  40357. */
  40358. }, {
  40359. key: 'setComment',
  40360. value: function setComment(value) {
  40361. if (!this.range.from) {
  40362. throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
  40363. }
  40364. var editorValue = this.editor.getValue();
  40365. var comment = '';
  40366. if (value != null) {
  40367. comment = value;
  40368. } else if (editorValue != null) {
  40369. comment = editorValue;
  40370. }
  40371. var row = this.range.from.row;
  40372. var col = this.range.from.col;
  40373. this.updateCommentMeta(row, col, _defineProperty({}, META_COMMENT_VALUE, comment));
  40374. this.hot.render();
  40375. }
  40376. /**
  40377. * Set a comment for a cell.
  40378. *
  40379. * @param {Number} row Visual row index.
  40380. * @param {Number} col Visual column index.
  40381. * @param {String} value Comment contents.
  40382. */
  40383. }, {
  40384. key: 'setCommentAtCell',
  40385. value: function setCommentAtCell(row, col, value) {
  40386. this.setRange({
  40387. from: new _src.CellCoords(row, col)
  40388. });
  40389. this.setComment(value);
  40390. }
  40391. /**
  40392. * Remove a comment from a cell according to previously set range (see {@link Comments#setRange}).
  40393. *
  40394. * @param {Boolean} [forceRender = true] If set to `true`, the table will be re-rendered at the end of the operation.
  40395. */
  40396. }, {
  40397. key: 'removeComment',
  40398. value: function removeComment() {
  40399. var forceRender = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  40400. if (!this.range.from) {
  40401. throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
  40402. }
  40403. this.hot.setCellMeta(this.range.from.row, this.range.from.col, META_COMMENT, void 0);
  40404. if (forceRender) {
  40405. this.hot.render();
  40406. }
  40407. this.hide();
  40408. }
  40409. /**
  40410. * Remove comment from a cell.
  40411. *
  40412. * @param {Number} row Visual row index.
  40413. * @param {Number} col Visual column index.
  40414. * @param {Boolean} [forceRender = true] If `true`, the table will be re-rendered at the end of the operation.
  40415. */
  40416. }, {
  40417. key: 'removeCommentAtCell',
  40418. value: function removeCommentAtCell(row, col) {
  40419. var forceRender = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  40420. this.setRange({
  40421. from: new _src.CellCoords(row, col)
  40422. });
  40423. this.removeComment(forceRender);
  40424. }
  40425. /**
  40426. * Get comment from a cell at the predefined range.
  40427. */
  40428. }, {
  40429. key: 'getComment',
  40430. value: function getComment() {
  40431. var row = this.range.from.row;
  40432. var column = this.range.from.col;
  40433. return this.getCommentMeta(row, column, META_COMMENT_VALUE);
  40434. }
  40435. /**
  40436. * Get comment from a cell at the provided coordinates.
  40437. *
  40438. * @param {Number} row Visual row index.
  40439. * @param {Number} column Visual column index.
  40440. */
  40441. }, {
  40442. key: 'getCommentAtCell',
  40443. value: function getCommentAtCell(row, column) {
  40444. return this.getCommentMeta(row, column, META_COMMENT_VALUE);
  40445. }
  40446. /**
  40447. * Show the comment editor accordingly to the previously set range (see {@link Comments#setRange}).
  40448. *
  40449. * @returns {Boolean} Returns `true` if comment editor was shown.
  40450. */
  40451. }, {
  40452. key: 'show',
  40453. value: function show() {
  40454. if (!this.range.from) {
  40455. throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
  40456. }
  40457. var meta = this.hot.getCellMeta(this.range.from.row, this.range.from.col);
  40458. this.refreshEditor(true);
  40459. this.editor.setValue(meta[META_COMMENT] ? meta[META_COMMENT][META_COMMENT_VALUE] : null || '');
  40460. if (this.editor.hidden) {
  40461. this.editor.show();
  40462. }
  40463. return true;
  40464. }
  40465. /**
  40466. * Show comment editor according to cell coordinates.
  40467. *
  40468. * @param {Number} row Visual row index.
  40469. * @param {Number} col Visual column index.
  40470. * @returns {Boolean} Returns `true` if comment editor was shown.
  40471. */
  40472. }, {
  40473. key: 'showAtCell',
  40474. value: function showAtCell(row, col) {
  40475. this.setRange({
  40476. from: new _src.CellCoords(row, col)
  40477. });
  40478. return this.show();
  40479. }
  40480. /**
  40481. * Hide the comment editor.
  40482. */
  40483. }, {
  40484. key: 'hide',
  40485. value: function hide() {
  40486. if (!this.editor.hidden) {
  40487. this.editor.hide();
  40488. }
  40489. }
  40490. /**
  40491. * Refresh comment editor position and styling.
  40492. *
  40493. * @param {Boolean} [force=false] If `true` then recalculation will be forced.
  40494. */
  40495. }, {
  40496. key: 'refreshEditor',
  40497. value: function refreshEditor() {
  40498. var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  40499. if (!force && (!this.range.from || !this.editor.isVisible())) {
  40500. return;
  40501. }
  40502. var scrollableElement = (0, _element.getScrollableElement)(this.hot.view.wt.wtTable.TABLE);
  40503. var TD = this.hot.view.wt.wtTable.getCell(this.range.from);
  40504. var row = this.range.from.row;
  40505. var column = this.range.from.col;
  40506. var cellOffset = (0, _element.offset)(TD);
  40507. var lastColWidth = this.hot.view.wt.wtTable.getStretchedColumnWidth(column);
  40508. var cellTopOffset = cellOffset.top < 0 ? 0 : cellOffset.top;
  40509. var cellLeftOffset = cellOffset.left;
  40510. if (this.hot.view.wt.wtViewport.hasVerticalScroll() && scrollableElement !== window) {
  40511. cellTopOffset -= this.hot.view.wt.wtOverlays.topOverlay.getScrollPosition();
  40512. }
  40513. if (this.hot.view.wt.wtViewport.hasHorizontalScroll() && scrollableElement !== window) {
  40514. cellLeftOffset -= this.hot.view.wt.wtOverlays.leftOverlay.getScrollPosition();
  40515. }
  40516. var x = cellLeftOffset + lastColWidth;
  40517. var y = cellTopOffset;
  40518. var commentStyle = this.getCommentMeta(row, column, META_STYLE);
  40519. var readOnly = this.getCommentMeta(row, column, META_READONLY);
  40520. if (commentStyle) {
  40521. this.editor.setSize(commentStyle.width, commentStyle.height);
  40522. } else {
  40523. this.editor.resetSize();
  40524. }
  40525. this.editor.setReadOnlyState(readOnly);
  40526. this.editor.setPosition(x, y);
  40527. }
  40528. /**
  40529. * Check if there is a comment for selected range.
  40530. *
  40531. * @private
  40532. * @returns {Boolean}
  40533. */
  40534. }, {
  40535. key: 'checkSelectionCommentsConsistency',
  40536. value: function checkSelectionCommentsConsistency() {
  40537. var selected = this.hot.getSelectedRangeLast();
  40538. if (!selected) {
  40539. return false;
  40540. }
  40541. var hasComment = false;
  40542. var cell = selected.from; // IN EXCEL THERE IS COMMENT ONLY FOR TOP LEFT CELL IN SELECTION
  40543. if (this.getCommentMeta(cell.row, cell.col, META_COMMENT_VALUE)) {
  40544. hasComment = true;
  40545. }
  40546. return hasComment;
  40547. }
  40548. /**
  40549. * Set or update the comment-related cell meta.
  40550. *
  40551. * @param {Number} row Visual row index.
  40552. * @param {Number} column Visual column index.
  40553. * @param {Object} metaObject Object defining all the comment-related meta information.
  40554. */
  40555. }, {
  40556. key: 'updateCommentMeta',
  40557. value: function updateCommentMeta(row, column, metaObject) {
  40558. var oldComment = this.hot.getCellMeta(row, column)[META_COMMENT];
  40559. var newComment = void 0;
  40560. if (oldComment) {
  40561. newComment = (0, _object.deepClone)(oldComment);
  40562. (0, _object.deepExtend)(newComment, metaObject);
  40563. } else {
  40564. newComment = metaObject;
  40565. }
  40566. this.hot.setCellMeta(row, column, META_COMMENT, newComment);
  40567. }
  40568. /**
  40569. * Get the comment related meta information.
  40570. *
  40571. * @param {Number} row Visual row index.
  40572. * @param {Number} column Visual column index.
  40573. * @param {String} property Cell meta property.
  40574. * @returns {Mixed}
  40575. */
  40576. }, {
  40577. key: 'getCommentMeta',
  40578. value: function getCommentMeta(row, column, property) {
  40579. var cellMeta = this.hot.getCellMeta(row, column);
  40580. if (!cellMeta[META_COMMENT]) {
  40581. return void 0;
  40582. }
  40583. return cellMeta[META_COMMENT][property];
  40584. }
  40585. /**
  40586. * `mousedown` event callback.
  40587. *
  40588. * @private
  40589. * @param {MouseEvent} event The `mousedown` event.
  40590. */
  40591. }, {
  40592. key: 'onMouseDown',
  40593. value: function onMouseDown(event) {
  40594. this.mouseDown = true;
  40595. if (!this.hot.view || !this.hot.view.wt) {
  40596. return;
  40597. }
  40598. if (!this.contextMenuEvent && !this.targetIsCommentTextArea(event)) {
  40599. var eventCell = (0, _element.closest)(event.target, 'TD', 'TBODY');
  40600. var coordinates = null;
  40601. if (eventCell) {
  40602. coordinates = this.hot.view.wt.wtTable.getCoords(eventCell);
  40603. }
  40604. if (!eventCell || this.range.from && coordinates && (this.range.from.row !== coordinates.row || this.range.from.col !== coordinates.col)) {
  40605. this.hide();
  40606. }
  40607. }
  40608. this.contextMenuEvent = false;
  40609. }
  40610. /**
  40611. * `mouseover` event callback.
  40612. *
  40613. * @private
  40614. * @param {MouseEvent} event The `mouseover` event.
  40615. */
  40616. }, {
  40617. key: 'onMouseOver',
  40618. value: function onMouseOver(event) {
  40619. var priv = privatePool.get(this);
  40620. priv.cellBelowCursor = document.elementFromPoint(event.clientX, event.clientY);
  40621. if (this.mouseDown || this.editor.isFocused() || (0, _element.hasClass)(event.target, 'wtBorder') || priv.cellBelowCursor !== event.target || !this.editor) {
  40622. return;
  40623. }
  40624. if (this.targetIsCellWithComment(event)) {
  40625. var coordinates = this.hot.view.wt.wtTable.getCoords(event.target);
  40626. var range = {
  40627. from: new _src.CellCoords(coordinates.row, coordinates.col)
  40628. };
  40629. this.displaySwitch.show(range);
  40630. } else if ((0, _element.isChildOf)(event.target, document) && !this.targetIsCommentTextArea(event)) {
  40631. this.displaySwitch.hide();
  40632. }
  40633. }
  40634. /**
  40635. * `mouseup` event callback.
  40636. *
  40637. * @private
  40638. * @param {MouseEvent} event The `mouseup` event.
  40639. */
  40640. }, {
  40641. key: 'onMouseUp',
  40642. value: function onMouseUp(event) {
  40643. this.mouseDown = false;
  40644. }
  40645. /** *
  40646. * The `afterRenderer` hook callback..
  40647. *
  40648. * @private
  40649. * @param {HTMLTableCellElement} TD The rendered `TD` element.
  40650. * @param {Object} cellProperties The rendered cell's property object.
  40651. */
  40652. }, {
  40653. key: 'onAfterRenderer',
  40654. value: function onAfterRenderer(TD, cellProperties) {
  40655. if (cellProperties[META_COMMENT] && cellProperties[META_COMMENT][META_COMMENT_VALUE]) {
  40656. (0, _element.addClass)(TD, cellProperties.commentedCellClassName);
  40657. }
  40658. }
  40659. /**
  40660. * `blur` event callback for the comment editor.
  40661. *
  40662. * @private
  40663. * @param {Event} event The `blur` event.
  40664. */
  40665. }, {
  40666. key: 'onEditorBlur',
  40667. value: function onEditorBlur(event) {
  40668. this.setComment();
  40669. }
  40670. /**
  40671. * `mousedown` hook. Along with `onEditorMouseUp` used to simulate the textarea resizing event.
  40672. *
  40673. * @private
  40674. * @param {MouseEvent} event The `mousedown` event.
  40675. */
  40676. }, {
  40677. key: 'onEditorMouseDown',
  40678. value: function onEditorMouseDown(event) {
  40679. var priv = privatePool.get(this);
  40680. priv.tempEditorDimensions = {
  40681. width: (0, _element.outerWidth)(event.target),
  40682. height: (0, _element.outerHeight)(event.target)
  40683. };
  40684. }
  40685. /**
  40686. * `mouseup` hook. Along with `onEditorMouseDown` used to simulate the textarea resizing event.
  40687. *
  40688. * @private
  40689. * @param {MouseEvent} event The `mouseup` event.
  40690. */
  40691. }, {
  40692. key: 'onEditorMouseUp',
  40693. value: function onEditorMouseUp(event) {
  40694. var priv = privatePool.get(this);
  40695. var currentWidth = (0, _element.outerWidth)(event.target);
  40696. var currentHeight = (0, _element.outerHeight)(event.target);
  40697. if (currentWidth !== priv.tempEditorDimensions.width + 1 || currentHeight !== priv.tempEditorDimensions.height + 2) {
  40698. this.updateCommentMeta(this.range.from.row, this.range.from.col, _defineProperty({}, META_STYLE, {
  40699. width: currentWidth,
  40700. height: currentHeight
  40701. }));
  40702. }
  40703. }
  40704. /**
  40705. * Context Menu's "Add comment" callback. Results in showing the comment editor.
  40706. *
  40707. * @private
  40708. */
  40709. }, {
  40710. key: 'onContextMenuAddComment',
  40711. value: function onContextMenuAddComment() {
  40712. var _this4 = this;
  40713. this.displaySwitch.cancelHiding();
  40714. var coords = this.hot.getSelectedRangeLast();
  40715. this.contextMenuEvent = true;
  40716. this.setRange({
  40717. from: coords.from
  40718. });
  40719. this.show();
  40720. setTimeout(function () {
  40721. if (_this4.hot) {
  40722. _this4.hot.deselectCell();
  40723. _this4.editor.focus();
  40724. }
  40725. }, 10);
  40726. }
  40727. /**
  40728. * Context Menu's "remove comment" callback.
  40729. *
  40730. * @private
  40731. */
  40732. }, {
  40733. key: 'onContextMenuRemoveComment',
  40734. value: function onContextMenuRemoveComment() {
  40735. this.contextMenuEvent = true;
  40736. var _hot$getSelectedRange = this.hot.getSelectedRangeLast(),
  40737. from = _hot$getSelectedRange.from,
  40738. to = _hot$getSelectedRange.to;
  40739. for (var i = from.row; i <= to.row; i++) {
  40740. for (var j = from.col; j <= to.col; j++) {
  40741. this.removeCommentAtCell(i, j, false);
  40742. }
  40743. }
  40744. this.hot.render();
  40745. }
  40746. /**
  40747. * Context Menu's "make comment read-only" callback.
  40748. *
  40749. * @private
  40750. */
  40751. }, {
  40752. key: 'onContextMenuMakeReadOnly',
  40753. value: function onContextMenuMakeReadOnly() {
  40754. this.contextMenuEvent = true;
  40755. var _hot$getSelectedRange2 = this.hot.getSelectedRangeLast(),
  40756. from = _hot$getSelectedRange2.from,
  40757. to = _hot$getSelectedRange2.to;
  40758. for (var i = from.row; i <= to.row; i++) {
  40759. for (var j = from.col; j <= to.col; j++) {
  40760. var currentState = !!this.getCommentMeta(i, j, META_READONLY);
  40761. this.updateCommentMeta(i, j, _defineProperty({}, META_READONLY, !currentState));
  40762. }
  40763. }
  40764. }
  40765. /**
  40766. * Add Comments plugin options to the Context Menu.
  40767. *
  40768. * @private
  40769. * @param {Object} defaultOptions
  40770. */
  40771. }, {
  40772. key: 'addToContextMenu',
  40773. value: function addToContextMenu(defaultOptions) {
  40774. var _this5 = this;
  40775. defaultOptions.items.push({
  40776. name: '---------'
  40777. }, {
  40778. key: 'commentsAddEdit',
  40779. name: function name() {
  40780. if (_this5.checkSelectionCommentsConsistency()) {
  40781. return _this5.hot.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_EDIT_COMMENT);
  40782. }
  40783. return _this5.hot.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ADD_COMMENT);
  40784. },
  40785. callback: function callback() {
  40786. return _this5.onContextMenuAddComment();
  40787. },
  40788. disabled: function disabled() {
  40789. return !(this.getSelectedLast() && !this.selection.isSelectedByCorner());
  40790. }
  40791. }, {
  40792. key: 'commentsRemove',
  40793. name: function name() {
  40794. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_REMOVE_COMMENT);
  40795. },
  40796. callback: function callback() {
  40797. return _this5.onContextMenuRemoveComment();
  40798. },
  40799. disabled: function disabled() {
  40800. return _this5.hot.selection.isSelectedByCorner();
  40801. }
  40802. }, {
  40803. key: 'commentsReadOnly',
  40804. name: function name() {
  40805. var _this6 = this;
  40806. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_READ_ONLY_COMMENT);
  40807. var hasProperty = (0, _utils.checkSelectionConsistency)(this.getSelectedRangeLast(), function (row, col) {
  40808. var readOnlyProperty = _this6.getCellMeta(row, col)[META_COMMENT];
  40809. if (readOnlyProperty) {
  40810. readOnlyProperty = readOnlyProperty[META_READONLY];
  40811. }
  40812. if (readOnlyProperty) {
  40813. return true;
  40814. }
  40815. });
  40816. if (hasProperty) {
  40817. label = (0, _utils.markLabelAsSelected)(label);
  40818. }
  40819. return label;
  40820. },
  40821. callback: function callback() {
  40822. return _this5.onContextMenuMakeReadOnly();
  40823. },
  40824. disabled: function disabled() {
  40825. return _this5.hot.selection.isSelectedByCorner() || !_this5.checkSelectionCommentsConsistency();
  40826. }
  40827. });
  40828. }
  40829. /**
  40830. * Get `displayDelay` setting of comment plugin.
  40831. *
  40832. * @returns {Number|undefined}
  40833. */
  40834. }, {
  40835. key: 'getDisplayDelaySetting',
  40836. value: function getDisplayDelaySetting() {
  40837. var commentSetting = this.hot.getSettings().comments;
  40838. if ((0, _object.isObject)(commentSetting)) {
  40839. return commentSetting.displayDelay;
  40840. }
  40841. return void 0;
  40842. }
  40843. /**
  40844. * `afterBeginEditing` hook callback.
  40845. *
  40846. * @private
  40847. * @param {Number} row Visual row index of the currently edited cell.
  40848. * @param {Number} column Visual column index of the currently edited cell.
  40849. */
  40850. }, {
  40851. key: 'onAfterBeginEditing',
  40852. value: function onAfterBeginEditing(row, column) {
  40853. this.hide();
  40854. }
  40855. /**
  40856. * Destroy plugin instance.
  40857. */
  40858. }, {
  40859. key: 'destroy',
  40860. value: function destroy() {
  40861. if (this.editor) {
  40862. this.editor.destroy();
  40863. }
  40864. if (this.displaySwitch) {
  40865. this.displaySwitch.destroy();
  40866. }
  40867. _get(Comments.prototype.__proto__ || Object.getPrototypeOf(Comments.prototype), 'destroy', this).call(this);
  40868. }
  40869. }]);
  40870. return Comments;
  40871. }(_base2.default);
  40872. (0, _plugins.registerPlugin)('comments', Comments);
  40873. exports.default = Comments;
  40874. /***/ }),
  40875. /* 416 */
  40876. /***/ (function(module, exports, __webpack_require__) {
  40877. "use strict";
  40878. exports.__esModule = true;
  40879. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  40880. var _element = __webpack_require__(0);
  40881. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  40882. /**
  40883. * Comment editor for the Comments plugin.
  40884. *
  40885. * @class CommentEditor
  40886. * @plugin Comments
  40887. */
  40888. var CommentEditor = function () {
  40889. _createClass(CommentEditor, null, [{
  40890. key: 'CLASS_EDITOR_CONTAINER',
  40891. get: function get() {
  40892. return 'htCommentsContainer';
  40893. }
  40894. }, {
  40895. key: 'CLASS_EDITOR',
  40896. get: function get() {
  40897. return 'htComments';
  40898. }
  40899. }, {
  40900. key: 'CLASS_INPUT',
  40901. get: function get() {
  40902. return 'htCommentTextArea';
  40903. }
  40904. }, {
  40905. key: 'CLASS_CELL',
  40906. get: function get() {
  40907. return 'htCommentCell';
  40908. }
  40909. }]);
  40910. function CommentEditor() {
  40911. _classCallCheck(this, CommentEditor);
  40912. this.editor = this.createEditor();
  40913. this.editorStyle = this.editor.style;
  40914. this.hidden = true;
  40915. this.hide();
  40916. }
  40917. /**
  40918. * Set position of the comments editor according to the provided x and y coordinates.
  40919. *
  40920. * @param {Number} x X position (in pixels).
  40921. * @param {Number} y Y position (in pixels).
  40922. */
  40923. _createClass(CommentEditor, [{
  40924. key: 'setPosition',
  40925. value: function setPosition(x, y) {
  40926. this.editorStyle.left = x + 'px';
  40927. this.editorStyle.top = y + 'px';
  40928. }
  40929. /**
  40930. * Set the editor size according to the provided arguments.
  40931. *
  40932. * @param {Number} width Width in pixels.
  40933. * @param {Number} height Height in pixels.
  40934. */
  40935. }, {
  40936. key: 'setSize',
  40937. value: function setSize(width, height) {
  40938. if (width && height) {
  40939. var input = this.getInputElement();
  40940. input.style.width = width + 'px';
  40941. input.style.height = height + 'px';
  40942. }
  40943. }
  40944. /**
  40945. * Reset the editor size to its initial state.
  40946. */
  40947. }, {
  40948. key: 'resetSize',
  40949. value: function resetSize() {
  40950. var input = this.getInputElement();
  40951. input.style.width = '';
  40952. input.style.height = '';
  40953. }
  40954. /**
  40955. * Set the read-only state for the comments editor.
  40956. *
  40957. * @param {Boolean} state The new read only state.
  40958. */
  40959. }, {
  40960. key: 'setReadOnlyState',
  40961. value: function setReadOnlyState(state) {
  40962. var input = this.getInputElement();
  40963. input.readOnly = state;
  40964. }
  40965. /**
  40966. * Show the comments editor.
  40967. */
  40968. }, {
  40969. key: 'show',
  40970. value: function show() {
  40971. this.editorStyle.display = 'block';
  40972. this.hidden = false;
  40973. }
  40974. /**
  40975. * Hide the comments editor.
  40976. */
  40977. }, {
  40978. key: 'hide',
  40979. value: function hide() {
  40980. this.editorStyle.display = 'none';
  40981. this.hidden = true;
  40982. }
  40983. /**
  40984. * Checks if the editor is visible.
  40985. *
  40986. * @returns {Boolean}
  40987. */
  40988. }, {
  40989. key: 'isVisible',
  40990. value: function isVisible() {
  40991. return this.editorStyle.display === 'block';
  40992. }
  40993. /**
  40994. * Set the comment value.
  40995. *
  40996. * @param {String} [value] The value to use.
  40997. */
  40998. }, {
  40999. key: 'setValue',
  41000. value: function setValue() {
  41001. var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  41002. value = value || '';
  41003. this.getInputElement().value = value;
  41004. }
  41005. /**
  41006. * Get the comment value.
  41007. *
  41008. * @returns {String}
  41009. */
  41010. }, {
  41011. key: 'getValue',
  41012. value: function getValue() {
  41013. return this.getInputElement().value;
  41014. }
  41015. /**
  41016. * Checks if the comment input element is focused.
  41017. *
  41018. * @returns {Boolean}
  41019. */
  41020. }, {
  41021. key: 'isFocused',
  41022. value: function isFocused() {
  41023. return document.activeElement === this.getInputElement();
  41024. }
  41025. /**
  41026. * Focus the comments input element.
  41027. */
  41028. }, {
  41029. key: 'focus',
  41030. value: function focus() {
  41031. this.getInputElement().focus();
  41032. }
  41033. /**
  41034. * Create the `textarea` to be used as a comments editor.
  41035. *
  41036. * @returns {HTMLElement}
  41037. */
  41038. }, {
  41039. key: 'createEditor',
  41040. value: function createEditor() {
  41041. var container = document.querySelector('.' + CommentEditor.CLASS_EDITOR_CONTAINER);
  41042. var editor = void 0;
  41043. var textArea = void 0;
  41044. if (!container) {
  41045. container = document.createElement('div');
  41046. (0, _element.addClass)(container, CommentEditor.CLASS_EDITOR_CONTAINER);
  41047. document.body.appendChild(container);
  41048. }
  41049. editor = document.createElement('div');
  41050. (0, _element.addClass)(editor, CommentEditor.CLASS_EDITOR);
  41051. textArea = document.createElement('textarea');
  41052. (0, _element.addClass)(textArea, CommentEditor.CLASS_INPUT);
  41053. editor.appendChild(textArea);
  41054. container.appendChild(editor);
  41055. return editor;
  41056. }
  41057. /**
  41058. * Get the input element.
  41059. *
  41060. * @returns {HTMLElement}
  41061. */
  41062. }, {
  41063. key: 'getInputElement',
  41064. value: function getInputElement() {
  41065. return this.editor.querySelector('.' + CommentEditor.CLASS_INPUT);
  41066. }
  41067. /**
  41068. * Destroy the comments editor.
  41069. */
  41070. }, {
  41071. key: 'destroy',
  41072. value: function destroy() {
  41073. this.editor.parentNode.removeChild(this.editor);
  41074. this.editor = null;
  41075. this.editorStyle = null;
  41076. }
  41077. }]);
  41078. return CommentEditor;
  41079. }();
  41080. exports.default = CommentEditor;
  41081. /***/ }),
  41082. /* 417 */
  41083. /***/ (function(module, exports, __webpack_require__) {
  41084. "use strict";
  41085. exports.__esModule = true;
  41086. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  41087. var _function = __webpack_require__(43);
  41088. var _object = __webpack_require__(2);
  41089. var _localHooks = __webpack_require__(58);
  41090. var _localHooks2 = _interopRequireDefault(_localHooks);
  41091. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  41092. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  41093. var DEFAULT_DISPLAY_DELAY = 250;
  41094. var DEFAULT_HIDE_DELAY = 250;
  41095. /**
  41096. * Display switch for the Comments plugin. Manages the time of delayed displaying / hiding comments.
  41097. *
  41098. * @class DisplaySwitch
  41099. * @plugin Comments
  41100. */
  41101. var DisplaySwitch = function () {
  41102. function DisplaySwitch(displayDelay) {
  41103. _classCallCheck(this, DisplaySwitch);
  41104. /**
  41105. * Flag to determine if comment can be showed or hidden. State `true` mean that last performed action
  41106. * was an attempt to show comment element. State `false` mean that it was attempt to hide comment element.
  41107. *
  41108. * @type {Boolean}
  41109. */
  41110. this.wasLastActionShow = true;
  41111. /**
  41112. * Show comment after predefined delay. It keeps reference to immutable `debounce` function.
  41113. *
  41114. * @type {Function}
  41115. */
  41116. this.showDebounced = null;
  41117. /**
  41118. * Reference to timer, run by `setTimeout`, which is hiding comment
  41119. *
  41120. * @type {Number}
  41121. */
  41122. this.hidingTimer = null;
  41123. this.updateDelay(displayDelay);
  41124. }
  41125. /**
  41126. * Responsible for hiding comment after proper delay.
  41127. */
  41128. _createClass(DisplaySwitch, [{
  41129. key: 'hide',
  41130. value: function hide() {
  41131. var _this = this;
  41132. this.wasLastActionShow = false;
  41133. this.hidingTimer = setTimeout(function () {
  41134. if (_this.wasLastActionShow === false) {
  41135. _this.runLocalHooks('hide');
  41136. }
  41137. }, DEFAULT_HIDE_DELAY);
  41138. }
  41139. /**
  41140. * Responsible for showing comment after proper delay.
  41141. *
  41142. * @param {Object} range Coordinates of selected cell.
  41143. */
  41144. }, {
  41145. key: 'show',
  41146. value: function show(range) {
  41147. this.wasLastActionShow = true;
  41148. this.showDebounced(range);
  41149. }
  41150. }, {
  41151. key: 'cancelHiding',
  41152. /**
  41153. * Cancel hiding comment.
  41154. */
  41155. value: function cancelHiding() {
  41156. this.wasLastActionShow = true;
  41157. clearTimeout(this.hidingTimer);
  41158. this.hidingTimer = null;
  41159. }
  41160. /**
  41161. * Update the switch settings.
  41162. *
  41163. * @param {Number} displayDelay Delay of showing the comments (in milliseconds).
  41164. */
  41165. }, {
  41166. key: 'updateDelay',
  41167. value: function updateDelay() {
  41168. var _this2 = this;
  41169. var displayDelay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_DISPLAY_DELAY;
  41170. this.showDebounced = (0, _function.debounce)(function (range) {
  41171. if (_this2.wasLastActionShow) {
  41172. _this2.runLocalHooks('show', range.from.row, range.from.col);
  41173. }
  41174. }, displayDelay);
  41175. }
  41176. /**
  41177. * Destroy the switcher.
  41178. */
  41179. }, {
  41180. key: 'destroy',
  41181. value: function destroy() {
  41182. this.clearLocalHooks();
  41183. }
  41184. }]);
  41185. return DisplaySwitch;
  41186. }();
  41187. (0, _object.mixin)(DisplaySwitch, _localHooks2.default);
  41188. exports.default = DisplaySwitch;
  41189. /***/ }),
  41190. /* 418 */
  41191. /***/ (function(module, exports) {
  41192. // removed by extract-text-webpack-plugin
  41193. /***/ }),
  41194. /* 419 */
  41195. /***/ (function(module, exports, __webpack_require__) {
  41196. "use strict";
  41197. exports.__esModule = true;
  41198. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  41199. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  41200. var _base = __webpack_require__(10);
  41201. var _base2 = _interopRequireDefault(_base);
  41202. var _pluginHooks = __webpack_require__(15);
  41203. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  41204. var _array = __webpack_require__(1);
  41205. var _commandExecutor = __webpack_require__(420);
  41206. var _commandExecutor2 = _interopRequireDefault(_commandExecutor);
  41207. var _eventManager = __webpack_require__(6);
  41208. var _eventManager2 = _interopRequireDefault(_eventManager);
  41209. var _itemsFactory = __webpack_require__(421);
  41210. var _itemsFactory2 = _interopRequireDefault(_itemsFactory);
  41211. var _menu = __webpack_require__(433);
  41212. var _menu2 = _interopRequireDefault(_menu);
  41213. var _plugins = __webpack_require__(8);
  41214. var _event = __webpack_require__(12);
  41215. var _element = __webpack_require__(0);
  41216. var _predefinedItems = __webpack_require__(94);
  41217. __webpack_require__(435);
  41218. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  41219. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  41220. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  41221. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  41222. _pluginHooks2.default.getSingleton().register('afterContextMenuDefaultOptions');
  41223. _pluginHooks2.default.getSingleton().register('beforeContextMenuShow');
  41224. _pluginHooks2.default.getSingleton().register('afterContextMenuShow');
  41225. _pluginHooks2.default.getSingleton().register('afterContextMenuHide');
  41226. _pluginHooks2.default.getSingleton().register('afterContextMenuExecute');
  41227. /**
  41228. * @description
  41229. * This plugin creates the Handsontable Context Menu. It allows to create a new row or
  41230. * column at any place in the grid among [other features](http://docs.handsontable.com/demo-context-menu.html).
  41231. * Possible values:
  41232. * * `true` (to enable default options),
  41233. * * `false` (to disable completely)
  41234. *
  41235. * or array of any available strings:
  41236. * * `["row_above", "row_below", "col_left", "col_right",
  41237. * "remove_row", "remove_col", "---------", "undo", "redo"]`.
  41238. *
  41239. * See [the context menu demo](http://docs.handsontable.com/demo-context-menu.html) for examples.
  41240. *
  41241. * @example
  41242. * ```js
  41243. * ...
  41244. * // as a boolean
  41245. * contextMenu: true
  41246. * ...
  41247. * // as a array
  41248. * contextMenu: ['row_above', 'row_below', '---------', 'undo', 'redo']
  41249. * ...
  41250. * ```
  41251. *
  41252. * @plugin ContextMenu
  41253. */
  41254. var ContextMenu = function (_BasePlugin) {
  41255. _inherits(ContextMenu, _BasePlugin);
  41256. _createClass(ContextMenu, null, [{
  41257. key: 'DEFAULT_ITEMS',
  41258. /**
  41259. * Default menu items order when `contextMenu` is enabled by `true`.
  41260. *
  41261. * @returns {Array}
  41262. */
  41263. get: function get() {
  41264. return [_predefinedItems.ROW_ABOVE, _predefinedItems.ROW_BELOW, _predefinedItems.SEPARATOR, _predefinedItems.COLUMN_LEFT, _predefinedItems.COLUMN_RIGHT, _predefinedItems.SEPARATOR, _predefinedItems.REMOVE_ROW, _predefinedItems.REMOVE_COLUMN, _predefinedItems.SEPARATOR, _predefinedItems.UNDO, _predefinedItems.REDO, _predefinedItems.SEPARATOR, _predefinedItems.READ_ONLY, _predefinedItems.SEPARATOR, _predefinedItems.ALIGNMENT];
  41265. }
  41266. }]);
  41267. function ContextMenu(hotInstance) {
  41268. _classCallCheck(this, ContextMenu);
  41269. /**
  41270. * Instance of {@link EventManager}.
  41271. *
  41272. * @type {EventManager}
  41273. */
  41274. var _this = _possibleConstructorReturn(this, (ContextMenu.__proto__ || Object.getPrototypeOf(ContextMenu)).call(this, hotInstance));
  41275. _this.eventManager = new _eventManager2.default(_this);
  41276. /**
  41277. * Instance of {@link CommandExecutor}.
  41278. *
  41279. * @type {CommandExecutor}
  41280. */
  41281. _this.commandExecutor = new _commandExecutor2.default(_this.hot);
  41282. /**
  41283. * Instance of {@link ItemsFactory}.
  41284. *
  41285. * @type {ItemsFactory}
  41286. */
  41287. _this.itemsFactory = null;
  41288. /**
  41289. * Instance of {@link Menu}.
  41290. *
  41291. * @type {Menu}
  41292. */
  41293. _this.menu = null;
  41294. return _this;
  41295. }
  41296. /**
  41297. * Check if the plugin is enabled in the Handsontable settings.
  41298. *
  41299. * @returns {Boolean}
  41300. */
  41301. _createClass(ContextMenu, [{
  41302. key: 'isEnabled',
  41303. value: function isEnabled() {
  41304. return this.hot.getSettings().contextMenu;
  41305. }
  41306. /**
  41307. * Enable plugin for this Handsontable instance.
  41308. */
  41309. }, {
  41310. key: 'enablePlugin',
  41311. value: function enablePlugin() {
  41312. var _this2 = this;
  41313. if (this.enabled) {
  41314. return;
  41315. }
  41316. this.itemsFactory = new _itemsFactory2.default(this.hot, ContextMenu.DEFAULT_ITEMS);
  41317. var settings = this.hot.getSettings().contextMenu;
  41318. var predefinedItems = {
  41319. items: this.itemsFactory.getItems(settings)
  41320. };
  41321. this.registerEvents();
  41322. if (typeof settings.callback === 'function') {
  41323. this.commandExecutor.setCommonCallback(settings.callback);
  41324. }
  41325. _get(ContextMenu.prototype.__proto__ || Object.getPrototypeOf(ContextMenu.prototype), 'enablePlugin', this).call(this);
  41326. var delayedInitialization = function delayedInitialization() {
  41327. if (!_this2.hot) {
  41328. return;
  41329. }
  41330. _this2.hot.runHooks('afterContextMenuDefaultOptions', predefinedItems);
  41331. _this2.itemsFactory.setPredefinedItems(predefinedItems.items);
  41332. var menuItems = _this2.itemsFactory.getItems(settings);
  41333. _this2.menu = new _menu2.default(_this2.hot, {
  41334. className: 'htContextMenu',
  41335. keepInViewport: true
  41336. });
  41337. _this2.hot.runHooks('beforeContextMenuSetItems', menuItems);
  41338. _this2.menu.setMenuItems(menuItems);
  41339. _this2.menu.addLocalHook('beforeOpen', function () {
  41340. return _this2.onMenuBeforeOpen();
  41341. });
  41342. _this2.menu.addLocalHook('afterOpen', function () {
  41343. return _this2.onMenuAfterOpen();
  41344. });
  41345. _this2.menu.addLocalHook('afterClose', function () {
  41346. return _this2.onMenuAfterClose();
  41347. });
  41348. _this2.menu.addLocalHook('executeCommand', function () {
  41349. for (var _len = arguments.length, params = Array(_len), _key = 0; _key < _len; _key++) {
  41350. params[_key] = arguments[_key];
  41351. }
  41352. return _this2.executeCommand.apply(_this2, params);
  41353. });
  41354. // Register all commands. Predefined and added by user or by plugins
  41355. (0, _array.arrayEach)(menuItems, function (command) {
  41356. return _this2.commandExecutor.registerCommand(command.key, command);
  41357. });
  41358. };
  41359. this.callOnPluginsReady(function () {
  41360. if (_this2.isPluginsReady) {
  41361. setTimeout(delayedInitialization, 0);
  41362. } else {
  41363. delayedInitialization();
  41364. }
  41365. });
  41366. }
  41367. /**
  41368. * Updates the plugin to use the latest options you have specified.
  41369. */
  41370. }, {
  41371. key: 'updatePlugin',
  41372. value: function updatePlugin() {
  41373. this.disablePlugin();
  41374. this.enablePlugin();
  41375. _get(ContextMenu.prototype.__proto__ || Object.getPrototypeOf(ContextMenu.prototype), 'updatePlugin', this).call(this);
  41376. }
  41377. /**
  41378. * Disable plugin for this Handsontable instance.
  41379. */
  41380. }, {
  41381. key: 'disablePlugin',
  41382. value: function disablePlugin() {
  41383. this.close();
  41384. if (this.menu) {
  41385. this.menu.destroy();
  41386. this.menu = null;
  41387. }
  41388. _get(ContextMenu.prototype.__proto__ || Object.getPrototypeOf(ContextMenu.prototype), 'disablePlugin', this).call(this);
  41389. }
  41390. /**
  41391. * Register dom listeners.
  41392. *
  41393. * @private
  41394. */
  41395. }, {
  41396. key: 'registerEvents',
  41397. value: function registerEvents() {
  41398. var _this3 = this;
  41399. this.eventManager.addEventListener(this.hot.rootElement, 'contextmenu', function (event) {
  41400. return _this3.onContextMenu(event);
  41401. });
  41402. }
  41403. /**
  41404. * Open menu and re-position it based on dom event object.
  41405. *
  41406. * @param {Event} event The event object.
  41407. */
  41408. }, {
  41409. key: 'open',
  41410. value: function open(event) {
  41411. if (!this.menu) {
  41412. return;
  41413. }
  41414. this.menu.open();
  41415. this.menu.setPosition({
  41416. top: parseInt((0, _event.pageY)(event), 10) - (0, _element.getWindowScrollTop)(),
  41417. left: parseInt((0, _event.pageX)(event), 10) - (0, _element.getWindowScrollLeft)()
  41418. });
  41419. // ContextMenu is not detected HotTableEnv correctly because is injected outside hot-table
  41420. this.menu.hotMenu.isHotTableEnv = this.hot.isHotTableEnv;
  41421. // Handsontable.eventManager.isHotTableEnv = this.hot.isHotTableEnv;
  41422. }
  41423. /**
  41424. * Close menu.
  41425. */
  41426. }, {
  41427. key: 'close',
  41428. value: function close() {
  41429. if (!this.menu) {
  41430. return;
  41431. }
  41432. this.menu.close();
  41433. }
  41434. /**
  41435. * Execute context menu command.
  41436. *
  41437. * You can execute all predefined commands:
  41438. * * `'row_above'` - Insert row above
  41439. * * `'row_below'` - Insert row below
  41440. * * `'col_left'` - Insert column left
  41441. * * `'col_right'` - Insert column right
  41442. * * `'clear_column'` - Clear selected column
  41443. * * `'remove_row'` - Remove row
  41444. * * `'remove_col'` - Remove column
  41445. * * `'undo'` - Undo last action
  41446. * * `'redo'` - Redo last action
  41447. * * `'make_read_only'` - Make cell read only
  41448. * * `'alignment:left'` - Alignment to the left
  41449. * * `'alignment:top'` - Alignment to the top
  41450. * * `'alignment:right'` - Alignment to the right
  41451. * * `'alignment:bottom'` - Alignment to the bottom
  41452. * * `'alignment:middle'` - Alignment to the middle
  41453. * * `'alignment:center'` - Alignment to the center (justify)
  41454. *
  41455. * Or you can execute command registered in settings where `key` is your command name.
  41456. *
  41457. * @param {String} commandName
  41458. * @param {*} params
  41459. */
  41460. }, {
  41461. key: 'executeCommand',
  41462. value: function executeCommand() {
  41463. for (var _len2 = arguments.length, params = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  41464. params[_key2] = arguments[_key2];
  41465. }
  41466. this.commandExecutor.execute.apply(this.commandExecutor, params);
  41467. }
  41468. /**
  41469. * On context menu listener.
  41470. *
  41471. * @private
  41472. * @param {Event} event
  41473. */
  41474. }, {
  41475. key: 'onContextMenu',
  41476. value: function onContextMenu(event) {
  41477. var settings = this.hot.getSettings();
  41478. var showRowHeaders = settings.rowHeaders;
  41479. var showColHeaders = settings.colHeaders;
  41480. function isValidElement(element) {
  41481. return element.nodeName === 'TD' || element.parentNode.nodeName === 'TD';
  41482. }
  41483. // if event is from hot-table we must get web component element not element inside him
  41484. var element = event.realTarget;
  41485. this.close();
  41486. if ((0, _element.hasClass)(element, 'handsontableInput')) {
  41487. return;
  41488. }
  41489. event.preventDefault();
  41490. (0, _event.stopPropagation)(event);
  41491. if (!(showRowHeaders || showColHeaders)) {
  41492. if (!isValidElement(element) && !((0, _element.hasClass)(element, 'current') && (0, _element.hasClass)(element, 'wtBorder'))) {
  41493. return;
  41494. }
  41495. }
  41496. this.open(event);
  41497. }
  41498. /**
  41499. * On menu before open listener.
  41500. *
  41501. * @private
  41502. */
  41503. }, {
  41504. key: 'onMenuBeforeOpen',
  41505. value: function onMenuBeforeOpen() {
  41506. this.hot.runHooks('beforeContextMenuShow', this);
  41507. }
  41508. /**
  41509. * On menu after open listener.
  41510. *
  41511. * @private
  41512. */
  41513. }, {
  41514. key: 'onMenuAfterOpen',
  41515. value: function onMenuAfterOpen() {
  41516. this.hot.runHooks('afterContextMenuShow', this);
  41517. }
  41518. /**
  41519. * On menu after close listener.
  41520. *
  41521. * @private
  41522. */
  41523. }, {
  41524. key: 'onMenuAfterClose',
  41525. value: function onMenuAfterClose() {
  41526. this.hot.listen();
  41527. this.hot.runHooks('afterContextMenuHide', this);
  41528. }
  41529. /**
  41530. * Destroy instance.
  41531. */
  41532. }, {
  41533. key: 'destroy',
  41534. value: function destroy() {
  41535. this.close();
  41536. if (this.menu) {
  41537. this.menu.destroy();
  41538. }
  41539. _get(ContextMenu.prototype.__proto__ || Object.getPrototypeOf(ContextMenu.prototype), 'destroy', this).call(this);
  41540. }
  41541. }]);
  41542. return ContextMenu;
  41543. }(_base2.default);
  41544. ContextMenu.SEPARATOR = {
  41545. name: _predefinedItems.SEPARATOR
  41546. };
  41547. (0, _plugins.registerPlugin)('contextMenu', ContextMenu);
  41548. exports.default = ContextMenu;
  41549. /***/ }),
  41550. /* 420 */
  41551. /***/ (function(module, exports, __webpack_require__) {
  41552. "use strict";
  41553. exports.__esModule = true;
  41554. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  41555. var _array = __webpack_require__(1);
  41556. var _object = __webpack_require__(2);
  41557. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  41558. /**
  41559. * Command executor for ContextMenu.
  41560. *
  41561. * @class CommandExecutor
  41562. * @plugin ContextMenu
  41563. */
  41564. var CommandExecutor = function () {
  41565. function CommandExecutor(hotInstance) {
  41566. _classCallCheck(this, CommandExecutor);
  41567. this.hot = hotInstance;
  41568. this.commands = {};
  41569. this.commonCallback = null;
  41570. }
  41571. /**
  41572. * Register command.
  41573. *
  41574. * @param {String} name Command name.
  41575. * @param {Object} commandDescriptor Command descriptor object with properties like `key` (command id),
  41576. * `callback` (task to execute), `name` (command name), `disabled` (command availability).
  41577. */
  41578. _createClass(CommandExecutor, [{
  41579. key: 'registerCommand',
  41580. value: function registerCommand(name, commandDescriptor) {
  41581. this.commands[name] = commandDescriptor;
  41582. }
  41583. /**
  41584. * Set common callback which will be trigger on every executed command.
  41585. *
  41586. * @param {Function} callback Function which will be fired on every command execute.
  41587. */
  41588. }, {
  41589. key: 'setCommonCallback',
  41590. value: function setCommonCallback(callback) {
  41591. this.commonCallback = callback;
  41592. }
  41593. /**
  41594. * Execute command by its name.
  41595. *
  41596. * @param {String} commandName Command id.
  41597. * @param {*} params Arguments passed to command task.
  41598. */
  41599. }, {
  41600. key: 'execute',
  41601. value: function execute(commandName) {
  41602. var _this = this;
  41603. for (var _len = arguments.length, params = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  41604. params[_key - 1] = arguments[_key];
  41605. }
  41606. var commandSplit = commandName.split(':');
  41607. commandName = commandSplit[0];
  41608. var subCommandName = commandSplit.length === 2 ? commandSplit[1] : null;
  41609. var command = this.commands[commandName];
  41610. if (!command) {
  41611. throw new Error('Menu command \'' + commandName + '\' not exists.');
  41612. }
  41613. if (subCommandName && command.submenu) {
  41614. command = findSubCommand(subCommandName, command.submenu.items);
  41615. }
  41616. if (command.disabled === true) {
  41617. return;
  41618. }
  41619. if (typeof command.disabled == 'function' && command.disabled.call(this.hot) === true) {
  41620. return;
  41621. }
  41622. if ((0, _object.hasOwnProperty)(command, 'submenu')) {
  41623. return;
  41624. }
  41625. var callbacks = [];
  41626. if (typeof command.callback === 'function') {
  41627. callbacks.push(command.callback);
  41628. }
  41629. if (typeof this.commonCallback === 'function') {
  41630. callbacks.push(this.commonCallback);
  41631. }
  41632. params.unshift(commandSplit.join(':'));
  41633. (0, _array.arrayEach)(callbacks, function (callback) {
  41634. return callback.apply(_this.hot, params);
  41635. });
  41636. }
  41637. }]);
  41638. return CommandExecutor;
  41639. }();
  41640. function findSubCommand(subCommandName, subCommands) {
  41641. var command = void 0;
  41642. (0, _array.arrayEach)(subCommands, function (cmd) {
  41643. var cmds = cmd.key ? cmd.key.split(':') : null;
  41644. if (Array.isArray(cmds) && cmds[1] === subCommandName) {
  41645. command = cmd;
  41646. return false;
  41647. }
  41648. });
  41649. return command;
  41650. }
  41651. exports.default = CommandExecutor;
  41652. /***/ }),
  41653. /* 421 */
  41654. /***/ (function(module, exports, __webpack_require__) {
  41655. "use strict";
  41656. exports.__esModule = true;
  41657. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  41658. var _object = __webpack_require__(2);
  41659. var _array = __webpack_require__(1);
  41660. var _predefinedItems = __webpack_require__(94);
  41661. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  41662. /**
  41663. * Predefined items class factory for menu items.
  41664. *
  41665. * @class ItemsFactory
  41666. * @plugin ContextMenu
  41667. */
  41668. var ItemsFactory = function () {
  41669. function ItemsFactory(hotInstance) {
  41670. var orderPattern = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  41671. _classCallCheck(this, ItemsFactory);
  41672. this.hot = hotInstance;
  41673. this.predefinedItems = (0, _predefinedItems.predefinedItems)();
  41674. this.defaultOrderPattern = orderPattern;
  41675. }
  41676. /**
  41677. * Set predefined items.
  41678. *
  41679. * @param {Array} predefinedItems Array of predefined items.
  41680. */
  41681. _createClass(ItemsFactory, [{
  41682. key: 'setPredefinedItems',
  41683. value: function setPredefinedItems(predefinedItems) {
  41684. var _this = this;
  41685. var items = {};
  41686. this.defaultOrderPattern.length = 0;
  41687. (0, _object.objectEach)(predefinedItems, function (value, key) {
  41688. var menuItemKey = '';
  41689. if (value.name === _predefinedItems.SEPARATOR) {
  41690. items[_predefinedItems.SEPARATOR] = value;
  41691. menuItemKey = _predefinedItems.SEPARATOR;
  41692. // Menu item added as a property to array
  41693. } else if (isNaN(parseInt(key, 10))) {
  41694. value.key = value.key === void 0 ? key : value.key;
  41695. items[key] = value;
  41696. menuItemKey = value.key;
  41697. } else {
  41698. items[value.key] = value;
  41699. menuItemKey = value.key;
  41700. }
  41701. _this.defaultOrderPattern.push(menuItemKey);
  41702. });
  41703. this.predefinedItems = items;
  41704. }
  41705. /**
  41706. * Get all menu items based on pattern.
  41707. *
  41708. * @param {Array|Object|Boolean} pattern Pattern which you can define by displaying menu items order. If `true` default
  41709. * pattern will be used.
  41710. * @returns {Array}
  41711. */
  41712. }, {
  41713. key: 'getItems',
  41714. value: function getItems() {
  41715. var pattern = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  41716. return _getItems(pattern, this.defaultOrderPattern, this.predefinedItems);
  41717. }
  41718. }]);
  41719. return ItemsFactory;
  41720. }();
  41721. function _getItems() {
  41722. var pattern = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  41723. var defaultPattern = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  41724. var items = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  41725. var result = [];
  41726. if (pattern && pattern.items) {
  41727. pattern = pattern.items;
  41728. } else if (!Array.isArray(pattern)) {
  41729. pattern = defaultPattern;
  41730. }
  41731. if ((0, _object.isObject)(pattern)) {
  41732. (0, _object.objectEach)(pattern, function (value, key) {
  41733. var item = items[typeof value === 'string' ? value : key];
  41734. if (!item) {
  41735. item = value;
  41736. }
  41737. if ((0, _object.isObject)(value)) {
  41738. (0, _object.extend)(item, value);
  41739. } else if (typeof item === 'string') {
  41740. item = { name: item };
  41741. }
  41742. if (item.key === void 0) {
  41743. item.key = key;
  41744. }
  41745. result.push(item);
  41746. });
  41747. } else {
  41748. (0, _array.arrayEach)(pattern, function (name, key) {
  41749. var item = items[name];
  41750. // Item deleted from settings `allowInsertRow: false` etc.
  41751. if (!item && _predefinedItems.ITEMS.indexOf(name) >= 0) {
  41752. return;
  41753. }
  41754. if (!item) {
  41755. item = { name: name, key: '' + key };
  41756. }
  41757. if ((0, _object.isObject)(name)) {
  41758. (0, _object.extend)(item, name);
  41759. }
  41760. if (item.key === void 0) {
  41761. item.key = key;
  41762. }
  41763. result.push(item);
  41764. });
  41765. }
  41766. return result;
  41767. }
  41768. exports.default = ItemsFactory;
  41769. /***/ }),
  41770. /* 422 */
  41771. /***/ (function(module, exports, __webpack_require__) {
  41772. "use strict";
  41773. exports.__esModule = true;
  41774. exports.KEY = undefined;
  41775. exports.default = alignmentItem;
  41776. var _utils = __webpack_require__(19);
  41777. var _separator = __webpack_require__(93);
  41778. var _constants = __webpack_require__(7);
  41779. var C = _interopRequireWildcard(_constants);
  41780. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  41781. var KEY = exports.KEY = 'alignment';
  41782. function alignmentItem() {
  41783. return {
  41784. key: KEY,
  41785. name: function name() {
  41786. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ALIGNMENT);
  41787. },
  41788. disabled: function disabled() {
  41789. return !(this.getSelectedRange() && !this.selection.isSelectedByCorner());
  41790. },
  41791. submenu: {
  41792. items: [{
  41793. key: KEY + ':left',
  41794. name: function name() {
  41795. var _this = this;
  41796. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ALIGNMENT_LEFT);
  41797. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  41798. var className = _this.getCellMeta(row, col).className;
  41799. if (className && className.indexOf('htLeft') !== -1) {
  41800. return true;
  41801. }
  41802. });
  41803. if (hasClass) {
  41804. label = (0, _utils.markLabelAsSelected)(label);
  41805. }
  41806. return label;
  41807. },
  41808. callback: function callback() {
  41809. var _this2 = this;
  41810. var selectedRange = this.getSelectedRange();
  41811. var stateBefore = (0, _utils.getAlignmentClasses)(selectedRange, function (row, col) {
  41812. return _this2.getCellMeta(row, col).className;
  41813. });
  41814. var type = 'horizontal';
  41815. var alignment = 'htLeft';
  41816. this.runHooks('beforeCellAlignment', stateBefore, selectedRange, type, alignment);
  41817. (0, _utils.align)(selectedRange, type, alignment, function (row, col) {
  41818. return _this2.getCellMeta(row, col);
  41819. }, function (row, col, key, value) {
  41820. return _this2.setCellMeta(row, col, key, value);
  41821. });
  41822. this.render();
  41823. },
  41824. disabled: false
  41825. }, {
  41826. key: KEY + ':center',
  41827. name: function name() {
  41828. var _this3 = this;
  41829. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ALIGNMENT_CENTER);
  41830. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  41831. var className = _this3.getCellMeta(row, col).className;
  41832. if (className && className.indexOf('htCenter') !== -1) {
  41833. return true;
  41834. }
  41835. });
  41836. if (hasClass) {
  41837. label = (0, _utils.markLabelAsSelected)(label);
  41838. }
  41839. return label;
  41840. },
  41841. callback: function callback(key, selection) {
  41842. var _this4 = this;
  41843. var selectedRange = this.getSelectedRange();
  41844. var stateBefore = (0, _utils.getAlignmentClasses)(selectedRange, function (row, col) {
  41845. return _this4.getCellMeta(row, col).className;
  41846. });
  41847. var type = 'horizontal';
  41848. var alignment = 'htCenter';
  41849. this.runHooks('beforeCellAlignment', stateBefore, selectedRange, type, alignment);
  41850. (0, _utils.align)(selectedRange, type, alignment, function (row, col) {
  41851. return _this4.getCellMeta(row, col);
  41852. }, function (row, col, key, value) {
  41853. return _this4.setCellMeta(row, col, key, value);
  41854. });
  41855. this.render();
  41856. },
  41857. disabled: false
  41858. }, {
  41859. key: KEY + ':right',
  41860. name: function name() {
  41861. var _this5 = this;
  41862. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ALIGNMENT_RIGHT);
  41863. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  41864. var className = _this5.getCellMeta(row, col).className;
  41865. if (className && className.indexOf('htRight') !== -1) {
  41866. return true;
  41867. }
  41868. });
  41869. if (hasClass) {
  41870. label = (0, _utils.markLabelAsSelected)(label);
  41871. }
  41872. return label;
  41873. },
  41874. callback: function callback() {
  41875. var _this6 = this;
  41876. var selectedRange = this.getSelectedRange();
  41877. var stateBefore = (0, _utils.getAlignmentClasses)(selectedRange, function (row, col) {
  41878. return _this6.getCellMeta(row, col).className;
  41879. });
  41880. var type = 'horizontal';
  41881. var alignment = 'htRight';
  41882. this.runHooks('beforeCellAlignment', stateBefore, selectedRange, type, alignment);
  41883. (0, _utils.align)(selectedRange, type, alignment, function (row, col) {
  41884. return _this6.getCellMeta(row, col);
  41885. }, function (row, col, key, value) {
  41886. return _this6.setCellMeta(row, col, key, value);
  41887. });
  41888. this.render();
  41889. },
  41890. disabled: false
  41891. }, {
  41892. key: KEY + ':justify',
  41893. name: function name() {
  41894. var _this7 = this;
  41895. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ALIGNMENT_JUSTIFY);
  41896. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  41897. var className = _this7.getCellMeta(row, col).className;
  41898. if (className && className.indexOf('htJustify') !== -1) {
  41899. return true;
  41900. }
  41901. });
  41902. if (hasClass) {
  41903. label = (0, _utils.markLabelAsSelected)(label);
  41904. }
  41905. return label;
  41906. },
  41907. callback: function callback() {
  41908. var _this8 = this;
  41909. var selectedRange = this.getSelectedRange();
  41910. var stateBefore = (0, _utils.getAlignmentClasses)(selectedRange, function (row, col) {
  41911. return _this8.getCellMeta(row, col).className;
  41912. });
  41913. var type = 'horizontal';
  41914. var alignment = 'htJustify';
  41915. this.runHooks('beforeCellAlignment', stateBefore, selectedRange, type, alignment);
  41916. (0, _utils.align)(selectedRange, type, alignment, function (row, col) {
  41917. return _this8.getCellMeta(row, col);
  41918. }, function (row, col, key, value) {
  41919. return _this8.setCellMeta(row, col, key, value);
  41920. });
  41921. this.render();
  41922. },
  41923. disabled: false
  41924. }, {
  41925. name: _separator.KEY
  41926. }, {
  41927. key: KEY + ':top',
  41928. name: function name() {
  41929. var _this9 = this;
  41930. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ALIGNMENT_TOP);
  41931. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  41932. var className = _this9.getCellMeta(row, col).className;
  41933. if (className && className.indexOf('htTop') !== -1) {
  41934. return true;
  41935. }
  41936. });
  41937. if (hasClass) {
  41938. label = (0, _utils.markLabelAsSelected)(label);
  41939. }
  41940. return label;
  41941. },
  41942. callback: function callback() {
  41943. var _this10 = this;
  41944. var selectedRange = this.getSelectedRange();
  41945. var stateBefore = (0, _utils.getAlignmentClasses)(selectedRange, function (row, col) {
  41946. return _this10.getCellMeta(row, col).className;
  41947. });
  41948. var type = 'vertical';
  41949. var alignment = 'htTop';
  41950. this.runHooks('beforeCellAlignment', stateBefore, selectedRange, type, alignment);
  41951. (0, _utils.align)(selectedRange, type, alignment, function (row, col) {
  41952. return _this10.getCellMeta(row, col);
  41953. }, function (row, col, key, value) {
  41954. return _this10.setCellMeta(row, col, key, value);
  41955. });
  41956. this.render();
  41957. },
  41958. disabled: false
  41959. }, {
  41960. key: KEY + ':middle',
  41961. name: function name() {
  41962. var _this11 = this;
  41963. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ALIGNMENT_MIDDLE);
  41964. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  41965. var className = _this11.getCellMeta(row, col).className;
  41966. if (className && className.indexOf('htMiddle') !== -1) {
  41967. return true;
  41968. }
  41969. });
  41970. if (hasClass) {
  41971. label = (0, _utils.markLabelAsSelected)(label);
  41972. }
  41973. return label;
  41974. },
  41975. callback: function callback() {
  41976. var _this12 = this;
  41977. var selectedRange = this.getSelectedRange();
  41978. var stateBefore = (0, _utils.getAlignmentClasses)(selectedRange, function (row, col) {
  41979. return _this12.getCellMeta(row, col).className;
  41980. });
  41981. var type = 'vertical';
  41982. var alignment = 'htMiddle';
  41983. this.runHooks('beforeCellAlignment', stateBefore, selectedRange, type, alignment);
  41984. (0, _utils.align)(selectedRange, type, alignment, function (row, col) {
  41985. return _this12.getCellMeta(row, col);
  41986. }, function (row, col, key, value) {
  41987. return _this12.setCellMeta(row, col, key, value);
  41988. });
  41989. this.render();
  41990. },
  41991. disabled: false
  41992. }, {
  41993. key: KEY + ':bottom',
  41994. name: function name() {
  41995. var _this13 = this;
  41996. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ALIGNMENT_BOTTOM);
  41997. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  41998. var className = _this13.getCellMeta(row, col).className;
  41999. if (className && className.indexOf('htBottom') !== -1) {
  42000. return true;
  42001. }
  42002. });
  42003. if (hasClass) {
  42004. label = (0, _utils.markLabelAsSelected)(label);
  42005. }
  42006. return label;
  42007. },
  42008. callback: function callback() {
  42009. var _this14 = this;
  42010. var selectedRange = this.getSelectedRange();
  42011. var stateBefore = (0, _utils.getAlignmentClasses)(selectedRange, function (row, col) {
  42012. return _this14.getCellMeta(row, col).className;
  42013. });
  42014. var type = 'vertical';
  42015. var alignment = 'htBottom';
  42016. this.runHooks('beforeCellAlignment', stateBefore, selectedRange, type, alignment);
  42017. (0, _utils.align)(selectedRange, type, alignment, function (row, col) {
  42018. return _this14.getCellMeta(row, col);
  42019. }, function (row, col, key, value) {
  42020. return _this14.setCellMeta(row, col, key, value);
  42021. });
  42022. this.render();
  42023. },
  42024. disabled: false
  42025. }]
  42026. }
  42027. };
  42028. }
  42029. /***/ }),
  42030. /* 423 */
  42031. /***/ (function(module, exports, __webpack_require__) {
  42032. "use strict";
  42033. exports.__esModule = true;
  42034. exports.KEY = undefined;
  42035. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  42036. exports.default = clearColumnItem;
  42037. var _utils = __webpack_require__(19);
  42038. var _constants = __webpack_require__(7);
  42039. var C = _interopRequireWildcard(_constants);
  42040. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  42041. var KEY = exports.KEY = 'clear_column';
  42042. function clearColumnItem() {
  42043. return {
  42044. key: KEY,
  42045. name: function name() {
  42046. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_CLEAR_COLUMN);
  42047. },
  42048. callback: function callback(key, selection) {
  42049. var column = selection[0].start.col;
  42050. if (this.countRows()) {
  42051. this.populateFromArray(0, column, [[null]], Math.max(selection[0].start.row, selection[0].end.row), column, 'ContextMenu.clearColumn');
  42052. }
  42053. },
  42054. disabled: function disabled() {
  42055. var selected = (0, _utils.getValidSelection)(this);
  42056. if (!selected) {
  42057. return true;
  42058. }
  42059. var _selected$ = _slicedToArray(selected[0], 4),
  42060. startRow = _selected$[0],
  42061. startColumn = _selected$[1],
  42062. endRow = _selected$[2],
  42063. endColumn = _selected$[3];
  42064. var entireRowSelection = [startRow, 0, endRow, this.countCols() - 1];
  42065. var rowSelected = entireRowSelection.join(',') === selected.join(',');
  42066. return startColumn < 0 || this.countCols() >= this.getSettings().maxCols || rowSelected;
  42067. }
  42068. };
  42069. }
  42070. /***/ }),
  42071. /* 424 */
  42072. /***/ (function(module, exports, __webpack_require__) {
  42073. "use strict";
  42074. exports.__esModule = true;
  42075. exports.KEY = undefined;
  42076. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  42077. exports.default = columnLeftItem;
  42078. var _utils = __webpack_require__(19);
  42079. var _constants = __webpack_require__(7);
  42080. var C = _interopRequireWildcard(_constants);
  42081. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  42082. var KEY = exports.KEY = 'col_left';
  42083. function columnLeftItem() {
  42084. return {
  42085. key: KEY,
  42086. name: function name() {
  42087. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_INSERT_LEFT);
  42088. },
  42089. callback: function callback(key, normalizedSelection) {
  42090. var latestSelection = normalizedSelection[Math.max(normalizedSelection.length - 1, 0)];
  42091. this.alter('insert_col', latestSelection.start.col, 1, 'ContextMenu.columnLeft');
  42092. },
  42093. disabled: function disabled() {
  42094. var selected = (0, _utils.getValidSelection)(this);
  42095. if (!selected) {
  42096. return true;
  42097. }
  42098. if (!this.isColumnModificationAllowed()) {
  42099. return true;
  42100. }
  42101. var _selected$ = _slicedToArray(selected[0], 4),
  42102. startRow = _selected$[0],
  42103. startColumn = _selected$[1],
  42104. endRow = _selected$[2],
  42105. endColumn = _selected$[3];
  42106. var entireRowSelection = [startRow, 0, endRow, this.countCols() - 1];
  42107. var rowSelected = entireRowSelection.join(',') === selected.join(',');
  42108. var onlyOneColumn = this.countCols() === 1;
  42109. return startColumn < 0 || this.countCols() >= this.getSettings().maxCols || !onlyOneColumn && rowSelected;
  42110. },
  42111. hidden: function hidden() {
  42112. return !this.getSettings().allowInsertColumn;
  42113. }
  42114. };
  42115. }
  42116. /***/ }),
  42117. /* 425 */
  42118. /***/ (function(module, exports, __webpack_require__) {
  42119. "use strict";
  42120. exports.__esModule = true;
  42121. exports.KEY = undefined;
  42122. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  42123. exports.default = columnRightItem;
  42124. var _utils = __webpack_require__(19);
  42125. var _constants = __webpack_require__(7);
  42126. var C = _interopRequireWildcard(_constants);
  42127. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  42128. var KEY = exports.KEY = 'col_right';
  42129. function columnRightItem() {
  42130. return {
  42131. key: KEY,
  42132. name: function name() {
  42133. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_INSERT_RIGHT);
  42134. },
  42135. callback: function callback(key, normalizedSelection) {
  42136. var latestSelection = normalizedSelection[Math.max(normalizedSelection.length - 1, 0)];
  42137. this.alter('insert_col', latestSelection.end.col + 1, 1, 'ContextMenu.columnRight');
  42138. },
  42139. disabled: function disabled() {
  42140. var selected = (0, _utils.getValidSelection)(this);
  42141. if (!selected) {
  42142. return true;
  42143. }
  42144. if (!this.isColumnModificationAllowed()) {
  42145. return true;
  42146. }
  42147. var _selected$ = _slicedToArray(selected[0], 4),
  42148. startRow = _selected$[0],
  42149. startColumn = _selected$[1],
  42150. endRow = _selected$[2],
  42151. endColumn = _selected$[3];
  42152. var entireRowSelection = [startRow, 0, endRow, this.countCols() - 1];
  42153. var rowSelected = entireRowSelection.join(',') === selected.join(',');
  42154. var onlyOneColumn = this.countCols() === 1;
  42155. return startColumn < 0 || this.countCols() >= this.getSettings().maxCols || !onlyOneColumn && rowSelected;
  42156. },
  42157. hidden: function hidden() {
  42158. return !this.getSettings().allowInsertColumn;
  42159. }
  42160. };
  42161. }
  42162. /***/ }),
  42163. /* 426 */
  42164. /***/ (function(module, exports, __webpack_require__) {
  42165. "use strict";
  42166. exports.__esModule = true;
  42167. exports.KEY = undefined;
  42168. exports.default = readOnlyItem;
  42169. var _utils = __webpack_require__(19);
  42170. var _array = __webpack_require__(1);
  42171. var _constants = __webpack_require__(7);
  42172. var C = _interopRequireWildcard(_constants);
  42173. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  42174. var KEY = exports.KEY = 'make_read_only';
  42175. function readOnlyItem() {
  42176. return {
  42177. key: KEY,
  42178. name: function name() {
  42179. var _this = this;
  42180. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_READ_ONLY);
  42181. var atLeastOneReadOnly = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  42182. return _this.getCellMeta(row, col).readOnly;
  42183. });
  42184. if (atLeastOneReadOnly) {
  42185. label = (0, _utils.markLabelAsSelected)(label);
  42186. }
  42187. return label;
  42188. },
  42189. callback: function callback() {
  42190. var _this2 = this;
  42191. var ranges = this.getSelectedRange();
  42192. var atLeastOneReadOnly = (0, _utils.checkSelectionConsistency)(ranges, function (row, col) {
  42193. return _this2.getCellMeta(row, col).readOnly;
  42194. });
  42195. (0, _array.arrayEach)(ranges, function (range) {
  42196. range.forAll(function (row, col) {
  42197. _this2.setCellMeta(row, col, 'readOnly', !atLeastOneReadOnly);
  42198. });
  42199. });
  42200. this.render();
  42201. },
  42202. disabled: function disabled() {
  42203. return !(this.getSelectedRange() && !this.selection.isSelectedByCorner());
  42204. }
  42205. };
  42206. }
  42207. /***/ }),
  42208. /* 427 */
  42209. /***/ (function(module, exports, __webpack_require__) {
  42210. "use strict";
  42211. exports.__esModule = true;
  42212. exports.KEY = undefined;
  42213. exports.default = redoItem;
  42214. var _constants = __webpack_require__(7);
  42215. var C = _interopRequireWildcard(_constants);
  42216. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  42217. var KEY = exports.KEY = 'redo';
  42218. function redoItem() {
  42219. return {
  42220. key: KEY,
  42221. name: function name() {
  42222. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_REDO);
  42223. },
  42224. callback: function callback() {
  42225. this.redo();
  42226. },
  42227. disabled: function disabled() {
  42228. return this.undoRedo && !this.undoRedo.isRedoAvailable();
  42229. }
  42230. };
  42231. }
  42232. /***/ }),
  42233. /* 428 */
  42234. /***/ (function(module, exports, __webpack_require__) {
  42235. "use strict";
  42236. exports.__esModule = true;
  42237. exports.KEY = undefined;
  42238. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  42239. exports.default = removeColumnItem;
  42240. var _utils = __webpack_require__(19);
  42241. var _array = __webpack_require__(1);
  42242. var _utils2 = __webpack_require__(91);
  42243. var _constants = __webpack_require__(7);
  42244. var C = _interopRequireWildcard(_constants);
  42245. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  42246. var KEY = exports.KEY = 'remove_col';
  42247. function removeColumnItem() {
  42248. return {
  42249. key: KEY,
  42250. name: function name() {
  42251. var selection = this.getSelected();
  42252. var pluralForm = 0;
  42253. if (selection) {
  42254. if (selection.length > 1) {
  42255. pluralForm = 1;
  42256. } else {
  42257. var _selection$ = _slicedToArray(selection[0], 4),
  42258. fromColumn = _selection$[1],
  42259. toColumn = _selection$[3];
  42260. if (fromColumn - toColumn !== 0) {
  42261. pluralForm = 1;
  42262. }
  42263. }
  42264. }
  42265. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_REMOVE_COLUMN, pluralForm);
  42266. },
  42267. callback: function callback() {
  42268. this.alter('remove_col', (0, _utils2.transformSelectionToColumnDistance)(this.getSelected()), null, 'ContextMenu.removeColumn');
  42269. },
  42270. disabled: function disabled() {
  42271. var selected = (0, _utils.getValidSelection)(this);
  42272. var totalColumns = this.countCols();
  42273. if (!selected) {
  42274. return true;
  42275. }
  42276. return this.selection.isSelectedByRowHeader() || this.selection.isSelectedByCorner() || !this.isColumnModificationAllowed() || !totalColumns;
  42277. },
  42278. hidden: function hidden() {
  42279. return !this.getSettings().allowRemoveColumn;
  42280. }
  42281. };
  42282. }
  42283. /***/ }),
  42284. /* 429 */
  42285. /***/ (function(module, exports, __webpack_require__) {
  42286. "use strict";
  42287. exports.__esModule = true;
  42288. exports.KEY = undefined;
  42289. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  42290. exports.default = removeRowItem;
  42291. var _utils = __webpack_require__(19);
  42292. var _array = __webpack_require__(1);
  42293. var _utils2 = __webpack_require__(91);
  42294. var _constants = __webpack_require__(7);
  42295. var C = _interopRequireWildcard(_constants);
  42296. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  42297. var KEY = exports.KEY = 'remove_row';
  42298. function removeRowItem() {
  42299. return {
  42300. key: KEY,
  42301. name: function name() {
  42302. var selection = this.getSelected();
  42303. var pluralForm = 0;
  42304. if (selection) {
  42305. if (selection.length > 1) {
  42306. pluralForm = 1;
  42307. } else {
  42308. var _selection$ = _slicedToArray(selection[0], 3),
  42309. fromRow = _selection$[0],
  42310. toRow = _selection$[2];
  42311. if (fromRow - toRow !== 0) {
  42312. pluralForm = 1;
  42313. }
  42314. }
  42315. }
  42316. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_REMOVE_ROW, pluralForm);
  42317. },
  42318. callback: function callback() {
  42319. this.alter('remove_row', (0, _utils2.transformSelectionToRowDistance)(this.getSelected()), null, 'ContextMenu.removeRow');
  42320. },
  42321. disabled: function disabled() {
  42322. var selected = (0, _utils.getValidSelection)(this);
  42323. var totalRows = this.countRows();
  42324. if (!selected) {
  42325. return true;
  42326. }
  42327. return this.selection.isSelectedByColumnHeader() || this.selection.isSelectedByCorner() || !totalRows;
  42328. },
  42329. hidden: function hidden() {
  42330. return !this.getSettings().allowRemoveRow;
  42331. }
  42332. };
  42333. }
  42334. /***/ }),
  42335. /* 430 */
  42336. /***/ (function(module, exports, __webpack_require__) {
  42337. "use strict";
  42338. exports.__esModule = true;
  42339. exports.KEY = undefined;
  42340. exports.default = rowAboveItem;
  42341. var _utils = __webpack_require__(19);
  42342. var _constants = __webpack_require__(7);
  42343. var C = _interopRequireWildcard(_constants);
  42344. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  42345. var KEY = exports.KEY = 'row_above';
  42346. function rowAboveItem() {
  42347. return {
  42348. key: KEY,
  42349. name: function name() {
  42350. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ROW_ABOVE);
  42351. },
  42352. callback: function callback(key, normalizedSelection) {
  42353. var latestSelection = normalizedSelection[Math.max(normalizedSelection.length - 1, 0)];
  42354. this.alter('insert_row', latestSelection.start.row, 1, 'ContextMenu.rowAbove');
  42355. },
  42356. disabled: function disabled() {
  42357. var selected = (0, _utils.getValidSelection)(this);
  42358. if (!selected) {
  42359. return true;
  42360. }
  42361. return this.selection.isSelectedByColumnHeader() || this.countRows() >= this.getSettings().maxRows;
  42362. },
  42363. hidden: function hidden() {
  42364. return !this.getSettings().allowInsertRow;
  42365. }
  42366. };
  42367. }
  42368. /***/ }),
  42369. /* 431 */
  42370. /***/ (function(module, exports, __webpack_require__) {
  42371. "use strict";
  42372. exports.__esModule = true;
  42373. exports.KEY = undefined;
  42374. exports.default = rowBelowItem;
  42375. var _utils = __webpack_require__(19);
  42376. var _constants = __webpack_require__(7);
  42377. var C = _interopRequireWildcard(_constants);
  42378. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  42379. var KEY = exports.KEY = 'row_below';
  42380. function rowBelowItem() {
  42381. return {
  42382. key: KEY,
  42383. name: function name() {
  42384. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ROW_BELOW);
  42385. },
  42386. callback: function callback(key, normalizedSelection) {
  42387. var latestSelection = normalizedSelection[Math.max(normalizedSelection.length - 1, 0)];
  42388. this.alter('insert_row', latestSelection.end.row + 1, 1, 'ContextMenu.rowBelow');
  42389. },
  42390. disabled: function disabled() {
  42391. var selected = (0, _utils.getValidSelection)(this);
  42392. if (!selected) {
  42393. return true;
  42394. }
  42395. return this.selection.isSelectedByColumnHeader() || this.countRows() >= this.getSettings().maxRows;
  42396. },
  42397. hidden: function hidden() {
  42398. return !this.getSettings().allowInsertRow;
  42399. }
  42400. };
  42401. }
  42402. /***/ }),
  42403. /* 432 */
  42404. /***/ (function(module, exports, __webpack_require__) {
  42405. "use strict";
  42406. exports.__esModule = true;
  42407. exports.KEY = undefined;
  42408. exports.default = undoItem;
  42409. var _constants = __webpack_require__(7);
  42410. var C = _interopRequireWildcard(_constants);
  42411. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  42412. var KEY = exports.KEY = 'undo';
  42413. function undoItem() {
  42414. return {
  42415. key: KEY,
  42416. name: function name() {
  42417. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_UNDO);
  42418. },
  42419. callback: function callback() {
  42420. this.undo();
  42421. },
  42422. disabled: function disabled() {
  42423. return this.undoRedo && !this.undoRedo.isUndoAvailable();
  42424. }
  42425. };
  42426. }
  42427. /***/ }),
  42428. /* 433 */
  42429. /***/ (function(module, exports, __webpack_require__) {
  42430. "use strict";
  42431. exports.__esModule = true;
  42432. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  42433. var _core = __webpack_require__(88);
  42434. var _core2 = _interopRequireDefault(_core);
  42435. var _element = __webpack_require__(0);
  42436. var _array = __webpack_require__(1);
  42437. var _cursor = __webpack_require__(434);
  42438. var _cursor2 = _interopRequireDefault(_cursor);
  42439. var _eventManager = __webpack_require__(6);
  42440. var _eventManager2 = _interopRequireDefault(_eventManager);
  42441. var _object = __webpack_require__(2);
  42442. var _mixed = __webpack_require__(16);
  42443. var _function = __webpack_require__(43);
  42444. var _utils = __webpack_require__(19);
  42445. var _unicode = __webpack_require__(21);
  42446. var _localHooks = __webpack_require__(58);
  42447. var _localHooks2 = _interopRequireDefault(_localHooks);
  42448. var _predefinedItems = __webpack_require__(94);
  42449. var _event = __webpack_require__(12);
  42450. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  42451. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  42452. var MIN_WIDTH = 215;
  42453. /**
  42454. * @class Menu
  42455. * @plugin ContextMenu
  42456. */
  42457. var Menu = function () {
  42458. function Menu(hotInstance, options) {
  42459. _classCallCheck(this, Menu);
  42460. this.hot = hotInstance;
  42461. this.options = options || {
  42462. parent: null,
  42463. name: null,
  42464. className: '',
  42465. keepInViewport: true,
  42466. standalone: false,
  42467. minWidth: MIN_WIDTH
  42468. };
  42469. this.eventManager = new _eventManager2.default(this);
  42470. this.container = this.createContainer(this.options.name);
  42471. this.hotMenu = null;
  42472. this.hotSubMenus = {};
  42473. this.parentMenu = this.options.parent || null;
  42474. this.menuItems = null;
  42475. this.origOutsideClickDeselects = null;
  42476. this.keyEvent = false;
  42477. this.offset = {
  42478. above: 0,
  42479. below: 0,
  42480. left: 0,
  42481. right: 0
  42482. };
  42483. this._afterScrollCallback = null;
  42484. this.registerEvents();
  42485. }
  42486. /**
  42487. * Register event listeners.
  42488. *
  42489. * @private
  42490. */
  42491. _createClass(Menu, [{
  42492. key: 'registerEvents',
  42493. value: function registerEvents() {
  42494. var _this = this;
  42495. this.eventManager.addEventListener(document.documentElement, 'mousedown', function (event) {
  42496. return _this.onDocumentMouseDown(event);
  42497. });
  42498. }
  42499. /**
  42500. * Set array of objects which defines menu items.
  42501. *
  42502. * @param {Array} menuItems Menu items to display.
  42503. */
  42504. }, {
  42505. key: 'setMenuItems',
  42506. value: function setMenuItems(menuItems) {
  42507. this.menuItems = menuItems;
  42508. }
  42509. /**
  42510. * Set offset menu position for specified area (`above`, `below`, `left` or `right`).
  42511. *
  42512. * @param {String} area Specified area name (`above`, `below`, `left` or `right`).
  42513. * @param {Number} offset Offset value.
  42514. */
  42515. }, {
  42516. key: 'setOffset',
  42517. value: function setOffset(area) {
  42518. var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  42519. this.offset[area] = offset;
  42520. }
  42521. /**
  42522. * Check if menu is using as sub-menu.
  42523. *
  42524. * @returns {Boolean}
  42525. */
  42526. }, {
  42527. key: 'isSubMenu',
  42528. value: function isSubMenu() {
  42529. return this.parentMenu !== null;
  42530. }
  42531. /**
  42532. * Open menu.
  42533. *
  42534. * @fires Hooks#beforeContextMenuShow
  42535. * @fires Hooks#afterContextMenuShow
  42536. */
  42537. }, {
  42538. key: 'open',
  42539. value: function open() {
  42540. var _this2 = this;
  42541. this.runLocalHooks('beforeOpen');
  42542. this.container.removeAttribute('style');
  42543. this.container.style.display = 'block';
  42544. var delayedOpenSubMenu = (0, _function.debounce)(function (row) {
  42545. return _this2.openSubMenu(row);
  42546. }, 300);
  42547. var minWidthOfMenu = this.options.minWidth || MIN_WIDTH;
  42548. var filteredItems = (0, _array.arrayFilter)(this.menuItems, function (item) {
  42549. return (0, _utils.isItemHidden)(item, _this2.hot);
  42550. });
  42551. filteredItems = (0, _utils.filterSeparators)(filteredItems, _predefinedItems.SEPARATOR);
  42552. var settings = {
  42553. data: filteredItems,
  42554. colHeaders: false,
  42555. autoColumnSize: true,
  42556. modifyColWidth: function modifyColWidth(width) {
  42557. if ((0, _mixed.isDefined)(width) && width < minWidthOfMenu) {
  42558. return minWidthOfMenu;
  42559. }
  42560. return width;
  42561. },
  42562. autoRowSize: false,
  42563. readOnly: true,
  42564. copyPaste: false,
  42565. columns: [{
  42566. data: 'name',
  42567. renderer: function renderer(hot, TD, row, col, prop, value) {
  42568. return _this2.menuItemRenderer(hot, TD, row, col, prop, value);
  42569. }
  42570. }],
  42571. renderAllRows: true,
  42572. fragmentSelection: 'cell',
  42573. disableVisualSelection: 'area',
  42574. beforeKeyDown: function beforeKeyDown(event) {
  42575. return _this2.onBeforeKeyDown(event);
  42576. },
  42577. afterOnCellMouseOver: function afterOnCellMouseOver(event, coords, TD) {
  42578. if (_this2.isAllSubMenusClosed()) {
  42579. delayedOpenSubMenu(coords.row);
  42580. } else {
  42581. _this2.openSubMenu(coords.row);
  42582. }
  42583. },
  42584. rowHeights: function rowHeights(row) {
  42585. return filteredItems[row].name === _predefinedItems.SEPARATOR ? 1 : 23;
  42586. }
  42587. };
  42588. this.origOutsideClickDeselects = this.hot.getSettings().outsideClickDeselects;
  42589. this.hot.getSettings().outsideClickDeselects = false;
  42590. this.hotMenu = new _core2.default(this.container, settings);
  42591. this.hotMenu.addHook('afterInit', function () {
  42592. return _this2.onAfterInit();
  42593. });
  42594. this.hotMenu.addHook('afterSelection', function () {
  42595. return _this2.onAfterSelection.apply(_this2, arguments);
  42596. });
  42597. this.hotMenu.init();
  42598. this.hotMenu.listen();
  42599. this.blockMainTableCallbacks();
  42600. this.runLocalHooks('afterOpen');
  42601. }
  42602. /**
  42603. * Close menu.
  42604. *
  42605. * @param {Boolean} [closeParent=false] if `true` try to close parent menu if exists.
  42606. */
  42607. }, {
  42608. key: 'close',
  42609. value: function close() {
  42610. var closeParent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  42611. if (!this.isOpened()) {
  42612. return;
  42613. }
  42614. if (closeParent && this.parentMenu) {
  42615. this.parentMenu.close();
  42616. } else {
  42617. this.closeAllSubMenus();
  42618. this.container.style.display = 'none';
  42619. this.releaseMainTableCallbacks();
  42620. this.hotMenu.destroy();
  42621. this.hotMenu = null;
  42622. this.hot.getSettings().outsideClickDeselects = this.origOutsideClickDeselects;
  42623. this.runLocalHooks('afterClose');
  42624. if (this.parentMenu) {
  42625. this.parentMenu.hotMenu.listen();
  42626. }
  42627. }
  42628. }
  42629. /**
  42630. * Open sub menu at the provided row index.
  42631. *
  42632. * @param {Number} row Row index.
  42633. * @returns {Menu|Boolean} Returns created menu or `false` if no one menu was created.
  42634. */
  42635. }, {
  42636. key: 'openSubMenu',
  42637. value: function openSubMenu(row) {
  42638. if (!this.hotMenu) {
  42639. return false;
  42640. }
  42641. var cell = this.hotMenu.getCell(row, 0);
  42642. this.closeAllSubMenus();
  42643. if (!cell || !(0, _utils.hasSubMenu)(cell)) {
  42644. return false;
  42645. }
  42646. var dataItem = this.hotMenu.getSourceDataAtRow(row);
  42647. var subMenu = new Menu(this.hot, {
  42648. parent: this,
  42649. name: dataItem.name,
  42650. className: this.options.className,
  42651. keepInViewport: true
  42652. });
  42653. subMenu.setMenuItems(dataItem.submenu.items);
  42654. subMenu.open();
  42655. subMenu.setPosition(cell.getBoundingClientRect());
  42656. this.hotSubMenus[dataItem.key] = subMenu;
  42657. return subMenu;
  42658. }
  42659. /**
  42660. * Close sub menu at row index.
  42661. *
  42662. * @param {Number} row Row index.
  42663. */
  42664. }, {
  42665. key: 'closeSubMenu',
  42666. value: function closeSubMenu(row) {
  42667. var dataItem = this.hotMenu.getSourceDataAtRow(row);
  42668. var menus = this.hotSubMenus[dataItem.key];
  42669. if (menus) {
  42670. menus.destroy();
  42671. delete this.hotSubMenus[dataItem.key];
  42672. }
  42673. }
  42674. /**
  42675. * Close all opened sub menus.
  42676. */
  42677. }, {
  42678. key: 'closeAllSubMenus',
  42679. value: function closeAllSubMenus() {
  42680. var _this3 = this;
  42681. (0, _array.arrayEach)(this.hotMenu.getData(), function (value, row) {
  42682. return _this3.closeSubMenu(row);
  42683. });
  42684. }
  42685. /**
  42686. * Checks if all created and opened sub menus are closed.
  42687. *
  42688. * @returns {Boolean}
  42689. */
  42690. }, {
  42691. key: 'isAllSubMenusClosed',
  42692. value: function isAllSubMenusClosed() {
  42693. return Object.keys(this.hotSubMenus).length === 0;
  42694. }
  42695. /**
  42696. * Destroy instance.
  42697. */
  42698. }, {
  42699. key: 'destroy',
  42700. value: function destroy() {
  42701. this.clearLocalHooks();
  42702. this.close();
  42703. this.parentMenu = null;
  42704. this.eventManager.destroy();
  42705. }
  42706. /**
  42707. * Checks if menu was opened.
  42708. *
  42709. * @returns {Boolean} Returns `true` if menu was opened.
  42710. */
  42711. }, {
  42712. key: 'isOpened',
  42713. value: function isOpened() {
  42714. return this.hotMenu !== null;
  42715. }
  42716. /**
  42717. * Execute menu command.
  42718. *
  42719. * @param {Event} [event]
  42720. */
  42721. }, {
  42722. key: 'executeCommand',
  42723. value: function executeCommand(event) {
  42724. if (!this.isOpened() || !this.hotMenu.getSelectedLast()) {
  42725. return;
  42726. }
  42727. var selectedItem = this.hotMenu.getSourceDataAtRow(this.hotMenu.getSelectedLast()[0]);
  42728. this.runLocalHooks('select', selectedItem, event);
  42729. if (selectedItem.isCommand === false || selectedItem.name === _predefinedItems.SEPARATOR) {
  42730. return;
  42731. }
  42732. var selRanges = this.hot.getSelectedRange();
  42733. var normalizedSelection = selRanges ? (0, _utils.normalizeSelection)(selRanges) : [];
  42734. var autoClose = true;
  42735. // Don't close context menu if item is disabled or it has submenu
  42736. if (selectedItem.disabled === true || typeof selectedItem.disabled === 'function' && selectedItem.disabled.call(this.hot) === true || selectedItem.submenu) {
  42737. autoClose = false;
  42738. }
  42739. this.runLocalHooks('executeCommand', selectedItem.key, normalizedSelection, event);
  42740. if (this.isSubMenu()) {
  42741. this.parentMenu.runLocalHooks('executeCommand', selectedItem.key, normalizedSelection, event);
  42742. }
  42743. if (autoClose) {
  42744. this.close(true);
  42745. }
  42746. }
  42747. /**
  42748. * Set menu position based on dom event or based on literal object.
  42749. *
  42750. * @param {Event|Object} coords Event or literal Object with coordinates.
  42751. */
  42752. }, {
  42753. key: 'setPosition',
  42754. value: function setPosition(coords) {
  42755. var cursor = new _cursor2.default(coords);
  42756. if (this.options.keepInViewport) {
  42757. if (cursor.fitsBelow(this.container)) {
  42758. this.setPositionBelowCursor(cursor);
  42759. } else if (cursor.fitsAbove(this.container)) {
  42760. this.setPositionAboveCursor(cursor);
  42761. } else {
  42762. this.setPositionBelowCursor(cursor);
  42763. }
  42764. if (cursor.fitsOnRight(this.container)) {
  42765. this.setPositionOnRightOfCursor(cursor);
  42766. } else {
  42767. this.setPositionOnLeftOfCursor(cursor);
  42768. }
  42769. } else {
  42770. this.setPositionBelowCursor(cursor);
  42771. this.setPositionOnRightOfCursor(cursor);
  42772. }
  42773. }
  42774. /**
  42775. * Set menu position above cursor object.
  42776. *
  42777. * @param {Cursor} cursor `Cursor` object.
  42778. */
  42779. }, {
  42780. key: 'setPositionAboveCursor',
  42781. value: function setPositionAboveCursor(cursor) {
  42782. var top = this.offset.above + cursor.top - this.container.offsetHeight;
  42783. if (this.isSubMenu()) {
  42784. top = cursor.top + cursor.cellHeight - this.container.offsetHeight + 3;
  42785. }
  42786. this.container.style.top = top + 'px';
  42787. }
  42788. /**
  42789. * Set menu position below cursor object.
  42790. *
  42791. * @param {Cursor} cursor `Cursor` object.
  42792. */
  42793. }, {
  42794. key: 'setPositionBelowCursor',
  42795. value: function setPositionBelowCursor(cursor) {
  42796. var top = this.offset.below + cursor.top;
  42797. if (this.isSubMenu()) {
  42798. top = cursor.top - 1;
  42799. }
  42800. this.container.style.top = top + 'px';
  42801. }
  42802. /**
  42803. * Set menu position on the right of cursor object.
  42804. *
  42805. * @param {Cursor} cursor `Cursor` object.
  42806. */
  42807. }, {
  42808. key: 'setPositionOnRightOfCursor',
  42809. value: function setPositionOnRightOfCursor(cursor) {
  42810. var left = void 0;
  42811. if (this.isSubMenu()) {
  42812. left = 1 + cursor.left + cursor.cellWidth;
  42813. } else {
  42814. left = this.offset.right + 1 + cursor.left;
  42815. }
  42816. this.container.style.left = left + 'px';
  42817. }
  42818. /**
  42819. * Set menu position on the left of cursor object.
  42820. *
  42821. * @param {Cursor} cursor `Cursor` object.
  42822. */
  42823. }, {
  42824. key: 'setPositionOnLeftOfCursor',
  42825. value: function setPositionOnLeftOfCursor(cursor) {
  42826. var left = this.offset.left + cursor.left - this.container.offsetWidth + (0, _element.getScrollbarWidth)() + 4;
  42827. this.container.style.left = left + 'px';
  42828. }
  42829. /**
  42830. * Select first cell in opened menu.
  42831. */
  42832. }, {
  42833. key: 'selectFirstCell',
  42834. value: function selectFirstCell() {
  42835. var cell = this.hotMenu.getCell(0, 0);
  42836. if ((0, _utils.isSeparator)(cell) || (0, _utils.isDisabled)(cell) || (0, _utils.isSelectionDisabled)(cell)) {
  42837. this.selectNextCell(0, 0);
  42838. } else {
  42839. this.hotMenu.selectCell(0, 0);
  42840. }
  42841. }
  42842. /**
  42843. * Select last cell in opened menu.
  42844. */
  42845. }, {
  42846. key: 'selectLastCell',
  42847. value: function selectLastCell() {
  42848. var lastRow = this.hotMenu.countRows() - 1;
  42849. var cell = this.hotMenu.getCell(lastRow, 0);
  42850. if ((0, _utils.isSeparator)(cell) || (0, _utils.isDisabled)(cell) || (0, _utils.isSelectionDisabled)(cell)) {
  42851. this.selectPrevCell(lastRow, 0);
  42852. } else {
  42853. this.hotMenu.selectCell(lastRow, 0);
  42854. }
  42855. }
  42856. /**
  42857. * Select next cell in opened menu.
  42858. *
  42859. * @param {Number} row Row index.
  42860. * @param {Number} col Column index.
  42861. */
  42862. }, {
  42863. key: 'selectNextCell',
  42864. value: function selectNextCell(row, col) {
  42865. var nextRow = row + 1;
  42866. var cell = nextRow < this.hotMenu.countRows() ? this.hotMenu.getCell(nextRow, col) : null;
  42867. if (!cell) {
  42868. return;
  42869. }
  42870. if ((0, _utils.isSeparator)(cell) || (0, _utils.isDisabled)(cell) || (0, _utils.isSelectionDisabled)(cell)) {
  42871. this.selectNextCell(nextRow, col);
  42872. } else {
  42873. this.hotMenu.selectCell(nextRow, col);
  42874. }
  42875. }
  42876. /**
  42877. * Select previous cell in opened menu.
  42878. *
  42879. * @param {Number} row Row index.
  42880. * @param {Number} col Column index.
  42881. */
  42882. }, {
  42883. key: 'selectPrevCell',
  42884. value: function selectPrevCell(row, col) {
  42885. var prevRow = row - 1;
  42886. var cell = prevRow >= 0 ? this.hotMenu.getCell(prevRow, col) : null;
  42887. if (!cell) {
  42888. return;
  42889. }
  42890. if ((0, _utils.isSeparator)(cell) || (0, _utils.isDisabled)(cell) || (0, _utils.isSelectionDisabled)(cell)) {
  42891. this.selectPrevCell(prevRow, col);
  42892. } else {
  42893. this.hotMenu.selectCell(prevRow, col);
  42894. }
  42895. }
  42896. /**
  42897. * Menu item renderer.
  42898. *
  42899. * @private
  42900. */
  42901. }, {
  42902. key: 'menuItemRenderer',
  42903. value: function menuItemRenderer(hot, TD, row, col, prop, value) {
  42904. var _this4 = this;
  42905. var item = hot.getSourceDataAtRow(row);
  42906. var wrapper = document.createElement('div');
  42907. var isSubMenu = function isSubMenu(item) {
  42908. return (0, _object.hasOwnProperty)(item, 'submenu');
  42909. };
  42910. var itemIsSeparator = function itemIsSeparator(item) {
  42911. return new RegExp(_predefinedItems.SEPARATOR, 'i').test(item.name);
  42912. };
  42913. var itemIsDisabled = function itemIsDisabled(item) {
  42914. return item.disabled === true || typeof item.disabled == 'function' && item.disabled.call(_this4.hot) === true;
  42915. };
  42916. var itemIsSelectionDisabled = function itemIsSelectionDisabled(item) {
  42917. return item.disableSelection;
  42918. };
  42919. if (typeof value === 'function') {
  42920. value = value.call(this.hot);
  42921. }
  42922. (0, _element.empty)(TD);
  42923. (0, _element.addClass)(wrapper, 'htItemWrapper');
  42924. TD.appendChild(wrapper);
  42925. if (itemIsSeparator(item)) {
  42926. (0, _element.addClass)(TD, 'htSeparator');
  42927. } else if (typeof item.renderer === 'function') {
  42928. (0, _element.addClass)(TD, 'htCustomMenuRenderer');
  42929. TD.appendChild(item.renderer(hot, wrapper, row, col, prop, value));
  42930. } else {
  42931. (0, _element.fastInnerHTML)(wrapper, value);
  42932. }
  42933. if (itemIsDisabled(item)) {
  42934. (0, _element.addClass)(TD, 'htDisabled');
  42935. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  42936. return hot.deselectCell();
  42937. });
  42938. } else if (itemIsSelectionDisabled(item)) {
  42939. (0, _element.addClass)(TD, 'htSelectionDisabled');
  42940. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  42941. return hot.deselectCell();
  42942. });
  42943. } else if (isSubMenu(item)) {
  42944. (0, _element.addClass)(TD, 'htSubmenu');
  42945. if (itemIsSelectionDisabled(item)) {
  42946. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  42947. return hot.deselectCell();
  42948. });
  42949. } else {
  42950. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  42951. return hot.selectCell(row, col, void 0, void 0, false, false);
  42952. });
  42953. }
  42954. } else {
  42955. (0, _element.removeClass)(TD, 'htSubmenu');
  42956. (0, _element.removeClass)(TD, 'htDisabled');
  42957. if (itemIsSelectionDisabled(item)) {
  42958. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  42959. return hot.deselectCell();
  42960. });
  42961. } else {
  42962. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  42963. return hot.selectCell(row, col, void 0, void 0, false, false);
  42964. });
  42965. }
  42966. }
  42967. }
  42968. /**
  42969. * Create container/wrapper for handsontable.
  42970. *
  42971. * @private
  42972. * @param {String} [name] Class name.
  42973. * @returns {HTMLElement}
  42974. */
  42975. }, {
  42976. key: 'createContainer',
  42977. value: function createContainer() {
  42978. var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  42979. var container = void 0;
  42980. if (name) {
  42981. if ((0, _function.isFunction)(name)) {
  42982. name = name.call(this.hot);
  42983. if (name === null || (0, _mixed.isUndefined)(name)) {
  42984. name = '';
  42985. } else {
  42986. name = name.toString();
  42987. }
  42988. }
  42989. name = name.replace(/[^A-z0-9]/g, '_');
  42990. name = this.options.className + 'Sub_' + name;
  42991. container = document.querySelector('.' + this.options.className + '.' + name);
  42992. } else {
  42993. container = document.querySelector('.' + this.options.className);
  42994. }
  42995. if (!container) {
  42996. container = document.createElement('div');
  42997. (0, _element.addClass)(container, 'htMenu ' + this.options.className);
  42998. if (name) {
  42999. (0, _element.addClass)(container, name);
  43000. }
  43001. document.getElementsByTagName('body')[0].appendChild(container);
  43002. }
  43003. return container;
  43004. }
  43005. /**
  43006. * @private
  43007. */
  43008. }, {
  43009. key: 'blockMainTableCallbacks',
  43010. value: function blockMainTableCallbacks() {
  43011. this._afterScrollCallback = function () {};
  43012. this.hot.addHook('afterScrollVertically', this._afterScrollCallback);
  43013. this.hot.addHook('afterScrollHorizontally', this._afterScrollCallback);
  43014. }
  43015. /**
  43016. * @private
  43017. */
  43018. }, {
  43019. key: 'releaseMainTableCallbacks',
  43020. value: function releaseMainTableCallbacks() {
  43021. if (this._afterScrollCallback) {
  43022. this.hot.removeHook('afterScrollVertically', this._afterScrollCallback);
  43023. this.hot.removeHook('afterScrollHorizontally', this._afterScrollCallback);
  43024. this._afterScrollCallback = null;
  43025. }
  43026. }
  43027. /**
  43028. * On before key down listener.
  43029. *
  43030. * @private
  43031. * @param {Event} event
  43032. */
  43033. }, {
  43034. key: 'onBeforeKeyDown',
  43035. value: function onBeforeKeyDown(event) {
  43036. var selection = this.hotMenu.getSelectedLast();
  43037. var stopEvent = false;
  43038. this.keyEvent = true;
  43039. switch (event.keyCode) {
  43040. case _unicode.KEY_CODES.ESCAPE:
  43041. this.close();
  43042. stopEvent = true;
  43043. break;
  43044. case _unicode.KEY_CODES.ENTER:
  43045. if (selection) {
  43046. if (this.hotMenu.getSourceDataAtRow(selection[0]).submenu) {
  43047. stopEvent = true;
  43048. } else {
  43049. this.executeCommand(event);
  43050. this.close(true);
  43051. }
  43052. }
  43053. break;
  43054. case _unicode.KEY_CODES.ARROW_DOWN:
  43055. if (selection) {
  43056. this.selectNextCell(selection[0], selection[1]);
  43057. } else {
  43058. this.selectFirstCell();
  43059. }
  43060. stopEvent = true;
  43061. break;
  43062. case _unicode.KEY_CODES.ARROW_UP:
  43063. if (selection) {
  43064. this.selectPrevCell(selection[0], selection[1]);
  43065. } else {
  43066. this.selectLastCell();
  43067. }
  43068. stopEvent = true;
  43069. break;
  43070. case _unicode.KEY_CODES.ARROW_RIGHT:
  43071. if (selection) {
  43072. var menu = this.openSubMenu(selection[0]);
  43073. if (menu) {
  43074. menu.selectFirstCell();
  43075. }
  43076. }
  43077. stopEvent = true;
  43078. break;
  43079. case _unicode.KEY_CODES.ARROW_LEFT:
  43080. if (selection && this.isSubMenu()) {
  43081. this.close();
  43082. if (this.parentMenu) {
  43083. this.parentMenu.hotMenu.listen();
  43084. }
  43085. stopEvent = true;
  43086. }
  43087. break;
  43088. default:
  43089. break;
  43090. }
  43091. if (stopEvent) {
  43092. event.preventDefault();
  43093. (0, _event.stopImmediatePropagation)(event);
  43094. }
  43095. this.keyEvent = false;
  43096. }
  43097. /**
  43098. * On after init listener.
  43099. *
  43100. * @private
  43101. */
  43102. }, {
  43103. key: 'onAfterInit',
  43104. value: function onAfterInit() {
  43105. var data = this.hotMenu.getSettings().data;
  43106. var hiderStyle = this.hotMenu.view.wt.wtTable.hider.style;
  43107. var holderStyle = this.hotMenu.view.wt.wtTable.holder.style;
  43108. var currentHiderWidth = parseInt(hiderStyle.width, 10);
  43109. var realHeight = (0, _array.arrayReduce)(data, function (accumulator, value) {
  43110. return accumulator + (value.name === _predefinedItems.SEPARATOR ? 1 : 26);
  43111. }, 0);
  43112. holderStyle.width = currentHiderWidth + 22 + 'px';
  43113. holderStyle.height = realHeight + 4 + 'px';
  43114. hiderStyle.height = holderStyle.height;
  43115. }
  43116. /**
  43117. * On after selection listener.
  43118. *
  43119. * @param {Number} r Selection start row index.
  43120. * @param {Number} c Selection start column index.
  43121. * @param {Number} r2 Selection end row index.
  43122. * @param {Number} c2 Selection end column index.
  43123. * @param {Object} preventScrolling Object with `value` property where its value change will be observed.
  43124. * @param {Number} selectionLayerLevel The number which indicates what selection layer is currently modified.
  43125. */
  43126. }, {
  43127. key: 'onAfterSelection',
  43128. value: function onAfterSelection(r, c, r2, c2, preventScrolling) {
  43129. if (this.keyEvent === false) {
  43130. preventScrolling.value = true;
  43131. }
  43132. }
  43133. /**
  43134. * Document mouse down listener.
  43135. *
  43136. * @private
  43137. * @param {Event} event
  43138. */
  43139. }, {
  43140. key: 'onDocumentMouseDown',
  43141. value: function onDocumentMouseDown(event) {
  43142. if (!this.isOpened()) {
  43143. return;
  43144. }
  43145. if (this.container && (0, _element.isChildOf)(event.target, this.container)) {
  43146. this.executeCommand(event);
  43147. }
  43148. // Close menu when clicked element is not belongs to menu itself
  43149. if (this.options.standalone && this.hotMenu && !(0, _element.isChildOf)(event.target, this.hotMenu.rootElement)) {
  43150. this.close(true);
  43151. // Automatically close menu when clicked element is not belongs to menu or submenu (not necessarily to itself)
  43152. } else if ((this.isAllSubMenusClosed() || this.isSubMenu()) && !(0, _element.isChildOf)(event.target, '.htMenu') && (0, _element.isChildOf)(event.target, document)) {
  43153. this.close(true);
  43154. }
  43155. }
  43156. }]);
  43157. return Menu;
  43158. }();
  43159. (0, _object.mixin)(Menu, _localHooks2.default);
  43160. exports.default = Menu;
  43161. /***/ }),
  43162. /* 434 */
  43163. /***/ (function(module, exports, __webpack_require__) {
  43164. "use strict";
  43165. exports.__esModule = true;
  43166. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  43167. var _element = __webpack_require__(0);
  43168. var _event = __webpack_require__(12);
  43169. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  43170. /**
  43171. * Helper class for checking if element will fit at the desired side of cursor.
  43172. *
  43173. * @class Cursor
  43174. * @plugin ContextMenu
  43175. */
  43176. var Cursor = function () {
  43177. function Cursor(object) {
  43178. _classCallCheck(this, Cursor);
  43179. var windowScrollTop = (0, _element.getWindowScrollTop)();
  43180. var windowScrollLeft = (0, _element.getWindowScrollLeft)();
  43181. var top = void 0,
  43182. topRelative = void 0;
  43183. var left = void 0,
  43184. leftRelative = void 0;
  43185. var cellHeight = void 0,
  43186. cellWidth = void 0;
  43187. this.type = this.getSourceType(object);
  43188. if (this.type === 'literal') {
  43189. top = parseInt(object.top, 10);
  43190. left = parseInt(object.left, 10);
  43191. cellHeight = object.height || 0;
  43192. cellWidth = object.width || 0;
  43193. topRelative = top;
  43194. leftRelative = left;
  43195. top += windowScrollTop;
  43196. left += windowScrollLeft;
  43197. } else if (this.type === 'event') {
  43198. top = parseInt((0, _event.pageY)(object), 10);
  43199. left = parseInt((0, _event.pageX)(object), 10);
  43200. cellHeight = object.target.clientHeight;
  43201. cellWidth = object.target.clientWidth;
  43202. topRelative = top - windowScrollTop;
  43203. leftRelative = left - windowScrollLeft;
  43204. }
  43205. this.top = top;
  43206. this.topRelative = topRelative;
  43207. this.left = left;
  43208. this.leftRelative = leftRelative;
  43209. this.scrollTop = windowScrollTop;
  43210. this.scrollLeft = windowScrollLeft;
  43211. this.cellHeight = cellHeight;
  43212. this.cellWidth = cellWidth;
  43213. }
  43214. /**
  43215. * Get source type name.
  43216. *
  43217. * @param {*} object Event or Object with coordinates.
  43218. * @returns {String} Returns one of this values: `'literal'`, `'event'`.
  43219. */
  43220. _createClass(Cursor, [{
  43221. key: 'getSourceType',
  43222. value: function getSourceType(object) {
  43223. var type = 'literal';
  43224. if (object instanceof Event) {
  43225. type = 'event';
  43226. }
  43227. return type;
  43228. }
  43229. /**
  43230. * Checks if element can be placed above the cursor.
  43231. *
  43232. * @param {HTMLElement} element Element to check if it's size will fit above the cursor.
  43233. * @returns {Boolean}
  43234. */
  43235. }, {
  43236. key: 'fitsAbove',
  43237. value: function fitsAbove(element) {
  43238. return this.topRelative >= element.offsetHeight;
  43239. }
  43240. /**
  43241. * Checks if element can be placed below the cursor.
  43242. *
  43243. * @param {HTMLElement} element Element to check if it's size will fit below the cursor.
  43244. * @param {Number} [viewportHeight] The viewport height.
  43245. * @returns {Boolean}
  43246. */
  43247. }, {
  43248. key: 'fitsBelow',
  43249. value: function fitsBelow(element) {
  43250. var viewportHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.innerHeight;
  43251. return this.topRelative + element.offsetHeight <= viewportHeight;
  43252. }
  43253. /**
  43254. * Checks if element can be placed on the right of the cursor.
  43255. *
  43256. * @param {HTMLElement} element Element to check if it's size will fit on the right of the cursor.
  43257. * @param {Number} [viewportWidth] The viewport width.
  43258. * @returns {Boolean}
  43259. */
  43260. }, {
  43261. key: 'fitsOnRight',
  43262. value: function fitsOnRight(element) {
  43263. var viewportWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.innerWidth;
  43264. return this.leftRelative + this.cellWidth + element.offsetWidth <= viewportWidth;
  43265. }
  43266. /**
  43267. * Checks if element can be placed on the left on the cursor.
  43268. *
  43269. * @param {HTMLElement} element Element to check if it's size will fit on the left of the cursor.
  43270. * @returns {Boolean}
  43271. */
  43272. }, {
  43273. key: 'fitsOnLeft',
  43274. value: function fitsOnLeft(element) {
  43275. return this.leftRelative >= element.offsetWidth;
  43276. }
  43277. }]);
  43278. return Cursor;
  43279. }();
  43280. exports.default = Cursor;
  43281. /***/ }),
  43282. /* 435 */
  43283. /***/ (function(module, exports) {
  43284. // removed by extract-text-webpack-plugin
  43285. /***/ }),
  43286. /* 436 */
  43287. /***/ (function(module, exports, __webpack_require__) {
  43288. "use strict";
  43289. exports.__esModule = true;
  43290. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  43291. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  43292. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  43293. var _base = __webpack_require__(10);
  43294. var _base2 = _interopRequireDefault(_base);
  43295. var _pluginHooks = __webpack_require__(15);
  43296. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  43297. var _SheetClip = __webpack_require__(311);
  43298. var _SheetClip2 = _interopRequireDefault(_SheetClip);
  43299. var _src = __webpack_require__(4);
  43300. var _element = __webpack_require__(0);
  43301. var _array = __webpack_require__(1);
  43302. var _number = __webpack_require__(5);
  43303. var _plugins = __webpack_require__(8);
  43304. var _textarea = __webpack_require__(437);
  43305. var _textarea2 = _interopRequireDefault(_textarea);
  43306. var _copy = __webpack_require__(438);
  43307. var _copy2 = _interopRequireDefault(_copy);
  43308. var _cut = __webpack_require__(439);
  43309. var _cut2 = _interopRequireDefault(_cut);
  43310. var _eventManager = __webpack_require__(6);
  43311. var _eventManager2 = _interopRequireDefault(_eventManager);
  43312. var _pasteEvent = __webpack_require__(440);
  43313. var _pasteEvent2 = _interopRequireDefault(_pasteEvent);
  43314. __webpack_require__(442);
  43315. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  43316. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  43317. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  43318. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  43319. _pluginHooks2.default.getSingleton().register('afterCopyLimit');
  43320. _pluginHooks2.default.getSingleton().register('modifyCopyableRange');
  43321. _pluginHooks2.default.getSingleton().register('beforeCut');
  43322. _pluginHooks2.default.getSingleton().register('afterCut');
  43323. _pluginHooks2.default.getSingleton().register('beforePaste');
  43324. _pluginHooks2.default.getSingleton().register('afterPaste');
  43325. _pluginHooks2.default.getSingleton().register('beforeCopy');
  43326. _pluginHooks2.default.getSingleton().register('afterCopy');
  43327. var ROWS_LIMIT = 1000;
  43328. var COLUMNS_LIMIT = 1000;
  43329. var privatePool = new WeakMap();
  43330. /**
  43331. * @description
  43332. * This plugin enables the copy/paste functionality in the Handsontable.
  43333. *
  43334. * @example
  43335. * ```js
  43336. * ...
  43337. * copyPaste: true,
  43338. * ...
  43339. * ```
  43340. * @class CopyPaste
  43341. * @plugin CopyPaste
  43342. */
  43343. var CopyPaste = function (_BasePlugin) {
  43344. _inherits(CopyPaste, _BasePlugin);
  43345. function CopyPaste(hotInstance) {
  43346. _classCallCheck(this, CopyPaste);
  43347. /**
  43348. * Event manager
  43349. *
  43350. * @type {EventManager}
  43351. */
  43352. var _this = _possibleConstructorReturn(this, (CopyPaste.__proto__ || Object.getPrototypeOf(CopyPaste)).call(this, hotInstance));
  43353. _this.eventManager = new _eventManager2.default(_this);
  43354. /**
  43355. * Maximum number of columns than can be copied to clipboard using <kbd>CTRL</kbd> + <kbd>C</kbd>.
  43356. *
  43357. * @private
  43358. * @type {Number}
  43359. * @default 1000
  43360. */
  43361. _this.columnsLimit = COLUMNS_LIMIT;
  43362. /**
  43363. * Ranges of the cells coordinates, which should be used to copy/cut/paste actions.
  43364. *
  43365. * @private
  43366. * @type {Array}
  43367. */
  43368. _this.copyableRanges = [];
  43369. /**
  43370. * Defines paste (<kbd>CTRL</kbd> + <kbd>V</kbd>) behavior.
  43371. * * Default value `"overwrite"` will paste clipboard value over current selection.
  43372. * * When set to `"shift_down"`, clipboard data will be pasted in place of current selection, while all selected cells are moved down.
  43373. * * When set to `"shift_right"`, clipboard data will be pasted in place of current selection, while all selected cells are moved right.
  43374. *
  43375. * @private
  43376. * @type {String}
  43377. * @default 'overwrite'
  43378. */
  43379. _this.pasteMode = 'overwrite';
  43380. /**
  43381. * Maximum number of rows than can be copied to clipboard using <kbd>CTRL</kbd> + <kbd>C</kbd>.
  43382. *
  43383. * @private
  43384. * @type {Number}
  43385. * @default 1000
  43386. */
  43387. _this.rowsLimit = ROWS_LIMIT;
  43388. /**
  43389. * The `textarea` element which is necessary to process copying, cutting off and pasting.
  43390. *
  43391. * @private
  43392. * @type {HTMLElement}
  43393. * @default undefined
  43394. */
  43395. _this.textarea = void 0;
  43396. privatePool.set(_this, {
  43397. isTriggeredByCopy: false,
  43398. isTriggeredByCut: false,
  43399. isBeginEditing: false,
  43400. isFragmentSelectionEnabled: false
  43401. });
  43402. return _this;
  43403. }
  43404. /**
  43405. * Check if plugin is enabled.
  43406. *
  43407. * @returns {Boolean}
  43408. */
  43409. _createClass(CopyPaste, [{
  43410. key: 'isEnabled',
  43411. value: function isEnabled() {
  43412. return !!this.hot.getSettings().copyPaste;
  43413. }
  43414. /**
  43415. * Enable the plugin.
  43416. */
  43417. }, {
  43418. key: 'enablePlugin',
  43419. value: function enablePlugin() {
  43420. var _this2 = this;
  43421. if (this.enabled) {
  43422. return;
  43423. }
  43424. var settings = this.hot.getSettings();
  43425. var priv = privatePool.get(this);
  43426. this.textarea = _textarea2.default.getSingleton();
  43427. priv.isFragmentSelectionEnabled = settings.fragmentSelection;
  43428. if (_typeof(settings.copyPaste) === 'object') {
  43429. this.pasteMode = settings.copyPaste.pasteMode || this.pasteMode;
  43430. this.rowsLimit = settings.copyPaste.rowsLimit || this.rowsLimit;
  43431. this.columnsLimit = settings.copyPaste.columnsLimit || this.columnsLimit;
  43432. }
  43433. this.addHook('afterContextMenuDefaultOptions', function (options) {
  43434. return _this2.onAfterContextMenuDefaultOptions(options);
  43435. });
  43436. this.addHook('afterSelectionEnd', function () {
  43437. return _this2.onAfterSelectionEnd();
  43438. });
  43439. this.registerEvents();
  43440. _get(CopyPaste.prototype.__proto__ || Object.getPrototypeOf(CopyPaste.prototype), 'enablePlugin', this).call(this);
  43441. }
  43442. /**
  43443. * Updates the plugin to use the latest options you have specified.
  43444. */
  43445. }, {
  43446. key: 'updatePlugin',
  43447. value: function updatePlugin() {
  43448. this.disablePlugin();
  43449. this.enablePlugin();
  43450. _get(CopyPaste.prototype.__proto__ || Object.getPrototypeOf(CopyPaste.prototype), 'updatePlugin', this).call(this);
  43451. }
  43452. /**
  43453. * Disable plugin for this Handsontable instance.
  43454. */
  43455. }, {
  43456. key: 'disablePlugin',
  43457. value: function disablePlugin() {
  43458. if (this.textarea) {
  43459. this.textarea.destroy();
  43460. }
  43461. _get(CopyPaste.prototype.__proto__ || Object.getPrototypeOf(CopyPaste.prototype), 'disablePlugin', this).call(this);
  43462. }
  43463. /**
  43464. * Prepares copyable text from the cells selection in the invisible textarea.
  43465. *
  43466. * @function setCopyable
  43467. * @memberof CopyPaste#
  43468. */
  43469. }, {
  43470. key: 'setCopyableText',
  43471. value: function setCopyableText() {
  43472. var selRange = this.hot.getSelectedRangeLast();
  43473. if (!selRange) {
  43474. return;
  43475. }
  43476. var topLeft = selRange.getTopLeftCorner();
  43477. var bottomRight = selRange.getBottomRightCorner();
  43478. var startRow = topLeft.row;
  43479. var startCol = topLeft.col;
  43480. var endRow = bottomRight.row;
  43481. var endCol = bottomRight.col;
  43482. var finalEndRow = Math.min(endRow, startRow + this.rowsLimit - 1);
  43483. var finalEndCol = Math.min(endCol, startCol + this.columnsLimit - 1);
  43484. this.copyableRanges.length = 0;
  43485. this.copyableRanges.push({
  43486. startRow: startRow,
  43487. startCol: startCol,
  43488. endRow: finalEndRow,
  43489. endCol: finalEndCol
  43490. });
  43491. this.copyableRanges = this.hot.runHooks('modifyCopyableRange', this.copyableRanges);
  43492. if (endRow !== finalEndRow || endCol !== finalEndCol) {
  43493. this.hot.runHooks('afterCopyLimit', endRow - startRow + 1, endCol - startCol + 1, this.rowsLimit, this.columnsLimit);
  43494. }
  43495. }
  43496. /**
  43497. * Create copyable text releated to range objects.
  43498. *
  43499. * @since 0.19.0
  43500. * @param {Array} ranges Array of Objects with properties `startRow`, `endRow`, `startCol` and `endCol`.
  43501. * @returns {String} Returns string which will be copied into clipboard.
  43502. */
  43503. }, {
  43504. key: 'getRangedCopyableData',
  43505. value: function getRangedCopyableData(ranges) {
  43506. var _this3 = this;
  43507. var dataSet = [];
  43508. var copyableRows = [];
  43509. var copyableColumns = [];
  43510. // Count all copyable rows and columns
  43511. (0, _array.arrayEach)(ranges, function (range) {
  43512. (0, _number.rangeEach)(range.startRow, range.endRow, function (row) {
  43513. if (copyableRows.indexOf(row) === -1) {
  43514. copyableRows.push(row);
  43515. }
  43516. });
  43517. (0, _number.rangeEach)(range.startCol, range.endCol, function (column) {
  43518. if (copyableColumns.indexOf(column) === -1) {
  43519. copyableColumns.push(column);
  43520. }
  43521. });
  43522. });
  43523. // Concat all rows and columns data defined in ranges into one copyable string
  43524. (0, _array.arrayEach)(copyableRows, function (row) {
  43525. var rowSet = [];
  43526. (0, _array.arrayEach)(copyableColumns, function (column) {
  43527. rowSet.push(_this3.hot.getCopyableData(row, column));
  43528. });
  43529. dataSet.push(rowSet);
  43530. });
  43531. return _SheetClip2.default.stringify(dataSet);
  43532. }
  43533. /**
  43534. * Create copyable text releated to range objects.
  43535. *
  43536. * @since 0.31.1
  43537. * @param {Array} ranges Array of Objects with properties `startRow`, `startCol`, `endRow` and `endCol`.
  43538. * @returns {Array} Returns array of arrays which will be copied into clipboard.
  43539. */
  43540. }, {
  43541. key: 'getRangedData',
  43542. value: function getRangedData(ranges) {
  43543. var _this4 = this;
  43544. var dataSet = [];
  43545. var copyableRows = [];
  43546. var copyableColumns = [];
  43547. // Count all copyable rows and columns
  43548. (0, _array.arrayEach)(ranges, function (range) {
  43549. (0, _number.rangeEach)(range.startRow, range.endRow, function (row) {
  43550. if (copyableRows.indexOf(row) === -1) {
  43551. copyableRows.push(row);
  43552. }
  43553. });
  43554. (0, _number.rangeEach)(range.startCol, range.endCol, function (column) {
  43555. if (copyableColumns.indexOf(column) === -1) {
  43556. copyableColumns.push(column);
  43557. }
  43558. });
  43559. });
  43560. // Concat all rows and columns data defined in ranges into one copyable string
  43561. (0, _array.arrayEach)(copyableRows, function (row) {
  43562. var rowSet = [];
  43563. (0, _array.arrayEach)(copyableColumns, function (column) {
  43564. rowSet.push(_this4.hot.getCopyableData(row, column));
  43565. });
  43566. dataSet.push(rowSet);
  43567. });
  43568. return dataSet;
  43569. }
  43570. /**
  43571. * Copy action.
  43572. */
  43573. }, {
  43574. key: 'copy',
  43575. value: function copy() {
  43576. var priv = privatePool.get(this);
  43577. priv.isTriggeredByCopy = true;
  43578. this.textarea.select();
  43579. document.execCommand('copy');
  43580. }
  43581. /**
  43582. * Cut action.
  43583. */
  43584. }, {
  43585. key: 'cut',
  43586. value: function cut() {
  43587. var priv = privatePool.get(this);
  43588. priv.isTriggeredByCut = true;
  43589. this.textarea.select();
  43590. document.execCommand('cut');
  43591. }
  43592. /**
  43593. * Simulated paste action.
  43594. *
  43595. * @param {String} [value=''] New value, which should be `pasted`.
  43596. */
  43597. }, {
  43598. key: 'paste',
  43599. value: function paste() {
  43600. var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  43601. var pasteData = new _pasteEvent2.default();
  43602. pasteData.clipboardData.setData('text/plain', value);
  43603. this.onPaste(pasteData);
  43604. }
  43605. /**
  43606. * Register event listeners.
  43607. *
  43608. * @private
  43609. */
  43610. }, {
  43611. key: 'registerEvents',
  43612. value: function registerEvents() {
  43613. var _this5 = this;
  43614. this.eventManager.addEventListener(this.textarea.element, 'paste', function (event) {
  43615. return _this5.onPaste(event);
  43616. });
  43617. this.eventManager.addEventListener(this.textarea.element, 'cut', function (event) {
  43618. return _this5.onCut(event);
  43619. });
  43620. this.eventManager.addEventListener(this.textarea.element, 'copy', function (event) {
  43621. return _this5.onCopy(event);
  43622. });
  43623. }
  43624. /**
  43625. * `copy` event callback on textarea element.
  43626. *
  43627. * @param {Event} event ClipboardEvent.
  43628. * @private
  43629. */
  43630. }, {
  43631. key: 'onCopy',
  43632. value: function onCopy(event) {
  43633. var priv = privatePool.get(this);
  43634. if (!this.hot.isListening() && !priv.isTriggeredByCopy) {
  43635. return;
  43636. }
  43637. this.setCopyableText();
  43638. priv.isTriggeredByCopy = false;
  43639. var rangedData = this.getRangedData(this.copyableRanges);
  43640. var allowCopying = !!this.hot.runHooks('beforeCopy', rangedData, this.copyableRanges);
  43641. var value = '';
  43642. if (allowCopying) {
  43643. value = _SheetClip2.default.stringify(rangedData);
  43644. if (event && event.clipboardData) {
  43645. event.clipboardData.setData('text/plain', value);
  43646. } else if (typeof ClipboardEvent === 'undefined') {
  43647. window.clipboardData.setData('Text', value);
  43648. }
  43649. this.hot.runHooks('afterCopy', rangedData, this.copyableRanges);
  43650. }
  43651. event.preventDefault();
  43652. }
  43653. /**
  43654. * `cut` event callback on textarea element.
  43655. *
  43656. * @param {Event} event ClipboardEvent.
  43657. * @private
  43658. */
  43659. }, {
  43660. key: 'onCut',
  43661. value: function onCut(event) {
  43662. var priv = privatePool.get(this);
  43663. if (!this.hot.isListening() && !priv.isTriggeredByCut) {
  43664. return;
  43665. }
  43666. this.setCopyableText();
  43667. priv.isTriggeredByCut = false;
  43668. var rangedData = this.getRangedData(this.copyableRanges);
  43669. var allowCuttingOut = !!this.hot.runHooks('beforeCut', rangedData, this.copyableRanges);
  43670. var value = void 0;
  43671. if (allowCuttingOut) {
  43672. value = _SheetClip2.default.stringify(rangedData);
  43673. if (event && event.clipboardData) {
  43674. event.clipboardData.setData('text/plain', value);
  43675. } else if (typeof ClipboardEvent === 'undefined') {
  43676. window.clipboardData.setData('Text', value);
  43677. }
  43678. this.hot.emptySelectedCells();
  43679. this.hot.runHooks('afterCut', rangedData, this.copyableRanges);
  43680. }
  43681. event.preventDefault();
  43682. }
  43683. /**
  43684. * `paste` event callback on textarea element.
  43685. *
  43686. * @param {Event} event ClipboardEvent or pseudo ClipboardEvent, if paste was called manually.
  43687. * @private
  43688. */
  43689. }, {
  43690. key: 'onPaste',
  43691. value: function onPaste(event) {
  43692. var _this6 = this;
  43693. if (!this.hot.isListening()) {
  43694. return;
  43695. }
  43696. if (event && event.preventDefault) {
  43697. event.preventDefault();
  43698. }
  43699. var inputArray = void 0;
  43700. if (event && typeof event.clipboardData !== 'undefined') {
  43701. this.textarea.setValue(event.clipboardData.getData('text/plain'));
  43702. } else if (typeof ClipboardEvent === 'undefined' && typeof window.clipboardData !== 'undefined') {
  43703. this.textarea.setValue(window.clipboardData.getData('Text'));
  43704. }
  43705. inputArray = _SheetClip2.default.parse(this.textarea.getValue());
  43706. this.textarea.setValue(' ');
  43707. if (inputArray.length === 0) {
  43708. return;
  43709. }
  43710. var allowPasting = !!this.hot.runHooks('beforePaste', inputArray, this.copyableRanges);
  43711. if (!allowPasting) {
  43712. return;
  43713. }
  43714. var selected = this.hot.getSelectedLast();
  43715. var coordsFrom = new _src.CellCoords(selected[0], selected[1]);
  43716. var coordsTo = new _src.CellCoords(selected[2], selected[3]);
  43717. var cellRange = new _src.CellRange(coordsFrom, coordsFrom, coordsTo);
  43718. var topLeftCorner = cellRange.getTopLeftCorner();
  43719. var bottomRightCorner = cellRange.getBottomRightCorner();
  43720. var areaStart = topLeftCorner;
  43721. var areaEnd = new _src.CellCoords(Math.max(bottomRightCorner.row, inputArray.length - 1 + topLeftCorner.row), Math.max(bottomRightCorner.col, inputArray[0].length - 1 + topLeftCorner.col));
  43722. var isSelRowAreaCoverInputValue = coordsTo.row - coordsFrom.row >= inputArray.length - 1;
  43723. var isSelColAreaCoverInputValue = coordsTo.col - coordsFrom.col >= inputArray[0].length - 1;
  43724. this.hot.addHookOnce('afterChange', function (changes) {
  43725. var changesLength = changes ? changes.length : 0;
  43726. if (changesLength) {
  43727. var offset = { row: 0, col: 0 };
  43728. var highestColumnIndex = -1;
  43729. (0, _array.arrayEach)(changes, function (change, index) {
  43730. var nextChange = changesLength > index + 1 ? changes[index + 1] : null;
  43731. if (nextChange) {
  43732. if (!isSelRowAreaCoverInputValue) {
  43733. offset.row += Math.max(nextChange[0] - change[0] - 1, 0);
  43734. }
  43735. if (!isSelColAreaCoverInputValue && change[1] > highestColumnIndex) {
  43736. highestColumnIndex = change[1];
  43737. offset.col += Math.max(nextChange[1] - change[1] - 1, 0);
  43738. }
  43739. }
  43740. });
  43741. _this6.hot.selectCell(areaStart.row, areaStart.col, areaEnd.row + offset.row, areaEnd.col + offset.col);
  43742. }
  43743. });
  43744. this.hot.populateFromArray(areaStart.row, areaStart.col, inputArray, areaEnd.row, areaEnd.col, 'CopyPaste.paste', this.pasteMode);
  43745. this.hot.runHooks('afterPaste', inputArray, this.copyableRanges);
  43746. }
  43747. /**
  43748. * Add copy, cut and paste options to the Context Menu.
  43749. *
  43750. * @private
  43751. * @param {Object} options Contains default added options of the Context Menu.
  43752. */
  43753. }, {
  43754. key: 'onAfterContextMenuDefaultOptions',
  43755. value: function onAfterContextMenuDefaultOptions(options) {
  43756. options.items.push({
  43757. name: '---------'
  43758. }, (0, _copy2.default)(this), (0, _cut2.default)(this));
  43759. }
  43760. /**
  43761. * We have to keep focus on textarea element, to make possible use of the browser tools (copy, cut, paste).
  43762. *
  43763. * @private
  43764. */
  43765. }, {
  43766. key: 'onAfterSelectionEnd',
  43767. value: function onAfterSelectionEnd() {
  43768. var priv = privatePool.get(this);
  43769. var editor = this.hot.getActiveEditor();
  43770. if (editor && typeof editor.isOpened !== 'undefined' && editor.isOpened()) {
  43771. return;
  43772. }
  43773. if (priv.isFragmentSelectionEnabled && !this.textarea.isActive() && (0, _element.getSelectionText)()) {
  43774. return;
  43775. }
  43776. this.setCopyableText();
  43777. this.textarea.select();
  43778. }
  43779. /**
  43780. * Destroy plugin instance.
  43781. */
  43782. }, {
  43783. key: 'destroy',
  43784. value: function destroy() {
  43785. if (this.textarea) {
  43786. this.textarea.destroy();
  43787. }
  43788. _get(CopyPaste.prototype.__proto__ || Object.getPrototypeOf(CopyPaste.prototype), 'destroy', this).call(this);
  43789. }
  43790. }]);
  43791. return CopyPaste;
  43792. }(_base2.default);
  43793. (0, _plugins.registerPlugin)('CopyPaste', CopyPaste);
  43794. exports.default = CopyPaste;
  43795. /***/ }),
  43796. /* 437 */
  43797. /***/ (function(module, exports, __webpack_require__) {
  43798. "use strict";
  43799. exports.__esModule = true;
  43800. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  43801. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  43802. /**
  43803. * @class Textarea
  43804. *
  43805. * @plugin CopyPaste
  43806. */
  43807. var Textarea = function () {
  43808. _createClass(Textarea, null, [{
  43809. key: 'getSingleton',
  43810. value: function getSingleton() {
  43811. globalSingleton.append();
  43812. return globalSingleton;
  43813. }
  43814. }]);
  43815. function Textarea() {
  43816. _classCallCheck(this, Textarea);
  43817. /**
  43818. * Main textarea element.
  43819. *
  43820. * @type {HTMLElement}
  43821. */
  43822. this.element = void 0;
  43823. /**
  43824. * Store information about append to the document.body.
  43825. *
  43826. * @type {Boolean}
  43827. */
  43828. this.isAppended = false;
  43829. /**
  43830. * Reference counter.
  43831. *
  43832. * @type {Number}
  43833. */
  43834. this.refCounter = 0;
  43835. }
  43836. /**
  43837. * Apends textarea element to the `body`
  43838. */
  43839. _createClass(Textarea, [{
  43840. key: 'append',
  43841. value: function append() {
  43842. if (this.hasBeenDestroyed()) {
  43843. this.create();
  43844. }
  43845. this.refCounter++;
  43846. if (!this.isAppended && document.body) {
  43847. if (document.body) {
  43848. this.isAppended = true;
  43849. document.body.appendChild(this.element);
  43850. }
  43851. }
  43852. }
  43853. /**
  43854. * Prepares textarea element with proper attributes.
  43855. */
  43856. }, {
  43857. key: 'create',
  43858. value: function create() {
  43859. this.element = document.createElement('textarea');
  43860. this.element.id = 'HandsontableCopyPaste';
  43861. this.element.className = 'copyPaste';
  43862. this.element.tabIndex = -1;
  43863. this.element.autocomplete = 'off';
  43864. this.element.wrap = 'hard';
  43865. this.element.value = ' ';
  43866. }
  43867. /**
  43868. * Deselects textarea element if is active.
  43869. */
  43870. }, {
  43871. key: 'deselect',
  43872. value: function deselect() {
  43873. if (this.element === document.activeElement) {
  43874. document.activeElement.blur();
  43875. }
  43876. }
  43877. /**
  43878. * Destroy instance
  43879. */
  43880. }, {
  43881. key: 'destroy',
  43882. value: function destroy() {
  43883. this.refCounter--;
  43884. this.refCounter = this.refCounter < 0 ? 0 : this.refCounter;
  43885. if (this.hasBeenDestroyed() && this.element && this.element.parentNode) {
  43886. this.element.parentNode.removeChild(this.element);
  43887. this.element = null;
  43888. this.isAppended = false;
  43889. }
  43890. }
  43891. /**
  43892. * Getter for the element.
  43893. *
  43894. * @returns {String}
  43895. */
  43896. }, {
  43897. key: 'getValue',
  43898. value: function getValue() {
  43899. return this.element.value;
  43900. }
  43901. /**
  43902. * Check if instance has been destroyed
  43903. *
  43904. * @returns {Boolean}
  43905. */
  43906. }, {
  43907. key: 'hasBeenDestroyed',
  43908. value: function hasBeenDestroyed() {
  43909. return this.refCounter < 1;
  43910. }
  43911. /**
  43912. * Check if the element is an active element in frame.
  43913. *
  43914. * @returns {Boolean}
  43915. */
  43916. }, {
  43917. key: 'isActive',
  43918. value: function isActive() {
  43919. return this.element === document.activeElement;
  43920. }
  43921. /**
  43922. * Sets focus on the element and select content.
  43923. */
  43924. }, {
  43925. key: 'select',
  43926. value: function select() {
  43927. this.element.focus();
  43928. this.element.select();
  43929. }
  43930. /**
  43931. * Setter for the element.
  43932. *
  43933. * @param {String} data Value which should be insert into the element.
  43934. */
  43935. }, {
  43936. key: 'setValue',
  43937. value: function setValue(data) {
  43938. this.element.value = data;
  43939. }
  43940. }]);
  43941. return Textarea;
  43942. }();
  43943. var globalSingleton = new Textarea();
  43944. exports.default = Textarea;
  43945. /***/ }),
  43946. /* 438 */
  43947. /***/ (function(module, exports, __webpack_require__) {
  43948. "use strict";
  43949. exports.__esModule = true;
  43950. exports.default = copyItem;
  43951. var _constants = __webpack_require__(7);
  43952. var C = _interopRequireWildcard(_constants);
  43953. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  43954. function copyItem(copyPastePlugin) {
  43955. return {
  43956. key: 'copy',
  43957. name: function name() {
  43958. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_COPY);
  43959. },
  43960. callback: function callback() {
  43961. copyPastePlugin.copy();
  43962. },
  43963. disabled: function disabled() {
  43964. var selected = this.getSelected();
  43965. if (!selected || selected.length > 1) {
  43966. return true;
  43967. }
  43968. return false;
  43969. },
  43970. hidden: false
  43971. };
  43972. }
  43973. /***/ }),
  43974. /* 439 */
  43975. /***/ (function(module, exports, __webpack_require__) {
  43976. "use strict";
  43977. exports.__esModule = true;
  43978. exports.default = cutItem;
  43979. var _constants = __webpack_require__(7);
  43980. var C = _interopRequireWildcard(_constants);
  43981. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  43982. function cutItem(copyPastePlugin) {
  43983. return {
  43984. key: 'cut',
  43985. name: function name() {
  43986. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_CUT);
  43987. },
  43988. callback: function callback() {
  43989. copyPastePlugin.cut();
  43990. },
  43991. disabled: function disabled() {
  43992. var selected = this.getSelected();
  43993. if (!selected || selected.length > 1) {
  43994. return true;
  43995. }
  43996. return false;
  43997. },
  43998. hidden: false
  43999. };
  44000. }
  44001. /***/ }),
  44002. /* 440 */
  44003. /***/ (function(module, exports, __webpack_require__) {
  44004. "use strict";
  44005. exports.__esModule = true;
  44006. var _clipboardData = __webpack_require__(441);
  44007. var _clipboardData2 = _interopRequireDefault(_clipboardData);
  44008. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  44009. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  44010. var PasteEvent = function PasteEvent() {
  44011. _classCallCheck(this, PasteEvent);
  44012. this.clipboardData = new _clipboardData2.default();
  44013. };
  44014. exports.default = PasteEvent;
  44015. /***/ }),
  44016. /* 441 */
  44017. /***/ (function(module, exports, __webpack_require__) {
  44018. "use strict";
  44019. exports.__esModule = true;
  44020. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  44021. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  44022. var ClipboardData = function () {
  44023. function ClipboardData() {
  44024. _classCallCheck(this, ClipboardData);
  44025. this.data = {};
  44026. }
  44027. _createClass(ClipboardData, [{
  44028. key: "setData",
  44029. value: function setData(type, value) {
  44030. this.data[type] = value;
  44031. }
  44032. }, {
  44033. key: "getData",
  44034. value: function getData(type) {
  44035. return this.data[type] || void 0;
  44036. }
  44037. }]);
  44038. return ClipboardData;
  44039. }();
  44040. exports.default = ClipboardData;
  44041. /***/ }),
  44042. /* 442 */
  44043. /***/ (function(module, exports) {
  44044. // removed by extract-text-webpack-plugin
  44045. /***/ }),
  44046. /* 443 */
  44047. /***/ (function(module, exports, __webpack_require__) {
  44048. "use strict";
  44049. exports.__esModule = true;
  44050. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  44051. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  44052. var _base = __webpack_require__(10);
  44053. var _base2 = _interopRequireDefault(_base);
  44054. var _plugins = __webpack_require__(8);
  44055. var _object = __webpack_require__(2);
  44056. var _number = __webpack_require__(5);
  44057. var _src = __webpack_require__(4);
  44058. var _pluginHooks = __webpack_require__(15);
  44059. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  44060. var _array = __webpack_require__(1);
  44061. var _constants = __webpack_require__(7);
  44062. var C = _interopRequireWildcard(_constants);
  44063. var _bottom = __webpack_require__(444);
  44064. var _bottom2 = _interopRequireDefault(_bottom);
  44065. var _left = __webpack_require__(445);
  44066. var _left2 = _interopRequireDefault(_left);
  44067. var _noBorders = __webpack_require__(446);
  44068. var _noBorders2 = _interopRequireDefault(_noBorders);
  44069. var _right = __webpack_require__(447);
  44070. var _right2 = _interopRequireDefault(_right);
  44071. var _top = __webpack_require__(448);
  44072. var _top2 = _interopRequireDefault(_top);
  44073. var _utils = __webpack_require__(48);
  44074. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  44075. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  44076. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  44077. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  44078. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  44079. /**
  44080. * @plugin CustomBorders
  44081. *
  44082. * @description
  44083. * This plugin enables an option to apply custom borders through the context menu (configurable with context menu key `borders`).
  44084. *
  44085. * To initialize Handsontable with predefined custom borders, provide cell coordinates and border styles in a form of an array.
  44086. *
  44087. * See [Custom Borders](http://docs.handsontable.com/demo-custom-borders.html) demo for more examples.
  44088. *
  44089. * @example
  44090. * ```js
  44091. * ...
  44092. * customBorders: [
  44093. * {
  44094. * range: {
  44095. * from: {
  44096. * row: 1,
  44097. * col: 1
  44098. * },
  44099. * to: {
  44100. * row: 3,
  44101. * col: 4
  44102. * },
  44103. * },
  44104. * left: {},
  44105. * right: {},
  44106. * top: {},
  44107. * bottom: {},
  44108. * },
  44109. * ],
  44110. * ...
  44111. *
  44112. * // or
  44113. * ...
  44114. * customBorders: [
  44115. * { row: 2,
  44116. * col: 2,
  44117. * left: {
  44118. * width: 2,
  44119. * color: 'red',
  44120. * },
  44121. * right: {
  44122. * width: 1,
  44123. * color: 'green',
  44124. * },
  44125. * top: '',
  44126. * bottom: '',
  44127. * }.
  44128. * ],
  44129. * ...
  44130. * ```
  44131. * @private
  44132. * @class CustomBorders
  44133. */
  44134. var CustomBorders = function (_BasePlugin) {
  44135. _inherits(CustomBorders, _BasePlugin);
  44136. function CustomBorders(hotInstance) {
  44137. _classCallCheck(this, CustomBorders);
  44138. /**
  44139. * Saved borders settings.
  44140. *
  44141. * @type {Array}
  44142. */
  44143. var _this = _possibleConstructorReturn(this, (CustomBorders.__proto__ || Object.getPrototypeOf(CustomBorders)).call(this, hotInstance));
  44144. _this.savedBorderSettings = void 0;
  44145. return _this;
  44146. }
  44147. /**
  44148. * Check if the plugin is enabled in the handsontable settings.
  44149. *
  44150. * @returns {Boolean}
  44151. */
  44152. _createClass(CustomBorders, [{
  44153. key: 'isEnabled',
  44154. value: function isEnabled() {
  44155. return !!this.hot.getSettings().customBorders;
  44156. }
  44157. /**
  44158. * Enable plugin for this Handsontable instance.
  44159. */
  44160. }, {
  44161. key: 'enablePlugin',
  44162. value: function enablePlugin() {
  44163. var _this2 = this;
  44164. if (this.enabled) {
  44165. return;
  44166. }
  44167. this.addHook('afterContextMenuDefaultOptions', function (options) {
  44168. return _this2.onAfterContextMenuDefaultOptions(options);
  44169. });
  44170. this.addHook('afterInit', function () {
  44171. return _this2.onAfterInit();
  44172. });
  44173. _get(CustomBorders.prototype.__proto__ || Object.getPrototypeOf(CustomBorders.prototype), 'enablePlugin', this).call(this);
  44174. }
  44175. /**
  44176. * Disable plugin for this Handsontable instance.
  44177. */
  44178. }, {
  44179. key: 'disablePlugin',
  44180. value: function disablePlugin() {
  44181. this.clearBorders();
  44182. _get(CustomBorders.prototype.__proto__ || Object.getPrototypeOf(CustomBorders.prototype), 'disablePlugin', this).call(this);
  44183. }
  44184. /**
  44185. * Updates the plugin to use the latest options you have specified.
  44186. */
  44187. }, {
  44188. key: 'updatePlugin',
  44189. value: function updatePlugin() {
  44190. this.disablePlugin();
  44191. this.enablePlugin();
  44192. this.changeBorderSettings();
  44193. _get(CustomBorders.prototype.__proto__ || Object.getPrototypeOf(CustomBorders.prototype), 'updatePlugin', this).call(this);
  44194. }
  44195. /**
  44196. * Get index of border from the settings.
  44197. *
  44198. * @param {String} className Class name as string.
  44199. * @returns {Number}
  44200. */
  44201. }, {
  44202. key: 'getSettingIndex',
  44203. value: function getSettingIndex(className) {
  44204. var index = -1;
  44205. (0, _array.arrayEach)(this.hot.selection.highlight.borders, function (selection, i) {
  44206. if (selection.settings.className === className) {
  44207. index = i;
  44208. return false;
  44209. }
  44210. });
  44211. return index;
  44212. }
  44213. /**
  44214. * Insert WalkontableSelection instance into Walkontable settings.
  44215. *
  44216. * @param {Object} border Object with `row` and `col`, `left`, `right`, `top` and `bottom`, `className` and `border` ({Object} with `color`, `width` and `cornerVisible` property) properties.
  44217. */
  44218. }, {
  44219. key: 'insertBorderIntoSettings',
  44220. value: function insertBorderIntoSettings(border) {
  44221. var coordinates = {
  44222. row: border.row,
  44223. col: border.col
  44224. };
  44225. var selection = new _src.Selection(border, new _src.CellRange(coordinates, coordinates, coordinates));
  44226. var index = this.getSettingIndex(border.className);
  44227. if (index >= 0) {
  44228. this.hot.selection.highlight.borders[index] = selection;
  44229. } else {
  44230. this.hot.selection.highlight.borders.push(selection);
  44231. }
  44232. }
  44233. /**
  44234. * Prepare borders from setting (single cell).
  44235. *
  44236. * @param {Number} row Visual row index.
  44237. * @param {Number} col Visual column index.
  44238. * @param {Object} borderObj Object with `row` and `col`, `left`, `right`, `top` and `bottom` properties.
  44239. */
  44240. }, {
  44241. key: 'prepareBorderFromCustomAdded',
  44242. value: function prepareBorderFromCustomAdded(row, col, borderObj) {
  44243. var border = (0, _utils.createEmptyBorders)(row, col);
  44244. border = (0, _utils.extendDefaultBorder)(border, borderObj);
  44245. this.hot.setCellMeta(row, col, 'borders', border);
  44246. this.insertBorderIntoSettings(border);
  44247. }
  44248. /** *
  44249. * Prepare borders from setting (object).
  44250. *
  44251. * @param {Object} rowObj Object with `range`, `left`, `right`, `top` and `bottom` properties.
  44252. */
  44253. }, {
  44254. key: 'prepareBorderFromCustomAddedRange',
  44255. value: function prepareBorderFromCustomAddedRange(rowObj) {
  44256. var _this3 = this;
  44257. var range = rowObj.range;
  44258. (0, _number.rangeEach)(range.from.row, range.to.row, function (rowIndex) {
  44259. (0, _number.rangeEach)(range.from.col, range.to.col, function (colIndex) {
  44260. var border = (0, _utils.createEmptyBorders)(rowIndex, colIndex);
  44261. var add = 0;
  44262. if (rowIndex === range.from.row) {
  44263. add += 1;
  44264. if ((0, _object.hasOwnProperty)(rowObj, 'top')) {
  44265. border.top = rowObj.top;
  44266. }
  44267. }
  44268. if (rowIndex === range.to.row) {
  44269. add += 1;
  44270. if ((0, _object.hasOwnProperty)(rowObj, 'bottom')) {
  44271. border.bottom = rowObj.bottom;
  44272. }
  44273. }
  44274. if (colIndex === range.from.col) {
  44275. add += 1;
  44276. if ((0, _object.hasOwnProperty)(rowObj, 'left')) {
  44277. border.left = rowObj.left;
  44278. }
  44279. }
  44280. if (colIndex === range.to.col) {
  44281. add += 1;
  44282. if ((0, _object.hasOwnProperty)(rowObj, 'right')) {
  44283. border.right = rowObj.right;
  44284. }
  44285. }
  44286. if (add > 0) {
  44287. _this3.hot.setCellMeta(rowIndex, colIndex, 'borders', border);
  44288. _this3.insertBorderIntoSettings(border);
  44289. }
  44290. });
  44291. });
  44292. }
  44293. /**
  44294. * Remove borders divs from DOM.
  44295. *
  44296. * @param {String} borderClassName Border class name as string.
  44297. */
  44298. }, {
  44299. key: 'removeBordersFromDom',
  44300. value: function removeBordersFromDom(borderClassName) {
  44301. var borders = this.hot.rootElement.querySelectorAll('.' + borderClassName + ':not(td)');
  44302. (0, _number.rangeEach)(0, borders.length - 1, function (index) {
  44303. var parent = borders[index].parentNode;
  44304. if (parent.parentNode) {
  44305. parent.parentNode.removeChild(parent);
  44306. }
  44307. });
  44308. }
  44309. /**
  44310. * Remove border (triggered from context menu).
  44311. *
  44312. * @param {Number} row Visual row index.
  44313. * @param {Number} col Visual column index.
  44314. */
  44315. }, {
  44316. key: 'removeAllBorders',
  44317. value: function removeAllBorders(row, col) {
  44318. var borderClassName = (0, _utils.createClassName)(row, col);
  44319. this.removeBordersFromDom(borderClassName);
  44320. this.hot.removeCellMeta(row, col, 'borders');
  44321. }
  44322. /**
  44323. * Set borders for each cell re. to border position.
  44324. *
  44325. * @param {Number} row Visual row index.
  44326. * @param {Number} col Visual column index.
  44327. * @param {String} place Coordinate where add/remove border - `top`, `bottom`, `left`, `right` and `noBorders`.
  44328. * @param {Boolean} remove True when remove borders, and false when add borders.
  44329. */
  44330. }, {
  44331. key: 'setBorder',
  44332. value: function setBorder(row, col, place, remove) {
  44333. var bordersMeta = this.hot.getCellMeta(row, col).borders;
  44334. if (!bordersMeta || bordersMeta.border === void 0) {
  44335. bordersMeta = (0, _utils.createEmptyBorders)(row, col);
  44336. }
  44337. if (remove) {
  44338. bordersMeta[place] = (0, _utils.createSingleEmptyBorder)();
  44339. } else {
  44340. bordersMeta[place] = (0, _utils.createDefaultCustomBorder)();
  44341. }
  44342. this.hot.setCellMeta(row, col, 'borders', bordersMeta);
  44343. var borderClassName = (0, _utils.createClassName)(row, col);
  44344. this.removeBordersFromDom(borderClassName);
  44345. this.insertBorderIntoSettings(bordersMeta);
  44346. this.hot.render();
  44347. }
  44348. /**
  44349. * Prepare borders based on cell and border position.
  44350. *
  44351. * @param {Object} selected
  44352. * @param {String} place Coordinate where add/remove border - `top`, `bottom`, `left`, `right` and `noBorders`.
  44353. * @param {Boolean} remove True when remove borders, and false when add borders.
  44354. */
  44355. }, {
  44356. key: 'prepareBorder',
  44357. value: function prepareBorder(selected, place, remove) {
  44358. var _this4 = this;
  44359. (0, _array.arrayEach)(selected, function (_ref) {
  44360. var start = _ref.start,
  44361. end = _ref.end;
  44362. if (start.row === end.row && start.col === end.col) {
  44363. if (place === 'noBorders') {
  44364. _this4.removeAllBorders(start.row, start.col);
  44365. } else {
  44366. _this4.setBorder(start.row, start.col, place, remove);
  44367. }
  44368. } else {
  44369. switch (place) {
  44370. case 'noBorders':
  44371. (0, _number.rangeEach)(start.col, end.col, function (colIndex) {
  44372. (0, _number.rangeEach)(start.row, end.row, function (rowIndex) {
  44373. _this4.removeAllBorders(rowIndex, colIndex);
  44374. });
  44375. });
  44376. break;
  44377. case 'top':
  44378. (0, _number.rangeEach)(start.col, end.col, function (topCol) {
  44379. _this4.setBorder(start.row, topCol, place, remove);
  44380. });
  44381. break;
  44382. case 'right':
  44383. (0, _number.rangeEach)(start.row, end.row, function (rowRight) {
  44384. _this4.setBorder(rowRight, end.col, place, remove);
  44385. });
  44386. break;
  44387. case 'bottom':
  44388. (0, _number.rangeEach)(start.col, end.col, function (bottomCol) {
  44389. _this4.setBorder(end.row, bottomCol, place, remove);
  44390. });
  44391. break;
  44392. case 'left':
  44393. (0, _number.rangeEach)(start.row, end.row, function (rowLeft) {
  44394. _this4.setBorder(rowLeft, start.col, place, remove);
  44395. });
  44396. break;
  44397. default:
  44398. break;
  44399. }
  44400. }
  44401. });
  44402. }
  44403. /**
  44404. * Create borders from settings.
  44405. *
  44406. * @private
  44407. * @param {Array} customBorders Object with `row` and `col`, `left`, `right`, `top` and `bottom` properties.
  44408. */
  44409. }, {
  44410. key: 'createCustomBorders',
  44411. value: function createCustomBorders(customBorders) {
  44412. var _this5 = this;
  44413. (0, _number.rangeEach)(0, customBorders.length - 1, function (index) {
  44414. if (customBorders[index].range) {
  44415. _this5.prepareBorderFromCustomAddedRange(customBorders[index]);
  44416. } else {
  44417. _this5.prepareBorderFromCustomAdded(customBorders[index].row, customBorders[index].col, customBorders[index]);
  44418. }
  44419. });
  44420. this.hot.render();
  44421. this.hot.view.wt.draw(true);
  44422. }
  44423. /**
  44424. * Add border options to context menu.
  44425. *
  44426. * @private
  44427. * @param {Object} defaultOptions Context menu items.
  44428. */
  44429. }, {
  44430. key: 'onAfterContextMenuDefaultOptions',
  44431. value: function onAfterContextMenuDefaultOptions(defaultOptions) {
  44432. if (!this.hot.getSettings().customBorders) {
  44433. return;
  44434. }
  44435. defaultOptions.items.push({
  44436. name: '---------'
  44437. }, {
  44438. key: 'borders',
  44439. name: function name() {
  44440. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_BORDERS);
  44441. },
  44442. disabled: function disabled() {
  44443. return this.selection.isSelectedByCorner();
  44444. },
  44445. submenu: {
  44446. items: [(0, _top2.default)(this), (0, _right2.default)(this), (0, _bottom2.default)(this), (0, _left2.default)(this), (0, _noBorders2.default)(this)]
  44447. }
  44448. });
  44449. }
  44450. /**
  44451. * Clear borders.
  44452. *
  44453. * @private
  44454. */
  44455. }, {
  44456. key: 'clearBorders',
  44457. value: function clearBorders() {
  44458. var _this6 = this;
  44459. var bordersFromTable = this.hot.rootElement.querySelectorAll('td[class^="border"]');
  44460. (0, _number.rangeEach)(0, bordersFromTable.length - 1, function (index) {
  44461. _this6.removeBordersFromDom(bordersFromTable[index].className);
  44462. });
  44463. }
  44464. /**
  44465. * Change borders from settings.
  44466. *
  44467. * @private
  44468. */
  44469. }, {
  44470. key: 'changeBorderSettings',
  44471. value: function changeBorderSettings() {
  44472. var customBorders = this.hot.getSettings().customBorders;
  44473. if (customBorders) {
  44474. if (Array.isArray(customBorders)) {
  44475. this.savedBorderSettings = customBorders;
  44476. this.createCustomBorders(customBorders);
  44477. } else if (customBorders !== void 0) {
  44478. var borders = this.savedBorderSettings ? this.savedBorderSettings : customBorders;
  44479. this.createCustomBorders(borders);
  44480. }
  44481. }
  44482. }
  44483. /**
  44484. * `afterInit` hook callback.
  44485. *
  44486. * @private
  44487. */
  44488. }, {
  44489. key: 'onAfterInit',
  44490. value: function onAfterInit() {
  44491. this.changeBorderSettings();
  44492. }
  44493. /**
  44494. * Destroy plugin instance.
  44495. */
  44496. }, {
  44497. key: 'destroy',
  44498. value: function destroy() {
  44499. _get(CustomBorders.prototype.__proto__ || Object.getPrototypeOf(CustomBorders.prototype), 'destroy', this).call(this);
  44500. }
  44501. }]);
  44502. return CustomBorders;
  44503. }(_base2.default);
  44504. (0, _plugins.registerPlugin)('customBorders', CustomBorders);
  44505. exports.default = CustomBorders;
  44506. /***/ }),
  44507. /* 444 */
  44508. /***/ (function(module, exports, __webpack_require__) {
  44509. "use strict";
  44510. exports.__esModule = true;
  44511. exports.default = bottom;
  44512. var _constants = __webpack_require__(7);
  44513. var C = _interopRequireWildcard(_constants);
  44514. var _utils = __webpack_require__(48);
  44515. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  44516. function bottom(customBordersPlugin) {
  44517. return {
  44518. key: 'borders:bottom',
  44519. name: function name() {
  44520. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_BORDERS_BOTTOM);
  44521. var hasBorder = (0, _utils.checkSelectionBorders)(this, 'bottom');
  44522. if (hasBorder) {
  44523. label = (0, _utils.markSelected)(label);
  44524. }
  44525. return label;
  44526. },
  44527. callback: function callback(key, selected) {
  44528. var hasBorder = (0, _utils.checkSelectionBorders)(this, 'bottom');
  44529. customBordersPlugin.prepareBorder(selected, 'bottom', hasBorder);
  44530. }
  44531. };
  44532. }
  44533. /***/ }),
  44534. /* 445 */
  44535. /***/ (function(module, exports, __webpack_require__) {
  44536. "use strict";
  44537. exports.__esModule = true;
  44538. exports.default = left;
  44539. var _constants = __webpack_require__(7);
  44540. var C = _interopRequireWildcard(_constants);
  44541. var _utils = __webpack_require__(48);
  44542. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  44543. function left(customBordersPlugin) {
  44544. return {
  44545. key: 'borders:left',
  44546. name: function name() {
  44547. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_BORDERS_LEFT);
  44548. var hasBorder = (0, _utils.checkSelectionBorders)(this, 'left');
  44549. if (hasBorder) {
  44550. label = (0, _utils.markSelected)(label);
  44551. }
  44552. return label;
  44553. },
  44554. callback: function callback(key, selected) {
  44555. var hasBorder = (0, _utils.checkSelectionBorders)(this, 'left');
  44556. customBordersPlugin.prepareBorder(selected, 'left', hasBorder);
  44557. }
  44558. };
  44559. }
  44560. /***/ }),
  44561. /* 446 */
  44562. /***/ (function(module, exports, __webpack_require__) {
  44563. "use strict";
  44564. exports.__esModule = true;
  44565. exports.default = noBorders;
  44566. var _constants = __webpack_require__(7);
  44567. var C = _interopRequireWildcard(_constants);
  44568. var _utils = __webpack_require__(48);
  44569. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  44570. function noBorders(customBordersPlugin) {
  44571. return {
  44572. key: 'borders:no_borders',
  44573. name: function name() {
  44574. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_REMOVE_BORDERS);
  44575. },
  44576. callback: function callback(key, selected) {
  44577. customBordersPlugin.prepareBorder(selected, 'noBorders');
  44578. },
  44579. disabled: function disabled() {
  44580. return !(0, _utils.checkSelectionBorders)(this);
  44581. }
  44582. };
  44583. }
  44584. /***/ }),
  44585. /* 447 */
  44586. /***/ (function(module, exports, __webpack_require__) {
  44587. "use strict";
  44588. exports.__esModule = true;
  44589. exports.default = right;
  44590. var _constants = __webpack_require__(7);
  44591. var C = _interopRequireWildcard(_constants);
  44592. var _utils = __webpack_require__(48);
  44593. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  44594. function right(customBordersPlugin) {
  44595. return {
  44596. key: 'borders:right',
  44597. name: function name() {
  44598. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_BORDERS_RIGHT);
  44599. var hasBorder = (0, _utils.checkSelectionBorders)(this, 'right');
  44600. if (hasBorder) {
  44601. label = (0, _utils.markSelected)(label);
  44602. }
  44603. return label;
  44604. },
  44605. callback: function callback(key, selected) {
  44606. var hasBorder = (0, _utils.checkSelectionBorders)(this, 'right');
  44607. customBordersPlugin.prepareBorder(selected, 'right', hasBorder);
  44608. }
  44609. };
  44610. }
  44611. /***/ }),
  44612. /* 448 */
  44613. /***/ (function(module, exports, __webpack_require__) {
  44614. "use strict";
  44615. exports.__esModule = true;
  44616. exports.default = top;
  44617. var _constants = __webpack_require__(7);
  44618. var C = _interopRequireWildcard(_constants);
  44619. var _utils = __webpack_require__(48);
  44620. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  44621. function top(customBordersPlugin) {
  44622. return {
  44623. key: 'borders:top',
  44624. name: function name() {
  44625. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_BORDERS_TOP);
  44626. var hasBorder = (0, _utils.checkSelectionBorders)(this, 'top');
  44627. if (hasBorder) {
  44628. label = (0, _utils.markSelected)(label);
  44629. }
  44630. return label;
  44631. },
  44632. callback: function callback(key, selected) {
  44633. var hasBorder = (0, _utils.checkSelectionBorders)(this, 'top');
  44634. customBordersPlugin.prepareBorder(selected, 'top', hasBorder);
  44635. }
  44636. };
  44637. }
  44638. /***/ }),
  44639. /* 449 */
  44640. /***/ (function(module, exports, __webpack_require__) {
  44641. "use strict";
  44642. exports.__esModule = true;
  44643. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  44644. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  44645. var _base = __webpack_require__(10);
  44646. var _base2 = _interopRequireDefault(_base);
  44647. var _eventManager = __webpack_require__(6);
  44648. var _eventManager2 = _interopRequireDefault(_eventManager);
  44649. var _plugins = __webpack_require__(8);
  44650. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  44651. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  44652. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  44653. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  44654. /**
  44655. * @description
  44656. * Plugin used to scroll Handsontable by selecting a cell and dragging outside of the visible viewport.
  44657. *
  44658. *
  44659. * @class DragToScroll
  44660. * @plugin DragToScroll
  44661. */
  44662. var DragToScroll = function (_BasePlugin) {
  44663. _inherits(DragToScroll, _BasePlugin);
  44664. function DragToScroll(hotInstance) {
  44665. _classCallCheck(this, DragToScroll);
  44666. /**
  44667. * Instance of {@link EventManager}.
  44668. *
  44669. * @type {EventManager}
  44670. */
  44671. var _this = _possibleConstructorReturn(this, (DragToScroll.__proto__ || Object.getPrototypeOf(DragToScroll)).call(this, hotInstance));
  44672. _this.eventManager = new _eventManager2.default(_this);
  44673. /**
  44674. * DOMRect - size of an element and its position relative to the viewport,
  44675. * e.g. {bottom: 449, height: 441, left: 8, right: 814, top: 8, width: 806, x: 8, y:8}.
  44676. *
  44677. * @type {Object}
  44678. */
  44679. _this.boundaries = null;
  44680. /**
  44681. * Callback function.
  44682. *
  44683. * @type {Function}
  44684. */
  44685. _this.callback = null;
  44686. /**
  44687. * Flag indicates mouseDown/mouseUp.
  44688. *
  44689. * @type {Boolean}
  44690. */
  44691. _this.listening = false;
  44692. return _this;
  44693. }
  44694. /**
  44695. * Check if the plugin is enabled in the Handsontable settings.
  44696. *
  44697. * @returns {Boolean}
  44698. */
  44699. _createClass(DragToScroll, [{
  44700. key: 'isEnabled',
  44701. value: function isEnabled() {
  44702. return !!this.hot.getSettings().dragToScroll;
  44703. }
  44704. /**
  44705. * Enable plugin for this Handsontable instance.
  44706. */
  44707. }, {
  44708. key: 'enablePlugin',
  44709. value: function enablePlugin() {
  44710. var _this2 = this;
  44711. if (this.enabled) {
  44712. return;
  44713. }
  44714. this.addHook('afterOnCellMouseDown', function () {
  44715. return _this2.setupListening();
  44716. });
  44717. this.addHook('afterOnCellCornerMouseDown', function () {
  44718. return _this2.setupListening();
  44719. });
  44720. this.registerEvents();
  44721. _get(DragToScroll.prototype.__proto__ || Object.getPrototypeOf(DragToScroll.prototype), 'enablePlugin', this).call(this);
  44722. }
  44723. /**
  44724. * Updates the plugin to use the latest options you have specified.
  44725. */
  44726. }, {
  44727. key: 'updatePlugin',
  44728. value: function updatePlugin() {
  44729. this.disablePlugin();
  44730. this.enablePlugin();
  44731. _get(DragToScroll.prototype.__proto__ || Object.getPrototypeOf(DragToScroll.prototype), 'updatePlugin', this).call(this);
  44732. }
  44733. /**
  44734. * Disable plugin for this Handsontable instance.
  44735. */
  44736. }, {
  44737. key: 'disablePlugin',
  44738. value: function disablePlugin() {
  44739. this.unregisterEvents();
  44740. _get(DragToScroll.prototype.__proto__ || Object.getPrototypeOf(DragToScroll.prototype), 'disablePlugin', this).call(this);
  44741. }
  44742. /**
  44743. * Sets the value of the visible element.
  44744. *
  44745. * @param boundaries {Object} compatible with getBoundingClientRect
  44746. */
  44747. }, {
  44748. key: 'setBoundaries',
  44749. value: function setBoundaries(boundaries) {
  44750. this.boundaries = boundaries;
  44751. }
  44752. /**
  44753. * Change callback function.
  44754. *
  44755. * @param callback {Function}
  44756. */
  44757. }, {
  44758. key: 'setCallback',
  44759. value: function setCallback(callback) {
  44760. this.callback = callback;
  44761. }
  44762. /**
  44763. * Check if mouse position (x, y) is outside of the viewport.
  44764. *
  44765. * @param {Number} x
  44766. * @param {Number} y
  44767. */
  44768. }, {
  44769. key: 'check',
  44770. value: function check(x, y) {
  44771. var diffX = 0;
  44772. var diffY = 0;
  44773. if (y < this.boundaries.top) {
  44774. // y is less than top
  44775. diffY = y - this.boundaries.top;
  44776. } else if (y > this.boundaries.bottom) {
  44777. // y is more than bottom
  44778. diffY = y - this.boundaries.bottom;
  44779. }
  44780. if (x < this.boundaries.left) {
  44781. // x is less than left
  44782. diffX = x - this.boundaries.left;
  44783. } else if (x > this.boundaries.right) {
  44784. // x is more than right
  44785. diffX = x - this.boundaries.right;
  44786. }
  44787. this.callback(diffX, diffY);
  44788. }
  44789. /**
  44790. * Register dom listeners.
  44791. *
  44792. * @private
  44793. */
  44794. }, {
  44795. key: 'registerEvents',
  44796. value: function registerEvents() {
  44797. var _this3 = this;
  44798. this.eventManager.addEventListener(document, 'mouseup', function () {
  44799. return _this3.onMouseUp();
  44800. });
  44801. this.eventManager.addEventListener(document, 'mousemove', function (event) {
  44802. return _this3.onMouseMove(event);
  44803. });
  44804. }
  44805. /**
  44806. * Unbind the events used by the plugin.
  44807. *
  44808. * @private
  44809. */
  44810. }, {
  44811. key: 'unregisterEvents',
  44812. value: function unregisterEvents() {
  44813. this.eventManager.clear();
  44814. }
  44815. /**
  44816. * On after on cell/cellCorner mouse down listener.
  44817. *
  44818. * @private
  44819. */
  44820. }, {
  44821. key: 'setupListening',
  44822. value: function setupListening() {
  44823. var scrollHandler = this.hot.view.wt.wtTable.holder; // native scroll
  44824. if (scrollHandler === window) {
  44825. // not much we can do currently
  44826. return;
  44827. }
  44828. this.setBoundaries(scrollHandler.getBoundingClientRect());
  44829. this.setCallback(function (scrollX, scrollY) {
  44830. if (scrollX < 0) {
  44831. scrollHandler.scrollLeft -= 50;
  44832. } else if (scrollX > 0) {
  44833. scrollHandler.scrollLeft += 50;
  44834. }
  44835. if (scrollY < 0) {
  44836. scrollHandler.scrollTop -= 20;
  44837. } else if (scrollY > 0) {
  44838. scrollHandler.scrollTop += 20;
  44839. }
  44840. });
  44841. this.listening = true;
  44842. }
  44843. /**
  44844. * 'mouseMove' event callback.
  44845. *
  44846. * @private
  44847. * @param {MouseEvent} event `mousemove` event properties.
  44848. */
  44849. }, {
  44850. key: 'onMouseMove',
  44851. value: function onMouseMove(event) {
  44852. if (this.listening) {
  44853. this.check(event.clientX, event.clientY);
  44854. }
  44855. }
  44856. /**
  44857. * `onMouseUp` hook callback.
  44858. *
  44859. * @private
  44860. */
  44861. }, {
  44862. key: 'onMouseUp',
  44863. value: function onMouseUp() {
  44864. this.listening = false;
  44865. }
  44866. /**
  44867. * Destroy instance.
  44868. */
  44869. }, {
  44870. key: 'destroy',
  44871. value: function destroy() {
  44872. _get(DragToScroll.prototype.__proto__ || Object.getPrototypeOf(DragToScroll.prototype), 'destroy', this).call(this);
  44873. }
  44874. }]);
  44875. return DragToScroll;
  44876. }(_base2.default);
  44877. (0, _plugins.registerPlugin)('dragToScroll', DragToScroll);
  44878. exports.default = DragToScroll;
  44879. /***/ }),
  44880. /* 450 */
  44881. /***/ (function(module, exports, __webpack_require__) {
  44882. "use strict";
  44883. exports.__esModule = true;
  44884. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  44885. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  44886. var _base = __webpack_require__(10);
  44887. var _base2 = _interopRequireDefault(_base);
  44888. var _plugins = __webpack_require__(8);
  44889. var _array = __webpack_require__(1);
  44890. var _freezeColumn = __webpack_require__(451);
  44891. var _freezeColumn2 = _interopRequireDefault(_freezeColumn);
  44892. var _unfreezeColumn = __webpack_require__(452);
  44893. var _unfreezeColumn2 = _interopRequireDefault(_unfreezeColumn);
  44894. __webpack_require__(453);
  44895. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  44896. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  44897. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  44898. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  44899. var privatePool = new WeakMap();
  44900. /**
  44901. * This plugin allows to manually "freeze" and "unfreeze" a column using an entry in the Context Menu.
  44902. * You can turn it on by setting a `manualColumnFreeze` property to `true`.
  44903. *
  44904. * @plugin ManualColumnFreeze
  44905. * @dependencies ManualColumnMove
  44906. */
  44907. var ManualColumnFreeze = function (_BasePlugin) {
  44908. _inherits(ManualColumnFreeze, _BasePlugin);
  44909. function ManualColumnFreeze(hotInstance) {
  44910. _classCallCheck(this, ManualColumnFreeze);
  44911. var _this = _possibleConstructorReturn(this, (ManualColumnFreeze.__proto__ || Object.getPrototypeOf(ManualColumnFreeze)).call(this, hotInstance));
  44912. privatePool.set(_this, {
  44913. moveByFreeze: false,
  44914. afterFirstUse: false
  44915. });
  44916. /**
  44917. * Original column positions
  44918. *
  44919. * @type {Array}
  44920. */
  44921. _this.frozenColumnsBasePositions = [];
  44922. /**
  44923. * Reference to the `ManualColumnMove` plugin.
  44924. */
  44925. _this.manualColumnMovePlugin = void 0;
  44926. return _this;
  44927. }
  44928. /**
  44929. * Check if the plugin is enabled in the Handsontable settings.
  44930. *
  44931. * @returns {Boolean}
  44932. */
  44933. _createClass(ManualColumnFreeze, [{
  44934. key: 'isEnabled',
  44935. value: function isEnabled() {
  44936. return !!this.hot.getSettings().manualColumnFreeze;
  44937. }
  44938. /**
  44939. * Enable plugin for this Handsontable instance.
  44940. */
  44941. }, {
  44942. key: 'enablePlugin',
  44943. value: function enablePlugin() {
  44944. var _this2 = this;
  44945. if (this.enabled) {
  44946. return;
  44947. }
  44948. this.addHook('afterContextMenuDefaultOptions', function (options) {
  44949. return _this2.addContextMenuEntry(options);
  44950. });
  44951. this.addHook('afterInit', function () {
  44952. return _this2.onAfterInit();
  44953. });
  44954. this.addHook('beforeColumnMove', function (rows, target) {
  44955. return _this2.onBeforeColumnMove(rows, target);
  44956. });
  44957. _get(ManualColumnFreeze.prototype.__proto__ || Object.getPrototypeOf(ManualColumnFreeze.prototype), 'enablePlugin', this).call(this);
  44958. }
  44959. /**
  44960. * Disable plugin for this Handsontable instance.
  44961. */
  44962. }, {
  44963. key: 'disablePlugin',
  44964. value: function disablePlugin() {
  44965. var priv = privatePool.get(this);
  44966. priv.afterFirstUse = false;
  44967. priv.moveByFreeze = false;
  44968. _get(ManualColumnFreeze.prototype.__proto__ || Object.getPrototypeOf(ManualColumnFreeze.prototype), 'disablePlugin', this).call(this);
  44969. }
  44970. /**
  44971. * Updates the plugin to use the latest options you have specified.
  44972. */
  44973. }, {
  44974. key: 'updatePlugin',
  44975. value: function updatePlugin() {
  44976. this.disablePlugin();
  44977. this.enablePlugin();
  44978. _get(ManualColumnFreeze.prototype.__proto__ || Object.getPrototypeOf(ManualColumnFreeze.prototype), 'updatePlugin', this).call(this);
  44979. }
  44980. /**
  44981. * Freeze the given column (add it to fixed columns).
  44982. *
  44983. * @param {Number} column Visual column index.
  44984. */
  44985. }, {
  44986. key: 'freezeColumn',
  44987. value: function freezeColumn(column) {
  44988. var priv = privatePool.get(this);
  44989. var settings = this.hot.getSettings();
  44990. if (!priv.afterFirstUse) {
  44991. priv.afterFirstUse = true;
  44992. }
  44993. if (settings.fixedColumnsLeft === this.hot.countCols() || column <= settings.fixedColumnsLeft - 1) {
  44994. return; // already fixed
  44995. }
  44996. priv.moveByFreeze = true;
  44997. if (column !== this.getMovePlugin().columnsMapper.getValueByIndex(column)) {
  44998. this.frozenColumnsBasePositions[settings.fixedColumnsLeft] = column;
  44999. }
  45000. this.getMovePlugin().moveColumn(column, settings.fixedColumnsLeft++);
  45001. }
  45002. /**
  45003. * Unfreeze the given column (remove it from fixed columns and bring to it's previous position).
  45004. *
  45005. * @param {Number} column Visual column index.
  45006. */
  45007. }, {
  45008. key: 'unfreezeColumn',
  45009. value: function unfreezeColumn(column) {
  45010. var priv = privatePool.get(this);
  45011. var settings = this.hot.getSettings();
  45012. if (!priv.afterFirstUse) {
  45013. priv.afterFirstUse = true;
  45014. }
  45015. if (settings.fixedColumnsLeft <= 0 || column > settings.fixedColumnsLeft - 1) {
  45016. return; // not fixed
  45017. }
  45018. var returnCol = this.getBestColumnReturnPosition(column);
  45019. priv.moveByFreeze = true;
  45020. settings.fixedColumnsLeft--;
  45021. this.getMovePlugin().moveColumn(column, returnCol + 1);
  45022. }
  45023. /**
  45024. * Get the reference to the ManualColumnMove plugin.
  45025. *
  45026. * @private
  45027. * @returns {Object}
  45028. */
  45029. }, {
  45030. key: 'getMovePlugin',
  45031. value: function getMovePlugin() {
  45032. if (!this.manualColumnMovePlugin) {
  45033. this.manualColumnMovePlugin = this.hot.getPlugin('manualColumnMove');
  45034. }
  45035. return this.manualColumnMovePlugin;
  45036. }
  45037. /**
  45038. * Estimates the most fitting return position for unfrozen column.
  45039. *
  45040. * @private
  45041. * @param {Number} column Visual column index.
  45042. */
  45043. }, {
  45044. key: 'getBestColumnReturnPosition',
  45045. value: function getBestColumnReturnPosition(column) {
  45046. var movePlugin = this.getMovePlugin();
  45047. var settings = this.hot.getSettings();
  45048. var i = settings.fixedColumnsLeft;
  45049. var j = movePlugin.columnsMapper.getValueByIndex(i);
  45050. var initialCol = void 0;
  45051. if (this.frozenColumnsBasePositions[column] === null || this.frozenColumnsBasePositions[column] === void 0) {
  45052. initialCol = movePlugin.columnsMapper.getValueByIndex(column);
  45053. while (j !== null && j <= initialCol) {
  45054. i++;
  45055. j = movePlugin.columnsMapper.getValueByIndex(i);
  45056. }
  45057. } else {
  45058. initialCol = this.frozenColumnsBasePositions[column];
  45059. this.frozenColumnsBasePositions[column] = void 0;
  45060. while (j !== null && j <= initialCol) {
  45061. i++;
  45062. j = movePlugin.columnsMapper.getValueByIndex(i);
  45063. }
  45064. i = j;
  45065. }
  45066. return i - 1;
  45067. }
  45068. /**
  45069. * Add the manualColumnFreeze context menu entries.
  45070. *
  45071. * @private
  45072. * @param {Object} options Context menu options.
  45073. */
  45074. }, {
  45075. key: 'addContextMenuEntry',
  45076. value: function addContextMenuEntry(options) {
  45077. options.items.push({ name: '---------' }, (0, _freezeColumn2.default)(this), (0, _unfreezeColumn2.default)(this));
  45078. }
  45079. /**
  45080. * Enabling `manualColumnMove` plugin on `afterInit` hook.
  45081. *
  45082. * @private
  45083. */
  45084. }, {
  45085. key: 'onAfterInit',
  45086. value: function onAfterInit() {
  45087. if (!this.getMovePlugin().isEnabled()) {
  45088. this.getMovePlugin().enablePlugin();
  45089. }
  45090. }
  45091. /**
  45092. * Prevent moving the rows from/to fixed area.
  45093. *
  45094. * @private
  45095. * @param {Array} rows
  45096. * @param {Number} target
  45097. */
  45098. }, {
  45099. key: 'onBeforeColumnMove',
  45100. value: function onBeforeColumnMove(rows, target) {
  45101. var priv = privatePool.get(this);
  45102. if (priv.afterFirstUse && !priv.moveByFreeze) {
  45103. var frozenLen = this.hot.getSettings().fixedColumnsLeft;
  45104. var disallowMoving = target < frozenLen;
  45105. if (!disallowMoving) {
  45106. (0, _array.arrayEach)(rows, function (value, index, array) {
  45107. if (value < frozenLen) {
  45108. disallowMoving = true;
  45109. return false;
  45110. }
  45111. });
  45112. }
  45113. if (disallowMoving) {
  45114. return false;
  45115. }
  45116. }
  45117. if (priv.moveByFreeze) {
  45118. priv.moveByFreeze = false;
  45119. }
  45120. }
  45121. /**
  45122. * Destroy plugin instance.
  45123. */
  45124. }, {
  45125. key: 'destroy',
  45126. value: function destroy() {
  45127. _get(ManualColumnFreeze.prototype.__proto__ || Object.getPrototypeOf(ManualColumnFreeze.prototype), 'destroy', this).call(this);
  45128. }
  45129. }]);
  45130. return ManualColumnFreeze;
  45131. }(_base2.default);
  45132. (0, _plugins.registerPlugin)('manualColumnFreeze', ManualColumnFreeze);
  45133. exports.default = ManualColumnFreeze;
  45134. /***/ }),
  45135. /* 451 */
  45136. /***/ (function(module, exports, __webpack_require__) {
  45137. "use strict";
  45138. exports.__esModule = true;
  45139. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  45140. exports.default = freezeColumnItem;
  45141. var _constants = __webpack_require__(7);
  45142. var C = _interopRequireWildcard(_constants);
  45143. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  45144. function freezeColumnItem(manualColumnFreezePlugin) {
  45145. return {
  45146. key: 'freeze_column',
  45147. name: function name() {
  45148. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_FREEZE_COLUMN);
  45149. },
  45150. callback: function callback(key, selected) {
  45151. var _selected = _slicedToArray(selected, 1),
  45152. selectedColumn = _selected[0].start.col;
  45153. manualColumnFreezePlugin.freezeColumn(selectedColumn);
  45154. this.render();
  45155. this.view.wt.wtOverlays.adjustElementsSize(true);
  45156. },
  45157. hidden: function hidden() {
  45158. var selection = this.getSelectedRange();
  45159. var hide = false;
  45160. if (selection === void 0) {
  45161. hide = true;
  45162. } else if (selection.length > 1) {
  45163. hide = true;
  45164. } else if (selection[0].from.col !== selection[0].to.col || selection[0].from.col <= this.getSettings().fixedColumnsLeft - 1) {
  45165. hide = true;
  45166. }
  45167. return hide;
  45168. }
  45169. };
  45170. }
  45171. /***/ }),
  45172. /* 452 */
  45173. /***/ (function(module, exports, __webpack_require__) {
  45174. "use strict";
  45175. exports.__esModule = true;
  45176. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  45177. exports.default = unfreezeColumnItem;
  45178. var _constants = __webpack_require__(7);
  45179. var C = _interopRequireWildcard(_constants);
  45180. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  45181. function unfreezeColumnItem(manualColumnFreezePlugin) {
  45182. return {
  45183. key: 'unfreeze_column',
  45184. name: function name() {
  45185. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_UNFREEZE_COLUMN);
  45186. },
  45187. callback: function callback(key, selected) {
  45188. var _selected = _slicedToArray(selected, 1),
  45189. selectedColumn = _selected[0].start.col;
  45190. manualColumnFreezePlugin.unfreezeColumn(selectedColumn);
  45191. this.render();
  45192. this.view.wt.wtOverlays.adjustElementsSize(true);
  45193. },
  45194. hidden: function hidden() {
  45195. var selection = this.getSelectedRange();
  45196. var hide = false;
  45197. if (selection === void 0) {
  45198. hide = true;
  45199. } else if (selection.length > 1) {
  45200. hide = true;
  45201. } else if (selection[0].from.col !== selection[0].to.col || selection[0].from.col >= this.getSettings().fixedColumnsLeft) {
  45202. hide = true;
  45203. }
  45204. return hide;
  45205. }
  45206. };
  45207. }
  45208. /***/ }),
  45209. /* 453 */
  45210. /***/ (function(module, exports) {
  45211. // removed by extract-text-webpack-plugin
  45212. /***/ }),
  45213. /* 454 */
  45214. /***/ (function(module, exports, __webpack_require__) {
  45215. "use strict";
  45216. exports.__esModule = true;
  45217. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  45218. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  45219. var _base = __webpack_require__(10);
  45220. var _base2 = _interopRequireDefault(_base);
  45221. var _pluginHooks = __webpack_require__(15);
  45222. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  45223. var _array = __webpack_require__(1);
  45224. var _element = __webpack_require__(0);
  45225. var _number = __webpack_require__(5);
  45226. var _eventManager = __webpack_require__(6);
  45227. var _eventManager2 = _interopRequireDefault(_eventManager);
  45228. var _plugins = __webpack_require__(8);
  45229. var _columnsMapper = __webpack_require__(455);
  45230. var _columnsMapper2 = _interopRequireDefault(_columnsMapper);
  45231. var _backlight = __webpack_require__(456);
  45232. var _backlight2 = _interopRequireDefault(_backlight);
  45233. var _guideline = __webpack_require__(457);
  45234. var _guideline2 = _interopRequireDefault(_guideline);
  45235. var _src = __webpack_require__(4);
  45236. __webpack_require__(458);
  45237. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  45238. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  45239. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  45240. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  45241. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  45242. _pluginHooks2.default.getSingleton().register('beforeColumnMove');
  45243. _pluginHooks2.default.getSingleton().register('afterColumnMove');
  45244. _pluginHooks2.default.getSingleton().register('unmodifyCol');
  45245. var privatePool = new WeakMap();
  45246. var CSS_PLUGIN = 'ht__manualColumnMove';
  45247. var CSS_SHOW_UI = 'show-ui';
  45248. var CSS_ON_MOVING = 'on-moving--columns';
  45249. var CSS_AFTER_SELECTION = 'after-selection--columns';
  45250. /**
  45251. * @plugin ManualColumnMove
  45252. *
  45253. * @description
  45254. * This plugin allows to change columns order.
  45255. *
  45256. * API:
  45257. * - moveColumn - move single column to the new position.
  45258. * - moveColumns - move many columns (as an array of indexes) to the new position.
  45259. *
  45260. * If you want apply visual changes, you have to call manually the render() method on the instance of Handsontable.
  45261. *
  45262. * UI components:
  45263. * - backlight - highlight of selected columns.
  45264. * - guideline - line which shows where rows has been moved.
  45265. *
  45266. * @class ManualColumnMove
  45267. * @plugin ManualColumnMove
  45268. */
  45269. var ManualColumnMove = function (_BasePlugin) {
  45270. _inherits(ManualColumnMove, _BasePlugin);
  45271. function ManualColumnMove(hotInstance) {
  45272. _classCallCheck(this, ManualColumnMove);
  45273. /**
  45274. * Set up WeakMap of plugin to sharing private parameters;
  45275. */
  45276. var _this = _possibleConstructorReturn(this, (ManualColumnMove.__proto__ || Object.getPrototypeOf(ManualColumnMove)).call(this, hotInstance));
  45277. privatePool.set(_this, {
  45278. columnsToMove: [],
  45279. countCols: 0,
  45280. fixedColumns: 0,
  45281. pressed: void 0,
  45282. disallowMoving: void 0,
  45283. target: {
  45284. eventPageX: void 0,
  45285. coords: void 0,
  45286. TD: void 0,
  45287. col: void 0
  45288. }
  45289. });
  45290. /**
  45291. * List of last removed row indexes.
  45292. *
  45293. * @type {Array}
  45294. */
  45295. _this.removedColumns = [];
  45296. /**
  45297. * Object containing visual row indexes mapped to data source indexes.
  45298. *
  45299. * @type {RowsMapper}
  45300. */
  45301. _this.columnsMapper = new _columnsMapper2.default(_this);
  45302. /**
  45303. * Event Manager object.
  45304. *
  45305. * @type {Object}
  45306. */
  45307. _this.eventManager = new _eventManager2.default(_this);
  45308. /**
  45309. * Backlight UI object.
  45310. *
  45311. * @type {Object}
  45312. */
  45313. _this.backlight = new _backlight2.default(hotInstance);
  45314. /**
  45315. * Guideline UI object.
  45316. *
  45317. * @type {Object}
  45318. */
  45319. _this.guideline = new _guideline2.default(hotInstance);
  45320. return _this;
  45321. }
  45322. /**
  45323. * Check if plugin is enabled.
  45324. *
  45325. * @returns {Boolean}
  45326. */
  45327. _createClass(ManualColumnMove, [{
  45328. key: 'isEnabled',
  45329. value: function isEnabled() {
  45330. return !!this.hot.getSettings().manualColumnMove;
  45331. }
  45332. /**
  45333. * Enable the plugin.
  45334. */
  45335. }, {
  45336. key: 'enablePlugin',
  45337. value: function enablePlugin() {
  45338. var _this2 = this;
  45339. if (this.enabled) {
  45340. return;
  45341. }
  45342. this.addHook('beforeOnCellMouseDown', function (event, coords, TD, blockCalculations) {
  45343. return _this2.onBeforeOnCellMouseDown(event, coords, TD, blockCalculations);
  45344. });
  45345. this.addHook('beforeOnCellMouseOver', function (event, coords, TD, blockCalculations) {
  45346. return _this2.onBeforeOnCellMouseOver(event, coords, TD, blockCalculations);
  45347. });
  45348. this.addHook('afterScrollVertically', function () {
  45349. return _this2.onAfterScrollVertically();
  45350. });
  45351. this.addHook('modifyCol', function (row, source) {
  45352. return _this2.onModifyCol(row, source);
  45353. });
  45354. this.addHook('beforeRemoveCol', function (index, amount) {
  45355. return _this2.onBeforeRemoveCol(index, amount);
  45356. });
  45357. this.addHook('afterRemoveCol', function () {
  45358. return _this2.onAfterRemoveCol();
  45359. });
  45360. this.addHook('afterCreateCol', function (index, amount) {
  45361. return _this2.onAfterCreateCol(index, amount);
  45362. });
  45363. this.addHook('afterLoadData', function () {
  45364. return _this2.onAfterLoadData();
  45365. });
  45366. this.addHook('unmodifyCol', function (column) {
  45367. return _this2.onUnmodifyCol(column);
  45368. });
  45369. this.registerEvents();
  45370. // TODO: move adding plugin classname to BasePlugin.
  45371. (0, _element.addClass)(this.hot.rootElement, CSS_PLUGIN);
  45372. _get(ManualColumnMove.prototype.__proto__ || Object.getPrototypeOf(ManualColumnMove.prototype), 'enablePlugin', this).call(this);
  45373. }
  45374. /**
  45375. * Updates the plugin to use the latest options you have specified.
  45376. */
  45377. }, {
  45378. key: 'updatePlugin',
  45379. value: function updatePlugin() {
  45380. this.disablePlugin();
  45381. this.enablePlugin();
  45382. this.onAfterPluginsInitialized();
  45383. _get(ManualColumnMove.prototype.__proto__ || Object.getPrototypeOf(ManualColumnMove.prototype), 'updatePlugin', this).call(this);
  45384. }
  45385. /**
  45386. * Disable plugin for this Handsontable instance.
  45387. */
  45388. }, {
  45389. key: 'disablePlugin',
  45390. value: function disablePlugin() {
  45391. var pluginSettings = this.hot.getSettings().manualColumnMove;
  45392. if (Array.isArray(pluginSettings)) {
  45393. this.columnsMapper.clearMap();
  45394. }
  45395. (0, _element.removeClass)(this.hot.rootElement, CSS_PLUGIN);
  45396. this.unregisterEvents();
  45397. this.backlight.destroy();
  45398. this.guideline.destroy();
  45399. _get(ManualColumnMove.prototype.__proto__ || Object.getPrototypeOf(ManualColumnMove.prototype), 'disablePlugin', this).call(this);
  45400. }
  45401. /**
  45402. * Move a single column.
  45403. *
  45404. * @param {Number} column Visual column index to be moved.
  45405. * @param {Number} target Visual column index being a target for the moved column.
  45406. */
  45407. }, {
  45408. key: 'moveColumn',
  45409. value: function moveColumn(column, target) {
  45410. this.moveColumns([column], target);
  45411. }
  45412. /**
  45413. * Move multiple columns.
  45414. *
  45415. * @param {Array} columns Array of visual column indexes to be moved.
  45416. * @param {Number} target Visual column index being a target for the moved columns.
  45417. */
  45418. }, {
  45419. key: 'moveColumns',
  45420. value: function moveColumns(columns, target) {
  45421. var _this3 = this;
  45422. var visualColumns = [].concat(_toConsumableArray(columns));
  45423. var priv = privatePool.get(this);
  45424. var beforeColumnHook = this.hot.runHooks('beforeColumnMove', visualColumns, target);
  45425. priv.disallowMoving = !beforeColumnHook;
  45426. if (beforeColumnHook !== false) {
  45427. // first we need to rewrite an visual indexes to physical for save reference after move
  45428. (0, _array.arrayEach)(columns, function (column, index, array) {
  45429. array[index] = _this3.columnsMapper.getValueByIndex(column);
  45430. });
  45431. // next, when we have got an physical indexes, we can move columns
  45432. (0, _array.arrayEach)(columns, function (column, index) {
  45433. var actualPosition = _this3.columnsMapper.getIndexByValue(column);
  45434. if (actualPosition !== target) {
  45435. _this3.columnsMapper.moveColumn(actualPosition, target + index);
  45436. }
  45437. });
  45438. // after moving we have to clear columnsMapper from null entries
  45439. this.columnsMapper.clearNull();
  45440. }
  45441. this.hot.runHooks('afterColumnMove', visualColumns, target);
  45442. }
  45443. /**
  45444. * Correct the cell selection after the move action. Fired only when action was made with a mouse.
  45445. * That means that changing the column order using the API won't correct the selection.
  45446. *
  45447. * @private
  45448. * @param {Number} startColumn Visual column index for the start of the selection.
  45449. * @param {Number} endColumn Visual column index for the end of the selection.
  45450. */
  45451. }, {
  45452. key: 'changeSelection',
  45453. value: function changeSelection(startColumn, endColumn) {
  45454. this.hot.selectColumns(startColumn, endColumn);
  45455. }
  45456. /**
  45457. * Get the sum of the widths of columns in the provided range.
  45458. *
  45459. * @private
  45460. * @param {Number} from Visual column index.
  45461. * @param {Number} to Visual column index.
  45462. * @returns {Number}
  45463. */
  45464. }, {
  45465. key: 'getColumnsWidth',
  45466. value: function getColumnsWidth(from, to) {
  45467. var width = 0;
  45468. for (var i = from; i < to; i++) {
  45469. var columnWidth = 0;
  45470. if (i < 0) {
  45471. columnWidth = this.hot.view.wt.wtViewport.getRowHeaderWidth() || 0;
  45472. } else {
  45473. columnWidth = this.hot.view.wt.wtTable.getStretchedColumnWidth(i) || 0;
  45474. }
  45475. width += columnWidth;
  45476. }
  45477. return width;
  45478. }
  45479. /**
  45480. * Load initial settings when persistent state is saved or when plugin was initialized as an array.
  45481. *
  45482. * @private
  45483. */
  45484. }, {
  45485. key: 'initialSettings',
  45486. value: function initialSettings() {
  45487. var pluginSettings = this.hot.getSettings().manualColumnMove;
  45488. if (Array.isArray(pluginSettings)) {
  45489. this.moveColumns(pluginSettings, 0);
  45490. } else if (pluginSettings !== void 0) {
  45491. this.persistentStateLoad();
  45492. }
  45493. }
  45494. /**
  45495. * Check if the provided column is in the fixedColumnsLeft section.
  45496. *
  45497. * @private
  45498. * @param {Number} column Visual column index to check.
  45499. * @returns {Boolean}
  45500. */
  45501. }, {
  45502. key: 'isFixedColumnsLeft',
  45503. value: function isFixedColumnsLeft(column) {
  45504. return column < this.hot.getSettings().fixedColumnsLeft;
  45505. }
  45506. /**
  45507. * Save the manual column positions to the persistent state.
  45508. *
  45509. * @private
  45510. */
  45511. }, {
  45512. key: 'persistentStateSave',
  45513. value: function persistentStateSave() {
  45514. this.hot.runHooks('persistentStateSave', 'manualColumnMove', this.columnsMapper._arrayMap);
  45515. }
  45516. /**
  45517. * Load the manual column positions from the persistent state.
  45518. *
  45519. * @private
  45520. */
  45521. }, {
  45522. key: 'persistentStateLoad',
  45523. value: function persistentStateLoad() {
  45524. var storedState = {};
  45525. this.hot.runHooks('persistentStateLoad', 'manualColumnMove', storedState);
  45526. if (storedState.value) {
  45527. this.columnsMapper._arrayMap = storedState.value;
  45528. }
  45529. }
  45530. /**
  45531. * Prepare array of indexes based on actual selection.
  45532. *
  45533. * @private
  45534. * @returns {Array}
  45535. */
  45536. }, {
  45537. key: 'prepareColumnsToMoving',
  45538. value: function prepareColumnsToMoving(start, end) {
  45539. var selectedColumns = [];
  45540. (0, _number.rangeEach)(start, end, function (i) {
  45541. selectedColumns.push(i);
  45542. });
  45543. return selectedColumns;
  45544. }
  45545. /**
  45546. * Update the UI visual position.
  45547. *
  45548. * @private
  45549. */
  45550. }, {
  45551. key: 'refreshPositions',
  45552. value: function refreshPositions() {
  45553. var priv = privatePool.get(this);
  45554. var firstVisible = this.hot.view.wt.wtTable.getFirstVisibleColumn();
  45555. var lastVisible = this.hot.view.wt.wtTable.getLastVisibleColumn();
  45556. var wtTable = this.hot.view.wt.wtTable;
  45557. var scrollableElement = this.hot.view.wt.wtOverlays.scrollableElement;
  45558. var scrollLeft = typeof scrollableElement.scrollX === 'number' ? scrollableElement.scrollX : scrollableElement.scrollLeft;
  45559. var tdOffsetLeft = this.hot.view.THEAD.offsetLeft + this.getColumnsWidth(0, priv.coordsColumn);
  45560. var mouseOffsetLeft = priv.target.eventPageX - (priv.rootElementOffset - (scrollableElement.scrollX === void 0 ? scrollLeft : 0));
  45561. var hiderWidth = wtTable.hider.offsetWidth;
  45562. var tbodyOffsetLeft = wtTable.TBODY.offsetLeft;
  45563. var backlightElemMarginLeft = this.backlight.getOffset().left;
  45564. var backlightElemWidth = this.backlight.getSize().width;
  45565. var rowHeaderWidth = 0;
  45566. if (priv.rootElementOffset + wtTable.holder.offsetWidth + scrollLeft < priv.target.eventPageX) {
  45567. if (priv.coordsColumn < priv.countCols) {
  45568. priv.coordsColumn++;
  45569. }
  45570. }
  45571. if (priv.hasRowHeaders) {
  45572. rowHeaderWidth = this.hot.view.wt.wtOverlays.leftOverlay.clone.wtTable.getColumnHeader(-1).offsetWidth;
  45573. }
  45574. if (this.isFixedColumnsLeft(priv.coordsColumn)) {
  45575. tdOffsetLeft += scrollLeft;
  45576. }
  45577. tdOffsetLeft += rowHeaderWidth;
  45578. if (priv.coordsColumn < 0) {
  45579. // if hover on rowHeader
  45580. if (priv.fixedColumns > 0) {
  45581. priv.target.col = 0;
  45582. } else {
  45583. priv.target.col = firstVisible > 0 ? firstVisible - 1 : firstVisible;
  45584. }
  45585. } else if (priv.target.TD.offsetWidth / 2 + tdOffsetLeft <= mouseOffsetLeft) {
  45586. var newCoordsCol = priv.coordsColumn >= priv.countCols ? priv.countCols - 1 : priv.coordsColumn;
  45587. // if hover on right part of TD
  45588. priv.target.col = newCoordsCol + 1;
  45589. // unfortunately first column is bigger than rest
  45590. tdOffsetLeft += priv.target.TD.offsetWidth;
  45591. if (priv.target.col > lastVisible) {
  45592. this.hot.scrollViewportTo(void 0, lastVisible + 1, void 0, true);
  45593. }
  45594. } else {
  45595. // elsewhere on table
  45596. priv.target.col = priv.coordsColumn;
  45597. if (priv.target.col <= firstVisible && priv.target.col >= priv.fixedColumns) {
  45598. this.hot.scrollViewportTo(void 0, firstVisible - 1);
  45599. }
  45600. }
  45601. if (priv.target.col <= firstVisible && priv.target.col >= priv.fixedColumns) {
  45602. this.hot.scrollViewportTo(void 0, firstVisible - 1);
  45603. }
  45604. var backlightLeft = mouseOffsetLeft;
  45605. var guidelineLeft = tdOffsetLeft;
  45606. if (mouseOffsetLeft + backlightElemWidth + backlightElemMarginLeft >= hiderWidth) {
  45607. // prevent display backlight on the right side of the table
  45608. backlightLeft = hiderWidth - backlightElemWidth - backlightElemMarginLeft;
  45609. } else if (mouseOffsetLeft + backlightElemMarginLeft < tbodyOffsetLeft + rowHeaderWidth) {
  45610. // prevent display backlight on the left side of the table
  45611. backlightLeft = tbodyOffsetLeft + rowHeaderWidth + Math.abs(backlightElemMarginLeft);
  45612. }
  45613. if (tdOffsetLeft >= hiderWidth - 1) {
  45614. // prevent display guideline outside the table
  45615. guidelineLeft = hiderWidth - 1;
  45616. } else if (guidelineLeft === 0) {
  45617. // guideline has got `margin-left: -1px` as default
  45618. guidelineLeft = 1;
  45619. } else if (scrollableElement.scrollX !== void 0 && priv.coordsColumn < priv.fixedColumns) {
  45620. guidelineLeft -= priv.rootElementOffset <= scrollableElement.scrollX ? priv.rootElementOffset : 0;
  45621. }
  45622. this.backlight.setPosition(null, backlightLeft);
  45623. this.guideline.setPosition(null, guidelineLeft);
  45624. }
  45625. /**
  45626. * This method checks arrayMap from columnsMapper and updates the columnsMapper if it's necessary.
  45627. *
  45628. * @private
  45629. */
  45630. }, {
  45631. key: 'updateColumnsMapper',
  45632. value: function updateColumnsMapper() {
  45633. var countCols = this.hot.countSourceCols();
  45634. var columnsMapperLen = this.columnsMapper._arrayMap.length;
  45635. if (columnsMapperLen === 0) {
  45636. this.columnsMapper.createMap(countCols || this.hot.getSettings().startCols);
  45637. } else if (columnsMapperLen < countCols) {
  45638. var diff = countCols - columnsMapperLen;
  45639. this.columnsMapper.insertItems(columnsMapperLen, diff);
  45640. } else if (columnsMapperLen > countCols) {
  45641. var maxIndex = countCols - 1;
  45642. var columnsToRemove = [];
  45643. (0, _array.arrayEach)(this.columnsMapper._arrayMap, function (value, index) {
  45644. if (value > maxIndex) {
  45645. columnsToRemove.push(index);
  45646. }
  45647. });
  45648. this.columnsMapper.removeItems(columnsToRemove);
  45649. }
  45650. }
  45651. /**
  45652. * Bind the events used by the plugin.
  45653. *
  45654. * @private
  45655. */
  45656. }, {
  45657. key: 'registerEvents',
  45658. value: function registerEvents() {
  45659. var _this4 = this;
  45660. this.eventManager.addEventListener(document.documentElement, 'mousemove', function (event) {
  45661. return _this4.onMouseMove(event);
  45662. });
  45663. this.eventManager.addEventListener(document.documentElement, 'mouseup', function () {
  45664. return _this4.onMouseUp();
  45665. });
  45666. }
  45667. /**
  45668. * Unbind the events used by the plugin.
  45669. *
  45670. * @private
  45671. */
  45672. }, {
  45673. key: 'unregisterEvents',
  45674. value: function unregisterEvents() {
  45675. this.eventManager.clear();
  45676. }
  45677. /**
  45678. * Change the behavior of selection / dragging.
  45679. *
  45680. * @private
  45681. * @param {MouseEvent} event `mousedown` event properties.
  45682. * @param {CellCoords} coords Visual cell coordinates where was fired event.
  45683. * @param {HTMLElement} TD Cell represented as HTMLElement.
  45684. * @param {Object} blockCalculations Object which contains information about blockCalculation for row, column or cells.
  45685. */
  45686. }, {
  45687. key: 'onBeforeOnCellMouseDown',
  45688. value: function onBeforeOnCellMouseDown(event, coords, TD, blockCalculations) {
  45689. var wtTable = this.hot.view.wt.wtTable;
  45690. var isHeaderSelection = this.hot.selection.isSelectedByColumnHeader();
  45691. var selection = this.hot.getSelectedRangeLast();
  45692. var priv = privatePool.get(this);
  45693. var isSortingElement = event.realTarget.className.indexOf('columnSorting') > -1;
  45694. if (!selection || !isHeaderSelection || priv.pressed || event.button !== 0 || isSortingElement) {
  45695. priv.pressed = false;
  45696. priv.columnsToMove.length = 0;
  45697. (0, _element.removeClass)(this.hot.rootElement, [CSS_ON_MOVING, CSS_SHOW_UI]);
  45698. return;
  45699. }
  45700. var guidelineIsNotReady = this.guideline.isBuilt() && !this.guideline.isAppended();
  45701. var backlightIsNotReady = this.backlight.isBuilt() && !this.backlight.isAppended();
  45702. if (guidelineIsNotReady && backlightIsNotReady) {
  45703. this.guideline.appendTo(wtTable.hider);
  45704. this.backlight.appendTo(wtTable.hider);
  45705. }
  45706. var from = selection.from,
  45707. to = selection.to;
  45708. var start = Math.min(from.col, to.col);
  45709. var end = Math.max(from.col, to.col);
  45710. if (coords.row < 0 && coords.col >= start && coords.col <= end) {
  45711. blockCalculations.column = true;
  45712. priv.pressed = true;
  45713. priv.target.eventPageX = event.pageX;
  45714. priv.coordsColumn = coords.col;
  45715. priv.target.TD = TD;
  45716. priv.target.col = coords.col;
  45717. priv.columnsToMove = this.prepareColumnsToMoving(start, end);
  45718. priv.hasRowHeaders = !!this.hot.getSettings().rowHeaders;
  45719. priv.countCols = this.hot.countCols();
  45720. priv.fixedColumns = this.hot.getSettings().fixedColumnsLeft;
  45721. priv.rootElementOffset = (0, _element.offset)(this.hot.rootElement).left;
  45722. var countColumnsFrom = priv.hasRowHeaders ? -1 : 0;
  45723. var topPos = wtTable.holder.scrollTop + wtTable.getColumnHeaderHeight(0) + 1;
  45724. var fixedColumns = coords.col < priv.fixedColumns;
  45725. var scrollableElement = this.hot.view.wt.wtOverlays.scrollableElement;
  45726. var wrapperIsWindow = scrollableElement.scrollX ? scrollableElement.scrollX - priv.rootElementOffset : 0;
  45727. var mouseOffset = event.layerX - (fixedColumns ? wrapperIsWindow : 0);
  45728. var leftOffset = Math.abs(this.getColumnsWidth(start, coords.col) + mouseOffset);
  45729. this.backlight.setPosition(topPos, this.getColumnsWidth(countColumnsFrom, start) + leftOffset);
  45730. this.backlight.setSize(this.getColumnsWidth(start, end + 1), wtTable.hider.offsetHeight - topPos);
  45731. this.backlight.setOffset(null, leftOffset * -1);
  45732. (0, _element.addClass)(this.hot.rootElement, CSS_ON_MOVING);
  45733. } else {
  45734. (0, _element.removeClass)(this.hot.rootElement, CSS_AFTER_SELECTION);
  45735. priv.pressed = false;
  45736. priv.columnsToMove.length = 0;
  45737. }
  45738. }
  45739. /**
  45740. * 'mouseMove' event callback. Fired when pointer move on document.documentElement.
  45741. *
  45742. * @private
  45743. * @param {MouseEvent} event `mousemove` event properties.
  45744. */
  45745. }, {
  45746. key: 'onMouseMove',
  45747. value: function onMouseMove(event) {
  45748. var priv = privatePool.get(this);
  45749. if (!priv.pressed) {
  45750. return;
  45751. }
  45752. // callback for browser which doesn't supports CSS pointer-event: none
  45753. if (event.realTarget === this.backlight.element) {
  45754. var width = this.backlight.getSize().width;
  45755. this.backlight.setSize(0);
  45756. setTimeout(function () {
  45757. this.backlight.setPosition(width);
  45758. });
  45759. }
  45760. priv.target.eventPageX = event.pageX;
  45761. this.refreshPositions();
  45762. }
  45763. /**
  45764. * 'beforeOnCellMouseOver' hook callback. Fired when pointer was over cell.
  45765. *
  45766. * @private
  45767. * @param {MouseEvent} event `mouseover` event properties.
  45768. * @param {CellCoords} coords Visual cell coordinates where was fired event.
  45769. * @param {HTMLElement} TD Cell represented as HTMLElement.
  45770. * @param {Object} blockCalculations Object which contains information about blockCalculation for row, column or cells.
  45771. */
  45772. }, {
  45773. key: 'onBeforeOnCellMouseOver',
  45774. value: function onBeforeOnCellMouseOver(event, coords, TD, blockCalculations) {
  45775. var selectedRange = this.hot.getSelectedRangeLast();
  45776. var priv = privatePool.get(this);
  45777. if (!selectedRange || !priv.pressed) {
  45778. return;
  45779. }
  45780. if (priv.columnsToMove.indexOf(coords.col) > -1) {
  45781. (0, _element.removeClass)(this.hot.rootElement, CSS_SHOW_UI);
  45782. } else {
  45783. (0, _element.addClass)(this.hot.rootElement, CSS_SHOW_UI);
  45784. }
  45785. blockCalculations.row = true;
  45786. blockCalculations.column = true;
  45787. blockCalculations.cell = true;
  45788. priv.coordsColumn = coords.col;
  45789. priv.target.TD = TD;
  45790. }
  45791. /**
  45792. * `onMouseUp` hook callback.
  45793. *
  45794. * @private
  45795. */
  45796. }, {
  45797. key: 'onMouseUp',
  45798. value: function onMouseUp() {
  45799. var priv = privatePool.get(this);
  45800. priv.coordsColumn = void 0;
  45801. priv.pressed = false;
  45802. priv.backlightWidth = 0;
  45803. (0, _element.removeClass)(this.hot.rootElement, [CSS_ON_MOVING, CSS_SHOW_UI, CSS_AFTER_SELECTION]);
  45804. if (this.hot.selection.isSelectedByColumnHeader()) {
  45805. (0, _element.addClass)(this.hot.rootElement, CSS_AFTER_SELECTION);
  45806. }
  45807. if (priv.columnsToMove.length < 1 || priv.target.col === void 0 || priv.columnsToMove.indexOf(priv.target.col) > -1) {
  45808. return;
  45809. }
  45810. this.moveColumns(priv.columnsToMove, priv.target.col);
  45811. this.persistentStateSave();
  45812. this.hot.render();
  45813. this.hot.view.wt.wtOverlays.adjustElementsSize(true);
  45814. if (!priv.disallowMoving) {
  45815. var selectionStart = this.columnsMapper.getIndexByValue(priv.columnsToMove[0]);
  45816. var selectionEnd = this.columnsMapper.getIndexByValue(priv.columnsToMove[priv.columnsToMove.length - 1]);
  45817. this.changeSelection(selectionStart, selectionEnd);
  45818. }
  45819. priv.columnsToMove.length = 0;
  45820. }
  45821. /**
  45822. * `afterScrollHorizontally` hook callback. Fired the table was scrolled horizontally.
  45823. *
  45824. * @private
  45825. */
  45826. }, {
  45827. key: 'onAfterScrollVertically',
  45828. value: function onAfterScrollVertically() {
  45829. var wtTable = this.hot.view.wt.wtTable;
  45830. var headerHeight = wtTable.getColumnHeaderHeight(0) + 1;
  45831. var scrollTop = wtTable.holder.scrollTop;
  45832. var posTop = headerHeight + scrollTop;
  45833. this.backlight.setPosition(posTop);
  45834. this.backlight.setSize(null, wtTable.hider.offsetHeight - posTop);
  45835. }
  45836. /**
  45837. * `afterCreateCol` hook callback.
  45838. *
  45839. * @private
  45840. * @param {Number} index Visual index of the created column.
  45841. * @param {Number} amount Amount of created columns.
  45842. */
  45843. }, {
  45844. key: 'onAfterCreateCol',
  45845. value: function onAfterCreateCol(index, amount) {
  45846. this.columnsMapper.shiftItems(index, amount);
  45847. }
  45848. /**
  45849. * On before remove column listener.
  45850. *
  45851. * @private
  45852. * @param {Number} index Visual column index.
  45853. * @param {Number} amount Defines how many columns removed.
  45854. */
  45855. }, {
  45856. key: 'onBeforeRemoveCol',
  45857. value: function onBeforeRemoveCol(index, amount) {
  45858. var _this5 = this;
  45859. this.removedColumns.length = 0;
  45860. if (index !== false) {
  45861. // Collect physical row index.
  45862. (0, _number.rangeEach)(index, index + amount - 1, function (removedIndex) {
  45863. _this5.removedColumns.push(_this5.hot.runHooks('modifyCol', removedIndex, _this5.pluginName));
  45864. });
  45865. }
  45866. }
  45867. /**
  45868. * `afterRemoveCol` hook callback.
  45869. *
  45870. * @private
  45871. */
  45872. }, {
  45873. key: 'onAfterRemoveCol',
  45874. value: function onAfterRemoveCol() {
  45875. this.columnsMapper.unshiftItems(this.removedColumns);
  45876. }
  45877. /**
  45878. * `afterLoadData` hook callback.
  45879. *
  45880. * @private
  45881. */
  45882. }, {
  45883. key: 'onAfterLoadData',
  45884. value: function onAfterLoadData() {
  45885. this.updateColumnsMapper();
  45886. }
  45887. /**
  45888. * 'modifyRow' hook callback.
  45889. *
  45890. * @private
  45891. * @param {Number} column Visual column index.
  45892. * @returns {Number} Physical column index.
  45893. */
  45894. }, {
  45895. key: 'onModifyCol',
  45896. value: function onModifyCol(column, source) {
  45897. if (source !== this.pluginName) {
  45898. // ugly fix for try to insert new, needed columns after pasting data
  45899. var columnInMapper = this.columnsMapper.getValueByIndex(column);
  45900. column = columnInMapper === null ? column : columnInMapper;
  45901. }
  45902. return column;
  45903. }
  45904. /**
  45905. * 'unmodifyCol' hook callback.
  45906. *
  45907. * @private
  45908. * @param {Number} column Physical column index.
  45909. * @returns {Number} Visual column index.
  45910. */
  45911. }, {
  45912. key: 'onUnmodifyCol',
  45913. value: function onUnmodifyCol(column) {
  45914. var indexInMapper = this.columnsMapper.getIndexByValue(column);
  45915. return indexInMapper === null ? column : indexInMapper;
  45916. }
  45917. /**
  45918. * `afterPluginsInitialized` hook callback.
  45919. *
  45920. * @private
  45921. */
  45922. }, {
  45923. key: 'onAfterPluginsInitialized',
  45924. value: function onAfterPluginsInitialized() {
  45925. this.updateColumnsMapper();
  45926. this.initialSettings();
  45927. this.backlight.build();
  45928. this.guideline.build();
  45929. }
  45930. /**
  45931. * Destroy plugin instance.
  45932. */
  45933. }, {
  45934. key: 'destroy',
  45935. value: function destroy() {
  45936. this.backlight.destroy();
  45937. this.guideline.destroy();
  45938. _get(ManualColumnMove.prototype.__proto__ || Object.getPrototypeOf(ManualColumnMove.prototype), 'destroy', this).call(this);
  45939. }
  45940. }]);
  45941. return ManualColumnMove;
  45942. }(_base2.default);
  45943. (0, _plugins.registerPlugin)('ManualColumnMove', ManualColumnMove);
  45944. exports.default = ManualColumnMove;
  45945. /***/ }),
  45946. /* 455 */
  45947. /***/ (function(module, exports, __webpack_require__) {
  45948. "use strict";
  45949. exports.__esModule = true;
  45950. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  45951. var _arrayMapper = __webpack_require__(321);
  45952. var _arrayMapper2 = _interopRequireDefault(_arrayMapper);
  45953. var _array = __webpack_require__(1);
  45954. var _object = __webpack_require__(2);
  45955. var _number = __webpack_require__(5);
  45956. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  45957. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  45958. /**
  45959. * @class ColumnsMapper
  45960. * @plugin ManualColumnMove
  45961. */
  45962. var ColumnsMapper = function () {
  45963. function ColumnsMapper(manualColumnMove) {
  45964. _classCallCheck(this, ColumnsMapper);
  45965. /**
  45966. * Instance of ManualColumnMove plugin.
  45967. *
  45968. * @type {ManualColumnMove}
  45969. */
  45970. this.manualColumnMove = manualColumnMove;
  45971. }
  45972. /**
  45973. * Reset current map array and create new one.
  45974. *
  45975. * @param {Number} [length] Custom generated map length.
  45976. */
  45977. _createClass(ColumnsMapper, [{
  45978. key: 'createMap',
  45979. value: function createMap(length) {
  45980. var _this = this;
  45981. var originLength = length === void 0 ? this._arrayMap.length : length;
  45982. this._arrayMap.length = 0;
  45983. (0, _number.rangeEach)(originLength - 1, function (itemIndex) {
  45984. _this._arrayMap[itemIndex] = itemIndex;
  45985. });
  45986. }
  45987. /**
  45988. * Destroy class.
  45989. */
  45990. }, {
  45991. key: 'destroy',
  45992. value: function destroy() {
  45993. this._arrayMap = null;
  45994. }
  45995. /**
  45996. * Moving elements in columnsMapper.
  45997. *
  45998. * @param {Number} from Column index to move.
  45999. * @param {Number} to Target index.
  46000. */
  46001. }, {
  46002. key: 'moveColumn',
  46003. value: function moveColumn(from, to) {
  46004. var indexToMove = this._arrayMap[from];
  46005. this._arrayMap[from] = null;
  46006. this._arrayMap.splice(to, 0, indexToMove);
  46007. }
  46008. /**
  46009. * Clearing arrayMap from `null` entries.
  46010. */
  46011. }, {
  46012. key: 'clearNull',
  46013. value: function clearNull() {
  46014. this._arrayMap = (0, _array.arrayFilter)(this._arrayMap, function (i) {
  46015. return i !== null;
  46016. });
  46017. }
  46018. }]);
  46019. return ColumnsMapper;
  46020. }();
  46021. (0, _object.mixin)(ColumnsMapper, _arrayMapper2.default);
  46022. exports.default = ColumnsMapper;
  46023. /***/ }),
  46024. /* 456 */
  46025. /***/ (function(module, exports, __webpack_require__) {
  46026. "use strict";
  46027. exports.__esModule = true;
  46028. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  46029. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  46030. var _base = __webpack_require__(322);
  46031. var _base2 = _interopRequireDefault(_base);
  46032. var _element = __webpack_require__(0);
  46033. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  46034. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  46035. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  46036. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  46037. var CSS_CLASSNAME = 'ht__manualColumnMove--backlight';
  46038. /**
  46039. * @class BacklightUI
  46040. * @util
  46041. */
  46042. var BacklightUI = function (_BaseUI) {
  46043. _inherits(BacklightUI, _BaseUI);
  46044. function BacklightUI() {
  46045. _classCallCheck(this, BacklightUI);
  46046. return _possibleConstructorReturn(this, (BacklightUI.__proto__ || Object.getPrototypeOf(BacklightUI)).apply(this, arguments));
  46047. }
  46048. _createClass(BacklightUI, [{
  46049. key: 'build',
  46050. /**
  46051. * Custom className on build process.
  46052. */
  46053. value: function build() {
  46054. _get(BacklightUI.prototype.__proto__ || Object.getPrototypeOf(BacklightUI.prototype), 'build', this).call(this);
  46055. (0, _element.addClass)(this._element, CSS_CLASSNAME);
  46056. }
  46057. }]);
  46058. return BacklightUI;
  46059. }(_base2.default);
  46060. exports.default = BacklightUI;
  46061. /***/ }),
  46062. /* 457 */
  46063. /***/ (function(module, exports, __webpack_require__) {
  46064. "use strict";
  46065. exports.__esModule = true;
  46066. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  46067. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  46068. var _base = __webpack_require__(322);
  46069. var _base2 = _interopRequireDefault(_base);
  46070. var _element = __webpack_require__(0);
  46071. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  46072. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  46073. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  46074. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  46075. var CSS_CLASSNAME = 'ht__manualColumnMove--guideline';
  46076. /**
  46077. * @class GuidelineUI
  46078. * @util
  46079. */
  46080. var GuidelineUI = function (_BaseUI) {
  46081. _inherits(GuidelineUI, _BaseUI);
  46082. function GuidelineUI() {
  46083. _classCallCheck(this, GuidelineUI);
  46084. return _possibleConstructorReturn(this, (GuidelineUI.__proto__ || Object.getPrototypeOf(GuidelineUI)).apply(this, arguments));
  46085. }
  46086. _createClass(GuidelineUI, [{
  46087. key: 'build',
  46088. /**
  46089. * Custom className on build process.
  46090. */
  46091. value: function build() {
  46092. _get(GuidelineUI.prototype.__proto__ || Object.getPrototypeOf(GuidelineUI.prototype), 'build', this).call(this);
  46093. (0, _element.addClass)(this._element, CSS_CLASSNAME);
  46094. }
  46095. }]);
  46096. return GuidelineUI;
  46097. }(_base2.default);
  46098. exports.default = GuidelineUI;
  46099. /***/ }),
  46100. /* 458 */
  46101. /***/ (function(module, exports) {
  46102. // removed by extract-text-webpack-plugin
  46103. /***/ }),
  46104. /* 459 */
  46105. /***/ (function(module, exports, __webpack_require__) {
  46106. "use strict";
  46107. exports.__esModule = true;
  46108. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  46109. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  46110. var _base = __webpack_require__(10);
  46111. var _base2 = _interopRequireDefault(_base);
  46112. var _element = __webpack_require__(0);
  46113. var _eventManager = __webpack_require__(6);
  46114. var _eventManager2 = _interopRequireDefault(_eventManager);
  46115. var _event = __webpack_require__(12);
  46116. var _array = __webpack_require__(1);
  46117. var _number = __webpack_require__(5);
  46118. var _plugins = __webpack_require__(8);
  46119. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  46120. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  46121. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  46122. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  46123. // Developer note! Whenever you make a change in this file, make an analogous change in manualRowResize.js
  46124. /**
  46125. * @description
  46126. * ManualColumnResize Plugin.
  46127. *
  46128. * Has 2 UI components:
  46129. * - handle - the draggable element that sets the desired width of the column.
  46130. * - guide - the helper guide that shows the desired width as a vertical guide.
  46131. *
  46132. * @plugin ManualColumnResize
  46133. */
  46134. var ManualColumnResize = function (_BasePlugin) {
  46135. _inherits(ManualColumnResize, _BasePlugin);
  46136. function ManualColumnResize(hotInstance) {
  46137. _classCallCheck(this, ManualColumnResize);
  46138. var _this = _possibleConstructorReturn(this, (ManualColumnResize.__proto__ || Object.getPrototypeOf(ManualColumnResize)).call(this, hotInstance));
  46139. _this.currentTH = null;
  46140. _this.currentCol = null;
  46141. _this.selectedCols = [];
  46142. _this.currentWidth = null;
  46143. _this.newSize = null;
  46144. _this.startY = null;
  46145. _this.startWidth = null;
  46146. _this.startOffset = null;
  46147. _this.handle = document.createElement('DIV');
  46148. _this.guide = document.createElement('DIV');
  46149. _this.eventManager = new _eventManager2.default(_this);
  46150. _this.pressed = null;
  46151. _this.dblclick = 0;
  46152. _this.autoresizeTimeout = null;
  46153. _this.manualColumnWidths = [];
  46154. (0, _element.addClass)(_this.handle, 'manualColumnResizer');
  46155. (0, _element.addClass)(_this.guide, 'manualColumnResizerGuide');
  46156. return _this;
  46157. }
  46158. /**
  46159. * Check if the plugin is enabled in the handsontable settings.
  46160. *
  46161. * @returns {Boolean}
  46162. */
  46163. _createClass(ManualColumnResize, [{
  46164. key: 'isEnabled',
  46165. value: function isEnabled() {
  46166. return this.hot.getSettings().manualColumnResize;
  46167. }
  46168. /**
  46169. * Enable plugin for this Handsontable instance.
  46170. */
  46171. }, {
  46172. key: 'enablePlugin',
  46173. value: function enablePlugin() {
  46174. var _this2 = this;
  46175. if (this.enabled) {
  46176. return;
  46177. }
  46178. this.manualColumnWidths = [];
  46179. var initialColumnWidth = this.hot.getSettings().manualColumnResize;
  46180. var loadedManualColumnWidths = this.loadManualColumnWidths();
  46181. this.addHook('modifyColWidth', function (width, col) {
  46182. return _this2.onModifyColWidth(width, col);
  46183. });
  46184. this.addHook('beforeStretchingColumnWidth', function (stretchedWidth, column) {
  46185. return _this2.onBeforeStretchingColumnWidth(stretchedWidth, column);
  46186. });
  46187. this.addHook('beforeColumnResize', function (currentColumn, newSize, isDoubleClick) {
  46188. return _this2.onBeforeColumnResize(currentColumn, newSize, isDoubleClick);
  46189. });
  46190. if (typeof loadedManualColumnWidths != 'undefined') {
  46191. this.manualColumnWidths = loadedManualColumnWidths;
  46192. } else if (Array.isArray(initialColumnWidth)) {
  46193. this.manualColumnWidths = initialColumnWidth;
  46194. } else {
  46195. this.manualColumnWidths = [];
  46196. }
  46197. // Handsontable.hooks.register('beforeColumnResize');
  46198. // Handsontable.hooks.register('afterColumnResize');
  46199. this.bindEvents();
  46200. _get(ManualColumnResize.prototype.__proto__ || Object.getPrototypeOf(ManualColumnResize.prototype), 'enablePlugin', this).call(this);
  46201. }
  46202. /**
  46203. * Updates the plugin to use the latest options you have specified.
  46204. */
  46205. }, {
  46206. key: 'updatePlugin',
  46207. value: function updatePlugin() {
  46208. var initialColumnWidth = this.hot.getSettings().manualColumnResize;
  46209. if (Array.isArray(initialColumnWidth)) {
  46210. this.manualColumnWidths = initialColumnWidth;
  46211. } else if (!initialColumnWidth) {
  46212. this.manualColumnWidths = [];
  46213. }
  46214. }
  46215. /**
  46216. * Disable plugin for this Handsontable instance.
  46217. */
  46218. }, {
  46219. key: 'disablePlugin',
  46220. value: function disablePlugin() {
  46221. _get(ManualColumnResize.prototype.__proto__ || Object.getPrototypeOf(ManualColumnResize.prototype), 'disablePlugin', this).call(this);
  46222. }
  46223. /**
  46224. * Save the current sizes using the persistentState plugin.
  46225. */
  46226. }, {
  46227. key: 'saveManualColumnWidths',
  46228. value: function saveManualColumnWidths() {
  46229. this.hot.runHooks('persistentStateSave', 'manualColumnWidths', this.manualColumnWidths);
  46230. }
  46231. /**
  46232. * Load the previously saved sizes using the persistentState plugin.
  46233. *
  46234. * @returns {Array}
  46235. */
  46236. }, {
  46237. key: 'loadManualColumnWidths',
  46238. value: function loadManualColumnWidths() {
  46239. var storedState = {};
  46240. this.hot.runHooks('persistentStateLoad', 'manualColumnWidths', storedState);
  46241. return storedState.value;
  46242. }
  46243. /**
  46244. * Set the resize handle position.
  46245. *
  46246. * @param {HTMLCellElement} TH TH HTML element.
  46247. */
  46248. }, {
  46249. key: 'setupHandlePosition',
  46250. value: function setupHandlePosition(TH) {
  46251. var _this3 = this;
  46252. if (!TH.parentNode) {
  46253. return false;
  46254. }
  46255. this.currentTH = TH;
  46256. var col = this.hot.view.wt.wtTable.getCoords(TH).col; // getCoords returns CellCoords
  46257. var headerHeight = (0, _element.outerHeight)(this.currentTH);
  46258. if (col >= 0) {
  46259. // if not col header
  46260. var box = this.currentTH.getBoundingClientRect();
  46261. this.currentCol = col;
  46262. this.selectedCols = [];
  46263. if (this.hot.selection.isSelected() && this.hot.selection.isSelectedByColumnHeader()) {
  46264. var _hot$getSelectedRange = this.hot.getSelectedRangeLast(),
  46265. from = _hot$getSelectedRange.from,
  46266. to = _hot$getSelectedRange.to;
  46267. var start = from.col;
  46268. var end = to.col;
  46269. if (start >= end) {
  46270. start = to.col;
  46271. end = from.col;
  46272. }
  46273. if (this.currentCol >= start && this.currentCol <= end) {
  46274. (0, _number.rangeEach)(start, end, function (i) {
  46275. return _this3.selectedCols.push(i);
  46276. });
  46277. } else {
  46278. this.selectedCols.push(this.currentCol);
  46279. }
  46280. } else {
  46281. this.selectedCols.push(this.currentCol);
  46282. }
  46283. this.startOffset = box.left - 6;
  46284. this.startWidth = parseInt(box.width, 10);
  46285. this.handle.style.top = box.top + 'px';
  46286. this.handle.style.left = this.startOffset + this.startWidth + 'px';
  46287. this.handle.style.height = headerHeight + 'px';
  46288. this.hot.rootElement.appendChild(this.handle);
  46289. }
  46290. }
  46291. /**
  46292. * Refresh the resize handle position.
  46293. */
  46294. }, {
  46295. key: 'refreshHandlePosition',
  46296. value: function refreshHandlePosition() {
  46297. this.handle.style.left = this.startOffset + this.currentWidth + 'px';
  46298. }
  46299. /**
  46300. * Set the resize guide position.
  46301. */
  46302. }, {
  46303. key: 'setupGuidePosition',
  46304. value: function setupGuidePosition() {
  46305. var handleHeight = parseInt((0, _element.outerHeight)(this.handle), 10);
  46306. var handleBottomPosition = parseInt(this.handle.style.top, 10) + handleHeight;
  46307. var maximumVisibleElementHeight = parseInt(this.hot.view.maximumVisibleElementHeight(0), 10);
  46308. (0, _element.addClass)(this.handle, 'active');
  46309. (0, _element.addClass)(this.guide, 'active');
  46310. this.guide.style.top = handleBottomPosition + 'px';
  46311. this.guide.style.left = this.handle.style.left;
  46312. this.guide.style.height = maximumVisibleElementHeight - handleHeight + 'px';
  46313. this.hot.rootElement.appendChild(this.guide);
  46314. }
  46315. /**
  46316. * Refresh the resize guide position.
  46317. */
  46318. }, {
  46319. key: 'refreshGuidePosition',
  46320. value: function refreshGuidePosition() {
  46321. this.guide.style.left = this.handle.style.left;
  46322. }
  46323. /**
  46324. * Hide both the resize handle and resize guide.
  46325. */
  46326. }, {
  46327. key: 'hideHandleAndGuide',
  46328. value: function hideHandleAndGuide() {
  46329. (0, _element.removeClass)(this.handle, 'active');
  46330. (0, _element.removeClass)(this.guide, 'active');
  46331. }
  46332. /**
  46333. * Check if provided element is considered a column header.
  46334. *
  46335. * @param {HTMLElement} element HTML element.
  46336. * @returns {Boolean}
  46337. */
  46338. }, {
  46339. key: 'checkIfColumnHeader',
  46340. value: function checkIfColumnHeader(element) {
  46341. if (element != this.hot.rootElement) {
  46342. var parent = element.parentNode;
  46343. if (parent.tagName === 'THEAD') {
  46344. return true;
  46345. }
  46346. return this.checkIfColumnHeader(parent);
  46347. }
  46348. return false;
  46349. }
  46350. /**
  46351. * Get the TH element from the provided element.
  46352. *
  46353. * @param {HTMLElement} element HTML element.
  46354. * @returns {HTMLElement}
  46355. */
  46356. }, {
  46357. key: 'getTHFromTargetElement',
  46358. value: function getTHFromTargetElement(element) {
  46359. if (element.tagName != 'TABLE') {
  46360. if (element.tagName == 'TH') {
  46361. return element;
  46362. }
  46363. return this.getTHFromTargetElement(element.parentNode);
  46364. }
  46365. return null;
  46366. }
  46367. /**
  46368. * 'mouseover' event callback - set the handle position.
  46369. *
  46370. * @private
  46371. * @param {MouseEvent} event
  46372. */
  46373. }, {
  46374. key: 'onMouseOver',
  46375. value: function onMouseOver(event) {
  46376. if (this.checkIfColumnHeader(event.target)) {
  46377. var th = this.getTHFromTargetElement(event.target);
  46378. if (!th) {
  46379. return;
  46380. }
  46381. var colspan = th.getAttribute('colspan');
  46382. if (th && (colspan === null || colspan === 1)) {
  46383. if (!this.pressed) {
  46384. this.setupHandlePosition(th);
  46385. }
  46386. }
  46387. }
  46388. }
  46389. /**
  46390. * Auto-size row after doubleclick - callback.
  46391. *
  46392. * @private
  46393. */
  46394. }, {
  46395. key: 'afterMouseDownTimeout',
  46396. value: function afterMouseDownTimeout() {
  46397. var _this4 = this;
  46398. var render = function render() {
  46399. _this4.hot.forceFullRender = true;
  46400. _this4.hot.view.render(); // updates all
  46401. _this4.hot.view.wt.wtOverlays.adjustElementsSize(true);
  46402. };
  46403. var resize = function resize(selectedCol, forceRender) {
  46404. var hookNewSize = _this4.hot.runHooks('beforeColumnResize', selectedCol, _this4.newSize, true);
  46405. if (hookNewSize !== void 0) {
  46406. _this4.newSize = hookNewSize;
  46407. }
  46408. if (_this4.hot.getSettings().stretchH === 'all') {
  46409. _this4.clearManualSize(selectedCol);
  46410. } else {
  46411. _this4.setManualSize(selectedCol, _this4.newSize); // double click sets by auto row size plugin
  46412. }
  46413. if (forceRender) {
  46414. render();
  46415. }
  46416. _this4.saveManualColumnWidths();
  46417. _this4.hot.runHooks('afterColumnResize', selectedCol, _this4.newSize, true);
  46418. };
  46419. if (this.dblclick >= 2) {
  46420. var selectedColsLength = this.selectedCols.length;
  46421. if (selectedColsLength > 1) {
  46422. (0, _array.arrayEach)(this.selectedCols, function (selectedCol) {
  46423. resize(selectedCol);
  46424. });
  46425. render();
  46426. } else {
  46427. (0, _array.arrayEach)(this.selectedCols, function (selectedCol) {
  46428. resize(selectedCol, true);
  46429. });
  46430. }
  46431. }
  46432. this.dblclick = 0;
  46433. this.autoresizeTimeout = null;
  46434. }
  46435. /**
  46436. * 'mousedown' event callback.
  46437. *
  46438. * @private
  46439. * @param {MouseEvent} e
  46440. */
  46441. }, {
  46442. key: 'onMouseDown',
  46443. value: function onMouseDown(event) {
  46444. var _this5 = this;
  46445. if ((0, _element.hasClass)(event.target, 'manualColumnResizer')) {
  46446. this.setupGuidePosition();
  46447. this.pressed = this.hot;
  46448. if (this.autoresizeTimeout === null) {
  46449. this.autoresizeTimeout = setTimeout(function () {
  46450. return _this5.afterMouseDownTimeout();
  46451. }, 500);
  46452. this.hot._registerTimeout(this.autoresizeTimeout);
  46453. }
  46454. this.dblclick++;
  46455. this.startX = (0, _event.pageX)(event);
  46456. this.newSize = this.startWidth;
  46457. }
  46458. }
  46459. /**
  46460. * 'mousemove' event callback - refresh the handle and guide positions, cache the new column width.
  46461. *
  46462. * @private
  46463. * @param {MouseEvent} e
  46464. */
  46465. }, {
  46466. key: 'onMouseMove',
  46467. value: function onMouseMove(event) {
  46468. var _this6 = this;
  46469. if (this.pressed) {
  46470. this.currentWidth = this.startWidth + ((0, _event.pageX)(event) - this.startX);
  46471. (0, _array.arrayEach)(this.selectedCols, function (selectedCol) {
  46472. _this6.newSize = _this6.setManualSize(selectedCol, _this6.currentWidth);
  46473. });
  46474. this.refreshHandlePosition();
  46475. this.refreshGuidePosition();
  46476. }
  46477. }
  46478. /**
  46479. * 'mouseup' event callback - apply the column resizing.
  46480. *
  46481. * @private
  46482. * @param {MouseEvent} e
  46483. */
  46484. }, {
  46485. key: 'onMouseUp',
  46486. value: function onMouseUp(event) {
  46487. var _this7 = this;
  46488. var render = function render() {
  46489. _this7.hot.forceFullRender = true;
  46490. _this7.hot.view.render(); // updates all
  46491. _this7.hot.view.wt.wtOverlays.adjustElementsSize(true);
  46492. };
  46493. var resize = function resize(selectedCol, forceRender) {
  46494. _this7.hot.runHooks('beforeColumnResize', selectedCol, _this7.newSize);
  46495. if (forceRender) {
  46496. render();
  46497. }
  46498. _this7.saveManualColumnWidths();
  46499. _this7.hot.runHooks('afterColumnResize', selectedCol, _this7.newSize);
  46500. };
  46501. if (this.pressed) {
  46502. this.hideHandleAndGuide();
  46503. this.pressed = false;
  46504. if (this.newSize != this.startWidth) {
  46505. var selectedColsLength = this.selectedCols.length;
  46506. if (selectedColsLength > 1) {
  46507. (0, _array.arrayEach)(this.selectedCols, function (selectedCol) {
  46508. resize(selectedCol);
  46509. });
  46510. render();
  46511. } else {
  46512. (0, _array.arrayEach)(this.selectedCols, function (selectedCol) {
  46513. resize(selectedCol, true);
  46514. });
  46515. }
  46516. }
  46517. this.setupHandlePosition(this.currentTH);
  46518. }
  46519. }
  46520. /**
  46521. * Bind the mouse events.
  46522. *
  46523. * @private
  46524. */
  46525. }, {
  46526. key: 'bindEvents',
  46527. value: function bindEvents() {
  46528. var _this8 = this;
  46529. this.eventManager.addEventListener(this.hot.rootElement, 'mouseover', function (e) {
  46530. return _this8.onMouseOver(e);
  46531. });
  46532. this.eventManager.addEventListener(this.hot.rootElement, 'mousedown', function (e) {
  46533. return _this8.onMouseDown(e);
  46534. });
  46535. this.eventManager.addEventListener(window, 'mousemove', function (e) {
  46536. return _this8.onMouseMove(e);
  46537. });
  46538. this.eventManager.addEventListener(window, 'mouseup', function (e) {
  46539. return _this8.onMouseUp(e);
  46540. });
  46541. }
  46542. /**
  46543. * Cache the current column width.
  46544. *
  46545. * @param {Number} column Visual column index.
  46546. * @param {Number} width Column width.
  46547. * @returns {Number}
  46548. */
  46549. }, {
  46550. key: 'setManualSize',
  46551. value: function setManualSize(column, width) {
  46552. width = Math.max(width, 20);
  46553. /**
  46554. * We need to run col through modifyCol hook, in case the order of displayed columns is different than the order
  46555. * in data source. For instance, this order can be modified by manualColumnMove plugin.
  46556. */
  46557. column = this.hot.runHooks('modifyCol', column);
  46558. this.manualColumnWidths[column] = width;
  46559. return width;
  46560. }
  46561. /**
  46562. * Clear cache for the current column index.
  46563. *
  46564. * @param {Number} column Visual column index.
  46565. */
  46566. }, {
  46567. key: 'clearManualSize',
  46568. value: function clearManualSize(column) {
  46569. column = this.hot.runHooks('modifyCol', column);
  46570. this.manualColumnWidths[column] = void 0;
  46571. }
  46572. /**
  46573. * Modify the provided column width, based on the plugin settings
  46574. *
  46575. * @private
  46576. * @param {Number} width Column width.
  46577. * @param {Number} column Visual column index.
  46578. * @returns {Number}
  46579. */
  46580. }, {
  46581. key: 'onModifyColWidth',
  46582. value: function onModifyColWidth(width, column) {
  46583. if (this.enabled) {
  46584. column = this.hot.runHooks('modifyCol', column);
  46585. if (this.hot.getSettings().manualColumnResize && this.manualColumnWidths[column]) {
  46586. return this.manualColumnWidths[column];
  46587. }
  46588. }
  46589. return width;
  46590. }
  46591. /**
  46592. * Modify the provided column stretched width. This hook decides if specified column should be stretched or not.
  46593. *
  46594. * @private
  46595. * @param {Number} stretchedWidth Stretched width.
  46596. * @param {Number} column Physical column index.
  46597. * @returns {Number}
  46598. */
  46599. }, {
  46600. key: 'onBeforeStretchingColumnWidth',
  46601. value: function onBeforeStretchingColumnWidth(stretchedWidth, column) {
  46602. var width = this.manualColumnWidths[column];
  46603. if (width === void 0) {
  46604. width = stretchedWidth;
  46605. }
  46606. return width;
  46607. }
  46608. /**
  46609. * `beforeColumnResize` hook callback.
  46610. *
  46611. * @private
  46612. * @param {Number} currentColumn Index of the resized column.
  46613. * @param {Number} newSize Calculated new column width.
  46614. * @param {Boolean} isDoubleClick Flag that determines whether there was a double-click.
  46615. */
  46616. }, {
  46617. key: 'onBeforeColumnResize',
  46618. value: function onBeforeColumnResize() {
  46619. // clear the header height cache information
  46620. this.hot.view.wt.wtViewport.hasOversizedColumnHeadersMarked = {};
  46621. }
  46622. }]);
  46623. return ManualColumnResize;
  46624. }(_base2.default);
  46625. (0, _plugins.registerPlugin)('manualColumnResize', ManualColumnResize);
  46626. exports.default = ManualColumnResize;
  46627. /***/ }),
  46628. /* 460 */
  46629. /***/ (function(module, exports, __webpack_require__) {
  46630. "use strict";
  46631. exports.__esModule = true;
  46632. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  46633. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  46634. var _base = __webpack_require__(10);
  46635. var _base2 = _interopRequireDefault(_base);
  46636. var _pluginHooks = __webpack_require__(15);
  46637. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  46638. var _array = __webpack_require__(1);
  46639. var _element = __webpack_require__(0);
  46640. var _number = __webpack_require__(5);
  46641. var _eventManager = __webpack_require__(6);
  46642. var _eventManager2 = _interopRequireDefault(_eventManager);
  46643. var _plugins = __webpack_require__(8);
  46644. var _rowsMapper = __webpack_require__(461);
  46645. var _rowsMapper2 = _interopRequireDefault(_rowsMapper);
  46646. var _backlight = __webpack_require__(462);
  46647. var _backlight2 = _interopRequireDefault(_backlight);
  46648. var _guideline = __webpack_require__(463);
  46649. var _guideline2 = _interopRequireDefault(_guideline);
  46650. var _src = __webpack_require__(4);
  46651. __webpack_require__(464);
  46652. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  46653. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  46654. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  46655. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  46656. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  46657. _pluginHooks2.default.getSingleton().register('beforeRowMove');
  46658. _pluginHooks2.default.getSingleton().register('afterRowMove');
  46659. _pluginHooks2.default.getSingleton().register('unmodifyRow');
  46660. var privatePool = new WeakMap();
  46661. var CSS_PLUGIN = 'ht__manualRowMove';
  46662. var CSS_SHOW_UI = 'show-ui';
  46663. var CSS_ON_MOVING = 'on-moving--rows';
  46664. var CSS_AFTER_SELECTION = 'after-selection--rows';
  46665. /**
  46666. * @plugin ManualRowMove
  46667. *
  46668. * @description
  46669. * This plugin allows to change rows order.
  46670. *
  46671. * API:
  46672. * - moveRow - move single row to the new position.
  46673. * - moveRows - move many rows (as an array of indexes) to the new position.
  46674. *
  46675. * If you want apply visual changes, you have to call manually the render() method on the instance of handsontable.
  46676. *
  46677. * UI components:
  46678. * - backlight - highlight of selected rows.
  46679. * - guideline - line which shows where rows has been moved.
  46680. *
  46681. * @class ManualRowMove
  46682. * @plugin ManualRowMove
  46683. */
  46684. var ManualRowMove = function (_BasePlugin) {
  46685. _inherits(ManualRowMove, _BasePlugin);
  46686. function ManualRowMove(hotInstance) {
  46687. _classCallCheck(this, ManualRowMove);
  46688. /**
  46689. * Set up WeakMap of plugin to sharing private parameters;
  46690. */
  46691. var _this = _possibleConstructorReturn(this, (ManualRowMove.__proto__ || Object.getPrototypeOf(ManualRowMove)).call(this, hotInstance));
  46692. privatePool.set(_this, {
  46693. rowsToMove: [],
  46694. pressed: void 0,
  46695. disallowMoving: void 0,
  46696. target: {
  46697. eventPageY: void 0,
  46698. coords: void 0,
  46699. TD: void 0,
  46700. row: void 0
  46701. }
  46702. });
  46703. /**
  46704. * List of last removed row indexes.
  46705. *
  46706. * @type {Array}
  46707. */
  46708. _this.removedRows = [];
  46709. /**
  46710. * Object containing visual row indexes mapped to data source indexes.
  46711. *
  46712. * @type {RowsMapper}
  46713. */
  46714. _this.rowsMapper = new _rowsMapper2.default(_this);
  46715. /**
  46716. * Event Manager object.
  46717. *
  46718. * @type {Object}
  46719. */
  46720. _this.eventManager = new _eventManager2.default(_this);
  46721. /**
  46722. * Backlight UI object.
  46723. *
  46724. * @type {Object}
  46725. */
  46726. _this.backlight = new _backlight2.default(hotInstance);
  46727. /**
  46728. * Guideline UI object.
  46729. *
  46730. * @type {Object}
  46731. */
  46732. _this.guideline = new _guideline2.default(hotInstance);
  46733. return _this;
  46734. }
  46735. /**
  46736. * Check if plugin is enabled.
  46737. *
  46738. * @returns {Boolean}
  46739. */
  46740. _createClass(ManualRowMove, [{
  46741. key: 'isEnabled',
  46742. value: function isEnabled() {
  46743. return !!this.hot.getSettings().manualRowMove;
  46744. }
  46745. /**
  46746. * Enable the plugin.
  46747. */
  46748. }, {
  46749. key: 'enablePlugin',
  46750. value: function enablePlugin() {
  46751. var _this2 = this;
  46752. if (this.enabled) {
  46753. return;
  46754. }
  46755. this.addHook('beforeOnCellMouseDown', function (event, coords, TD, blockCalculations) {
  46756. return _this2.onBeforeOnCellMouseDown(event, coords, TD, blockCalculations);
  46757. });
  46758. this.addHook('beforeOnCellMouseOver', function (event, coords, TD, blockCalculations) {
  46759. return _this2.onBeforeOnCellMouseOver(event, coords, TD, blockCalculations);
  46760. });
  46761. this.addHook('afterScrollHorizontally', function () {
  46762. return _this2.onAfterScrollHorizontally();
  46763. });
  46764. this.addHook('modifyRow', function (row, source) {
  46765. return _this2.onModifyRow(row, source);
  46766. });
  46767. this.addHook('beforeRemoveRow', function (index, amount) {
  46768. return _this2.onBeforeRemoveRow(index, amount);
  46769. });
  46770. this.addHook('afterRemoveRow', function () {
  46771. return _this2.onAfterRemoveRow();
  46772. });
  46773. this.addHook('afterCreateRow', function (index, amount) {
  46774. return _this2.onAfterCreateRow(index, amount);
  46775. });
  46776. this.addHook('afterLoadData', function () {
  46777. return _this2.onAfterLoadData();
  46778. });
  46779. this.addHook('beforeColumnSort', function (column, order) {
  46780. return _this2.onBeforeColumnSort(column, order);
  46781. });
  46782. this.addHook('unmodifyRow', function (row) {
  46783. return _this2.onUnmodifyRow(row);
  46784. });
  46785. this.registerEvents();
  46786. // TODO: move adding plugin classname to BasePlugin.
  46787. (0, _element.addClass)(this.hot.rootElement, CSS_PLUGIN);
  46788. _get(ManualRowMove.prototype.__proto__ || Object.getPrototypeOf(ManualRowMove.prototype), 'enablePlugin', this).call(this);
  46789. }
  46790. /**
  46791. * Updates the plugin to use the latest options you have specified.
  46792. */
  46793. }, {
  46794. key: 'updatePlugin',
  46795. value: function updatePlugin() {
  46796. this.disablePlugin();
  46797. this.enablePlugin();
  46798. this.onAfterPluginsInitialized();
  46799. _get(ManualRowMove.prototype.__proto__ || Object.getPrototypeOf(ManualRowMove.prototype), 'updatePlugin', this).call(this);
  46800. }
  46801. /**
  46802. * Disable plugin for this Handsontable instance.
  46803. */
  46804. }, {
  46805. key: 'disablePlugin',
  46806. value: function disablePlugin() {
  46807. var pluginSettings = this.hot.getSettings().manualRowMove;
  46808. if (Array.isArray(pluginSettings)) {
  46809. this.rowsMapper.clearMap();
  46810. }
  46811. (0, _element.removeClass)(this.hot.rootElement, CSS_PLUGIN);
  46812. this.unregisterEvents();
  46813. this.backlight.destroy();
  46814. this.guideline.destroy();
  46815. _get(ManualRowMove.prototype.__proto__ || Object.getPrototypeOf(ManualRowMove.prototype), 'disablePlugin', this).call(this);
  46816. }
  46817. /**
  46818. * Move a single row.
  46819. *
  46820. * @param {Number} row Visual row index to be moved.
  46821. * @param {Number} target Visual row index being a target for the moved row.
  46822. */
  46823. }, {
  46824. key: 'moveRow',
  46825. value: function moveRow(row, target) {
  46826. this.moveRows([row], target);
  46827. }
  46828. /**
  46829. * Move multiple rows.
  46830. *
  46831. * @param {Array} rows Array of visual row indexes to be moved.
  46832. * @param {Number} target Visual row index being a target for the moved rows.
  46833. */
  46834. }, {
  46835. key: 'moveRows',
  46836. value: function moveRows(rows, target) {
  46837. var _this3 = this;
  46838. var visualRows = [].concat(_toConsumableArray(rows));
  46839. var priv = privatePool.get(this);
  46840. var beforeMoveHook = this.hot.runHooks('beforeRowMove', visualRows, target);
  46841. priv.disallowMoving = beforeMoveHook === false;
  46842. if (!priv.disallowMoving) {
  46843. // first we need to rewrite an visual indexes to physical for save reference after move
  46844. (0, _array.arrayEach)(rows, function (row, index, array) {
  46845. array[index] = _this3.rowsMapper.getValueByIndex(row);
  46846. });
  46847. // next, when we have got an physical indexes, we can move rows
  46848. (0, _array.arrayEach)(rows, function (row, index) {
  46849. var actualPosition = _this3.rowsMapper.getIndexByValue(row);
  46850. if (actualPosition !== target) {
  46851. _this3.rowsMapper.moveRow(actualPosition, target + index);
  46852. }
  46853. });
  46854. // after moving we have to clear rowsMapper from null entries
  46855. this.rowsMapper.clearNull();
  46856. }
  46857. this.hot.runHooks('afterRowMove', visualRows, target);
  46858. }
  46859. /**
  46860. * Correct the cell selection after the move action. Fired only when action was made with a mouse.
  46861. * That means that changing the row order using the API won't correct the selection.
  46862. *
  46863. * @private
  46864. * @param {Number} startRow Visual row index for the start of the selection.
  46865. * @param {Number} endRow Visual row index for the end of the selection.
  46866. */
  46867. }, {
  46868. key: 'changeSelection',
  46869. value: function changeSelection(startRow, endRow) {
  46870. this.hot.selectRows(startRow, endRow);
  46871. }
  46872. /**
  46873. * Get the sum of the heights of rows in the provided range.
  46874. *
  46875. * @private
  46876. * @param {Number} from Visual row index.
  46877. * @param {Number} to Visual row index.
  46878. * @returns {Number}
  46879. */
  46880. }, {
  46881. key: 'getRowsHeight',
  46882. value: function getRowsHeight(from, to) {
  46883. var height = 0;
  46884. for (var i = from; i < to; i++) {
  46885. var rowHeight = this.hot.view.wt.wtTable.getRowHeight(i) || 23;
  46886. height += rowHeight;
  46887. }
  46888. return height;
  46889. }
  46890. /**
  46891. * Load initial settings when persistent state is saved or when plugin was initialized as an array.
  46892. *
  46893. * @private
  46894. */
  46895. }, {
  46896. key: 'initialSettings',
  46897. value: function initialSettings() {
  46898. var pluginSettings = this.hot.getSettings().manualRowMove;
  46899. if (Array.isArray(pluginSettings)) {
  46900. this.moveRows(pluginSettings, 0);
  46901. } else if (pluginSettings !== void 0) {
  46902. var persistentState = this.persistentStateLoad();
  46903. if (persistentState.length) {
  46904. this.moveRows(persistentState, 0);
  46905. }
  46906. }
  46907. }
  46908. /**
  46909. * Check if the provided row is in the fixedRowsTop section.
  46910. *
  46911. * @private
  46912. * @param {Number} row Visual row index to check.
  46913. * @returns {Boolean}
  46914. */
  46915. }, {
  46916. key: 'isFixedRowTop',
  46917. value: function isFixedRowTop(row) {
  46918. return row < this.hot.getSettings().fixedRowsTop;
  46919. }
  46920. /**
  46921. * Check if the provided row is in the fixedRowsBottom section.
  46922. *
  46923. * @private
  46924. * @param {Number} row Visual row index to check.
  46925. * @returns {Boolean}
  46926. */
  46927. }, {
  46928. key: 'isFixedRowBottom',
  46929. value: function isFixedRowBottom(row) {
  46930. return row > this.hot.getSettings().fixedRowsBottom;
  46931. }
  46932. /**
  46933. * Save the manual row positions to the persistent state.
  46934. *
  46935. * @private
  46936. */
  46937. }, {
  46938. key: 'persistentStateSave',
  46939. value: function persistentStateSave() {
  46940. this.hot.runHooks('persistentStateSave', 'manualRowMove', this.rowsMapper._arrayMap);
  46941. }
  46942. /**
  46943. * Load the manual row positions from the persistent state.
  46944. *
  46945. * @private
  46946. * @returns {Array} Stored state.
  46947. */
  46948. }, {
  46949. key: 'persistentStateLoad',
  46950. value: function persistentStateLoad() {
  46951. var storedState = {};
  46952. this.hot.runHooks('persistentStateLoad', 'manualRowMove', storedState);
  46953. return storedState.value ? storedState.value : [];
  46954. }
  46955. /**
  46956. * Prepare array of indexes based on actual selection.
  46957. *
  46958. * @private
  46959. * @returns {Array}
  46960. */
  46961. }, {
  46962. key: 'prepareRowsToMoving',
  46963. value: function prepareRowsToMoving() {
  46964. var selection = this.hot.getSelectedRangeLast();
  46965. var selectedRows = [];
  46966. if (!selection) {
  46967. return selectedRows;
  46968. }
  46969. var from = selection.from,
  46970. to = selection.to;
  46971. var start = Math.min(from.row, to.row);
  46972. var end = Math.max(from.row, to.row);
  46973. (0, _number.rangeEach)(start, end, function (i) {
  46974. selectedRows.push(i);
  46975. });
  46976. return selectedRows;
  46977. }
  46978. /**
  46979. * Update the UI visual position.
  46980. *
  46981. * @private
  46982. */
  46983. }, {
  46984. key: 'refreshPositions',
  46985. value: function refreshPositions() {
  46986. var priv = privatePool.get(this);
  46987. var coords = priv.target.coords;
  46988. var firstVisible = this.hot.view.wt.wtTable.getFirstVisibleRow();
  46989. var lastVisible = this.hot.view.wt.wtTable.getLastVisibleRow();
  46990. var fixedRows = this.hot.getSettings().fixedRowsTop;
  46991. var countRows = this.hot.countRows();
  46992. if (coords.row < fixedRows && firstVisible > 0) {
  46993. this.hot.scrollViewportTo(firstVisible - 1);
  46994. }
  46995. if (coords.row >= lastVisible && lastVisible < countRows) {
  46996. this.hot.scrollViewportTo(lastVisible + 1, undefined, true);
  46997. }
  46998. var wtTable = this.hot.view.wt.wtTable;
  46999. var TD = priv.target.TD;
  47000. var rootElementOffset = (0, _element.offset)(this.hot.rootElement);
  47001. var tdOffsetTop = this.hot.view.THEAD.offsetHeight + this.getRowsHeight(0, coords.row);
  47002. var mouseOffsetTop = priv.target.eventPageY - rootElementOffset.top + wtTable.holder.scrollTop;
  47003. var hiderHeight = wtTable.hider.offsetHeight;
  47004. var tbodyOffsetTop = wtTable.TBODY.offsetTop;
  47005. var backlightElemMarginTop = this.backlight.getOffset().top;
  47006. var backlightElemHeight = this.backlight.getSize().height;
  47007. if (this.isFixedRowTop(coords.row)) {
  47008. tdOffsetTop += wtTable.holder.scrollTop;
  47009. }
  47010. // todo: fixedRowsBottom
  47011. // if (this.isFixedRowBottom(coords.row)) {
  47012. //
  47013. // }
  47014. if (coords.row < 0) {
  47015. // if hover on colHeader
  47016. priv.target.row = firstVisible > 0 ? firstVisible - 1 : firstVisible;
  47017. } else if (TD.offsetHeight / 2 + tdOffsetTop <= mouseOffsetTop) {
  47018. // if hover on lower part of TD
  47019. priv.target.row = coords.row + 1;
  47020. // unfortunately first row is bigger than rest
  47021. tdOffsetTop += coords.row === 0 ? TD.offsetHeight - 1 : TD.offsetHeight;
  47022. } else {
  47023. // elsewhere on table
  47024. priv.target.row = coords.row;
  47025. }
  47026. var backlightTop = mouseOffsetTop;
  47027. var guidelineTop = tdOffsetTop;
  47028. if (mouseOffsetTop + backlightElemHeight + backlightElemMarginTop >= hiderHeight) {
  47029. // prevent display backlight below table
  47030. backlightTop = hiderHeight - backlightElemHeight - backlightElemMarginTop;
  47031. } else if (mouseOffsetTop + backlightElemMarginTop < tbodyOffsetTop) {
  47032. // prevent display above below table
  47033. backlightTop = tbodyOffsetTop + Math.abs(backlightElemMarginTop);
  47034. }
  47035. if (tdOffsetTop >= hiderHeight - 1) {
  47036. // prevent display guideline below table
  47037. guidelineTop = hiderHeight - 1;
  47038. }
  47039. var topOverlayHeight = 0;
  47040. if (this.hot.view.wt.wtOverlays.topOverlay) {
  47041. topOverlayHeight = this.hot.view.wt.wtOverlays.topOverlay.clone.wtTable.TABLE.offsetHeight;
  47042. }
  47043. if (coords.row >= fixedRows && guidelineTop - wtTable.holder.scrollTop < topOverlayHeight) {
  47044. this.hot.scrollViewportTo(coords.row);
  47045. }
  47046. this.backlight.setPosition(backlightTop);
  47047. this.guideline.setPosition(guidelineTop);
  47048. }
  47049. /**
  47050. * This method checks arrayMap from rowsMapper and updates the rowsMapper if it's necessary.
  47051. *
  47052. * @private
  47053. */
  47054. }, {
  47055. key: 'updateRowsMapper',
  47056. value: function updateRowsMapper() {
  47057. var countRows = this.hot.countSourceRows();
  47058. var rowsMapperLen = this.rowsMapper._arrayMap.length;
  47059. if (rowsMapperLen === 0) {
  47060. this.rowsMapper.createMap(countRows || this.hot.getSettings().startRows);
  47061. } else if (rowsMapperLen < countRows) {
  47062. var diff = countRows - rowsMapperLen;
  47063. this.rowsMapper.insertItems(rowsMapperLen, diff);
  47064. } else if (rowsMapperLen > countRows) {
  47065. var maxIndex = countRows - 1;
  47066. var rowsToRemove = [];
  47067. (0, _array.arrayEach)(this.rowsMapper._arrayMap, function (value, index) {
  47068. if (value > maxIndex) {
  47069. rowsToRemove.push(index);
  47070. }
  47071. });
  47072. this.rowsMapper.removeItems(rowsToRemove);
  47073. }
  47074. }
  47075. /**
  47076. * Bind the events used by the plugin.
  47077. *
  47078. * @private
  47079. */
  47080. }, {
  47081. key: 'registerEvents',
  47082. value: function registerEvents() {
  47083. var _this4 = this;
  47084. this.eventManager.addEventListener(document.documentElement, 'mousemove', function (event) {
  47085. return _this4.onMouseMove(event);
  47086. });
  47087. this.eventManager.addEventListener(document.documentElement, 'mouseup', function () {
  47088. return _this4.onMouseUp();
  47089. });
  47090. }
  47091. /**
  47092. * Unbind the events used by the plugin.
  47093. *
  47094. * @private
  47095. */
  47096. }, {
  47097. key: 'unregisterEvents',
  47098. value: function unregisterEvents() {
  47099. this.eventManager.clear();
  47100. }
  47101. /**
  47102. * `beforeColumnSort` hook callback. If user uses the sorting, manual row moving is disabled.
  47103. *
  47104. * @private
  47105. * @param {Number} column Column index where soring is present
  47106. * @param {*} order State of sorting. ASC/DESC/None
  47107. */
  47108. }, {
  47109. key: 'onBeforeColumnSort',
  47110. value: function onBeforeColumnSort(column, order) {
  47111. var priv = privatePool.get(this);
  47112. priv.disallowMoving = order !== void 0;
  47113. }
  47114. /**
  47115. * Change the behavior of selection / dragging.
  47116. *
  47117. * @private
  47118. * @param {MouseEvent} event
  47119. * @param {CellCoords} coords Visual coordinates.
  47120. * @param {HTMLElement} TD
  47121. * @param {Object} blockCalculations
  47122. */
  47123. }, {
  47124. key: 'onBeforeOnCellMouseDown',
  47125. value: function onBeforeOnCellMouseDown(event, coords, TD, blockCalculations) {
  47126. var wtTable = this.hot.view.wt.wtTable;
  47127. var isHeaderSelection = this.hot.selection.isSelectedByRowHeader();
  47128. var selection = this.hot.getSelectedRangeLast();
  47129. var priv = privatePool.get(this);
  47130. if (!selection || !isHeaderSelection || priv.pressed || event.button !== 0) {
  47131. priv.pressed = false;
  47132. priv.rowsToMove.length = 0;
  47133. (0, _element.removeClass)(this.hot.rootElement, [CSS_ON_MOVING, CSS_SHOW_UI]);
  47134. return;
  47135. }
  47136. var guidelineIsNotReady = this.guideline.isBuilt() && !this.guideline.isAppended();
  47137. var backlightIsNotReady = this.backlight.isBuilt() && !this.backlight.isAppended();
  47138. if (guidelineIsNotReady && backlightIsNotReady) {
  47139. this.guideline.appendTo(wtTable.hider);
  47140. this.backlight.appendTo(wtTable.hider);
  47141. }
  47142. var from = selection.from,
  47143. to = selection.to;
  47144. var start = Math.min(from.row, to.row);
  47145. var end = Math.max(from.row, to.row);
  47146. if (coords.col < 0 && coords.row >= start && coords.row <= end) {
  47147. blockCalculations.row = true;
  47148. priv.pressed = true;
  47149. priv.target.eventPageY = event.pageY;
  47150. priv.target.coords = coords;
  47151. priv.target.TD = TD;
  47152. priv.rowsToMove = this.prepareRowsToMoving();
  47153. var leftPos = wtTable.holder.scrollLeft + this.hot.view.wt.wtViewport.getRowHeaderWidth();
  47154. this.backlight.setPosition(null, leftPos);
  47155. this.backlight.setSize(wtTable.hider.offsetWidth - leftPos, this.getRowsHeight(start, end + 1));
  47156. this.backlight.setOffset((this.getRowsHeight(start, coords.row) + event.layerY) * -1, null);
  47157. (0, _element.addClass)(this.hot.rootElement, CSS_ON_MOVING);
  47158. this.refreshPositions();
  47159. } else {
  47160. (0, _element.removeClass)(this.hot.rootElement, CSS_AFTER_SELECTION);
  47161. priv.pressed = false;
  47162. priv.rowsToMove.length = 0;
  47163. }
  47164. }
  47165. /**
  47166. * 'mouseMove' event callback. Fired when pointer move on document.documentElement.
  47167. *
  47168. * @private
  47169. * @param {MouseEvent} event `mousemove` event properties.
  47170. */
  47171. }, {
  47172. key: 'onMouseMove',
  47173. value: function onMouseMove(event) {
  47174. var priv = privatePool.get(this);
  47175. if (!priv.pressed) {
  47176. return;
  47177. }
  47178. // callback for browser which doesn't supports CSS pointer-event: none
  47179. if (event.realTarget === this.backlight.element) {
  47180. var height = this.backlight.getSize().height;
  47181. this.backlight.setSize(null, 0);
  47182. setTimeout(function () {
  47183. this.backlight.setPosition(null, height);
  47184. });
  47185. }
  47186. priv.target.eventPageY = event.pageY;
  47187. this.refreshPositions();
  47188. }
  47189. /**
  47190. * 'beforeOnCellMouseOver' hook callback. Fired when pointer was over cell.
  47191. *
  47192. * @private
  47193. * @param {MouseEvent} event `mouseover` event properties.
  47194. * @param {CellCoords} coords Visual cell coordinates where was fired event.
  47195. * @param {HTMLElement} TD Cell represented as HTMLElement.
  47196. * @param {Object} blockCalculations Object which contains information about blockCalculation for row, column or cells.
  47197. */
  47198. }, {
  47199. key: 'onBeforeOnCellMouseOver',
  47200. value: function onBeforeOnCellMouseOver(event, coords, TD, blockCalculations) {
  47201. var selectedRange = this.hot.getSelectedRangeLast();
  47202. var priv = privatePool.get(this);
  47203. if (!selectedRange || !priv.pressed) {
  47204. return;
  47205. }
  47206. if (priv.rowsToMove.indexOf(coords.row) > -1) {
  47207. (0, _element.removeClass)(this.hot.rootElement, CSS_SHOW_UI);
  47208. } else {
  47209. (0, _element.addClass)(this.hot.rootElement, CSS_SHOW_UI);
  47210. }
  47211. blockCalculations.row = true;
  47212. blockCalculations.column = true;
  47213. blockCalculations.cell = true;
  47214. priv.target.coords = coords;
  47215. priv.target.TD = TD;
  47216. }
  47217. /**
  47218. * `onMouseUp` hook callback.
  47219. *
  47220. * @private
  47221. */
  47222. }, {
  47223. key: 'onMouseUp',
  47224. value: function onMouseUp() {
  47225. var priv = privatePool.get(this);
  47226. var target = priv.target.row;
  47227. var rowsLen = priv.rowsToMove.length;
  47228. priv.pressed = false;
  47229. priv.backlightHeight = 0;
  47230. (0, _element.removeClass)(this.hot.rootElement, [CSS_ON_MOVING, CSS_SHOW_UI, CSS_AFTER_SELECTION]);
  47231. if (this.hot.selection.isSelectedByRowHeader()) {
  47232. (0, _element.addClass)(this.hot.rootElement, CSS_AFTER_SELECTION);
  47233. }
  47234. if (rowsLen < 1 || target === void 0 || priv.rowsToMove.indexOf(target) > -1 || priv.rowsToMove[rowsLen - 1] === target - 1) {
  47235. return;
  47236. }
  47237. this.moveRows(priv.rowsToMove, target);
  47238. this.persistentStateSave();
  47239. this.hot.render();
  47240. if (!priv.disallowMoving) {
  47241. var selectionStart = this.rowsMapper.getIndexByValue(priv.rowsToMove[0]);
  47242. var selectionEnd = this.rowsMapper.getIndexByValue(priv.rowsToMove[rowsLen - 1]);
  47243. this.changeSelection(selectionStart, selectionEnd);
  47244. }
  47245. priv.rowsToMove.length = 0;
  47246. }
  47247. /**
  47248. * `afterScrollHorizontally` hook callback. Fired the table was scrolled horizontally.
  47249. *
  47250. * @private
  47251. */
  47252. }, {
  47253. key: 'onAfterScrollHorizontally',
  47254. value: function onAfterScrollHorizontally() {
  47255. var wtTable = this.hot.view.wt.wtTable;
  47256. var headerWidth = this.hot.view.wt.wtViewport.getRowHeaderWidth();
  47257. var scrollLeft = wtTable.holder.scrollLeft;
  47258. var posLeft = headerWidth + scrollLeft;
  47259. this.backlight.setPosition(null, posLeft);
  47260. this.backlight.setSize(wtTable.hider.offsetWidth - posLeft);
  47261. }
  47262. /**
  47263. * `afterCreateRow` hook callback.
  47264. *
  47265. * @private
  47266. * @param {Number} index Visual index of the created row.
  47267. * @param {Number} amount Amount of created rows.
  47268. */
  47269. }, {
  47270. key: 'onAfterCreateRow',
  47271. value: function onAfterCreateRow(index, amount) {
  47272. this.rowsMapper.shiftItems(index, amount);
  47273. }
  47274. /**
  47275. * On before remove row listener.
  47276. *
  47277. * @private
  47278. * @param {Number} index Visual row index.
  47279. * @param {Number} amount Defines how many rows removed.
  47280. */
  47281. }, {
  47282. key: 'onBeforeRemoveRow',
  47283. value: function onBeforeRemoveRow(index, amount) {
  47284. var _this5 = this;
  47285. this.removedRows.length = 0;
  47286. if (index !== false) {
  47287. // Collect physical row index.
  47288. (0, _number.rangeEach)(index, index + amount - 1, function (removedIndex) {
  47289. _this5.removedRows.push(_this5.hot.runHooks('modifyRow', removedIndex, _this5.pluginName));
  47290. });
  47291. }
  47292. }
  47293. /**
  47294. * `afterRemoveRow` hook callback.
  47295. *
  47296. * @private
  47297. */
  47298. }, {
  47299. key: 'onAfterRemoveRow',
  47300. value: function onAfterRemoveRow() {
  47301. this.rowsMapper.unshiftItems(this.removedRows);
  47302. }
  47303. /**
  47304. * `afterLoadData` hook callback.
  47305. *
  47306. * @private
  47307. */
  47308. }, {
  47309. key: 'onAfterLoadData',
  47310. value: function onAfterLoadData() {
  47311. this.updateRowsMapper();
  47312. }
  47313. /**
  47314. * 'modifyRow' hook callback.
  47315. *
  47316. * @private
  47317. * @param {Number} row Visual Row index.
  47318. * @returns {Number} Physical row index.
  47319. */
  47320. }, {
  47321. key: 'onModifyRow',
  47322. value: function onModifyRow(row, source) {
  47323. if (source !== this.pluginName) {
  47324. var rowInMapper = this.rowsMapper.getValueByIndex(row);
  47325. row = rowInMapper === null ? row : rowInMapper;
  47326. }
  47327. return row;
  47328. }
  47329. /**
  47330. * 'unmodifyRow' hook callback.
  47331. *
  47332. * @private
  47333. * @param {Number} row Physical row index.
  47334. * @returns {Number} Visual row index.
  47335. */
  47336. }, {
  47337. key: 'onUnmodifyRow',
  47338. value: function onUnmodifyRow(row) {
  47339. var indexInMapper = this.rowsMapper.getIndexByValue(row);
  47340. return indexInMapper === null ? row : indexInMapper;
  47341. }
  47342. /**
  47343. * `afterPluginsInitialized` hook callback.
  47344. *
  47345. * @private
  47346. */
  47347. }, {
  47348. key: 'onAfterPluginsInitialized',
  47349. value: function onAfterPluginsInitialized() {
  47350. this.updateRowsMapper();
  47351. this.initialSettings();
  47352. this.backlight.build();
  47353. this.guideline.build();
  47354. }
  47355. /**
  47356. * Destroy plugin instance.
  47357. */
  47358. }, {
  47359. key: 'destroy',
  47360. value: function destroy() {
  47361. this.backlight.destroy();
  47362. this.guideline.destroy();
  47363. _get(ManualRowMove.prototype.__proto__ || Object.getPrototypeOf(ManualRowMove.prototype), 'destroy', this).call(this);
  47364. }
  47365. }]);
  47366. return ManualRowMove;
  47367. }(_base2.default);
  47368. (0, _plugins.registerPlugin)('ManualRowMove', ManualRowMove);
  47369. exports.default = ManualRowMove;
  47370. /***/ }),
  47371. /* 461 */
  47372. /***/ (function(module, exports, __webpack_require__) {
  47373. "use strict";
  47374. exports.__esModule = true;
  47375. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  47376. var _arrayMapper = __webpack_require__(321);
  47377. var _arrayMapper2 = _interopRequireDefault(_arrayMapper);
  47378. var _array = __webpack_require__(1);
  47379. var _object = __webpack_require__(2);
  47380. var _number = __webpack_require__(5);
  47381. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  47382. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  47383. /**
  47384. * @class RowsMapper
  47385. * @plugin ManualRowMove
  47386. */
  47387. var RowsMapper = function () {
  47388. function RowsMapper(manualRowMove) {
  47389. _classCallCheck(this, RowsMapper);
  47390. /**
  47391. * Instance of ManualRowMove plugin.
  47392. *
  47393. * @type {ManualRowMove}
  47394. */
  47395. this.manualRowMove = manualRowMove;
  47396. }
  47397. /**
  47398. * Reset current map array and create new one.
  47399. *
  47400. * @param {Number} [length] Custom generated map length.
  47401. */
  47402. _createClass(RowsMapper, [{
  47403. key: 'createMap',
  47404. value: function createMap(length) {
  47405. var _this = this;
  47406. var originLength = length === void 0 ? this._arrayMap.length : length;
  47407. this._arrayMap.length = 0;
  47408. (0, _number.rangeEach)(originLength - 1, function (itemIndex) {
  47409. _this._arrayMap[itemIndex] = itemIndex;
  47410. });
  47411. }
  47412. /**
  47413. * Destroy class.
  47414. */
  47415. }, {
  47416. key: 'destroy',
  47417. value: function destroy() {
  47418. this._arrayMap = null;
  47419. }
  47420. /**
  47421. *
  47422. * Moving elements in rowsMapper.
  47423. * @param {Number} from Row index to move.
  47424. * @param {Number} to Target index.
  47425. */
  47426. }, {
  47427. key: 'moveRow',
  47428. value: function moveRow(from, to) {
  47429. var indexToMove = this._arrayMap[from];
  47430. this._arrayMap[from] = null;
  47431. this._arrayMap.splice(to, 0, indexToMove);
  47432. }
  47433. /**
  47434. * Clearing arrayMap from `null` entries.
  47435. */
  47436. }, {
  47437. key: 'clearNull',
  47438. value: function clearNull() {
  47439. this._arrayMap = (0, _array.arrayFilter)(this._arrayMap, function (i) {
  47440. return i !== null;
  47441. });
  47442. }
  47443. }]);
  47444. return RowsMapper;
  47445. }();
  47446. (0, _object.mixin)(RowsMapper, _arrayMapper2.default);
  47447. exports.default = RowsMapper;
  47448. /***/ }),
  47449. /* 462 */
  47450. /***/ (function(module, exports, __webpack_require__) {
  47451. "use strict";
  47452. exports.__esModule = true;
  47453. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  47454. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  47455. var _base = __webpack_require__(323);
  47456. var _base2 = _interopRequireDefault(_base);
  47457. var _element = __webpack_require__(0);
  47458. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  47459. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  47460. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  47461. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  47462. var CSS_CLASSNAME = 'ht__manualRowMove--backlight';
  47463. /**
  47464. * @class BacklightUI
  47465. * @util
  47466. */
  47467. var BacklightUI = function (_BaseUI) {
  47468. _inherits(BacklightUI, _BaseUI);
  47469. function BacklightUI() {
  47470. _classCallCheck(this, BacklightUI);
  47471. return _possibleConstructorReturn(this, (BacklightUI.__proto__ || Object.getPrototypeOf(BacklightUI)).apply(this, arguments));
  47472. }
  47473. _createClass(BacklightUI, [{
  47474. key: 'build',
  47475. /**
  47476. * Custom className on build process.
  47477. */
  47478. value: function build() {
  47479. _get(BacklightUI.prototype.__proto__ || Object.getPrototypeOf(BacklightUI.prototype), 'build', this).call(this);
  47480. (0, _element.addClass)(this._element, CSS_CLASSNAME);
  47481. }
  47482. }]);
  47483. return BacklightUI;
  47484. }(_base2.default);
  47485. exports.default = BacklightUI;
  47486. /***/ }),
  47487. /* 463 */
  47488. /***/ (function(module, exports, __webpack_require__) {
  47489. "use strict";
  47490. exports.__esModule = true;
  47491. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  47492. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  47493. var _base = __webpack_require__(323);
  47494. var _base2 = _interopRequireDefault(_base);
  47495. var _element = __webpack_require__(0);
  47496. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  47497. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  47498. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  47499. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  47500. var CSS_CLASSNAME = 'ht__manualRowMove--guideline';
  47501. /**
  47502. * @class GuidelineUI
  47503. * @util
  47504. */
  47505. var GuidelineUI = function (_BaseUI) {
  47506. _inherits(GuidelineUI, _BaseUI);
  47507. function GuidelineUI() {
  47508. _classCallCheck(this, GuidelineUI);
  47509. return _possibleConstructorReturn(this, (GuidelineUI.__proto__ || Object.getPrototypeOf(GuidelineUI)).apply(this, arguments));
  47510. }
  47511. _createClass(GuidelineUI, [{
  47512. key: 'build',
  47513. /**
  47514. * Custom className on build process.
  47515. */
  47516. value: function build() {
  47517. _get(GuidelineUI.prototype.__proto__ || Object.getPrototypeOf(GuidelineUI.prototype), 'build', this).call(this);
  47518. (0, _element.addClass)(this._element, CSS_CLASSNAME);
  47519. }
  47520. }]);
  47521. return GuidelineUI;
  47522. }(_base2.default);
  47523. exports.default = GuidelineUI;
  47524. /***/ }),
  47525. /* 464 */
  47526. /***/ (function(module, exports) {
  47527. // removed by extract-text-webpack-plugin
  47528. /***/ }),
  47529. /* 465 */
  47530. /***/ (function(module, exports, __webpack_require__) {
  47531. "use strict";
  47532. exports.__esModule = true;
  47533. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  47534. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  47535. var _base = __webpack_require__(10);
  47536. var _base2 = _interopRequireDefault(_base);
  47537. var _element = __webpack_require__(0);
  47538. var _eventManager = __webpack_require__(6);
  47539. var _eventManager2 = _interopRequireDefault(_eventManager);
  47540. var _event = __webpack_require__(12);
  47541. var _array = __webpack_require__(1);
  47542. var _number = __webpack_require__(5);
  47543. var _plugins = __webpack_require__(8);
  47544. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  47545. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  47546. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  47547. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  47548. // Developer note! Whenever you make a change in this file, make an analogous change in manualRowResize.js
  47549. /**
  47550. * @description
  47551. * ManualRowResize Plugin.
  47552. *
  47553. * Has 2 UI components:
  47554. * - handle - the draggable element that sets the desired height of the row.
  47555. * - guide - the helper guide that shows the desired height as a horizontal guide.
  47556. *
  47557. * @plugin ManualRowResize
  47558. */
  47559. var ManualRowResize = function (_BasePlugin) {
  47560. _inherits(ManualRowResize, _BasePlugin);
  47561. function ManualRowResize(hotInstance) {
  47562. _classCallCheck(this, ManualRowResize);
  47563. var _this = _possibleConstructorReturn(this, (ManualRowResize.__proto__ || Object.getPrototypeOf(ManualRowResize)).call(this, hotInstance));
  47564. _this.currentTH = null;
  47565. _this.currentRow = null;
  47566. _this.selectedRows = [];
  47567. _this.currentHeight = null;
  47568. _this.newSize = null;
  47569. _this.startY = null;
  47570. _this.startHeight = null;
  47571. _this.startOffset = null;
  47572. _this.handle = document.createElement('DIV');
  47573. _this.guide = document.createElement('DIV');
  47574. _this.eventManager = new _eventManager2.default(_this);
  47575. _this.pressed = null;
  47576. _this.dblclick = 0;
  47577. _this.autoresizeTimeout = null;
  47578. _this.manualRowHeights = [];
  47579. (0, _element.addClass)(_this.handle, 'manualRowResizer');
  47580. (0, _element.addClass)(_this.guide, 'manualRowResizerGuide');
  47581. return _this;
  47582. }
  47583. /**
  47584. * Check if the plugin is enabled in the handsontable settings.
  47585. *
  47586. * @returns {Boolean}
  47587. */
  47588. _createClass(ManualRowResize, [{
  47589. key: 'isEnabled',
  47590. value: function isEnabled() {
  47591. return this.hot.getSettings().manualRowResize;
  47592. }
  47593. /**
  47594. * Enable plugin for this Handsontable instance.
  47595. */
  47596. }, {
  47597. key: 'enablePlugin',
  47598. value: function enablePlugin() {
  47599. var _this2 = this;
  47600. if (this.enabled) {
  47601. return;
  47602. }
  47603. this.manualRowHeights = [];
  47604. var initialRowHeights = this.hot.getSettings().manualRowResize;
  47605. var loadedManualRowHeights = this.loadManualRowHeights();
  47606. if (typeof loadedManualRowHeights != 'undefined') {
  47607. this.manualRowHeights = loadedManualRowHeights;
  47608. } else if (Array.isArray(initialRowHeights)) {
  47609. this.manualRowHeights = initialRowHeights;
  47610. } else {
  47611. this.manualRowHeights = [];
  47612. }
  47613. this.addHook('modifyRowHeight', function (height, row) {
  47614. return _this2.onModifyRowHeight(height, row);
  47615. });
  47616. // Handsontable.hooks.register('beforeRowResize');
  47617. // Handsontable.hooks.register('afterRowResize');
  47618. this.bindEvents();
  47619. _get(ManualRowResize.prototype.__proto__ || Object.getPrototypeOf(ManualRowResize.prototype), 'enablePlugin', this).call(this);
  47620. }
  47621. /**
  47622. * Updates the plugin to use the latest options you have specified.
  47623. */
  47624. }, {
  47625. key: 'updatePlugin',
  47626. value: function updatePlugin() {
  47627. var initialRowHeights = this.hot.getSettings().manualRowResize;
  47628. if (Array.isArray(initialRowHeights)) {
  47629. this.manualRowHeights = initialRowHeights;
  47630. } else if (!initialRowHeights) {
  47631. this.manualRowHeights = [];
  47632. }
  47633. }
  47634. /**
  47635. * Disable plugin for this Handsontable instance.
  47636. */
  47637. }, {
  47638. key: 'disablePlugin',
  47639. value: function disablePlugin() {
  47640. _get(ManualRowResize.prototype.__proto__ || Object.getPrototypeOf(ManualRowResize.prototype), 'disablePlugin', this).call(this);
  47641. }
  47642. /**
  47643. * Save the current sizes using the persistentState plugin.
  47644. */
  47645. }, {
  47646. key: 'saveManualRowHeights',
  47647. value: function saveManualRowHeights() {
  47648. this.hot.runHooks('persistentStateSave', 'manualRowHeights', this.manualRowHeights);
  47649. }
  47650. /**
  47651. * Load the previously saved sizes using the persistentState plugin.
  47652. *
  47653. * @returns {Array}
  47654. */
  47655. }, {
  47656. key: 'loadManualRowHeights',
  47657. value: function loadManualRowHeights() {
  47658. var storedState = {};
  47659. this.hot.runHooks('persistentStateLoad', 'manualRowHeights', storedState);
  47660. return storedState.value;
  47661. }
  47662. /**
  47663. * Set the resize handle position.
  47664. *
  47665. * @param {HTMLCellElement} TH TH HTML element.
  47666. */
  47667. }, {
  47668. key: 'setupHandlePosition',
  47669. value: function setupHandlePosition(TH) {
  47670. var _this3 = this;
  47671. this.currentTH = TH;
  47672. var row = this.hot.view.wt.wtTable.getCoords(TH).row; // getCoords returns CellCoords
  47673. var headerWidth = (0, _element.outerWidth)(this.currentTH);
  47674. if (row >= 0) {
  47675. // if not col header
  47676. var box = this.currentTH.getBoundingClientRect();
  47677. this.currentRow = row;
  47678. this.selectedRows = [];
  47679. if (this.hot.selection.isSelected() && this.hot.selection.isSelectedByRowHeader()) {
  47680. var _hot$getSelectedRange = this.hot.getSelectedRangeLast(),
  47681. from = _hot$getSelectedRange.from,
  47682. to = _hot$getSelectedRange.to;
  47683. var start = from.row;
  47684. var end = to.row;
  47685. if (start >= end) {
  47686. start = to.row;
  47687. end = from.row;
  47688. }
  47689. if (this.currentRow >= start && this.currentRow <= end) {
  47690. (0, _number.rangeEach)(start, end, function (i) {
  47691. return _this3.selectedRows.push(i);
  47692. });
  47693. } else {
  47694. this.selectedRows.push(this.currentRow);
  47695. }
  47696. } else {
  47697. this.selectedRows.push(this.currentRow);
  47698. }
  47699. this.startOffset = box.top - 6;
  47700. this.startHeight = parseInt(box.height, 10);
  47701. this.handle.style.left = box.left + 'px';
  47702. this.handle.style.top = this.startOffset + this.startHeight + 'px';
  47703. this.handle.style.width = headerWidth + 'px';
  47704. this.hot.rootElement.appendChild(this.handle);
  47705. }
  47706. }
  47707. /**
  47708. * Refresh the resize handle position.
  47709. */
  47710. }, {
  47711. key: 'refreshHandlePosition',
  47712. value: function refreshHandlePosition() {
  47713. this.handle.style.top = this.startOffset + this.currentHeight + 'px';
  47714. }
  47715. /**
  47716. * Set the resize guide position.
  47717. */
  47718. }, {
  47719. key: 'setupGuidePosition',
  47720. value: function setupGuidePosition() {
  47721. var handleWidth = parseInt((0, _element.outerWidth)(this.handle), 10);
  47722. var handleRightPosition = parseInt(this.handle.style.left, 10) + handleWidth;
  47723. var maximumVisibleElementWidth = parseInt(this.hot.view.maximumVisibleElementWidth(0), 10);
  47724. (0, _element.addClass)(this.handle, 'active');
  47725. (0, _element.addClass)(this.guide, 'active');
  47726. this.guide.style.top = this.handle.style.top;
  47727. this.guide.style.left = handleRightPosition + 'px';
  47728. this.guide.style.width = maximumVisibleElementWidth - handleWidth + 'px';
  47729. this.hot.rootElement.appendChild(this.guide);
  47730. }
  47731. /**
  47732. * Refresh the resize guide position.
  47733. */
  47734. }, {
  47735. key: 'refreshGuidePosition',
  47736. value: function refreshGuidePosition() {
  47737. this.guide.style.top = this.handle.style.top;
  47738. }
  47739. /**
  47740. * Hide both the resize handle and resize guide.
  47741. */
  47742. }, {
  47743. key: 'hideHandleAndGuide',
  47744. value: function hideHandleAndGuide() {
  47745. (0, _element.removeClass)(this.handle, 'active');
  47746. (0, _element.removeClass)(this.guide, 'active');
  47747. }
  47748. /**
  47749. * Check if provided element is considered as a row header.
  47750. *
  47751. * @param {HTMLElement} element HTML element.
  47752. * @returns {Boolean}
  47753. */
  47754. }, {
  47755. key: 'checkIfRowHeader',
  47756. value: function checkIfRowHeader(element) {
  47757. if (element != this.hot.rootElement) {
  47758. var parent = element.parentNode;
  47759. if (parent.tagName === 'TBODY') {
  47760. return true;
  47761. }
  47762. return this.checkIfRowHeader(parent);
  47763. }
  47764. return false;
  47765. }
  47766. /**
  47767. * Get the TH element from the provided element.
  47768. *
  47769. * @param {HTMLElement} element HTML element.
  47770. * @returns {HTMLElement}
  47771. */
  47772. }, {
  47773. key: 'getTHFromTargetElement',
  47774. value: function getTHFromTargetElement(element) {
  47775. if (element.tagName != 'TABLE') {
  47776. if (element.tagName == 'TH') {
  47777. return element;
  47778. }
  47779. return this.getTHFromTargetElement(element.parentNode);
  47780. }
  47781. return null;
  47782. }
  47783. /**
  47784. * 'mouseover' event callback - set the handle position.
  47785. *
  47786. * @private
  47787. * @param {MouseEvent} event
  47788. */
  47789. }, {
  47790. key: 'onMouseOver',
  47791. value: function onMouseOver(event) {
  47792. if (this.checkIfRowHeader(event.target)) {
  47793. var th = this.getTHFromTargetElement(event.target);
  47794. if (th) {
  47795. if (!this.pressed) {
  47796. this.setupHandlePosition(th);
  47797. }
  47798. }
  47799. }
  47800. }
  47801. /**
  47802. * Auto-size row after doubleclick - callback.
  47803. *
  47804. * @private
  47805. */
  47806. }, {
  47807. key: 'afterMouseDownTimeout',
  47808. value: function afterMouseDownTimeout() {
  47809. var _this4 = this;
  47810. var render = function render() {
  47811. _this4.hot.forceFullRender = true;
  47812. _this4.hot.view.render(); // updates all
  47813. _this4.hot.view.wt.wtOverlays.adjustElementsSize(true);
  47814. };
  47815. var resize = function resize(selectedRow, forceRender) {
  47816. var hookNewSize = _this4.hot.runHooks('beforeRowResize', selectedRow, _this4.newSize, true);
  47817. if (hookNewSize !== void 0) {
  47818. _this4.newSize = hookNewSize;
  47819. }
  47820. _this4.setManualSize(selectedRow, _this4.newSize); // double click sets auto row size
  47821. if (forceRender) {
  47822. render();
  47823. }
  47824. _this4.hot.runHooks('afterRowResize', selectedRow, _this4.newSize, true);
  47825. };
  47826. if (this.dblclick >= 2) {
  47827. var selectedRowsLength = this.selectedRows.length;
  47828. if (selectedRowsLength > 1) {
  47829. (0, _array.arrayEach)(this.selectedRows, function (selectedRow) {
  47830. resize(selectedRow);
  47831. });
  47832. render();
  47833. } else {
  47834. (0, _array.arrayEach)(this.selectedRows, function (selectedRow) {
  47835. resize(selectedRow, true);
  47836. });
  47837. }
  47838. }
  47839. this.dblclick = 0;
  47840. this.autoresizeTimeout = null;
  47841. }
  47842. /**
  47843. * 'mousedown' event callback.
  47844. *
  47845. * @private
  47846. * @param {MouseEvent} event
  47847. */
  47848. }, {
  47849. key: 'onMouseDown',
  47850. value: function onMouseDown(event) {
  47851. var _this5 = this;
  47852. if ((0, _element.hasClass)(event.target, 'manualRowResizer')) {
  47853. this.setupGuidePosition();
  47854. this.pressed = this.hot;
  47855. if (this.autoresizeTimeout == null) {
  47856. this.autoresizeTimeout = setTimeout(function () {
  47857. return _this5.afterMouseDownTimeout();
  47858. }, 500);
  47859. this.hot._registerTimeout(this.autoresizeTimeout);
  47860. }
  47861. this.dblclick++;
  47862. this.startY = (0, _event.pageY)(event);
  47863. this.newSize = this.startHeight;
  47864. }
  47865. }
  47866. /**
  47867. * 'mousemove' event callback - refresh the handle and guide positions, cache the new row height.
  47868. *
  47869. * @private
  47870. * @param {MouseEvent} event
  47871. */
  47872. }, {
  47873. key: 'onMouseMove',
  47874. value: function onMouseMove(event) {
  47875. var _this6 = this;
  47876. if (this.pressed) {
  47877. this.currentHeight = this.startHeight + ((0, _event.pageY)(event) - this.startY);
  47878. (0, _array.arrayEach)(this.selectedRows, function (selectedRow) {
  47879. _this6.newSize = _this6.setManualSize(selectedRow, _this6.currentHeight);
  47880. });
  47881. this.refreshHandlePosition();
  47882. this.refreshGuidePosition();
  47883. }
  47884. }
  47885. /**
  47886. * 'mouseup' event callback - apply the row resizing.
  47887. *
  47888. * @private
  47889. * @param {MouseEvent} event
  47890. */
  47891. }, {
  47892. key: 'onMouseUp',
  47893. value: function onMouseUp(event) {
  47894. var _this7 = this;
  47895. var render = function render() {
  47896. _this7.hot.forceFullRender = true;
  47897. _this7.hot.view.render(); // updates all
  47898. _this7.hot.view.wt.wtOverlays.adjustElementsSize(true);
  47899. };
  47900. var runHooks = function runHooks(selectedRow, forceRender) {
  47901. _this7.hot.runHooks('beforeRowResize', selectedRow, _this7.newSize);
  47902. if (forceRender) {
  47903. render();
  47904. }
  47905. _this7.saveManualRowHeights();
  47906. _this7.hot.runHooks('afterRowResize', selectedRow, _this7.newSize);
  47907. };
  47908. if (this.pressed) {
  47909. this.hideHandleAndGuide();
  47910. this.pressed = false;
  47911. if (this.newSize != this.startHeight) {
  47912. var selectedRowsLength = this.selectedRows.length;
  47913. if (selectedRowsLength > 1) {
  47914. (0, _array.arrayEach)(this.selectedRows, function (selectedRow) {
  47915. runHooks(selectedRow);
  47916. });
  47917. render();
  47918. } else {
  47919. (0, _array.arrayEach)(this.selectedRows, function (selectedRow) {
  47920. runHooks(selectedRow, true);
  47921. });
  47922. }
  47923. }
  47924. this.setupHandlePosition(this.currentTH);
  47925. }
  47926. }
  47927. /**
  47928. * Bind the mouse events.
  47929. *
  47930. * @private
  47931. */
  47932. }, {
  47933. key: 'bindEvents',
  47934. value: function bindEvents() {
  47935. var _this8 = this;
  47936. this.eventManager.addEventListener(this.hot.rootElement, 'mouseover', function (e) {
  47937. return _this8.onMouseOver(e);
  47938. });
  47939. this.eventManager.addEventListener(this.hot.rootElement, 'mousedown', function (e) {
  47940. return _this8.onMouseDown(e);
  47941. });
  47942. this.eventManager.addEventListener(window, 'mousemove', function (e) {
  47943. return _this8.onMouseMove(e);
  47944. });
  47945. this.eventManager.addEventListener(window, 'mouseup', function (e) {
  47946. return _this8.onMouseUp(e);
  47947. });
  47948. }
  47949. /**
  47950. * Cache the current row height.
  47951. *
  47952. * @param {Number} row Visual row index.
  47953. * @param {Number} height Row height.
  47954. * @returns {Number}
  47955. */
  47956. }, {
  47957. key: 'setManualSize',
  47958. value: function setManualSize(row, height) {
  47959. row = this.hot.runHooks('modifyRow', row);
  47960. this.manualRowHeights[row] = height;
  47961. return height;
  47962. }
  47963. /**
  47964. * Modify the provided row height, based on the plugin settings.
  47965. *
  47966. * @private
  47967. * @param {Number} height Row height.
  47968. * @param {Number} row Visual row index.
  47969. * @returns {Number}
  47970. */
  47971. }, {
  47972. key: 'onModifyRowHeight',
  47973. value: function onModifyRowHeight(height, row) {
  47974. if (this.enabled) {
  47975. var autoRowSizePlugin = this.hot.getPlugin('autoRowSize');
  47976. var autoRowHeightResult = autoRowSizePlugin ? autoRowSizePlugin.heights[row] : null;
  47977. row = this.hot.runHooks('modifyRow', row);
  47978. var manualRowHeight = this.manualRowHeights[row];
  47979. if (manualRowHeight !== void 0 && (manualRowHeight === autoRowHeightResult || manualRowHeight > (height || 0))) {
  47980. return manualRowHeight;
  47981. }
  47982. }
  47983. return height;
  47984. }
  47985. }]);
  47986. return ManualRowResize;
  47987. }(_base2.default);
  47988. (0, _plugins.registerPlugin)('manualRowResize', ManualRowResize);
  47989. exports.default = ManualRowResize;
  47990. /***/ }),
  47991. /* 466 */
  47992. /***/ (function(module, exports, __webpack_require__) {
  47993. "use strict";
  47994. exports.__esModule = true;
  47995. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  47996. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  47997. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  47998. var _base = __webpack_require__(10);
  47999. var _base2 = _interopRequireDefault(_base);
  48000. var _pluginHooks = __webpack_require__(15);
  48001. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  48002. var _plugins = __webpack_require__(8);
  48003. var _event = __webpack_require__(12);
  48004. var _src = __webpack_require__(4);
  48005. var _cellsCollection = __webpack_require__(467);
  48006. var _cellsCollection2 = _interopRequireDefault(_cellsCollection);
  48007. var _cellCoords = __webpack_require__(95);
  48008. var _cellCoords2 = _interopRequireDefault(_cellCoords);
  48009. var _autofill = __webpack_require__(468);
  48010. var _autofill2 = _interopRequireDefault(_autofill);
  48011. var _selection = __webpack_require__(469);
  48012. var _selection2 = _interopRequireDefault(_selection);
  48013. var _toggleMerge = __webpack_require__(470);
  48014. var _toggleMerge2 = _interopRequireDefault(_toggleMerge);
  48015. var _array = __webpack_require__(1);
  48016. var _object = __webpack_require__(2);
  48017. var _console = __webpack_require__(56);
  48018. var _number = __webpack_require__(5);
  48019. var _utils = __webpack_require__(324);
  48020. __webpack_require__(471);
  48021. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  48022. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  48023. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  48024. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  48025. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  48026. _pluginHooks2.default.getSingleton().register('beforeMergeCells');
  48027. _pluginHooks2.default.getSingleton().register('afterMergeCells');
  48028. _pluginHooks2.default.getSingleton().register('beforeUnmergeCells');
  48029. _pluginHooks2.default.getSingleton().register('afterUnmergeCells');
  48030. var privatePool = new WeakMap();
  48031. /**
  48032. * @plugin MergeCells
  48033. *
  48034. * @description Plugin, which allows merging cells in the table (using the initial configuration, API or context menu).
  48035. *
  48036. * @example
  48037. *
  48038. * ```js
  48039. * ...
  48040. * let hot = new Handsontable(document.getElementById('example'), {
  48041. * data: getData(),
  48042. * mergeCells: [
  48043. * {row: 0, col: 3, rowspan: 3, colspan: 3},
  48044. * {row: 2, col: 6, rowspan: 2, colspan: 2},
  48045. * {row: 4, col: 8, rowspan: 3, colspan: 3}
  48046. * ],
  48047. * ...
  48048. * ```
  48049. */
  48050. var MergeCells = function (_BasePlugin) {
  48051. _inherits(MergeCells, _BasePlugin);
  48052. function MergeCells(hotInstance) {
  48053. _classCallCheck(this, MergeCells);
  48054. var _this = _possibleConstructorReturn(this, (MergeCells.__proto__ || Object.getPrototypeOf(MergeCells)).call(this, hotInstance));
  48055. privatePool.set(_this, {
  48056. lastDesiredCoords: null
  48057. });
  48058. /**
  48059. * A container for all the merged cells.
  48060. *
  48061. * @type {MergedCellsCollection}
  48062. */
  48063. _this.mergedCellsCollection = null;
  48064. /**
  48065. * Instance of the class responsible for all the autofill-related calculations.
  48066. *
  48067. * @private
  48068. * @type {AutofillCalculations}
  48069. */
  48070. _this.autofillCalculations = null;
  48071. /**
  48072. * Instance of the class responsible for the selection-related calculations.
  48073. *
  48074. * @private
  48075. * @type {SelectionCalculations}
  48076. */
  48077. _this.selectionCalculations = null;
  48078. return _this;
  48079. }
  48080. /**
  48081. * Check if the plugin is enabled in the Handsontable settings.
  48082. *
  48083. * @returns {Boolean}
  48084. */
  48085. _createClass(MergeCells, [{
  48086. key: 'isEnabled',
  48087. value: function isEnabled() {
  48088. return !!this.hot.getSettings().mergeCells;
  48089. }
  48090. /**
  48091. * Enable the plugin.
  48092. */
  48093. }, {
  48094. key: 'enablePlugin',
  48095. value: function enablePlugin() {
  48096. var _this2 = this;
  48097. if (this.enabled) {
  48098. return;
  48099. }
  48100. this.mergedCellsCollection = new _cellsCollection2.default(this);
  48101. this.autofillCalculations = new _autofill2.default(this);
  48102. this.selectionCalculations = new _selection2.default(this);
  48103. this.addHook('afterInit', function () {
  48104. return _this2.onAfterInit.apply(_this2, arguments);
  48105. });
  48106. this.addHook('beforeKeyDown', function () {
  48107. return _this2.onBeforeKeyDown.apply(_this2, arguments);
  48108. });
  48109. this.addHook('modifyTransformStart', function () {
  48110. return _this2.onModifyTransformStart.apply(_this2, arguments);
  48111. });
  48112. this.addHook('afterModifyTransformStart', function () {
  48113. return _this2.onAfterModifyTransformStart.apply(_this2, arguments);
  48114. });
  48115. this.addHook('modifyTransformEnd', function () {
  48116. return _this2.onModifyTransformEnd.apply(_this2, arguments);
  48117. });
  48118. this.addHook('modifyGetCellCoords', function () {
  48119. return _this2.onModifyGetCellCoords.apply(_this2, arguments);
  48120. });
  48121. this.addHook('beforeSetRangeEnd', function () {
  48122. return _this2.onBeforeSetRangeEnd.apply(_this2, arguments);
  48123. });
  48124. this.addHook('afterIsMultipleSelection', function () {
  48125. return _this2.onAfterIsMultipleSelection.apply(_this2, arguments);
  48126. });
  48127. this.addHook('afterRenderer', function () {
  48128. return _this2.onAfterRenderer.apply(_this2, arguments);
  48129. });
  48130. this.addHook('afterContextMenuDefaultOptions', function () {
  48131. return _this2.addMergeActionsToContextMenu.apply(_this2, arguments);
  48132. });
  48133. this.addHook('afterGetCellMeta', function () {
  48134. return _this2.onAfterGetCellMeta.apply(_this2, arguments);
  48135. });
  48136. this.addHook('afterViewportRowCalculatorOverride', function () {
  48137. return _this2.onAfterViewportRowCalculatorOverride.apply(_this2, arguments);
  48138. });
  48139. this.addHook('afterViewportColumnCalculatorOverride', function () {
  48140. return _this2.onAfterViewportColumnCalculatorOverride.apply(_this2, arguments);
  48141. });
  48142. this.addHook('modifyAutofillRange', function () {
  48143. return _this2.onModifyAutofillRange.apply(_this2, arguments);
  48144. });
  48145. this.addHook('afterCreateCol', function () {
  48146. return _this2.onAfterCreateCol.apply(_this2, arguments);
  48147. });
  48148. this.addHook('afterRemoveCol', function () {
  48149. return _this2.onAfterRemoveCol.apply(_this2, arguments);
  48150. });
  48151. this.addHook('afterCreateRow', function () {
  48152. return _this2.onAfterCreateRow.apply(_this2, arguments);
  48153. });
  48154. this.addHook('afterRemoveRow', function () {
  48155. return _this2.onAfterRemoveRow.apply(_this2, arguments);
  48156. });
  48157. this.addHook('afterChange', function () {
  48158. return _this2.onAfterChange.apply(_this2, arguments);
  48159. });
  48160. this.addHook('beforeDrawBorders', function () {
  48161. return _this2.onBeforeDrawAreaBorders.apply(_this2, arguments);
  48162. });
  48163. this.addHook('afterDrawSelection', function () {
  48164. return _this2.onAfterDrawSelection.apply(_this2, arguments);
  48165. });
  48166. this.addHook('beforeRemoveCellClassNames', function () {
  48167. return _this2.onBeforeRemoveCellClassNames.apply(_this2, arguments);
  48168. });
  48169. _get(MergeCells.prototype.__proto__ || Object.getPrototypeOf(MergeCells.prototype), 'enablePlugin', this).call(this);
  48170. }
  48171. /**
  48172. * Disable the plugin.
  48173. */
  48174. }, {
  48175. key: 'disablePlugin',
  48176. value: function disablePlugin() {
  48177. this.clearCollections();
  48178. this.hot.render();
  48179. _get(MergeCells.prototype.__proto__ || Object.getPrototypeOf(MergeCells.prototype), 'disablePlugin', this).call(this);
  48180. }
  48181. /**
  48182. * Update the plugin (after using the `updateSettings` method)
  48183. */
  48184. }, {
  48185. key: 'updatePlugin',
  48186. value: function updatePlugin() {
  48187. var settings = this.hot.getSettings().mergeCells;
  48188. this.clearCollections();
  48189. this.disablePlugin();
  48190. this.enablePlugin();
  48191. this.generateFromSettings(settings);
  48192. _get(MergeCells.prototype.__proto__ || Object.getPrototypeOf(MergeCells.prototype), 'updatePlugin', this).call(this);
  48193. }
  48194. /**
  48195. * Validate a single setting object, represented by a single merged cell information object.
  48196. *
  48197. * @private
  48198. * @param {Object} setting An object with `row`, `col`, `rowspan` and `colspan` properties.
  48199. * @return {Boolean}
  48200. */
  48201. }, {
  48202. key: 'validateSetting',
  48203. value: function validateSetting(setting) {
  48204. var valid = true;
  48205. if (!setting) {
  48206. return false;
  48207. }
  48208. if (_cellCoords2.default.containsNegativeValues(setting)) {
  48209. (0, _console.warn)(_cellCoords2.default.NEGATIVE_VALUES_WARNING(setting));
  48210. valid = false;
  48211. } else if (_cellCoords2.default.isOutOfBounds(setting, this.hot.countRows(), this.hot.countCols())) {
  48212. (0, _console.warn)(_cellCoords2.default.IS_OUT_OF_BOUNDS_WARNING(setting));
  48213. valid = false;
  48214. } else if (_cellCoords2.default.isSingleCell(setting)) {
  48215. (0, _console.warn)(_cellCoords2.default.IS_SINGLE_CELL(setting));
  48216. valid = false;
  48217. } else if (_cellCoords2.default.containsZeroSpan(setting)) {
  48218. (0, _console.warn)(_cellCoords2.default.ZERO_SPAN_WARNING(setting));
  48219. valid = false;
  48220. }
  48221. return valid;
  48222. }
  48223. /**
  48224. * Generate the merged cells from the settings provided to the plugin.
  48225. *
  48226. * @private
  48227. * @param {Array|Boolean} settings The settings provided to the plugin.
  48228. */
  48229. }, {
  48230. key: 'generateFromSettings',
  48231. value: function generateFromSettings(settings) {
  48232. var _this3 = this;
  48233. if (Array.isArray(settings)) {
  48234. var _hot;
  48235. var populationArgumentsList = [];
  48236. (0, _array.arrayEach)(settings, function (setting) {
  48237. if (!_this3.validateSetting(setting)) {
  48238. return;
  48239. }
  48240. var highlight = new _src.CellCoords(setting.row, setting.col);
  48241. var rangeEnd = new _src.CellCoords(setting.row + setting.rowspan - 1, setting.col + setting.colspan - 1);
  48242. var mergeRange = new _src.CellRange(highlight, highlight, rangeEnd);
  48243. populationArgumentsList.push(_this3.mergeRange(mergeRange, true, true));
  48244. });
  48245. // remove 'empty' setting objects, caused by improper merge range declarations
  48246. populationArgumentsList = populationArgumentsList.filter(function (value) {
  48247. return value !== true;
  48248. });
  48249. var bulkPopulationData = this.getBulkCollectionData(populationArgumentsList);
  48250. (_hot = this.hot).populateFromArray.apply(_hot, _toConsumableArray(bulkPopulationData));
  48251. }
  48252. }
  48253. /**
  48254. * Generates a bulk set of all the data to be populated to fill the data "under" the added merged cells.
  48255. *
  48256. * @private
  48257. * @param {Array} populationArgumentsList Array in a form of `[row, column, dataUnderCollection]`.
  48258. * @return {Array} Array in a form of `[row, column, dataOfAllCollections]`.
  48259. */
  48260. }, {
  48261. key: 'getBulkCollectionData',
  48262. value: function getBulkCollectionData(populationArgumentsList) {
  48263. var _hot2;
  48264. var populationDataRange = this.getBulkCollectionDataRange(populationArgumentsList);
  48265. var dataAtRange = (_hot2 = this.hot).getData.apply(_hot2, _toConsumableArray(populationDataRange));
  48266. var newDataAtRange = dataAtRange.splice(0);
  48267. (0, _array.arrayEach)(populationArgumentsList, function (mergedCellArguments) {
  48268. var _mergedCellArguments = _slicedToArray(mergedCellArguments, 3),
  48269. mergedCellRowIndex = _mergedCellArguments[0],
  48270. mergedCellColumnIndex = _mergedCellArguments[1],
  48271. mergedCellData = _mergedCellArguments[2];
  48272. (0, _array.arrayEach)(mergedCellData, function (mergedCellRow, rowIndex) {
  48273. (0, _array.arrayEach)(mergedCellRow, function (mergedCellElement, columnIndex) {
  48274. newDataAtRange[mergedCellRowIndex - populationDataRange[0] + rowIndex][mergedCellColumnIndex - populationDataRange[1] + columnIndex] = mergedCellElement;
  48275. });
  48276. });
  48277. });
  48278. return [populationDataRange[0], populationDataRange[1], newDataAtRange];
  48279. }
  48280. /**
  48281. * Get the range of combined data ranges provided in a form of an array of arrays ([row, column, dataUnderCollection])
  48282. *
  48283. * @private
  48284. * @param {Array} populationArgumentsList Array containing argument lists for the `populateFromArray` method - row, column and data for population.
  48285. * @return {Array[]} Start and end coordinates of the merged cell range. (in a form of [rowIndex, columnIndex])
  48286. */
  48287. }, {
  48288. key: 'getBulkCollectionDataRange',
  48289. value: function getBulkCollectionDataRange(populationArgumentsList) {
  48290. var start = [0, 0];
  48291. var end = [0, 0];
  48292. var mergedCellRow = null;
  48293. var mergedCellColumn = null;
  48294. var mergedCellData = null;
  48295. (0, _array.arrayEach)(populationArgumentsList, function (mergedCellArguments) {
  48296. mergedCellRow = mergedCellArguments[0];
  48297. mergedCellColumn = mergedCellArguments[1];
  48298. mergedCellData = mergedCellArguments[2];
  48299. start[0] = Math.min(mergedCellRow, start[0]);
  48300. start[1] = Math.min(mergedCellColumn, start[1]);
  48301. end[0] = Math.max(mergedCellRow + mergedCellData.length - 1, end[0]);
  48302. end[1] = Math.max(mergedCellColumn + mergedCellData[0].length - 1, end[1]);
  48303. });
  48304. return [].concat(start, end);
  48305. }
  48306. /**
  48307. * Clear the merged cells from the merged cell container.
  48308. */
  48309. }, {
  48310. key: 'clearCollections',
  48311. value: function clearCollections() {
  48312. this.mergedCellsCollection.clear();
  48313. }
  48314. /**
  48315. * Returns `true` if a range is mergeable.
  48316. *
  48317. * @private
  48318. * @param {Object} newMergedCellInfo Merged cell information object to test.
  48319. * @param {Boolean} [auto=false] `true` if triggered at initialization.
  48320. * @returns {Boolean}
  48321. */
  48322. }, {
  48323. key: 'canMergeRange',
  48324. value: function canMergeRange(newMergedCellInfo) {
  48325. var auto = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  48326. return auto ? true : this.validateSetting(newMergedCellInfo);
  48327. }
  48328. /**
  48329. * Merge or unmerge, based on last selected range.
  48330. *
  48331. * @private
  48332. */
  48333. }, {
  48334. key: 'toggleMergeOnSelection',
  48335. value: function toggleMergeOnSelection() {
  48336. var currentRange = this.hot.getSelectedRangeLast();
  48337. if (!currentRange) {
  48338. return;
  48339. }
  48340. currentRange.setDirection('NW-SE');
  48341. var from = currentRange.from,
  48342. to = currentRange.to;
  48343. this.toggleMerge(currentRange);
  48344. this.hot.selectCell(from.row, from.col, to.row, to.col, false);
  48345. }
  48346. /**
  48347. * Merge the selection provided as a cell range.
  48348. *
  48349. * @param {CellRange} [cellRange] Selection cell range.
  48350. */
  48351. }, {
  48352. key: 'mergeSelection',
  48353. value: function mergeSelection() {
  48354. var cellRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.hot.getSelectedRangeLast();
  48355. if (!cellRange) {
  48356. return;
  48357. }
  48358. cellRange.setDirection('NW-SE');
  48359. var from = cellRange.from,
  48360. to = cellRange.to;
  48361. this.unmergeRange(cellRange, true);
  48362. this.mergeRange(cellRange);
  48363. this.hot.selectCell(from.row, from.col, to.row, to.col, false);
  48364. }
  48365. /**
  48366. * Unmerge the selection provided as a cell range.
  48367. *
  48368. * @param {CellRange} [cellRange] Selection cell range.
  48369. */
  48370. }, {
  48371. key: 'unmergeSelection',
  48372. value: function unmergeSelection() {
  48373. var cellRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.hot.getSelectedRangeLast();
  48374. if (!cellRange) {
  48375. return;
  48376. }
  48377. var from = cellRange.from,
  48378. to = cellRange.to;
  48379. this.unmergeRange(cellRange, true);
  48380. this.hot.selectCell(from.row, from.col, to.row, to.col, false);
  48381. }
  48382. /**
  48383. * Merge cells in the provided cell range.
  48384. *
  48385. * @private
  48386. * @param {CellRange} cellRange Cell range to merge.
  48387. * @param {Boolean} [auto=false] `true` if is called automatically, e.g. at initialization.
  48388. * @param {Boolean} [preventPopulation=false] `true`, if the method should not run `populateFromArray` at the end, but rather return its arguments.
  48389. * @returns {Array|Boolean} Returns an array of [row, column, dataUnderCollection] if preventPopulation is set to true. If the the merging process went successful, it returns `true`, otherwise - `false`.
  48390. * @fires Hooks#beforeMergeCells
  48391. * @fires Hooks#afterMergeCells
  48392. */
  48393. }, {
  48394. key: 'mergeRange',
  48395. value: function mergeRange(cellRange) {
  48396. var _this4 = this;
  48397. var auto = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  48398. var preventPopulation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  48399. var topLeft = cellRange.getTopLeftCorner();
  48400. var bottomRight = cellRange.getBottomRightCorner();
  48401. var mergeParent = {
  48402. row: topLeft.row,
  48403. col: topLeft.col,
  48404. rowspan: bottomRight.row - topLeft.row + 1,
  48405. colspan: bottomRight.col - topLeft.col + 1
  48406. };
  48407. var clearedData = [];
  48408. var populationInfo = null;
  48409. if (!this.canMergeRange(mergeParent, auto)) {
  48410. return false;
  48411. }
  48412. this.hot.runHooks('beforeMergeCells', cellRange, auto);
  48413. (0, _number.rangeEach)(0, mergeParent.rowspan - 1, function (i) {
  48414. (0, _number.rangeEach)(0, mergeParent.colspan - 1, function (j) {
  48415. var clearedValue = null;
  48416. if (!clearedData[i]) {
  48417. clearedData[i] = [];
  48418. }
  48419. if (i === 0 && j === 0) {
  48420. clearedValue = _this4.hot.getDataAtCell(mergeParent.row, mergeParent.col);
  48421. } else {
  48422. _this4.hot.setCellMeta(mergeParent.row + i, mergeParent.col + j, 'hidden', true);
  48423. }
  48424. clearedData[i][j] = clearedValue;
  48425. });
  48426. });
  48427. this.hot.setCellMeta(mergeParent.row, mergeParent.col, 'spanned', true);
  48428. var mergedCellAdded = this.mergedCellsCollection.add(mergeParent);
  48429. if (mergedCellAdded) {
  48430. if (preventPopulation) {
  48431. populationInfo = [mergeParent.row, mergeParent.col, clearedData];
  48432. } else {
  48433. this.hot.populateFromArray(mergeParent.row, mergeParent.col, clearedData, void 0, void 0, this.pluginName);
  48434. }
  48435. this.hot.runHooks('afterMergeCells', cellRange, mergeParent, auto);
  48436. return populationInfo;
  48437. }
  48438. return true;
  48439. }
  48440. /**
  48441. * Unmerge the selection provided as a cell range. If no cell range is provided, it uses the current selection.
  48442. *
  48443. * @private
  48444. * @param {CellRange} cellRange Selection cell range.
  48445. * @param {Boolean} [auto=false] `true` if called automatically by the plugin.
  48446. */
  48447. }, {
  48448. key: 'unmergeRange',
  48449. value: function unmergeRange(cellRange) {
  48450. var _this5 = this;
  48451. var auto = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  48452. var mergedCells = this.mergedCellsCollection.getWithinRange(cellRange);
  48453. if (!mergedCells) {
  48454. return;
  48455. }
  48456. this.hot.runHooks('beforeUnmergeCells', cellRange, auto);
  48457. (0, _array.arrayEach)(mergedCells, function (currentCollection) {
  48458. _this5.mergedCellsCollection.remove(currentCollection.row, currentCollection.col);
  48459. (0, _number.rangeEach)(0, currentCollection.rowspan - 1, function (i) {
  48460. (0, _number.rangeEach)(0, currentCollection.colspan - 1, function (j) {
  48461. _this5.hot.removeCellMeta(currentCollection.row + i, currentCollection.col + j, 'hidden');
  48462. });
  48463. });
  48464. _this5.hot.removeCellMeta(currentCollection.row, currentCollection.col, 'spanned');
  48465. });
  48466. this.hot.render();
  48467. this.hot.runHooks('afterUnmergeCells', cellRange, auto);
  48468. }
  48469. /**
  48470. * Merge or unmerge, based on the cell range provided as `cellRange`.
  48471. *
  48472. * @private
  48473. * @param {CellRange} cellRange The cell range to merge or unmerged.
  48474. */
  48475. }, {
  48476. key: 'toggleMerge',
  48477. value: function toggleMerge(cellRange) {
  48478. var mergedCell = this.mergedCellsCollection.get(cellRange.from.row, cellRange.from.col);
  48479. var mergedCellCoversWholeRange = mergedCell.row === cellRange.from.row && mergedCell.col === cellRange.from.col && mergedCell.row + mergedCell.rowspan - 1 === cellRange.to.row && mergedCell.col + mergedCell.colspan - 1 === cellRange.to.col;
  48480. if (mergedCellCoversWholeRange) {
  48481. this.unmergeRange(cellRange);
  48482. } else {
  48483. this.mergeSelection(cellRange);
  48484. }
  48485. }
  48486. /**
  48487. * Merge the specified range.
  48488. *
  48489. * @param {Number} startRow Start row of the merged cell.
  48490. * @param {Number} startColumn Start column of the merged cell.
  48491. * @param {Number} endRow End row of the merged cell.
  48492. * @param {Number} endColumn End column of the merged cell.
  48493. */
  48494. }, {
  48495. key: 'merge',
  48496. value: function merge(startRow, startColumn, endRow, endColumn) {
  48497. var start = new _src.CellCoords(startRow, startColumn);
  48498. var end = new _src.CellCoords(endRow, endColumn);
  48499. this.mergeRange(new _src.CellRange(start, start, end));
  48500. }
  48501. /**
  48502. * Unmerge the merged cell in the provided range.
  48503. *
  48504. * @param {Number} startRow Start row of the merged cell.
  48505. * @param {Number} startColumn Start column of the merged cell.
  48506. * @param {Number} endRow End row of the merged cell.
  48507. * @param {Number} endColumn End column of the merged cell.
  48508. */
  48509. }, {
  48510. key: 'unmerge',
  48511. value: function unmerge(startRow, startColumn, endRow, endColumn) {
  48512. var start = new _src.CellCoords(startRow, startColumn);
  48513. var end = new _src.CellCoords(endRow, endColumn);
  48514. this.unmergeRange(new _src.CellRange(start, start, end));
  48515. }
  48516. /**
  48517. * `afterInit` hook callback.
  48518. *
  48519. * @private
  48520. */
  48521. }, {
  48522. key: 'onAfterInit',
  48523. value: function onAfterInit() {
  48524. this.generateFromSettings(this.hot.getSettings().mergeCells);
  48525. this.hot.render();
  48526. }
  48527. /**
  48528. * `beforeKeyDown` hook callback.
  48529. *
  48530. * @private
  48531. * @param {KeyboardEvent} event The `keydown` event object.
  48532. */
  48533. }, {
  48534. key: 'onBeforeKeyDown',
  48535. value: function onBeforeKeyDown(event) {
  48536. var ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  48537. if (ctrlDown && event.keyCode === 77) {
  48538. // CTRL + M
  48539. this.toggleMerge(this.hot.getSelectedRangeLast());
  48540. this.hot.render();
  48541. (0, _event.stopImmediatePropagation)(event);
  48542. }
  48543. }
  48544. /**
  48545. * Modify the information on whether the current selection contains multiple cells. The `afterIsMultipleSelection` hook callback.
  48546. *
  48547. * @private
  48548. * @param {Boolean} isMultiple
  48549. * @returns {Boolean}
  48550. */
  48551. }, {
  48552. key: 'onAfterIsMultipleSelection',
  48553. value: function onAfterIsMultipleSelection(isMultiple) {
  48554. if (isMultiple) {
  48555. var mergedCells = this.mergedCellsCollection.mergedCells;
  48556. var selectionRange = this.hot.getSelectedRangeLast();
  48557. for (var group = 0; group < mergedCells.length; group += 1) {
  48558. if (selectionRange.highlight.row === mergedCells[group].row && selectionRange.highlight.col === mergedCells[group].col && selectionRange.to.row === mergedCells[group].row + mergedCells[group].rowspan - 1 && selectionRange.to.col === mergedCells[group].col + mergedCells[group].colspan - 1) {
  48559. return false;
  48560. }
  48561. }
  48562. }
  48563. return isMultiple;
  48564. }
  48565. /**
  48566. * `modifyTransformStart` hook callback.
  48567. *
  48568. * @private
  48569. * @param {Object} delta The transformation delta.
  48570. */
  48571. }, {
  48572. key: 'onModifyTransformStart',
  48573. value: function onModifyTransformStart(delta) {
  48574. var priv = privatePool.get(this);
  48575. var currentlySelectedRange = this.hot.getSelectedRangeLast();
  48576. var newDelta = {
  48577. row: delta.row,
  48578. col: delta.col
  48579. };
  48580. var nextPosition = null;
  48581. var currentPosition = new _src.CellCoords(currentlySelectedRange.highlight.row, currentlySelectedRange.highlight.col);
  48582. var mergedParent = this.mergedCellsCollection.get(currentPosition.row, currentPosition.col);
  48583. if (!priv.lastDesiredCoords) {
  48584. priv.lastDesiredCoords = new _src.CellCoords(null, null);
  48585. }
  48586. if (mergedParent) {
  48587. // only merge selected
  48588. var mergeTopLeft = new _src.CellCoords(mergedParent.row, mergedParent.col);
  48589. var mergeBottomRight = new _src.CellCoords(mergedParent.row + mergedParent.rowspan - 1, mergedParent.col + mergedParent.colspan - 1);
  48590. var mergeRange = new _src.CellRange(mergeTopLeft, mergeTopLeft, mergeBottomRight);
  48591. if (!mergeRange.includes(priv.lastDesiredCoords)) {
  48592. priv.lastDesiredCoords = new _src.CellCoords(null, null); // reset outdated version of lastDesiredCoords
  48593. }
  48594. newDelta.row = priv.lastDesiredCoords.row ? priv.lastDesiredCoords.row - currentPosition.row : newDelta.row;
  48595. newDelta.col = priv.lastDesiredCoords.col ? priv.lastDesiredCoords.col - currentPosition.col : newDelta.col;
  48596. if (delta.row > 0) {
  48597. // moving down
  48598. newDelta.row = mergedParent.row + mergedParent.rowspan - 1 - currentPosition.row + delta.row;
  48599. } else if (delta.row < 0) {
  48600. // moving up
  48601. newDelta.row = currentPosition.row - mergedParent.row + delta.row;
  48602. }
  48603. if (delta.col > 0) {
  48604. // moving right
  48605. newDelta.col = mergedParent.col + mergedParent.colspan - 1 - currentPosition.col + delta.col;
  48606. } else if (delta.col < 0) {
  48607. // moving left
  48608. newDelta.col = currentPosition.col - mergedParent.col + delta.col;
  48609. }
  48610. }
  48611. nextPosition = new _src.CellCoords(currentlySelectedRange.highlight.row + newDelta.row, currentlySelectedRange.highlight.col + newDelta.col);
  48612. var nextParentIsMerged = this.mergedCellsCollection.get(nextPosition.row, nextPosition.col);
  48613. if (nextParentIsMerged) {
  48614. // skipping the invisible cells in the merge range
  48615. priv.lastDesiredCoords = nextPosition;
  48616. newDelta = {
  48617. row: nextParentIsMerged.row - currentPosition.row,
  48618. col: nextParentIsMerged.col - currentPosition.col
  48619. };
  48620. }
  48621. if (newDelta.row !== 0) {
  48622. delta.row = newDelta.row;
  48623. }
  48624. if (newDelta.col !== 0) {
  48625. delta.col = newDelta.col;
  48626. }
  48627. }
  48628. /**
  48629. * `modifyTransformEnd` hook callback. Needed to handle "jumping over" merged merged cells, while selecting.
  48630. *
  48631. * @private
  48632. * @param {Object} delta The transformation delta.
  48633. */
  48634. }, {
  48635. key: 'onModifyTransformEnd',
  48636. value: function onModifyTransformEnd(delta) {
  48637. var _this6 = this;
  48638. var currentSelectionRange = this.hot.getSelectedRangeLast();
  48639. var newDelta = (0, _object.clone)(delta);
  48640. var newSelectionRange = this.selectionCalculations.getUpdatedSelectionRange(currentSelectionRange, delta);
  48641. var tempDelta = (0, _object.clone)(newDelta);
  48642. var mergedCellsWithinRange = this.mergedCellsCollection.getWithinRange(newSelectionRange, true);
  48643. do {
  48644. tempDelta = (0, _object.clone)(newDelta);
  48645. this.selectionCalculations.getUpdatedSelectionRange(currentSelectionRange, newDelta);
  48646. (0, _array.arrayEach)(mergedCellsWithinRange, function (mergedCell) {
  48647. _this6.selectionCalculations.snapDelta(newDelta, currentSelectionRange, mergedCell);
  48648. });
  48649. } while (newDelta.row !== tempDelta.row || newDelta.col !== tempDelta.col);
  48650. delta.row = newDelta.row;
  48651. delta.col = newDelta.col;
  48652. }
  48653. /**
  48654. * `modifyGetCellCoords` hook callback. Swaps the `getCell` coords with the merged parent coords.
  48655. *
  48656. * @private
  48657. * @param {Number} row Row index.
  48658. * @param {Number} column Column index.
  48659. * @returns {Array}
  48660. */
  48661. }, {
  48662. key: 'onModifyGetCellCoords',
  48663. value: function onModifyGetCellCoords(row, column) {
  48664. var mergeParent = this.mergedCellsCollection.get(row, column);
  48665. return mergeParent ? [mergeParent.row, mergeParent.col, mergeParent.row + mergeParent.rowspan - 1, mergeParent.col + mergeParent.colspan - 1] : void 0;
  48666. }
  48667. /**
  48668. * `afterContextMenuDefaultOptions` hook callback.
  48669. *
  48670. * @private
  48671. * @param {Object} defaultOptions The default context menu options.
  48672. */
  48673. }, {
  48674. key: 'addMergeActionsToContextMenu',
  48675. value: function addMergeActionsToContextMenu(defaultOptions) {
  48676. defaultOptions.items.push({
  48677. name: '---------'
  48678. }, (0, _toggleMerge2.default)(this));
  48679. }
  48680. /**
  48681. * `afterRenderer` hook callback.
  48682. *
  48683. * @private
  48684. * @param {HTMLElement} TD The cell to be modified.
  48685. * @param {Number} row Row index.
  48686. * @param {Number} col Column index.
  48687. */
  48688. }, {
  48689. key: 'onAfterRenderer',
  48690. value: function onAfterRenderer(TD, row, col) {
  48691. var mergedCell = this.mergedCellsCollection.get(row, col);
  48692. (0, _utils.applySpanProperties)(TD, mergedCell, row, col);
  48693. }
  48694. /**
  48695. * `beforeSetRangeEnd` hook callback.
  48696. * While selecting cells with keyboard or mouse, make sure that rectangular area is expanded to the extent of the merged cell
  48697. *
  48698. * @private
  48699. * @param {Object} coords Cell coords.
  48700. */
  48701. }, {
  48702. key: 'onBeforeSetRangeEnd',
  48703. value: function onBeforeSetRangeEnd(coords) {
  48704. var selRange = this.hot.getSelectedRangeLast();
  48705. selRange.highlight = new _src.CellCoords(selRange.highlight.row, selRange.highlight.col); // clone in case we will modify its reference
  48706. selRange.to = coords;
  48707. var rangeExpanded = false;
  48708. if (selRange.from.row === 0 && selRange.to.row === this.hot.countRows() - 1 || selRange.from.col === 0 && selRange.to.col === this.hot.countCols() - 1) {
  48709. return;
  48710. }
  48711. do {
  48712. rangeExpanded = false;
  48713. for (var i = 0; i < this.mergedCellsCollection.mergedCells.length; i += 1) {
  48714. var cellInfo = this.mergedCellsCollection.mergedCells[i];
  48715. var mergedCellRange = cellInfo.getRange();
  48716. if (selRange.expandByRange(mergedCellRange)) {
  48717. coords.row = selRange.to.row;
  48718. coords.col = selRange.to.col;
  48719. rangeExpanded = true;
  48720. }
  48721. }
  48722. } while (rangeExpanded);
  48723. }
  48724. /**
  48725. * The `afterGetCellMeta` hook callback.
  48726. *
  48727. * @private
  48728. * @param {Number} row Row index.
  48729. * @param {Number} col Column index.
  48730. * @param {Object} cellProperties The cell properties object.
  48731. */
  48732. }, {
  48733. key: 'onAfterGetCellMeta',
  48734. value: function onAfterGetCellMeta(row, col, cellProperties) {
  48735. var mergeParent = this.mergedCellsCollection.get(row, col);
  48736. if (mergeParent && (mergeParent.row !== row || mergeParent.col !== col)) {
  48737. cellProperties.copyable = false;
  48738. }
  48739. }
  48740. /**
  48741. * `afterViewportRowCalculatorOverride` hook callback.
  48742. *
  48743. * @private
  48744. * @param {Object} calc The row calculator object.
  48745. */
  48746. }, {
  48747. key: 'onAfterViewportRowCalculatorOverride',
  48748. value: function onAfterViewportRowCalculatorOverride(calc) {
  48749. var _this7 = this;
  48750. var colCount = this.hot.countCols();
  48751. var mergeParent = void 0;
  48752. (0, _number.rangeEach)(0, colCount - 1, function (c) {
  48753. mergeParent = _this7.mergedCellsCollection.get(calc.startRow, c);
  48754. if (mergeParent) {
  48755. if (mergeParent.row < calc.startRow) {
  48756. calc.startRow = mergeParent.row;
  48757. return _this7.onAfterViewportRowCalculatorOverride.call(_this7, calc); // recursively search upwards
  48758. }
  48759. }
  48760. mergeParent = _this7.mergedCellsCollection.get(calc.endRow, c);
  48761. if (mergeParent) {
  48762. var mergeEnd = mergeParent.row + mergeParent.rowspan - 1;
  48763. if (mergeEnd > calc.endRow) {
  48764. calc.endRow = mergeEnd;
  48765. return _this7.onAfterViewportRowCalculatorOverride.call(_this7, calc); // recursively search upwards
  48766. }
  48767. }
  48768. return true;
  48769. });
  48770. }
  48771. /**
  48772. * `afterViewportColumnCalculatorOverride` hook callback.
  48773. *
  48774. * @private
  48775. * @param {Object} calc The column calculator object.
  48776. */
  48777. }, {
  48778. key: 'onAfterViewportColumnCalculatorOverride',
  48779. value: function onAfterViewportColumnCalculatorOverride(calc) {
  48780. var _this8 = this;
  48781. var rowCount = this.hot.countRows();
  48782. var mergeParent = void 0;
  48783. (0, _number.rangeEach)(0, rowCount - 1, function (r) {
  48784. mergeParent = _this8.mergedCellsCollection.get(r, calc.startColumn);
  48785. if (mergeParent && mergeParent.col < calc.startColumn) {
  48786. calc.startColumn = mergeParent.col;
  48787. return _this8.onAfterViewportColumnCalculatorOverride.call(_this8, calc); // recursively search upwards
  48788. }
  48789. mergeParent = _this8.mergedCellsCollection.get(r, calc.endColumn);
  48790. if (mergeParent) {
  48791. var mergeEnd = mergeParent.col + mergeParent.colspan - 1;
  48792. if (mergeEnd > calc.endColumn) {
  48793. calc.endColumn = mergeEnd;
  48794. return _this8.onAfterViewportColumnCalculatorOverride.call(_this8, calc); // recursively search upwards
  48795. }
  48796. }
  48797. return true;
  48798. });
  48799. }
  48800. /**
  48801. * The `modifyAutofillRange` hook callback.
  48802. *
  48803. * @private
  48804. * @param {Array} drag The drag area coordinates.
  48805. * @param {Array} select The selection information.
  48806. * @return {Array} The new drag area.
  48807. */
  48808. }, {
  48809. key: 'onModifyAutofillRange',
  48810. value: function onModifyAutofillRange(drag, select) {
  48811. this.autofillCalculations.correctSelectionAreaSize(select);
  48812. var dragDirection = this.autofillCalculations.getDirection(select, drag);
  48813. if (this.autofillCalculations.dragAreaOverlapsCollections(select, drag, dragDirection)) {
  48814. drag = select;
  48815. return drag;
  48816. }
  48817. var mergedCellsWithinSelectionArea = this.mergedCellsCollection.getWithinRange({
  48818. from: { row: select[0], col: select[1] },
  48819. to: { row: select[2], col: select[3] }
  48820. });
  48821. if (!mergedCellsWithinSelectionArea) {
  48822. return drag;
  48823. }
  48824. drag = this.autofillCalculations.snapDragArea(select, drag, dragDirection, mergedCellsWithinSelectionArea);
  48825. return drag;
  48826. }
  48827. /**
  48828. * `afterCreateCol` hook callback.
  48829. *
  48830. * @private
  48831. * @param {Number} column Column index.
  48832. * @param {Number} count Number of created columns.
  48833. */
  48834. }, {
  48835. key: 'onAfterCreateCol',
  48836. value: function onAfterCreateCol(column, count) {
  48837. this.mergedCellsCollection.shiftCollections('right', column, count);
  48838. }
  48839. /**
  48840. * `afterRemoveCol` hook callback.
  48841. *
  48842. * @private
  48843. * @param {Number} column Column index.
  48844. * @param {Number} count Number of removed columns.
  48845. */
  48846. }, {
  48847. key: 'onAfterRemoveCol',
  48848. value: function onAfterRemoveCol(column, count) {
  48849. this.mergedCellsCollection.shiftCollections('left', column, count);
  48850. }
  48851. /**
  48852. * `afterCreateRow` hook callback.
  48853. *
  48854. * @private
  48855. * @param {Number} row Row index.
  48856. * @param {Number} count Number of created rows.
  48857. * @param {String} source Source of change.
  48858. */
  48859. }, {
  48860. key: 'onAfterCreateRow',
  48861. value: function onAfterCreateRow(row, count, source) {
  48862. if (source === 'auto') {
  48863. return;
  48864. }
  48865. this.mergedCellsCollection.shiftCollections('down', row, count);
  48866. }
  48867. /**
  48868. * `afterRemoveRow` hook callback.
  48869. *
  48870. * @private
  48871. * @param {Number} row Row index.
  48872. * @param {Number} count Number of removed rows.
  48873. */
  48874. }, {
  48875. key: 'onAfterRemoveRow',
  48876. value: function onAfterRemoveRow(row, count) {
  48877. this.mergedCellsCollection.shiftCollections('up', row, count);
  48878. }
  48879. /**
  48880. * `afterChange` hook callback. Used to propagate merged cells after using Autofill.
  48881. *
  48882. * @private
  48883. * @param {Array} changes The changes array.
  48884. * @param {String} source Determines the source of the change.
  48885. */
  48886. }, {
  48887. key: 'onAfterChange',
  48888. value: function onAfterChange(changes, source) {
  48889. if (source !== 'Autofill.fill') {
  48890. return;
  48891. }
  48892. this.autofillCalculations.recreateAfterDataPopulation(changes);
  48893. }
  48894. /**
  48895. * `beforeDrawAreaBorders` hook callback.
  48896. *
  48897. * @private
  48898. * @param {Array} corners Coordinates of the area corners.
  48899. * @param {String} className Class name for the area.
  48900. */
  48901. }, {
  48902. key: 'onBeforeDrawAreaBorders',
  48903. value: function onBeforeDrawAreaBorders(corners, className) {
  48904. if (className && className === 'area') {
  48905. var selectedRange = this.hot.getSelectedRangeLast();
  48906. var mergedCellsWithinRange = this.mergedCellsCollection.getWithinRange(selectedRange);
  48907. (0, _array.arrayEach)(mergedCellsWithinRange, function (mergedCell) {
  48908. if (selectedRange.getBottomRightCorner().row === mergedCell.getLastRow() && selectedRange.getBottomRightCorner().col === mergedCell.getLastColumn()) {
  48909. corners[2] = mergedCell.row;
  48910. corners[3] = mergedCell.col;
  48911. }
  48912. });
  48913. }
  48914. }
  48915. /**
  48916. * `afterModifyTransformStart` hook callback. Fixes a problem with navigating through merged cells at the edges of the table
  48917. * with the ENTER/SHIFT+ENTER/TAB/SHIFT+TAB keys.
  48918. *
  48919. * @private
  48920. * @param {CellCoords} coords Coordinates of the to-be-selected cell.
  48921. * @param {Number} rowTransformDir Row transformation direction (negative value = up, 0 = none, positive value = down)
  48922. * @param {Number} colTransformDir Column transformation direction (negative value = up, 0 = none, positive value = down)
  48923. */
  48924. }, {
  48925. key: 'onAfterModifyTransformStart',
  48926. value: function onAfterModifyTransformStart(coords, rowTransformDir, colTransformDir) {
  48927. if (!this.enabled) {
  48928. return;
  48929. }
  48930. var mergedCellAtCoords = this.mergedCellsCollection.get(coords.row, coords.col);
  48931. if (!mergedCellAtCoords) {
  48932. return;
  48933. }
  48934. var goingDown = rowTransformDir > 0;
  48935. var goingUp = rowTransformDir < 0;
  48936. var goingLeft = colTransformDir < 0;
  48937. var goingRight = colTransformDir > 0;
  48938. var mergedCellOnBottomEdge = mergedCellAtCoords.row + mergedCellAtCoords.rowspan - 1 === this.hot.countRows() - 1;
  48939. var mergedCellOnTopEdge = mergedCellAtCoords.row === 0;
  48940. var mergedCellOnRightEdge = mergedCellAtCoords.col + mergedCellAtCoords.colspan - 1 === this.hot.countCols() - 1;
  48941. var mergedCellOnLeftEdge = mergedCellAtCoords.col === 0;
  48942. if (goingDown && mergedCellOnBottomEdge || goingUp && mergedCellOnTopEdge || goingRight && mergedCellOnRightEdge || goingLeft && mergedCellOnLeftEdge) {
  48943. coords.row = mergedCellAtCoords.row;
  48944. coords.col = mergedCellAtCoords.col;
  48945. }
  48946. }
  48947. /**
  48948. * `afterDrawSelection` hook callback. Used to add the additional class name for the entirely-selected merged cells.
  48949. *
  48950. * @private
  48951. * @param {Number} currentRow Row index of the currently processed cell.
  48952. * @param {Number} currentColumn Column index of the currently cell.
  48953. * @param {Array} cornersOfSelection Array of the current selection in a form of `[startRow, startColumn, endRow, endColumn]`.
  48954. * @param {Number|undefined} layerLevel Number indicating which layer of selection is currently processed.
  48955. * @returns {String|undefined} A `String`, which will act as an additional `className` to be added to the currently processed cell.
  48956. */
  48957. }, {
  48958. key: 'onAfterDrawSelection',
  48959. value: function onAfterDrawSelection(currentRow, currentColumn, cornersOfSelection, layerLevel) {
  48960. return this.selectionCalculations.getSelectedMergedCellClassName(currentRow, currentColumn, cornersOfSelection, layerLevel);
  48961. }
  48962. /**
  48963. * `beforeRemoveCellClassNames` hook callback. Used to remove additional class name from all cells in the table.
  48964. *
  48965. * @private
  48966. * @returns {String[]} An `Array` of `String`s. Each of these strings will act like class names to be removed from all the cells in the table.
  48967. */
  48968. }, {
  48969. key: 'onBeforeRemoveCellClassNames',
  48970. value: function onBeforeRemoveCellClassNames() {
  48971. return this.selectionCalculations.getSelectedMergedCellClassNameToRemove();
  48972. }
  48973. }]);
  48974. return MergeCells;
  48975. }(_base2.default);
  48976. (0, _plugins.registerPlugin)('mergeCells', MergeCells);
  48977. exports.default = MergeCells;
  48978. /***/ }),
  48979. /* 467 */
  48980. /***/ (function(module, exports, __webpack_require__) {
  48981. "use strict";
  48982. exports.__esModule = true;
  48983. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  48984. var _templateObject = _taggedTemplateLiteral(['The merged cell declared at [', ', ', '] overlaps with the other declared merged \n cell. The overlapping merged cell was not added to the table, please fix your setup.'], ['The merged cell declared at [', ', ', '] overlaps with the other declared merged \n cell. The overlapping merged cell was not added to the table, please fix your setup.']);
  48985. var _cellCoords = __webpack_require__(95);
  48986. var _cellCoords2 = _interopRequireDefault(_cellCoords);
  48987. var _index = __webpack_require__(4);
  48988. var _number = __webpack_require__(5);
  48989. var _console = __webpack_require__(56);
  48990. var _array = __webpack_require__(1);
  48991. var _utils = __webpack_require__(324);
  48992. var _templateLiteralTag = __webpack_require__(42);
  48993. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  48994. function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
  48995. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  48996. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  48997. /**
  48998. * Defines a container object for the merged cells.
  48999. *
  49000. * @class MergedCellsCollection
  49001. * @plugin MergeCells
  49002. */
  49003. var MergedCellsCollection = function () {
  49004. function MergedCellsCollection(plugin) {
  49005. _classCallCheck(this, MergedCellsCollection);
  49006. /**
  49007. * Reference to the Merge Cells plugin.
  49008. *
  49009. * @type {MergeCells}
  49010. */
  49011. this.plugin = plugin;
  49012. /**
  49013. * Array of merged cells.
  49014. *
  49015. * @type {Array}
  49016. */
  49017. this.mergedCells = [];
  49018. /**
  49019. * The Handsontable instance.
  49020. *
  49021. * @type {Handsontable}
  49022. */
  49023. this.hot = plugin.hot;
  49024. }
  49025. /**
  49026. * Get a warning message for when the declared merged cell data overlaps already existing merged cells.
  49027. *
  49028. * @param {Object} newMergedCell Object containg information about the merged cells that was about to be added.
  49029. * @return {String}
  49030. */
  49031. _createClass(MergedCellsCollection, [{
  49032. key: 'get',
  49033. /**
  49034. * Get a merged cell from the container, based on the provided arguments. You can provide either the "starting coordinates"
  49035. * of a merged cell, or any coordinates from the body of the merged cell.
  49036. *
  49037. * @param {Number} row Row index.
  49038. * @param {Number} column Column index.
  49039. * @returns {MergedCellCoords|Boolean} Returns a wanted merged cell on success and `false` on failure.
  49040. */
  49041. value: function get(row, column) {
  49042. var mergedCells = this.mergedCells;
  49043. var result = false;
  49044. (0, _array.arrayEach)(mergedCells, function (mergedCell) {
  49045. if (mergedCell.row <= row && mergedCell.row + mergedCell.rowspan - 1 >= row && mergedCell.col <= column && mergedCell.col + mergedCell.colspan - 1 >= column) {
  49046. result = mergedCell;
  49047. return false;
  49048. }
  49049. return true;
  49050. });
  49051. return result;
  49052. }
  49053. /**
  49054. * Get a merged cell containing the provided range.
  49055. *
  49056. * @param {CellRange|Object} range The range to search merged cells for.
  49057. * @return {MergedCellCoords|Boolean}
  49058. */
  49059. }, {
  49060. key: 'getByRange',
  49061. value: function getByRange(range) {
  49062. var mergedCells = this.mergedCells;
  49063. var result = false;
  49064. (0, _array.arrayEach)(mergedCells, function (mergedCell) {
  49065. if (mergedCell.row <= range.from.row && mergedCell.row + mergedCell.rowspan - 1 >= range.to.row && mergedCell.col <= range.from.col && mergedCell.col + mergedCell.colspan - 1 >= range.to.col) {
  49066. result = mergedCell;
  49067. return result;
  49068. }
  49069. return true;
  49070. });
  49071. return result;
  49072. }
  49073. /**
  49074. * Get a merged cell contained in the provided range.
  49075. *
  49076. * @param {CellRange|Object} range The range to search merged cells in.
  49077. * @param [countPartials=false] If set to `true`, all the merged cells overlapping the range will be taken into calculation.
  49078. * @return {Array|Boolean} Array of found merged cells of `false` if none were found.
  49079. */
  49080. }, {
  49081. key: 'getWithinRange',
  49082. value: function getWithinRange(range) {
  49083. var countPartials = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  49084. var mergedCells = this.mergedCells;
  49085. var foundMergedCells = [];
  49086. if (!range.includesRange) {
  49087. var from = new _index.CellCoords(range.from.row, range.from.col);
  49088. var to = new _index.CellCoords(range.to.row, range.to.col);
  49089. range = new _index.CellRange(from, from, to);
  49090. }
  49091. (0, _array.arrayEach)(mergedCells, function (mergedCell) {
  49092. var mergedCellTopLeft = new _index.CellCoords(mergedCell.row, mergedCell.col);
  49093. var mergedCellBottomRight = new _index.CellCoords(mergedCell.row + mergedCell.rowspan - 1, mergedCell.col + mergedCell.colspan - 1);
  49094. var mergedCellRange = new _index.CellRange(mergedCellTopLeft, mergedCellTopLeft, mergedCellBottomRight);
  49095. if (countPartials) {
  49096. if (range.overlaps(mergedCellRange)) {
  49097. foundMergedCells.push(mergedCell);
  49098. }
  49099. } else if (range.includesRange(mergedCellRange)) {
  49100. foundMergedCells.push(mergedCell);
  49101. }
  49102. });
  49103. return foundMergedCells.length ? foundMergedCells : false;
  49104. }
  49105. /**
  49106. * Add a merged cell to the container.
  49107. *
  49108. * @param {Object} mergedCellInfo The merged cell information object. Has to contain `row`, `col`, `colspan` and `rowspan` properties.
  49109. * @return {MergedCellCoords|Boolean} Returns the new merged cell on success and `false` on failure.
  49110. */
  49111. }, {
  49112. key: 'add',
  49113. value: function add(mergedCellInfo) {
  49114. var mergedCells = this.mergedCells;
  49115. var row = mergedCellInfo.row;
  49116. var column = mergedCellInfo.col;
  49117. var rowspan = mergedCellInfo.rowspan;
  49118. var colspan = mergedCellInfo.colspan;
  49119. var newMergedCell = new _cellCoords2.default(row, column, rowspan, colspan);
  49120. var alreadyExists = this.get(row, column);
  49121. var isOverlapping = this.isOverlapping(newMergedCell);
  49122. if (!alreadyExists && !isOverlapping) {
  49123. if (this.hot) {
  49124. newMergedCell.normalize(this.hot);
  49125. }
  49126. mergedCells.push(newMergedCell);
  49127. return newMergedCell;
  49128. }
  49129. (0, _console.warn)(MergedCellsCollection.IS_OVERLAPPING_WARNING(newMergedCell));
  49130. return false;
  49131. }
  49132. /**
  49133. * Remove a merged cell from the container. You can provide either the "starting coordinates"
  49134. * of a merged cell, or any coordinates from the body of the merged cell.
  49135. *
  49136. * @param {Number} row Row index.
  49137. * @param {Number} column Column index.
  49138. * @return {MergedCellCoords|Boolean} Returns the removed merged cell on success and `false` on failure.
  49139. */
  49140. }, {
  49141. key: 'remove',
  49142. value: function remove(row, column) {
  49143. var mergedCells = this.mergedCells;
  49144. var wantedCollection = this.get(row, column);
  49145. var wantedCollectionIndex = wantedCollection ? this.mergedCells.indexOf(wantedCollection) : null;
  49146. if (wantedCollection && wantedCollectionIndex !== false) {
  49147. mergedCells.splice(wantedCollectionIndex, 1);
  49148. return wantedCollection;
  49149. }
  49150. return false;
  49151. }
  49152. /**
  49153. * Clear all the merged cells.
  49154. */
  49155. }, {
  49156. key: 'clear',
  49157. value: function clear() {
  49158. var _this = this;
  49159. var mergedCells = this.mergedCells;
  49160. var mergedCellParentsToClear = [];
  49161. var hiddenCollectionElements = [];
  49162. (0, _array.arrayEach)(mergedCells, function (mergedCell) {
  49163. mergedCellParentsToClear.push([_this.hot.getCell(mergedCell.row, mergedCell.col), _this.get(mergedCell.row, mergedCell.col), mergedCell.row, mergedCell.col]);
  49164. });
  49165. this.mergedCells.length = 0;
  49166. (0, _array.arrayEach)(mergedCellParentsToClear, function (mergedCell, i) {
  49167. (0, _number.rangeEach)(0, mergedCell.rowspan - 1, function (j) {
  49168. (0, _number.rangeEach)(0, mergedCell.colspan - 1, function (k) {
  49169. if (k !== 0 || j !== 0) {
  49170. hiddenCollectionElements.push([_this.hot.getCell(mergedCell.row + j, mergedCell.col + k), null, null, null]);
  49171. }
  49172. });
  49173. });
  49174. mergedCellParentsToClear[i][1] = null;
  49175. });
  49176. (0, _array.arrayEach)(mergedCellParentsToClear, function (mergedCellParents) {
  49177. _utils.applySpanProperties.apply(undefined, _toConsumableArray(mergedCellParents));
  49178. });
  49179. (0, _array.arrayEach)(hiddenCollectionElements, function (hiddenCollectionElement) {
  49180. _utils.applySpanProperties.apply(undefined, _toConsumableArray(hiddenCollectionElement));
  49181. });
  49182. }
  49183. /**
  49184. * Check if the provided merged cell overlaps with the others in the container.
  49185. *
  49186. * @param {MergedCellCoords} mergedCell The merged cell to check against all others in the container.
  49187. * @return {Boolean} `true` if the provided merged cell overlaps with the others, `false` otherwise.
  49188. */
  49189. }, {
  49190. key: 'isOverlapping',
  49191. value: function isOverlapping(mergedCell) {
  49192. var mergedCellRange = new _index.CellRange(null, new _index.CellCoords(mergedCell.row, mergedCell.col), new _index.CellCoords(mergedCell.row + mergedCell.rowspan - 1, mergedCell.col + mergedCell.colspan - 1));
  49193. var result = false;
  49194. (0, _array.arrayEach)(this.mergedCells, function (col) {
  49195. var currentRange = new _index.CellRange(null, new _index.CellCoords(col.row, col.col), new _index.CellCoords(col.row + col.rowspan - 1, col.col + col.colspan - 1));
  49196. if (currentRange.overlaps(mergedCellRange)) {
  49197. result = true;
  49198. return false;
  49199. }
  49200. return true;
  49201. });
  49202. return result;
  49203. }
  49204. /**
  49205. * Check whether the provided row/col coordinates direct to a merged parent.
  49206. *
  49207. * @param {Number} row Row index.
  49208. * @param {Number} column Column index.
  49209. * @return {Boolean}
  49210. */
  49211. }, {
  49212. key: 'isMergedParent',
  49213. value: function isMergedParent(row, column) {
  49214. var mergedCells = this.mergedCells;
  49215. var result = false;
  49216. (0, _array.arrayEach)(mergedCells, function (mergedCell) {
  49217. if (mergedCell.row === row && mergedCell.col === column) {
  49218. result = true;
  49219. return false;
  49220. }
  49221. return true;
  49222. });
  49223. return result;
  49224. }
  49225. /**
  49226. * Shift the merged cell in the direction and by an offset defined in the arguments.
  49227. *
  49228. * @param {String} direction `right`, `left`, `up` or `down`.
  49229. * @param {Number} index Index where the change, which caused the shifting took place.
  49230. * @param {Number} count Number of rows/columns added/removed in the preceding action.
  49231. */
  49232. }, {
  49233. key: 'shiftCollections',
  49234. value: function shiftCollections(direction, index, count) {
  49235. var _this2 = this;
  49236. var shiftVector = [0, 0];
  49237. switch (direction) {
  49238. case 'right':
  49239. shiftVector[0] += count;
  49240. break;
  49241. case 'left':
  49242. shiftVector[0] -= count;
  49243. break;
  49244. case 'down':
  49245. shiftVector[1] += count;
  49246. break;
  49247. case 'up':
  49248. shiftVector[1] -= count;
  49249. break;
  49250. default:
  49251. }
  49252. (0, _array.arrayEach)(this.mergedCells, function (currentMerge) {
  49253. currentMerge.shift(shiftVector, index);
  49254. });
  49255. (0, _number.rangeEachReverse)(this.mergedCells.length - 1, 0, function (i) {
  49256. var currentMerge = _this2.mergedCells[i];
  49257. if (currentMerge && currentMerge.removed) {
  49258. _this2.mergedCells.splice(_this2.mergedCells.indexOf(currentMerge), 1);
  49259. }
  49260. });
  49261. }
  49262. }], [{
  49263. key: 'IS_OVERLAPPING_WARNING',
  49264. value: function IS_OVERLAPPING_WARNING(newMergedCell) {
  49265. return (0, _templateLiteralTag.toSingleLine)(_templateObject, newMergedCell.row, newMergedCell.col);
  49266. }
  49267. }]);
  49268. return MergedCellsCollection;
  49269. }();
  49270. exports.default = MergedCellsCollection;
  49271. /***/ }),
  49272. /* 468 */
  49273. /***/ (function(module, exports, __webpack_require__) {
  49274. "use strict";
  49275. exports.__esModule = true;
  49276. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  49277. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  49278. var _object = __webpack_require__(2);
  49279. var _src = __webpack_require__(4);
  49280. var _array = __webpack_require__(1);
  49281. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  49282. /**
  49283. * Class responsible for all of the Autofill-related operations on merged cells.
  49284. *
  49285. * @class AutofillCalculations
  49286. * @plugin MergeCells
  49287. * @util
  49288. */
  49289. var AutofillCalculations = function () {
  49290. function AutofillCalculations(plugin) {
  49291. _classCallCheck(this, AutofillCalculations);
  49292. /**
  49293. * Reference to the Merge Cells plugin.
  49294. *
  49295. * @type {MergeCells}
  49296. */
  49297. this.plugin = plugin;
  49298. /**
  49299. * Reference to the MergedCellsCollection class instance.
  49300. *
  49301. * @type {MergedCellsCollection}
  49302. */
  49303. this.mergedCellsCollection = this.plugin.mergedCellsCollection;
  49304. /**
  49305. * Cache of the currently processed autofill data.
  49306. *
  49307. * @private
  49308. * @type {Object}
  49309. */
  49310. this.currentFillData = null;
  49311. }
  49312. /**
  49313. * Correct the provided selection area, so it's not selecting only a part of a merged cell.
  49314. *
  49315. * @param {Array} selectionArea
  49316. */
  49317. _createClass(AutofillCalculations, [{
  49318. key: 'correctSelectionAreaSize',
  49319. value: function correctSelectionAreaSize(selectionArea) {
  49320. if (selectionArea[0] === selectionArea[2] && selectionArea[1] === selectionArea[3]) {
  49321. var mergedCell = this.mergedCellsCollection.get(selectionArea[0], selectionArea[1]);
  49322. if (mergedCell) {
  49323. selectionArea[2] = selectionArea[0] + mergedCell.rowspan - 1;
  49324. selectionArea[3] = selectionArea[1] + mergedCell.colspan - 1;
  49325. }
  49326. }
  49327. }
  49328. /**
  49329. * Get the direction of the autofill process.
  49330. *
  49331. * @param {Array} selectionArea The selection area.
  49332. * @param {Array} finalArea The final area (base + drag).
  49333. * @return {String} `up`, `down`, `left` or `right`.
  49334. */
  49335. }, {
  49336. key: 'getDirection',
  49337. value: function getDirection(selectionArea, finalArea) {
  49338. var direction = null;
  49339. if (finalArea[0] === selectionArea[0] && finalArea[1] === selectionArea[1] && finalArea[3] === selectionArea[3]) {
  49340. direction = 'down';
  49341. } else if (finalArea[2] === selectionArea[2] && finalArea[1] === selectionArea[1] && finalArea[3] === selectionArea[3]) {
  49342. direction = 'up';
  49343. } else if (finalArea[1] === selectionArea[1] && finalArea[2] === selectionArea[2]) {
  49344. direction = 'right';
  49345. } else {
  49346. direction = 'left';
  49347. }
  49348. return direction;
  49349. }
  49350. /**
  49351. * Snap the drag area to the farthest merged cell, so it won't clip any of the merged cells.
  49352. *
  49353. * @param {Array} baseArea The base selected area.
  49354. * @param {Array} dragArea The drag area.
  49355. * @param {String} dragDirection The autofill drag direction.
  49356. * @param {Array} foundMergedCells MergeCellCoords found in the base selection area.
  49357. * @return {Array} The new drag area
  49358. */
  49359. }, {
  49360. key: 'snapDragArea',
  49361. value: function snapDragArea(baseArea, dragArea, dragDirection, foundMergedCells) {
  49362. var newDragArea = dragArea.slice(0);
  49363. var fillSize = this.getAutofillSize(baseArea, dragArea, dragDirection);
  49364. var _baseArea = _slicedToArray(baseArea, 4),
  49365. baseAreaStartRow = _baseArea[0],
  49366. baseAreaStartColumn = _baseArea[1],
  49367. baseAreaEndRow = _baseArea[2],
  49368. baseAreaEndColumn = _baseArea[3];
  49369. var verticalDirection = ['up', 'down'].indexOf(dragDirection) > -1;
  49370. var fullCycle = verticalDirection ? baseAreaEndRow - baseAreaStartRow + 1 : baseAreaEndColumn - baseAreaStartColumn + 1;
  49371. var fulls = Math.floor(fillSize / fullCycle) * fullCycle;
  49372. var partials = fillSize - fulls;
  49373. var farthestCollection = this.getFarthestCollection(baseArea, dragArea, dragDirection, foundMergedCells);
  49374. if (farthestCollection) {
  49375. if (dragDirection === 'down') {
  49376. var fill = farthestCollection.row + farthestCollection.rowspan - baseAreaStartRow - partials;
  49377. var newLimit = newDragArea[2] + fill;
  49378. if (newLimit >= this.plugin.hot.countRows()) {
  49379. newDragArea[2] -= partials;
  49380. } else {
  49381. newDragArea[2] += partials ? fill : 0;
  49382. }
  49383. } else if (dragDirection === 'right') {
  49384. var _fill = farthestCollection.col + farthestCollection.colspan - baseAreaStartColumn - partials;
  49385. var _newLimit = newDragArea[3] + _fill;
  49386. if (_newLimit >= this.plugin.hot.countCols()) {
  49387. newDragArea[3] -= partials;
  49388. } else {
  49389. newDragArea[3] += partials ? _fill : 0;
  49390. }
  49391. } else if (dragDirection === 'up') {
  49392. var _fill2 = baseAreaEndRow - partials - farthestCollection.row + 1;
  49393. var _newLimit2 = newDragArea[0] + _fill2;
  49394. if (_newLimit2 < 0) {
  49395. newDragArea[0] += partials;
  49396. } else {
  49397. newDragArea[0] -= partials ? _fill2 : 0;
  49398. }
  49399. } else if (dragDirection === 'left') {
  49400. var _fill3 = baseAreaEndColumn - partials - farthestCollection.col + 1;
  49401. var _newLimit3 = newDragArea[1] + _fill3;
  49402. if (_newLimit3 < 0) {
  49403. newDragArea[1] += partials;
  49404. } else {
  49405. newDragArea[1] -= partials ? _fill3 : 0;
  49406. }
  49407. }
  49408. }
  49409. this.updateCurrentFillCache({
  49410. baseArea: baseArea,
  49411. dragDirection: dragDirection,
  49412. foundMergedCells: foundMergedCells,
  49413. fillSize: fillSize,
  49414. dragArea: newDragArea,
  49415. cycleLength: fullCycle
  49416. });
  49417. return newDragArea;
  49418. }
  49419. /**
  49420. * Update the current fill cache with the provided object.
  49421. *
  49422. * @private
  49423. * @param {Object} updateObject
  49424. */
  49425. }, {
  49426. key: 'updateCurrentFillCache',
  49427. value: function updateCurrentFillCache(updateObject) {
  49428. if (!this.currentFillData) {
  49429. this.currentFillData = {};
  49430. }
  49431. (0, _object.extend)(this.currentFillData, updateObject);
  49432. }
  49433. /**
  49434. * Get the "length" of the drag area.
  49435. *
  49436. * @private
  49437. * @param {Array} baseArea The base selection area.
  49438. * @param {Array} dragArea The drag area (containing the base area).
  49439. * @param {String} direction The drag direction.
  49440. * @return {Number|null} The "length" (height or width, depending on the direction) of the drag.
  49441. */
  49442. }, {
  49443. key: 'getAutofillSize',
  49444. value: function getAutofillSize(baseArea, dragArea, direction) {
  49445. var _baseArea2 = _slicedToArray(baseArea, 4),
  49446. baseAreaStartRow = _baseArea2[0],
  49447. baseAreaStartColumn = _baseArea2[1],
  49448. baseAreaEndRow = _baseArea2[2],
  49449. baseAreaEndColumn = _baseArea2[3];
  49450. var _dragArea = _slicedToArray(dragArea, 4),
  49451. dragAreaStartRow = _dragArea[0],
  49452. dragAreaStartColumn = _dragArea[1],
  49453. dragAreaEndRow = _dragArea[2],
  49454. dragAreaEndColumn = _dragArea[3];
  49455. switch (direction) {
  49456. case 'up':
  49457. return baseAreaStartRow - dragAreaStartRow;
  49458. case 'down':
  49459. return dragAreaEndRow - baseAreaEndRow;
  49460. case 'left':
  49461. return baseAreaStartColumn - dragAreaStartColumn;
  49462. case 'right':
  49463. return dragAreaEndColumn - baseAreaEndColumn;
  49464. default:
  49465. return null;
  49466. }
  49467. }
  49468. /**
  49469. * Trim the default drag area (containing the selection area) to the drag-only area.
  49470. *
  49471. * @private
  49472. * @param {Array} baseArea The base selection area.
  49473. * @param {Array} dragArea The base selection area extended by the drag area.
  49474. * @param {String} direction Drag direction.
  49475. * @return {Array|null} Array representing the drag area coordinates.
  49476. */
  49477. }, {
  49478. key: 'getDragArea',
  49479. value: function getDragArea(baseArea, dragArea, direction) {
  49480. var _baseArea3 = _slicedToArray(baseArea, 4),
  49481. baseAreaStartRow = _baseArea3[0],
  49482. baseAreaStartColumn = _baseArea3[1],
  49483. baseAreaEndRow = _baseArea3[2],
  49484. baseAreaEndColumn = _baseArea3[3];
  49485. var _dragArea2 = _slicedToArray(dragArea, 4),
  49486. dragAreaStartRow = _dragArea2[0],
  49487. dragAreaStartColumn = _dragArea2[1],
  49488. dragAreaEndRow = _dragArea2[2],
  49489. dragAreaEndColumn = _dragArea2[3];
  49490. switch (direction) {
  49491. case 'up':
  49492. return [dragAreaStartRow, dragAreaStartColumn, baseAreaStartRow - 1, baseAreaEndColumn];
  49493. case 'down':
  49494. return [baseAreaEndRow + 1, baseAreaStartColumn, dragAreaEndRow, baseAreaEndColumn];
  49495. case 'left':
  49496. return [dragAreaStartRow, dragAreaStartColumn, baseAreaEndRow, baseAreaStartColumn - 1];
  49497. case 'right':
  49498. return [baseAreaStartRow, baseAreaEndColumn + 1, dragAreaEndRow, dragAreaEndColumn];
  49499. default:
  49500. return null;
  49501. }
  49502. }
  49503. /**
  49504. * Get the to-be-farthest merged cell in the newly filled area.
  49505. *
  49506. * @private
  49507. * @param {Array} baseArea The base selection area.
  49508. * @param {Array} dragArea The drag area (containing the base area).
  49509. * @param {String} direction The drag direction.
  49510. * @param {Array} mergedCellArray Array of the merged cells found in the base area.
  49511. * @return {MergedCellCoords|null}
  49512. */
  49513. }, {
  49514. key: 'getFarthestCollection',
  49515. value: function getFarthestCollection(baseArea, dragArea, direction, mergedCellArray) {
  49516. var _baseArea4 = _slicedToArray(baseArea, 4),
  49517. baseAreaStartRow = _baseArea4[0],
  49518. baseAreaStartColumn = _baseArea4[1],
  49519. baseAreaEndRow = _baseArea4[2],
  49520. baseAreaEndColumn = _baseArea4[3];
  49521. var verticalDirection = ['up', 'down'].indexOf(direction) > -1;
  49522. var baseEnd = verticalDirection ? baseAreaEndRow : baseAreaEndColumn;
  49523. var baseStart = verticalDirection ? baseAreaStartRow : baseAreaStartColumn;
  49524. var fillSize = this.getAutofillSize(baseArea, dragArea, direction);
  49525. var fullCycle = verticalDirection ? baseAreaEndRow - baseAreaStartRow + 1 : baseAreaEndColumn - baseAreaStartColumn + 1;
  49526. var fulls = Math.floor(fillSize / fullCycle) * fullCycle;
  49527. var partials = fillSize - fulls;
  49528. var inclusionFunctionName = null;
  49529. var farthestCollection = null;
  49530. var endOfDragRecreationIndex = null;
  49531. switch (direction) {
  49532. case 'up':
  49533. inclusionFunctionName = 'includesVertically';
  49534. endOfDragRecreationIndex = baseEnd - partials + 1;
  49535. break;
  49536. case 'left':
  49537. inclusionFunctionName = 'includesHorizontally';
  49538. endOfDragRecreationIndex = baseEnd - partials + 1;
  49539. break;
  49540. case 'down':
  49541. inclusionFunctionName = 'includesVertically';
  49542. endOfDragRecreationIndex = baseStart + partials - 1;
  49543. break;
  49544. case 'right':
  49545. inclusionFunctionName = 'includesHorizontally';
  49546. endOfDragRecreationIndex = baseStart + partials - 1;
  49547. break;
  49548. default:
  49549. }
  49550. (0, _array.arrayEach)(mergedCellArray, function (currentCollection) {
  49551. if (currentCollection[inclusionFunctionName](endOfDragRecreationIndex) && currentCollection.isFarther(farthestCollection, direction)) {
  49552. farthestCollection = currentCollection;
  49553. }
  49554. });
  49555. return farthestCollection;
  49556. }
  49557. /**
  49558. * Recreate the merged cells after the autofill process.
  49559. *
  49560. * @param {Array} changes Changes made.
  49561. */
  49562. }, {
  49563. key: 'recreateAfterDataPopulation',
  49564. value: function recreateAfterDataPopulation(changes) {
  49565. if (!this.currentFillData) {
  49566. return;
  49567. }
  49568. var fillRange = this.getRangeFromChanges(changes);
  49569. var foundMergedCells = this.currentFillData.foundMergedCells;
  49570. var dragDirection = this.currentFillData.dragDirection;
  49571. var inBounds = function inBounds(current, offset) {
  49572. switch (dragDirection) {
  49573. case 'up':
  49574. return current.row - offset >= fillRange.from.row;
  49575. case 'down':
  49576. return current.row + current.rowspan - 1 + offset <= fillRange.to.row;
  49577. case 'left':
  49578. return current.col - offset >= fillRange.from.column;
  49579. case 'right':
  49580. return current.col + current.colspan - 1 + offset <= fillRange.to.column;
  49581. default:
  49582. return null;
  49583. }
  49584. };
  49585. var fillOffset = 0;
  49586. var current = null;
  49587. var multiplier = 1;
  49588. do {
  49589. for (var j = 0; j < foundMergedCells.length; j += 1) {
  49590. current = foundMergedCells[j];
  49591. fillOffset = multiplier * this.currentFillData.cycleLength;
  49592. if (inBounds(current, fillOffset)) {
  49593. switch (dragDirection) {
  49594. case 'up':
  49595. this.plugin.mergedCellsCollection.add({
  49596. row: current.row - fillOffset,
  49597. rowspan: current.rowspan,
  49598. col: current.col,
  49599. colspan: current.colspan
  49600. });
  49601. break;
  49602. case 'down':
  49603. this.plugin.mergedCellsCollection.add({
  49604. row: current.row + fillOffset,
  49605. rowspan: current.rowspan,
  49606. col: current.col,
  49607. colspan: current.colspan
  49608. });
  49609. break;
  49610. case 'left':
  49611. this.plugin.mergedCellsCollection.add({
  49612. row: current.row,
  49613. rowspan: current.rowspan,
  49614. col: current.col - fillOffset,
  49615. colspan: current.colspan
  49616. });
  49617. break;
  49618. case 'right':
  49619. this.plugin.mergedCellsCollection.add({
  49620. row: current.row,
  49621. rowspan: current.rowspan,
  49622. col: current.col + fillOffset,
  49623. colspan: current.colspan
  49624. });
  49625. break;
  49626. default:
  49627. }
  49628. }
  49629. if (j === foundMergedCells.length - 1) {
  49630. multiplier += 1;
  49631. }
  49632. }
  49633. } while (inBounds(current, fillOffset));
  49634. this.currentFillData = null;
  49635. this.plugin.hot.render();
  49636. }
  49637. /**
  49638. * Get the drag range from the changes made.
  49639. *
  49640. * @private
  49641. * @param {Array} changes The changes made.
  49642. * @returns {Object} Object with `from` and `to` properties, both containing `row` and `column` keys.
  49643. */
  49644. }, {
  49645. key: 'getRangeFromChanges',
  49646. value: function getRangeFromChanges(changes) {
  49647. var rows = { min: null, max: null };
  49648. var columns = { min: null, max: null };
  49649. (0, _array.arrayEach)(changes, function (change) {
  49650. if (rows.min === null || change[0] < rows.min) {
  49651. rows.min = change[0];
  49652. }
  49653. if (rows.max === null || change[0] > rows.max) {
  49654. rows.max = change[0];
  49655. }
  49656. if (columns.min === null || change[1] < columns.min) {
  49657. columns.min = change[1];
  49658. }
  49659. if (columns.max === null || change[1] > columns.max) {
  49660. columns.max = change[1];
  49661. }
  49662. });
  49663. return {
  49664. from: {
  49665. row: rows.min,
  49666. column: columns.min
  49667. },
  49668. to: {
  49669. row: rows.max,
  49670. column: columns.max
  49671. }
  49672. };
  49673. }
  49674. /**
  49675. * Check if the drag area contains any merged cells.
  49676. *
  49677. * @param {Array} baseArea The base selection area.
  49678. * @param {Array} fullArea The base area extended by the drag area.
  49679. * @param {String} direction Drag direction.
  49680. * @returns {Boolean}
  49681. */
  49682. }, {
  49683. key: 'dragAreaOverlapsCollections',
  49684. value: function dragAreaOverlapsCollections(baseArea, fullArea, direction) {
  49685. var dragArea = this.getDragArea(baseArea, fullArea, direction);
  49686. var _dragArea3 = _slicedToArray(dragArea, 4),
  49687. dragAreaStartRow = _dragArea3[0],
  49688. dragAreaStartColumn = _dragArea3[1],
  49689. dragAreaEndRow = _dragArea3[2],
  49690. dragAreaEndColumn = _dragArea3[3];
  49691. var topLeft = new _src.CellCoords(dragAreaStartRow, dragAreaStartColumn);
  49692. var bottomRight = new _src.CellCoords(dragAreaEndRow, dragAreaEndColumn);
  49693. var dragRange = new _src.CellRange(topLeft, topLeft, bottomRight);
  49694. return !!this.mergedCellsCollection.getWithinRange(dragRange, true);
  49695. }
  49696. }]);
  49697. return AutofillCalculations;
  49698. }();
  49699. exports.default = AutofillCalculations;
  49700. /***/ }),
  49701. /* 469 */
  49702. /***/ (function(module, exports, __webpack_require__) {
  49703. "use strict";
  49704. exports.__esModule = true;
  49705. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  49706. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  49707. var _src = __webpack_require__(4);
  49708. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  49709. /**
  49710. * Class responsible for all of the Selection-related operations on merged cells.
  49711. *
  49712. * @class SelectionCalculations
  49713. * @plugin MergeCells
  49714. * @util
  49715. */
  49716. var SelectionCalculations = function () {
  49717. function SelectionCalculations(plugin) {
  49718. _classCallCheck(this, SelectionCalculations);
  49719. /**
  49720. * Reference to the Merge Cells plugin.
  49721. *
  49722. * @type {MergeCells}
  49723. */
  49724. this.plugin = plugin;
  49725. /**
  49726. * Class name used for fully selected merged cells.
  49727. *
  49728. * @type {String}
  49729. */
  49730. this.fullySelectedMergedCellClassName = 'fullySelectedMergedCell';
  49731. }
  49732. /**
  49733. * "Snap" the delta value according to defined merged cells. (In other words, compensate the rowspan -
  49734. * e.g. going up with `delta.row = -1` over a merged cell with `rowspan = 3`, `delta.row` should change to `-3`.)
  49735. *
  49736. * @param {Object} delta The delta object containing `row` and `col` properties.
  49737. * @param {CellRange} selectionRange The selection range.
  49738. * @param {Object} mergedCell A merged cell object.
  49739. */
  49740. _createClass(SelectionCalculations, [{
  49741. key: 'snapDelta',
  49742. value: function snapDelta(delta, selectionRange, mergedCell) {
  49743. var cellCoords = selectionRange.to;
  49744. var newRow = cellCoords.row + delta.row;
  49745. var newColumn = cellCoords.col + delta.col;
  49746. if (delta.row) {
  49747. this.jumpOverMergedCell(delta, mergedCell, newRow);
  49748. } else if (delta.col) {
  49749. this.jumpOverMergedCell(delta, mergedCell, newColumn);
  49750. }
  49751. }
  49752. /**
  49753. * "Jump" over the merged cell (compensate for the indexes within the merged cell to get past it)
  49754. *
  49755. * @private
  49756. * @param {Object} delta The delta object.
  49757. * @param {MergedCellCoords} mergedCell The merge cell object.
  49758. * @param {Number} newIndex New row/column index, created with the delta.
  49759. */
  49760. }, {
  49761. key: 'jumpOverMergedCell',
  49762. value: function jumpOverMergedCell(delta, mergedCell, newIndex) {
  49763. var flatDelta = delta.row || delta.col;
  49764. var includesIndex = null;
  49765. var firstIndex = null;
  49766. var lastIndex = null;
  49767. if (delta.row) {
  49768. includesIndex = mergedCell.includesVertically(newIndex);
  49769. firstIndex = mergedCell.row;
  49770. lastIndex = mergedCell.getLastRow();
  49771. } else if (delta.col) {
  49772. includesIndex = mergedCell.includesHorizontally(newIndex);
  49773. firstIndex = mergedCell.col;
  49774. lastIndex = mergedCell.getLastColumn();
  49775. }
  49776. if (flatDelta === 0) {
  49777. return;
  49778. } else if (flatDelta > 0) {
  49779. if (includesIndex && newIndex !== firstIndex) {
  49780. flatDelta += lastIndex - newIndex + 1;
  49781. }
  49782. } else if (includesIndex && newIndex !== lastIndex) {
  49783. flatDelta -= newIndex - firstIndex + 1;
  49784. }
  49785. if (delta.row) {
  49786. delta.row = flatDelta;
  49787. } else if (delta.col) {
  49788. delta.col = flatDelta;
  49789. }
  49790. }
  49791. /**
  49792. * Get a selection range with `to` property incremented by the provided delta.
  49793. *
  49794. * @param {CellRange} oldSelectionRange The base selection range.
  49795. * @param {Object} delta The delta object with `row` and `col` properties.
  49796. * @returns {CellRange} A new `CellRange` object.
  49797. */
  49798. }, {
  49799. key: 'getUpdatedSelectionRange',
  49800. value: function getUpdatedSelectionRange(oldSelectionRange, delta) {
  49801. return new _src.CellRange(oldSelectionRange.highlight, oldSelectionRange.from, new _src.CellCoords(oldSelectionRange.to.row + delta.row, oldSelectionRange.to.col + delta.col));
  49802. }
  49803. /**
  49804. * Generate an additional class name for the entirely-selected merged cells.
  49805. *
  49806. * @param {Number} currentRow Row index of the currently processed cell.
  49807. * @param {Number} currentColumn Column index of the currently cell.
  49808. * @param {Array} cornersOfSelection Array of the current selection in a form of `[startRow, startColumn, endRow, endColumn]`.
  49809. * @param {Number|undefined} layerLevel Number indicating which layer of selection is currently processed.
  49810. * @returns {String|undefined} A `String`, which will act as an additional `className` to be added to the currently processed cell.
  49811. */
  49812. }, {
  49813. key: 'getSelectedMergedCellClassName',
  49814. value: function getSelectedMergedCellClassName(currentRow, currentColumn, cornersOfSelection, layerLevel) {
  49815. var _cornersOfSelection = _slicedToArray(cornersOfSelection, 4),
  49816. startRow = _cornersOfSelection[0],
  49817. startColumn = _cornersOfSelection[1],
  49818. endRow = _cornersOfSelection[2],
  49819. endColumn = _cornersOfSelection[3];
  49820. if (layerLevel === void 0) {
  49821. return;
  49822. }
  49823. if (currentRow >= startRow && currentRow <= endRow && currentColumn >= startColumn && currentColumn <= endColumn) {
  49824. var isMergedCellParent = this.plugin.mergedCellsCollection.isMergedParent(currentRow, currentColumn);
  49825. if (!isMergedCellParent) {
  49826. return;
  49827. }
  49828. var mergedCell = this.plugin.mergedCellsCollection.get(currentRow, currentColumn);
  49829. if (!mergedCell) {
  49830. return;
  49831. }
  49832. if (mergedCell.row + mergedCell.rowspan - 1 <= endRow && mergedCell.col + mergedCell.colspan - 1 <= endColumn) {
  49833. return this.fullySelectedMergedCellClassName + '-' + layerLevel;
  49834. } else if (this.plugin.selectionCalculations.isMergeCellFullySelected(mergedCell, this.plugin.hot.getSelectedRange())) {
  49835. return this.fullySelectedMergedCellClassName + '-multiple';
  49836. }
  49837. }
  49838. }
  49839. /**
  49840. * Check if the provided merged cell is fully selected (by one or many layers of selection)
  49841. *
  49842. * @param {MergedCellCoords} mergedCell The merged cell to be processed.
  49843. * @param {CellRange[]} selectionRangesArray Array of selection ranges.
  49844. * @returns {Boolean}
  49845. */
  49846. }, {
  49847. key: 'isMergeCellFullySelected',
  49848. value: function isMergeCellFullySelected(mergedCell, selectionRangesArray) {
  49849. var mergedCellIndividualCoords = [];
  49850. if (!selectionRangesArray || !mergedCell) {
  49851. return false;
  49852. }
  49853. for (var r = 0; r < mergedCell.rowspan; r += 1) {
  49854. for (var c = 0; c < mergedCell.colspan; c += 1) {
  49855. mergedCellIndividualCoords.push(new _src.CellCoords(mergedCell.row + r, mergedCell.col + c));
  49856. }
  49857. }
  49858. for (var i = 0; i < mergedCellIndividualCoords.length; i += 1) {
  49859. var insideSelections = [];
  49860. for (var s = 0; s < selectionRangesArray.length; s += 1) {
  49861. insideSelections[s] = selectionRangesArray[s].includes(mergedCellIndividualCoords[i]);
  49862. }
  49863. if (!insideSelections.includes(true)) {
  49864. return false;
  49865. }
  49866. }
  49867. return true;
  49868. }
  49869. /**
  49870. * Generate an array of the entirely-selected merged cells' class names.
  49871. *
  49872. * @returns {String[]} An `Array` of `String`s. Each of these strings will act like class names to be removed from all the cells in the table.
  49873. */
  49874. }, {
  49875. key: 'getSelectedMergedCellClassNameToRemove',
  49876. value: function getSelectedMergedCellClassNameToRemove() {
  49877. var classNames = [];
  49878. for (var i = 0; i <= 7; i += 1) {
  49879. classNames.push(this.fullySelectedMergedCellClassName + '-' + i);
  49880. }
  49881. classNames.push(this.fullySelectedMergedCellClassName + '-multiple');
  49882. return classNames;
  49883. }
  49884. }]);
  49885. return SelectionCalculations;
  49886. }();
  49887. exports.default = SelectionCalculations;
  49888. /***/ }),
  49889. /* 470 */
  49890. /***/ (function(module, exports, __webpack_require__) {
  49891. "use strict";
  49892. exports.__esModule = true;
  49893. exports.default = toggleMergeItem;
  49894. var _constants = __webpack_require__(7);
  49895. var C = _interopRequireWildcard(_constants);
  49896. var _cellCoords = __webpack_require__(95);
  49897. var _cellCoords2 = _interopRequireDefault(_cellCoords);
  49898. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  49899. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  49900. function toggleMergeItem(plugin) {
  49901. return {
  49902. key: 'mergeCells',
  49903. name: function name() {
  49904. var sel = this.getSelectedLast();
  49905. if (sel) {
  49906. var info = plugin.mergedCellsCollection.get(sel[0], sel[1]);
  49907. if (info.row === sel[0] && info.col === sel[1] && info.row + info.rowspan - 1 === sel[2] && info.col + info.colspan - 1 === sel[3]) {
  49908. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_UNMERGE_CELLS);
  49909. }
  49910. }
  49911. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_MERGE_CELLS);
  49912. },
  49913. callback: function callback() {
  49914. plugin.toggleMergeOnSelection();
  49915. },
  49916. disabled: function disabled() {
  49917. var sel = this.getSelectedLast();
  49918. if (!sel) {
  49919. return true;
  49920. }
  49921. var isSingleCell = _cellCoords2.default.isSingleCell({
  49922. row: sel[0],
  49923. col: sel[1],
  49924. rowspan: sel[2] - sel[0] + 1,
  49925. colspan: sel[3] - sel[1] + 1
  49926. });
  49927. return isSingleCell || this.selection.isSelectedByCorner();
  49928. },
  49929. hidden: false
  49930. };
  49931. }
  49932. /***/ }),
  49933. /* 471 */
  49934. /***/ (function(module, exports) {
  49935. // removed by extract-text-webpack-plugin
  49936. /***/ }),
  49937. /* 472 */
  49938. /***/ (function(module, exports, __webpack_require__) {
  49939. "use strict";
  49940. exports.__esModule = true;
  49941. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  49942. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  49943. var _pluginHooks = __webpack_require__(15);
  49944. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  49945. var _element = __webpack_require__(0);
  49946. var _browser = __webpack_require__(27);
  49947. var _base = __webpack_require__(10);
  49948. var _base2 = _interopRequireDefault(_base);
  49949. var _eventManager = __webpack_require__(6);
  49950. var _eventManager2 = _interopRequireDefault(_eventManager);
  49951. var _plugins = __webpack_require__(8);
  49952. var _src = __webpack_require__(4);
  49953. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  49954. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  49955. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  49956. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  49957. /**
  49958. * @private
  49959. * @plugin MultipleSelectionHandles
  49960. */
  49961. var MultipleSelectionHandles = function (_BasePlugin) {
  49962. _inherits(MultipleSelectionHandles, _BasePlugin);
  49963. /**
  49964. * @param {Object} hotInstance
  49965. */
  49966. function MultipleSelectionHandles(hotInstance) {
  49967. _classCallCheck(this, MultipleSelectionHandles);
  49968. /**
  49969. * @type {Array}
  49970. */
  49971. var _this2 = _possibleConstructorReturn(this, (MultipleSelectionHandles.__proto__ || Object.getPrototypeOf(MultipleSelectionHandles)).call(this, hotInstance));
  49972. _this2.dragged = [];
  49973. /**
  49974. * Instance of EventManager.
  49975. *
  49976. * @type {EventManager}
  49977. */
  49978. _this2.eventManager = null;
  49979. /**
  49980. * @type {null}
  49981. */
  49982. _this2.lastSetCell = null;
  49983. return _this2;
  49984. }
  49985. /**
  49986. * Check if the plugin is enabled in the handsontable settings.
  49987. *
  49988. * @returns {Boolean}
  49989. */
  49990. _createClass(MultipleSelectionHandles, [{
  49991. key: 'isEnabled',
  49992. value: function isEnabled() {
  49993. return (0, _browser.isMobileBrowser)();
  49994. }
  49995. /**
  49996. * Enable plugin for this Handsontable instance.
  49997. */
  49998. }, {
  49999. key: 'enablePlugin',
  50000. value: function enablePlugin() {
  50001. if (this.enabled) {
  50002. return;
  50003. }
  50004. if (!this.eventManager) {
  50005. this.eventManager = new _eventManager2.default(this);
  50006. }
  50007. this.registerListeners();
  50008. _get(MultipleSelectionHandles.prototype.__proto__ || Object.getPrototypeOf(MultipleSelectionHandles.prototype), 'enablePlugin', this).call(this);
  50009. }
  50010. /**
  50011. * Bind the touch events
  50012. * @private
  50013. */
  50014. }, {
  50015. key: 'registerListeners',
  50016. value: function registerListeners() {
  50017. var _this = this;
  50018. function removeFromDragged(query) {
  50019. if (_this.dragged.length === 1) {
  50020. // clear array
  50021. _this.dragged.splice(0, _this.dragged.length);
  50022. return true;
  50023. }
  50024. var entryPosition = _this.dragged.indexOf(query);
  50025. if (entryPosition == -1) {
  50026. return false;
  50027. } else if (entryPosition === 0) {
  50028. _this.dragged = _this.dragged.slice(0, 1);
  50029. } else if (entryPosition == 1) {
  50030. _this.dragged = _this.dragged.slice(-1);
  50031. }
  50032. }
  50033. this.eventManager.addEventListener(this.hot.rootElement, 'touchstart', function (event) {
  50034. var selectedRange = void 0;
  50035. if ((0, _element.hasClass)(event.target, 'topLeftSelectionHandle-HitArea')) {
  50036. selectedRange = _this.hot.getSelectedRangeLast();
  50037. _this.dragged.push('topLeft');
  50038. _this.touchStartRange = {
  50039. width: selectedRange.getWidth(),
  50040. height: selectedRange.getHeight(),
  50041. direction: selectedRange.getDirection()
  50042. };
  50043. event.preventDefault();
  50044. return false;
  50045. } else if ((0, _element.hasClass)(event.target, 'bottomRightSelectionHandle-HitArea')) {
  50046. selectedRange = _this.hot.getSelectedRangeLast();
  50047. _this.dragged.push('bottomRight');
  50048. _this.touchStartRange = {
  50049. width: selectedRange.getWidth(),
  50050. height: selectedRange.getHeight(),
  50051. direction: selectedRange.getDirection()
  50052. };
  50053. event.preventDefault();
  50054. return false;
  50055. }
  50056. });
  50057. this.eventManager.addEventListener(this.hot.rootElement, 'touchend', function (event) {
  50058. if ((0, _element.hasClass)(event.target, 'topLeftSelectionHandle-HitArea')) {
  50059. removeFromDragged.call(_this, 'topLeft');
  50060. _this.touchStartRange = void 0;
  50061. event.preventDefault();
  50062. return false;
  50063. } else if ((0, _element.hasClass)(event.target, 'bottomRightSelectionHandle-HitArea')) {
  50064. removeFromDragged.call(_this, 'bottomRight');
  50065. _this.touchStartRange = void 0;
  50066. event.preventDefault();
  50067. return false;
  50068. }
  50069. });
  50070. this.eventManager.addEventListener(this.hot.rootElement, 'touchmove', function (event) {
  50071. var scrollTop = (0, _element.getWindowScrollTop)(),
  50072. scrollLeft = (0, _element.getWindowScrollLeft)(),
  50073. endTarget = void 0,
  50074. targetCoords = void 0,
  50075. selectedRange = void 0,
  50076. rangeWidth = void 0,
  50077. rangeHeight = void 0,
  50078. rangeDirection = void 0,
  50079. newRangeCoords = void 0;
  50080. if (_this.dragged.length === 0) {
  50081. return;
  50082. }
  50083. endTarget = document.elementFromPoint(event.touches[0].screenX - scrollLeft, event.touches[0].screenY - scrollTop);
  50084. if (!endTarget || endTarget === _this.lastSetCell) {
  50085. return;
  50086. }
  50087. if (endTarget.nodeName == 'TD' || endTarget.nodeName == 'TH') {
  50088. targetCoords = _this.hot.getCoords(endTarget);
  50089. if (targetCoords.col == -1) {
  50090. targetCoords.col = 0;
  50091. }
  50092. selectedRange = _this.hot.getSelectedRangeLast();
  50093. rangeWidth = selectedRange.getWidth();
  50094. rangeHeight = selectedRange.getHeight();
  50095. rangeDirection = selectedRange.getDirection();
  50096. if (rangeWidth == 1 && rangeHeight == 1) {
  50097. _this.hot.selection.setRangeEnd(targetCoords);
  50098. }
  50099. newRangeCoords = _this.getCurrentRangeCoords(selectedRange, targetCoords, _this.touchStartRange.direction, rangeDirection, _this.dragged[0]);
  50100. if (newRangeCoords.start !== null) {
  50101. _this.hot.selection.setRangeStart(newRangeCoords.start);
  50102. }
  50103. _this.hot.selection.setRangeEnd(newRangeCoords.end);
  50104. _this.lastSetCell = endTarget;
  50105. }
  50106. event.preventDefault();
  50107. });
  50108. }
  50109. }, {
  50110. key: 'getCurrentRangeCoords',
  50111. value: function getCurrentRangeCoords(selectedRange, currentTouch, touchStartDirection, currentDirection, draggedHandle) {
  50112. var topLeftCorner = selectedRange.getTopLeftCorner(),
  50113. bottomRightCorner = selectedRange.getBottomRightCorner(),
  50114. bottomLeftCorner = selectedRange.getBottomLeftCorner(),
  50115. topRightCorner = selectedRange.getTopRightCorner();
  50116. var newCoords = {
  50117. start: null,
  50118. end: null
  50119. };
  50120. switch (touchStartDirection) {
  50121. case 'NE-SW':
  50122. switch (currentDirection) {
  50123. case 'NE-SW':
  50124. case 'NW-SE':
  50125. if (draggedHandle == 'topLeft') {
  50126. newCoords = {
  50127. start: new _src.CellCoords(currentTouch.row, selectedRange.highlight.col),
  50128. end: new _src.CellCoords(bottomLeftCorner.row, currentTouch.col)
  50129. };
  50130. } else {
  50131. newCoords = {
  50132. start: new _src.CellCoords(selectedRange.highlight.row, currentTouch.col),
  50133. end: new _src.CellCoords(currentTouch.row, topLeftCorner.col)
  50134. };
  50135. }
  50136. break;
  50137. case 'SE-NW':
  50138. if (draggedHandle == 'bottomRight') {
  50139. newCoords = {
  50140. start: new _src.CellCoords(bottomRightCorner.row, currentTouch.col),
  50141. end: new _src.CellCoords(currentTouch.row, topLeftCorner.col)
  50142. };
  50143. }
  50144. break;
  50145. default:
  50146. break;
  50147. }
  50148. break;
  50149. case 'NW-SE':
  50150. switch (currentDirection) {
  50151. case 'NE-SW':
  50152. if (draggedHandle == 'topLeft') {
  50153. newCoords = {
  50154. start: currentTouch,
  50155. end: bottomLeftCorner
  50156. };
  50157. } else {
  50158. newCoords.end = currentTouch;
  50159. }
  50160. break;
  50161. case 'NW-SE':
  50162. if (draggedHandle == 'topLeft') {
  50163. newCoords = {
  50164. start: currentTouch,
  50165. end: bottomRightCorner
  50166. };
  50167. } else {
  50168. newCoords.end = currentTouch;
  50169. }
  50170. break;
  50171. case 'SE-NW':
  50172. if (draggedHandle == 'topLeft') {
  50173. newCoords = {
  50174. start: currentTouch,
  50175. end: topLeftCorner
  50176. };
  50177. } else {
  50178. newCoords.end = currentTouch;
  50179. }
  50180. break;
  50181. case 'SW-NE':
  50182. if (draggedHandle == 'topLeft') {
  50183. newCoords = {
  50184. start: currentTouch,
  50185. end: topRightCorner
  50186. };
  50187. } else {
  50188. newCoords.end = currentTouch;
  50189. }
  50190. break;
  50191. default:
  50192. break;
  50193. }
  50194. break;
  50195. case 'SW-NE':
  50196. switch (currentDirection) {
  50197. case 'NW-SE':
  50198. if (draggedHandle == 'bottomRight') {
  50199. newCoords = {
  50200. start: new _src.CellCoords(currentTouch.row, topLeftCorner.col),
  50201. end: new _src.CellCoords(bottomLeftCorner.row, currentTouch.col)
  50202. };
  50203. } else {
  50204. newCoords = {
  50205. start: new _src.CellCoords(topLeftCorner.row, currentTouch.col),
  50206. end: new _src.CellCoords(currentTouch.row, bottomRightCorner.col)
  50207. };
  50208. }
  50209. break;
  50210. // case 'NE-SW':
  50211. //
  50212. // break;
  50213. case 'SW-NE':
  50214. if (draggedHandle == 'topLeft') {
  50215. newCoords = {
  50216. start: new _src.CellCoords(selectedRange.highlight.row, currentTouch.col),
  50217. end: new _src.CellCoords(currentTouch.row, bottomRightCorner.col)
  50218. };
  50219. } else {
  50220. newCoords = {
  50221. start: new _src.CellCoords(currentTouch.row, topLeftCorner.col),
  50222. end: new _src.CellCoords(topLeftCorner.row, currentTouch.col)
  50223. };
  50224. }
  50225. break;
  50226. case 'SE-NW':
  50227. if (draggedHandle == 'bottomRight') {
  50228. newCoords = {
  50229. start: new _src.CellCoords(currentTouch.row, topRightCorner.col),
  50230. end: new _src.CellCoords(topLeftCorner.row, currentTouch.col)
  50231. };
  50232. } else if (draggedHandle == 'topLeft') {
  50233. newCoords = {
  50234. start: bottomLeftCorner,
  50235. end: currentTouch
  50236. };
  50237. }
  50238. break;
  50239. default:
  50240. break;
  50241. }
  50242. break;
  50243. case 'SE-NW':
  50244. switch (currentDirection) {
  50245. case 'NW-SE':
  50246. case 'NE-SW':
  50247. case 'SW-NE':
  50248. if (draggedHandle == 'topLeft') {
  50249. newCoords.end = currentTouch;
  50250. }
  50251. break;
  50252. case 'SE-NW':
  50253. if (draggedHandle == 'topLeft') {
  50254. newCoords.end = currentTouch;
  50255. } else {
  50256. newCoords = {
  50257. start: currentTouch,
  50258. end: topLeftCorner
  50259. };
  50260. }
  50261. break;
  50262. default:
  50263. break;
  50264. }
  50265. break;
  50266. default:
  50267. break;
  50268. }
  50269. return newCoords;
  50270. }
  50271. /**
  50272. * Check if user is currently dragging the handle.
  50273. *
  50274. * @returns {boolean} Dragging state
  50275. */
  50276. }, {
  50277. key: 'isDragged',
  50278. value: function isDragged() {
  50279. return this.dragged.length > 0;
  50280. }
  50281. }]);
  50282. return MultipleSelectionHandles;
  50283. }(_base2.default);
  50284. (0, _plugins.registerPlugin)('multipleSelectionHandles', MultipleSelectionHandles);
  50285. exports.default = MultipleSelectionHandles;
  50286. /***/ }),
  50287. /* 473 */
  50288. /***/ (function(module, exports, __webpack_require__) {
  50289. "use strict";
  50290. exports.__esModule = true;
  50291. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  50292. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  50293. var _base = __webpack_require__(10);
  50294. var _base2 = _interopRequireDefault(_base);
  50295. var _jsonPatchDuplex = __webpack_require__(325);
  50296. var _jsonPatchDuplex2 = _interopRequireDefault(_jsonPatchDuplex);
  50297. var _dataObserver = __webpack_require__(474);
  50298. var _dataObserver2 = _interopRequireDefault(_dataObserver);
  50299. var _array = __webpack_require__(1);
  50300. var _plugins = __webpack_require__(8);
  50301. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  50302. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  50303. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  50304. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  50305. // Handsontable.hooks.register('afterChangesObserved');
  50306. /**
  50307. * @plugin ObserveChanges
  50308. *
  50309. * @description
  50310. * This plugin allows to observe data source changes.
  50311. *
  50312. * By default, the plugin is declared as `undefined`, which makes it disabled.
  50313. * Enabling this plugin switches the table into one-way data binding where changes are applied into the data source (outside from the table)
  50314. * will be automatically reflected in the table.
  50315. *
  50316. * ```js
  50317. * ...
  50318. * // as a boolean
  50319. * observeChanges: true,
  50320. * ...
  50321. * ```
  50322. *
  50323. * To configure this plugin see {@link Options#observeChanges}.
  50324. */
  50325. var ObserveChanges = function (_BasePlugin) {
  50326. _inherits(ObserveChanges, _BasePlugin);
  50327. function ObserveChanges(hotInstance) {
  50328. _classCallCheck(this, ObserveChanges);
  50329. /**
  50330. * Instance of {@link DataObserver}.
  50331. *
  50332. * @type {DataObserver}
  50333. */
  50334. var _this = _possibleConstructorReturn(this, (ObserveChanges.__proto__ || Object.getPrototypeOf(ObserveChanges)).call(this, hotInstance));
  50335. _this.observer = null;
  50336. return _this;
  50337. }
  50338. /**
  50339. * Check if the plugin is enabled in the handsontable settings.
  50340. *
  50341. * @returns {Boolean}
  50342. */
  50343. _createClass(ObserveChanges, [{
  50344. key: 'isEnabled',
  50345. value: function isEnabled() {
  50346. return this.hot.getSettings().observeChanges;
  50347. }
  50348. /**
  50349. * Enable plugin for this Handsontable instance.
  50350. */
  50351. }, {
  50352. key: 'enablePlugin',
  50353. value: function enablePlugin() {
  50354. var _this2 = this;
  50355. if (this.enabled) {
  50356. return;
  50357. }
  50358. if (!this.observer) {
  50359. this.observer = new _dataObserver2.default(this.hot.getSourceData());
  50360. this._exposePublicApi();
  50361. }
  50362. this.observer.addLocalHook('change', function (patches) {
  50363. return _this2.onDataChange(patches);
  50364. });
  50365. this.addHook('afterCreateRow', function () {
  50366. return _this2.onAfterTableAlter();
  50367. });
  50368. this.addHook('afterRemoveRow', function () {
  50369. return _this2.onAfterTableAlter();
  50370. });
  50371. this.addHook('afterCreateCol', function () {
  50372. return _this2.onAfterTableAlter();
  50373. });
  50374. this.addHook('afterRemoveCol', function () {
  50375. return _this2.onAfterTableAlter();
  50376. });
  50377. this.addHook('afterChange', function (changes, source) {
  50378. return _this2.onAfterTableAlter(source);
  50379. });
  50380. this.addHook('afterLoadData', function (firstRun) {
  50381. return _this2.onAfterLoadData(firstRun);
  50382. });
  50383. _get(ObserveChanges.prototype.__proto__ || Object.getPrototypeOf(ObserveChanges.prototype), 'enablePlugin', this).call(this);
  50384. }
  50385. /**
  50386. * Disable plugin for this Handsontable instance.
  50387. */
  50388. }, {
  50389. key: 'disablePlugin',
  50390. value: function disablePlugin() {
  50391. if (this.observer) {
  50392. this.observer.destroy();
  50393. this.observer = null;
  50394. this._deletePublicApi();
  50395. }
  50396. _get(ObserveChanges.prototype.__proto__ || Object.getPrototypeOf(ObserveChanges.prototype), 'disablePlugin', this).call(this);
  50397. }
  50398. /**
  50399. * Data change observer.
  50400. *
  50401. * @private
  50402. * @param {Array} patches An array of objects which every item defines coordinates where data was changed.
  50403. */
  50404. }, {
  50405. key: 'onDataChange',
  50406. value: function onDataChange(patches) {
  50407. var _this3 = this;
  50408. if (!this.observer.isPaused()) {
  50409. var sourceName = this.pluginName + '.change';
  50410. var actions = {
  50411. add: function add(patch) {
  50412. if (isNaN(patch.col)) {
  50413. _this3.hot.runHooks('afterCreateRow', patch.row, 1, sourceName);
  50414. } else {
  50415. _this3.hot.runHooks('afterCreateCol', patch.col, 1, sourceName);
  50416. }
  50417. },
  50418. remove: function remove(patch) {
  50419. if (isNaN(patch.col)) {
  50420. _this3.hot.runHooks('afterRemoveRow', patch.row, 1, sourceName);
  50421. } else {
  50422. _this3.hot.runHooks('afterRemoveCol', patch.col, 1, sourceName);
  50423. }
  50424. },
  50425. replace: function replace(patch) {
  50426. _this3.hot.runHooks('afterChange', [[patch.row, patch.col, null, patch.value]], sourceName);
  50427. }
  50428. };
  50429. (0, _array.arrayEach)(patches, function (patch) {
  50430. if (actions[patch.op]) {
  50431. actions[patch.op](patch);
  50432. }
  50433. });
  50434. this.hot.render();
  50435. }
  50436. this.hot.runHooks('afterChangesObserved');
  50437. }
  50438. /**
  50439. * On after table alter listener. Prevents infinity loop between internal and external data changing.
  50440. *
  50441. * @private
  50442. * @param source
  50443. */
  50444. }, {
  50445. key: 'onAfterTableAlter',
  50446. value: function onAfterTableAlter(source) {
  50447. var _this4 = this;
  50448. if (source !== 'loadData') {
  50449. this.observer.pause();
  50450. this.hot.addHookOnce('afterChangesObserved', function () {
  50451. return _this4.observer.resume();
  50452. });
  50453. }
  50454. }
  50455. /**
  50456. * On after load data listener.
  50457. *
  50458. * @private
  50459. * @param {Boolean} firstRun `true` if event was fired first time.
  50460. */
  50461. }, {
  50462. key: 'onAfterLoadData',
  50463. value: function onAfterLoadData(firstRun) {
  50464. if (!firstRun) {
  50465. this.observer.setObservedData(this.hot.getSourceData());
  50466. }
  50467. }
  50468. /**
  50469. * Destroy plugin instance.
  50470. */
  50471. }, {
  50472. key: 'destroy',
  50473. value: function destroy() {
  50474. if (this.observer) {
  50475. this.observer.destroy();
  50476. this._deletePublicApi();
  50477. }
  50478. _get(ObserveChanges.prototype.__proto__ || Object.getPrototypeOf(ObserveChanges.prototype), 'destroy', this).call(this);
  50479. }
  50480. /**
  50481. * Expose plugins methods to the core.
  50482. *
  50483. * @private
  50484. */
  50485. }, {
  50486. key: '_exposePublicApi',
  50487. value: function _exposePublicApi() {
  50488. var _this5 = this;
  50489. var hot = this.hot;
  50490. hot.pauseObservingChanges = function () {
  50491. return _this5.observer.pause();
  50492. };
  50493. hot.resumeObservingChanges = function () {
  50494. return _this5.observer.resume();
  50495. };
  50496. hot.isPausedObservingChanges = function () {
  50497. return _this5.observer.isPaused();
  50498. };
  50499. }
  50500. /**
  50501. * Delete all previously exposed methods.
  50502. *
  50503. * @private
  50504. */
  50505. }, {
  50506. key: '_deletePublicApi',
  50507. value: function _deletePublicApi() {
  50508. var hot = this.hot;
  50509. delete hot.pauseObservingChanges;
  50510. delete hot.resumeObservingChanges;
  50511. delete hot.isPausedObservingChanges;
  50512. }
  50513. }]);
  50514. return ObserveChanges;
  50515. }(_base2.default);
  50516. exports.default = ObserveChanges;
  50517. (0, _plugins.registerPlugin)('observeChanges', ObserveChanges);
  50518. /***/ }),
  50519. /* 474 */
  50520. /***/ (function(module, exports, __webpack_require__) {
  50521. "use strict";
  50522. exports.__esModule = true;
  50523. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  50524. var _jsonPatchDuplex = __webpack_require__(325);
  50525. var _jsonPatchDuplex2 = _interopRequireDefault(_jsonPatchDuplex);
  50526. var _localHooks = __webpack_require__(58);
  50527. var _localHooks2 = _interopRequireDefault(_localHooks);
  50528. var _object = __webpack_require__(2);
  50529. var _utils = __webpack_require__(475);
  50530. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  50531. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  50532. /**
  50533. * @class DataObserver
  50534. * @plugin ObserveChanges
  50535. */
  50536. var DataObserver = function () {
  50537. function DataObserver(observedData) {
  50538. _classCallCheck(this, DataObserver);
  50539. /**
  50540. * Observed source data.
  50541. *
  50542. * @type {Array}
  50543. */
  50544. this.observedData = null;
  50545. /**
  50546. * JsonPatch observer.
  50547. *
  50548. * @type {Object}
  50549. */
  50550. this.observer = null;
  50551. /**
  50552. * Flag which determines if observer is paused or not. Paused observer doesn't emit `change` hooks.
  50553. *
  50554. * @type {Boolean}
  50555. * @default false
  50556. */
  50557. this.paused = false;
  50558. this.setObservedData(observedData);
  50559. }
  50560. /**
  50561. * Set data to observe.
  50562. *
  50563. * @param {*} observedData
  50564. */
  50565. _createClass(DataObserver, [{
  50566. key: 'setObservedData',
  50567. value: function setObservedData(observedData) {
  50568. var _this = this;
  50569. if (this.observer) {
  50570. _jsonPatchDuplex2.default.unobserve(this.observedData, this.observer);
  50571. }
  50572. this.observedData = observedData;
  50573. this.observer = _jsonPatchDuplex2.default.observe(this.observedData, function (patches) {
  50574. return _this.onChange(patches);
  50575. });
  50576. }
  50577. /**
  50578. * Check if observer was paused.
  50579. *
  50580. * @returns {Boolean}
  50581. */
  50582. }, {
  50583. key: 'isPaused',
  50584. value: function isPaused() {
  50585. return this.paused;
  50586. }
  50587. /**
  50588. * Pause observer (stop emitting all detected changes).
  50589. */
  50590. }, {
  50591. key: 'pause',
  50592. value: function pause() {
  50593. this.paused = true;
  50594. }
  50595. /**
  50596. * Resume observer (emit all detected changes).
  50597. */
  50598. }, {
  50599. key: 'resume',
  50600. value: function resume() {
  50601. this.paused = false;
  50602. }
  50603. /**
  50604. * JsonPatch on change listener.
  50605. *
  50606. * @private
  50607. * @param {Array} patches An array of object passed from jsonpatch.
  50608. */
  50609. }, {
  50610. key: 'onChange',
  50611. value: function onChange(patches) {
  50612. this.runLocalHooks('change', (0, _utils.cleanPatches)(patches));
  50613. }
  50614. /**
  50615. * Destroy observer instance.
  50616. */
  50617. }, {
  50618. key: 'destroy',
  50619. value: function destroy() {
  50620. _jsonPatchDuplex2.default.unobserve(this.observedData, this.observer);
  50621. this.observedData = null;
  50622. this.observer = null;
  50623. }
  50624. }]);
  50625. return DataObserver;
  50626. }();
  50627. (0, _object.mixin)(DataObserver, _localHooks2.default);
  50628. exports.default = DataObserver;
  50629. /***/ }),
  50630. /* 475 */
  50631. /***/ (function(module, exports, __webpack_require__) {
  50632. "use strict";
  50633. exports.__esModule = true;
  50634. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  50635. exports.cleanPatches = cleanPatches;
  50636. exports.parsePath = parsePath;
  50637. var _array = __webpack_require__(1);
  50638. /**
  50639. * Clean and extend patches from jsonpatch observer.
  50640. *
  50641. * @param {Array} patches
  50642. * @returns {Array}
  50643. */
  50644. function cleanPatches(patches) {
  50645. var newOrRemovedColumns = [];
  50646. /**
  50647. * If observeChanges uses native Object.observe method, then it produces patches for length property. Filter them.
  50648. * If path can't be parsed. Filter it.
  50649. */
  50650. patches = (0, _array.arrayFilter)(patches, function (patch) {
  50651. if (/[/]length/ig.test(patch.path)) {
  50652. return false;
  50653. }
  50654. if (!parsePath(patch.path)) {
  50655. return false;
  50656. }
  50657. return true;
  50658. });
  50659. /**
  50660. * Extend patches with changed cells coords
  50661. */
  50662. patches = (0, _array.arrayMap)(patches, function (patch) {
  50663. var coords = parsePath(patch.path);
  50664. patch.row = coords.row;
  50665. patch.col = coords.col;
  50666. return patch;
  50667. });
  50668. /**
  50669. * Removing or adding column will produce one patch for each table row.
  50670. * Leaves only one patch for each column add/remove operation.
  50671. */
  50672. patches = (0, _array.arrayFilter)(patches, function (patch) {
  50673. if (['add', 'remove'].indexOf(patch.op) !== -1 && !isNaN(patch.col)) {
  50674. if (newOrRemovedColumns.indexOf(patch.col) !== -1) {
  50675. return false;
  50676. }
  50677. newOrRemovedColumns.push(patch.col);
  50678. }
  50679. return true;
  50680. });
  50681. newOrRemovedColumns.length = 0;
  50682. return patches;
  50683. }
  50684. /**
  50685. * Extract coordinates from path where data was changed.
  50686. *
  50687. * @param {String} path Path describing where data was changed.
  50688. * @returns {Object|null} Returns an object with `row` and `col` properties or `null` if path doesn't have necessary information.
  50689. */
  50690. function parsePath(path) {
  50691. var match = path.match(/^\/(\d+)\/?(.*)?$/);
  50692. if (!match) {
  50693. return null;
  50694. }
  50695. var _match = _slicedToArray(match, 3),
  50696. row = _match[1],
  50697. column = _match[2];
  50698. return {
  50699. row: parseInt(row, 10),
  50700. col: /^\d*$/.test(column) ? parseInt(column, 10) : column
  50701. };
  50702. }
  50703. /***/ }),
  50704. /* 476 */
  50705. /***/ (function(module, exports, __webpack_require__) {
  50706. "use strict";
  50707. exports.__esModule = true;
  50708. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  50709. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  50710. var _base = __webpack_require__(10);
  50711. var _base2 = _interopRequireDefault(_base);
  50712. var _plugins = __webpack_require__(8);
  50713. var _object = __webpack_require__(2);
  50714. var _number = __webpack_require__(5);
  50715. var _mixed = __webpack_require__(16);
  50716. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  50717. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  50718. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  50719. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  50720. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  50721. var DEFAULT_SEARCH_RESULT_CLASS = 'htSearchResult';
  50722. var DEFAULT_CALLBACK = function DEFAULT_CALLBACK(instance, row, col, data, testResult) {
  50723. instance.getCellMeta(row, col).isSearchResult = testResult;
  50724. };
  50725. var DEFAULT_QUERY_METHOD = function DEFAULT_QUERY_METHOD(query, value) {
  50726. if ((0, _mixed.isUndefined)(query) || query === null || !query.toLowerCase || query.length === 0) {
  50727. return false;
  50728. }
  50729. if ((0, _mixed.isUndefined)(value) || value === null) {
  50730. return false;
  50731. }
  50732. return value.toString().toLowerCase().indexOf(query.toLowerCase()) !== -1;
  50733. };
  50734. /**
  50735. * @plugin Search
  50736. *
  50737. * @example
  50738. *
  50739. * ```js
  50740. * ...
  50741. * // as boolean
  50742. * search: true
  50743. *
  50744. * // as a object with one or more options
  50745. * search: {
  50746. * callback: myNewCallbackFunction,
  50747. * queryMethod: myNewQueryMethod,
  50748. * searchResultClass: 'customClass'
  50749. * }
  50750. *
  50751. * // Access to search plugin instance:
  50752. * var searchPlugin = hot.getPlugin('search');
  50753. *
  50754. * // Set callback programmatically:
  50755. * searchPlugin.setCallback(myNewCallbackFunction);
  50756. * // Set query method programmatically:
  50757. * searchPlugin.setQueryMethod(myNewQueryMethod);
  50758. * // Set search result cells class programmatically:
  50759. * searchPlugin.setSearchResultClass(customClass);
  50760. * ...
  50761. * ```
  50762. */
  50763. var Search = function (_BasePlugin) {
  50764. _inherits(Search, _BasePlugin);
  50765. function Search(hotInstance) {
  50766. _classCallCheck(this, Search);
  50767. /**
  50768. * Function called during querying for each cell from the {@link DataMap}.
  50769. *
  50770. * @type {Function}
  50771. */
  50772. var _this = _possibleConstructorReturn(this, (Search.__proto__ || Object.getPrototypeOf(Search)).call(this, hotInstance));
  50773. _this.callback = DEFAULT_CALLBACK;
  50774. /**
  50775. * Query function is responsible for determining whether a query matches the value stored in a cell.
  50776. *
  50777. * @type {Function}
  50778. */
  50779. _this.queryMethod = DEFAULT_QUERY_METHOD;
  50780. /**
  50781. * Class name added to each cell that belongs to the searched query.
  50782. *
  50783. * @type {String}
  50784. */
  50785. _this.searchResultClass = DEFAULT_SEARCH_RESULT_CLASS;
  50786. return _this;
  50787. }
  50788. /**
  50789. * Check if the plugin is enabled in the Handsontable settings.
  50790. *
  50791. * @returns {Boolean}
  50792. */
  50793. _createClass(Search, [{
  50794. key: 'isEnabled',
  50795. value: function isEnabled() {
  50796. return this.hot.getSettings().search;
  50797. }
  50798. /**
  50799. * Enable plugin for this Handsontable instance.
  50800. */
  50801. }, {
  50802. key: 'enablePlugin',
  50803. value: function enablePlugin() {
  50804. var _this2 = this;
  50805. if (this.enabled) {
  50806. return;
  50807. }
  50808. var searchSettings = this.hot.getSettings().search;
  50809. this.updatePluginSettings(searchSettings);
  50810. this.addHook('beforeRenderer', function () {
  50811. return _this2.onBeforeRenderer.apply(_this2, arguments);
  50812. });
  50813. _get(Search.prototype.__proto__ || Object.getPrototypeOf(Search.prototype), 'enablePlugin', this).call(this);
  50814. }
  50815. /**
  50816. * Disable plugin for this Handsontable instance.
  50817. */
  50818. }, {
  50819. key: 'disablePlugin',
  50820. value: function disablePlugin() {
  50821. var _this3 = this;
  50822. var beforeRendererCallback = function beforeRendererCallback() {
  50823. return _this3.onBeforeRenderer.apply(_this3, arguments);
  50824. };
  50825. this.hot.addHook('beforeRenderer', beforeRendererCallback);
  50826. this.hot.addHookOnce('afterRender', function () {
  50827. _this3.hot.removeHook('beforeRenderer', beforeRendererCallback);
  50828. });
  50829. _get(Search.prototype.__proto__ || Object.getPrototypeOf(Search.prototype), 'disablePlugin', this).call(this);
  50830. }
  50831. /**
  50832. * Updates the plugin to use the latest options you have specified.
  50833. */
  50834. }, {
  50835. key: 'updatePlugin',
  50836. value: function updatePlugin() {
  50837. this.disablePlugin();
  50838. this.enablePlugin();
  50839. _get(Search.prototype.__proto__ || Object.getPrototypeOf(Search.prototype), 'updatePlugin', this).call(this);
  50840. }
  50841. /**
  50842. * Query method - used inside search input listener.
  50843. *
  50844. * @param {String} queryStr Searched value.
  50845. * @param {Function} [callback] Callback function performed on cells with values which matches to the searched query.
  50846. * @param {Function} [queryMethod] Query function responsible for determining whether a query matches the value stored in a cell.
  50847. *
  50848. * @returns {Array} Return array of objects with `row`, `col`, `data` properties or empty array.
  50849. */
  50850. }, {
  50851. key: 'query',
  50852. value: function query(queryStr) {
  50853. var _this4 = this;
  50854. var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getCallback();
  50855. var queryMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.getQueryMethod();
  50856. var rowCount = this.hot.countRows();
  50857. var colCount = this.hot.countCols();
  50858. var queryResult = [];
  50859. var instance = this.hot;
  50860. (0, _number.rangeEach)(0, rowCount - 1, function (rowIndex) {
  50861. (0, _number.rangeEach)(0, colCount - 1, function (colIndex) {
  50862. var cellData = _this4.hot.getDataAtCell(rowIndex, colIndex);
  50863. var cellProperties = _this4.hot.getCellMeta(rowIndex, colIndex);
  50864. var cellCallback = cellProperties.search.callback || callback;
  50865. var cellQueryMethod = cellProperties.search.queryMethod || queryMethod;
  50866. var testResult = cellQueryMethod(queryStr, cellData);
  50867. if (testResult) {
  50868. var singleResult = {
  50869. row: rowIndex,
  50870. col: colIndex,
  50871. data: cellData
  50872. };
  50873. queryResult.push(singleResult);
  50874. }
  50875. if (cellCallback) {
  50876. cellCallback(instance, rowIndex, colIndex, cellData, testResult);
  50877. }
  50878. });
  50879. });
  50880. return queryResult;
  50881. }
  50882. }, {
  50883. key: 'getCallback',
  50884. /**
  50885. * Get callback function.
  50886. *
  50887. * @returns {Function} Return the callback function.
  50888. */
  50889. value: function getCallback() {
  50890. return this.callback;
  50891. }
  50892. /**
  50893. * Set callback function.
  50894. *
  50895. * @param {Function} newCallback
  50896. */
  50897. }, {
  50898. key: 'setCallback',
  50899. value: function setCallback(newCallback) {
  50900. this.callback = newCallback;
  50901. }
  50902. /**
  50903. * Get queryMethod function.
  50904. *
  50905. * @returns {Function} Return the query method.
  50906. */
  50907. }, {
  50908. key: 'getQueryMethod',
  50909. value: function getQueryMethod() {
  50910. return this.queryMethod;
  50911. }
  50912. /**
  50913. * Set queryMethod function.
  50914. *
  50915. * @param {Function} newQueryMethod
  50916. */
  50917. }, {
  50918. key: 'setQueryMethod',
  50919. value: function setQueryMethod(newQueryMethod) {
  50920. this.queryMethod = newQueryMethod;
  50921. }
  50922. /**
  50923. * Get search result cells class.
  50924. *
  50925. * @returns {Function} Return the cell class.
  50926. */
  50927. }, {
  50928. key: 'getSearchResultClass',
  50929. value: function getSearchResultClass() {
  50930. return this.searchResultClass;
  50931. }
  50932. /**
  50933. * Set search result cells class.
  50934. *
  50935. * @param {String} newElementClass
  50936. */
  50937. }, {
  50938. key: 'setSearchResultClass',
  50939. value: function setSearchResultClass(newElementClass) {
  50940. this.searchResultClass = newElementClass;
  50941. }
  50942. /**
  50943. * Updates the settings of the plugin.
  50944. *
  50945. * @param {Object} searchSettings The plugin settings, taken from Handsontable configuration.
  50946. * @private
  50947. */
  50948. }, {
  50949. key: 'updatePluginSettings',
  50950. value: function updatePluginSettings(searchSettings) {
  50951. if ((0, _object.isObject)(searchSettings)) {
  50952. if (searchSettings.searchResultClass) {
  50953. this.setSearchResultClass(searchSettings.searchResultClass);
  50954. }
  50955. if (searchSettings.queryMethod) {
  50956. this.setQueryMethod(searchSettings.queryMethod);
  50957. }
  50958. if (searchSettings.callback) {
  50959. this.setCallback(searchSettings.callback);
  50960. }
  50961. }
  50962. }
  50963. /** *
  50964. * The `beforeRenderer` hook callback.
  50965. *
  50966. * @private
  50967. * @param {HTMLTableCellElement} TD The rendered `TD` element.
  50968. * @param {Number} row Visual row index.
  50969. * @param {Number} col Visual column index.
  50970. * @param {String | Number} prop Column property name or a column index, if datasource is an array of arrays.
  50971. * @param {String} value Value of the rendered cell.
  50972. * @param {Object} cellProperties Object containing the cell's properties.
  50973. */
  50974. }, {
  50975. key: 'onBeforeRenderer',
  50976. value: function onBeforeRenderer(TD, row, col, prop, value, cellProperties) {
  50977. // TODO: #4972
  50978. var className = cellProperties.className || [];
  50979. var classArray = [];
  50980. if (typeof className === 'string') {
  50981. classArray = className.split(' ');
  50982. } else {
  50983. var _classArray;
  50984. (_classArray = classArray).push.apply(_classArray, _toConsumableArray(className));
  50985. }
  50986. if (this.isEnabled() && cellProperties.isSearchResult) {
  50987. if (!classArray.includes(this.searchResultClass)) {
  50988. classArray.push('' + this.searchResultClass);
  50989. }
  50990. } else if (classArray.includes(this.searchResultClass)) {
  50991. classArray.splice(classArray.indexOf(this.searchResultClass), 1);
  50992. }
  50993. cellProperties.className = classArray.join(' ');
  50994. }
  50995. /**
  50996. * Destroy plugin instance.
  50997. */
  50998. }, {
  50999. key: 'destroy',
  51000. value: function destroy() {
  51001. _get(Search.prototype.__proto__ || Object.getPrototypeOf(Search.prototype), 'destroy', this).call(this);
  51002. }
  51003. }]);
  51004. return Search;
  51005. }(_base2.default);
  51006. (0, _plugins.registerPlugin)('search', Search);
  51007. exports.default = Search;
  51008. /***/ }),
  51009. /* 477 */
  51010. /***/ (function(module, exports, __webpack_require__) {
  51011. "use strict";
  51012. exports.__esModule = true;
  51013. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  51014. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  51015. var _element = __webpack_require__(0);
  51016. var _array = __webpack_require__(1);
  51017. var _base = __webpack_require__(10);
  51018. var _base2 = _interopRequireDefault(_base);
  51019. var _plugins = __webpack_require__(8);
  51020. var _feature = __webpack_require__(40);
  51021. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  51022. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  51023. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  51024. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  51025. /**
  51026. * @private
  51027. * @plugin TouchScroll
  51028. * @class TouchScroll
  51029. */
  51030. var TouchScroll = function (_BasePlugin) {
  51031. _inherits(TouchScroll, _BasePlugin);
  51032. function TouchScroll(hotInstance) {
  51033. _classCallCheck(this, TouchScroll);
  51034. /**
  51035. * Collection of scrollbars to update.
  51036. *
  51037. * @type {Array}
  51038. */
  51039. var _this = _possibleConstructorReturn(this, (TouchScroll.__proto__ || Object.getPrototypeOf(TouchScroll)).call(this, hotInstance));
  51040. _this.scrollbars = [];
  51041. /**
  51042. * Collection of overlays to update.
  51043. *
  51044. * @type {Array}
  51045. */
  51046. _this.clones = [];
  51047. /**
  51048. * Flag which determines if collection of overlays should be refilled on every table render.
  51049. *
  51050. * @type {Boolean}
  51051. * @default false
  51052. */
  51053. _this.lockedCollection = false;
  51054. /**
  51055. * Flag which determines if walkontable should freeze overlays while scrolling.
  51056. *
  51057. * @type {Boolean}
  51058. * @default false
  51059. */
  51060. _this.freezeOverlays = false;
  51061. return _this;
  51062. }
  51063. /**
  51064. * Check if plugin is enabled.
  51065. *
  51066. * @returns {Boolean}
  51067. */
  51068. _createClass(TouchScroll, [{
  51069. key: 'isEnabled',
  51070. value: function isEnabled() {
  51071. return (0, _feature.isTouchSupported)();
  51072. }
  51073. /**
  51074. * Enable the plugin.
  51075. */
  51076. }, {
  51077. key: 'enablePlugin',
  51078. value: function enablePlugin() {
  51079. var _this2 = this;
  51080. if (this.enabled) {
  51081. return;
  51082. }
  51083. this.addHook('afterRender', function () {
  51084. return _this2.onAfterRender();
  51085. });
  51086. this.registerEvents();
  51087. _get(TouchScroll.prototype.__proto__ || Object.getPrototypeOf(TouchScroll.prototype), 'enablePlugin', this).call(this);
  51088. }
  51089. /**
  51090. * Updates the plugin to use the latest options you have specified.
  51091. */
  51092. }, {
  51093. key: 'updatePlugin',
  51094. value: function updatePlugin() {
  51095. this.lockedCollection = false;
  51096. _get(TouchScroll.prototype.__proto__ || Object.getPrototypeOf(TouchScroll.prototype), 'updatePlugin', this).call(this);
  51097. }
  51098. /**
  51099. * Disable plugin for this Handsontable instance.
  51100. */
  51101. }, {
  51102. key: 'disablePlugin',
  51103. value: function disablePlugin() {
  51104. _get(TouchScroll.prototype.__proto__ || Object.getPrototypeOf(TouchScroll.prototype), 'disablePlugin', this).call(this);
  51105. }
  51106. /**
  51107. * Register all necessary events.
  51108. *
  51109. * @private
  51110. */
  51111. }, {
  51112. key: 'registerEvents',
  51113. value: function registerEvents() {
  51114. var _this3 = this;
  51115. this.addHook('beforeTouchScroll', function () {
  51116. return _this3.onBeforeTouchScroll();
  51117. });
  51118. this.addHook('afterMomentumScroll', function () {
  51119. return _this3.onAfterMomentumScroll();
  51120. });
  51121. }
  51122. /**
  51123. * After render listener.
  51124. *
  51125. * @private
  51126. */
  51127. }, {
  51128. key: 'onAfterRender',
  51129. value: function onAfterRender() {
  51130. if (this.lockedCollection) {
  51131. return;
  51132. }
  51133. var _hot$view$wt$wtOverla = this.hot.view.wt.wtOverlays,
  51134. topOverlay = _hot$view$wt$wtOverla.topOverlay,
  51135. bottomOverlay = _hot$view$wt$wtOverla.bottomOverlay,
  51136. leftOverlay = _hot$view$wt$wtOverla.leftOverlay,
  51137. topLeftCornerOverlay = _hot$view$wt$wtOverla.topLeftCornerOverlay,
  51138. bottomLeftCornerOverlay = _hot$view$wt$wtOverla.bottomLeftCornerOverlay;
  51139. this.lockedCollection = true;
  51140. this.scrollbars.length = 0;
  51141. this.scrollbars.push(topOverlay);
  51142. if (bottomOverlay.clone) {
  51143. this.scrollbars.push(bottomOverlay);
  51144. }
  51145. this.scrollbars.push(leftOverlay);
  51146. if (topLeftCornerOverlay) {
  51147. this.scrollbars.push(topLeftCornerOverlay);
  51148. }
  51149. if (bottomLeftCornerOverlay && bottomLeftCornerOverlay.clone) {
  51150. this.scrollbars.push(bottomLeftCornerOverlay);
  51151. }
  51152. this.clones.length = 0;
  51153. if (topOverlay.needFullRender) {
  51154. this.clones.push(topOverlay.clone.wtTable.holder.parentNode);
  51155. }
  51156. if (bottomOverlay.needFullRender) {
  51157. this.clones.push(bottomOverlay.clone.wtTable.holder.parentNode);
  51158. }
  51159. if (leftOverlay.needFullRender) {
  51160. this.clones.push(leftOverlay.clone.wtTable.holder.parentNode);
  51161. }
  51162. if (topLeftCornerOverlay) {
  51163. this.clones.push(topLeftCornerOverlay.clone.wtTable.holder.parentNode);
  51164. }
  51165. if (bottomLeftCornerOverlay && bottomLeftCornerOverlay.clone) {
  51166. this.clones.push(bottomLeftCornerOverlay.clone.wtTable.holder.parentNode);
  51167. }
  51168. }
  51169. /**
  51170. * Touch scroll listener.
  51171. *
  51172. * @private
  51173. */
  51174. }, {
  51175. key: 'onBeforeTouchScroll',
  51176. value: function onBeforeTouchScroll() {
  51177. this.freezeOverlays = true;
  51178. (0, _array.arrayEach)(this.clones, function (clone) {
  51179. (0, _element.addClass)(clone, 'hide-tween');
  51180. });
  51181. }
  51182. /**
  51183. * After momentum scroll listener.
  51184. *
  51185. * @private
  51186. */
  51187. }, {
  51188. key: 'onAfterMomentumScroll',
  51189. value: function onAfterMomentumScroll() {
  51190. var _this4 = this;
  51191. this.freezeOverlays = false;
  51192. (0, _array.arrayEach)(this.clones, function (clone) {
  51193. (0, _element.removeClass)(clone, 'hide-tween');
  51194. (0, _element.addClass)(clone, 'show-tween');
  51195. });
  51196. setTimeout(function () {
  51197. (0, _array.arrayEach)(_this4.clones, function (clone) {
  51198. (0, _element.removeClass)(clone, 'show-tween');
  51199. });
  51200. }, 400);
  51201. (0, _array.arrayEach)(this.scrollbars, function (scrollbar) {
  51202. scrollbar.refresh();
  51203. scrollbar.resetFixedPosition();
  51204. });
  51205. this.hot.view.wt.wtOverlays.syncScrollWithMaster();
  51206. }
  51207. }]);
  51208. return TouchScroll;
  51209. }(_base2.default);
  51210. (0, _plugins.registerPlugin)('touchScroll', TouchScroll);
  51211. exports.default = TouchScroll;
  51212. /***/ }),
  51213. /* 478 */
  51214. /***/ (function(module, exports, __webpack_require__) {
  51215. "use strict";
  51216. exports.__esModule = true;
  51217. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  51218. var _pluginHooks = __webpack_require__(15);
  51219. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  51220. var _array = __webpack_require__(1);
  51221. var _number = __webpack_require__(5);
  51222. var _object = __webpack_require__(2);
  51223. var _event = __webpack_require__(12);
  51224. var _src = __webpack_require__(4);
  51225. var _utils = __webpack_require__(19);
  51226. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  51227. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  51228. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  51229. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
  51230. * Handsontable UndoRedo class
  51231. */
  51232. /**
  51233. * @description
  51234. * Handsontable UndoRedo plugin. It allows to undo and redo certain actions done in the table.
  51235. * Please note, that not all actions are currently undo-able.
  51236. *
  51237. * @example
  51238. * ```js
  51239. * ...
  51240. * undo: true
  51241. * ...
  51242. * ```
  51243. * @class UndoRedo
  51244. * @plugin UndoRedo
  51245. */
  51246. function UndoRedo(instance) {
  51247. var plugin = this;
  51248. this.instance = instance;
  51249. this.doneActions = [];
  51250. this.undoneActions = [];
  51251. this.ignoreNewActions = false;
  51252. instance.addHook('afterChange', function (changes, source) {
  51253. if (changes && source !== 'UndoRedo.undo' && source !== 'UndoRedo.redo' && source !== 'MergeCells') {
  51254. plugin.done(new UndoRedo.ChangeAction(changes));
  51255. }
  51256. });
  51257. instance.addHook('afterCreateRow', function (index, amount, source) {
  51258. if (source === 'UndoRedo.undo' || source === 'UndoRedo.undo' || source === 'auto') {
  51259. return;
  51260. }
  51261. var action = new UndoRedo.CreateRowAction(index, amount);
  51262. plugin.done(action);
  51263. });
  51264. instance.addHook('beforeRemoveRow', function (index, amount, logicRows, source) {
  51265. if (source === 'UndoRedo.undo' || source === 'UndoRedo.redo' || source === 'auto') {
  51266. return;
  51267. }
  51268. var originalData = plugin.instance.getSourceDataArray();
  51269. index = (originalData.length + index) % originalData.length;
  51270. var removedData = (0, _object.deepClone)(originalData.slice(index, index + amount));
  51271. plugin.done(new UndoRedo.RemoveRowAction(index, removedData));
  51272. });
  51273. instance.addHook('afterCreateCol', function (index, amount, source) {
  51274. if (source === 'UndoRedo.undo' || source === 'UndoRedo.redo' || source === 'auto') {
  51275. return;
  51276. }
  51277. plugin.done(new UndoRedo.CreateColumnAction(index, amount));
  51278. });
  51279. instance.addHook('beforeRemoveCol', function (index, amount, logicColumns, source) {
  51280. if (source === 'UndoRedo.undo' || source === 'UndoRedo.redo' || source === 'auto') {
  51281. return;
  51282. }
  51283. var originalData = plugin.instance.getSourceDataArray();
  51284. index = (plugin.instance.countCols() + index) % plugin.instance.countCols();
  51285. var removedData = [];
  51286. var headers = [];
  51287. var indexes = [];
  51288. (0, _number.rangeEach)(originalData.length - 1, function (i) {
  51289. var column = [];
  51290. var origRow = originalData[i];
  51291. (0, _number.rangeEach)(index, index + (amount - 1), function (j) {
  51292. column.push(origRow[instance.runHooks('modifyCol', j)]);
  51293. });
  51294. removedData.push(column);
  51295. });
  51296. (0, _number.rangeEach)(amount - 1, function (i) {
  51297. indexes.push(instance.runHooks('modifyCol', index + i));
  51298. });
  51299. if (Array.isArray(instance.getSettings().colHeaders)) {
  51300. (0, _number.rangeEach)(amount - 1, function (i) {
  51301. headers.push(instance.getSettings().colHeaders[instance.runHooks('modifyCol', index + i)] || null);
  51302. });
  51303. }
  51304. var manualColumnMovePlugin = plugin.instance.getPlugin('manualColumnMove');
  51305. var columnsMap = manualColumnMovePlugin.isEnabled() ? manualColumnMovePlugin.columnsMapper.__arrayMap : [];
  51306. var action = new UndoRedo.RemoveColumnAction(index, indexes, removedData, headers, columnsMap);
  51307. plugin.done(action);
  51308. });
  51309. instance.addHook('beforeCellAlignment', function (stateBefore, range, type, alignment) {
  51310. var action = new UndoRedo.CellAlignmentAction(stateBefore, range, type, alignment);
  51311. plugin.done(action);
  51312. });
  51313. instance.addHook('beforeFilter', function (conditionsStack) {
  51314. plugin.done(new UndoRedo.FiltersAction(conditionsStack));
  51315. });
  51316. instance.addHook('beforeRowMove', function (movedRows, target) {
  51317. if (movedRows === false) {
  51318. return;
  51319. }
  51320. plugin.done(new UndoRedo.RowMoveAction(movedRows, target));
  51321. });
  51322. instance.addHook('beforeMergeCells', function (cellRange, auto) {
  51323. if (auto) {
  51324. return;
  51325. }
  51326. plugin.done(new UndoRedo.MergeCellsAction(instance, cellRange));
  51327. });
  51328. instance.addHook('afterUnmergeCells', function (cellRange, auto) {
  51329. if (auto) {
  51330. return;
  51331. }
  51332. plugin.done(new UndoRedo.UnmergeCellsAction(instance, cellRange));
  51333. });
  51334. }
  51335. UndoRedo.prototype.done = function (action) {
  51336. if (!this.ignoreNewActions) {
  51337. this.doneActions.push(action);
  51338. this.undoneActions.length = 0;
  51339. }
  51340. };
  51341. /**
  51342. * Undo last edit.
  51343. *
  51344. * @function undo
  51345. * @memberof UndoRedo#
  51346. */
  51347. UndoRedo.prototype.undo = function () {
  51348. if (this.isUndoAvailable()) {
  51349. var action = this.doneActions.pop();
  51350. var actionClone = (0, _object.deepClone)(action);
  51351. var instance = this.instance;
  51352. var continueAction = instance.runHooks('beforeUndo', actionClone);
  51353. if (continueAction === false) {
  51354. return;
  51355. }
  51356. this.ignoreNewActions = true;
  51357. var that = this;
  51358. action.undo(this.instance, function () {
  51359. that.ignoreNewActions = false;
  51360. that.undoneActions.push(action);
  51361. });
  51362. instance.runHooks('afterUndo', actionClone);
  51363. }
  51364. };
  51365. /**
  51366. * Redo edit (used to reverse an undo).
  51367. *
  51368. * @function redo
  51369. * @memberof UndoRedo#
  51370. */
  51371. UndoRedo.prototype.redo = function () {
  51372. if (this.isRedoAvailable()) {
  51373. var action = this.undoneActions.pop();
  51374. var actionClone = (0, _object.deepClone)(action);
  51375. var instance = this.instance;
  51376. var continueAction = instance.runHooks('beforeRedo', actionClone);
  51377. if (continueAction === false) {
  51378. return;
  51379. }
  51380. this.ignoreNewActions = true;
  51381. var that = this;
  51382. action.redo(this.instance, function () {
  51383. that.ignoreNewActions = false;
  51384. that.doneActions.push(action);
  51385. });
  51386. instance.runHooks('afterRedo', actionClone);
  51387. }
  51388. };
  51389. /**
  51390. * Check if undo action is available.
  51391. *
  51392. * @function isUndoAvailable
  51393. * @memberof UndoRedo#
  51394. * @return {Boolean} Return `true` if undo can be performed, `false` otherwise
  51395. */
  51396. UndoRedo.prototype.isUndoAvailable = function () {
  51397. return this.doneActions.length > 0;
  51398. };
  51399. /**
  51400. * Check if redo action is available.
  51401. *
  51402. * @function isRedoAvailable
  51403. * @memberof UndoRedo#
  51404. * @return {Boolean} Return `true` if redo can be performed, `false` otherwise.
  51405. */
  51406. UndoRedo.prototype.isRedoAvailable = function () {
  51407. return this.undoneActions.length > 0;
  51408. };
  51409. /**
  51410. * Clears undo history.
  51411. *
  51412. * @function clear
  51413. * @memberof UndoRedo#
  51414. */
  51415. UndoRedo.prototype.clear = function () {
  51416. this.doneActions.length = 0;
  51417. this.undoneActions.length = 0;
  51418. };
  51419. UndoRedo.Action = function () {};
  51420. UndoRedo.Action.prototype.undo = function () {};
  51421. UndoRedo.Action.prototype.redo = function () {};
  51422. /**
  51423. * Change action.
  51424. */
  51425. UndoRedo.ChangeAction = function (changes) {
  51426. this.changes = changes;
  51427. this.actionType = 'change';
  51428. };
  51429. (0, _object.inherit)(UndoRedo.ChangeAction, UndoRedo.Action);
  51430. UndoRedo.ChangeAction.prototype.undo = function (instance, undoneCallback) {
  51431. var data = (0, _object.deepClone)(this.changes),
  51432. emptyRowsAtTheEnd = instance.countEmptyRows(true),
  51433. emptyColsAtTheEnd = instance.countEmptyCols(true);
  51434. for (var i = 0, len = data.length; i < len; i++) {
  51435. data[i].splice(3, 1);
  51436. }
  51437. instance.addHookOnce('afterChange', undoneCallback);
  51438. instance.setDataAtRowProp(data, null, null, 'UndoRedo.undo');
  51439. for (var _i = 0, _len = data.length; _i < _len; _i++) {
  51440. if (instance.getSettings().minSpareRows && data[_i][0] + 1 + instance.getSettings().minSpareRows === instance.countRows() && emptyRowsAtTheEnd === instance.getSettings().minSpareRows) {
  51441. instance.alter('remove_row', parseInt(data[_i][0] + 1, 10), instance.getSettings().minSpareRows);
  51442. instance.undoRedo.doneActions.pop();
  51443. }
  51444. if (instance.getSettings().minSpareCols && data[_i][1] + 1 + instance.getSettings().minSpareCols === instance.countCols() && emptyColsAtTheEnd === instance.getSettings().minSpareCols) {
  51445. instance.alter('remove_col', parseInt(data[_i][1] + 1, 10), instance.getSettings().minSpareCols);
  51446. instance.undoRedo.doneActions.pop();
  51447. }
  51448. }
  51449. };
  51450. UndoRedo.ChangeAction.prototype.redo = function (instance, onFinishCallback) {
  51451. var data = (0, _object.deepClone)(this.changes);
  51452. for (var i = 0, len = data.length; i < len; i++) {
  51453. data[i].splice(2, 1);
  51454. }
  51455. instance.addHookOnce('afterChange', onFinishCallback);
  51456. instance.setDataAtRowProp(data, null, null, 'UndoRedo.redo');
  51457. };
  51458. /**
  51459. * Create row action.
  51460. */
  51461. UndoRedo.CreateRowAction = function (index, amount) {
  51462. this.index = index;
  51463. this.amount = amount;
  51464. this.actionType = 'insert_row';
  51465. };
  51466. (0, _object.inherit)(UndoRedo.CreateRowAction, UndoRedo.Action);
  51467. UndoRedo.CreateRowAction.prototype.undo = function (instance, undoneCallback) {
  51468. var rowCount = instance.countRows(),
  51469. minSpareRows = instance.getSettings().minSpareRows;
  51470. if (this.index >= rowCount && this.index - minSpareRows < rowCount) {
  51471. this.index -= minSpareRows; // work around the situation where the needed row was removed due to an 'undo' of a made change
  51472. }
  51473. instance.addHookOnce('afterRemoveRow', undoneCallback);
  51474. instance.alter('remove_row', this.index, this.amount, 'UndoRedo.undo');
  51475. };
  51476. UndoRedo.CreateRowAction.prototype.redo = function (instance, redoneCallback) {
  51477. instance.addHookOnce('afterCreateRow', redoneCallback);
  51478. instance.alter('insert_row', this.index, this.amount, 'UndoRedo.redo');
  51479. };
  51480. /**
  51481. * Remove row action.
  51482. */
  51483. UndoRedo.RemoveRowAction = function (index, data) {
  51484. this.index = index;
  51485. this.data = data;
  51486. this.actionType = 'remove_row';
  51487. };
  51488. (0, _object.inherit)(UndoRedo.RemoveRowAction, UndoRedo.Action);
  51489. UndoRedo.RemoveRowAction.prototype.undo = function (instance, undoneCallback) {
  51490. instance.alter('insert_row', this.index, this.data.length, 'UndoRedo.undo');
  51491. instance.addHookOnce('afterRender', undoneCallback);
  51492. instance.populateFromArray(this.index, 0, this.data, void 0, void 0, 'UndoRedo.undo');
  51493. };
  51494. UndoRedo.RemoveRowAction.prototype.redo = function (instance, redoneCallback) {
  51495. instance.addHookOnce('afterRemoveRow', redoneCallback);
  51496. instance.alter('remove_row', this.index, this.data.length, 'UndoRedo.redo');
  51497. };
  51498. /**
  51499. * Create column action.
  51500. */
  51501. UndoRedo.CreateColumnAction = function (index, amount) {
  51502. this.index = index;
  51503. this.amount = amount;
  51504. this.actionType = 'insert_col';
  51505. };
  51506. (0, _object.inherit)(UndoRedo.CreateColumnAction, UndoRedo.Action);
  51507. UndoRedo.CreateColumnAction.prototype.undo = function (instance, undoneCallback) {
  51508. instance.addHookOnce('afterRemoveCol', undoneCallback);
  51509. instance.alter('remove_col', this.index, this.amount, 'UndoRedo.undo');
  51510. };
  51511. UndoRedo.CreateColumnAction.prototype.redo = function (instance, redoneCallback) {
  51512. instance.addHookOnce('afterCreateCol', redoneCallback);
  51513. instance.alter('insert_col', this.index, this.amount, 'UndoRedo.redo');
  51514. };
  51515. /**
  51516. * Remove column action.
  51517. */
  51518. UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPositions) {
  51519. this.index = index;
  51520. this.indexes = indexes;
  51521. this.data = data;
  51522. this.amount = this.data[0].length;
  51523. this.headers = headers;
  51524. this.columnPositions = columnPositions.slice(0);
  51525. this.actionType = 'remove_col';
  51526. };
  51527. (0, _object.inherit)(UndoRedo.RemoveColumnAction, UndoRedo.Action);
  51528. UndoRedo.RemoveColumnAction.prototype.undo = function (instance, undoneCallback) {
  51529. var _this = this;
  51530. var row = void 0;
  51531. var ascendingIndexes = this.indexes.slice(0).sort();
  51532. var sortByIndexes = function sortByIndexes(elem, j, arr) {
  51533. return arr[_this.indexes.indexOf(ascendingIndexes[j])];
  51534. };
  51535. var sortedData = [];
  51536. (0, _number.rangeEach)(this.data.length - 1, function (i) {
  51537. sortedData[i] = (0, _array.arrayMap)(_this.data[i], sortByIndexes);
  51538. });
  51539. var sortedHeaders = [];
  51540. sortedHeaders = (0, _array.arrayMap)(this.headers, sortByIndexes);
  51541. var changes = [];
  51542. // TODO: Temporary hook for undo/redo mess
  51543. instance.runHooks('beforeCreateCol', this.indexes[0], this.indexes.length, 'UndoRedo.undo');
  51544. (0, _number.rangeEach)(this.data.length - 1, function (i) {
  51545. row = instance.getSourceDataAtRow(i);
  51546. (0, _number.rangeEach)(ascendingIndexes.length - 1, function (j) {
  51547. row.splice(ascendingIndexes[j], 0, sortedData[i][j]);
  51548. changes.push([i, ascendingIndexes[j], null, sortedData[i][j]]);
  51549. });
  51550. });
  51551. // TODO: Temporary hook for undo/redo mess
  51552. if (instance.getPlugin('formulas')) {
  51553. instance.getPlugin('formulas').onAfterSetDataAtCell(changes);
  51554. }
  51555. if (typeof this.headers !== 'undefined') {
  51556. (0, _number.rangeEach)(sortedHeaders.length - 1, function (j) {
  51557. instance.getSettings().colHeaders.splice(ascendingIndexes[j], 0, sortedHeaders[j]);
  51558. });
  51559. }
  51560. if (instance.getPlugin('manualColumnMove')) {
  51561. instance.getPlugin('manualColumnMove').columnsMapper.__arrayMap = this.columnPositions;
  51562. }
  51563. instance.addHookOnce('afterRender', undoneCallback);
  51564. // TODO: Temporary hook for undo/redo mess
  51565. instance.runHooks('afterCreateCol', this.indexes[0], this.indexes.length, 'UndoRedo.undo');
  51566. if (instance.getPlugin('formulas')) {
  51567. instance.getPlugin('formulas').recalculateFull();
  51568. }
  51569. instance.render();
  51570. };
  51571. UndoRedo.RemoveColumnAction.prototype.redo = function (instance, redoneCallback) {
  51572. instance.addHookOnce('afterRemoveCol', redoneCallback);
  51573. instance.alter('remove_col', this.index, this.amount, 'UndoRedo.redo');
  51574. };
  51575. /**
  51576. * Cell alignment action.
  51577. */
  51578. UndoRedo.CellAlignmentAction = function (stateBefore, range, type, alignment) {
  51579. this.stateBefore = stateBefore;
  51580. this.range = range;
  51581. this.type = type;
  51582. this.alignment = alignment;
  51583. };
  51584. UndoRedo.CellAlignmentAction.prototype.undo = function (instance, undoneCallback) {
  51585. var _this2 = this;
  51586. (0, _array.arrayEach)(this.range, function (_ref) {
  51587. var from = _ref.from,
  51588. to = _ref.to;
  51589. for (var row = from.row; row <= to.row; row += 1) {
  51590. for (var col = from.col; col <= to.col; col += 1) {
  51591. instance.setCellMeta(row, col, 'className', _this2.stateBefore[row][col] || ' htLeft');
  51592. }
  51593. }
  51594. });
  51595. instance.addHookOnce('afterRender', undoneCallback);
  51596. instance.render();
  51597. };
  51598. UndoRedo.CellAlignmentAction.prototype.redo = function (instance, undoneCallback) {
  51599. (0, _utils.align)(this.range, this.type, this.alignment, function (row, col) {
  51600. return instance.getCellMeta(row, col);
  51601. }, function (row, col, key, value) {
  51602. return instance.setCellMeta(row, col, key, value);
  51603. });
  51604. instance.addHookOnce('afterRender', undoneCallback);
  51605. instance.render();
  51606. };
  51607. /**
  51608. * Filters action.
  51609. */
  51610. UndoRedo.FiltersAction = function (conditionsStack) {
  51611. this.conditionsStack = conditionsStack;
  51612. this.actionType = 'filter';
  51613. };
  51614. (0, _object.inherit)(UndoRedo.FiltersAction, UndoRedo.Action);
  51615. UndoRedo.FiltersAction.prototype.undo = function (instance, undoneCallback) {
  51616. var filters = instance.getPlugin('filters');
  51617. instance.addHookOnce('afterRender', undoneCallback);
  51618. filters.conditionCollection.importAllConditions(this.conditionsStack.slice(0, this.conditionsStack.length - 1));
  51619. filters.filter();
  51620. };
  51621. UndoRedo.FiltersAction.prototype.redo = function (instance, redoneCallback) {
  51622. var filters = instance.getPlugin('filters');
  51623. instance.addHookOnce('afterRender', redoneCallback);
  51624. filters.conditionCollection.importAllConditions(this.conditionsStack);
  51625. filters.filter();
  51626. };
  51627. /**
  51628. * Merge Cells action.
  51629. * @util
  51630. */
  51631. var MergeCellsAction = function (_UndoRedo$Action) {
  51632. _inherits(MergeCellsAction, _UndoRedo$Action);
  51633. function MergeCellsAction(instance, cellRange) {
  51634. _classCallCheck(this, MergeCellsAction);
  51635. var _this3 = _possibleConstructorReturn(this, (MergeCellsAction.__proto__ || Object.getPrototypeOf(MergeCellsAction)).call(this));
  51636. _this3.cellRange = cellRange;
  51637. _this3.rangeData = instance.getData(cellRange.from.row, cellRange.from.col, cellRange.to.row, cellRange.to.col);
  51638. return _this3;
  51639. }
  51640. _createClass(MergeCellsAction, [{
  51641. key: 'undo',
  51642. value: function undo(instance, undoneCallback) {
  51643. var mergeCellsPlugin = instance.getPlugin('mergeCells');
  51644. instance.addHookOnce('afterRender', undoneCallback);
  51645. mergeCellsPlugin.unmergeRange(this.cellRange, true);
  51646. instance.populateFromArray(this.cellRange.from.row, this.cellRange.from.col, this.rangeData, void 0, void 0, 'MergeCells');
  51647. }
  51648. }, {
  51649. key: 'redo',
  51650. value: function redo(instance, redoneCallback) {
  51651. var mergeCellsPlugin = instance.getPlugin('mergeCells');
  51652. instance.addHookOnce('afterRender', redoneCallback);
  51653. mergeCellsPlugin.mergeRange(this.cellRange);
  51654. }
  51655. }]);
  51656. return MergeCellsAction;
  51657. }(UndoRedo.Action);
  51658. UndoRedo.MergeCellsAction = MergeCellsAction;
  51659. /**
  51660. * Unmerge Cells action.
  51661. * @util
  51662. */
  51663. var UnmergeCellsAction = function (_UndoRedo$Action2) {
  51664. _inherits(UnmergeCellsAction, _UndoRedo$Action2);
  51665. function UnmergeCellsAction(instance, cellRange) {
  51666. _classCallCheck(this, UnmergeCellsAction);
  51667. var _this4 = _possibleConstructorReturn(this, (UnmergeCellsAction.__proto__ || Object.getPrototypeOf(UnmergeCellsAction)).call(this));
  51668. _this4.cellRange = cellRange;
  51669. return _this4;
  51670. }
  51671. _createClass(UnmergeCellsAction, [{
  51672. key: 'undo',
  51673. value: function undo(instance, undoneCallback) {
  51674. var mergeCellsPlugin = instance.getPlugin('mergeCells');
  51675. instance.addHookOnce('afterRender', undoneCallback);
  51676. mergeCellsPlugin.mergeRange(this.cellRange, true);
  51677. }
  51678. }, {
  51679. key: 'redo',
  51680. value: function redo(instance, redoneCallback) {
  51681. var mergeCellsPlugin = instance.getPlugin('mergeCells');
  51682. instance.addHookOnce('afterRender', redoneCallback);
  51683. mergeCellsPlugin.unmergeRange(this.cellRange, true);
  51684. instance.render();
  51685. }
  51686. }]);
  51687. return UnmergeCellsAction;
  51688. }(UndoRedo.Action);
  51689. UndoRedo.UnmergeCellsAction = UnmergeCellsAction;
  51690. /**
  51691. * ManualRowMove action.
  51692. * @TODO: removeRow undo should works on logical index
  51693. */
  51694. UndoRedo.RowMoveAction = function (movedRows, target) {
  51695. this.rows = movedRows.slice();
  51696. this.target = target;
  51697. };
  51698. (0, _object.inherit)(UndoRedo.RowMoveAction, UndoRedo.Action);
  51699. UndoRedo.RowMoveAction.prototype.undo = function (instance, undoneCallback) {
  51700. var manualRowMove = instance.getPlugin('manualRowMove');
  51701. instance.addHookOnce('afterRender', undoneCallback);
  51702. var mod = this.rows[0] < this.target ? -1 * this.rows.length : 0;
  51703. var newTarget = this.rows[0] > this.target ? this.rows[0] + this.rows.length : this.rows[0];
  51704. var newRows = [];
  51705. var rowsLen = this.rows.length + mod;
  51706. for (var i = mod; i < rowsLen; i += 1) {
  51707. newRows.push(this.target + i);
  51708. }
  51709. manualRowMove.moveRows(newRows.slice(), newTarget);
  51710. instance.render();
  51711. instance.selectCell(this.rows[0], 0, this.rows[this.rows.length - 1], instance.countCols() - 1, false, false);
  51712. };
  51713. UndoRedo.RowMoveAction.prototype.redo = function (instance, redoneCallback) {
  51714. var manualRowMove = instance.getPlugin('manualRowMove');
  51715. instance.addHookOnce('afterRender', redoneCallback);
  51716. manualRowMove.moveRows(this.rows.slice(), this.target);
  51717. instance.render();
  51718. var startSelection = this.rows[0] < this.target ? this.target - this.rows.length : this.target;
  51719. instance.selectCell(startSelection, 0, startSelection + this.rows.length - 1, instance.countCols() - 1, false, false);
  51720. };
  51721. function init() {
  51722. var instance = this;
  51723. var pluginEnabled = typeof instance.getSettings().undo == 'undefined' || instance.getSettings().undo;
  51724. if (pluginEnabled) {
  51725. if (!instance.undoRedo) {
  51726. /**
  51727. * Instance of Handsontable.UndoRedo Plugin {@link Handsontable.UndoRedo}
  51728. *
  51729. * @alias undoRedo
  51730. * @memberof! Handsontable.Core#
  51731. * @type {UndoRedo}
  51732. */
  51733. instance.undoRedo = new UndoRedo(instance);
  51734. exposeUndoRedoMethods(instance);
  51735. instance.addHook('beforeKeyDown', onBeforeKeyDown);
  51736. instance.addHook('afterChange', onAfterChange);
  51737. }
  51738. } else if (instance.undoRedo) {
  51739. delete instance.undoRedo;
  51740. removeExposedUndoRedoMethods(instance);
  51741. instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  51742. instance.removeHook('afterChange', onAfterChange);
  51743. }
  51744. }
  51745. function onBeforeKeyDown(event) {
  51746. var instance = this;
  51747. var ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  51748. if (ctrlDown) {
  51749. if (event.keyCode === 89 || event.shiftKey && event.keyCode === 90) {
  51750. // CTRL + Y or CTRL + SHIFT + Z
  51751. instance.undoRedo.redo();
  51752. (0, _event.stopImmediatePropagation)(event);
  51753. } else if (event.keyCode === 90) {
  51754. // CTRL + Z
  51755. instance.undoRedo.undo();
  51756. (0, _event.stopImmediatePropagation)(event);
  51757. }
  51758. }
  51759. }
  51760. function onAfterChange(changes, source) {
  51761. var instance = this;
  51762. if (source === 'loadData') {
  51763. return instance.undoRedo.clear();
  51764. }
  51765. }
  51766. function exposeUndoRedoMethods(instance) {
  51767. /**
  51768. * {@link UndoRedo#undo}
  51769. * @alias undo
  51770. * @memberof! Handsontable.Core#
  51771. */
  51772. instance.undo = function () {
  51773. return instance.undoRedo.undo();
  51774. };
  51775. /**
  51776. * {@link UndoRedo#redo}
  51777. * @alias redo
  51778. * @memberof! Handsontable.Core#
  51779. */
  51780. instance.redo = function () {
  51781. return instance.undoRedo.redo();
  51782. };
  51783. /**
  51784. * {@link UndoRedo#isUndoAvailable}
  51785. * @alias isUndoAvailable
  51786. * @memberof! Handsontable.Core#
  51787. */
  51788. instance.isUndoAvailable = function () {
  51789. return instance.undoRedo.isUndoAvailable();
  51790. };
  51791. /**
  51792. * {@link UndoRedo#isRedoAvailable}
  51793. * @alias isRedoAvailable
  51794. * @memberof! Handsontable.Core#
  51795. */
  51796. instance.isRedoAvailable = function () {
  51797. return instance.undoRedo.isRedoAvailable();
  51798. };
  51799. /**
  51800. * {@link UndoRedo#clear}
  51801. * @alias clearUndo
  51802. * @memberof! Handsontable.Core#
  51803. */
  51804. instance.clearUndo = function () {
  51805. return instance.undoRedo.clear();
  51806. };
  51807. }
  51808. function removeExposedUndoRedoMethods(instance) {
  51809. delete instance.undo;
  51810. delete instance.redo;
  51811. delete instance.isUndoAvailable;
  51812. delete instance.isRedoAvailable;
  51813. delete instance.clearUndo;
  51814. }
  51815. var hook = _pluginHooks2.default.getSingleton();
  51816. hook.add('afterInit', init);
  51817. hook.add('afterUpdateSettings', init);
  51818. hook.register('beforeUndo');
  51819. hook.register('afterUndo');
  51820. hook.register('beforeRedo');
  51821. hook.register('afterRedo');
  51822. exports.default = UndoRedo;
  51823. /***/ })
  51824. /******/ ])["default"];
  51825. });