handsontable.js 1.6 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546
  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(require("moment"), require("numbro"), require("pikaday"));
  32. else if(typeof define === 'function' && define.amd)
  33. define("Handsontable", ["moment", "numbro", "pikaday"], factory);
  34. else if(typeof exports === 'object')
  35. exports["Handsontable"] = factory(require("moment"), require("numbro"), require("pikaday"));
  36. else
  37. root["Handsontable"] = factory(root["moment"], root["numbro"], root["Pikaday"]);
  38. })(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_55__, __WEBPACK_EXTERNAL_MODULE_247__, __WEBPACK_EXTERNAL_MODULE_236__) {
  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 = 206);
  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__(44);
  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__(54);
  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__(228);
  1656. var _debug2 = _interopRequireDefault(_debug);
  1657. var _left = __webpack_require__(229);
  1658. var _left2 = _interopRequireDefault(_left);
  1659. var _top = __webpack_require__(230);
  1660. var _top2 = _interopRequireDefault(_top);
  1661. var _topLeftCorner = __webpack_require__(231);
  1662. var _topLeftCorner2 = _interopRequireDefault(_topLeftCorner);
  1663. var _border = __webpack_require__(187);
  1664. var _border2 = _interopRequireDefault(_border);
  1665. var _core = __webpack_require__(179);
  1666. var _core2 = _interopRequireDefault(_core);
  1667. var _event = __webpack_require__(180);
  1668. var _event2 = _interopRequireDefault(_event);
  1669. var _overlays = __webpack_require__(181);
  1670. var _overlays2 = _interopRequireDefault(_overlays);
  1671. var _scroll = __webpack_require__(182);
  1672. var _scroll2 = _interopRequireDefault(_scroll);
  1673. var _selection = __webpack_require__(232);
  1674. var _selection2 = _interopRequireDefault(_selection);
  1675. var _settings = __webpack_require__(183);
  1676. var _settings2 = _interopRequireDefault(_settings);
  1677. var _table = __webpack_require__(184);
  1678. var _table2 = _interopRequireDefault(_table);
  1679. var _tableRenderer = __webpack_require__(185);
  1680. var _tableRenderer2 = _interopRequireDefault(_tableRenderer);
  1681. var _viewport = __webpack_require__(186);
  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__(193);
  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__(48);
  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__(242);
  2526. var _cellDecorator2 = _interopRequireDefault(_cellDecorator);
  2527. var _autocompleteRenderer = __webpack_require__(243);
  2528. var _autocompleteRenderer2 = _interopRequireDefault(_autocompleteRenderer);
  2529. var _checkboxRenderer = __webpack_require__(244);
  2530. var _checkboxRenderer2 = _interopRequireDefault(_checkboxRenderer);
  2531. var _htmlRenderer = __webpack_require__(245);
  2532. var _htmlRenderer2 = _interopRequireDefault(_htmlRenderer);
  2533. var _numericRenderer = __webpack_require__(246);
  2534. var _numericRenderer2 = _interopRequireDefault(_numericRenderer);
  2535. var _passwordRenderer = __webpack_require__(248);
  2536. var _passwordRenderer2 = _interopRequireDefault(_passwordRenderer);
  2537. var _textRenderer = __webpack_require__(249);
  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__(55);
  4448. var _moment2 = _interopRequireDefault(_moment);
  4449. var _templateLiteralTag = __webpack_require__(41);
  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__(53);
  4605. var _baseEditor2 = _interopRequireDefault(_baseEditor);
  4606. var _autocompleteEditor = __webpack_require__(188);
  4607. var _autocompleteEditor2 = _interopRequireDefault(_autocompleteEditor);
  4608. var _checkboxEditor = __webpack_require__(234);
  4609. var _checkboxEditor2 = _interopRequireDefault(_checkboxEditor);
  4610. var _dateEditor = __webpack_require__(235);
  4611. var _dateEditor2 = _interopRequireDefault(_dateEditor);
  4612. var _dropdownEditor = __webpack_require__(238);
  4613. var _dropdownEditor2 = _interopRequireDefault(_dropdownEditor);
  4614. var _handsontableEditor = __webpack_require__(189);
  4615. var _handsontableEditor2 = _interopRequireDefault(_handsontableEditor);
  4616. var _numericEditor = __webpack_require__(239);
  4617. var _numericEditor2 = _interopRequireDefault(_numericEditor);
  4618. var _passwordEditor = __webpack_require__(240);
  4619. var _passwordEditor2 = _interopRequireDefault(_passwordEditor);
  4620. var _selectEditor = __webpack_require__(241);
  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__(44);
  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__(250);
  5127. var _autocompleteValidator2 = _interopRequireDefault(_autocompleteValidator);
  5128. var _dateValidator = __webpack_require__(251);
  5129. var _dateValidator2 = _interopRequireDefault(_dateValidator);
  5130. var _numericValidator = __webpack_require__(252);
  5131. var _numericValidator2 = _interopRequireDefault(_numericValidator);
  5132. var _timeValidator = __webpack_require__(253);
  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__(48)('src');
  5179. var TO_STRING = 'toString';
  5180. var $toString = Function[TO_STRING];
  5181. var TPL = ('' + $toString).split(TO_STRING);
  5182. __webpack_require__(44).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__(49);
  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__(48)('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;
  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. "use strict";
  5879. exports.__esModule = true;
  5880. exports.toSingleLine = toSingleLine;
  5881. var _array = __webpack_require__(1);
  5882. /**
  5883. * Tags a multiline string and return new one without line break characters and following spaces.
  5884. *
  5885. * @param {Array} strings Parts of the entire string without expressions.
  5886. * @param {...String} expressions Expressions converted to strings, which are added to the entire string.
  5887. * @returns {String}
  5888. */
  5889. function toSingleLine(strings) {
  5890. for (var _len = arguments.length, expressions = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  5891. expressions[_key - 1] = arguments[_key];
  5892. }
  5893. var result = (0, _array.arrayReduce)(strings, function (previousValue, currentValue, index) {
  5894. var valueWithoutWhiteSpaces = currentValue.replace(/(?:\r?\n\s+)/g, '');
  5895. var expressionForIndex = expressions[index] ? expressions[index] : '';
  5896. return previousValue + valueWithoutWhiteSpaces + expressionForIndex;
  5897. }, '');
  5898. return result.trim();
  5899. } /* eslint-disable import/prefer-default-export */
  5900. /***/ }),
  5901. /* 42 */
  5902. /***/ (function(module, exports, __webpack_require__) {
  5903. "use strict";
  5904. exports.__esModule = true;
  5905. exports.isFunction = isFunction;
  5906. exports.throttle = throttle;
  5907. exports.throttleAfterHits = throttleAfterHits;
  5908. exports.debounce = debounce;
  5909. exports.pipe = pipe;
  5910. exports.partial = partial;
  5911. exports.curry = curry;
  5912. exports.curryRight = curryRight;
  5913. var _array = __webpack_require__(1);
  5914. /**
  5915. * Checks if given variable is function.
  5916. *
  5917. * @param {*} func Variable to check.
  5918. * @returns {Boolean}
  5919. */
  5920. function isFunction(func) {
  5921. return typeof func === 'function';
  5922. }
  5923. /**
  5924. * Creates throttle function that enforces a maximum number of times a function (`func`) can be called over time (`wait`).
  5925. *
  5926. * @param {Function} func Function to invoke.
  5927. * @param {Number} wait Delay in miliseconds.
  5928. * @returns {Function}
  5929. */
  5930. function throttle(func) {
  5931. var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
  5932. var lastCalled = 0;
  5933. var result = {
  5934. lastCallThrottled: true
  5935. };
  5936. var lastTimer = null;
  5937. function _throttle() {
  5938. var _this = this;
  5939. var args = arguments;
  5940. var stamp = Date.now();
  5941. var needCall = false;
  5942. result.lastCallThrottled = true;
  5943. if (!lastCalled) {
  5944. lastCalled = stamp;
  5945. needCall = true;
  5946. }
  5947. var remaining = wait - (stamp - lastCalled);
  5948. if (needCall) {
  5949. result.lastCallThrottled = false;
  5950. func.apply(this, args);
  5951. } else {
  5952. if (lastTimer) {
  5953. clearTimeout(lastTimer);
  5954. }
  5955. lastTimer = setTimeout(function () {
  5956. result.lastCallThrottled = false;
  5957. func.apply(_this, args);
  5958. lastCalled = 0;
  5959. lastTimer = void 0;
  5960. }, remaining);
  5961. }
  5962. return result;
  5963. }
  5964. return _throttle;
  5965. }
  5966. /**
  5967. * Creates throttle function that enforces a maximum number of times a function (`func`) can be called over
  5968. * time (`wait`) after specified hits.
  5969. *
  5970. * @param {Function} func Function to invoke.
  5971. * @param {Number} wait Delay in miliseconds.
  5972. * @param {Number} hits Number of hits after throttling will be applied.
  5973. * @returns {Function}
  5974. */
  5975. function throttleAfterHits(func) {
  5976. var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
  5977. var hits = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
  5978. var funcThrottle = throttle(func, wait);
  5979. var remainHits = hits;
  5980. function _clearHits() {
  5981. remainHits = hits;
  5982. }
  5983. function _throttleAfterHits() {
  5984. if (remainHits) {
  5985. remainHits--;
  5986. return func.apply(this, arguments);
  5987. }
  5988. return funcThrottle.apply(this, arguments);
  5989. }
  5990. _throttleAfterHits.clearHits = _clearHits;
  5991. return _throttleAfterHits;
  5992. }
  5993. /**
  5994. * Creates debounce function that enforces a function (`func`) not be called again until a certain amount of time (`wait`)
  5995. * has passed without it being called.
  5996. *
  5997. * @param {Function} func Function to invoke.
  5998. * @param {Number} wait Delay in milliseconds.
  5999. * @returns {Function}
  6000. */
  6001. function debounce(func) {
  6002. var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
  6003. var lastTimer = null;
  6004. var result = void 0;
  6005. function _debounce() {
  6006. var _this2 = this;
  6007. var args = arguments;
  6008. if (lastTimer) {
  6009. clearTimeout(lastTimer);
  6010. }
  6011. lastTimer = setTimeout(function () {
  6012. result = func.apply(_this2, args);
  6013. }, wait);
  6014. return result;
  6015. }
  6016. return _debounce;
  6017. }
  6018. /**
  6019. * Creates the function that returns the result of calling the given functions. Result of the first function is passed to
  6020. * the second as an argument and so on. Only first function in the chain can handle multiple arguments.
  6021. *
  6022. * @param {Function} functions Functions to compose.
  6023. * @returns {Function}
  6024. */
  6025. function pipe() {
  6026. for (var _len = arguments.length, functions = Array(_len), _key = 0; _key < _len; _key++) {
  6027. functions[_key] = arguments[_key];
  6028. }
  6029. var firstFunc = functions[0],
  6030. restFunc = functions.slice(1);
  6031. return function _pipe() {
  6032. return (0, _array.arrayReduce)(restFunc, function (acc, fn) {
  6033. return fn(acc);
  6034. }, firstFunc.apply(this, arguments));
  6035. };
  6036. }
  6037. /**
  6038. * Creates the function that returns the function with cached arguments.
  6039. *
  6040. * @param {Function} func Function to partialization.
  6041. * @param {Array} params Function arguments to cache.
  6042. * @returns {Function}
  6043. */
  6044. function partial(func) {
  6045. for (var _len2 = arguments.length, params = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  6046. params[_key2 - 1] = arguments[_key2];
  6047. }
  6048. return function _partial() {
  6049. for (var _len3 = arguments.length, restParams = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  6050. restParams[_key3] = arguments[_key3];
  6051. }
  6052. return func.apply(this, params.concat(restParams));
  6053. };
  6054. }
  6055. /**
  6056. * Creates the functions that returns the function with cached arguments. If count if passed arguments will be matched
  6057. * to the arguments defined in `func` then function will be invoked.
  6058. * Arguments are added to the stack in direction from the left to the right.
  6059. *
  6060. * @example
  6061. * ```
  6062. * var replace = curry(function(find, replace, string) {
  6063. * return string.replace(find, replace);
  6064. * });
  6065. *
  6066. * // returns function with bounded first argument
  6067. * var replace = replace('foo')
  6068. *
  6069. * // returns replaced string - all arguments was passed so function was invoked
  6070. * replace('bar', 'Some test with foo...');
  6071. *
  6072. * ```
  6073. *
  6074. * @param {Function} func Function to currying.
  6075. * @returns {Function}
  6076. */
  6077. function curry(func) {
  6078. var argsLength = func.length;
  6079. function given(argsSoFar) {
  6080. return function _curry() {
  6081. for (var _len4 = arguments.length, params = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
  6082. params[_key4] = arguments[_key4];
  6083. }
  6084. var passedArgsSoFar = argsSoFar.concat(params);
  6085. var result = void 0;
  6086. if (passedArgsSoFar.length >= argsLength) {
  6087. result = func.apply(this, passedArgsSoFar);
  6088. } else {
  6089. result = given(passedArgsSoFar);
  6090. }
  6091. return result;
  6092. };
  6093. }
  6094. return given([]);
  6095. }
  6096. /**
  6097. * Creates the functions that returns the function with cached arguments. If count if passed arguments will be matched
  6098. * to the arguments defined in `func` then function will be invoked.
  6099. * Arguments are added to the stack in direction from the right to the left.
  6100. *
  6101. * @example
  6102. * ```
  6103. * var replace = curry(function(find, replace, string) {
  6104. * return string.replace(find, replace);
  6105. * });
  6106. *
  6107. * // returns function with bounded first argument
  6108. * var replace = replace('Some test with foo...')
  6109. *
  6110. * // returns replaced string - all arguments was passed so function was invoked
  6111. * replace('bar', 'foo');
  6112. *
  6113. * ```
  6114. *
  6115. * @param {Function} func Function to currying.
  6116. * @returns {Function}
  6117. */
  6118. function curryRight(func) {
  6119. var argsLength = func.length;
  6120. function given(argsSoFar) {
  6121. return function _curry() {
  6122. for (var _len5 = arguments.length, params = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
  6123. params[_key5] = arguments[_key5];
  6124. }
  6125. var passedArgsSoFar = argsSoFar.concat(params.reverse());
  6126. var result = void 0;
  6127. if (passedArgsSoFar.length >= argsLength) {
  6128. result = func.apply(this, passedArgsSoFar);
  6129. } else {
  6130. result = given(passedArgsSoFar);
  6131. }
  6132. return result;
  6133. };
  6134. }
  6135. return given([]);
  6136. }
  6137. /***/ }),
  6138. /* 43 */
  6139. /***/ (function(module, exports) {
  6140. var toString = {}.toString;
  6141. module.exports = function (it) {
  6142. return toString.call(it).slice(8, -1);
  6143. };
  6144. /***/ }),
  6145. /* 44 */
  6146. /***/ (function(module, exports) {
  6147. var core = module.exports = { version: '2.5.5' };
  6148. if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
  6149. /***/ }),
  6150. /* 45 */
  6151. /***/ (function(module, exports, __webpack_require__) {
  6152. var isObject = __webpack_require__(9);
  6153. module.exports = function (it, TYPE) {
  6154. if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');
  6155. return it;
  6156. };
  6157. /***/ }),
  6158. /* 46 */
  6159. /***/ (function(module, exports, __webpack_require__) {
  6160. // 22.1.3.31 Array.prototype[@@unscopables]
  6161. var UNSCOPABLES = __webpack_require__(11)('unscopables');
  6162. var ArrayProto = Array.prototype;
  6163. if (ArrayProto[UNSCOPABLES] == undefined) __webpack_require__(31)(ArrayProto, UNSCOPABLES, {});
  6164. module.exports = function (key) {
  6165. ArrayProto[UNSCOPABLES][key] = true;
  6166. };
  6167. /***/ }),
  6168. /* 47 */
  6169. /***/ (function(module, exports, __webpack_require__) {
  6170. "use strict";
  6171. exports.__esModule = true;
  6172. exports.createClassName = createClassName;
  6173. exports.createDefaultCustomBorder = createDefaultCustomBorder;
  6174. exports.createSingleEmptyBorder = createSingleEmptyBorder;
  6175. exports.createDefaultHtBorder = createDefaultHtBorder;
  6176. exports.createEmptyBorders = createEmptyBorders;
  6177. exports.extendDefaultBorder = extendDefaultBorder;
  6178. exports.checkSelectionBorders = checkSelectionBorders;
  6179. exports.markSelected = markSelected;
  6180. var _object = __webpack_require__(2);
  6181. var _array = __webpack_require__(1);
  6182. /**
  6183. * Create separated class name for borders for each cell.
  6184. *
  6185. * @param {Number} row Visual row index.
  6186. * @param {Number} col Visual column index.
  6187. * @returns {String}
  6188. */
  6189. function createClassName(row, col) {
  6190. return 'border_row' + row + 'col' + col;
  6191. }
  6192. /**
  6193. * Create default single border for each position (top/right/bottom/left).
  6194. *
  6195. * @returns {Object} `{{width: number, color: string}}`
  6196. */
  6197. function createDefaultCustomBorder() {
  6198. return {
  6199. width: 1,
  6200. color: '#000'
  6201. };
  6202. }
  6203. /**
  6204. * Create default object for empty border.
  6205. *
  6206. * @returns {Object} `{{hide: boolean}}`
  6207. */
  6208. function createSingleEmptyBorder() {
  6209. return { hide: true };
  6210. }
  6211. /**
  6212. * Create default Handsontable border object.
  6213. *
  6214. * @returns {Object} `{{width: number, color: string, cornerVisible: boolean}}`
  6215. */
  6216. function createDefaultHtBorder() {
  6217. return {
  6218. width: 1,
  6219. color: '#000',
  6220. cornerVisible: false
  6221. };
  6222. }
  6223. /**
  6224. * Prepare empty border for each cell with all custom borders hidden.
  6225. *
  6226. * @param {Number} row Visual row index.
  6227. * @param {Number} col Visual column index.
  6228. * @returns {Object} `{{className: *, border: *, row: *, col: *, top: {hide: boolean}, right: {hide: boolean}, bottom: {hide: boolean}, left: {hide: boolean}}}`
  6229. */
  6230. function createEmptyBorders(row, col) {
  6231. return {
  6232. className: createClassName(row, col),
  6233. border: createDefaultHtBorder(),
  6234. row: row,
  6235. col: col,
  6236. top: createSingleEmptyBorder(),
  6237. right: createSingleEmptyBorder(),
  6238. bottom: createSingleEmptyBorder(),
  6239. left: createSingleEmptyBorder()
  6240. };
  6241. }
  6242. function extendDefaultBorder(defaultBorder, customBorder) {
  6243. if ((0, _object.hasOwnProperty)(customBorder, 'border')) {
  6244. defaultBorder.border = customBorder.border;
  6245. }
  6246. if ((0, _object.hasOwnProperty)(customBorder, 'top')) {
  6247. defaultBorder.top = customBorder.top;
  6248. }
  6249. if ((0, _object.hasOwnProperty)(customBorder, 'right')) {
  6250. defaultBorder.right = customBorder.right;
  6251. }
  6252. if ((0, _object.hasOwnProperty)(customBorder, 'bottom')) {
  6253. defaultBorder.bottom = customBorder.bottom;
  6254. }
  6255. if ((0, _object.hasOwnProperty)(customBorder, 'left')) {
  6256. defaultBorder.left = customBorder.left;
  6257. }
  6258. return defaultBorder;
  6259. }
  6260. /**
  6261. * Check if selection has border by className
  6262. *
  6263. * @param hot
  6264. * @param direction
  6265. */
  6266. function checkSelectionBorders(hot, direction) {
  6267. var atLeastOneHasBorder = false;
  6268. (0, _array.arrayEach)(hot.getSelectedRange(), function (range) {
  6269. range.forAll(function (r, c) {
  6270. var metaBorders = hot.getCellMeta(r, c).borders;
  6271. if (metaBorders) {
  6272. if (direction) {
  6273. if (!(0, _object.hasOwnProperty)(metaBorders[direction], 'hide')) {
  6274. atLeastOneHasBorder = true;
  6275. return false; // breaks forAll
  6276. }
  6277. } else {
  6278. atLeastOneHasBorder = true;
  6279. return false; // breaks forAll
  6280. }
  6281. }
  6282. });
  6283. });
  6284. return atLeastOneHasBorder;
  6285. }
  6286. /**
  6287. * Mark label in contextMenu as selected
  6288. *
  6289. * @param label
  6290. * @returns {string}
  6291. */
  6292. function markSelected(label) {
  6293. return '<span class="selected">' + String.fromCharCode(10003) + '</span>' + label; // workaround for https://github.com/handsontable/handsontable/issues/1946
  6294. }
  6295. /***/ }),
  6296. /* 48 */
  6297. /***/ (function(module, exports) {
  6298. var id = 0;
  6299. var px = Math.random();
  6300. module.exports = function (key) {
  6301. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  6302. };
  6303. /***/ }),
  6304. /* 49 */
  6305. /***/ (function(module, exports) {
  6306. module.exports = function (bitmap, value) {
  6307. return {
  6308. enumerable: !(bitmap & 1),
  6309. configurable: !(bitmap & 2),
  6310. writable: !(bitmap & 4),
  6311. value: value
  6312. };
  6313. };
  6314. /***/ }),
  6315. /* 50 */
  6316. /***/ (function(module, exports) {
  6317. module.exports = {};
  6318. /***/ }),
  6319. /* 51 */
  6320. /***/ (function(module, exports, __webpack_require__) {
  6321. var def = __webpack_require__(20).f;
  6322. var has = __webpack_require__(29);
  6323. var TAG = __webpack_require__(11)('toStringTag');
  6324. module.exports = function (it, tag, stat) {
  6325. if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
  6326. };
  6327. /***/ }),
  6328. /* 52 */
  6329. /***/ (function(module, exports) {
  6330. exports.f = {}.propertyIsEnumerable;
  6331. /***/ }),
  6332. /* 53 */
  6333. /***/ (function(module, exports, __webpack_require__) {
  6334. "use strict";
  6335. exports.__esModule = true;
  6336. exports.EditorState = undefined;
  6337. var _src = __webpack_require__(4);
  6338. var _mixed = __webpack_require__(16);
  6339. var EditorState = exports.EditorState = {
  6340. VIRGIN: 'STATE_VIRGIN', // before editing
  6341. EDITING: 'STATE_EDITING',
  6342. WAITING: 'STATE_WAITING', // waiting for async validation
  6343. FINISHED: 'STATE_FINISHED'
  6344. };
  6345. function BaseEditor(instance) {
  6346. this.instance = instance;
  6347. this.state = EditorState.VIRGIN;
  6348. this._opened = false;
  6349. this._fullEditMode = false;
  6350. this._closeCallback = null;
  6351. this.init();
  6352. }
  6353. BaseEditor.prototype._fireCallbacks = function (result) {
  6354. if (this._closeCallback) {
  6355. this._closeCallback(result);
  6356. this._closeCallback = null;
  6357. }
  6358. };
  6359. BaseEditor.prototype.init = function () {};
  6360. BaseEditor.prototype.getValue = function () {
  6361. throw Error('Editor getValue() method unimplemented');
  6362. };
  6363. BaseEditor.prototype.setValue = function (newValue) {
  6364. throw Error('Editor setValue() method unimplemented');
  6365. };
  6366. BaseEditor.prototype.open = function () {
  6367. throw Error('Editor open() method unimplemented');
  6368. };
  6369. BaseEditor.prototype.close = function () {
  6370. throw Error('Editor close() method unimplemented');
  6371. };
  6372. BaseEditor.prototype.prepare = function (row, col, prop, td, originalValue, cellProperties) {
  6373. this.TD = td;
  6374. this.row = row;
  6375. this.col = col;
  6376. this.prop = prop;
  6377. this.originalValue = originalValue;
  6378. this.cellProperties = cellProperties;
  6379. this.state = EditorState.VIRGIN;
  6380. };
  6381. BaseEditor.prototype.extend = function () {
  6382. var baseClass = this.constructor;
  6383. function Editor() {
  6384. baseClass.apply(this, arguments);
  6385. }
  6386. function inherit(Child, Parent) {
  6387. function Bridge() {}
  6388. Bridge.prototype = Parent.prototype;
  6389. Child.prototype = new Bridge();
  6390. Child.prototype.constructor = Child;
  6391. return Child;
  6392. }
  6393. return inherit(Editor, baseClass);
  6394. };
  6395. BaseEditor.prototype.saveValue = function (value, ctrlDown) {
  6396. var selection = void 0;
  6397. var tmp = void 0;
  6398. // if ctrl+enter and multiple cells selected, behave like Excel (finish editing and apply to all cells)
  6399. if (ctrlDown) {
  6400. selection = this.instance.getSelectedLast();
  6401. if (selection[0] > selection[2]) {
  6402. tmp = selection[0];
  6403. selection[0] = selection[2];
  6404. selection[2] = tmp;
  6405. }
  6406. if (selection[1] > selection[3]) {
  6407. tmp = selection[1];
  6408. selection[1] = selection[3];
  6409. selection[3] = tmp;
  6410. }
  6411. } else {
  6412. selection = [this.row, this.col, null, null];
  6413. }
  6414. this.instance.populateFromArray(selection[0], selection[1], value, selection[2], selection[3], 'edit');
  6415. };
  6416. BaseEditor.prototype.beginEditing = function (newInitialValue, event) {
  6417. if (this.state !== EditorState.VIRGIN) {
  6418. return;
  6419. }
  6420. this.instance.view.scrollViewport(new _src.CellCoords(this.row, this.col));
  6421. this.instance.view.render();
  6422. this.state = EditorState.EDITING;
  6423. newInitialValue = typeof newInitialValue === 'string' ? newInitialValue : this.originalValue;
  6424. this.setValue((0, _mixed.stringify)(newInitialValue));
  6425. this.open(event);
  6426. this._opened = true;
  6427. this.focus();
  6428. // only rerender the selections (FillHandle should disappear when beginediting is triggered)
  6429. this.instance.view.render();
  6430. this.instance.runHooks('afterBeginEditing', this.row, this.col);
  6431. };
  6432. BaseEditor.prototype.finishEditing = function (restoreOriginalValue, ctrlDown, callback) {
  6433. var _this = this,
  6434. val;
  6435. if (callback) {
  6436. var previousCloseCallback = this._closeCallback;
  6437. this._closeCallback = function (result) {
  6438. if (previousCloseCallback) {
  6439. previousCloseCallback(result);
  6440. }
  6441. callback(result);
  6442. _this.instance.view.render();
  6443. };
  6444. }
  6445. if (this.isWaiting()) {
  6446. return;
  6447. }
  6448. if (this.state == EditorState.VIRGIN) {
  6449. this.instance._registerTimeout(setTimeout(function () {
  6450. _this._fireCallbacks(true);
  6451. }, 0));
  6452. return;
  6453. }
  6454. if (this.state == EditorState.EDITING) {
  6455. if (restoreOriginalValue) {
  6456. this.cancelChanges();
  6457. this.instance.view.render();
  6458. return;
  6459. }
  6460. var value = this.getValue();
  6461. if (this.instance.getSettings().trimWhitespace) {
  6462. // We trim only string values
  6463. val = [[typeof value === 'string' ? String.prototype.trim.call(value || '') : value]];
  6464. } else {
  6465. val = [[value]];
  6466. }
  6467. this.state = EditorState.WAITING;
  6468. this.saveValue(val, ctrlDown);
  6469. if (this.instance.getCellValidator(this.cellProperties)) {
  6470. this.instance.addHookOnce('postAfterValidate', function (result) {
  6471. _this.state = EditorState.FINISHED;
  6472. _this.discardEditor(result);
  6473. });
  6474. } else {
  6475. this.state = EditorState.FINISHED;
  6476. this.discardEditor(true);
  6477. }
  6478. }
  6479. };
  6480. BaseEditor.prototype.cancelChanges = function () {
  6481. this.state = EditorState.FINISHED;
  6482. this.discardEditor();
  6483. };
  6484. BaseEditor.prototype.discardEditor = function (result) {
  6485. if (this.state !== EditorState.FINISHED) {
  6486. return;
  6487. }
  6488. // validator was defined and failed
  6489. if (result === false && this.cellProperties.allowInvalid !== true) {
  6490. this.instance.selectCell(this.row, this.col);
  6491. this.focus();
  6492. this.state = EditorState.EDITING;
  6493. this._fireCallbacks(false);
  6494. } else {
  6495. this.close();
  6496. this._opened = false;
  6497. this._fullEditMode = false;
  6498. this.state = EditorState.VIRGIN;
  6499. this._fireCallbacks(true);
  6500. }
  6501. };
  6502. /**
  6503. * Switch editor into full edit mode. In this state navigation keys don't close editor. This mode is activated
  6504. * automatically after hit ENTER or F2 key on the cell or while editing cell press F2 key.
  6505. */
  6506. BaseEditor.prototype.enableFullEditMode = function () {
  6507. this._fullEditMode = true;
  6508. };
  6509. /**
  6510. * Checks if editor is in full edit mode.
  6511. *
  6512. * @returns {Boolean}
  6513. */
  6514. BaseEditor.prototype.isInFullEditMode = function () {
  6515. return this._fullEditMode;
  6516. };
  6517. BaseEditor.prototype.isOpened = function () {
  6518. return this._opened;
  6519. };
  6520. BaseEditor.prototype.isWaiting = function () {
  6521. return this.state === EditorState.WAITING;
  6522. };
  6523. BaseEditor.prototype.checkEditorSection = function () {
  6524. var totalRows = this.instance.countRows();
  6525. var section = '';
  6526. if (this.row < this.instance.getSettings().fixedRowsTop) {
  6527. if (this.col < this.instance.getSettings().fixedColumnsLeft) {
  6528. section = 'top-left-corner';
  6529. } else {
  6530. section = 'top';
  6531. }
  6532. } else if (this.instance.getSettings().fixedRowsBottom && this.row >= totalRows - this.instance.getSettings().fixedRowsBottom) {
  6533. if (this.col < this.instance.getSettings().fixedColumnsLeft) {
  6534. section = 'bottom-left-corner';
  6535. } else {
  6536. section = 'bottom';
  6537. }
  6538. } else if (this.col < this.instance.getSettings().fixedColumnsLeft) {
  6539. section = 'left';
  6540. }
  6541. return section;
  6542. };
  6543. exports.default = BaseEditor;
  6544. /***/ }),
  6545. /* 54 */
  6546. /***/ (function(module, exports, __webpack_require__) {
  6547. "use strict";
  6548. exports.__esModule = true;
  6549. 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; }; }();
  6550. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6551. /**
  6552. * CellCoords holds cell coordinates (row, column) and few method to validate them and
  6553. * retrieve as an array or an object
  6554. *
  6555. * @class CellCoords
  6556. */
  6557. var CellCoords = function () {
  6558. /**
  6559. * @param {Number} row Row index
  6560. * @param {Number} col Column index
  6561. */
  6562. function CellCoords(row, col) {
  6563. _classCallCheck(this, CellCoords);
  6564. if (typeof row !== 'undefined' && typeof col !== 'undefined') {
  6565. this.row = row;
  6566. this.col = col;
  6567. } else {
  6568. this.row = null;
  6569. this.col = null;
  6570. }
  6571. }
  6572. /**
  6573. * Checks if given set of coordinates is valid in context of a given Walkontable instance
  6574. *
  6575. * @param {Walkontable} wotInstance
  6576. * @returns {Boolean}
  6577. */
  6578. _createClass(CellCoords, [{
  6579. key: 'isValid',
  6580. value: function isValid(wotInstance) {
  6581. // is it a valid cell index (0 or higher)
  6582. if (this.row < 0 || this.col < 0) {
  6583. return false;
  6584. }
  6585. // is selection within total rows and columns
  6586. if (this.row >= wotInstance.getSetting('totalRows') || this.col >= wotInstance.getSetting('totalColumns')) {
  6587. return false;
  6588. }
  6589. return true;
  6590. }
  6591. /**
  6592. * Checks if this cell coords are the same as cell coords given as a parameter
  6593. *
  6594. * @param {CellCoords} cellCoords
  6595. * @returns {Boolean}
  6596. */
  6597. }, {
  6598. key: 'isEqual',
  6599. value: function isEqual(cellCoords) {
  6600. if (cellCoords === this) {
  6601. return true;
  6602. }
  6603. return this.row === cellCoords.row && this.col === cellCoords.col;
  6604. }
  6605. /**
  6606. * Checks if tested coordinates are positioned in south-east from this cell coords
  6607. *
  6608. * @param {Object} testedCoords
  6609. * @returns {Boolean}
  6610. */
  6611. }, {
  6612. key: 'isSouthEastOf',
  6613. value: function isSouthEastOf(testedCoords) {
  6614. return this.row >= testedCoords.row && this.col >= testedCoords.col;
  6615. }
  6616. /**
  6617. * Checks if tested coordinates are positioned in north-east from this cell coords
  6618. *
  6619. * @param {Object} testedCoords
  6620. * @returns {Boolean}
  6621. */
  6622. }, {
  6623. key: 'isNorthWestOf',
  6624. value: function isNorthWestOf(testedCoords) {
  6625. return this.row <= testedCoords.row && this.col <= testedCoords.col;
  6626. }
  6627. /**
  6628. * Checks if tested coordinates are positioned in south-west from this cell coords
  6629. *
  6630. * @param {Object} testedCoords
  6631. * @returns {Boolean}
  6632. */
  6633. }, {
  6634. key: 'isSouthWestOf',
  6635. value: function isSouthWestOf(testedCoords) {
  6636. return this.row >= testedCoords.row && this.col <= testedCoords.col;
  6637. }
  6638. /**
  6639. * Checks if tested coordinates are positioned in north-east from this cell coords
  6640. *
  6641. * @param {Object} testedCoords
  6642. * @returns {Boolean}
  6643. */
  6644. }, {
  6645. key: 'isNorthEastOf',
  6646. value: function isNorthEastOf(testedCoords) {
  6647. return this.row <= testedCoords.row && this.col >= testedCoords.col;
  6648. }
  6649. /**
  6650. * Convert CellCoords to literal object.
  6651. *
  6652. * @return {Object} Returns a literal object with `row` and `col` properties.
  6653. */
  6654. }, {
  6655. key: 'toObject',
  6656. value: function toObject() {
  6657. return {
  6658. row: this.row,
  6659. col: this.col
  6660. };
  6661. }
  6662. }]);
  6663. return CellCoords;
  6664. }();
  6665. exports.default = CellCoords;
  6666. /***/ }),
  6667. /* 55 */
  6668. /***/ (function(module, exports) {
  6669. module.exports = __WEBPACK_EXTERNAL_MODULE_55__;
  6670. /***/ }),
  6671. /* 56 */
  6672. /***/ (function(module, exports, __webpack_require__) {
  6673. "use strict";
  6674. exports.__esModule = true;
  6675. exports.log = log;
  6676. exports.warn = warn;
  6677. exports.info = info;
  6678. exports.error = error;
  6679. var _mixed = __webpack_require__(16);
  6680. /**
  6681. * Logs message to the console if the `console` object is exposed.
  6682. *
  6683. * @param {...*} args Values which will be logged.
  6684. */
  6685. function log() {
  6686. if ((0, _mixed.isDefined)(console)) {
  6687. var _console;
  6688. (_console = console).log.apply(_console, arguments);
  6689. }
  6690. } /* eslint-disable no-console */
  6691. /* eslint-disable no-restricted-globals */
  6692. /**
  6693. * "In Internet Explorer 9 (and 8), the console object is only exposed when the developer tools are opened
  6694. * for a particular tab."
  6695. *
  6696. * Source: https://stackoverflow.com/a/5473193
  6697. */
  6698. ;
  6699. /**
  6700. * Logs warn to the console if the `console` object is exposed.
  6701. *
  6702. * @param {...*} args Values which will be logged.
  6703. */
  6704. function warn() {
  6705. if ((0, _mixed.isDefined)(console)) {
  6706. var _console2;
  6707. (_console2 = console).warn.apply(_console2, arguments);
  6708. }
  6709. };
  6710. /**
  6711. * Logs info to the console if the `console` object is exposed.
  6712. *
  6713. * @param {...*} args Values which will be logged.
  6714. */
  6715. function info() {
  6716. if ((0, _mixed.isDefined)(console)) {
  6717. var _console3;
  6718. (_console3 = console).info.apply(_console3, arguments);
  6719. }
  6720. };
  6721. /**
  6722. * Logs error to the console if the `console` object is exposed.
  6723. *
  6724. * @param {...*} args Values which will be logged.
  6725. */
  6726. function error() {
  6727. if ((0, _mixed.isDefined)(console)) {
  6728. var _console4;
  6729. (_console4 = console).error.apply(_console4, arguments);
  6730. }
  6731. };
  6732. /***/ }),
  6733. /* 57 */
  6734. /***/ (function(module, exports, __webpack_require__) {
  6735. "use strict";
  6736. exports.__esModule = true;
  6737. var _element = __webpack_require__(0);
  6738. var _autoResize = __webpack_require__(233);
  6739. var _autoResize2 = _interopRequireDefault(_autoResize);
  6740. var _baseEditor = __webpack_require__(53);
  6741. var _baseEditor2 = _interopRequireDefault(_baseEditor);
  6742. var _eventManager = __webpack_require__(6);
  6743. var _eventManager2 = _interopRequireDefault(_eventManager);
  6744. var _unicode = __webpack_require__(21);
  6745. var _event = __webpack_require__(12);
  6746. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6747. var TextEditor = _baseEditor2.default.prototype.extend();
  6748. /**
  6749. * @private
  6750. * @editor TextEditor
  6751. * @class TextEditor
  6752. * @dependencies autoResize
  6753. */
  6754. TextEditor.prototype.init = function () {
  6755. var that = this;
  6756. this.createElements();
  6757. this.eventManager = new _eventManager2.default(this);
  6758. this.bindEvents();
  6759. this.autoResize = (0, _autoResize2.default)();
  6760. this.instance.addHook('afterDestroy', function () {
  6761. that.destroy();
  6762. });
  6763. };
  6764. TextEditor.prototype.getValue = function () {
  6765. return this.TEXTAREA.value;
  6766. };
  6767. TextEditor.prototype.setValue = function (newValue) {
  6768. this.TEXTAREA.value = newValue;
  6769. };
  6770. var onBeforeKeyDown = function onBeforeKeyDown(event) {
  6771. var instance = this,
  6772. that = instance.getActiveEditor(),
  6773. ctrlDown;
  6774. // catch CTRL but not right ALT (which in some systems triggers ALT+CTRL)
  6775. ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  6776. // Process only events that have been fired in the editor
  6777. if (event.target !== that.TEXTAREA || (0, _event.isImmediatePropagationStopped)(event)) {
  6778. return;
  6779. }
  6780. if (event.keyCode === 17 || event.keyCode === 224 || event.keyCode === 91 || event.keyCode === 93) {
  6781. // when CTRL or its equivalent is pressed and cell is edited, don't prepare selectable text in textarea
  6782. (0, _event.stopImmediatePropagation)(event);
  6783. return;
  6784. }
  6785. switch (event.keyCode) {
  6786. case _unicode.KEY_CODES.ARROW_RIGHT:
  6787. if (that.isInFullEditMode()) {
  6788. if (!that.isWaiting() && !that.allowKeyEventPropagation || !that.isWaiting() && that.allowKeyEventPropagation && !that.allowKeyEventPropagation(event.keyCode)) {
  6789. (0, _event.stopImmediatePropagation)(event);
  6790. }
  6791. }
  6792. break;
  6793. case _unicode.KEY_CODES.ARROW_LEFT:
  6794. if (that.isInFullEditMode()) {
  6795. if (!that.isWaiting() && !that.allowKeyEventPropagation || !that.isWaiting() && that.allowKeyEventPropagation && !that.allowKeyEventPropagation(event.keyCode)) {
  6796. (0, _event.stopImmediatePropagation)(event);
  6797. }
  6798. }
  6799. break;
  6800. case _unicode.KEY_CODES.ARROW_UP:
  6801. case _unicode.KEY_CODES.ARROW_DOWN:
  6802. if (that.isInFullEditMode()) {
  6803. if (!that.isWaiting() && !that.allowKeyEventPropagation || !that.isWaiting() && that.allowKeyEventPropagation && !that.allowKeyEventPropagation(event.keyCode)) {
  6804. (0, _event.stopImmediatePropagation)(event);
  6805. }
  6806. }
  6807. break;
  6808. case _unicode.KEY_CODES.ENTER:
  6809. {
  6810. var isMultipleSelection = this.selection.isMultiple();
  6811. if (ctrlDown && !isMultipleSelection || event.altKey) {
  6812. // if ctrl+enter or alt+enter, add new line
  6813. if (that.isOpened()) {
  6814. var caretPosition = (0, _element.getCaretPosition)(that.TEXTAREA);
  6815. var value = that.getValue();
  6816. var newValue = value.slice(0, caretPosition) + '\n' + value.slice(caretPosition);
  6817. that.setValue(newValue);
  6818. (0, _element.setCaretPosition)(that.TEXTAREA, caretPosition + 1);
  6819. } else {
  6820. that.beginEditing(that.originalValue + '\n');
  6821. }
  6822. (0, _event.stopImmediatePropagation)(event);
  6823. }
  6824. event.preventDefault(); // don't add newline to field
  6825. break;
  6826. }
  6827. case _unicode.KEY_CODES.A:
  6828. case _unicode.KEY_CODES.X:
  6829. case _unicode.KEY_CODES.C:
  6830. case _unicode.KEY_CODES.V:
  6831. if (ctrlDown) {
  6832. (0, _event.stopImmediatePropagation)(event); // CTRL+A, CTRL+C, CTRL+V, CTRL+X should only work locally when cell is edited (not in table context)
  6833. }
  6834. break;
  6835. case _unicode.KEY_CODES.BACKSPACE:
  6836. case _unicode.KEY_CODES.DELETE:
  6837. case _unicode.KEY_CODES.HOME:
  6838. case _unicode.KEY_CODES.END:
  6839. (0, _event.stopImmediatePropagation)(event); // backspace, delete, home, end should only work locally when cell is edited (not in table context)
  6840. break;
  6841. default:
  6842. break;
  6843. }
  6844. 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) {
  6845. that.autoResize.resize(String.fromCharCode(event.keyCode));
  6846. }
  6847. };
  6848. TextEditor.prototype.open = function () {
  6849. this.refreshDimensions(); // need it instantly, to prevent https://github.com/handsontable/handsontable/issues/348
  6850. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  6851. };
  6852. TextEditor.prototype.close = function (tdOutside) {
  6853. this.textareaParentStyle.display = 'none';
  6854. this.autoResize.unObserve();
  6855. if (document.activeElement === this.TEXTAREA) {
  6856. this.instance.listen(); // don't refocus the table if user focused some cell outside of HT on purpose
  6857. }
  6858. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  6859. };
  6860. TextEditor.prototype.focus = function () {
  6861. this.TEXTAREA.focus();
  6862. (0, _element.setCaretPosition)(this.TEXTAREA, this.TEXTAREA.value.length);
  6863. };
  6864. TextEditor.prototype.createElements = function () {
  6865. // this.$body = $(document.body);
  6866. this.TEXTAREA = document.createElement('TEXTAREA');
  6867. (0, _element.addClass)(this.TEXTAREA, 'handsontableInput');
  6868. this.textareaStyle = this.TEXTAREA.style;
  6869. this.textareaStyle.width = 0;
  6870. this.textareaStyle.height = 0;
  6871. this.TEXTAREA_PARENT = document.createElement('DIV');
  6872. (0, _element.addClass)(this.TEXTAREA_PARENT, 'handsontableInputHolder');
  6873. this.textareaParentStyle = this.TEXTAREA_PARENT.style;
  6874. this.textareaParentStyle.top = 0;
  6875. this.textareaParentStyle.left = 0;
  6876. this.textareaParentStyle.display = 'none';
  6877. this.TEXTAREA_PARENT.appendChild(this.TEXTAREA);
  6878. this.instance.rootElement.appendChild(this.TEXTAREA_PARENT);
  6879. var that = this;
  6880. this.instance._registerTimeout(setTimeout(function () {
  6881. that.refreshDimensions();
  6882. }, 0));
  6883. };
  6884. TextEditor.prototype.getEditedCell = function () {
  6885. var editorSection = this.checkEditorSection(),
  6886. editedCell;
  6887. switch (editorSection) {
  6888. case 'top':
  6889. editedCell = this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.getCell({
  6890. row: this.row,
  6891. col: this.col
  6892. });
  6893. this.textareaParentStyle.zIndex = 101;
  6894. break;
  6895. case 'top-left-corner':
  6896. editedCell = this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.getCell({
  6897. row: this.row,
  6898. col: this.col
  6899. });
  6900. this.textareaParentStyle.zIndex = 103;
  6901. break;
  6902. case 'bottom-left-corner':
  6903. editedCell = this.instance.view.wt.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.getCell({
  6904. row: this.row,
  6905. col: this.col
  6906. });
  6907. this.textareaParentStyle.zIndex = 103;
  6908. break;
  6909. case 'left':
  6910. editedCell = this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.getCell({
  6911. row: this.row,
  6912. col: this.col
  6913. });
  6914. this.textareaParentStyle.zIndex = 102;
  6915. break;
  6916. case 'bottom':
  6917. editedCell = this.instance.view.wt.wtOverlays.bottomOverlay.clone.wtTable.getCell({
  6918. row: this.row,
  6919. col: this.col
  6920. });
  6921. this.textareaParentStyle.zIndex = 102;
  6922. break;
  6923. default:
  6924. editedCell = this.instance.getCell(this.row, this.col);
  6925. this.textareaParentStyle.zIndex = '';
  6926. break;
  6927. }
  6928. return editedCell != -1 && editedCell != -2 ? editedCell : void 0;
  6929. };
  6930. TextEditor.prototype.refreshValue = function () {
  6931. var sourceData = this.instance.getSourceDataAtCell(this.row, this.prop);
  6932. this.originalValue = sourceData;
  6933. this.setValue(sourceData);
  6934. this.refreshDimensions();
  6935. };
  6936. TextEditor.prototype.refreshDimensions = function () {
  6937. if (this.state !== _baseEditor.EditorState.EDITING) {
  6938. return;
  6939. }
  6940. this.TD = this.getEditedCell();
  6941. // TD is outside of the viewport.
  6942. if (!this.TD) {
  6943. this.close(true);
  6944. return;
  6945. }
  6946. var currentOffset = (0, _element.offset)(this.TD);
  6947. var containerOffset = (0, _element.offset)(this.instance.rootElement);
  6948. var scrollableContainer = this.instance.view.wt.wtOverlays.topOverlay.mainTableScrollableElement;
  6949. var totalRowsCount = this.instance.countRows();
  6950. var containerScrollTop = scrollableContainer !== window ? scrollableContainer.scrollTop : 0;
  6951. var containerScrollLeft = scrollableContainer !== window ? scrollableContainer.scrollLeft : 0;
  6952. var editorSection = this.checkEditorSection();
  6953. var scrollTop = ['', 'left'].includes(editorSection) ? containerScrollTop : 0;
  6954. var scrollLeft = ['', 'top', 'bottom'].includes(editorSection) ? containerScrollLeft : 0;
  6955. // If colHeaders is disabled, cells in the first row have border-top
  6956. var editTopModifier = currentOffset.top === containerOffset.top ? 0 : 1;
  6957. var settings = this.instance.getSettings();
  6958. var rowHeadersCount = this.instance.hasRowHeaders();
  6959. var colHeadersCount = this.instance.hasColHeaders();
  6960. var backgroundColor = this.TD.style.backgroundColor;
  6961. var editTop = currentOffset.top - containerOffset.top - editTopModifier - scrollTop;
  6962. var editLeft = currentOffset.left - containerOffset.left - 1 - scrollLeft;
  6963. var cssTransformOffset = void 0;
  6964. // TODO: Refactor this to the new instance.getCell method (from #ply-59), after 0.12.1 is released
  6965. switch (editorSection) {
  6966. case 'top':
  6967. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.holder.parentNode);
  6968. break;
  6969. case 'left':
  6970. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.holder.parentNode);
  6971. break;
  6972. case 'top-left-corner':
  6973. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.holder.parentNode);
  6974. break;
  6975. case 'bottom-left-corner':
  6976. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.holder.parentNode);
  6977. break;
  6978. case 'bottom':
  6979. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.bottomOverlay.clone.wtTable.holder.parentNode);
  6980. break;
  6981. default:
  6982. break;
  6983. }
  6984. if (colHeadersCount && this.instance.getSelectedLast()[0] === 0 || settings.fixedRowsBottom && this.instance.getSelectedLast()[0] === totalRowsCount - settings.fixedRowsBottom) {
  6985. editTop += 1;
  6986. }
  6987. if (this.instance.getSelectedLast()[1] === 0) {
  6988. editLeft += 1;
  6989. }
  6990. if (cssTransformOffset && cssTransformOffset != -1) {
  6991. this.textareaParentStyle[cssTransformOffset[0]] = cssTransformOffset[1];
  6992. } else {
  6993. (0, _element.resetCssTransform)(this.TEXTAREA_PARENT);
  6994. }
  6995. this.textareaParentStyle.top = editTop + 'px';
  6996. this.textareaParentStyle.left = editLeft + 'px';
  6997. var firstRowOffset = this.instance.view.wt.wtViewport.rowsRenderCalculator.startPosition;
  6998. var firstColumnOffset = this.instance.view.wt.wtViewport.columnsRenderCalculator.startPosition;
  6999. var horizontalScrollPosition = this.instance.view.wt.wtOverlays.leftOverlay.getScrollPosition();
  7000. var verticalScrollPosition = this.instance.view.wt.wtOverlays.topOverlay.getScrollPosition();
  7001. var scrollbarWidth = (0, _element.getScrollbarWidth)();
  7002. var cellTopOffset = this.TD.offsetTop + firstRowOffset - verticalScrollPosition;
  7003. var cellLeftOffset = this.TD.offsetLeft + firstColumnOffset - horizontalScrollPosition;
  7004. var width = (0, _element.innerWidth)(this.TD) - 8;
  7005. var actualVerticalScrollbarWidth = (0, _element.hasVerticalScrollbar)(scrollableContainer) ? scrollbarWidth : 0;
  7006. var actualHorizontalScrollbarWidth = (0, _element.hasHorizontalScrollbar)(scrollableContainer) ? scrollbarWidth : 0;
  7007. var maxWidth = this.instance.view.maximumVisibleElementWidth(cellLeftOffset) - 9 - actualVerticalScrollbarWidth;
  7008. var height = this.TD.scrollHeight + 1;
  7009. var maxHeight = Math.max(this.instance.view.maximumVisibleElementHeight(cellTopOffset) - actualHorizontalScrollbarWidth, 23);
  7010. var cellComputedStyle = (0, _element.getComputedStyle)(this.TD);
  7011. this.TEXTAREA.style.fontSize = cellComputedStyle.fontSize;
  7012. this.TEXTAREA.style.fontFamily = cellComputedStyle.fontFamily;
  7013. this.TEXTAREA.style.backgroundColor = ''; // RESET STYLE
  7014. this.TEXTAREA.style.backgroundColor = backgroundColor ? backgroundColor : (0, _element.getComputedStyle)(this.TEXTAREA).backgroundColor;
  7015. this.autoResize.init(this.TEXTAREA, {
  7016. minHeight: Math.min(height, maxHeight),
  7017. maxHeight: maxHeight, // TEXTAREA should never be wider than visible part of the viewport (should not cover the scrollbar)
  7018. minWidth: Math.min(width, maxWidth),
  7019. maxWidth: maxWidth // TEXTAREA should never be wider than visible part of the viewport (should not cover the scrollbar)
  7020. }, true);
  7021. this.textareaParentStyle.display = 'block';
  7022. };
  7023. TextEditor.prototype.bindEvents = function () {
  7024. var editor = this;
  7025. this.eventManager.addEventListener(this.TEXTAREA, 'cut', function (event) {
  7026. (0, _event.stopPropagation)(event);
  7027. });
  7028. this.eventManager.addEventListener(this.TEXTAREA, 'paste', function (event) {
  7029. (0, _event.stopPropagation)(event);
  7030. });
  7031. this.instance.addHook('afterScrollHorizontally', function () {
  7032. editor.refreshDimensions();
  7033. });
  7034. this.instance.addHook('afterScrollVertically', function () {
  7035. editor.refreshDimensions();
  7036. });
  7037. this.instance.addHook('afterColumnResize', function () {
  7038. editor.refreshDimensions();
  7039. editor.focus();
  7040. });
  7041. this.instance.addHook('afterRowResize', function () {
  7042. editor.refreshDimensions();
  7043. editor.focus();
  7044. });
  7045. this.instance.addHook('afterDestroy', function () {
  7046. editor.eventManager.destroy();
  7047. });
  7048. };
  7049. TextEditor.prototype.destroy = function () {
  7050. this.eventManager.destroy();
  7051. };
  7052. exports.default = TextEditor;
  7053. /***/ }),
  7054. /* 58 */
  7055. /***/ (function(module, exports, __webpack_require__) {
  7056. "use strict";
  7057. exports.__esModule = true;
  7058. var _array = __webpack_require__(1);
  7059. var _object = __webpack_require__(2);
  7060. var MIXIN_NAME = 'localHooks';
  7061. /**
  7062. * Mixin object to extend objects functionality for local hooks.
  7063. *
  7064. * @type {Object}
  7065. */
  7066. var localHooks = {
  7067. /**
  7068. * Internal hooks storage.
  7069. */
  7070. _localHooks: Object.create(null),
  7071. /**
  7072. * Add hook to the collection.
  7073. *
  7074. * @param {String} key Hook name.
  7075. * @param {Function} callback Hook callback
  7076. */
  7077. addLocalHook: function addLocalHook(key, callback) {
  7078. if (!this._localHooks[key]) {
  7079. this._localHooks[key] = [];
  7080. }
  7081. this._localHooks[key].push(callback);
  7082. },
  7083. /**
  7084. * Run hooks.
  7085. *
  7086. * @param {String} key Hook name.
  7087. * @param {*} params
  7088. */
  7089. runLocalHooks: function runLocalHooks(key) {
  7090. var _this = this;
  7091. for (var _len = arguments.length, params = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  7092. params[_key - 1] = arguments[_key];
  7093. }
  7094. if (this._localHooks[key]) {
  7095. (0, _array.arrayEach)(this._localHooks[key], function (callback) {
  7096. return callback.apply(_this, params);
  7097. });
  7098. }
  7099. },
  7100. /**
  7101. * Clear all added hooks.
  7102. */
  7103. clearLocalHooks: function clearLocalHooks() {
  7104. this._localHooks = {};
  7105. }
  7106. };
  7107. (0, _object.defineGetter)(localHooks, 'MIXIN_NAME', MIXIN_NAME, {
  7108. writable: false,
  7109. enumerable: false
  7110. });
  7111. exports.default = localHooks;
  7112. /***/ }),
  7113. /* 59 */
  7114. /***/ (function(module, exports) {
  7115. // 7.1.4 ToInteger
  7116. var ceil = Math.ceil;
  7117. var floor = Math.floor;
  7118. module.exports = function (it) {
  7119. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  7120. };
  7121. /***/ }),
  7122. /* 60 */
  7123. /***/ (function(module, exports, __webpack_require__) {
  7124. var toInteger = __webpack_require__(59);
  7125. var max = Math.max;
  7126. var min = Math.min;
  7127. module.exports = function (index, length) {
  7128. index = toInteger(index);
  7129. return index < 0 ? max(index + length, 0) : min(index, length);
  7130. };
  7131. /***/ }),
  7132. /* 61 */
  7133. /***/ (function(module, exports, __webpack_require__) {
  7134. var redefine = __webpack_require__(30);
  7135. module.exports = function (target, src, safe) {
  7136. for (var key in src) redefine(target, key, src[key], safe);
  7137. return target;
  7138. };
  7139. /***/ }),
  7140. /* 62 */
  7141. /***/ (function(module, exports) {
  7142. module.exports = function (it) {
  7143. if (typeof it != 'function') throw TypeError(it + ' is not a function!');
  7144. return it;
  7145. };
  7146. /***/ }),
  7147. /* 63 */
  7148. /***/ (function(module, exports) {
  7149. module.exports = function (it, Constructor, name, forbiddenField) {
  7150. if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {
  7151. throw TypeError(name + ': incorrect invocation!');
  7152. } return it;
  7153. };
  7154. /***/ }),
  7155. /* 64 */
  7156. /***/ (function(module, exports, __webpack_require__) {
  7157. var ctx = __webpack_require__(32);
  7158. var call = __webpack_require__(102);
  7159. var isArrayIter = __webpack_require__(103);
  7160. var anObject = __webpack_require__(18);
  7161. var toLength = __webpack_require__(25);
  7162. var getIterFn = __webpack_require__(104);
  7163. var BREAK = {};
  7164. var RETURN = {};
  7165. var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
  7166. var iterFn = ITERATOR ? function () { return iterable; } : getIterFn(iterable);
  7167. var f = ctx(fn, that, entries ? 2 : 1);
  7168. var index = 0;
  7169. var length, step, iterator, result;
  7170. if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
  7171. // fast case for arrays with default iterator
  7172. if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) {
  7173. result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
  7174. if (result === BREAK || result === RETURN) return result;
  7175. } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
  7176. result = call(iterator, f, step.value, entries);
  7177. if (result === BREAK || result === RETURN) return result;
  7178. }
  7179. };
  7180. exports.BREAK = BREAK;
  7181. exports.RETURN = RETURN;
  7182. /***/ }),
  7183. /* 65 */
  7184. /***/ (function(module, exports) {
  7185. module.exports = false;
  7186. /***/ }),
  7187. /* 66 */
  7188. /***/ (function(module, exports, __webpack_require__) {
  7189. "use strict";
  7190. var global = __webpack_require__(14);
  7191. var $export = __webpack_require__(3);
  7192. var redefine = __webpack_require__(30);
  7193. var redefineAll = __webpack_require__(61);
  7194. var meta = __webpack_require__(34);
  7195. var forOf = __webpack_require__(64);
  7196. var anInstance = __webpack_require__(63);
  7197. var isObject = __webpack_require__(9);
  7198. var fails = __webpack_require__(23);
  7199. var $iterDetect = __webpack_require__(79);
  7200. var setToStringTag = __webpack_require__(51);
  7201. var inheritIfRequired = __webpack_require__(209);
  7202. module.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
  7203. var Base = global[NAME];
  7204. var C = Base;
  7205. var ADDER = IS_MAP ? 'set' : 'add';
  7206. var proto = C && C.prototype;
  7207. var O = {};
  7208. var fixMethod = function (KEY) {
  7209. var fn = proto[KEY];
  7210. redefine(proto, KEY,
  7211. KEY == 'delete' ? function (a) {
  7212. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  7213. } : KEY == 'has' ? function has(a) {
  7214. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  7215. } : KEY == 'get' ? function get(a) {
  7216. return IS_WEAK && !isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a);
  7217. } : KEY == 'add' ? function add(a) { fn.call(this, a === 0 ? 0 : a); return this; }
  7218. : function set(a, b) { fn.call(this, a === 0 ? 0 : a, b); return this; }
  7219. );
  7220. };
  7221. if (typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function () {
  7222. new C().entries().next();
  7223. }))) {
  7224. // create collection constructor
  7225. C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
  7226. redefineAll(C.prototype, methods);
  7227. meta.NEED = true;
  7228. } else {
  7229. var instance = new C();
  7230. // early implementations not supports chaining
  7231. var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;
  7232. // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false
  7233. var THROWS_ON_PRIMITIVES = fails(function () { instance.has(1); });
  7234. // most early implementations doesn't supports iterables, most modern - not close it correctly
  7235. var ACCEPT_ITERABLES = $iterDetect(function (iter) { new C(iter); }); // eslint-disable-line no-new
  7236. // for early implementations -0 and +0 not the same
  7237. var BUGGY_ZERO = !IS_WEAK && fails(function () {
  7238. // V8 ~ Chromium 42- fails only with 5+ elements
  7239. var $instance = new C();
  7240. var index = 5;
  7241. while (index--) $instance[ADDER](index, index);
  7242. return !$instance.has(-0);
  7243. });
  7244. if (!ACCEPT_ITERABLES) {
  7245. C = wrapper(function (target, iterable) {
  7246. anInstance(target, C, NAME);
  7247. var that = inheritIfRequired(new Base(), target, C);
  7248. if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
  7249. return that;
  7250. });
  7251. C.prototype = proto;
  7252. proto.constructor = C;
  7253. }
  7254. if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {
  7255. fixMethod('delete');
  7256. fixMethod('has');
  7257. IS_MAP && fixMethod('get');
  7258. }
  7259. if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER);
  7260. // weak collections should not contains .clear method
  7261. if (IS_WEAK && proto.clear) delete proto.clear;
  7262. }
  7263. setToStringTag(C, NAME);
  7264. O[NAME] = C;
  7265. $export($export.G + $export.W + $export.F * (C != Base), O);
  7266. if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);
  7267. return C;
  7268. };
  7269. /***/ }),
  7270. /* 67 */
  7271. /***/ (function(module, exports, __webpack_require__) {
  7272. var pIE = __webpack_require__(52);
  7273. var createDesc = __webpack_require__(49);
  7274. var toIObject = __webpack_require__(24);
  7275. var toPrimitive = __webpack_require__(73);
  7276. var has = __webpack_require__(29);
  7277. var IE8_DOM_DEFINE = __webpack_require__(98);
  7278. var gOPD = Object.getOwnPropertyDescriptor;
  7279. exports.f = __webpack_require__(22) ? gOPD : function getOwnPropertyDescriptor(O, P) {
  7280. O = toIObject(O);
  7281. P = toPrimitive(P, true);
  7282. if (IE8_DOM_DEFINE) try {
  7283. return gOPD(O, P);
  7284. } catch (e) { /* empty */ }
  7285. if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);
  7286. };
  7287. /***/ }),
  7288. /* 68 */
  7289. /***/ (function(module, exports, __webpack_require__) {
  7290. // 0 -> Array#forEach
  7291. // 1 -> Array#map
  7292. // 2 -> Array#filter
  7293. // 3 -> Array#some
  7294. // 4 -> Array#every
  7295. // 5 -> Array#find
  7296. // 6 -> Array#findIndex
  7297. var ctx = __webpack_require__(32);
  7298. var IObject = __webpack_require__(75);
  7299. var toObject = __webpack_require__(33);
  7300. var toLength = __webpack_require__(25);
  7301. var asc = __webpack_require__(210);
  7302. module.exports = function (TYPE, $create) {
  7303. var IS_MAP = TYPE == 1;
  7304. var IS_FILTER = TYPE == 2;
  7305. var IS_SOME = TYPE == 3;
  7306. var IS_EVERY = TYPE == 4;
  7307. var IS_FIND_INDEX = TYPE == 6;
  7308. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  7309. var create = $create || asc;
  7310. return function ($this, callbackfn, that) {
  7311. var O = toObject($this);
  7312. var self = IObject(O);
  7313. var f = ctx(callbackfn, that, 3);
  7314. var length = toLength(self.length);
  7315. var index = 0;
  7316. var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  7317. var val, res;
  7318. for (;length > index; index++) if (NO_HOLES || index in self) {
  7319. val = self[index];
  7320. res = f(val, index, O);
  7321. if (TYPE) {
  7322. if (IS_MAP) result[index] = res; // map
  7323. else if (res) switch (TYPE) {
  7324. case 3: return true; // some
  7325. case 5: return val; // find
  7326. case 6: return index; // findIndex
  7327. case 2: result.push(val); // filter
  7328. } else if (IS_EVERY) return false; // every
  7329. }
  7330. }
  7331. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
  7332. };
  7333. };
  7334. /***/ }),
  7335. /* 69 */
  7336. /***/ (function(module, exports) {
  7337. exports.f = Object.getOwnPropertySymbols;
  7338. /***/ }),
  7339. /* 70 */
  7340. /***/ (function(module, exports, __webpack_require__) {
  7341. "use strict";
  7342. var hide = __webpack_require__(31);
  7343. var redefine = __webpack_require__(30);
  7344. var fails = __webpack_require__(23);
  7345. var defined = __webpack_require__(38);
  7346. var wks = __webpack_require__(11);
  7347. module.exports = function (KEY, length, exec) {
  7348. var SYMBOL = wks(KEY);
  7349. var fns = exec(defined, SYMBOL, ''[KEY]);
  7350. var strfn = fns[0];
  7351. var rxfn = fns[1];
  7352. if (fails(function () {
  7353. var O = {};
  7354. O[SYMBOL] = function () { return 7; };
  7355. return ''[KEY](O) != 7;
  7356. })) {
  7357. redefine(String.prototype, KEY, strfn);
  7358. hide(RegExp.prototype, SYMBOL, length == 2
  7359. // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
  7360. // 21.2.5.11 RegExp.prototype[@@split](string, limit)
  7361. ? function (string, arg) { return rxfn.call(string, this, arg); }
  7362. // 21.2.5.6 RegExp.prototype[@@match](string)
  7363. // 21.2.5.9 RegExp.prototype[@@search](string)
  7364. : function (string) { return rxfn.call(string, this); }
  7365. );
  7366. }
  7367. };
  7368. /***/ }),
  7369. /* 71 */
  7370. /***/ (function(module, exports, __webpack_require__) {
  7371. "use strict";
  7372. exports.__esModule = true;
  7373. exports.DEFAULT_LANGUAGE_CODE = exports.getLanguagesDictionaries = exports.getDefaultLanguageDictionary = exports.hasLanguageDictionary = exports.getLanguageDictionary = exports.registerLanguageDictionary = undefined;
  7374. var _object = __webpack_require__(2);
  7375. var _utils = __webpack_require__(197);
  7376. var _staticRegister2 = __webpack_require__(39);
  7377. var _staticRegister3 = _interopRequireDefault(_staticRegister2);
  7378. var _enUS = __webpack_require__(269);
  7379. var _enUS2 = _interopRequireDefault(_enUS);
  7380. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7381. var DEFAULT_LANGUAGE_CODE = _enUS2.default.languageCode;
  7382. var _staticRegister = (0, _staticRegister3.default)('languagesDictionaries'),
  7383. registerGloballyLanguageDictionary = _staticRegister.register,
  7384. getGlobalLanguageDictionary = _staticRegister.getItem,
  7385. hasGlobalLanguageDictionary = _staticRegister.hasItem,
  7386. getGlobalLanguagesDictionaries = _staticRegister.getValues;
  7387. /**
  7388. * Register language dictionary for specific language code.
  7389. *
  7390. * @param {String|Object} languageCodeOrDictionary Language code for specific language i.e. 'en-US', 'pt-BR', 'de-DE' or object representing dictionary.
  7391. * @param {Object} dictionary Dictionary for specific language (optional if first parameter has already dictionary).
  7392. */
  7393. function registerLanguage(languageCodeOrDictionary, dictionary) {
  7394. var languageCode = languageCodeOrDictionary;
  7395. // Dictionary passed as first argument.
  7396. if ((0, _object.isObject)(languageCodeOrDictionary)) {
  7397. dictionary = languageCodeOrDictionary;
  7398. languageCode = dictionary.languageCode;
  7399. }
  7400. extendLanguageDictionary(languageCode, dictionary);
  7401. registerGloballyLanguageDictionary(languageCode, (0, _object.deepClone)(dictionary));
  7402. // We do not allow user to work with dictionary by reference, it can cause lot of bugs.
  7403. return (0, _object.deepClone)(dictionary);
  7404. };
  7405. /**
  7406. * Get language dictionary for specific language code.
  7407. *
  7408. * @param {String} languageCode Language code.
  7409. * @returns {Object} Object with constants representing identifiers for translation (as keys) and corresponding translation phrases (as values).
  7410. */
  7411. function getLanguage(languageCode) {
  7412. if (!hasLanguage(languageCode)) {
  7413. return null;
  7414. }
  7415. return (0, _object.deepClone)(getGlobalLanguageDictionary(languageCode));
  7416. }
  7417. /**
  7418. *
  7419. * Get if language with specified language code was registered.
  7420. *
  7421. * @param {String} languageCode Language code for specific language i.e. 'en-US', 'pt-BR', 'de-DE'.
  7422. * @returns {Boolean}
  7423. */
  7424. function hasLanguage(languageCode) {
  7425. return hasGlobalLanguageDictionary(languageCode);
  7426. }
  7427. /**
  7428. * Get default language dictionary.
  7429. *
  7430. * @returns {Object} Object with constants representing identifiers for translation (as keys) and corresponding translation phrases (as values).
  7431. */
  7432. function getDefaultLanguage() {
  7433. return _enUS2.default;
  7434. }
  7435. /**
  7436. * 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).
  7437. *
  7438. * @private
  7439. * @param {String} languageCode Language code.
  7440. * @param {Object} dictionary Dictionary which is extended.
  7441. */
  7442. function extendLanguageDictionary(languageCode, dictionary) {
  7443. if (languageCode !== DEFAULT_LANGUAGE_CODE) {
  7444. (0, _utils.extendNotExistingKeys)(dictionary, getGlobalLanguageDictionary(DEFAULT_LANGUAGE_CODE));
  7445. }
  7446. }
  7447. /**
  7448. * Get registered language dictionaries.
  7449. *
  7450. * @returns {Array}
  7451. */
  7452. function getLanguages() {
  7453. return getGlobalLanguagesDictionaries();
  7454. }
  7455. exports.registerLanguageDictionary = registerLanguage;
  7456. exports.getLanguageDictionary = getLanguage;
  7457. exports.hasLanguageDictionary = hasLanguage;
  7458. exports.getDefaultLanguageDictionary = getDefaultLanguage;
  7459. exports.getLanguagesDictionaries = getLanguages;
  7460. exports.DEFAULT_LANGUAGE_CODE = DEFAULT_LANGUAGE_CODE;
  7461. /**
  7462. * Automatically registers default dictionary.
  7463. */
  7464. registerLanguage(_enUS2.default);
  7465. /***/ }),
  7466. /* 72 */
  7467. /***/ (function(module, exports, __webpack_require__) {
  7468. var isObject = __webpack_require__(9);
  7469. var document = __webpack_require__(14).document;
  7470. // typeof document.createElement is 'object' in old IE
  7471. var is = isObject(document) && isObject(document.createElement);
  7472. module.exports = function (it) {
  7473. return is ? document.createElement(it) : {};
  7474. };
  7475. /***/ }),
  7476. /* 73 */
  7477. /***/ (function(module, exports, __webpack_require__) {
  7478. // 7.1.1 ToPrimitive(input [, PreferredType])
  7479. var isObject = __webpack_require__(9);
  7480. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  7481. // and the second argument - flag - preferred type is a string
  7482. module.exports = function (it, S) {
  7483. if (!isObject(it)) return it;
  7484. var fn, val;
  7485. if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  7486. if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
  7487. if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  7488. throw TypeError("Can't convert object to primitive value");
  7489. };
  7490. /***/ }),
  7491. /* 74 */
  7492. /***/ (function(module, exports, __webpack_require__) {
  7493. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  7494. var anObject = __webpack_require__(18);
  7495. var dPs = __webpack_require__(207);
  7496. var enumBugKeys = __webpack_require__(78);
  7497. var IE_PROTO = __webpack_require__(76)('IE_PROTO');
  7498. var Empty = function () { /* empty */ };
  7499. var PROTOTYPE = 'prototype';
  7500. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  7501. var createDict = function () {
  7502. // Thrash, waste and sodomy: IE GC bug
  7503. var iframe = __webpack_require__(72)('iframe');
  7504. var i = enumBugKeys.length;
  7505. var lt = '<';
  7506. var gt = '>';
  7507. var iframeDocument;
  7508. iframe.style.display = 'none';
  7509. __webpack_require__(101).appendChild(iframe);
  7510. iframe.src = 'javascript:'; // eslint-disable-line no-script-url
  7511. // createDict = iframe.contentWindow.Object;
  7512. // html.removeChild(iframe);
  7513. iframeDocument = iframe.contentWindow.document;
  7514. iframeDocument.open();
  7515. iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
  7516. iframeDocument.close();
  7517. createDict = iframeDocument.F;
  7518. while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];
  7519. return createDict();
  7520. };
  7521. module.exports = Object.create || function create(O, Properties) {
  7522. var result;
  7523. if (O !== null) {
  7524. Empty[PROTOTYPE] = anObject(O);
  7525. result = new Empty();
  7526. Empty[PROTOTYPE] = null;
  7527. // add "__proto__" for Object.getPrototypeOf polyfill
  7528. result[IE_PROTO] = O;
  7529. } else result = createDict();
  7530. return Properties === undefined ? result : dPs(result, Properties);
  7531. };
  7532. /***/ }),
  7533. /* 75 */
  7534. /***/ (function(module, exports, __webpack_require__) {
  7535. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  7536. var cof = __webpack_require__(43);
  7537. // eslint-disable-next-line no-prototype-builtins
  7538. module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
  7539. return cof(it) == 'String' ? it.split('') : Object(it);
  7540. };
  7541. /***/ }),
  7542. /* 76 */
  7543. /***/ (function(module, exports, __webpack_require__) {
  7544. var shared = __webpack_require__(77)('keys');
  7545. var uid = __webpack_require__(48);
  7546. module.exports = function (key) {
  7547. return shared[key] || (shared[key] = uid(key));
  7548. };
  7549. /***/ }),
  7550. /* 77 */
  7551. /***/ (function(module, exports, __webpack_require__) {
  7552. var global = __webpack_require__(14);
  7553. var SHARED = '__core-js_shared__';
  7554. var store = global[SHARED] || (global[SHARED] = {});
  7555. module.exports = function (key) {
  7556. return store[key] || (store[key] = {});
  7557. };
  7558. /***/ }),
  7559. /* 78 */
  7560. /***/ (function(module, exports) {
  7561. // IE 8- don't enum bug keys
  7562. module.exports = (
  7563. 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
  7564. ).split(',');
  7565. /***/ }),
  7566. /* 79 */
  7567. /***/ (function(module, exports, __webpack_require__) {
  7568. var ITERATOR = __webpack_require__(11)('iterator');
  7569. var SAFE_CLOSING = false;
  7570. try {
  7571. var riter = [7][ITERATOR]();
  7572. riter['return'] = function () { SAFE_CLOSING = true; };
  7573. // eslint-disable-next-line no-throw-literal
  7574. Array.from(riter, function () { throw 2; });
  7575. } catch (e) { /* empty */ }
  7576. module.exports = function (exec, skipClosing) {
  7577. if (!skipClosing && !SAFE_CLOSING) return false;
  7578. var safe = false;
  7579. try {
  7580. var arr = [7];
  7581. var iter = arr[ITERATOR]();
  7582. iter.next = function () { return { done: safe = true }; };
  7583. arr[ITERATOR] = function () { return iter; };
  7584. exec(arr);
  7585. } catch (e) { /* empty */ }
  7586. return safe;
  7587. };
  7588. /***/ }),
  7589. /* 80 */
  7590. /***/ (function(module, exports, __webpack_require__) {
  7591. var ctx = __webpack_require__(32);
  7592. var invoke = __webpack_require__(213);
  7593. var html = __webpack_require__(101);
  7594. var cel = __webpack_require__(72);
  7595. var global = __webpack_require__(14);
  7596. var process = global.process;
  7597. var setTask = global.setImmediate;
  7598. var clearTask = global.clearImmediate;
  7599. var MessageChannel = global.MessageChannel;
  7600. var Dispatch = global.Dispatch;
  7601. var counter = 0;
  7602. var queue = {};
  7603. var ONREADYSTATECHANGE = 'onreadystatechange';
  7604. var defer, channel, port;
  7605. var run = function () {
  7606. var id = +this;
  7607. // eslint-disable-next-line no-prototype-builtins
  7608. if (queue.hasOwnProperty(id)) {
  7609. var fn = queue[id];
  7610. delete queue[id];
  7611. fn();
  7612. }
  7613. };
  7614. var listener = function (event) {
  7615. run.call(event.data);
  7616. };
  7617. // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
  7618. if (!setTask || !clearTask) {
  7619. setTask = function setImmediate(fn) {
  7620. var args = [];
  7621. var i = 1;
  7622. while (arguments.length > i) args.push(arguments[i++]);
  7623. queue[++counter] = function () {
  7624. // eslint-disable-next-line no-new-func
  7625. invoke(typeof fn == 'function' ? fn : Function(fn), args);
  7626. };
  7627. defer(counter);
  7628. return counter;
  7629. };
  7630. clearTask = function clearImmediate(id) {
  7631. delete queue[id];
  7632. };
  7633. // Node.js 0.8-
  7634. if (__webpack_require__(43)(process) == 'process') {
  7635. defer = function (id) {
  7636. process.nextTick(ctx(run, id, 1));
  7637. };
  7638. // Sphere (JS game engine) Dispatch API
  7639. } else if (Dispatch && Dispatch.now) {
  7640. defer = function (id) {
  7641. Dispatch.now(ctx(run, id, 1));
  7642. };
  7643. // Browsers with MessageChannel, includes WebWorkers
  7644. } else if (MessageChannel) {
  7645. channel = new MessageChannel();
  7646. port = channel.port2;
  7647. channel.port1.onmessage = listener;
  7648. defer = ctx(port.postMessage, port, 1);
  7649. // Browsers with postMessage, skip WebWorkers
  7650. // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
  7651. } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) {
  7652. defer = function (id) {
  7653. global.postMessage(id + '', '*');
  7654. };
  7655. global.addEventListener('message', listener, false);
  7656. // IE8-
  7657. } else if (ONREADYSTATECHANGE in cel('script')) {
  7658. defer = function (id) {
  7659. html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function () {
  7660. html.removeChild(this);
  7661. run.call(id);
  7662. };
  7663. };
  7664. // Rest old browsers
  7665. } else {
  7666. defer = function (id) {
  7667. setTimeout(ctx(run, id, 1), 0);
  7668. };
  7669. }
  7670. }
  7671. module.exports = {
  7672. set: setTask,
  7673. clear: clearTask
  7674. };
  7675. /***/ }),
  7676. /* 81 */
  7677. /***/ (function(module, exports, __webpack_require__) {
  7678. // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
  7679. var $keys = __webpack_require__(99);
  7680. var hiddenKeys = __webpack_require__(78).concat('length', 'prototype');
  7681. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  7682. return $keys(O, hiddenKeys);
  7683. };
  7684. /***/ }),
  7685. /* 82 */
  7686. /***/ (function(module, exports, __webpack_require__) {
  7687. // helper for String#{startsWith, endsWith, includes}
  7688. var isRegExp = __webpack_require__(142);
  7689. var defined = __webpack_require__(38);
  7690. module.exports = function (that, searchString, NAME) {
  7691. if (isRegExp(searchString)) throw TypeError('String#' + NAME + " doesn't accept regex!");
  7692. return String(defined(that));
  7693. };
  7694. /***/ }),
  7695. /* 83 */
  7696. /***/ (function(module, exports, __webpack_require__) {
  7697. var MATCH = __webpack_require__(11)('match');
  7698. module.exports = function (KEY) {
  7699. var re = /./;
  7700. try {
  7701. '/./'[KEY](re);
  7702. } catch (e) {
  7703. try {
  7704. re[MATCH] = false;
  7705. return !'/./'[KEY](re);
  7706. } catch (f) { /* empty */ }
  7707. } return true;
  7708. };
  7709. /***/ }),
  7710. /* 84 */
  7711. /***/ (function(module, exports, __webpack_require__) {
  7712. "use strict";
  7713. var $defineProperty = __webpack_require__(20);
  7714. var createDesc = __webpack_require__(49);
  7715. module.exports = function (object, index, value) {
  7716. if (index in object) $defineProperty.f(object, index, createDesc(0, value));
  7717. else object[index] = value;
  7718. };
  7719. /***/ }),
  7720. /* 85 */
  7721. /***/ (function(module, exports, __webpack_require__) {
  7722. "use strict";
  7723. var addToUnscopables = __webpack_require__(46);
  7724. var step = __webpack_require__(108);
  7725. var Iterators = __webpack_require__(50);
  7726. var toIObject = __webpack_require__(24);
  7727. // 22.1.3.4 Array.prototype.entries()
  7728. // 22.1.3.13 Array.prototype.keys()
  7729. // 22.1.3.29 Array.prototype.values()
  7730. // 22.1.3.30 Array.prototype[@@iterator]()
  7731. module.exports = __webpack_require__(106)(Array, 'Array', function (iterated, kind) {
  7732. this._t = toIObject(iterated); // target
  7733. this._i = 0; // next index
  7734. this._k = kind; // kind
  7735. // 22.1.5.2.1 %ArrayIteratorPrototype%.next()
  7736. }, function () {
  7737. var O = this._t;
  7738. var kind = this._k;
  7739. var index = this._i++;
  7740. if (!O || index >= O.length) {
  7741. this._t = undefined;
  7742. return step(1);
  7743. }
  7744. if (kind == 'keys') return step(0, index);
  7745. if (kind == 'values') return step(0, O[index]);
  7746. return step(0, [index, O[index]]);
  7747. }, 'values');
  7748. // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
  7749. Iterators.Arguments = Iterators.Array;
  7750. addToUnscopables('keys');
  7751. addToUnscopables('values');
  7752. addToUnscopables('entries');
  7753. /***/ }),
  7754. /* 86 */
  7755. /***/ (function(module, exports, __webpack_require__) {
  7756. "use strict";
  7757. exports.__esModule = true;
  7758. 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; }; }();
  7759. var _coords = __webpack_require__(54);
  7760. var _coords2 = _interopRequireDefault(_coords);
  7761. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7762. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7763. /**
  7764. * A cell range is a set of exactly two CellCoords (that can be the same or different).
  7765. *
  7766. * @class CellRange
  7767. */
  7768. var CellRange = function () {
  7769. /**
  7770. * @param {CellCoords} highlight Used to draw bold border around a cell where selection was
  7771. * started and to edit the cell when you press Enter.
  7772. * @param {CellCoords} [from] Usually the same as highlight, but in Excel there is distinction - one can change
  7773. * highlight within a selection.
  7774. * @param {CellCoords} [to] End selection.
  7775. */
  7776. function CellRange(highlight) {
  7777. var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : highlight;
  7778. var to = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : highlight;
  7779. _classCallCheck(this, CellRange);
  7780. this.highlight = highlight;
  7781. this.from = from;
  7782. this.to = to;
  7783. }
  7784. /**
  7785. * Set the new coordinates for highlighting selection.
  7786. *
  7787. * @param {CellCoords} coords Coordinates to use.
  7788. */
  7789. _createClass(CellRange, [{
  7790. key: 'setHighlight',
  7791. value: function setHighlight(coords) {
  7792. this.highlight = coords;
  7793. return this;
  7794. }
  7795. /**
  7796. * Set the new coordinates where selection starts from.
  7797. *
  7798. * @param {CellCoords} coords Coordinates to use.
  7799. */
  7800. }, {
  7801. key: 'setFrom',
  7802. value: function setFrom(coords) {
  7803. this.from = coords;
  7804. return this;
  7805. }
  7806. /**
  7807. * Set new coordinates where selection ends from.
  7808. *
  7809. * @param {CellCoords} coords Coordinates to use.
  7810. */
  7811. }, {
  7812. key: 'setTo',
  7813. value: function setTo(coords) {
  7814. this.to = coords;
  7815. return this;
  7816. }
  7817. /**
  7818. * Checks if given coords are valid in context of a given Walkontable instance
  7819. *
  7820. * @param {Walkontable} wotInstance
  7821. * @returns {Boolean}
  7822. */
  7823. }, {
  7824. key: 'isValid',
  7825. value: function isValid(wotInstance) {
  7826. return this.from.isValid(wotInstance) && this.to.isValid(wotInstance);
  7827. }
  7828. /**
  7829. * Checks if this cell range is restricted to one cell
  7830. *
  7831. * @returns {Boolean}
  7832. */
  7833. }, {
  7834. key: 'isSingle',
  7835. value: function isSingle() {
  7836. return this.from.row === this.to.row && this.from.col === this.to.col;
  7837. }
  7838. /**
  7839. * Returns selected range height (in number of rows)
  7840. *
  7841. * @returns {Number}
  7842. */
  7843. }, {
  7844. key: 'getHeight',
  7845. value: function getHeight() {
  7846. return Math.max(this.from.row, this.to.row) - Math.min(this.from.row, this.to.row) + 1;
  7847. }
  7848. /**
  7849. * Returns selected range width (in number of columns)
  7850. *
  7851. * @returns {Number}
  7852. */
  7853. }, {
  7854. key: 'getWidth',
  7855. value: function getWidth() {
  7856. return Math.max(this.from.col, this.to.col) - Math.min(this.from.col, this.to.col) + 1;
  7857. }
  7858. /**
  7859. * Checks if given cell coords is within `from` and `to` cell coords of this range
  7860. *
  7861. * @param {CellCoords} cellCoords
  7862. * @returns {Boolean}
  7863. */
  7864. }, {
  7865. key: 'includes',
  7866. value: function includes(cellCoords) {
  7867. var row = cellCoords.row,
  7868. col = cellCoords.col;
  7869. var topLeft = this.getTopLeftCorner();
  7870. var bottomRight = this.getBottomRightCorner();
  7871. return topLeft.row <= row && bottomRight.row >= row && topLeft.col <= col && bottomRight.col >= col;
  7872. }
  7873. /**
  7874. * Checks if given range is within of this range
  7875. *
  7876. * @param {CellRange} testedRange
  7877. * @returns {Boolean}
  7878. */
  7879. }, {
  7880. key: 'includesRange',
  7881. value: function includesRange(testedRange) {
  7882. return this.includes(testedRange.getTopLeftCorner()) && this.includes(testedRange.getBottomRightCorner());
  7883. }
  7884. /**
  7885. * Checks if given range is equal to this range
  7886. *
  7887. * @param {CellRange} testedRange
  7888. * @returns {Boolean}
  7889. */
  7890. }, {
  7891. key: 'isEqual',
  7892. value: function isEqual(testedRange) {
  7893. 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);
  7894. }
  7895. /**
  7896. * Checks if tested range overlaps with the range.
  7897. * Range A is considered to to be overlapping with range B if intersection of A and B or B and A is not empty.
  7898. *
  7899. * @param {CellRange} testedRange
  7900. * @returns {Boolean}
  7901. */
  7902. }, {
  7903. key: 'overlaps',
  7904. value: function overlaps(testedRange) {
  7905. return testedRange.isSouthEastOf(this.getTopLeftCorner()) && testedRange.isNorthWestOf(this.getBottomRightCorner());
  7906. }
  7907. /**
  7908. * @param {CellRange} testedCoords
  7909. * @returns {Boolean}
  7910. */
  7911. }, {
  7912. key: 'isSouthEastOf',
  7913. value: function isSouthEastOf(testedCoords) {
  7914. return this.getTopLeftCorner().isSouthEastOf(testedCoords) || this.getBottomRightCorner().isSouthEastOf(testedCoords);
  7915. }
  7916. /**
  7917. * @param {CellRange} testedCoords
  7918. * @returns {Boolean}
  7919. */
  7920. }, {
  7921. key: 'isNorthWestOf',
  7922. value: function isNorthWestOf(testedCoords) {
  7923. return this.getTopLeftCorner().isNorthWestOf(testedCoords) || this.getBottomRightCorner().isNorthWestOf(testedCoords);
  7924. }
  7925. /**
  7926. * Returns `true` if the provided range is overlapping the current range horizontally
  7927. * (e.g. the current range's last column is 5 and the provided range's first column is 3).
  7928. *
  7929. * @param {CellRange} range The range to check against.
  7930. * @returns {Boolean}
  7931. */
  7932. }, {
  7933. key: 'isOverlappingHorizontally',
  7934. value: function isOverlappingHorizontally(range) {
  7935. 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;
  7936. }
  7937. /**
  7938. * Returns `true` if the provided range is overlapping the current range vertically
  7939. * (e.g. the current range's last row is 5 and the provided range's first row is 3).
  7940. *
  7941. * @param {CellRange} range The range to check against.
  7942. * @returns {Boolean}
  7943. */
  7944. }, {
  7945. key: 'isOverlappingVertically',
  7946. value: function isOverlappingVertically(range) {
  7947. 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;
  7948. }
  7949. /**
  7950. * Adds a cell to a range (only if exceeds corners of the range). Returns information if range was expanded
  7951. *
  7952. * @param {CellCoords} cellCoords
  7953. * @returns {Boolean}
  7954. */
  7955. }, {
  7956. key: 'expand',
  7957. value: function expand(cellCoords) {
  7958. var topLeft = this.getTopLeftCorner();
  7959. var bottomRight = this.getBottomRightCorner();
  7960. if (cellCoords.row < topLeft.row || cellCoords.col < topLeft.col || cellCoords.row > bottomRight.row || cellCoords.col > bottomRight.col) {
  7961. this.from = new _coords2.default(Math.min(topLeft.row, cellCoords.row), Math.min(topLeft.col, cellCoords.col));
  7962. this.to = new _coords2.default(Math.max(bottomRight.row, cellCoords.row), Math.max(bottomRight.col, cellCoords.col));
  7963. return true;
  7964. }
  7965. return false;
  7966. }
  7967. /**
  7968. * @param {CellRange} expandingRange
  7969. * @returns {Boolean}
  7970. */
  7971. }, {
  7972. key: 'expandByRange',
  7973. value: function expandByRange(expandingRange) {
  7974. if (this.includesRange(expandingRange) || !this.overlaps(expandingRange)) {
  7975. return false;
  7976. }
  7977. var topLeft = this.getTopLeftCorner();
  7978. var bottomRight = this.getBottomRightCorner();
  7979. var initialDirection = this.getDirection();
  7980. var expandingTopLeft = expandingRange.getTopLeftCorner();
  7981. var expandingBottomRight = expandingRange.getBottomRightCorner();
  7982. var resultTopRow = Math.min(topLeft.row, expandingTopLeft.row);
  7983. var resultTopCol = Math.min(topLeft.col, expandingTopLeft.col);
  7984. var resultBottomRow = Math.max(bottomRight.row, expandingBottomRight.row);
  7985. var resultBottomCol = Math.max(bottomRight.col, expandingBottomRight.col);
  7986. var finalFrom = new _coords2.default(resultTopRow, resultTopCol);
  7987. var finalTo = new _coords2.default(resultBottomRow, resultBottomCol);
  7988. this.from = finalFrom;
  7989. this.to = finalTo;
  7990. this.setDirection(initialDirection);
  7991. if (this.highlight.row === this.getBottomRightCorner().row && this.getVerticalDirection() === 'N-S') {
  7992. this.flipDirectionVertically();
  7993. }
  7994. if (this.highlight.col === this.getTopRightCorner().col && this.getHorizontalDirection() === 'W-E') {
  7995. this.flipDirectionHorizontally();
  7996. }
  7997. return true;
  7998. }
  7999. /**
  8000. * @returns {String}
  8001. */
  8002. }, {
  8003. key: 'getDirection',
  8004. value: function getDirection() {
  8005. if (this.from.isNorthWestOf(this.to)) {
  8006. // NorthWest - SouthEast
  8007. return 'NW-SE';
  8008. } else if (this.from.isNorthEastOf(this.to)) {
  8009. // NorthEast - SouthWest
  8010. return 'NE-SW';
  8011. } else if (this.from.isSouthEastOf(this.to)) {
  8012. // SouthEast - NorthWest
  8013. return 'SE-NW';
  8014. } else if (this.from.isSouthWestOf(this.to)) {
  8015. // SouthWest - NorthEast
  8016. return 'SW-NE';
  8017. }
  8018. }
  8019. /**
  8020. * Get the vertical direction of the range.
  8021. *
  8022. * @returns {String} Available options: `N-S` (north->south), `S-N` (south->north).
  8023. */
  8024. }, {
  8025. key: 'getVerticalDirection',
  8026. value: function getVerticalDirection() {
  8027. return ['NE-SW', 'NW-SE'].indexOf(this.getDirection()) > -1 ? 'N-S' : 'S-N';
  8028. }
  8029. /**
  8030. * Get the horizontal direction of the range.
  8031. *
  8032. * @returns {String} Available options: `W-E` (west->east), `E-W` (east->west).
  8033. */
  8034. }, {
  8035. key: 'getHorizontalDirection',
  8036. value: function getHorizontalDirection() {
  8037. return ['NW-SE', 'SW-NE'].indexOf(this.getDirection()) > -1 ? 'W-E' : 'E-W';
  8038. }
  8039. /**
  8040. * @param {String} direction
  8041. */
  8042. }, {
  8043. key: 'setDirection',
  8044. value: function setDirection(direction) {
  8045. switch (direction) {
  8046. case 'NW-SE':
  8047. var _ref = [this.getTopLeftCorner(), this.getBottomRightCorner()];
  8048. this.from = _ref[0];
  8049. this.to = _ref[1];
  8050. break;
  8051. case 'NE-SW':
  8052. var _ref2 = [this.getTopRightCorner(), this.getBottomLeftCorner()];
  8053. this.from = _ref2[0];
  8054. this.to = _ref2[1];
  8055. break;
  8056. case 'SE-NW':
  8057. var _ref3 = [this.getBottomRightCorner(), this.getTopLeftCorner()];
  8058. this.from = _ref3[0];
  8059. this.to = _ref3[1];
  8060. break;
  8061. case 'SW-NE':
  8062. var _ref4 = [this.getBottomLeftCorner(), this.getTopRightCorner()];
  8063. this.from = _ref4[0];
  8064. this.to = _ref4[1];
  8065. break;
  8066. default:
  8067. break;
  8068. }
  8069. }
  8070. /**
  8071. * Flip the direction vertically. (e.g. `NW-SE` changes to `SW-NE`)
  8072. */
  8073. }, {
  8074. key: 'flipDirectionVertically',
  8075. value: function flipDirectionVertically() {
  8076. var direction = this.getDirection();
  8077. switch (direction) {
  8078. case 'NW-SE':
  8079. this.setDirection('SW-NE');
  8080. break;
  8081. case 'NE-SW':
  8082. this.setDirection('SE-NW');
  8083. break;
  8084. case 'SE-NW':
  8085. this.setDirection('NE-SW');
  8086. break;
  8087. case 'SW-NE':
  8088. this.setDirection('NW-SE');
  8089. break;
  8090. default:
  8091. break;
  8092. }
  8093. }
  8094. /**
  8095. * Flip the direction horizontally. (e.g. `NW-SE` changes to `NE-SW`)
  8096. */
  8097. }, {
  8098. key: 'flipDirectionHorizontally',
  8099. value: function flipDirectionHorizontally() {
  8100. var direction = this.getDirection();
  8101. switch (direction) {
  8102. case 'NW-SE':
  8103. this.setDirection('NE-SW');
  8104. break;
  8105. case 'NE-SW':
  8106. this.setDirection('NW-SE');
  8107. break;
  8108. case 'SE-NW':
  8109. this.setDirection('SW-NE');
  8110. break;
  8111. case 'SW-NE':
  8112. this.setDirection('SE-NW');
  8113. break;
  8114. default:
  8115. break;
  8116. }
  8117. }
  8118. /**
  8119. * Get top left corner of this range
  8120. *
  8121. * @returns {CellCoords}
  8122. */
  8123. }, {
  8124. key: 'getTopLeftCorner',
  8125. value: function getTopLeftCorner() {
  8126. return new _coords2.default(Math.min(this.from.row, this.to.row), Math.min(this.from.col, this.to.col));
  8127. }
  8128. /**
  8129. * Get bottom right corner of this range
  8130. *
  8131. * @returns {CellCoords}
  8132. */
  8133. }, {
  8134. key: 'getBottomRightCorner',
  8135. value: function getBottomRightCorner() {
  8136. return new _coords2.default(Math.max(this.from.row, this.to.row), Math.max(this.from.col, this.to.col));
  8137. }
  8138. /**
  8139. * Get top right corner of this range
  8140. *
  8141. * @returns {CellCoords}
  8142. */
  8143. }, {
  8144. key: 'getTopRightCorner',
  8145. value: function getTopRightCorner() {
  8146. return new _coords2.default(Math.min(this.from.row, this.to.row), Math.max(this.from.col, this.to.col));
  8147. }
  8148. /**
  8149. * Get bottom left corner of this range
  8150. *
  8151. * @returns {CellCoords}
  8152. */
  8153. }, {
  8154. key: 'getBottomLeftCorner',
  8155. value: function getBottomLeftCorner() {
  8156. return new _coords2.default(Math.max(this.from.row, this.to.row), Math.min(this.from.col, this.to.col));
  8157. }
  8158. /**
  8159. * @param {CellCoords} coords
  8160. * @param {CellRange} expandedRange
  8161. * @returns {*}
  8162. */
  8163. }, {
  8164. key: 'isCorner',
  8165. value: function isCorner(coords, expandedRange) {
  8166. 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)))) {
  8167. return true;
  8168. }
  8169. return coords.isEqual(this.getTopLeftCorner()) || coords.isEqual(this.getTopRightCorner()) || coords.isEqual(this.getBottomLeftCorner()) || coords.isEqual(this.getBottomRightCorner());
  8170. }
  8171. /**
  8172. * @param {CellCoords} coords
  8173. * @param {CellRange} expandedRange
  8174. * @returns {CellCoords}
  8175. */
  8176. }, {
  8177. key: 'getOppositeCorner',
  8178. value: function getOppositeCorner(coords, expandedRange) {
  8179. if (!(coords instanceof _coords2.default)) {
  8180. return false;
  8181. }
  8182. if (expandedRange) {
  8183. if (expandedRange.includes(coords)) {
  8184. if (this.getTopLeftCorner().isEqual(new _coords2.default(expandedRange.from.row, expandedRange.from.col))) {
  8185. return this.getBottomRightCorner();
  8186. }
  8187. if (this.getTopRightCorner().isEqual(new _coords2.default(expandedRange.from.row, expandedRange.to.col))) {
  8188. return this.getBottomLeftCorner();
  8189. }
  8190. if (this.getBottomLeftCorner().isEqual(new _coords2.default(expandedRange.to.row, expandedRange.from.col))) {
  8191. return this.getTopRightCorner();
  8192. }
  8193. if (this.getBottomRightCorner().isEqual(new _coords2.default(expandedRange.to.row, expandedRange.to.col))) {
  8194. return this.getTopLeftCorner();
  8195. }
  8196. }
  8197. }
  8198. if (coords.isEqual(this.getBottomRightCorner())) {
  8199. return this.getTopLeftCorner();
  8200. } else if (coords.isEqual(this.getTopLeftCorner())) {
  8201. return this.getBottomRightCorner();
  8202. } else if (coords.isEqual(this.getTopRightCorner())) {
  8203. return this.getBottomLeftCorner();
  8204. } else if (coords.isEqual(this.getBottomLeftCorner())) {
  8205. return this.getTopRightCorner();
  8206. }
  8207. }
  8208. /**
  8209. * @param {CellRange} range
  8210. * @returns {Array}
  8211. */
  8212. }, {
  8213. key: 'getBordersSharedWith',
  8214. value: function getBordersSharedWith(range) {
  8215. if (!this.includesRange(range)) {
  8216. return [];
  8217. }
  8218. var thisBorders = {
  8219. top: Math.min(this.from.row, this.to.row),
  8220. bottom: Math.max(this.from.row, this.to.row),
  8221. left: Math.min(this.from.col, this.to.col),
  8222. right: Math.max(this.from.col, this.to.col)
  8223. };
  8224. var rangeBorders = {
  8225. top: Math.min(range.from.row, range.to.row),
  8226. bottom: Math.max(range.from.row, range.to.row),
  8227. left: Math.min(range.from.col, range.to.col),
  8228. right: Math.max(range.from.col, range.to.col)
  8229. };
  8230. var result = [];
  8231. if (thisBorders.top == rangeBorders.top) {
  8232. result.push('top');
  8233. }
  8234. if (thisBorders.right == rangeBorders.right) {
  8235. result.push('right');
  8236. }
  8237. if (thisBorders.bottom == rangeBorders.bottom) {
  8238. result.push('bottom');
  8239. }
  8240. if (thisBorders.left == rangeBorders.left) {
  8241. result.push('left');
  8242. }
  8243. return result;
  8244. }
  8245. /**
  8246. * Get inner selected cell coords defined by this range
  8247. *
  8248. * @returns {Array}
  8249. */
  8250. }, {
  8251. key: 'getInner',
  8252. value: function getInner() {
  8253. var topLeft = this.getTopLeftCorner();
  8254. var bottomRight = this.getBottomRightCorner();
  8255. var out = [];
  8256. for (var r = topLeft.row; r <= bottomRight.row; r++) {
  8257. for (var c = topLeft.col; c <= bottomRight.col; c++) {
  8258. if (!(this.from.row === r && this.from.col === c) && !(this.to.row === r && this.to.col === c)) {
  8259. out.push(new _coords2.default(r, c));
  8260. }
  8261. }
  8262. }
  8263. return out;
  8264. }
  8265. /**
  8266. * Get all selected cell coords defined by this range
  8267. *
  8268. * @returns {Array}
  8269. */
  8270. }, {
  8271. key: 'getAll',
  8272. value: function getAll() {
  8273. var topLeft = this.getTopLeftCorner();
  8274. var bottomRight = this.getBottomRightCorner();
  8275. var out = [];
  8276. for (var r = topLeft.row; r <= bottomRight.row; r++) {
  8277. for (var c = topLeft.col; c <= bottomRight.col; c++) {
  8278. if (topLeft.row === r && topLeft.col === c) {
  8279. out.push(topLeft);
  8280. } else if (bottomRight.row === r && bottomRight.col === c) {
  8281. out.push(bottomRight);
  8282. } else {
  8283. out.push(new _coords2.default(r, c));
  8284. }
  8285. }
  8286. }
  8287. return out;
  8288. }
  8289. /**
  8290. * Runs a callback function against all cells in the range. You can break the iteration by returning
  8291. * `false` in the callback function
  8292. *
  8293. * @param callback {Function}
  8294. */
  8295. }, {
  8296. key: 'forAll',
  8297. value: function forAll(callback) {
  8298. var topLeft = this.getTopLeftCorner();
  8299. var bottomRight = this.getBottomRightCorner();
  8300. for (var r = topLeft.row; r <= bottomRight.row; r++) {
  8301. for (var c = topLeft.col; c <= bottomRight.col; c++) {
  8302. var breakIteration = callback(r, c);
  8303. if (breakIteration === false) {
  8304. return;
  8305. }
  8306. }
  8307. }
  8308. }
  8309. /**
  8310. * Convert CellRange to literal object.
  8311. *
  8312. * @return {Object} Returns a literal object with `from` and `to` properties which each of that object
  8313. * contains `row` and `col` keys.
  8314. */
  8315. }, {
  8316. key: 'toObject',
  8317. value: function toObject() {
  8318. return {
  8319. from: this.from.toObject(),
  8320. to: this.to.toObject()
  8321. };
  8322. }
  8323. }]);
  8324. return CellRange;
  8325. }();
  8326. exports.default = CellRange;
  8327. /***/ }),
  8328. /* 87 */
  8329. /***/ (function(module, exports, __webpack_require__) {
  8330. "use strict";
  8331. exports.__esModule = true;
  8332. exports.getRegisteredCellTypes = exports.getRegisteredCellTypeNames = exports.hasCellType = exports.getCellType = exports.registerCellType = undefined;
  8333. var _staticRegister2 = __webpack_require__(39);
  8334. var _staticRegister3 = _interopRequireDefault(_staticRegister2);
  8335. var _editors = __webpack_require__(17);
  8336. var _renderers = __webpack_require__(13);
  8337. var _validators = __webpack_require__(28);
  8338. var _autocompleteType = __webpack_require__(254);
  8339. var _autocompleteType2 = _interopRequireDefault(_autocompleteType);
  8340. var _checkboxType = __webpack_require__(255);
  8341. var _checkboxType2 = _interopRequireDefault(_checkboxType);
  8342. var _dateType = __webpack_require__(256);
  8343. var _dateType2 = _interopRequireDefault(_dateType);
  8344. var _dropdownType = __webpack_require__(257);
  8345. var _dropdownType2 = _interopRequireDefault(_dropdownType);
  8346. var _handsontableType = __webpack_require__(258);
  8347. var _handsontableType2 = _interopRequireDefault(_handsontableType);
  8348. var _numericType = __webpack_require__(259);
  8349. var _numericType2 = _interopRequireDefault(_numericType);
  8350. var _passwordType = __webpack_require__(260);
  8351. var _passwordType2 = _interopRequireDefault(_passwordType);
  8352. var _textType = __webpack_require__(261);
  8353. var _textType2 = _interopRequireDefault(_textType);
  8354. var _timeType = __webpack_require__(262);
  8355. var _timeType2 = _interopRequireDefault(_timeType);
  8356. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8357. var _staticRegister = (0, _staticRegister3.default)('cellTypes'),
  8358. register = _staticRegister.register,
  8359. getItem = _staticRegister.getItem,
  8360. hasItem = _staticRegister.hasItem,
  8361. getNames = _staticRegister.getNames,
  8362. getValues = _staticRegister.getValues;
  8363. _register('autocomplete', _autocompleteType2.default);
  8364. _register('checkbox', _checkboxType2.default);
  8365. _register('date', _dateType2.default);
  8366. _register('dropdown', _dropdownType2.default);
  8367. _register('handsontable', _handsontableType2.default);
  8368. _register('numeric', _numericType2.default);
  8369. _register('password', _passwordType2.default);
  8370. _register('text', _textType2.default);
  8371. _register('time', _timeType2.default);
  8372. /**
  8373. * Retrieve cell type object.
  8374. *
  8375. * @param {String} name Cell type identification.
  8376. * @returns {Object} Returns cell type object.
  8377. */
  8378. function _getItem(name) {
  8379. if (!hasItem(name)) {
  8380. 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');
  8381. }
  8382. return getItem(name);
  8383. }
  8384. /**
  8385. * Register cell type under specified name.
  8386. *
  8387. * @param {String} name Cell type identification.
  8388. * @param {Object} type An object with contains keys (eq: `editor`, `renderer`, `validator`) which describes specified behaviour of the cell.
  8389. */
  8390. function _register(name, type) {
  8391. var editor = type.editor,
  8392. renderer = type.renderer,
  8393. validator = type.validator;
  8394. if (editor) {
  8395. (0, _editors.registerEditor)(name, editor);
  8396. }
  8397. if (renderer) {
  8398. (0, _renderers.registerRenderer)(name, renderer);
  8399. }
  8400. if (validator) {
  8401. (0, _validators.registerValidator)(name, validator);
  8402. }
  8403. register(name, type);
  8404. }
  8405. exports.registerCellType = _register;
  8406. exports.getCellType = _getItem;
  8407. exports.hasCellType = hasItem;
  8408. exports.getRegisteredCellTypeNames = getNames;
  8409. exports.getRegisteredCellTypes = getValues;
  8410. /***/ }),
  8411. /* 88 */
  8412. /***/ (function(module, exports, __webpack_require__) {
  8413. "use strict";
  8414. exports.__esModule = true;
  8415. 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; };
  8416. 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"); } }; }();
  8417. 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.']);
  8418. exports.default = Core;
  8419. var _element = __webpack_require__(0);
  8420. var _setting = __webpack_require__(89);
  8421. var _function = __webpack_require__(42);
  8422. var _console = __webpack_require__(56);
  8423. var _mixed = __webpack_require__(16);
  8424. var _browser = __webpack_require__(27);
  8425. var _dataMap = __webpack_require__(263);
  8426. var _dataMap2 = _interopRequireDefault(_dataMap);
  8427. var _editorManager = __webpack_require__(266);
  8428. var _editorManager2 = _interopRequireDefault(_editorManager);
  8429. var _eventManager = __webpack_require__(6);
  8430. var _eventManager2 = _interopRequireDefault(_eventManager);
  8431. var _object = __webpack_require__(2);
  8432. var _array = __webpack_require__(1);
  8433. var _templateLiteralTag = __webpack_require__(41);
  8434. var _plugins = __webpack_require__(8);
  8435. var _renderers = __webpack_require__(13);
  8436. var _validators = __webpack_require__(28);
  8437. var _string = __webpack_require__(36);
  8438. var _number = __webpack_require__(5);
  8439. var _tableView = __webpack_require__(267);
  8440. var _tableView2 = _interopRequireDefault(_tableView);
  8441. var _dataSource = __webpack_require__(268);
  8442. var _dataSource2 = _interopRequireDefault(_dataSource);
  8443. var _data = __webpack_require__(90);
  8444. var _recordTranslator = __webpack_require__(193);
  8445. var _rootInstance = __webpack_require__(194);
  8446. var _src = __webpack_require__(4);
  8447. var _pluginHooks = __webpack_require__(15);
  8448. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  8449. var _defaultSettings = __webpack_require__(195);
  8450. var _defaultSettings2 = _interopRequireDefault(_defaultSettings);
  8451. var _cellTypes = __webpack_require__(87);
  8452. var _i18n = __webpack_require__(196);
  8453. var _dictionariesManager = __webpack_require__(71);
  8454. var _utils = __webpack_require__(197);
  8455. var _keyStateObserver = __webpack_require__(198);
  8456. var _selection = __webpack_require__(272);
  8457. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8458. function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
  8459. 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); } }
  8460. var activeGuid = null;
  8461. /**
  8462. * Handsontable constructor
  8463. *
  8464. * @core
  8465. * @constructor Core
  8466. * @description
  8467. *
  8468. * After Handsontable is constructed, you can modify the grid behavior using the available public methods.
  8469. *
  8470. * ---
  8471. * ## How to call methods
  8472. *
  8473. * These are 2 equal ways to call a Handsontable method:
  8474. *
  8475. * ```js
  8476. * // all following examples assume that you constructed Handsontable like this
  8477. * var ht = new Handsontable(document.getElementById('example1'), options);
  8478. *
  8479. * // now, to use setDataAtCell method, you can either:
  8480. * ht.setDataAtCell(0, 0, 'new value');
  8481. * ```
  8482. *
  8483. * Alternatively, you can call the method using jQuery wrapper (__obsolete__, requires initialization using our jQuery guide
  8484. * ```js
  8485. * $('#example1').handsontable('setDataAtCell', 0, 0, 'new value');
  8486. * ```
  8487. * ---
  8488. */
  8489. function Core(rootElement, userSettings) {
  8490. var _this = this;
  8491. var rootInstanceSymbol = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  8492. var priv,
  8493. datamap,
  8494. dataSource,
  8495. grid,
  8496. editorManager,
  8497. preventScrollingToCell = false,
  8498. instance = this,
  8499. GridSettings = function GridSettings() {},
  8500. eventManager = new _eventManager2.default(instance);
  8501. (0, _object.extend)(GridSettings.prototype, _defaultSettings2.default.prototype); // create grid settings as a copy of default settings
  8502. (0, _object.extend)(GridSettings.prototype, userSettings); // overwrite defaults with user settings
  8503. (0, _object.extend)(GridSettings.prototype, expandType(userSettings));
  8504. (0, _utils.applyLanguageSetting)(GridSettings.prototype, userSettings.language);
  8505. if ((0, _rootInstance.hasValidParameter)(rootInstanceSymbol)) {
  8506. (0, _rootInstance.registerAsRootInstance)(this);
  8507. }
  8508. (0, _keyStateObserver.startObserving)();
  8509. this.rootElement = rootElement;
  8510. this.isHotTableEnv = (0, _element.isChildOfWebComponentTable)(this.rootElement);
  8511. _eventManager2.default.isHotTableEnv = this.isHotTableEnv;
  8512. this.container = document.createElement('div');
  8513. this.renderCall = false;
  8514. rootElement.insertBefore(this.container, rootElement.firstChild);
  8515. if (false) {
  8516. (0, _mixed._injectProductInfo)(userSettings.licenseKey, rootElement);
  8517. }
  8518. this.guid = 'ht_' + (0, _string.randomString)(); // this is the namespace for global events
  8519. var recordTranslator = (0, _recordTranslator.getTranslator)(instance);
  8520. dataSource = new _dataSource2.default(instance);
  8521. if (!this.rootElement.id || this.rootElement.id.substring(0, 3) === 'ht_') {
  8522. this.rootElement.id = this.guid; // if root element does not have an id, assign a random id
  8523. }
  8524. priv = {
  8525. cellSettings: [],
  8526. columnSettings: [],
  8527. columnsSettingConflicts: ['data', 'width', 'language'],
  8528. settings: new GridSettings(), // current settings instance
  8529. selRange: null, // exposed by public method `getSelectedRange`
  8530. isPopulated: null,
  8531. scrollable: null,
  8532. firstRun: true
  8533. };
  8534. var selection = new _selection.Selection(priv.settings, {
  8535. countCols: function countCols() {
  8536. return instance.countCols();
  8537. },
  8538. countRows: function countRows() {
  8539. return instance.countRows();
  8540. },
  8541. propToCol: function propToCol(prop) {
  8542. return datamap.propToCol(prop);
  8543. },
  8544. isEditorOpened: function isEditorOpened() {
  8545. return instance.getActiveEditor() ? instance.getActiveEditor().isOpened() : false;
  8546. }
  8547. });
  8548. this.selection = selection;
  8549. this.selection.addLocalHook('beforeSetRangeStart', function (cellCoords) {
  8550. _this.runHooks('beforeSetRangeStart', cellCoords);
  8551. });
  8552. this.selection.addLocalHook('beforeSetRangeStartOnly', function (cellCoords) {
  8553. _this.runHooks('beforeSetRangeStartOnly', cellCoords);
  8554. });
  8555. this.selection.addLocalHook('beforeSetRangeEnd', function (cellCoords) {
  8556. _this.runHooks('beforeSetRangeEnd', cellCoords);
  8557. if (cellCoords.row < 0) {
  8558. cellCoords.row = _this.view.wt.wtTable.getFirstVisibleRow();
  8559. }
  8560. if (cellCoords.col < 0) {
  8561. cellCoords.col = _this.view.wt.wtTable.getFirstVisibleColumn();
  8562. }
  8563. });
  8564. this.selection.addLocalHook('afterSetRangeEnd', function (cellCoords) {
  8565. var preventScrolling = (0, _object.createObjectPropListener)(false);
  8566. var selectionRange = _this.selection.getSelectedRange();
  8567. var _selectionRange$curre = selectionRange.current(),
  8568. from = _selectionRange$curre.from,
  8569. to = _selectionRange$curre.to;
  8570. var selectionLayerLevel = selectionRange.size() - 1;
  8571. _this.runHooks('afterSelection', from.row, from.col, to.row, to.col, preventScrolling, selectionLayerLevel);
  8572. _this.runHooks('afterSelectionByProp', from.row, instance.colToProp(from.col), to.row, instance.colToProp(to.col), preventScrolling, selectionLayerLevel);
  8573. var isSelectedByAnyHeader = _this.selection.isSelectedByAnyHeader();
  8574. var currentSelectedRange = _this.selection.selectedRange.current();
  8575. var scrollToCell = true;
  8576. if (preventScrollingToCell) {
  8577. scrollToCell = false;
  8578. }
  8579. if (preventScrolling.isTouched()) {
  8580. scrollToCell = !preventScrolling.value;
  8581. }
  8582. if (scrollToCell !== false && !isSelectedByAnyHeader) {
  8583. if (currentSelectedRange && !_this.selection.isMultiple()) {
  8584. _this.view.scrollViewport(currentSelectedRange.from);
  8585. } else {
  8586. _this.view.scrollViewport(cellCoords);
  8587. }
  8588. }
  8589. var isSelectedByRowHeader = _this.selection.isSelectedByRowHeader();
  8590. var isSelectedByColumnHeader = _this.selection.isSelectedByColumnHeader();
  8591. // @TODO: These CSS classes are no longer needed anymore. They are used only as a indicator of the selected
  8592. // rows/columns in the MergedCells plugin (via border.js#L520 in the walkontable module). After fixing
  8593. // the Border class this should be removed.
  8594. if (isSelectedByRowHeader && isSelectedByColumnHeader) {
  8595. (0, _element.addClass)(_this.rootElement, ['ht__selection--rows', 'ht__selection--columns']);
  8596. } else if (isSelectedByRowHeader) {
  8597. (0, _element.removeClass)(_this.rootElement, 'ht__selection--columns');
  8598. (0, _element.addClass)(_this.rootElement, 'ht__selection--rows');
  8599. } else if (isSelectedByColumnHeader) {
  8600. (0, _element.removeClass)(_this.rootElement, 'ht__selection--rows');
  8601. (0, _element.addClass)(_this.rootElement, 'ht__selection--columns');
  8602. } else {
  8603. (0, _element.removeClass)(_this.rootElement, ['ht__selection--rows', 'ht__selection--columns']);
  8604. }
  8605. _this._refreshBorders(null);
  8606. });
  8607. this.selection.addLocalHook('afterSelectionFinished', function (cellRanges) {
  8608. var selectionLayerLevel = cellRanges.length - 1;
  8609. var _cellRanges$selection = cellRanges[selectionLayerLevel],
  8610. from = _cellRanges$selection.from,
  8611. to = _cellRanges$selection.to;
  8612. _this.runHooks('afterSelectionEnd', from.row, from.col, to.row, to.col, selectionLayerLevel);
  8613. _this.runHooks('afterSelectionEndByProp', from.row, instance.colToProp(from.col), to.row, instance.colToProp(to.col), selectionLayerLevel);
  8614. });
  8615. this.selection.addLocalHook('afterIsMultipleSelection', function (isMultiple) {
  8616. var changedIsMultiple = _this.runHooks('afterIsMultipleSelection', isMultiple.value);
  8617. if (isMultiple.value) {
  8618. isMultiple.value = changedIsMultiple;
  8619. }
  8620. });
  8621. this.selection.addLocalHook('beforeModifyTransformStart', function (cellCoordsDelta) {
  8622. _this.runHooks('modifyTransformStart', cellCoordsDelta);
  8623. });
  8624. this.selection.addLocalHook('afterModifyTransformStart', function (coords, rowTransformDir, colTransformDir) {
  8625. _this.runHooks('afterModifyTransformStart', coords, rowTransformDir, colTransformDir);
  8626. });
  8627. this.selection.addLocalHook('beforeModifyTransformEnd', function (cellCoordsDelta) {
  8628. _this.runHooks('modifyTransformEnd', cellCoordsDelta);
  8629. });
  8630. this.selection.addLocalHook('afterModifyTransformEnd', function (coords, rowTransformDir, colTransformDir) {
  8631. _this.runHooks('afterModifyTransformEnd', coords, rowTransformDir, colTransformDir);
  8632. });
  8633. this.selection.addLocalHook('afterDeselect', function () {
  8634. editorManager.destroyEditor();
  8635. _this._refreshBorders();
  8636. (0, _element.removeClass)(_this.rootElement, ['ht__selection--rows', 'ht__selection--columns']);
  8637. _this.runHooks('afterDeselect');
  8638. });
  8639. this.selection.addLocalHook('insertRowRequire', function (totalRows) {
  8640. _this.alter('insert_row', totalRows, 1, 'auto');
  8641. });
  8642. this.selection.addLocalHook('insertColRequire', function (totalCols) {
  8643. _this.alter('insert_col', totalCols, 1, 'auto');
  8644. });
  8645. grid = {
  8646. /**
  8647. * Inserts or removes rows and columns.
  8648. *
  8649. * @memberof Core#
  8650. * @function alter
  8651. * @private
  8652. * @param {String} action Possible values: "insert_row", "insert_col", "remove_row", "remove_col".
  8653. * @param {Number|Array} index Row or column visual index which from the alter action will be triggered.
  8654. * Alter actions such as "remove_row" and "remove_col" support array indexes in the
  8655. * format `[[index, amount], [index, amount]...]` this can be used to remove
  8656. * non-consecutive columns or rows in one call.
  8657. * @param {Number} amount Ammount rows or columns to remove.
  8658. * @param {String} [source] Optional. Source of hook runner.
  8659. * @param {Boolean} [keepEmptyRows] Optional. Flag for preventing deletion of empty rows.
  8660. */
  8661. alter: function alter(action, index, amount, source, keepEmptyRows) {
  8662. var delta;
  8663. amount = amount || 1;
  8664. function spliceWith(data, index, count, toInject) {
  8665. var valueFactory = function valueFactory() {
  8666. var result = void 0;
  8667. if (toInject === 'array') {
  8668. result = [];
  8669. } else if (toInject === 'object') {
  8670. result = {};
  8671. }
  8672. return result;
  8673. };
  8674. var spliceArgs = (0, _array.arrayMap)(new Array(count), function () {
  8675. return valueFactory();
  8676. });
  8677. spliceArgs.unshift(index, 0);
  8678. data.splice.apply(data, _toConsumableArray(spliceArgs));
  8679. }
  8680. var normalizeIndexesGroup = function normalizeIndexesGroup(indexes) {
  8681. if (indexes.length === 0) {
  8682. return [];
  8683. }
  8684. var sortedIndexes = [].concat(_toConsumableArray(indexes));
  8685. // Sort the indexes in ascending order.
  8686. sortedIndexes.sort(function (_ref, _ref2) {
  8687. var _ref4 = _slicedToArray(_ref, 1),
  8688. indexA = _ref4[0];
  8689. var _ref3 = _slicedToArray(_ref2, 1),
  8690. indexB = _ref3[0];
  8691. if (indexA === indexB) {
  8692. return 0;
  8693. }
  8694. return indexA > indexB ? 1 : -1;
  8695. });
  8696. // Normalize the {index, amount} groups into bigger groups.
  8697. var normalizedIndexes = (0, _array.arrayReduce)(sortedIndexes, function (acc, _ref5) {
  8698. var _ref6 = _slicedToArray(_ref5, 2),
  8699. index = _ref6[0],
  8700. amount = _ref6[1];
  8701. var previousItem = acc[acc.length - 1];
  8702. var _previousItem = _slicedToArray(previousItem, 2),
  8703. prevIndex = _previousItem[0],
  8704. prevAmount = _previousItem[1];
  8705. var prevLastIndex = prevIndex + prevAmount;
  8706. if (index <= prevLastIndex) {
  8707. var amountToAdd = Math.max(amount - (prevLastIndex - index), 0);
  8708. previousItem[1] += amountToAdd;
  8709. } else {
  8710. acc.push([index, amount]);
  8711. }
  8712. return acc;
  8713. }, [sortedIndexes[0]]);
  8714. return normalizedIndexes;
  8715. };
  8716. /* eslint-disable no-case-declarations */
  8717. switch (action) {
  8718. case 'insert_row':
  8719. var numberOfSourceRows = instance.countSourceRows();
  8720. if (instance.getSettings().maxRows === numberOfSourceRows) {
  8721. return;
  8722. }
  8723. index = (0, _mixed.isDefined)(index) ? index : numberOfSourceRows;
  8724. delta = datamap.createRow(index, amount, source);
  8725. spliceWith(priv.cellSettings, index, amount, 'array');
  8726. if (delta) {
  8727. if (selection.isSelected() && selection.selectedRange.current().from.row >= index) {
  8728. selection.selectedRange.current().from.row += delta;
  8729. selection.transformEnd(delta, 0); // will call render() internally
  8730. } else {
  8731. instance._refreshBorders(); // it will call render and prepare methods
  8732. }
  8733. }
  8734. break;
  8735. case 'insert_col':
  8736. delta = datamap.createCol(index, amount, source);
  8737. for (var row = 0, len = instance.countSourceRows(); row < len; row++) {
  8738. if (priv.cellSettings[row]) {
  8739. spliceWith(priv.cellSettings[row], index, amount);
  8740. }
  8741. }
  8742. if (delta) {
  8743. if (Array.isArray(instance.getSettings().colHeaders)) {
  8744. var spliceArray = [index, 0];
  8745. spliceArray.length += delta; // inserts empty (undefined) elements at the end of an array
  8746. Array.prototype.splice.apply(instance.getSettings().colHeaders, spliceArray); // inserts empty (undefined) elements into the colHeader array
  8747. }
  8748. if (selection.isSelected() && selection.selectedRange.current().from.col >= index) {
  8749. selection.selectedRange.current().from.col += delta;
  8750. selection.transformEnd(0, delta); // will call render() internally
  8751. } else {
  8752. instance._refreshBorders(); // it will call render and prepare methods
  8753. }
  8754. }
  8755. break;
  8756. case 'remove_row':
  8757. var removeRow = function removeRow(indexes) {
  8758. var offset = 0;
  8759. (0, _array.arrayEach)(indexes, function (_ref7) {
  8760. var _ref8 = _slicedToArray(_ref7, 2),
  8761. index = _ref8[0],
  8762. amount = _ref8[1];
  8763. var calcIndex = (0, _mixed.isEmpty)(index) ? instance.countRows() - 1 : Math.max(index - offset, 0);
  8764. // If the 'index' is an integer decrease it by 'offset' otherwise pass it through to make the value
  8765. // compatible with datamap.removeCol method.
  8766. if (Number.isInteger(index)) {
  8767. index = Math.max(index - offset, 0);
  8768. }
  8769. // TODO: for datamap.removeRow index should be passed as it is (with undefined and null values). If not, the logic
  8770. // inside the datamap.removeRow breaks the removing functionality.
  8771. datamap.removeRow(index, amount, source);
  8772. priv.cellSettings.splice(calcIndex, amount);
  8773. var totalRows = instance.countRows();
  8774. var fixedRowsTop = instance.getSettings().fixedRowsTop;
  8775. if (fixedRowsTop >= calcIndex + 1) {
  8776. instance.getSettings().fixedRowsTop -= Math.min(amount, fixedRowsTop - calcIndex);
  8777. }
  8778. var fixedRowsBottom = instance.getSettings().fixedRowsBottom;
  8779. if (fixedRowsBottom && calcIndex >= totalRows - fixedRowsBottom) {
  8780. instance.getSettings().fixedRowsBottom -= Math.min(amount, fixedRowsBottom);
  8781. }
  8782. offset += amount;
  8783. });
  8784. };
  8785. if (Array.isArray(index)) {
  8786. removeRow(normalizeIndexesGroup(index));
  8787. } else {
  8788. removeRow([[index, amount]]);
  8789. }
  8790. grid.adjustRowsAndCols();
  8791. instance._refreshBorders(); // it will call render and prepare methods
  8792. break;
  8793. case 'remove_col':
  8794. var removeCol = function removeCol(indexes) {
  8795. var offset = 0;
  8796. (0, _array.arrayEach)(indexes, function (_ref9) {
  8797. var _ref10 = _slicedToArray(_ref9, 2),
  8798. index = _ref10[0],
  8799. amount = _ref10[1];
  8800. var calcIndex = (0, _mixed.isEmpty)(index) ? instance.countCols() - 1 : Math.max(index - offset, 0);
  8801. var visualColumnIndex = recordTranslator.toPhysicalColumn(calcIndex);
  8802. // If the 'index' is an integer decrease it by 'offset' otherwise pass it through to make the value
  8803. // compatible with datamap.removeCol method.
  8804. if (Number.isInteger(index)) {
  8805. index = Math.max(index - offset, 0);
  8806. }
  8807. // TODO: for datamap.removeCol index should be passed as it is (with undefined and null values). If not, the logic
  8808. // inside the datamap.removeCol breaks the removing functionality.
  8809. datamap.removeCol(index, amount, source);
  8810. for (var _row = 0, _len = instance.countSourceRows(); _row < _len; _row++) {
  8811. if (priv.cellSettings[_row]) {
  8812. // if row hasn't been rendered it wouldn't have cellSettings
  8813. priv.cellSettings[_row].splice(visualColumnIndex, amount);
  8814. }
  8815. }
  8816. var fixedColumnsLeft = instance.getSettings().fixedColumnsLeft;
  8817. if (fixedColumnsLeft >= calcIndex + 1) {
  8818. instance.getSettings().fixedColumnsLeft -= Math.min(amount, fixedColumnsLeft - calcIndex);
  8819. }
  8820. if (Array.isArray(instance.getSettings().colHeaders)) {
  8821. if (typeof visualColumnIndex === 'undefined') {
  8822. visualColumnIndex = -1;
  8823. }
  8824. instance.getSettings().colHeaders.splice(visualColumnIndex, amount);
  8825. }
  8826. offset += amount;
  8827. });
  8828. };
  8829. if (Array.isArray(index)) {
  8830. removeCol(normalizeIndexesGroup(index));
  8831. } else {
  8832. removeCol([[index, amount]]);
  8833. }
  8834. grid.adjustRowsAndCols();
  8835. instance._refreshBorders(); // it will call render and prepare methods
  8836. break;
  8837. default:
  8838. throw new Error('There is no such action "' + action + '"');
  8839. }
  8840. if (!keepEmptyRows) {
  8841. grid.adjustRowsAndCols(); // makes sure that we did not add rows that will be removed in next refresh
  8842. }
  8843. },
  8844. /**
  8845. * Makes sure there are empty rows at the bottom of the table
  8846. */
  8847. adjustRowsAndCols: function adjustRowsAndCols() {
  8848. if (priv.settings.minRows) {
  8849. // should I add empty rows to data source to meet minRows?
  8850. var rows = instance.countRows();
  8851. if (rows < priv.settings.minRows) {
  8852. for (var r = 0, minRows = priv.settings.minRows; r < minRows - rows; r++) {
  8853. datamap.createRow(instance.countRows(), 1, 'auto');
  8854. }
  8855. }
  8856. }
  8857. if (priv.settings.minSpareRows) {
  8858. var emptyRows = instance.countEmptyRows(true);
  8859. // should I add empty rows to meet minSpareRows?
  8860. if (emptyRows < priv.settings.minSpareRows) {
  8861. for (; emptyRows < priv.settings.minSpareRows && instance.countSourceRows() < priv.settings.maxRows; emptyRows++) {
  8862. datamap.createRow(instance.countRows(), 1, 'auto');
  8863. }
  8864. }
  8865. }
  8866. {
  8867. var emptyCols = void 0;
  8868. // count currently empty cols
  8869. if (priv.settings.minCols || priv.settings.minSpareCols) {
  8870. emptyCols = instance.countEmptyCols(true);
  8871. }
  8872. // should I add empty cols to meet minCols?
  8873. if (priv.settings.minCols && !priv.settings.columns && instance.countCols() < priv.settings.minCols) {
  8874. for (; instance.countCols() < priv.settings.minCols; emptyCols++) {
  8875. datamap.createCol(instance.countCols(), 1, 'auto');
  8876. }
  8877. }
  8878. // should I add empty cols to meet minSpareCols?
  8879. if (priv.settings.minSpareCols && !priv.settings.columns && instance.dataType === 'array' && emptyCols < priv.settings.minSpareCols) {
  8880. for (; emptyCols < priv.settings.minSpareCols && instance.countCols() < priv.settings.maxCols; emptyCols++) {
  8881. datamap.createCol(instance.countCols(), 1, 'auto');
  8882. }
  8883. }
  8884. }
  8885. var rowCount = instance.countRows();
  8886. var colCount = instance.countCols();
  8887. if (rowCount === 0 || colCount === 0) {
  8888. selection.deselect();
  8889. }
  8890. if (selection.isSelected()) {
  8891. (0, _array.arrayEach)(selection.selectedRange, function (range) {
  8892. var selectionChanged = false;
  8893. var fromRow = range.from.row;
  8894. var fromCol = range.from.col;
  8895. var toRow = range.to.row;
  8896. var toCol = range.to.col;
  8897. // if selection is outside, move selection to last row
  8898. if (fromRow > rowCount - 1) {
  8899. fromRow = rowCount - 1;
  8900. selectionChanged = true;
  8901. if (toRow > fromRow) {
  8902. toRow = fromRow;
  8903. }
  8904. } else if (toRow > rowCount - 1) {
  8905. toRow = rowCount - 1;
  8906. selectionChanged = true;
  8907. if (fromRow > toRow) {
  8908. fromRow = toRow;
  8909. }
  8910. }
  8911. // if selection is outside, move selection to last row
  8912. if (fromCol > colCount - 1) {
  8913. fromCol = colCount - 1;
  8914. selectionChanged = true;
  8915. if (toCol > fromCol) {
  8916. toCol = fromCol;
  8917. }
  8918. } else if (toCol > colCount - 1) {
  8919. toCol = colCount - 1;
  8920. selectionChanged = true;
  8921. if (fromCol > toCol) {
  8922. fromCol = toCol;
  8923. }
  8924. }
  8925. if (selectionChanged) {
  8926. instance.selectCell(fromRow, fromCol, toRow, toCol);
  8927. }
  8928. });
  8929. }
  8930. if (instance.view) {
  8931. instance.view.wt.wtOverlays.adjustElementsSize();
  8932. }
  8933. },
  8934. /**
  8935. * Populate the data from the provided 2d array from the given cell coordinates.
  8936. *
  8937. * @private
  8938. * @param {Object} start Start selection position. Visual indexes.
  8939. * @param {Array} input 2d data array.
  8940. * @param {Object} [end] End selection position (only for drag-down mode). Visual indexes.
  8941. * @param {String} [source="populateFromArray"] Source information string.
  8942. * @param {String} [method="overwrite"] Populate method. Possible options: `shift_down`, `shift_right`, `overwrite`.
  8943. * @param {String} direction (left|right|up|down) String specifying the direction.
  8944. * @param {Array} deltas The deltas array. A difference between values of adjacent cells.
  8945. * Useful **only** when the type of handled cells is `numeric`.
  8946. * @returns {Object|undefined} ending td in pasted area (only if any cell was changed).
  8947. */
  8948. populateFromArray: function populateFromArray(start, input, end, source, method, direction, deltas) {
  8949. // TODO: either remove or implement the `direction` argument. Currently it's not working at all.
  8950. var r,
  8951. rlen,
  8952. c,
  8953. clen,
  8954. setData = [],
  8955. current = {};
  8956. rlen = input.length;
  8957. if (rlen === 0) {
  8958. return false;
  8959. }
  8960. var repeatCol,
  8961. repeatRow,
  8962. cmax,
  8963. rmax,
  8964. baseEnd = {
  8965. row: end === null ? null : end.row,
  8966. col: end === null ? null : end.col
  8967. };
  8968. /* eslint-disable no-case-declarations */
  8969. // insert data with specified pasteMode method
  8970. switch (method) {
  8971. case 'shift_down':
  8972. repeatCol = end ? end.col - start.col + 1 : 0;
  8973. repeatRow = end ? end.row - start.row + 1 : 0;
  8974. input = (0, _data.translateRowsToColumns)(input);
  8975. for (c = 0, clen = input.length, cmax = Math.max(clen, repeatCol); c < cmax; c++) {
  8976. if (c < clen) {
  8977. var _instance;
  8978. for (r = 0, rlen = input[c].length; r < repeatRow - rlen; r++) {
  8979. input[c].push(input[c][r % rlen]);
  8980. }
  8981. input[c].unshift(start.col + c, start.row, 0);
  8982. (_instance = instance).spliceCol.apply(_instance, _toConsumableArray(input[c]));
  8983. } else {
  8984. var _instance2;
  8985. input[c % clen][0] = start.col + c;
  8986. (_instance2 = instance).spliceCol.apply(_instance2, _toConsumableArray(input[c % clen]));
  8987. }
  8988. }
  8989. break;
  8990. case 'shift_right':
  8991. repeatCol = end ? end.col - start.col + 1 : 0;
  8992. repeatRow = end ? end.row - start.row + 1 : 0;
  8993. for (r = 0, rlen = input.length, rmax = Math.max(rlen, repeatRow); r < rmax; r++) {
  8994. if (r < rlen) {
  8995. var _instance3;
  8996. for (c = 0, clen = input[r].length; c < repeatCol - clen; c++) {
  8997. input[r].push(input[r][c % clen]);
  8998. }
  8999. input[r].unshift(start.row + r, start.col, 0);
  9000. (_instance3 = instance).spliceRow.apply(_instance3, _toConsumableArray(input[r]));
  9001. } else {
  9002. var _instance4;
  9003. input[r % rlen][0] = start.row + r;
  9004. (_instance4 = instance).spliceRow.apply(_instance4, _toConsumableArray(input[r % rlen]));
  9005. }
  9006. }
  9007. break;
  9008. case 'overwrite':
  9009. default:
  9010. // overwrite and other not specified options
  9011. current.row = start.row;
  9012. current.col = start.col;
  9013. var selected = { // selected range
  9014. row: end && start ? end.row - start.row + 1 : 1,
  9015. col: end && start ? end.col - start.col + 1 : 1
  9016. };
  9017. var skippedRow = 0;
  9018. var skippedColumn = 0;
  9019. var pushData = true;
  9020. var cellMeta = void 0;
  9021. var getInputValue = function getInputValue(row) {
  9022. var col = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  9023. var rowValue = input[row % input.length];
  9024. if (col !== null) {
  9025. return rowValue[col % rowValue.length];
  9026. }
  9027. return rowValue;
  9028. };
  9029. var rowInputLength = input.length;
  9030. var rowSelectionLength = end ? end.row - start.row + 1 : 0;
  9031. if (end) {
  9032. rlen = rowSelectionLength;
  9033. } else {
  9034. rlen = Math.max(rowInputLength, rowSelectionLength);
  9035. }
  9036. for (r = 0; r < rlen; r++) {
  9037. if (end && current.row > end.row && rowSelectionLength > rowInputLength || !priv.settings.allowInsertRow && current.row > instance.countRows() - 1 || current.row >= priv.settings.maxRows) {
  9038. break;
  9039. }
  9040. var visualRow = r - skippedRow;
  9041. var colInputLength = getInputValue(visualRow).length;
  9042. var colSelectionLength = end ? end.col - start.col + 1 : 0;
  9043. if (end) {
  9044. clen = colSelectionLength;
  9045. } else {
  9046. clen = Math.max(colInputLength, colSelectionLength);
  9047. }
  9048. current.col = start.col;
  9049. cellMeta = instance.getCellMeta(current.row, current.col);
  9050. if ((source === 'CopyPaste.paste' || source === 'Autofill.autofill') && cellMeta.skipRowOnPaste) {
  9051. skippedRow++;
  9052. current.row++;
  9053. rlen++;
  9054. /* eslint-disable no-continue */
  9055. continue;
  9056. }
  9057. skippedColumn = 0;
  9058. for (c = 0; c < clen; c++) {
  9059. if (end && current.col > end.col && colSelectionLength > colInputLength || !priv.settings.allowInsertColumn && current.col > instance.countCols() - 1 || current.col >= priv.settings.maxCols) {
  9060. break;
  9061. }
  9062. cellMeta = instance.getCellMeta(current.row, current.col);
  9063. if ((source === 'CopyPaste.paste' || source === 'Autofill.fill') && cellMeta.skipColumnOnPaste) {
  9064. skippedColumn++;
  9065. current.col++;
  9066. clen++;
  9067. continue;
  9068. }
  9069. if (cellMeta.readOnly) {
  9070. current.col++;
  9071. /* eslint-disable no-continue */
  9072. continue;
  9073. }
  9074. var visualColumn = c - skippedColumn;
  9075. var value = getInputValue(visualRow, visualColumn);
  9076. var orgValue = instance.getDataAtCell(current.row, current.col);
  9077. var index = {
  9078. row: visualRow,
  9079. col: visualColumn
  9080. };
  9081. if (source === 'Autofill.fill') {
  9082. var result = instance.runHooks('beforeAutofillInsidePopulate', index, direction, input, deltas, {}, selected);
  9083. if (result) {
  9084. value = (0, _mixed.isUndefined)(result.value) ? value : result.value;
  9085. }
  9086. }
  9087. if (value !== null && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
  9088. if (orgValue === null || (typeof orgValue === 'undefined' ? 'undefined' : _typeof(orgValue)) !== 'object') {
  9089. pushData = false;
  9090. } else {
  9091. var orgValueSchema = (0, _object.duckSchema)(orgValue[0] || orgValue);
  9092. var valueSchema = (0, _object.duckSchema)(value[0] || value);
  9093. /* eslint-disable max-depth */
  9094. if ((0, _object.isObjectEqual)(orgValueSchema, valueSchema)) {
  9095. value = (0, _object.deepClone)(value);
  9096. } else {
  9097. pushData = false;
  9098. }
  9099. }
  9100. } else if (orgValue !== null && (typeof orgValue === 'undefined' ? 'undefined' : _typeof(orgValue)) === 'object') {
  9101. pushData = false;
  9102. }
  9103. if (pushData) {
  9104. setData.push([current.row, current.col, value]);
  9105. }
  9106. pushData = true;
  9107. current.col++;
  9108. }
  9109. current.row++;
  9110. }
  9111. instance.setDataAtCell(setData, null, null, source || 'populateFromArray');
  9112. break;
  9113. }
  9114. }
  9115. };
  9116. /**
  9117. * Internal function to set `language` key of settings.
  9118. *
  9119. * @private
  9120. * @param {String} languageCode Language code for specific language i.e. 'en-US', 'pt-BR', 'de-DE'
  9121. * @fires Hooks#afterLanguageChange
  9122. */
  9123. function setLanguage(languageCode) {
  9124. var normalizedLanguageCode = (0, _utils.normalizeLanguageCode)(languageCode);
  9125. if ((0, _dictionariesManager.hasLanguageDictionary)(normalizedLanguageCode)) {
  9126. instance.runHooks('beforeLanguageChange', normalizedLanguageCode);
  9127. GridSettings.prototype.language = normalizedLanguageCode;
  9128. instance.runHooks('afterLanguageChange', normalizedLanguageCode);
  9129. } else {
  9130. (0, _utils.warnUserAboutLanguageRegistration)(languageCode);
  9131. }
  9132. }
  9133. this.init = function () {
  9134. dataSource.setData(priv.settings.data);
  9135. instance.runHooks('beforeInit');
  9136. if ((0, _browser.isMobileBrowser)()) {
  9137. (0, _element.addClass)(instance.rootElement, 'mobile');
  9138. }
  9139. this.updateSettings(priv.settings, true);
  9140. this.view = new _tableView2.default(this);
  9141. editorManager = _editorManager2.default.getInstance(instance, priv, selection, datamap);
  9142. this.forceFullRender = true; // used when data was changed
  9143. instance.runHooks('init');
  9144. this.view.render();
  9145. if (_typeof(priv.firstRun) === 'object') {
  9146. instance.runHooks('afterChange', priv.firstRun[0], priv.firstRun[1]);
  9147. priv.firstRun = false;
  9148. }
  9149. instance.runHooks('afterInit');
  9150. };
  9151. function ValidatorsQueue() {
  9152. // moved this one level up so it can be used in any function here. Probably this should be moved to a separate file
  9153. var resolved = false;
  9154. return {
  9155. validatorsInQueue: 0,
  9156. valid: true,
  9157. addValidatorToQueue: function addValidatorToQueue() {
  9158. this.validatorsInQueue++;
  9159. resolved = false;
  9160. },
  9161. removeValidatorFormQueue: function removeValidatorFormQueue() {
  9162. this.validatorsInQueue = this.validatorsInQueue - 1 < 0 ? 0 : this.validatorsInQueue - 1;
  9163. this.checkIfQueueIsEmpty();
  9164. },
  9165. onQueueEmpty: function onQueueEmpty(valid) {},
  9166. checkIfQueueIsEmpty: function checkIfQueueIsEmpty() {
  9167. if (this.validatorsInQueue == 0 && resolved == false) {
  9168. resolved = true;
  9169. this.onQueueEmpty(this.valid);
  9170. }
  9171. }
  9172. };
  9173. }
  9174. /**
  9175. * Get parsed number from numeric string.
  9176. *
  9177. * @private
  9178. * @param {String} numericData Float (separated by a dot or a comma) or integer.
  9179. * @returns {Number} Number if we get data in parsable format, not changed value otherwise.
  9180. */
  9181. function getParsedNumber(numericData) {
  9182. // Unifying "float like" string. Change from value with comma determiner to value with dot determiner,
  9183. // for example from `450,65` to `450.65`.
  9184. var unifiedNumericData = numericData.replace(',', '.');
  9185. if (isNaN(parseFloat(unifiedNumericData)) === false) {
  9186. return parseFloat(unifiedNumericData);
  9187. }
  9188. return numericData;
  9189. }
  9190. function validateChanges(changes, source, callback) {
  9191. var waitingForValidator = new ValidatorsQueue();
  9192. var isNumericData = function isNumericData(value) {
  9193. return value.length > 0 && /^-?[\d\s]*(\.|,)?\d*$/.test(value);
  9194. };
  9195. waitingForValidator.onQueueEmpty = resolve;
  9196. for (var i = changes.length - 1; i >= 0; i--) {
  9197. if (changes[i] === null) {
  9198. changes.splice(i, 1);
  9199. } else {
  9200. var _changes$i = _slicedToArray(changes[i], 4),
  9201. row = _changes$i[0],
  9202. prop = _changes$i[1],
  9203. newValue = _changes$i[3];
  9204. var col = datamap.propToCol(prop);
  9205. var cellProperties = instance.getCellMeta(row, col);
  9206. if (cellProperties.type === 'numeric' && typeof newValue === 'string' && isNumericData(newValue)) {
  9207. changes[i][3] = getParsedNumber(newValue);
  9208. }
  9209. /* eslint-disable no-loop-func */
  9210. if (instance.getCellValidator(cellProperties)) {
  9211. waitingForValidator.addValidatorToQueue();
  9212. instance.validateCell(changes[i][3], cellProperties, function (i, cellProperties) {
  9213. return function (result) {
  9214. if (typeof result !== 'boolean') {
  9215. throw new Error('Validation error: result is not boolean');
  9216. }
  9217. if (result === false && cellProperties.allowInvalid === false) {
  9218. changes.splice(i, 1); // cancel the change
  9219. cellProperties.valid = true; // we cancelled the change, so cell value is still valid
  9220. var cell = instance.getCell(cellProperties.visualRow, cellProperties.visualCol);
  9221. (0, _element.removeClass)(cell, instance.getSettings().invalidCellClassName);
  9222. --i;
  9223. }
  9224. waitingForValidator.removeValidatorFormQueue();
  9225. };
  9226. }(i, cellProperties), source);
  9227. }
  9228. }
  9229. }
  9230. waitingForValidator.checkIfQueueIsEmpty();
  9231. function resolve() {
  9232. var beforeChangeResult;
  9233. if (changes.length) {
  9234. beforeChangeResult = instance.runHooks('beforeChange', changes, source || 'edit');
  9235. if ((0, _function.isFunction)(beforeChangeResult)) {
  9236. (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).');
  9237. } else if (beforeChangeResult === false) {
  9238. changes.splice(0, changes.length); // invalidate all changes (remove everything from array)
  9239. }
  9240. }
  9241. callback(); // called when async validators are resolved and beforeChange was not async
  9242. }
  9243. }
  9244. /**
  9245. * Internal function to apply changes. Called after validateChanges
  9246. *
  9247. * @private
  9248. * @param {Array} changes Array in form of [row, prop, oldValue, newValue]
  9249. * @param {String} source String that identifies how this change will be described in changes array (useful in onChange callback)
  9250. * @fires Hooks#beforeChangeRender
  9251. * @fires Hooks#afterChange
  9252. */
  9253. function applyChanges(changes, source) {
  9254. var i = changes.length - 1;
  9255. if (i < 0) {
  9256. return;
  9257. }
  9258. for (; i >= 0; i--) {
  9259. var skipThisChange = false;
  9260. if (changes[i] === null) {
  9261. changes.splice(i, 1);
  9262. /* eslint-disable no-continue */
  9263. continue;
  9264. }
  9265. if (changes[i][2] == null && changes[i][3] == null) {
  9266. /* eslint-disable no-continue */
  9267. continue;
  9268. }
  9269. if (priv.settings.allowInsertRow) {
  9270. while (changes[i][0] > instance.countRows() - 1) {
  9271. var numberOfCreatedRows = datamap.createRow(void 0, void 0, source);
  9272. if (numberOfCreatedRows === 0) {
  9273. skipThisChange = true;
  9274. break;
  9275. }
  9276. }
  9277. }
  9278. if (skipThisChange) {
  9279. /* eslint-disable no-continue */
  9280. continue;
  9281. }
  9282. if (instance.dataType === 'array' && (!priv.settings.columns || priv.settings.columns.length === 0) && priv.settings.allowInsertColumn) {
  9283. while (datamap.propToCol(changes[i][1]) > instance.countCols() - 1) {
  9284. datamap.createCol(void 0, void 0, source);
  9285. }
  9286. }
  9287. datamap.set(changes[i][0], changes[i][1], changes[i][3]);
  9288. }
  9289. instance.forceFullRender = true; // used when data was changed
  9290. grid.adjustRowsAndCols();
  9291. instance.runHooks('beforeChangeRender', changes, source);
  9292. editorManager.lockEditor();
  9293. instance._refreshBorders(null);
  9294. editorManager.unlockEditor();
  9295. instance.view.wt.wtOverlays.adjustElementsSize();
  9296. instance.runHooks('afterChange', changes, source || 'edit');
  9297. var activeEditor = instance.getActiveEditor();
  9298. if (activeEditor && (0, _mixed.isDefined)(activeEditor.refreshValue)) {
  9299. activeEditor.refreshValue();
  9300. }
  9301. }
  9302. /**
  9303. * Validate a single cell.
  9304. *
  9305. * @param {String|Number} value
  9306. * @param cellProperties
  9307. * @param callback
  9308. * @param source
  9309. */
  9310. this.validateCell = function (value, cellProperties, callback, source) {
  9311. var validator = instance.getCellValidator(cellProperties);
  9312. // the `canBeValidated = false` argument suggests, that the cell passes validation by default.
  9313. function done(valid) {
  9314. var canBeValidated = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  9315. // Fixes GH#3903
  9316. if (!canBeValidated || cellProperties.hidden === true) {
  9317. callback(valid);
  9318. return;
  9319. }
  9320. var col = cellProperties.visualCol,
  9321. row = cellProperties.visualRow,
  9322. td = instance.getCell(row, col, true);
  9323. if (td && td.nodeName != 'TH') {
  9324. instance.view.wt.wtSettings.settings.cellRenderer(row, col, td);
  9325. }
  9326. callback(valid);
  9327. }
  9328. if ((0, _mixed.isRegExp)(validator)) {
  9329. validator = function (validator) {
  9330. return function (value, callback) {
  9331. callback(validator.test(value));
  9332. };
  9333. }(validator);
  9334. }
  9335. if ((0, _function.isFunction)(validator)) {
  9336. value = instance.runHooks('beforeValidate', value, cellProperties.visualRow, cellProperties.prop, source);
  9337. // To provide consistent behaviour, validation should be always asynchronous
  9338. instance._registerTimeout(setTimeout(function () {
  9339. validator.call(cellProperties, value, function (valid) {
  9340. valid = instance.runHooks('afterValidate', valid, value, cellProperties.visualRow, cellProperties.prop, source);
  9341. cellProperties.valid = valid;
  9342. done(valid);
  9343. instance.runHooks('postAfterValidate', valid, value, cellProperties.visualRow, cellProperties.prop, source);
  9344. });
  9345. }, 0));
  9346. } else {
  9347. // resolve callback even if validator function was not found
  9348. instance._registerTimeout(setTimeout(function () {
  9349. cellProperties.valid = true;
  9350. done(cellProperties.valid, false);
  9351. }, 0));
  9352. }
  9353. };
  9354. function setDataInputToArray(row, propOrCol, value) {
  9355. if ((typeof row === 'undefined' ? 'undefined' : _typeof(row)) === 'object') {
  9356. // is it an array of changes
  9357. return row;
  9358. }
  9359. return [[row, propOrCol, value]];
  9360. }
  9361. /**
  9362. * @description
  9363. * Set new value to a cell. To change many cells at once, pass an array of `changes` in format `[[row, col, value], ...]` as
  9364. * the only parameter. `col` is the index of a __visible__ column (note that if columns were reordered,
  9365. * the current visible order will be used). `source` is a flag for before/afterChange events. If you pass only array of
  9366. * changes then `source` could be set as second parameter.
  9367. *
  9368. * @memberof Core#
  9369. * @function setDataAtCell
  9370. * @param {Number|Array} row Visual row index or array of changes in format `[[row, col, value], ...]`.
  9371. * @param {Number} col Visual column index.
  9372. * @param {String} value New value.
  9373. * @param {String} [source] String that identifies how this change will be described in the changes array (useful in onAfterChange or onBeforeChange callback).
  9374. */
  9375. this.setDataAtCell = function (row, col, value, source) {
  9376. var input = setDataInputToArray(row, col, value),
  9377. i,
  9378. ilen,
  9379. changes = [],
  9380. prop;
  9381. for (i = 0, ilen = input.length; i < ilen; i++) {
  9382. if (_typeof(input[i]) !== 'object') {
  9383. throw new Error('Method `setDataAtCell` accepts row number or changes array of arrays as its first parameter');
  9384. }
  9385. if (typeof input[i][1] !== 'number') {
  9386. throw new Error('Method `setDataAtCell` accepts row and column number as its parameters. If you want to use object property name, use method `setDataAtRowProp`');
  9387. }
  9388. prop = datamap.colToProp(input[i][1]);
  9389. changes.push([input[i][0], prop, dataSource.getAtCell(recordTranslator.toPhysicalRow(input[i][0]), input[i][1]), input[i][2]]);
  9390. }
  9391. if (!source && (typeof row === 'undefined' ? 'undefined' : _typeof(row)) === 'object') {
  9392. source = col;
  9393. }
  9394. instance.runHooks('afterSetDataAtCell', changes, source);
  9395. validateChanges(changes, source, function () {
  9396. applyChanges(changes, source);
  9397. });
  9398. };
  9399. /**
  9400. * @description
  9401. * Set new value to a cell. To change many cells at once, pass an array of `changes` in format `[[row, prop, value], ...]` as
  9402. * the only parameter. `prop` is the name of the object property (e.g. `first.name`). `source` is a flag for before/afterChange events.
  9403. * If you pass only array of changes then `source` could be set as second parameter.
  9404. *
  9405. * @memberof Core#
  9406. * @function setDataAtRowProp
  9407. * @param {Number|Array} row Visual row index or array of changes in format `[[row, prop, value], ...]`.
  9408. * @param {String} prop Property name or the source string.
  9409. * @param {String} value Value to be set.
  9410. * @param {String} [source] String that identifies how this change will be described in changes array (useful in onChange callback).
  9411. */
  9412. this.setDataAtRowProp = function (row, prop, value, source) {
  9413. var input = setDataInputToArray(row, prop, value),
  9414. i,
  9415. ilen,
  9416. changes = [];
  9417. for (i = 0, ilen = input.length; i < ilen; i++) {
  9418. changes.push([input[i][0], input[i][1], dataSource.getAtCell(recordTranslator.toPhysicalRow(input[i][0]), input[i][1]), input[i][2]]);
  9419. }
  9420. if (!source && (typeof row === 'undefined' ? 'undefined' : _typeof(row)) === 'object') {
  9421. source = prop;
  9422. }
  9423. instance.runHooks('afterSetDataAtRowProp', changes, source);
  9424. validateChanges(changes, source, function () {
  9425. applyChanges(changes, source);
  9426. });
  9427. };
  9428. /**
  9429. * Listen to the keyboard input on document body.
  9430. *
  9431. * @memberof Core#
  9432. * @function listen
  9433. * @since 0.11
  9434. * @param {Boolean} [modifyDocumentFocus=true] If `true`, currently focused element will be blured (which returns focus
  9435. * to the document.body). Otherwise the active element does not lose its focus.
  9436. */
  9437. this.listen = function () {
  9438. var modifyDocumentFocus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  9439. if (modifyDocumentFocus) {
  9440. var invalidActiveElement = !document.activeElement || document.activeElement && document.activeElement.nodeName === void 0;
  9441. if (document.activeElement && document.activeElement !== document.body && !invalidActiveElement) {
  9442. document.activeElement.blur();
  9443. } else if (invalidActiveElement) {
  9444. // IE
  9445. document.body.focus();
  9446. }
  9447. }
  9448. if (instance && !instance.isListening()) {
  9449. activeGuid = instance.guid;
  9450. instance.runHooks('afterListen');
  9451. }
  9452. };
  9453. /**
  9454. * Stop listening to keyboard input on the document body.
  9455. *
  9456. * @memberof Core#
  9457. * @function unlisten
  9458. * @since 0.11
  9459. */
  9460. this.unlisten = function () {
  9461. if (this.isListening()) {
  9462. activeGuid = null;
  9463. instance.runHooks('afterUnlisten');
  9464. }
  9465. };
  9466. /**
  9467. * Returns `true` if the current Handsontable instance is listening to keyboard input on document body.
  9468. *
  9469. * @memberof Core#
  9470. * @function isListening
  9471. * @since 0.11
  9472. * @returns {Boolean} `true` if the instance is listening, `false` otherwise.
  9473. */
  9474. this.isListening = function () {
  9475. return activeGuid === instance.guid;
  9476. };
  9477. /**
  9478. * Destroys the current editor, renders and selects the current cell.
  9479. *
  9480. * @memberof Core#
  9481. * @function destroyEditor
  9482. * @param {Boolean} [revertOriginal] If != `true`, edited data is saved. Otherwise the previous value is restored.
  9483. */
  9484. this.destroyEditor = function (revertOriginal) {
  9485. instance._refreshBorders(revertOriginal);
  9486. };
  9487. /**
  9488. * Populate cells at position with 2D input array (e.g. `[[1, 2], [3, 4]]`).
  9489. * Use `endRow`, `endCol` when you want to cut input when a certain row is reached.
  9490. * Optional `source` parameter (default value "populateFromArray") is used to identify this call in the resulting events (beforeChange, afterChange).
  9491. * Optional `populateMethod` parameter (default value "overwrite", possible values "shift_down" and "shift_right")
  9492. * has the same effect as pasteMode option {@link Options#pasteMode}
  9493. *
  9494. * @memberof Core#
  9495. * @function populateFromArray
  9496. * @since 0.9.0
  9497. * @param {Number} row Start visual row index.
  9498. * @param {Number} col Start visual column index.
  9499. * @param {Array} input 2d array
  9500. * @param {Number} [endRow] End visual row index (use when you want to cut input when certain row is reached).
  9501. * @param {Number} [endCol] End visual column index (use when you want to cut input when certain column is reached).
  9502. * @param {String} [source="populateFromArray"] Source string.
  9503. * @param {String} [method="overwrite"] Populate method. Possible options: `shift_down`, `shift_right`, `overwrite`.
  9504. * @param {String} direction Populate direction. (left|right|up|down)
  9505. * @param {Array} deltas Deltas array.
  9506. * @returns {Object|undefined} The ending TD element in pasted area (only if any cells were changed).
  9507. */
  9508. this.populateFromArray = function (row, col, input, endRow, endCol, source, method, direction, deltas) {
  9509. var c;
  9510. if (!((typeof input === 'undefined' ? 'undefined' : _typeof(input)) === 'object' && _typeof(input[0]) === 'object')) {
  9511. 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
  9512. }
  9513. c = typeof endRow === 'number' ? new _src.CellCoords(endRow, endCol) : null;
  9514. return grid.populateFromArray(new _src.CellCoords(row, col), input, c, source, method, direction, deltas);
  9515. };
  9516. /**
  9517. * Adds/removes data from the column. This function is modelled after Array.splice.
  9518. * Parameter `col` is the index of the column in which do you want to do splice.
  9519. * Parameter `index` is the row index at which to start changing the array.
  9520. * If negative, will begin that many elements from the end. Parameter `amount`, is the number of the old array elements to remove.
  9521. * If the amount is 0, no elements are removed. Fourth and further parameters are the `elements` to add to the array.
  9522. * If you don't specify any elements, spliceCol simply removes elements from the array.
  9523. * {@link DataMap#spliceCol}
  9524. *
  9525. * @memberof Core#
  9526. * @function spliceCol
  9527. * @since 0.9-beta2
  9528. * @param {Number} col Index of the column in which do you want to do splice.
  9529. * @param {Number} index Index at which to start changing the array. If negative, will begin that many elements from the end.
  9530. * @param {Number} amount An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed.
  9531. * @param {*} [elements] The elements to add to the array. If you don't specify any elements, spliceCol simply removes elements from the array.
  9532. */
  9533. this.spliceCol = function (col, index, amount /* , elements... */) {
  9534. var _datamap;
  9535. return (_datamap = datamap).spliceCol.apply(_datamap, arguments);
  9536. };
  9537. /**
  9538. * Adds/removes data from the row. This function works is modelled after Array.splice.
  9539. * Parameter `row` is the index of row in which do you want to do splice.
  9540. * Parameter `index` is the column index at which to start changing the array.
  9541. * If negative, will begin that many elements from the end. Parameter `amount`, is the number of old array elements to remove.
  9542. * If the amount is 0, no elements are removed. Fourth and further parameters are the `elements` to add to the array.
  9543. * If you don't specify any elements, spliceCol simply removes elements from the array.
  9544. * {@link DataMap#spliceRow}
  9545. *
  9546. * @memberof Core#
  9547. * @function spliceRow
  9548. * @since 0.11
  9549. * @param {Number} row Index of column in which do you want to do splice.
  9550. * @param {Number} index Index at which to start changing the array. If negative, will begin that many elements from the end.
  9551. * @param {Number} amount An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed.
  9552. * @param {*} [elements] The elements to add to the array. If you don't specify any elements, spliceCol simply removes elements from the array.
  9553. */
  9554. this.spliceRow = function (row, index, amount /* , elements... */) {
  9555. var _datamap2;
  9556. return (_datamap2 = datamap).spliceRow.apply(_datamap2, arguments);
  9557. };
  9558. /**
  9559. * Returns indexes of the currently selected cells as an array of arrays `[[startRow, startCol, endRow, endCol], ...]`.
  9560. *
  9561. * Start row and start col are the coordinates of the active cell (where the selection was started).
  9562. *
  9563. * The version 0.36.0 adds a non-consecutive selection feature. Since this version, the method returns an array of arrays.
  9564. * Additionally to collect the coordinates of the currently selected area (as it was previously done by the method)
  9565. * you need to use `getSelectedLast` method.
  9566. *
  9567. * @memberof Core#
  9568. * @function getSelected
  9569. * @returns {Array[]|undefined} An array of arrays of the selection's coordinates.
  9570. */
  9571. this.getSelected = function () {
  9572. // https://github.com/handsontable/handsontable/issues/44 //cjl
  9573. if (selection.isSelected()) {
  9574. return (0, _array.arrayMap)(selection.getSelectedRange(), function (_ref11) {
  9575. var from = _ref11.from,
  9576. to = _ref11.to;
  9577. return [from.row, from.col, to.row, to.col];
  9578. });
  9579. }
  9580. };
  9581. /**
  9582. * Returns the last coordinates applied to the table as a an array `[startRow, startCol, endRow, endCol]`.
  9583. *
  9584. * @since 0.36.0
  9585. * @memberof Core#
  9586. * @function getSelectedLast
  9587. * @returns {Array|undefined} An array of the selection's coordinates.
  9588. */
  9589. this.getSelectedLast = function () {
  9590. var selected = this.getSelected();
  9591. var result = void 0;
  9592. if (selected && selected.length > 0) {
  9593. result = selected[selected.length - 1];
  9594. }
  9595. return result;
  9596. };
  9597. /**
  9598. * Returns the current selection as an array of CellRange objects.
  9599. *
  9600. * The version 0.36.0 adds a non-consecutive selection feature. Since this version, the method returns an array of arrays.
  9601. * Additionally to collect the coordinates of the currently selected area (as it was previously done by the method)
  9602. * you need to use `getSelectedRangeLast` method.
  9603. *
  9604. * @memberof Core#
  9605. * @function getSelectedRange
  9606. * @since 0.11
  9607. * @returns {CellRange[]|undefined} Selected range object or undefined` if there is no selection.
  9608. */
  9609. this.getSelectedRange = function () {
  9610. // https://github.com/handsontable/handsontable/issues/44 //cjl
  9611. if (selection.isSelected()) {
  9612. return Array.from(selection.getSelectedRange());
  9613. }
  9614. };
  9615. /**
  9616. * Returns the last coordinates applied to the table as a CellRange object.
  9617. *
  9618. * @memberof Core#
  9619. * @function getSelectedRangeLast
  9620. * @since 0.36.0
  9621. * @returns {CellRange|undefined} Selected range object or undefined` if there is no selection.
  9622. */
  9623. this.getSelectedRangeLast = function () {
  9624. var selectedRange = this.getSelectedRange();
  9625. var result = void 0;
  9626. if (selectedRange && selectedRange.length > 0) {
  9627. result = selectedRange[selectedRange.length - 1];
  9628. }
  9629. return result;
  9630. };
  9631. /**
  9632. * Erases content from cells that have been selected in the table.
  9633. *
  9634. * @memberof Core#
  9635. * @function emptySelectedCells
  9636. * @since 0.36.0
  9637. */
  9638. this.emptySelectedCells = function () {
  9639. var _this2 = this;
  9640. if (!selection.isSelected()) {
  9641. return;
  9642. }
  9643. var changes = [];
  9644. (0, _array.arrayEach)(selection.getSelectedRange(), function (cellRange) {
  9645. var topLeft = cellRange.getTopLeftCorner();
  9646. var bottomRight = cellRange.getBottomRightCorner();
  9647. (0, _number.rangeEach)(topLeft.row, bottomRight.row, function (row) {
  9648. (0, _number.rangeEach)(topLeft.col, bottomRight.col, function (column) {
  9649. if (!_this2.getCellMeta(row, column).readOnly) {
  9650. changes.push([row, column, '']);
  9651. }
  9652. });
  9653. });
  9654. });
  9655. if (changes.length > 0) {
  9656. this.setDataAtCell(changes);
  9657. }
  9658. };
  9659. /**
  9660. * Rerender the table.
  9661. *
  9662. * @memberof Core#
  9663. * @function render
  9664. */
  9665. this.render = function () {
  9666. if (instance.view) {
  9667. instance.renderCall = true;
  9668. instance.forceFullRender = true; // used when data was changed
  9669. editorManager.lockEditor();
  9670. instance._refreshBorders(null);
  9671. editorManager.unlockEditor();
  9672. }
  9673. };
  9674. /**
  9675. * Reset all cells in the grid to contain data from the data array.
  9676. *
  9677. * @memberof Core#
  9678. * @function loadData
  9679. * @param {Array} data Array of arrays or array of objects containing data.
  9680. * @fires Hooks#afterLoadData
  9681. * @fires Hooks#afterChange
  9682. */
  9683. this.loadData = function (data) {
  9684. if (Array.isArray(priv.settings.dataSchema)) {
  9685. instance.dataType = 'array';
  9686. } else if ((0, _function.isFunction)(priv.settings.dataSchema)) {
  9687. instance.dataType = 'function';
  9688. } else {
  9689. instance.dataType = 'object';
  9690. }
  9691. if (datamap) {
  9692. datamap.destroy();
  9693. }
  9694. datamap = new _dataMap2.default(instance, priv, GridSettings);
  9695. if ((typeof data === 'undefined' ? 'undefined' : _typeof(data)) === 'object' && data !== null) {
  9696. if (!(data.push && data.splice)) {
  9697. // check if data is array. Must use duck-type check so Backbone Collections also pass it
  9698. // when data is not an array, attempt to make a single-row array of it
  9699. data = [data];
  9700. }
  9701. } else if (data === null) {
  9702. data = [];
  9703. var row;
  9704. var r = 0;
  9705. var rlen = 0;
  9706. var dataSchema = datamap.getSchema();
  9707. for (r = 0, rlen = priv.settings.startRows; r < rlen; r++) {
  9708. if ((instance.dataType === 'object' || instance.dataType === 'function') && priv.settings.dataSchema) {
  9709. row = (0, _object.deepClone)(dataSchema);
  9710. data.push(row);
  9711. } else if (instance.dataType === 'array') {
  9712. row = (0, _object.deepClone)(dataSchema[0]);
  9713. data.push(row);
  9714. } else {
  9715. row = [];
  9716. for (var c = 0, clen = priv.settings.startCols; c < clen; c++) {
  9717. row.push(null);
  9718. }
  9719. data.push(row);
  9720. }
  9721. }
  9722. } else {
  9723. throw new Error('loadData only accepts array of objects or array of arrays (' + (typeof data === 'undefined' ? 'undefined' : _typeof(data)) + ' given)');
  9724. }
  9725. priv.isPopulated = false;
  9726. GridSettings.prototype.data = data;
  9727. if (Array.isArray(data[0])) {
  9728. instance.dataType = 'array';
  9729. }
  9730. datamap.dataSource = data;
  9731. dataSource.data = data;
  9732. dataSource.dataType = instance.dataType;
  9733. dataSource.colToProp = datamap.colToProp.bind(datamap);
  9734. dataSource.propToCol = datamap.propToCol.bind(datamap);
  9735. clearCellSettingCache();
  9736. grid.adjustRowsAndCols();
  9737. instance.runHooks('afterLoadData', priv.firstRun);
  9738. if (priv.firstRun) {
  9739. priv.firstRun = [null, 'loadData'];
  9740. } else {
  9741. instance.runHooks('afterChange', null, 'loadData');
  9742. instance.render();
  9743. }
  9744. priv.isPopulated = true;
  9745. function clearCellSettingCache() {
  9746. priv.cellSettings.length = 0;
  9747. }
  9748. };
  9749. /**
  9750. * Returns the current data object (the same one that was passed by `data` configuration option or `loadData` method,
  9751. * unless the `modifyRow` hook was used to trim some of the rows. If that's the case - use the {@link Core#getSourceData} method.).
  9752. * Optionally you can provide cell range by defining `row`, `col`, `row2`, `col2` to get only a fragment of grid data.
  9753. *
  9754. * Note: getData functionality changed with the release of version 0.20. If you're looking for the previous functionality,
  9755. * you should use the {@link Core#getSourceData} method.
  9756. *
  9757. * @memberof Core#
  9758. * @function getData
  9759. * @param {Number} [r] From visual row index.
  9760. * @param {Number} [c] From visual column index.
  9761. * @param {Number} [r2] To visual row index.
  9762. * @param {Number} [c2] To visual column index.
  9763. * @returns {Array} Array with the data.
  9764. */
  9765. this.getData = function (r, c, r2, c2) {
  9766. if ((0, _mixed.isUndefined)(r)) {
  9767. return datamap.getAll();
  9768. }
  9769. return datamap.getRange(new _src.CellCoords(r, c), new _src.CellCoords(r2, c2), datamap.DESTINATION_RENDERER);
  9770. };
  9771. /**
  9772. * Returns a string value of the selected range. Each column is separated by tab, each row is separated by a new line character.
  9773. * {@link DataMap#getCopyableText}
  9774. *
  9775. * @memberof Core#
  9776. * @function getCopyableText
  9777. * @since 0.11
  9778. * @param {Number} startRow From visual row index.
  9779. * @param {Number} startCol From visual column index.
  9780. * @param {Number} endRow To visual row index.
  9781. * @param {Number} endCol To visual column index.
  9782. * @returns {String}
  9783. */
  9784. this.getCopyableText = function (startRow, startCol, endRow, endCol) {
  9785. return datamap.getCopyableText(new _src.CellCoords(startRow, startCol), new _src.CellCoords(endRow, endCol));
  9786. };
  9787. /**
  9788. * Returns the data's copyable value at specified row and column index ({@link DataMap#getCopyable}).
  9789. *
  9790. * @memberof Core#
  9791. * @function getCopyableData
  9792. * @since 0.19.0
  9793. * @param {Number} row Visual row index.
  9794. * @param {Number} column Visual column index.
  9795. * @returns {String}
  9796. */
  9797. this.getCopyableData = function (row, column) {
  9798. return datamap.getCopyable(row, datamap.colToProp(column));
  9799. };
  9800. /**
  9801. * Returns schema provided by constructor settings. If it doesn't exist then it returns the schema based on the data
  9802. * structure in the first row.
  9803. *
  9804. * @memberof Core#
  9805. * @function getSchema
  9806. * @since 0.13.2
  9807. * @returns {Object} Schema object.
  9808. */
  9809. this.getSchema = function () {
  9810. return datamap.getSchema();
  9811. };
  9812. /**
  9813. * Use it if you need to change configuration after initialization. The `settings` parameter is an object containing the new
  9814. * settings, declared the same way as in the initial settings object.
  9815. * Note, that although the `updateSettings` method doesn't overwrite the previously declared settings, it might reset
  9816. * the settings made post-initialization. (for example - ignore changes made using the columnResize feature).
  9817. *
  9818. * @memberof Core#
  9819. * @function updateSettings
  9820. * @param {Object} settings New settings object.
  9821. * @param {Boolean} init Calls this method in the initialization mode. Internal use only.
  9822. * Used by API could be cause of the unexpected behaviour of the Handsontable.
  9823. * @example
  9824. * ```js
  9825. * hot.updateSettings({
  9826. * contextMenu: true,
  9827. * colHeaders: true,
  9828. * fixedRowsTop: 2
  9829. * });
  9830. * ```
  9831. * @fires Hooks#afterCellMetaReset
  9832. * @fires Hooks#afterUpdateSettings
  9833. */
  9834. this.updateSettings = function (settings, init) {
  9835. var columnsAsFunc = false;
  9836. var i = void 0;
  9837. var j = void 0;
  9838. var clen = void 0;
  9839. if ((0, _mixed.isDefined)(settings.rows)) {
  9840. throw new Error('"rows" setting is no longer supported. do you mean startRows, minRows or maxRows?');
  9841. }
  9842. if ((0, _mixed.isDefined)(settings.cols)) {
  9843. throw new Error('"cols" setting is no longer supported. do you mean startCols, minCols or maxCols?');
  9844. }
  9845. for (i in settings) {
  9846. if (i === 'data') {
  9847. /* eslint-disable-next-line no-continue */
  9848. continue; // loadData will be triggered later
  9849. } else if (i === 'language') {
  9850. setLanguage(settings.language);
  9851. /* eslint-disable-next-line no-continue */
  9852. continue;
  9853. } else if (_pluginHooks2.default.getSingleton().getRegistered().indexOf(i) > -1) {
  9854. if ((0, _function.isFunction)(settings[i]) || Array.isArray(settings[i])) {
  9855. settings[i].initialHook = true;
  9856. instance.addHook(i, settings[i]);
  9857. }
  9858. } else if (!init && (0, _object.hasOwnProperty)(settings, i)) {
  9859. // Update settings
  9860. GridSettings.prototype[i] = settings[i];
  9861. }
  9862. }
  9863. // Load data or create data map
  9864. if (settings.data === void 0 && priv.settings.data === void 0) {
  9865. instance.loadData(null); // data source created just now
  9866. } else if (settings.data !== void 0) {
  9867. instance.loadData(settings.data); // data source given as option
  9868. } else if (settings.columns !== void 0) {
  9869. datamap.createMap();
  9870. }
  9871. clen = instance.countCols();
  9872. var columnSetting = settings.columns || GridSettings.prototype.columns;
  9873. // Init columns constructors configuration
  9874. if (columnSetting && (0, _function.isFunction)(columnSetting)) {
  9875. clen = instance.countSourceCols();
  9876. columnsAsFunc = true;
  9877. }
  9878. // Clear cellSettings cache
  9879. if (settings.cell !== void 0 || settings.cells !== void 0 || settings.columns !== void 0) {
  9880. priv.cellSettings.length = 0;
  9881. }
  9882. if (clen > 0) {
  9883. var proto = void 0;
  9884. var column = void 0;
  9885. for (i = 0, j = 0; i < clen; i++) {
  9886. if (columnsAsFunc && !columnSetting(i)) {
  9887. /* eslint-disable no-continue */
  9888. continue;
  9889. }
  9890. priv.columnSettings[j] = (0, _setting.columnFactory)(GridSettings, priv.columnsSettingConflicts);
  9891. // shortcut for prototype
  9892. proto = priv.columnSettings[j].prototype;
  9893. // Use settings provided by user
  9894. if (columnSetting) {
  9895. if (columnsAsFunc) {
  9896. column = columnSetting(i);
  9897. } else {
  9898. column = columnSetting[j];
  9899. }
  9900. if (column) {
  9901. (0, _object.extend)(proto, column);
  9902. (0, _object.extend)(proto, expandType(column));
  9903. }
  9904. }
  9905. j++;
  9906. }
  9907. }
  9908. if ((0, _mixed.isDefined)(settings.cell)) {
  9909. for (var key in settings.cell) {
  9910. if ((0, _object.hasOwnProperty)(settings.cell, key)) {
  9911. var cell = settings.cell[key];
  9912. instance.setCellMetaObject(cell.row, cell.col, cell);
  9913. }
  9914. }
  9915. }
  9916. instance.runHooks('afterCellMetaReset');
  9917. if ((0, _mixed.isDefined)(settings.className)) {
  9918. if (GridSettings.prototype.className) {
  9919. (0, _element.removeClass)(instance.rootElement, GridSettings.prototype.className);
  9920. }
  9921. if (settings.className) {
  9922. (0, _element.addClass)(instance.rootElement, settings.className);
  9923. }
  9924. }
  9925. var currentHeight = instance.rootElement.style.height;
  9926. if (currentHeight !== '') {
  9927. currentHeight = parseInt(instance.rootElement.style.height, 10);
  9928. }
  9929. var height = settings.height;
  9930. if ((0, _function.isFunction)(height)) {
  9931. height = height();
  9932. }
  9933. if (init) {
  9934. var initialStyle = instance.rootElement.getAttribute('style');
  9935. if (initialStyle) {
  9936. instance.rootElement.setAttribute('data-initialstyle', instance.rootElement.getAttribute('style'));
  9937. }
  9938. }
  9939. if (height === null) {
  9940. var _initialStyle = instance.rootElement.getAttribute('data-initialstyle');
  9941. if (_initialStyle && (_initialStyle.indexOf('height') > -1 || _initialStyle.indexOf('overflow') > -1)) {
  9942. instance.rootElement.setAttribute('style', _initialStyle);
  9943. } else {
  9944. instance.rootElement.style.height = '';
  9945. instance.rootElement.style.overflow = '';
  9946. }
  9947. } else if (height !== void 0) {
  9948. instance.rootElement.style.height = height + 'px';
  9949. instance.rootElement.style.overflow = 'hidden';
  9950. }
  9951. if (typeof settings.width !== 'undefined') {
  9952. var width = settings.width;
  9953. if ((0, _function.isFunction)(width)) {
  9954. width = width();
  9955. }
  9956. instance.rootElement.style.width = width + 'px';
  9957. }
  9958. if (!init) {
  9959. datamap.clearLengthCache(); // force clear cache length on updateSettings() #3416
  9960. if (instance.view) {
  9961. instance.view.wt.wtViewport.resetHasOversizedColumnHeadersMarked();
  9962. }
  9963. instance.runHooks('afterUpdateSettings', settings);
  9964. }
  9965. grid.adjustRowsAndCols();
  9966. if (instance.view && !priv.firstRun) {
  9967. instance.forceFullRender = true; // used when data was changed
  9968. editorManager.lockEditor();
  9969. instance._refreshBorders(null);
  9970. editorManager.unlockEditor();
  9971. }
  9972. if (!init && instance.view && (currentHeight === '' || height === '' || height === void 0) && currentHeight !== height) {
  9973. instance.view.wt.wtOverlays.updateMainScrollableElements();
  9974. }
  9975. };
  9976. /**
  9977. * Get value from the selected cell.
  9978. *
  9979. * @memberof Core#
  9980. * @function getValue
  9981. * @since 0.11
  9982. * @returns {*} Value of selected cell.
  9983. */
  9984. this.getValue = function () {
  9985. var sel = instance.getSelectedLast();
  9986. if (GridSettings.prototype.getValue) {
  9987. if ((0, _function.isFunction)(GridSettings.prototype.getValue)) {
  9988. return GridSettings.prototype.getValue.call(instance);
  9989. } else if (sel) {
  9990. return instance.getData()[sel[0][0]][GridSettings.prototype.getValue];
  9991. }
  9992. } else if (sel) {
  9993. return instance.getDataAtCell(sel[0], sel[1]);
  9994. }
  9995. };
  9996. function expandType(obj) {
  9997. if (!(0, _object.hasOwnProperty)(obj, 'type')) {
  9998. // ignore obj.prototype.type
  9999. return;
  10000. }
  10001. var type,
  10002. expandedType = {};
  10003. if (_typeof(obj.type) === 'object') {
  10004. type = obj.type;
  10005. } else if (typeof obj.type === 'string') {
  10006. type = (0, _cellTypes.getCellType)(obj.type);
  10007. }
  10008. for (var i in type) {
  10009. if ((0, _object.hasOwnProperty)(type, i) && !(0, _object.hasOwnProperty)(obj, i)) {
  10010. expandedType[i] = type[i];
  10011. }
  10012. }
  10013. return expandedType;
  10014. }
  10015. /**
  10016. * Returns the object settings.
  10017. *
  10018. * @memberof Core#
  10019. * @function getSettings
  10020. * @returns {Object} Object containing the current grid settings.
  10021. */
  10022. this.getSettings = function () {
  10023. return priv.settings;
  10024. };
  10025. /**
  10026. * Clears the data from the grid (the table settings remain intact).
  10027. *
  10028. * @memberof Core#
  10029. * @function clear
  10030. * @since 0.11.0
  10031. */
  10032. this.clear = function () {
  10033. this.selectAll();
  10034. this.emptySelectedCells();
  10035. };
  10036. /**
  10037. * @memberof Core#
  10038. * @function alter
  10039. * @param {String} action See grid.alter for possible values: `"insert_row"`, `"insert_col"`, `"remove_row"`, `"remove_col"`
  10040. * @param {Number} index Visual index of the row/column before which the new row/column will be inserted/removed.
  10041. * @param {Number} [amount = 1] Amound of rows/columns to be inserted/removed.
  10042. * @param {String} [source] Source indicator.
  10043. * @param {Boolean} [keepEmptyRows] Flag for preventing deletion of empty rows.
  10044. * @description
  10045. *
  10046. * Allows altering the table structure by either inserting/removing rows or inserting/removing columns:
  10047. *
  10048. * Insert new row(s) above the row with a given `index`. If index is `null` or `undefined`, the new row will be
  10049. * added after the last row.
  10050. * ```js
  10051. * var hot = new Handsontable(document.getElementById('example'));
  10052. * hot.alter('insert_row', 10);
  10053. * ```
  10054. *
  10055. * Insert new column(s) before the column with a given `index`. If index is `null` or `undefined`, the new column
  10056. * will be added after the last column.
  10057. * ```js
  10058. * var hot = new Handsontable(document.getElementById('example'));
  10059. * hot.alter('insert_col', 10);
  10060. * ```
  10061. *
  10062. * Remove the row(s) at the given `index`.
  10063. * ```js
  10064. * var hot = new Handsontable(document.getElementById('example'));
  10065. * hot.alter('remove_row', 10);
  10066. * ```
  10067. *
  10068. * Remove the column(s) at the given `index`.
  10069. * ```js
  10070. * var hot = new Handsontable(document.getElementById('example'));
  10071. * hot.alter('remove_col', 10);
  10072. * ```
  10073. */
  10074. this.alter = function (action, index, amount, source, keepEmptyRows) {
  10075. grid.alter(action, index, amount, source, keepEmptyRows);
  10076. };
  10077. /**
  10078. * Returns a TD element for the given `row` and `col` arguments, if it is rendered on screen.
  10079. * Returns `null` if the TD is not rendered on screen (probably because that part of the table is not visible).
  10080. *
  10081. * @memberof Core#
  10082. * @function getCell
  10083. * @param {Number} row Visual row index.
  10084. * @param {Number} col Visual column index.
  10085. * @param {Boolean} topmost If set to true, it returns the TD element from the topmost overlay. For example,
  10086. * if the wanted cell is in the range of fixed rows, it will return a TD element from the `top` overlay.
  10087. * @returns {Element} The cell's TD element.
  10088. */
  10089. this.getCell = function (row, col, topmost) {
  10090. return instance.view.getCellAtCoords(new _src.CellCoords(row, col), topmost);
  10091. };
  10092. /**
  10093. * Returns the coordinates of the cell, provided as a HTML Element.
  10094. *
  10095. * @memberof Core#
  10096. * @function getCoords
  10097. * @param {Element} elem The HTML Element representing the cell.
  10098. * @returns {CellCoords} Visual coordinates object.
  10099. */
  10100. this.getCoords = function (elem) {
  10101. return this.view.wt.wtTable.getCoords.call(this.view.wt.wtTable, elem);
  10102. };
  10103. /**
  10104. * Returns the property name that corresponds with the given column index. {@link DataMap#colToProp}
  10105. * If the data source is an array of arrays, it returns the columns index.
  10106. *
  10107. * @memberof Core#
  10108. * @function colToProp
  10109. * @param {Number} col Visual column index.
  10110. * @returns {String|Number} Column property or physical column index.
  10111. */
  10112. this.colToProp = function (col) {
  10113. return datamap.colToProp(col);
  10114. };
  10115. /**
  10116. * Returns column index that corresponds with the given property. {@link DataMap#propToCol}
  10117. *
  10118. * @memberof Core#
  10119. * @function propToCol
  10120. * @param {String|Number} prop Property name or physical column index.
  10121. * @returns {Number} Visual column index.
  10122. */
  10123. this.propToCol = function (prop) {
  10124. return datamap.propToCol(prop);
  10125. };
  10126. /**
  10127. * Translate physical row index into visual.
  10128. *
  10129. * @since 0.29.0
  10130. * @memberof Core#
  10131. * @function toVisualRow
  10132. * @param {Number} row Physical row index.
  10133. * @returns {Number} Returns visual row index.
  10134. */
  10135. this.toVisualRow = function (row) {
  10136. return recordTranslator.toVisualRow(row);
  10137. };
  10138. /**
  10139. * Translate physical column index into visual.
  10140. *
  10141. * @since 0.29.0
  10142. * @memberof Core#
  10143. * @function toVisualColumn
  10144. * @param {Number} column Physical column index.
  10145. * @returns {Number} Returns visual column index.
  10146. */
  10147. this.toVisualColumn = function (column) {
  10148. return recordTranslator.toVisualColumn(column);
  10149. };
  10150. /**
  10151. * Translate visual row index into physical.
  10152. * If displayed rows order is different than the order of rows stored in memory (i.e. sorting is applied)
  10153. * to retrieve valid physical row index you can use this method.
  10154. *
  10155. * @since 0.29.0
  10156. * @memberof Core#
  10157. * @function toPhysicalRow
  10158. * @param {Number} row Visual row index.
  10159. * @returns {Number} Returns physical row index.
  10160. */
  10161. this.toPhysicalRow = function (row) {
  10162. return recordTranslator.toPhysicalRow(row);
  10163. };
  10164. /**
  10165. * Translate visual column index into physical.
  10166. * If displayed columns order is different than the order of columns stored in memory (i.e. manual column move is applied)
  10167. * to retrieve valid physical column index you can use this method.
  10168. *
  10169. * @since 0.29.0
  10170. * @memberof Core#
  10171. * @function toPhysicalColumn
  10172. * @param {Number} column Visual column index.
  10173. * @returns {Number} Returns physical column index.
  10174. */
  10175. this.toPhysicalColumn = function (column) {
  10176. return recordTranslator.toPhysicalColumn(column);
  10177. };
  10178. /**
  10179. * @description
  10180. * Returns the cell value at `row`, `col`. `row` and `col` are the __visible__ indexes (note, that if columns were reordered or sorted,
  10181. * the currently visible order will be used).
  10182. *
  10183. * @memberof Core#
  10184. * @function getDataAtCell
  10185. * @param {Number} row Visual row index.
  10186. * @param {Number} col Visual column index.
  10187. * @returns {String|Boolean|null} Data at cell.
  10188. */
  10189. this.getDataAtCell = function (row, col) {
  10190. return datamap.get(row, datamap.colToProp(col));
  10191. };
  10192. /**
  10193. * Return value at `row`, `prop`. (Uses {@link DataMap#get})
  10194. *
  10195. * @memberof Core#
  10196. * @function getDataAtRowProp
  10197. * @param {Number} row Visual row index.
  10198. * @param {String} prop Property name.
  10199. * @returns {*} Cell value.
  10200. */
  10201. this.getDataAtRowProp = function (row, prop) {
  10202. return datamap.get(row, prop);
  10203. };
  10204. /**
  10205. * @description
  10206. * Returns array of column values from the data source. `col` is the __visible__ index of the column.
  10207. * Note, that if columns were reordered or sorted, the currently visible order will be used.
  10208. *
  10209. * @memberof Core#
  10210. * @function getDataAtCol
  10211. * @since 0.9-beta2
  10212. * @param {Number} col Visual column index.
  10213. * @returns {Array} Array of cell values.
  10214. */
  10215. this.getDataAtCol = function (col) {
  10216. var out = [];
  10217. 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)));
  10218. };
  10219. /**
  10220. * Given the object property name (e.g. `'first.name'`), returns an array of column's values from the data source.
  10221. * You can also provide a column index as the first argument.
  10222. *
  10223. * @memberof Core#
  10224. * @function getDataAtProp
  10225. * @since 0.9-beta2
  10226. * @param {String|Number} prop Property name / physical column index.
  10227. * @returns {Array} Array of cell values.
  10228. */
  10229. // TODO: Getting data from `datamap` should work on visual indexes.
  10230. this.getDataAtProp = function (prop) {
  10231. var out = [],
  10232. range;
  10233. range = datamap.getRange(new _src.CellCoords(0, datamap.propToCol(prop)), new _src.CellCoords(priv.settings.data.length - 1, datamap.propToCol(prop)), datamap.DESTINATION_RENDERER);
  10234. return out.concat.apply(out, _toConsumableArray(range));
  10235. };
  10236. /**
  10237. * Returns the source data object (the same that was passed by `data` configuration option or `loadData` method).
  10238. * Optionally you can provide a cell range by using the `row`, `col`, `row2`, `col2` arguments, to get only a fragment of grid data.
  10239. *
  10240. * @memberof Core#
  10241. * @function getSourceData
  10242. * @since 0.20.0
  10243. * @param {Number} [r] From physical row index.
  10244. * @param {Number} [c] From physical column index (or visual index, if data type is an array of objects).
  10245. * @param {Number} [r2] To physical row index.
  10246. * @param {Number} [c2] To physical column index (or visual index, if data type is an array of objects).
  10247. * @returns {Array} Array of grid data.
  10248. */
  10249. this.getSourceData = function (r, c, r2, c2) {
  10250. var data = void 0;
  10251. if (r === void 0) {
  10252. data = dataSource.getData();
  10253. } else {
  10254. data = dataSource.getByRange(new _src.CellCoords(r, c), new _src.CellCoords(r2, c2));
  10255. }
  10256. return data;
  10257. };
  10258. /**
  10259. * Returns the source data object as an arrays of arrays format even when source data was provided in another format.
  10260. * Optionally you can provide a cell range by using the `row`, `col`, `row2`, `col2` arguments, to get only a fragment of grid data.
  10261. *
  10262. * @memberof Core#
  10263. * @function getSourceDataArray
  10264. * @since 0.28.0
  10265. * @param {Number} [r] From physical row index.
  10266. * @param {Number} [c] From physical column index (or visual index, if data type is an array of objects).
  10267. * @param {Number} [r2] To physical row index.
  10268. * @param {Number} [c2] To physical column index (or visual index, if data type is an array of objects).
  10269. * @returns {Array} An array of arrays.
  10270. */
  10271. this.getSourceDataArray = function (r, c, r2, c2) {
  10272. var data = void 0;
  10273. if (r === void 0) {
  10274. data = dataSource.getData(true);
  10275. } else {
  10276. data = dataSource.getByRange(new _src.CellCoords(r, c), new _src.CellCoords(r2, c2), true);
  10277. }
  10278. return data;
  10279. };
  10280. /**
  10281. * Returns an array of column values from the data source. `col` is the index of the row in the data source.
  10282. *
  10283. * @memberof Core#
  10284. * @function getSourceDataAtCol
  10285. * @since 0.11.0-beta3
  10286. * @param {Number} column Visual column index.
  10287. * @returns {Array} Array of the column's cell values.
  10288. */
  10289. // TODO: Getting data from `sourceData` should work always on physical indexes.
  10290. this.getSourceDataAtCol = function (column) {
  10291. return dataSource.getAtColumn(column);
  10292. };
  10293. /**
  10294. * 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.
  10295. *
  10296. * @memberof Core#
  10297. * @function getSourceDataAtRow
  10298. * @since 0.11.0-beta3
  10299. * @param {Number} row Physical row index.
  10300. * @returns {Array|Object} Single row of data.
  10301. */
  10302. this.getSourceDataAtRow = function (row) {
  10303. return dataSource.getAtRow(row);
  10304. };
  10305. /**
  10306. * Returns a single value from the data source.
  10307. *
  10308. * @memberof Core#
  10309. * @function getSourceDataAtCell
  10310. * @param {Number} row Physical row index.
  10311. * @param {Number} column Visual column index.
  10312. * @returns {*} Cell data.
  10313. * @since 0.20.0
  10314. */
  10315. // TODO: Getting data from `sourceData` should work always on physical indexes.
  10316. this.getSourceDataAtCell = function (row, column) {
  10317. return dataSource.getAtCell(row, column);
  10318. };
  10319. /**
  10320. * @description
  10321. * Returns a single row of the data. The `row` argument is the __visible__ index of the row.
  10322. *
  10323. * @memberof Core#
  10324. * @function getDataAtRow
  10325. * @param {Number} row Visual row index.
  10326. * @returns {Array} Array of row's cell data.
  10327. * @since 0.9-beta2
  10328. */
  10329. this.getDataAtRow = function (row) {
  10330. var data = datamap.getRange(new _src.CellCoords(row, 0), new _src.CellCoords(row, this.countCols() - 1), datamap.DESTINATION_RENDERER);
  10331. return data[0] || [];
  10332. };
  10333. /**
  10334. * @description
  10335. * Returns a data type defined in the Handsontable settings under the `type` key ([Options#type](http://docs.handsontable.com/Options.html#type)).
  10336. * If there are cells with different types in the selected range, it returns `'mixed'`.
  10337. *
  10338. * @since 0.18.1
  10339. * @memberof Core#
  10340. * @function getDataType
  10341. * @param {Number} rowFrom From visual row index.
  10342. * @param {Number} columnFrom From visual column index.
  10343. * @param {Number} rowTo To visual row index.
  10344. * @param {Number} columnTo To visual column index.
  10345. * @returns {String} Cell type (e.q: `'mixed'`, `'text'`, `'numeric'`, `'autocomplete'`).
  10346. */
  10347. this.getDataType = function (rowFrom, columnFrom, rowTo, columnTo) {
  10348. var _this3 = this;
  10349. var previousType = null;
  10350. var currentType = null;
  10351. if (rowFrom === void 0) {
  10352. rowFrom = 0;
  10353. rowTo = this.countRows();
  10354. columnFrom = 0;
  10355. columnTo = this.countCols();
  10356. }
  10357. if (rowTo === void 0) {
  10358. rowTo = rowFrom;
  10359. }
  10360. if (columnTo === void 0) {
  10361. columnTo = columnFrom;
  10362. }
  10363. var type = 'mixed';
  10364. (0, _number.rangeEach)(Math.min(rowFrom, rowTo), Math.max(rowFrom, rowTo), function (row) {
  10365. var isTypeEqual = true;
  10366. (0, _number.rangeEach)(Math.min(columnFrom, columnTo), Math.max(columnFrom, columnTo), function (column) {
  10367. var cellType = _this3.getCellMeta(row, column);
  10368. currentType = cellType.type;
  10369. if (previousType) {
  10370. isTypeEqual = previousType === currentType;
  10371. } else {
  10372. previousType = currentType;
  10373. }
  10374. return isTypeEqual;
  10375. });
  10376. type = isTypeEqual ? currentType : 'mixed';
  10377. return isTypeEqual;
  10378. });
  10379. return type;
  10380. };
  10381. /**
  10382. * Remove a property defined by the `key` argument from the cell meta object for the provided `row` and `col` coordinates.
  10383. *
  10384. * @memberof Core#
  10385. * @function removeCellMeta
  10386. * @param {Number} row Visual row index.
  10387. * @param {Number} col Visual column index.
  10388. * @param {String} key Property name.
  10389. * @fires Hooks#beforeRemoveCellMeta
  10390. * @fires Hooks#afterRemoveCellMeta
  10391. */
  10392. this.removeCellMeta = function (row, col, key) {
  10393. var _recordTranslator$toP = recordTranslator.toPhysical(row, col),
  10394. _recordTranslator$toP2 = _slicedToArray(_recordTranslator$toP, 2),
  10395. physicalRow = _recordTranslator$toP2[0],
  10396. physicalColumn = _recordTranslator$toP2[1];
  10397. var cachedValue = priv.cellSettings[physicalRow][physicalColumn][key];
  10398. var hookResult = instance.runHooks('beforeRemoveCellMeta', row, col, key, cachedValue);
  10399. if (hookResult !== false) {
  10400. delete priv.cellSettings[physicalRow][physicalColumn][key];
  10401. instance.runHooks('afterRemoveCellMeta', row, col, key, cachedValue);
  10402. }
  10403. cachedValue = null;
  10404. };
  10405. /**
  10406. * Remove one or more rows from the cell meta object.
  10407. *
  10408. * @since 0.30.0
  10409. * @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.
  10410. * @param {Number} deleteAmount The number of items to be removed. If set to 0, no items will be removed.
  10411. * @param {Array} items The new items to be added to the array.
  10412. */
  10413. this.spliceCellsMeta = function (index, deleteAmount) {
  10414. var _priv$cellSettings;
  10415. for (var _len2 = arguments.length, items = Array(_len2 > 2 ? _len2 - 2 : 0), _key = 2; _key < _len2; _key++) {
  10416. items[_key - 2] = arguments[_key];
  10417. }
  10418. (_priv$cellSettings = priv.cellSettings).splice.apply(_priv$cellSettings, [index, deleteAmount].concat(items));
  10419. };
  10420. /**
  10421. * Set cell meta data object defined by `prop` to the corresponding params `row` and `col`.
  10422. *
  10423. * @memberof Core#
  10424. * @function setCellMetaObject
  10425. * @since 0.11
  10426. * @param {Number} row Visual row index.
  10427. * @param {Number} col Visual column index.
  10428. * @param {Object} prop Meta object.
  10429. */
  10430. this.setCellMetaObject = function (row, col, prop) {
  10431. if ((typeof prop === 'undefined' ? 'undefined' : _typeof(prop)) === 'object') {
  10432. for (var key in prop) {
  10433. if ((0, _object.hasOwnProperty)(prop, key)) {
  10434. var value = prop[key];
  10435. this.setCellMeta(row, col, key, value);
  10436. }
  10437. }
  10438. }
  10439. };
  10440. /**
  10441. * Sets a property defined by the `key` object to the meta object of a cell corresponding to params `row` and `col`.
  10442. *
  10443. * @memberof Core#
  10444. * @function setCellMeta
  10445. * @since 0.11
  10446. * @param {Number} row Visual row index.
  10447. * @param {Number} col Visual column index.
  10448. * @param {String} key Property name.
  10449. * @param {String} val Property value.
  10450. * @fires Hooks#afterSetCellMeta
  10451. */
  10452. this.setCellMeta = function (row, col, key, val) {
  10453. var _recordTranslator$toP3 = recordTranslator.toPhysical(row, col),
  10454. _recordTranslator$toP4 = _slicedToArray(_recordTranslator$toP3, 2),
  10455. physicalRow = _recordTranslator$toP4[0],
  10456. physicalColumn = _recordTranslator$toP4[1];
  10457. if (!priv.columnSettings[physicalColumn]) {
  10458. priv.columnSettings[physicalColumn] = (0, _setting.columnFactory)(GridSettings, priv.columnsSettingConflicts);
  10459. }
  10460. if (!priv.cellSettings[physicalRow]) {
  10461. priv.cellSettings[physicalRow] = [];
  10462. }
  10463. if (!priv.cellSettings[physicalRow][physicalColumn]) {
  10464. priv.cellSettings[physicalRow][physicalColumn] = new priv.columnSettings[physicalColumn]();
  10465. }
  10466. priv.cellSettings[physicalRow][physicalColumn][key] = val;
  10467. instance.runHooks('afterSetCellMeta', row, col, key, val);
  10468. };
  10469. /**
  10470. * Get all the cells meta settings at least once generated in the table (in order of cell initialization).
  10471. *
  10472. * @since 0.19.0
  10473. * @returns {Array} Returns Array of ColumnSettings object.
  10474. */
  10475. this.getCellsMeta = function () {
  10476. return (0, _array.arrayFlatten)(priv.cellSettings);
  10477. };
  10478. /**
  10479. * Returns the cell properties object for the given `row` and `col` coordinates.
  10480. *
  10481. * @memberof Core#
  10482. * @function getCellMeta
  10483. * @param {Number} row Visual row index.
  10484. * @param {Number} col Visual column index.
  10485. * @returns {Object} The cell properties object.
  10486. * @fires Hooks#beforeGetCellMeta
  10487. * @fires Hooks#afterGetCellMeta
  10488. */
  10489. this.getCellMeta = function (row, col) {
  10490. var prop = datamap.colToProp(col);
  10491. var cellProperties = void 0;
  10492. var _recordTranslator$toP5 = recordTranslator.toPhysical(row, col),
  10493. _recordTranslator$toP6 = _slicedToArray(_recordTranslator$toP5, 2),
  10494. physicalRow = _recordTranslator$toP6[0],
  10495. physicalColumn = _recordTranslator$toP6[1];
  10496. // Workaround for #11. Connected also with #3849. It should be fixed within #4497.
  10497. if (physicalRow === null) {
  10498. physicalRow = row;
  10499. }
  10500. if (!priv.columnSettings[physicalColumn]) {
  10501. priv.columnSettings[physicalColumn] = (0, _setting.columnFactory)(GridSettings, priv.columnsSettingConflicts);
  10502. }
  10503. if (!priv.cellSettings[physicalRow]) {
  10504. priv.cellSettings[physicalRow] = [];
  10505. }
  10506. if (!priv.cellSettings[physicalRow][physicalColumn]) {
  10507. priv.cellSettings[physicalRow][physicalColumn] = new priv.columnSettings[physicalColumn]();
  10508. }
  10509. cellProperties = priv.cellSettings[physicalRow][physicalColumn]; // retrieve cellProperties from cache
  10510. cellProperties.row = physicalRow;
  10511. cellProperties.col = physicalColumn;
  10512. cellProperties.visualRow = row;
  10513. cellProperties.visualCol = col;
  10514. cellProperties.prop = prop;
  10515. cellProperties.instance = instance;
  10516. instance.runHooks('beforeGetCellMeta', row, col, cellProperties);
  10517. (0, _object.extend)(cellProperties, expandType(cellProperties)); // for `type` added in beforeGetCellMeta
  10518. if (cellProperties.cells) {
  10519. var settings = cellProperties.cells.call(cellProperties, physicalRow, physicalColumn, prop);
  10520. if (settings) {
  10521. (0, _object.extend)(cellProperties, settings);
  10522. (0, _object.extend)(cellProperties, expandType(settings)); // for `type` added in cells
  10523. }
  10524. }
  10525. instance.runHooks('afterGetCellMeta', row, col, cellProperties);
  10526. return cellProperties;
  10527. };
  10528. /**
  10529. * Returns a row off the cell meta array.
  10530. *
  10531. * @memberof Core#
  10532. * @function getCellMetaAtRow
  10533. * @since 0.30.0
  10534. * @param {Number} row Physical index of the row to return cell meta for.
  10535. * @returns {Array}
  10536. */
  10537. this.getCellMetaAtRow = function (row) {
  10538. return priv.cellSettings[row];
  10539. };
  10540. /**
  10541. * Checks if the data format and config allows user to modify the column structure.
  10542. * @returns {boolean}
  10543. */
  10544. this.isColumnModificationAllowed = function () {
  10545. return !(instance.dataType === 'object' || instance.getSettings().columns);
  10546. };
  10547. var rendererLookup = (0, _data.cellMethodLookupFactory)('renderer');
  10548. /**
  10549. * Returns the cell renderer function by given `row` and `col` arguments.
  10550. *
  10551. * @memberof Core#
  10552. * @function getCellRenderer
  10553. * @since 0.11
  10554. * @param {Number|Object} row Visual row index or cell meta object.
  10555. * @param {Number} [col] Visual column index.
  10556. * @returns {Function} The renderer function.
  10557. */
  10558. this.getCellRenderer = function (row, col) {
  10559. return (0, _renderers.getRenderer)(rendererLookup.call(this, row, col));
  10560. };
  10561. /**
  10562. * Returns the cell editor by the provided `row` and `col` arguments.
  10563. *
  10564. * @memberof Core#
  10565. * @function getCellEditor
  10566. * @param {Number} row Visual row index.
  10567. * @param {Number} col Visual column index.
  10568. * @returns {Object} The Editor object.
  10569. */
  10570. this.getCellEditor = (0, _data.cellMethodLookupFactory)('editor');
  10571. var validatorLookup = (0, _data.cellMethodLookupFactory)('validator');
  10572. /**
  10573. * Returns the cell validator by `row` and `col`, provided a validator is defined. If not - it doesn't return anything.
  10574. *
  10575. * @memberof Core#
  10576. * @function getCellValidator
  10577. * @param {Number} row Visual row index.
  10578. * @param {Number} col Visual column index.
  10579. * @returns {Function|RegExp|undefined} The validator function.
  10580. */
  10581. this.getCellValidator = function (row, col) {
  10582. var validator = validatorLookup.call(this, row, col);
  10583. if (typeof validator === 'string') {
  10584. validator = (0, _validators.getValidator)(validator);
  10585. }
  10586. return validator;
  10587. };
  10588. /**
  10589. * Validates all cells using their validator functions and calls callback when finished.
  10590. *
  10591. * If one of the cells is invalid, the callback will be fired with `'valid'` arguments as `false` - otherwise it would equal `true`.
  10592. *
  10593. * @memberof Core#
  10594. * @function validateCells
  10595. * @param {Function} [callback] The callback function.
  10596. */
  10597. this.validateCells = function (callback) {
  10598. this._validateCells(callback);
  10599. };
  10600. /**
  10601. * Validates rows using their validator functions and calls callback when finished.
  10602. *
  10603. * If one of the cells is invalid, the callback will be fired with `'valid'` arguments as `false` - otherwise it would equal `true`.
  10604. *
  10605. * @memberof Core#
  10606. * @function validateRows
  10607. * @param {Array} [rows] Array of validation target visual row indexes.
  10608. * @param {Function} [callback] The callback function.
  10609. */
  10610. this.validateRows = function (rows, callback) {
  10611. if (!Array.isArray(rows)) {
  10612. throw new Error('validateRows parameter `rows` must be an array');
  10613. }
  10614. this._validateCells(callback, rows);
  10615. };
  10616. /**
  10617. * Validates columns using their validator functions and calls callback when finished.
  10618. *
  10619. * If one of the cells is invalid, the callback will be fired with `'valid'` arguments as `false` - otherwise it would equal `true`.
  10620. *
  10621. * @memberof Core#
  10622. * @function validateColumns
  10623. * @param {Array} [columns] Array of validation target visual columns indexes.
  10624. * @param {Function} [callback] The callback function.
  10625. */
  10626. this.validateColumns = function (columns, callback) {
  10627. if (!Array.isArray(columns)) {
  10628. throw new Error('validateColumns parameter `columns` must be an array');
  10629. }
  10630. this._validateCells(callback, undefined, columns);
  10631. };
  10632. /**
  10633. * Validates all cells using their validator functions and calls callback when finished.
  10634. *
  10635. * If one of the cells is invalid, the callback will be fired with `'valid'` arguments as `false` - otherwise it would equal `true`.
  10636. *
  10637. * Private use intended.
  10638. *
  10639. * @private
  10640. * @memberof Core#
  10641. * @function _validateCells
  10642. * @param {Function} [callback] The callback function.
  10643. * @param {Array} [rows] Optional. Array of validation target visual row indexes.
  10644. * @param {Array} [columns] Optional. Array of validation target visual column indexes.
  10645. */
  10646. this._validateCells = function (callback, rows, columns) {
  10647. var waitingForValidator = new ValidatorsQueue();
  10648. if (callback) {
  10649. waitingForValidator.onQueueEmpty = callback;
  10650. }
  10651. var i = instance.countRows() - 1;
  10652. while (i >= 0) {
  10653. if (rows !== undefined && rows.indexOf(i) === -1) {
  10654. i--;
  10655. continue;
  10656. }
  10657. var j = instance.countCols() - 1;
  10658. while (j >= 0) {
  10659. if (columns !== undefined && columns.indexOf(j) === -1) {
  10660. j--;
  10661. continue;
  10662. }
  10663. waitingForValidator.addValidatorToQueue();
  10664. instance.validateCell(instance.getDataAtCell(i, j), instance.getCellMeta(i, j), function (result) {
  10665. if (typeof result !== 'boolean') {
  10666. throw new Error('Validation error: result is not boolean');
  10667. }
  10668. if (result === false) {
  10669. waitingForValidator.valid = false;
  10670. }
  10671. waitingForValidator.removeValidatorFormQueue();
  10672. }, 'validateCells');
  10673. j--;
  10674. }
  10675. i--;
  10676. }
  10677. waitingForValidator.checkIfQueueIsEmpty();
  10678. };
  10679. /**
  10680. * 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.
  10681. *
  10682. * @memberof Core#
  10683. * @function getRowHeader
  10684. * @param {Number} [row] Visual row index.
  10685. * @fires Hooks#modifyRowHeader
  10686. * @returns {Array|String} Array of header values / single header value.
  10687. */
  10688. this.getRowHeader = function (row) {
  10689. var rowHeader = priv.settings.rowHeaders;
  10690. if (row !== void 0) {
  10691. row = instance.runHooks('modifyRowHeader', row);
  10692. }
  10693. if (row === void 0) {
  10694. rowHeader = [];
  10695. (0, _number.rangeEach)(instance.countRows() - 1, function (i) {
  10696. rowHeader.push(instance.getRowHeader(i));
  10697. });
  10698. } else if (Array.isArray(rowHeader) && rowHeader[row] !== void 0) {
  10699. rowHeader = rowHeader[row];
  10700. } else if ((0, _function.isFunction)(rowHeader)) {
  10701. rowHeader = rowHeader(row);
  10702. } else if (rowHeader && typeof rowHeader !== 'string' && typeof rowHeader !== 'number') {
  10703. rowHeader = row + 1;
  10704. }
  10705. return rowHeader;
  10706. };
  10707. /**
  10708. * Returns information about if this table is configured to display row headers.
  10709. *
  10710. * @memberof Core#
  10711. * @function hasRowHeaders
  10712. * @returns {Boolean} `true` if the instance has the row headers enabled, `false` otherwise.
  10713. * @since 0.11
  10714. */
  10715. this.hasRowHeaders = function () {
  10716. return !!priv.settings.rowHeaders;
  10717. };
  10718. /**
  10719. * Returns information about if this table is configured to display column headers.
  10720. *
  10721. * @memberof Core#
  10722. * @function hasColHeaders
  10723. * @since 0.11
  10724. * @returns {Boolean} `True` if the instance has the column headers enabled, `false` otherwise.
  10725. */
  10726. this.hasColHeaders = function () {
  10727. if (priv.settings.colHeaders !== void 0 && priv.settings.colHeaders !== null) {
  10728. // Polymer has empty value = null
  10729. return !!priv.settings.colHeaders;
  10730. }
  10731. for (var i = 0, ilen = instance.countCols(); i < ilen; i++) {
  10732. if (instance.getColHeader(i)) {
  10733. return true;
  10734. }
  10735. }
  10736. return false;
  10737. };
  10738. /**
  10739. * 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.
  10740. *
  10741. * @memberof Core#
  10742. * @function getColHeader
  10743. * @param {Number} [col] Visual column index.
  10744. * @fires Hooks#modifyColHeader
  10745. * @returns {Array|String} The column header(s).
  10746. */
  10747. this.getColHeader = function (col) {
  10748. var columnsAsFunc = priv.settings.columns && (0, _function.isFunction)(priv.settings.columns);
  10749. var result = priv.settings.colHeaders;
  10750. col = instance.runHooks('modifyColHeader', col);
  10751. if (col === void 0) {
  10752. var out = [];
  10753. var ilen = columnsAsFunc ? instance.countSourceCols() : instance.countCols();
  10754. for (var i = 0; i < ilen; i++) {
  10755. out.push(instance.getColHeader(i));
  10756. }
  10757. result = out;
  10758. } else {
  10759. var translateVisualIndexToColumns = function translateVisualIndexToColumns(col) {
  10760. var arr = [];
  10761. var columnsLen = instance.countSourceCols();
  10762. var index = 0;
  10763. for (; index < columnsLen; index++) {
  10764. if ((0, _function.isFunction)(instance.getSettings().columns) && instance.getSettings().columns(index)) {
  10765. arr.push(index);
  10766. }
  10767. }
  10768. return arr[col];
  10769. };
  10770. var baseCol = col;
  10771. col = instance.runHooks('modifyCol', col);
  10772. var prop = translateVisualIndexToColumns(col);
  10773. if (priv.settings.columns && (0, _function.isFunction)(priv.settings.columns) && priv.settings.columns(prop) && priv.settings.columns(prop).title) {
  10774. result = priv.settings.columns(prop).title;
  10775. } else if (priv.settings.columns && priv.settings.columns[col] && priv.settings.columns[col].title) {
  10776. result = priv.settings.columns[col].title;
  10777. } else if (Array.isArray(priv.settings.colHeaders) && priv.settings.colHeaders[col] !== void 0) {
  10778. result = priv.settings.colHeaders[col];
  10779. } else if ((0, _function.isFunction)(priv.settings.colHeaders)) {
  10780. result = priv.settings.colHeaders(col);
  10781. } else if (priv.settings.colHeaders && typeof priv.settings.colHeaders !== 'string' && typeof priv.settings.colHeaders !== 'number') {
  10782. result = (0, _data.spreadsheetColumnLabel)(baseCol); // see #1458
  10783. }
  10784. }
  10785. return result;
  10786. };
  10787. /**
  10788. * Return column width from settings (no guessing). Private use intended.
  10789. *
  10790. * @private
  10791. * @memberof Core#
  10792. * @function _getColWidthFromSettings
  10793. * @param {Number} col Visual col index.
  10794. * @returns {Number}
  10795. */
  10796. this._getColWidthFromSettings = function (col) {
  10797. var cellProperties = instance.getCellMeta(0, col);
  10798. var width = cellProperties.width;
  10799. if (width === void 0 || width === priv.settings.width) {
  10800. width = cellProperties.colWidths;
  10801. }
  10802. if (width !== void 0 && width !== null) {
  10803. switch (typeof width === 'undefined' ? 'undefined' : _typeof(width)) {
  10804. case 'object':
  10805. // array
  10806. width = width[col];
  10807. break;
  10808. case 'function':
  10809. width = width(col);
  10810. break;
  10811. default:
  10812. break;
  10813. }
  10814. if (typeof width === 'string') {
  10815. width = parseInt(width, 10);
  10816. }
  10817. }
  10818. return width;
  10819. };
  10820. /**
  10821. * Returns the width of the requested column.
  10822. *
  10823. * @memberof Core#
  10824. * @function getColWidth
  10825. * @since 0.11
  10826. * @param {Number} col Visual column index.
  10827. * @returns {Number} Column width.
  10828. * @fires Hooks#modifyColWidth
  10829. */
  10830. this.getColWidth = function (col) {
  10831. var width = instance._getColWidthFromSettings(col);
  10832. width = instance.runHooks('modifyColWidth', width, col);
  10833. if (width === void 0) {
  10834. width = _src.ViewportColumnsCalculator.DEFAULT_WIDTH;
  10835. }
  10836. return width;
  10837. };
  10838. /**
  10839. * Return row height from settings (no guessing). Private use intended.
  10840. *
  10841. * @private
  10842. * @memberof Core#
  10843. * @function _getRowHeightFromSettings
  10844. * @param {Number} row Visual row index.
  10845. * @returns {Number}
  10846. */
  10847. this._getRowHeightFromSettings = function (row) {
  10848. // let cellProperties = instance.getCellMeta(row, 0);
  10849. // let height = cellProperties.height;
  10850. //
  10851. // if (height === void 0 || height === priv.settings.height) {
  10852. // height = cellProperties.rowHeights;
  10853. // }
  10854. var height = priv.settings.rowHeights;
  10855. if (height !== void 0 && height !== null) {
  10856. switch (typeof height === 'undefined' ? 'undefined' : _typeof(height)) {
  10857. case 'object':
  10858. // array
  10859. height = height[row];
  10860. break;
  10861. case 'function':
  10862. height = height(row);
  10863. break;
  10864. default:
  10865. break;
  10866. }
  10867. if (typeof height === 'string') {
  10868. height = parseInt(height, 10);
  10869. }
  10870. }
  10871. return height;
  10872. };
  10873. /**
  10874. * Returns the row height.
  10875. *
  10876. * @memberof Core#
  10877. * @function getRowHeight
  10878. * @since 0.11
  10879. * @param {Number} row Visual row index.
  10880. * @returns {Number} The given row's height.
  10881. * @fires Hooks#modifyRowHeight
  10882. */
  10883. this.getRowHeight = function (row) {
  10884. var height = instance._getRowHeightFromSettings(row);
  10885. height = instance.runHooks('modifyRowHeight', height, row);
  10886. return height;
  10887. };
  10888. /**
  10889. * Returns the total number of rows in the data source.
  10890. *
  10891. * @memberof Core#
  10892. * @function countSourceRows
  10893. * @since 0.20.0
  10894. * @returns {Number} Total number in rows in data source.
  10895. */
  10896. this.countSourceRows = function () {
  10897. var sourceLength = instance.runHooks('modifySourceLength');
  10898. return sourceLength || (instance.getSourceData() ? instance.getSourceData().length : 0);
  10899. };
  10900. /**
  10901. * Returns the total number of columns in the data source.
  10902. *
  10903. * @memberof Core#
  10904. * @function countSourceCols
  10905. * @since 0.26.1
  10906. * @returns {Number} Total number in columns in data source.
  10907. */
  10908. this.countSourceCols = function () {
  10909. var len = 0;
  10910. var obj = instance.getSourceData() && instance.getSourceData()[0] ? instance.getSourceData()[0] : [];
  10911. if ((0, _object.isObject)(obj)) {
  10912. len = (0, _object.deepObjectSize)(obj);
  10913. } else {
  10914. len = obj.length || 0;
  10915. }
  10916. return len;
  10917. };
  10918. /**
  10919. * Returns the total number of rows in the grid.
  10920. *
  10921. * @memberof Core#
  10922. * @function countRows
  10923. * @returns {Number} Total number in rows the grid.
  10924. */
  10925. this.countRows = function () {
  10926. return datamap.getLength();
  10927. };
  10928. /**
  10929. * Returns the total number of columns in the grid.
  10930. *
  10931. * @memberof Core#
  10932. * @function countCols
  10933. * @returns {Number} Total number of columns.
  10934. */
  10935. this.countCols = function () {
  10936. var maxCols = this.getSettings().maxCols;
  10937. var dataHasLength = false;
  10938. var dataLen = 0;
  10939. if (instance.dataType === 'array') {
  10940. dataHasLength = priv.settings.data && priv.settings.data[0] && priv.settings.data[0].length;
  10941. }
  10942. if (dataHasLength) {
  10943. dataLen = priv.settings.data[0].length;
  10944. }
  10945. if (priv.settings.columns) {
  10946. var columnsIsFunction = (0, _function.isFunction)(priv.settings.columns);
  10947. if (columnsIsFunction) {
  10948. if (instance.dataType === 'array') {
  10949. var columnLen = 0;
  10950. for (var i = 0; i < dataLen; i++) {
  10951. if (priv.settings.columns(i)) {
  10952. columnLen++;
  10953. }
  10954. }
  10955. dataLen = columnLen;
  10956. } else if (instance.dataType === 'object' || instance.dataType === 'function') {
  10957. dataLen = datamap.colToPropCache.length;
  10958. }
  10959. } else {
  10960. dataLen = priv.settings.columns.length;
  10961. }
  10962. } else if (instance.dataType === 'object' || instance.dataType === 'function') {
  10963. dataLen = datamap.colToPropCache.length;
  10964. }
  10965. return Math.min(maxCols, dataLen);
  10966. };
  10967. /**
  10968. * Returns an visual index of the first rendered row.
  10969. *
  10970. * @memberof Core#
  10971. * @function rowOffset
  10972. * @returns {Number} Visual index of first rendered row.
  10973. */
  10974. this.rowOffset = function () {
  10975. return instance.view.wt.wtTable.getFirstRenderedRow();
  10976. };
  10977. /**
  10978. * Returns the visual index of the first rendered column.
  10979. *
  10980. * @memberof Core#
  10981. * @function colOffset
  10982. * @returns {Number} Visual index of the first visible column.
  10983. */
  10984. this.colOffset = function () {
  10985. return instance.view.wt.wtTable.getFirstRenderedColumn();
  10986. };
  10987. /**
  10988. * Returns the number of rendered rows (including rows partially or fully rendered outside viewport).
  10989. *
  10990. * @memberof Core#
  10991. * @function countRenderedRows
  10992. * @returns {Number} Returns -1 if table is not visible.
  10993. */
  10994. this.countRenderedRows = function () {
  10995. return instance.view.wt.drawn ? instance.view.wt.wtTable.getRenderedRowsCount() : -1;
  10996. };
  10997. /**
  10998. * Returns the number of visible rows (rendered rows that fully fit inside viewport).
  10999. *
  11000. * @memberof Core#
  11001. * @function countVisibleRows
  11002. * @returns {Number} Number of visible rows or -1.
  11003. */
  11004. this.countVisibleRows = function () {
  11005. return instance.view.wt.drawn ? instance.view.wt.wtTable.getVisibleRowsCount() : -1;
  11006. };
  11007. /**
  11008. * Returns the number of rendered columns (including columns partially or fully rendered outside viewport).
  11009. *
  11010. * @memberof Core#
  11011. * @function countRenderedCols
  11012. * @returns {Number} Returns -1 if table is not visible.
  11013. */
  11014. this.countRenderedCols = function () {
  11015. return instance.view.wt.drawn ? instance.view.wt.wtTable.getRenderedColumnsCount() : -1;
  11016. };
  11017. /**
  11018. * Returns the number of visible columns. Returns -1 if table is not visible
  11019. *
  11020. * @memberof Core#
  11021. * @function countVisibleCols
  11022. * @return {Number} Number of visible columns or -1.
  11023. */
  11024. this.countVisibleCols = function () {
  11025. return instance.view.wt.drawn ? instance.view.wt.wtTable.getVisibleColumnsCount() : -1;
  11026. };
  11027. /**
  11028. * Returns the number of empty rows. If the optional ending parameter is `true`, returns the
  11029. * number of empty rows at the bottom of the table.
  11030. *
  11031. * @memberof Core#
  11032. * @function countEmptyRows
  11033. * @param {Boolean} [ending] If `true`, will only count empty rows at the end of the data source.
  11034. * @returns {Number} Count empty rows.
  11035. */
  11036. this.countEmptyRows = function (ending) {
  11037. var emptyRows = 0;
  11038. (0, _number.rangeEachReverse)(instance.countRows() - 1, function (visualIndex) {
  11039. if (instance.isEmptyRow(visualIndex)) {
  11040. emptyRows += 1;
  11041. } else if (ending === true) {
  11042. return false;
  11043. }
  11044. });
  11045. return emptyRows;
  11046. };
  11047. /**
  11048. * Returns the number of empty columns. If the optional ending parameter is `true`, returns the number of empty
  11049. * columns at right hand edge of the table.
  11050. *
  11051. * @memberof Core#
  11052. * @function countEmptyCols
  11053. * @param {Boolean} [ending] If `true`, will only count empty columns at the end of the data source row.
  11054. * @returns {Number} Count empty cols.
  11055. */
  11056. this.countEmptyCols = function (ending) {
  11057. if (instance.countRows() < 1) {
  11058. return 0;
  11059. }
  11060. var emptyColumns = 0;
  11061. (0, _number.rangeEachReverse)(instance.countCols() - 1, function (visualIndex) {
  11062. if (instance.isEmptyCol(visualIndex)) {
  11063. emptyColumns += 1;
  11064. } else if (ending === true) {
  11065. return false;
  11066. }
  11067. });
  11068. return emptyColumns;
  11069. };
  11070. /**
  11071. * Check if all cells in the row declared by the `row` argument are empty.
  11072. *
  11073. * @memberof Core#
  11074. * @function isEmptyRow
  11075. * @param {Number} row Visual row index.
  11076. * @returns {Boolean} `true` if the row at the given `row` is empty, `false` otherwise.
  11077. */
  11078. this.isEmptyRow = function (row) {
  11079. return priv.settings.isEmptyRow.call(instance, row);
  11080. };
  11081. /**
  11082. * Check if all cells in the the column declared by the `col` argument are empty.
  11083. *
  11084. * @memberof Core#
  11085. * @function isEmptyCol
  11086. * @param {Number} col Column index.
  11087. * @returns {Boolean} `true` if the column at the given `col` is empty, `false` otherwise.
  11088. */
  11089. this.isEmptyCol = function (col) {
  11090. return priv.settings.isEmptyCol.call(instance, col);
  11091. };
  11092. /**
  11093. * Select cell specified by `row` and `col` values or a range of cells finishing at `endRow`, `endCol`. If the table
  11094. * was configured to support data column properties that properties can be used to making a selection.
  11095. *
  11096. * By default, viewport will be scrolled to the selection. After the `selectCell` method had finished, the instance
  11097. * will be listening to keyboard input on the document.
  11098. *
  11099. * @example
  11100. * ```js
  11101. * // select a single cell
  11102. * hot.selectCell(2, 4);
  11103. * // select a single cell using column property
  11104. * hot.selectCell(2, 'address');
  11105. * // select a range of cells
  11106. * hot.selectCell(2, 4, 3, 5);
  11107. * // select a range of cells using column properties
  11108. * hot.selectCell(2, 'address', 3, 'phone_number');
  11109. * // select a range of cells without scrolling to them
  11110. * hot.selectCell(2, 'address', 3, 'phone_number', false);
  11111. * ```
  11112. *
  11113. * @memberof Core#
  11114. * @function selectCell
  11115. * @param {Number} row Visual row index.
  11116. * @param {Number|String} column Visual column index or column property.
  11117. * @param {Number} [endRow] Visual end row index (if selecting a range).
  11118. * @param {Number|String} [endColumn] Visual end column index or column property (if selecting a range).
  11119. * @param {Boolean} [scrollToCell=true] If `true`, the viewport will be scrolled to the selection.
  11120. * @param {Boolean} [changeListener=true] If `false`, Handsontable will not change keyboard events listener to himself.
  11121. * @returns {Boolean} `true` if selection was successful, `false` otherwise.
  11122. */
  11123. this.selectCell = function (row, column, endRow, endColumn) {
  11124. var scrollToCell = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  11125. var changeListener = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
  11126. if ((0, _mixed.isUndefined)(row) || (0, _mixed.isUndefined)(column)) {
  11127. return false;
  11128. }
  11129. return this.selectCells([[row, column, endRow, endColumn]], scrollToCell, changeListener);
  11130. };
  11131. /**
  11132. * Make multiple, non-contiguous selection specified by `row` and `column` values or a range of cells
  11133. * finishing at `endRow`, `endColumn`. The method supports two input formats which are the same as that
  11134. * produces by `getSelected` and `getSelectedRange` methods.
  11135. *
  11136. * By default, viewport will be scrolled to selection. After the `selectCells` method had finished, the instance
  11137. * will be listening to keyboard input on the document.
  11138. *
  11139. * @example
  11140. * ```js
  11141. * // using an array of arrays
  11142. * hot.selectCells([[1, 1, 2, 2], [3, 3], [6, 2, 0, 2]]);
  11143. * // using an array of arrays with defined columns as props
  11144. * hot.selectCells([[1, 'id', 2, 'first_name'], [3, 'full_name'], [6, 'last_name', 0, 'first_name']]);
  11145. * // or using an array of CellRange objects (produced by `.getSelectedRange()` method)
  11146. * const selected = hot.getSelectedRange();
  11147. *
  11148. * selected[0].from.row = 0;
  11149. * selected[0].from.col = 0;
  11150. *
  11151. * hot.selectCells(selected);
  11152. * ```
  11153. *
  11154. * @memberof Core#
  11155. * @since 0.38.0
  11156. * @function selectCells
  11157. * @param {Array[]|CellRange[]} coords Visual coords passed as an array of array (`[[rowStart, columnStart, rowEnd, columnEnd], ...]`)
  11158. * the same format as `getSelected` method returns or as an CellRange objects
  11159. * which is the same format what `getSelectedRange` method returns.
  11160. * @param {Boolean} [scrollToCell=true] If `true`, the viewport will be scrolled to the selection.
  11161. * @param {Boolean} [changeListener=true] If `false`, Handsontable will not change keyboard events listener to himself.
  11162. * @returns {Boolean} `true` if selection was successful, `false` otherwise.
  11163. */
  11164. this.selectCells = function () {
  11165. var coords = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [[]];
  11166. var scrollToCell = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  11167. var changeListener = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  11168. if (scrollToCell === false) {
  11169. preventScrollingToCell = true;
  11170. }
  11171. var wasSelected = selection.selectCells(coords);
  11172. if (wasSelected && changeListener) {
  11173. instance.listen();
  11174. }
  11175. preventScrollingToCell = false;
  11176. return wasSelected;
  11177. };
  11178. /**
  11179. * Select the cell specified by the `row` and `prop` arguments, or a range finishing at `endRow`, `endProp`.
  11180. * By default, viewport will be scrolled to selection.
  11181. *
  11182. * @deprecated
  11183. * @memberof Core#
  11184. * @function selectCellByProp
  11185. * @param {Number} row Visual row index.
  11186. * @param {String} prop Property name.
  11187. * @param {Number} [endRow] visual end row index (if selecting a range).
  11188. * @param {String} [endProp] End property name (if selecting a range).
  11189. * @param {Boolean} [scrollToCell=true] If `true`, viewport will be scrolled to the selection.
  11190. * @param {Boolean} [changeListener=true] If `false`, Handsontable will not change keyboard events listener to himself.
  11191. * @returns {Boolean} `true` if selection was successful, `false` otherwise.
  11192. */
  11193. this.selectCellByProp = function (row, prop, endRow, endProp) {
  11194. var scrollToCell = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  11195. var changeListener = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
  11196. (0, _console.warn)((0, _templateLiteralTag.toSingleLine)(_templateObject));
  11197. return this.selectCells([[row, prop, endRow, endProp]], scrollToCell, changeListener);
  11198. };
  11199. /**
  11200. * Select column specified by `startColumn` visual index, column property or a range of columns finishing at `endColumn`.
  11201. *
  11202. * @example
  11203. * ```js
  11204. * // select column using visual index
  11205. * hot.selectColumns(1);
  11206. * // select column using column property
  11207. * hot.selectColumns('id');
  11208. * // select range of columns using visual indexes
  11209. * hot.selectColumns(1, 4);
  11210. * // select range of columns using column properties
  11211. * hot.selectColumns('id', 'last_name');
  11212. * ```
  11213. *
  11214. * @memberof Core#
  11215. * @since 0.38.0
  11216. * @function selectColumns
  11217. * @param {Number} startColumn The visual column index from which the selection starts.
  11218. * @param {Number} [endColumn=startColumn] The visual column index to which the selection finishes. If `endColumn`
  11219. * is not defined the column defined by `startColumn` will be selected.
  11220. * @returns {Boolean} `true` if selection was successful, `false` otherwise.
  11221. */
  11222. this.selectColumns = function (startColumn) {
  11223. var endColumn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startColumn;
  11224. return selection.selectColumns(startColumn, endColumn);
  11225. };
  11226. /**
  11227. * Select row specified by `startRow` visual index or a range of rows finishing at `endRow`.
  11228. *
  11229. * @example
  11230. * ```js
  11231. * select row using visual index
  11232. * hot.selectRows(1);
  11233. * select range of rows using visual indexes
  11234. * hot.selectRows(1, 4);
  11235. * ```
  11236. *
  11237. * @memberof Core#
  11238. * @since 0.38.0
  11239. * @function selectRows
  11240. * @param {Number} startRow The visual row index from which the selection starts.
  11241. * @param {Number} [endRow=startRow] The visual row index to which the selection finishes. If `endRow`
  11242. * is not defined the row defined by `startRow` will be selected.
  11243. * @returns {Boolean} `true` if selection was successful, `false` otherwise.
  11244. */
  11245. this.selectRows = function (startRow) {
  11246. var endRow = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startRow;
  11247. return selection.selectRows(startRow, endRow);
  11248. };
  11249. /**
  11250. * Deselects the current cell selection on grid.
  11251. *
  11252. * @memberof Core#
  11253. * @function deselectCell
  11254. */
  11255. this.deselectCell = function () {
  11256. selection.deselect();
  11257. };
  11258. /**
  11259. * Select the whole table. The previous selection will be overwritten.
  11260. *
  11261. * @since 0.38.2
  11262. * @memberof Core#
  11263. * @function selectAll
  11264. */
  11265. this.selectAll = function () {
  11266. preventScrollingToCell = true;
  11267. selection.selectAll();
  11268. preventScrollingToCell = false;
  11269. };
  11270. /**
  11271. * Scroll viewport to coords specified by the `row` and `column` arguments.
  11272. *
  11273. * @since 0.24.3
  11274. * @memberof Core#
  11275. * @function scrollViewportTo
  11276. * @param {Number} [row] Visual row index.
  11277. * @param {Number} [column] Visual column index.
  11278. * @param {Boolean} [snapToBottom = false] If `true`, viewport is scrolled to show the cell on the bottom of the table.
  11279. * @param {Boolean} [snapToRight = false] If `true`, viewport is scrolled to show the cell on the right side of the table.
  11280. * @returns {Boolean} `true` if scroll was successful, `false` otherwise.
  11281. */
  11282. this.scrollViewportTo = function (row, column) {
  11283. var snapToBottom = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  11284. var snapToRight = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  11285. if (row !== void 0 && (row < 0 || row >= instance.countRows())) {
  11286. return false;
  11287. }
  11288. if (column !== void 0 && (column < 0 || column >= instance.countCols())) {
  11289. return false;
  11290. }
  11291. var result = false;
  11292. if (row !== void 0 && column !== void 0) {
  11293. instance.view.wt.wtOverlays.topOverlay.scrollTo(row, snapToBottom);
  11294. instance.view.wt.wtOverlays.leftOverlay.scrollTo(column, snapToRight);
  11295. result = true;
  11296. }
  11297. if (typeof row === 'number' && typeof column !== 'number') {
  11298. instance.view.wt.wtOverlays.topOverlay.scrollTo(row, snapToBottom);
  11299. result = true;
  11300. }
  11301. if (typeof column === 'number' && typeof row !== 'number') {
  11302. instance.view.wt.wtOverlays.leftOverlay.scrollTo(column, snapToRight);
  11303. result = true;
  11304. }
  11305. return result;
  11306. };
  11307. /**
  11308. * Removes grid from the DOM.
  11309. *
  11310. * @memberof Core#
  11311. * @function destroy
  11312. * @fires Hooks#afterDestroy
  11313. */
  11314. this.destroy = function () {
  11315. instance._clearTimeouts();
  11316. if (instance.view) {
  11317. // in case HT is destroyed before initialization has finished
  11318. instance.view.destroy();
  11319. }
  11320. if (dataSource) {
  11321. dataSource.destroy();
  11322. }
  11323. dataSource = null;
  11324. (0, _keyStateObserver.stopObserving)();
  11325. if (false) {
  11326. var licenseInfo = document.querySelector('#hot-display-license-info');
  11327. if (licenseInfo) {
  11328. licenseInfo.parentNode.removeChild(licenseInfo);
  11329. }
  11330. }
  11331. (0, _element.empty)(instance.rootElement);
  11332. eventManager.destroy();
  11333. if (editorManager) {
  11334. editorManager.destroy();
  11335. }
  11336. instance.runHooks('afterDestroy');
  11337. _pluginHooks2.default.getSingleton().destroy(instance);
  11338. for (var i in instance) {
  11339. if ((0, _object.hasOwnProperty)(instance, i)) {
  11340. // replace instance methods with post mortem
  11341. if ((0, _function.isFunction)(instance[i])) {
  11342. instance[i] = postMortem;
  11343. } else if (i !== 'guid') {
  11344. // replace instance properties with null (restores memory)
  11345. // it should not be necessary but this prevents a memory leak side effects that show itself in Jasmine tests
  11346. instance[i] = null;
  11347. }
  11348. }
  11349. }
  11350. // replace private properties with null (restores memory)
  11351. // it should not be necessary but this prevents a memory leak side effects that show itself in Jasmine tests
  11352. if (datamap) {
  11353. datamap.destroy();
  11354. }
  11355. datamap = null;
  11356. priv = null;
  11357. grid = null;
  11358. selection = null;
  11359. editorManager = null;
  11360. instance = null;
  11361. GridSettings = null;
  11362. };
  11363. /**
  11364. * Replacement for all methods after Handsotnable was destroyed.
  11365. *
  11366. * @private
  11367. */
  11368. function postMortem() {
  11369. throw new Error('This method cannot be called because this Handsontable instance has been destroyed');
  11370. }
  11371. /**
  11372. * Returns the active editor object.
  11373. *
  11374. * @memberof Core#
  11375. * @function getActiveEditor
  11376. * @returns {Object} The active editor object.
  11377. */
  11378. this.getActiveEditor = function () {
  11379. return editorManager.getActiveEditor();
  11380. };
  11381. /**
  11382. * Returns plugin instance using the plugin name provided.
  11383. *
  11384. * @memberof Core#
  11385. * @function getPlugin
  11386. * @param {String} pluginName The plugin name.
  11387. * @returns {*} The plugin instance.
  11388. * @since 0.15.0
  11389. */
  11390. this.getPlugin = function (pluginName) {
  11391. return (0, _plugins.getPlugin)(this, pluginName);
  11392. };
  11393. /**
  11394. * Returns the Handsontable instance.
  11395. *
  11396. * @memberof Core#
  11397. * @function getInstance
  11398. * @returns {Handsontable} The Handsontable instance.
  11399. */
  11400. this.getInstance = function () {
  11401. return instance;
  11402. };
  11403. /**
  11404. * Adds listener to the specified hook name (only for this Handsontable instance).
  11405. *
  11406. * @memberof Core#
  11407. * @function addHook
  11408. * @see Hooks#add
  11409. * @param {String} key Hook name.
  11410. * @param {Function|Array} callback Function or array of Functions.
  11411. *
  11412. * @example
  11413. * ```js
  11414. * hot.addHook('beforeInit', myCallback);
  11415. * ```
  11416. */
  11417. this.addHook = function (key, callback) {
  11418. _pluginHooks2.default.getSingleton().add(key, callback, instance);
  11419. };
  11420. /**
  11421. * Check if for a specified hook name there are added listeners (only for this Handsontable instance).
  11422. *
  11423. * @memberof Core#
  11424. * @function hasHook
  11425. * @see Hooks#has
  11426. * @param {String} key Hook name
  11427. * @return {Boolean}
  11428. *
  11429. * @example
  11430. * ```js
  11431. * var hasBeforeInitListeners = hot.hasHook('beforeInit');
  11432. * ```
  11433. */
  11434. this.hasHook = function (key) {
  11435. return _pluginHooks2.default.getSingleton().has(key, instance);
  11436. };
  11437. /**
  11438. * Adds listener to specified hook name (only for this Handsontable instance).
  11439. * After the listener is triggered, it will be automatically removed.
  11440. *
  11441. * @memberof Core#
  11442. * @function addHookOnce
  11443. * @see Hooks#once
  11444. * @param {String} key Hook name.
  11445. * @param {Function|Array} callback Function or array of Functions.
  11446. *
  11447. * @example
  11448. * ```js
  11449. * hot.addHookOnce('beforeInit', myCallback);
  11450. * ```
  11451. */
  11452. this.addHookOnce = function (key, callback) {
  11453. _pluginHooks2.default.getSingleton().once(key, callback, instance);
  11454. };
  11455. /**
  11456. * Removes the hook listener previously registered with {@link Core#addHook}.
  11457. *
  11458. * @memberof Core#
  11459. * @function removeHook
  11460. * @see Hooks#remove
  11461. * @param {String} key Hook name.
  11462. * @param {Function} callback Function which have been registered via {@link Core#addHook}.
  11463. *
  11464. * @example
  11465. * ```js
  11466. * hot.removeHook('beforeInit', myCallback);
  11467. * ```
  11468. */
  11469. this.removeHook = function (key, callback) {
  11470. _pluginHooks2.default.getSingleton().remove(key, callback, instance);
  11471. };
  11472. /**
  11473. * Run the callbacks for the hook provided in the `key` argument using the parameters given in the other arguments.
  11474. *
  11475. * @memberof Core#
  11476. * @function runHooks
  11477. * @see Hooks#run
  11478. * @param {String} key Hook name.
  11479. * @param {*} [p1] Argument passed to the callback.
  11480. * @param {*} [p2] Argument passed to the callback.
  11481. * @param {*} [p3] Argument passed to the callback.
  11482. * @param {*} [p4] Argument passed to the callback.
  11483. * @param {*} [p5] Argument passed to the callback.
  11484. * @param {*} [p6] Argument passed to the callback.
  11485. * @returns {*}
  11486. *
  11487. * @example
  11488. * ```js
  11489. * hot.runHooks('beforeInit');
  11490. * ```
  11491. */
  11492. this.runHooks = function (key, p1, p2, p3, p4, p5, p6) {
  11493. return _pluginHooks2.default.getSingleton().run(instance, key, p1, p2, p3, p4, p5, p6);
  11494. };
  11495. /**
  11496. * Get phrase for specified dictionary key.
  11497. *
  11498. * @memberof Core#
  11499. * @function getTranslatedPhrase
  11500. * @since 0.35.0
  11501. * @param {String} dictionaryKey Constant which is dictionary key.
  11502. * @param {*} extraArguments Arguments which will be handled by formatters.
  11503. *
  11504. * @returns {String}
  11505. */
  11506. this.getTranslatedPhrase = function (dictionaryKey, extraArguments) {
  11507. return (0, _i18n.getTranslatedPhrase)(priv.settings.language, dictionaryKey, extraArguments);
  11508. };
  11509. this.timeouts = [];
  11510. /**
  11511. * Sets timeout. Purpose of this method is to clear all known timeouts when `destroy` method is called.
  11512. *
  11513. * @param {*} handle
  11514. * @private
  11515. */
  11516. this._registerTimeout = function (handle) {
  11517. this.timeouts.push(handle);
  11518. };
  11519. /**
  11520. * Clears all known timeouts.
  11521. *
  11522. * @private
  11523. */
  11524. this._clearTimeouts = function () {
  11525. for (var i = 0, ilen = this.timeouts.length; i < ilen; i++) {
  11526. clearTimeout(this.timeouts[i]);
  11527. }
  11528. };
  11529. /**
  11530. * Refresh selection borders. This is temporary method relic after selection rewrite.
  11531. *
  11532. * @private
  11533. * @param {Boolean} revertOriginal
  11534. */
  11535. this._refreshBorders = function (revertOriginal) {
  11536. editorManager.destroyEditor(revertOriginal);
  11537. instance.view.render();
  11538. if (selection.isSelected()) {
  11539. editorManager.prepareEditor();
  11540. }
  11541. };
  11542. _pluginHooks2.default.getSingleton().run(instance, 'construct');
  11543. };
  11544. /***/ }),
  11545. /* 89 */
  11546. /***/ (function(module, exports, __webpack_require__) {
  11547. "use strict";
  11548. exports.__esModule = true;
  11549. exports.columnFactory = columnFactory;
  11550. var _object = __webpack_require__(2);
  11551. /* eslint-disable import/prefer-default-export */
  11552. /**
  11553. * Factory for columns constructors.
  11554. *
  11555. * @param {Object} GridSettings
  11556. * @param {Array} conflictList
  11557. * @return {Object} ColumnSettings
  11558. */
  11559. function columnFactory(GridSettings, conflictList) {
  11560. function ColumnSettings() {};
  11561. (0, _object.inherit)(ColumnSettings, GridSettings);
  11562. // Clear conflict settings
  11563. for (var i = 0, len = conflictList.length; i < len; i++) {
  11564. ColumnSettings.prototype[conflictList[i]] = void 0;
  11565. }
  11566. return ColumnSettings;
  11567. }
  11568. /***/ }),
  11569. /* 90 */
  11570. /***/ (function(module, exports, __webpack_require__) {
  11571. "use strict";
  11572. exports.__esModule = true;
  11573. exports.spreadsheetColumnLabel = spreadsheetColumnLabel;
  11574. exports.spreadsheetColumnIndex = spreadsheetColumnIndex;
  11575. exports.createSpreadsheetData = createSpreadsheetData;
  11576. exports.createSpreadsheetObjectData = createSpreadsheetObjectData;
  11577. exports.createEmptySpreadsheetData = createEmptySpreadsheetData;
  11578. exports.translateRowsToColumns = translateRowsToColumns;
  11579. exports.cellMethodLookupFactory = cellMethodLookupFactory;
  11580. var _cellTypes = __webpack_require__(87);
  11581. var _object = __webpack_require__(2);
  11582. var COLUMN_LABEL_BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  11583. var COLUMN_LABEL_BASE_LENGTH = COLUMN_LABEL_BASE.length;
  11584. /**
  11585. * Generates spreadsheet-like column names: A, B, C, ..., Z, AA, AB, etc.
  11586. *
  11587. * @param {Number} index Column index.
  11588. * @returns {String}
  11589. */
  11590. function spreadsheetColumnLabel(index) {
  11591. var dividend = index + 1;
  11592. var columnLabel = '';
  11593. var modulo = void 0;
  11594. while (dividend > 0) {
  11595. modulo = (dividend - 1) % COLUMN_LABEL_BASE_LENGTH;
  11596. columnLabel = String.fromCharCode(65 + modulo) + columnLabel;
  11597. dividend = parseInt((dividend - modulo) / COLUMN_LABEL_BASE_LENGTH, 10);
  11598. }
  11599. return columnLabel;
  11600. }
  11601. /**
  11602. * Generates spreadsheet-like column index from theirs labels: A, B, C ...., Z, AA, AB, etc.
  11603. *
  11604. * @param {String} label Column label.
  11605. * @returns {Number}
  11606. */
  11607. function spreadsheetColumnIndex(label) {
  11608. var result = 0;
  11609. if (label) {
  11610. for (var i = 0, j = label.length - 1; i < label.length; i += 1, j -= 1) {
  11611. result += Math.pow(COLUMN_LABEL_BASE_LENGTH, j) * (COLUMN_LABEL_BASE.indexOf(label[i]) + 1);
  11612. }
  11613. }
  11614. --result;
  11615. return result;
  11616. }
  11617. /**
  11618. * Creates 2D array of Excel-like values "A1", "A2", ...
  11619. *
  11620. * @param {Number} rows Number of rows to generate.
  11621. * @param {Number} columns Number of columns to generate.
  11622. * @returns {Array}
  11623. */
  11624. function createSpreadsheetData() {
  11625. var rows = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
  11626. var columns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4;
  11627. var _rows = [],
  11628. i,
  11629. j;
  11630. for (i = 0; i < rows; i++) {
  11631. var row = [];
  11632. for (j = 0; j < columns; j++) {
  11633. row.push(spreadsheetColumnLabel(j) + (i + 1));
  11634. }
  11635. _rows.push(row);
  11636. }
  11637. return _rows;
  11638. }
  11639. /**
  11640. * Creates 2D array of Excel-like values "A1", "A2", as an array of objects.
  11641. *
  11642. * @param {Number} rows Number of rows to generate.
  11643. * @param {Number} colCount Number of columns to generate.
  11644. * @returns {Array}
  11645. */
  11646. function createSpreadsheetObjectData() {
  11647. var rows = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
  11648. var colCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4;
  11649. var _rows = [],
  11650. i,
  11651. j;
  11652. for (i = 0; i < rows; i++) {
  11653. var row = {};
  11654. for (j = 0; j < colCount; j++) {
  11655. row['prop' + j] = spreadsheetColumnLabel(j) + (i + 1);
  11656. }
  11657. _rows.push(row);
  11658. }
  11659. return _rows;
  11660. }
  11661. /**
  11662. * Generates an empty data object.
  11663. *
  11664. * @param {Number} rows Number of rows to generate.
  11665. * @param {Number} columns Number of columns to generate
  11666. * @returns {Array}
  11667. */
  11668. function createEmptySpreadsheetData(rows, columns) {
  11669. var data = [];
  11670. var row = void 0;
  11671. for (var i = 0; i < rows; i++) {
  11672. row = [];
  11673. for (var j = 0; j < columns; j++) {
  11674. row.push('');
  11675. }
  11676. data.push(row);
  11677. }
  11678. return data;
  11679. }
  11680. function translateRowsToColumns(input) {
  11681. var i,
  11682. ilen,
  11683. j,
  11684. jlen,
  11685. output = [],
  11686. olen = 0;
  11687. for (i = 0, ilen = input.length; i < ilen; i++) {
  11688. for (j = 0, jlen = input[i].length; j < jlen; j++) {
  11689. if (j == olen) {
  11690. output.push([]);
  11691. olen++;
  11692. }
  11693. output[j].push(input[i][j]);
  11694. }
  11695. }
  11696. return output;
  11697. }
  11698. /**
  11699. * Factory that produces a function for searching methods (or any properties) which could be defined directly in
  11700. * table configuration or implicitly, within cell type definition.
  11701. *
  11702. * For example: renderer can be defined explicitly using "renderer" property in column configuration or it can be
  11703. * defined implicitly using "type" property.
  11704. *
  11705. * Methods/properties defined explicitly always takes precedence over those defined through "type".
  11706. *
  11707. * If the method/property is not found in an object, searching is continued recursively through prototype chain, until
  11708. * it reaches the Object.prototype.
  11709. *
  11710. *
  11711. * @param methodName {String} name of the method/property to search (i.e. 'renderer', 'validator', 'copyable')
  11712. * @param allowUndefined {Boolean} [optional] if false, the search is continued if methodName has not been found in cell "type"
  11713. * @returns {Function}
  11714. */
  11715. function cellMethodLookupFactory(methodName, allowUndefined) {
  11716. allowUndefined = typeof allowUndefined == 'undefined' ? true : allowUndefined;
  11717. return function cellMethodLookup(row, col) {
  11718. return function getMethodFromProperties(properties) {
  11719. if (!properties) {
  11720. return; // method not found
  11721. } else if ((0, _object.hasOwnProperty)(properties, methodName) && properties[methodName] !== void 0) {
  11722. // check if it is own and is not empty
  11723. return properties[methodName]; // method defined directly
  11724. } else if ((0, _object.hasOwnProperty)(properties, 'type') && properties.type) {
  11725. // check if it is own and is not empty
  11726. var type;
  11727. if (typeof properties.type != 'string') {
  11728. throw new Error('Cell type must be a string ');
  11729. }
  11730. type = (0, _cellTypes.getCellType)(properties.type);
  11731. if ((0, _object.hasOwnProperty)(type, methodName)) {
  11732. return type[methodName]; // method defined in type.
  11733. } else if (allowUndefined) {
  11734. return; // method does not defined in type (eg. validator), returns undefined
  11735. }
  11736. }
  11737. return getMethodFromProperties(Object.getPrototypeOf(properties));
  11738. }(typeof row == 'number' ? this.getCellMeta(row, col) : row);
  11739. };
  11740. }
  11741. /***/ }),
  11742. /* 91 */
  11743. /***/ (function(module, exports, __webpack_require__) {
  11744. "use strict";
  11745. exports.__esModule = true;
  11746. exports.SELECTION_TYPES = exports.SELECTION_TYPE_OBJECT = exports.SELECTION_TYPE_ARRAY = exports.SELECTION_TYPE_EMPTY = exports.SELECTION_TYPE_UNRECOGNIZED = undefined;
  11747. 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"); } }; }();
  11748. 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; };
  11749. exports.detectSelectionType = detectSelectionType;
  11750. exports.normalizeSelectionFactory = normalizeSelectionFactory;
  11751. exports.transformSelectionToColumnDistance = transformSelectionToColumnDistance;
  11752. exports.transformSelectionToRowDistance = transformSelectionToRowDistance;
  11753. exports.isValidCoord = isValidCoord;
  11754. var _src = __webpack_require__(4);
  11755. var _array = __webpack_require__(1);
  11756. var _mixed = __webpack_require__(16);
  11757. var SELECTION_TYPE_UNRECOGNIZED = exports.SELECTION_TYPE_UNRECOGNIZED = 0;
  11758. var SELECTION_TYPE_EMPTY = exports.SELECTION_TYPE_EMPTY = 1;
  11759. var SELECTION_TYPE_ARRAY = exports.SELECTION_TYPE_ARRAY = 2;
  11760. var SELECTION_TYPE_OBJECT = exports.SELECTION_TYPE_OBJECT = 3;
  11761. var SELECTION_TYPES = exports.SELECTION_TYPES = [SELECTION_TYPE_OBJECT, SELECTION_TYPE_ARRAY];
  11762. var ARRAY_TYPE_PATTERN = [['number'], ['number', 'string'], ['number', 'undefined'], ['number', 'string', 'undefined']];
  11763. var rootCall = Symbol('root');
  11764. var childCall = Symbol('child');
  11765. /**
  11766. * Detect selection schema structure.
  11767. *
  11768. * @param {*} selectionRanges The selected range or and array of selected ranges. This type of data is produced by
  11769. * `hot.getSelected()`, `hot.getSelectedLast()`, `hot.getSelectedRange()`
  11770. * and `hot.getSelectedRangeLast()` methods.
  11771. * @returns {Number} Returns a number that specifies the type of detected selection schema. If selection schema type
  11772. * is unrecognized than it returns `0`.
  11773. */
  11774. function detectSelectionType(selectionRanges) {
  11775. var _callSymbol = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : rootCall;
  11776. if (_callSymbol !== rootCall && _callSymbol !== childCall) {
  11777. throw new Error('The second argument is used internally only and cannot be overwritten.');
  11778. }
  11779. var isArray = Array.isArray(selectionRanges);
  11780. var isRootCall = _callSymbol === rootCall;
  11781. var result = SELECTION_TYPE_UNRECOGNIZED;
  11782. if (isArray) {
  11783. var firstItem = selectionRanges[0];
  11784. if (selectionRanges.length === 0) {
  11785. result = SELECTION_TYPE_EMPTY;
  11786. } else if (isRootCall && firstItem instanceof _src.CellRange) {
  11787. result = SELECTION_TYPE_OBJECT;
  11788. } else if (isRootCall && Array.isArray(firstItem)) {
  11789. result = detectSelectionType(firstItem, childCall);
  11790. } else if (selectionRanges.length >= 2 && selectionRanges.length <= 4) {
  11791. var isArrayType = !selectionRanges.some(function (value, index) {
  11792. return !ARRAY_TYPE_PATTERN[index].includes(typeof value === 'undefined' ? 'undefined' : _typeof(value));
  11793. });
  11794. if (isArrayType) {
  11795. result = SELECTION_TYPE_ARRAY;
  11796. }
  11797. }
  11798. }
  11799. return result;
  11800. }
  11801. /**
  11802. * Factory function designed for normalization data schema from different data structures of the selection ranges.
  11803. *
  11804. * @param {String} type Selection type which will be processed.
  11805. * @param {Object} [options]
  11806. * @param {Boolean} [options.keepDirection=false] If `true`, the coordinates which contain the direction of the
  11807. * selected cells won't be changed. Otherwise, the selection will be
  11808. * normalized to values starting from top-left to bottom-right.
  11809. * @param {Function} [options.propToCol] Pass the converting function (usually `datamap.propToCol`) if the column
  11810. * defined as props should be normalized to the numeric values.
  11811. * @returns {Number[]} Returns normalized data about selected range as an array (`[rowStart, columnStart, rowEnd, columnEnd]`).
  11812. */
  11813. function normalizeSelectionFactory(type) {
  11814. var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  11815. _ref$keepDirection = _ref.keepDirection,
  11816. keepDirection = _ref$keepDirection === undefined ? false : _ref$keepDirection,
  11817. propToCol = _ref.propToCol;
  11818. if (!SELECTION_TYPES.includes(type)) {
  11819. throw new Error('Unsupported selection ranges schema type was provided.');
  11820. }
  11821. return function (selection) {
  11822. var isObjectType = type === SELECTION_TYPE_OBJECT;
  11823. var rowStart = isObjectType ? selection.from.row : selection[0];
  11824. var columnStart = isObjectType ? selection.from.col : selection[1];
  11825. var rowEnd = isObjectType ? selection.to.row : selection[2];
  11826. var columnEnd = isObjectType ? selection.to.col : selection[3];
  11827. if (typeof propToCol === 'function') {
  11828. if (typeof columnStart === 'string') {
  11829. columnStart = propToCol(columnStart);
  11830. }
  11831. if (typeof columnEnd === 'string') {
  11832. columnEnd = propToCol(columnEnd);
  11833. }
  11834. }
  11835. if ((0, _mixed.isUndefined)(rowEnd)) {
  11836. rowEnd = rowStart;
  11837. }
  11838. if ((0, _mixed.isUndefined)(columnEnd)) {
  11839. columnEnd = columnStart;
  11840. }
  11841. if (!keepDirection) {
  11842. var origRowStart = rowStart;
  11843. var origColumnStart = columnStart;
  11844. var origRowEnd = rowEnd;
  11845. var origColumnEnd = columnEnd;
  11846. rowStart = Math.min(origRowStart, origRowEnd);
  11847. columnStart = Math.min(origColumnStart, origColumnEnd);
  11848. rowEnd = Math.max(origRowStart, origRowEnd);
  11849. columnEnd = Math.max(origColumnStart, origColumnEnd);
  11850. }
  11851. return [rowStart, columnStart, rowEnd, columnEnd];
  11852. };
  11853. }
  11854. /**
  11855. * Function transform selection ranges (produced by `hot.getSelected()` and `hot.getSelectedRange()`) to normalized
  11856. * data structure. It merges repeated ranges into consecutive coordinates. The returned structure
  11857. * contains an array of arrays. The single item contains at index 0 visual column index from the selection was
  11858. * started and at index 1 distance as a count of selected columns.
  11859. *
  11860. * @param {Array[]|CellRange[]} selectionRanges Selection ranges produced by Handsontable.
  11861. * @return {Array[]} Returns an array of arrays with ranges defines in that schema:
  11862. * `[[visualColumnStart, distance], [visualColumnStart, distance], ...]`.
  11863. * The column distances are always created starting from the left (zero index) to the
  11864. * right (the latest column index).
  11865. */
  11866. function transformSelectionToColumnDistance(selectionRanges) {
  11867. var selectionType = detectSelectionType(selectionRanges);
  11868. if (selectionType === SELECTION_TYPE_UNRECOGNIZED || selectionType === SELECTION_TYPE_EMPTY) {
  11869. return [];
  11870. }
  11871. var selectionSchemaNormalizer = normalizeSelectionFactory(selectionType);
  11872. var unorderedIndexes = new Set();
  11873. // Iterate through all ranges and collect all column indexes which are not saved yet.
  11874. (0, _array.arrayEach)(selectionRanges, function (selection) {
  11875. var _selectionSchemaNorma = selectionSchemaNormalizer(selection),
  11876. _selectionSchemaNorma2 = _slicedToArray(_selectionSchemaNorma, 4),
  11877. columnStart = _selectionSchemaNorma2[1],
  11878. columnEnd = _selectionSchemaNorma2[3];
  11879. var amount = columnEnd - columnStart + 1;
  11880. (0, _array.arrayEach)(Array.from(new Array(amount), function (_, i) {
  11881. return columnStart + i;
  11882. }), function (index) {
  11883. if (!unorderedIndexes.has(index)) {
  11884. unorderedIndexes.add(index);
  11885. }
  11886. });
  11887. });
  11888. // Sort indexes in ascending order to easily detecting non-consecutive columns.
  11889. var orderedIndexes = Array.from(unorderedIndexes).sort(function (a, b) {
  11890. return a - b;
  11891. });
  11892. var normalizedColumnRanges = (0, _array.arrayReduce)(orderedIndexes, function (acc, visualColumnIndex, index, array) {
  11893. if (index !== 0 && visualColumnIndex === array[index - 1] + 1) {
  11894. acc[acc.length - 1][1]++;
  11895. } else {
  11896. acc.push([visualColumnIndex, 1]);
  11897. }
  11898. return acc;
  11899. }, []);
  11900. return normalizedColumnRanges;
  11901. }
  11902. /**
  11903. * Function transform selection ranges (produced by `hot.getSelected()` and `hot.getSelectedRange()`) to normalized
  11904. * data structure. It merges repeated ranges into consecutive coordinates. The returned structure
  11905. * contains an array of arrays. The single item contains at index 0 visual column index from the selection was
  11906. * started and at index 1 distance as a count of selected columns.
  11907. *
  11908. * @param {Array[]|CellRange[]} selectionRanges Selection ranges produced by Handsontable.
  11909. * @return {Array[]} Returns an array of arrays with ranges defines in that schema:
  11910. * `[[visualColumnStart, distance], [visualColumnStart, distance], ...]`.
  11911. * The column distances are always created starting from the left (zero index) to the
  11912. * right (the latest column index).
  11913. */
  11914. function transformSelectionToRowDistance(selectionRanges) {
  11915. var selectionType = detectSelectionType(selectionRanges);
  11916. if (selectionType === SELECTION_TYPE_UNRECOGNIZED || selectionType === SELECTION_TYPE_EMPTY) {
  11917. return [];
  11918. }
  11919. var selectionSchemaNormalizer = normalizeSelectionFactory(selectionType);
  11920. var unorderedIndexes = new Set();
  11921. // Iterate through all ranges and collect all column indexes which are not saved yet.
  11922. (0, _array.arrayEach)(selectionRanges, function (selection) {
  11923. var _selectionSchemaNorma3 = selectionSchemaNormalizer(selection),
  11924. _selectionSchemaNorma4 = _slicedToArray(_selectionSchemaNorma3, 3),
  11925. rowStart = _selectionSchemaNorma4[0],
  11926. rowEnd = _selectionSchemaNorma4[2];
  11927. var amount = rowEnd - rowStart + 1;
  11928. (0, _array.arrayEach)(Array.from(new Array(amount), function (_, i) {
  11929. return rowStart + i;
  11930. }), function (index) {
  11931. if (!unorderedIndexes.has(index)) {
  11932. unorderedIndexes.add(index);
  11933. }
  11934. });
  11935. });
  11936. // Sort indexes in ascending order to easily detecting non-consecutive columns.
  11937. var orderedIndexes = Array.from(unorderedIndexes).sort(function (a, b) {
  11938. return a - b;
  11939. });
  11940. var normalizedRowRanges = (0, _array.arrayReduce)(orderedIndexes, function (acc, rowIndex, index, array) {
  11941. if (index !== 0 && rowIndex === array[index - 1] + 1) {
  11942. acc[acc.length - 1][1]++;
  11943. } else {
  11944. acc.push([rowIndex, 1]);
  11945. }
  11946. return acc;
  11947. }, []);
  11948. return normalizedRowRanges;
  11949. }
  11950. /**
  11951. * Check if passed value can be treated as valid cell coordinate. The second argument is
  11952. * used to check if the value doesn't exceed the defined max table rows/columns count.
  11953. *
  11954. * @param {*} coord
  11955. * @param {Number} maxTableItemsCount The value that declares the maximum coordinate that is still validatable.
  11956. * @return {Boolean}
  11957. */
  11958. function isValidCoord(coord) {
  11959. var maxTableItemsCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
  11960. return typeof coord === 'number' && coord >= 0 && coord < maxTableItemsCount;
  11961. };
  11962. /***/ }),
  11963. /* 92 */
  11964. /***/ (function(module, exports, __webpack_require__) {
  11965. "use strict";
  11966. exports.__esModule = true;
  11967. 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; }; }();
  11968. var _element = __webpack_require__(0);
  11969. var _array = __webpack_require__(1);
  11970. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11971. /**
  11972. * @class GhostTable
  11973. * @util
  11974. */
  11975. var GhostTable = function () {
  11976. function GhostTable(hotInstance) {
  11977. _classCallCheck(this, GhostTable);
  11978. /**
  11979. * Handsontable instance.
  11980. *
  11981. * @type {Core}
  11982. */
  11983. this.hot = hotInstance;
  11984. /**
  11985. * Container element where every table will be injected.
  11986. *
  11987. * @type {HTMLElement|null}
  11988. */
  11989. this.container = null;
  11990. /**
  11991. * Flag which determine is table was injected to DOM.
  11992. *
  11993. * @type {Boolean}
  11994. */
  11995. this.injected = false;
  11996. /**
  11997. * Added rows collection.
  11998. *
  11999. * @type {Array}
  12000. */
  12001. this.rows = [];
  12002. /**
  12003. * Added columns collection.
  12004. *
  12005. * @type {Array}
  12006. */
  12007. this.columns = [];
  12008. /**
  12009. * Samples prepared for calculations.
  12010. *
  12011. * @type {Map}
  12012. * @default {null}
  12013. */
  12014. this.samples = null;
  12015. /**
  12016. * Ghost table settings.
  12017. *
  12018. * @type {Object}
  12019. * @default {Object}
  12020. */
  12021. this.settings = {
  12022. useHeaders: true
  12023. };
  12024. }
  12025. /**
  12026. * Add row.
  12027. *
  12028. * @param {Number} row Row index.
  12029. * @param {Map} samples Samples Map object.
  12030. */
  12031. _createClass(GhostTable, [{
  12032. key: 'addRow',
  12033. value: function addRow(row, samples) {
  12034. if (this.columns.length) {
  12035. throw new Error('Doesn\'t support multi-dimensional table');
  12036. }
  12037. if (!this.rows.length) {
  12038. this.container = this.createContainer(this.hot.rootElement.className);
  12039. }
  12040. var rowObject = { row: row };
  12041. this.rows.push(rowObject);
  12042. this.samples = samples;
  12043. this.table = this.createTable(this.hot.table.className);
  12044. this.table.colGroup.appendChild(this.createColGroupsCol());
  12045. this.table.tr.appendChild(this.createRow(row));
  12046. this.container.container.appendChild(this.table.fragment);
  12047. rowObject.table = this.table.table;
  12048. }
  12049. /**
  12050. * Add a row consisting of the column headers.
  12051. */
  12052. }, {
  12053. key: 'addColumnHeadersRow',
  12054. value: function addColumnHeadersRow(samples) {
  12055. if (this.hot.getColHeader(0) != null) {
  12056. var rowObject = { row: -1 };
  12057. this.rows.push(rowObject);
  12058. this.container = this.createContainer(this.hot.rootElement.className);
  12059. this.samples = samples;
  12060. this.table = this.createTable(this.hot.table.className);
  12061. this.table.colGroup.appendChild(this.createColGroupsCol());
  12062. this.table.tHead.appendChild(this.createColumnHeadersRow());
  12063. this.container.container.appendChild(this.table.fragment);
  12064. rowObject.table = this.table.table;
  12065. }
  12066. }
  12067. /**
  12068. * Add column.
  12069. *
  12070. * @param {Number} column Column index.
  12071. * @param {Map} samples Samples Map object.
  12072. */
  12073. }, {
  12074. key: 'addColumn',
  12075. value: function addColumn(column, samples) {
  12076. if (this.rows.length) {
  12077. throw new Error('Doesn\'t support multi-dimensional table');
  12078. }
  12079. if (!this.columns.length) {
  12080. this.container = this.createContainer(this.hot.rootElement.className);
  12081. }
  12082. var columnObject = { col: column };
  12083. this.columns.push(columnObject);
  12084. this.samples = samples;
  12085. this.table = this.createTable(this.hot.table.className);
  12086. if (this.getSetting('useHeaders') && this.hot.getColHeader(column) !== null) {
  12087. this.hot.view.appendColHeader(column, this.table.th);
  12088. }
  12089. this.table.tBody.appendChild(this.createCol(column));
  12090. this.container.container.appendChild(this.table.fragment);
  12091. columnObject.table = this.table.table;
  12092. }
  12093. /**
  12094. * Get calculated heights.
  12095. *
  12096. * @param {Function} callback Callback which will be fired for each calculated row.
  12097. */
  12098. }, {
  12099. key: 'getHeights',
  12100. value: function getHeights(callback) {
  12101. if (!this.injected) {
  12102. this.injectTable();
  12103. }
  12104. (0, _array.arrayEach)(this.rows, function (row) {
  12105. // -1 <- reduce border-top from table
  12106. callback(row.row, (0, _element.outerHeight)(row.table) - 1);
  12107. });
  12108. }
  12109. /**
  12110. * Get calculated widths.
  12111. *
  12112. * @param {Function} callback Callback which will be fired for each calculated column.
  12113. */
  12114. }, {
  12115. key: 'getWidths',
  12116. value: function getWidths(callback) {
  12117. if (!this.injected) {
  12118. this.injectTable();
  12119. }
  12120. (0, _array.arrayEach)(this.columns, function (column) {
  12121. callback(column.col, (0, _element.outerWidth)(column.table));
  12122. });
  12123. }
  12124. /**
  12125. * Set the Ghost Table settings to the provided object.
  12126. *
  12127. * @param {Object} settings New Ghost Table Settings
  12128. */
  12129. }, {
  12130. key: 'setSettings',
  12131. value: function setSettings(settings) {
  12132. this.settings = settings;
  12133. }
  12134. /**
  12135. * Set a single setting of the Ghost Table.
  12136. *
  12137. * @param {String} name Setting name.
  12138. * @param {*} value Setting value.
  12139. */
  12140. }, {
  12141. key: 'setSetting',
  12142. value: function setSetting(name, value) {
  12143. if (!this.settings) {
  12144. this.settings = {};
  12145. }
  12146. this.settings[name] = value;
  12147. }
  12148. /**
  12149. * Get the Ghost Table settings.
  12150. *
  12151. * @returns {Object|null}
  12152. */
  12153. }, {
  12154. key: 'getSettings',
  12155. value: function getSettings() {
  12156. return this.settings;
  12157. }
  12158. /**
  12159. * Get a single Ghost Table setting.
  12160. *
  12161. * @param {String} name
  12162. * @returns {Boolean|null}
  12163. */
  12164. }, {
  12165. key: 'getSetting',
  12166. value: function getSetting(name) {
  12167. if (this.settings) {
  12168. return this.settings[name];
  12169. }
  12170. return null;
  12171. }
  12172. /**
  12173. * Create colgroup col elements.
  12174. *
  12175. * @returns {DocumentFragment}
  12176. */
  12177. }, {
  12178. key: 'createColGroupsCol',
  12179. value: function createColGroupsCol() {
  12180. var _this = this;
  12181. var d = document;
  12182. var fragment = d.createDocumentFragment();
  12183. if (this.hot.hasRowHeaders()) {
  12184. fragment.appendChild(this.createColElement(-1));
  12185. }
  12186. this.samples.forEach(function (sample) {
  12187. (0, _array.arrayEach)(sample.strings, function (string) {
  12188. fragment.appendChild(_this.createColElement(string.col));
  12189. });
  12190. });
  12191. return fragment;
  12192. }
  12193. /**
  12194. * Create table row element.
  12195. *
  12196. * @param {Number} row Row index.
  12197. * @returns {DocumentFragment} Returns created table row elements.
  12198. */
  12199. }, {
  12200. key: 'createRow',
  12201. value: function createRow(row) {
  12202. var _this2 = this;
  12203. var d = document;
  12204. var fragment = d.createDocumentFragment();
  12205. var th = d.createElement('th');
  12206. if (this.hot.hasRowHeaders()) {
  12207. this.hot.view.appendRowHeader(row, th);
  12208. fragment.appendChild(th);
  12209. }
  12210. this.samples.forEach(function (sample) {
  12211. (0, _array.arrayEach)(sample.strings, function (string) {
  12212. var column = string.col;
  12213. var cellProperties = _this2.hot.getCellMeta(row, column);
  12214. cellProperties.col = column;
  12215. cellProperties.row = row;
  12216. var renderer = _this2.hot.getCellRenderer(cellProperties);
  12217. var td = d.createElement('td');
  12218. renderer(_this2.hot, td, row, column, _this2.hot.colToProp(column), string.value, cellProperties);
  12219. fragment.appendChild(td);
  12220. });
  12221. });
  12222. return fragment;
  12223. }
  12224. }, {
  12225. key: 'createColumnHeadersRow',
  12226. value: function createColumnHeadersRow() {
  12227. var _this3 = this;
  12228. var d = document;
  12229. var fragment = d.createDocumentFragment();
  12230. if (this.hot.hasRowHeaders()) {
  12231. var th = d.createElement('th');
  12232. this.hot.view.appendColHeader(-1, th);
  12233. fragment.appendChild(th);
  12234. }
  12235. this.samples.forEach(function (sample) {
  12236. (0, _array.arrayEach)(sample.strings, function (string) {
  12237. var column = string.col;
  12238. var th = d.createElement('th');
  12239. _this3.hot.view.appendColHeader(column, th);
  12240. fragment.appendChild(th);
  12241. });
  12242. });
  12243. return fragment;
  12244. }
  12245. /**
  12246. * Create table column elements.
  12247. *
  12248. * @param {Number} column Column index.
  12249. * @returns {DocumentFragment} Returns created column table column elements.
  12250. */
  12251. }, {
  12252. key: 'createCol',
  12253. value: function createCol(column) {
  12254. var _this4 = this;
  12255. var d = document;
  12256. var fragment = d.createDocumentFragment();
  12257. this.samples.forEach(function (sample) {
  12258. (0, _array.arrayEach)(sample.strings, function (string) {
  12259. var row = string.row;
  12260. var cellProperties = _this4.hot.getCellMeta(row, column);
  12261. cellProperties.col = column;
  12262. cellProperties.row = row;
  12263. var renderer = _this4.hot.getCellRenderer(cellProperties);
  12264. var td = d.createElement('td');
  12265. var tr = d.createElement('tr');
  12266. renderer(_this4.hot, td, row, column, _this4.hot.colToProp(column), string.value, cellProperties);
  12267. tr.appendChild(td);
  12268. fragment.appendChild(tr);
  12269. });
  12270. });
  12271. return fragment;
  12272. }
  12273. /**
  12274. * Remove table from document and reset internal state.
  12275. */
  12276. }, {
  12277. key: 'clean',
  12278. value: function clean() {
  12279. this.rows.length = 0;
  12280. this.rows[-1] = void 0;
  12281. this.columns.length = 0;
  12282. if (this.samples) {
  12283. this.samples.clear();
  12284. }
  12285. this.samples = null;
  12286. this.removeTable();
  12287. }
  12288. /**
  12289. * Inject generated table into document.
  12290. *
  12291. * @param {HTMLElement} [parent=null]
  12292. */
  12293. }, {
  12294. key: 'injectTable',
  12295. value: function injectTable() {
  12296. var parent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  12297. if (!this.injected) {
  12298. (parent || this.hot.rootElement).appendChild(this.container.fragment);
  12299. this.injected = true;
  12300. }
  12301. }
  12302. /**
  12303. * Remove table from document.
  12304. */
  12305. }, {
  12306. key: 'removeTable',
  12307. value: function removeTable() {
  12308. if (this.injected && this.container.container.parentNode) {
  12309. this.container.container.parentNode.removeChild(this.container.container);
  12310. this.container = null;
  12311. this.injected = false;
  12312. }
  12313. }
  12314. /**
  12315. * Create col element.
  12316. *
  12317. * @param {Number} column Column index.
  12318. * @returns {HTMLElement}
  12319. */
  12320. }, {
  12321. key: 'createColElement',
  12322. value: function createColElement(column) {
  12323. var d = document;
  12324. var col = d.createElement('col');
  12325. col.style.width = this.hot.view.wt.wtTable.getStretchedColumnWidth(column) + 'px';
  12326. return col;
  12327. }
  12328. /**
  12329. * Create table element.
  12330. *
  12331. * @param {String} className
  12332. * @returns {Object}
  12333. */
  12334. }, {
  12335. key: 'createTable',
  12336. value: function createTable() {
  12337. var className = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  12338. var d = document;
  12339. var fragment = d.createDocumentFragment();
  12340. var table = d.createElement('table');
  12341. var tHead = d.createElement('thead');
  12342. var tBody = d.createElement('tbody');
  12343. var colGroup = d.createElement('colgroup');
  12344. var tr = d.createElement('tr');
  12345. var th = d.createElement('th');
  12346. if (this.isVertical()) {
  12347. table.appendChild(colGroup);
  12348. }
  12349. if (this.isHorizontal()) {
  12350. tr.appendChild(th);
  12351. tHead.appendChild(tr);
  12352. table.style.tableLayout = 'auto';
  12353. table.style.width = 'auto';
  12354. }
  12355. table.appendChild(tHead);
  12356. if (this.isVertical()) {
  12357. tBody.appendChild(tr);
  12358. }
  12359. table.appendChild(tBody);
  12360. (0, _element.addClass)(table, className);
  12361. fragment.appendChild(table);
  12362. return { fragment: fragment, table: table, tHead: tHead, tBody: tBody, colGroup: colGroup, tr: tr, th: th };
  12363. }
  12364. /**
  12365. * Create container for tables.
  12366. *
  12367. * @param {String} className
  12368. * @returns {Object}
  12369. */
  12370. }, {
  12371. key: 'createContainer',
  12372. value: function createContainer() {
  12373. var className = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  12374. var d = document;
  12375. var fragment = d.createDocumentFragment();
  12376. var container = d.createElement('div');
  12377. className = 'htGhostTable htAutoSize ' + className.trim();
  12378. (0, _element.addClass)(container, className);
  12379. fragment.appendChild(container);
  12380. return { fragment: fragment, container: container };
  12381. }
  12382. /**
  12383. * Checks if table is raised vertically (checking rows).
  12384. *
  12385. * @returns {Boolean}
  12386. */
  12387. }, {
  12388. key: 'isVertical',
  12389. value: function isVertical() {
  12390. return !!(this.rows.length && !this.columns.length);
  12391. }
  12392. /**
  12393. * Checks if table is raised horizontally (checking columns).
  12394. *
  12395. * @returns {Boolean}
  12396. */
  12397. }, {
  12398. key: 'isHorizontal',
  12399. value: function isHorizontal() {
  12400. return !!(this.columns.length && !this.rows.length);
  12401. }
  12402. }]);
  12403. return GhostTable;
  12404. }();
  12405. exports.default = GhostTable;
  12406. /***/ }),
  12407. /* 93 */
  12408. /***/ (function(module, exports, __webpack_require__) {
  12409. "use strict";
  12410. exports.__esModule = true;
  12411. exports.default = separatorItem;
  12412. var KEY = exports.KEY = '---------';
  12413. function separatorItem() {
  12414. return {
  12415. name: KEY
  12416. };
  12417. }
  12418. /***/ }),
  12419. /* 94 */
  12420. /***/ (function(module, exports, __webpack_require__) {
  12421. "use strict";
  12422. exports.__esModule = true;
  12423. 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;
  12424. var _predefinedItems2;
  12425. var _alignment = __webpack_require__(300);
  12426. Object.defineProperty(exports, 'ALIGNMENT', {
  12427. enumerable: true,
  12428. get: function get() {
  12429. return _alignment.KEY;
  12430. }
  12431. });
  12432. var _clearColumn = __webpack_require__(301);
  12433. Object.defineProperty(exports, 'CLEAR_COLUMN', {
  12434. enumerable: true,
  12435. get: function get() {
  12436. return _clearColumn.KEY;
  12437. }
  12438. });
  12439. var _columnLeft = __webpack_require__(302);
  12440. Object.defineProperty(exports, 'COLUMN_LEFT', {
  12441. enumerable: true,
  12442. get: function get() {
  12443. return _columnLeft.KEY;
  12444. }
  12445. });
  12446. var _columnRight = __webpack_require__(303);
  12447. Object.defineProperty(exports, 'COLUMN_RIGHT', {
  12448. enumerable: true,
  12449. get: function get() {
  12450. return _columnRight.KEY;
  12451. }
  12452. });
  12453. var _readOnly = __webpack_require__(304);
  12454. Object.defineProperty(exports, 'READ_ONLY', {
  12455. enumerable: true,
  12456. get: function get() {
  12457. return _readOnly.KEY;
  12458. }
  12459. });
  12460. var _redo = __webpack_require__(305);
  12461. Object.defineProperty(exports, 'REDO', {
  12462. enumerable: true,
  12463. get: function get() {
  12464. return _redo.KEY;
  12465. }
  12466. });
  12467. var _removeColumn = __webpack_require__(306);
  12468. Object.defineProperty(exports, 'REMOVE_COLUMN', {
  12469. enumerable: true,
  12470. get: function get() {
  12471. return _removeColumn.KEY;
  12472. }
  12473. });
  12474. var _removeRow = __webpack_require__(307);
  12475. Object.defineProperty(exports, 'REMOVE_ROW', {
  12476. enumerable: true,
  12477. get: function get() {
  12478. return _removeRow.KEY;
  12479. }
  12480. });
  12481. var _rowAbove = __webpack_require__(308);
  12482. Object.defineProperty(exports, 'ROW_ABOVE', {
  12483. enumerable: true,
  12484. get: function get() {
  12485. return _rowAbove.KEY;
  12486. }
  12487. });
  12488. var _rowBelow = __webpack_require__(309);
  12489. Object.defineProperty(exports, 'ROW_BELOW', {
  12490. enumerable: true,
  12491. get: function get() {
  12492. return _rowBelow.KEY;
  12493. }
  12494. });
  12495. var _separator = __webpack_require__(93);
  12496. Object.defineProperty(exports, 'SEPARATOR', {
  12497. enumerable: true,
  12498. get: function get() {
  12499. return _separator.KEY;
  12500. }
  12501. });
  12502. var _undo = __webpack_require__(310);
  12503. Object.defineProperty(exports, 'UNDO', {
  12504. enumerable: true,
  12505. get: function get() {
  12506. return _undo.KEY;
  12507. }
  12508. });
  12509. exports.predefinedItems = predefinedItems;
  12510. exports.addItem = addItem;
  12511. var _object = __webpack_require__(2);
  12512. var _alignment2 = _interopRequireDefault(_alignment);
  12513. var _clearColumn2 = _interopRequireDefault(_clearColumn);
  12514. var _columnLeft2 = _interopRequireDefault(_columnLeft);
  12515. var _columnRight2 = _interopRequireDefault(_columnRight);
  12516. var _readOnly2 = _interopRequireDefault(_readOnly);
  12517. var _redo2 = _interopRequireDefault(_redo);
  12518. var _removeColumn2 = _interopRequireDefault(_removeColumn);
  12519. var _removeRow2 = _interopRequireDefault(_removeRow);
  12520. var _rowAbove2 = _interopRequireDefault(_rowAbove);
  12521. var _rowBelow2 = _interopRequireDefault(_rowBelow);
  12522. var _separator2 = _interopRequireDefault(_separator);
  12523. var _undo2 = _interopRequireDefault(_undo);
  12524. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12525. 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; }
  12526. 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];
  12527. 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);
  12528. /**
  12529. * Gets new object with all predefined menu items.
  12530. *
  12531. * @returns {Object}
  12532. */
  12533. function predefinedItems() {
  12534. var items = {};
  12535. (0, _object.objectEach)(_predefinedItems, function (itemFactory, key) {
  12536. items[key] = itemFactory();
  12537. });
  12538. return items;
  12539. }
  12540. /**
  12541. * Add new predefined menu item to the collection.
  12542. *
  12543. * @param {String} key Menu command id.
  12544. * @param {Object} item Object command descriptor.
  12545. */
  12546. function addItem(key, item) {
  12547. if (ITEMS.indexOf(key) === -1) {
  12548. _predefinedItems[key] = item;
  12549. }
  12550. }
  12551. /***/ }),
  12552. /* 95 */
  12553. /***/ (function(module, exports, __webpack_require__) {
  12554. "use strict";
  12555. exports.__esModule = true;
  12556. 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; }; }();
  12557. 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.']),
  12558. _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.']),
  12559. _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.']),
  12560. _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.']);
  12561. var _index = __webpack_require__(4);
  12562. var _templateLiteralTag = __webpack_require__(41);
  12563. function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
  12564. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12565. /**
  12566. * The `MergedCellCoords` class represents a single merged cell.
  12567. *
  12568. * @class MergedCellCoords
  12569. * @plugin MergeCells
  12570. */
  12571. var MergedCellCoords = function () {
  12572. function MergedCellCoords(row, column, rowspan, colspan) {
  12573. _classCallCheck(this, MergedCellCoords);
  12574. /**
  12575. * The index of the topmost merged cell row.
  12576. *
  12577. * @type {Number}
  12578. */
  12579. this.row = row;
  12580. /**
  12581. * The index of the leftmost column.
  12582. *
  12583. * @type {Number}
  12584. */
  12585. this.col = column;
  12586. /**
  12587. * The `rowspan` value of the merged cell.
  12588. *
  12589. * @type {Number}
  12590. */
  12591. this.rowspan = rowspan;
  12592. /**
  12593. * The `colspan` value of the merged cell.
  12594. *
  12595. * @type {Number}
  12596. */
  12597. this.colspan = colspan;
  12598. /**
  12599. * `true` only if the merged cell is bound to be removed.
  12600. *
  12601. * @type {Boolean}
  12602. */
  12603. this.removed = false;
  12604. }
  12605. /**
  12606. * Get a warning message for when the declared merged cell data contains negative values.
  12607. *
  12608. * @param {Object} newMergedCell Object containg information about the merged cells that was about to be added.
  12609. * @return {String}
  12610. */
  12611. _createClass(MergedCellCoords, [{
  12612. key: 'normalize',
  12613. /**
  12614. * Sanitize (prevent from going outside the boundaries) the merged cell.
  12615. *
  12616. * @param hotInstance
  12617. */
  12618. value: function normalize(hotInstance) {
  12619. var totalRows = hotInstance.countRows();
  12620. var totalColumns = hotInstance.countCols();
  12621. if (this.row < 0) {
  12622. this.row = 0;
  12623. } else if (this.row > totalRows - 1) {
  12624. this.row = totalRows - 1;
  12625. }
  12626. if (this.col < 0) {
  12627. this.col = 0;
  12628. } else if (this.col > totalColumns - 1) {
  12629. this.col = totalColumns - 1;
  12630. }
  12631. if (this.row + this.rowspan > totalRows - 1) {
  12632. this.rowspan = totalRows - this.row;
  12633. }
  12634. if (this.col + this.colspan > totalColumns - 1) {
  12635. this.colspan = totalColumns - this.col;
  12636. }
  12637. }
  12638. /**
  12639. * Returns `true` if the provided coordinates are inside the merged cell.
  12640. *
  12641. * @param {Number} row The row index.
  12642. * @param {Number} column The column index.
  12643. * @return {Boolean}
  12644. */
  12645. }, {
  12646. key: 'includes',
  12647. value: function includes(row, column) {
  12648. return this.row <= row && this.col <= column && this.row + this.rowspan - 1 >= row && this.col + this.colspan - 1 >= column;
  12649. }
  12650. /**
  12651. * Returns `true` if the provided `column` property is within the column span of the merged cell.
  12652. *
  12653. * @param {Number} column The column index.
  12654. * @return {Boolean}
  12655. */
  12656. }, {
  12657. key: 'includesHorizontally',
  12658. value: function includesHorizontally(column) {
  12659. return this.col <= column && this.col + this.colspan - 1 >= column;
  12660. }
  12661. /**
  12662. * Returns `true` if the provided `row` property is within the row span of the merged cell.
  12663. *
  12664. * @param {Number} row Row index.
  12665. * @return {Boolean}
  12666. */
  12667. }, {
  12668. key: 'includesVertically',
  12669. value: function includesVertically(row) {
  12670. return this.row <= row && this.row + this.rowspan - 1 >= row;
  12671. }
  12672. /**
  12673. * Shift (and possibly resize, if needed) the merged cell.
  12674. *
  12675. * @param {Array} shiftVector 2-element array containing the information on the shifting in the `x` and `y` axis.
  12676. * @param {Number} indexOfChange Index of the preceding change.
  12677. * @returns {Boolean} Returns `false` if the whole merged cell was removed.
  12678. */
  12679. }, {
  12680. key: 'shift',
  12681. value: function shift(shiftVector, indexOfChange) {
  12682. var shiftValue = shiftVector[0] || shiftVector[1];
  12683. var shiftedIndex = indexOfChange + Math.abs(shiftVector[0] || shiftVector[1]) - 1;
  12684. var span = shiftVector[0] ? 'colspan' : 'rowspan';
  12685. var index = shiftVector[0] ? 'col' : 'row';
  12686. var changeStart = Math.min(indexOfChange, shiftedIndex);
  12687. var changeEnd = Math.max(indexOfChange, shiftedIndex);
  12688. var mergeStart = this[index];
  12689. var mergeEnd = this[index] + this[span] - 1;
  12690. if (mergeStart >= indexOfChange) {
  12691. this[index] += shiftValue;
  12692. }
  12693. // adding rows/columns
  12694. if (shiftValue > 0) {
  12695. if (indexOfChange <= mergeEnd && indexOfChange > mergeStart) {
  12696. this[span] += shiftValue;
  12697. }
  12698. // removing rows/columns
  12699. } else if (shiftValue < 0) {
  12700. // removing the whole merge
  12701. if (changeStart <= mergeStart && changeEnd >= mergeEnd) {
  12702. this.removed = true;
  12703. return false;
  12704. // removing the merge partially, including the beginning
  12705. } else if (mergeStart >= changeStart && mergeStart <= changeEnd) {
  12706. var removedOffset = changeEnd - mergeStart + 1;
  12707. var preRemovedOffset = Math.abs(shiftValue) - removedOffset;
  12708. this[index] -= preRemovedOffset + shiftValue;
  12709. this[span] -= removedOffset;
  12710. // removing the middle part of the merge
  12711. } else if (mergeStart <= changeStart && mergeEnd >= changeEnd) {
  12712. this[span] += shiftValue;
  12713. // removing the end part of the merge
  12714. } else if (mergeStart <= changeStart && mergeEnd >= changeStart && mergeEnd < changeEnd) {
  12715. var removedPart = mergeEnd - changeStart + 1;
  12716. this[span] -= removedPart;
  12717. }
  12718. }
  12719. return true;
  12720. }
  12721. /**
  12722. * Check if the second provided merged cell is "farther" in the provided direction.
  12723. *
  12724. * @param {MergedCellCoords} mergedCell The merged cell to check.
  12725. * @param {String} direction Drag direction.
  12726. * @return {Boolean|null} `true` if the second provided merged cell is "farther".
  12727. */
  12728. }, {
  12729. key: 'isFarther',
  12730. value: function isFarther(mergedCell, direction) {
  12731. if (!mergedCell) {
  12732. return true;
  12733. }
  12734. if (direction === 'down') {
  12735. return mergedCell.row + mergedCell.rowspan - 1 < this.row + this.rowspan - 1;
  12736. } else if (direction === 'up') {
  12737. return mergedCell.row > this.row;
  12738. } else if (direction === 'right') {
  12739. return mergedCell.col + mergedCell.colspan - 1 < this.col + this.colspan - 1;
  12740. } else if (direction === 'left') {
  12741. return mergedCell.col > this.col;
  12742. }
  12743. return null;
  12744. }
  12745. /**
  12746. * Get the bottom row index of the merged cell.
  12747. *
  12748. * @returns {Number}
  12749. */
  12750. }, {
  12751. key: 'getLastRow',
  12752. value: function getLastRow() {
  12753. return this.row + this.rowspan - 1;
  12754. }
  12755. /**
  12756. * Get the rightmost column index of the merged cell.
  12757. *
  12758. * @returns {Number}
  12759. */
  12760. }, {
  12761. key: 'getLastColumn',
  12762. value: function getLastColumn() {
  12763. return this.col + this.colspan - 1;
  12764. }
  12765. /**
  12766. * Get the range coordinates of the merged cell.
  12767. *
  12768. * @return {CellRange}
  12769. */
  12770. }, {
  12771. key: 'getRange',
  12772. value: function getRange() {
  12773. 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()));
  12774. }
  12775. }], [{
  12776. key: 'NEGATIVE_VALUES_WARNING',
  12777. value: function NEGATIVE_VALUES_WARNING(newMergedCell) {
  12778. return (0, _templateLiteralTag.toSingleLine)(_templateObject, newMergedCell.row, newMergedCell.col, newMergedCell.rowspan, newMergedCell.colspan);
  12779. }
  12780. /**
  12781. * Get a warning message for when the declared merged cell data contains values exceeding the table limits.
  12782. *
  12783. * @param {Object} newMergedCell Object containg information about the merged cells that was about to be added.
  12784. * @return {String}
  12785. */
  12786. }, {
  12787. key: 'IS_OUT_OF_BOUNDS_WARNING',
  12788. value: function IS_OUT_OF_BOUNDS_WARNING(newMergedCell) {
  12789. return (0, _templateLiteralTag.toSingleLine)(_templateObject2, newMergedCell.row, newMergedCell.col);
  12790. }
  12791. /**
  12792. * Get a warning message for when the declared merged cell data represents a single cell.
  12793. *
  12794. * @param {Object} newMergedCell Object containg information about the merged cells that was about to be added.
  12795. * @return {String}
  12796. */
  12797. }, {
  12798. key: 'IS_SINGLE_CELL',
  12799. value: function IS_SINGLE_CELL(newMergedCell) {
  12800. return (0, _templateLiteralTag.toSingleLine)(_templateObject3, newMergedCell.row, newMergedCell.col);
  12801. }
  12802. /**
  12803. * Get a warning message for when the declared merged cell data contains "colspan" or "rowspan", that equals 0.
  12804. *
  12805. * @param {Object} newMergedCell Object containg information about the merged cells that was about to be added.
  12806. * @return {String}
  12807. */
  12808. }, {
  12809. key: 'ZERO_SPAN_WARNING',
  12810. value: function ZERO_SPAN_WARNING(newMergedCell) {
  12811. return (0, _templateLiteralTag.toSingleLine)(_templateObject4, newMergedCell.row, newMergedCell.col);
  12812. }
  12813. /**
  12814. * Check whether the values provided for a merged cell contain any negative values.
  12815. *
  12816. * @param {Object} mergedCellInfo Object containing the `row`, `col`, `rowspan` and `colspan` properties.
  12817. * @return {Boolean}
  12818. */
  12819. }, {
  12820. key: 'containsNegativeValues',
  12821. value: function containsNegativeValues(mergedCellInfo) {
  12822. return mergedCellInfo.row < 0 || mergedCellInfo.col < 0 || mergedCellInfo.rowspan < 0 || mergedCellInfo.colspan < 0;
  12823. }
  12824. /**
  12825. * Check whether the provided merged cell information object represents a single cell.
  12826. *
  12827. * @private
  12828. * @param {Object} mergedCellInfo An object with `row`, `col`, `rowspan` and `colspan` properties.
  12829. * @return {Boolean}
  12830. */
  12831. }, {
  12832. key: 'isSingleCell',
  12833. value: function isSingleCell(mergedCellInfo) {
  12834. return mergedCellInfo.colspan === 1 && mergedCellInfo.rowspan === 1;
  12835. }
  12836. /**
  12837. * Check whether the provided merged cell information object contains a rowspan or colspan of 0.
  12838. *
  12839. * @private
  12840. * @param {Object} mergedCellInfo An object with `row`, `col`, `rowspan` and `colspan` properties.
  12841. * @return {Boolean}
  12842. */
  12843. }, {
  12844. key: 'containsZeroSpan',
  12845. value: function containsZeroSpan(mergedCellInfo) {
  12846. return mergedCellInfo.colspan === 0 || mergedCellInfo.rowspan === 0;
  12847. }
  12848. /**
  12849. * Check whether the provided merged cell object is to be declared out of bounds of the table.
  12850. *
  12851. * @param {Object} mergeCell Object containing the `row`, `col`, `rowspan` and `colspan` properties.
  12852. * @param {Number} rowCount Number of rows in the table.
  12853. * @param {Number} columnCount Number of rows in the table.
  12854. * @return {Boolean}
  12855. */
  12856. }, {
  12857. key: 'isOutOfBounds',
  12858. value: function isOutOfBounds(mergeCell, rowCount, columnCount) {
  12859. 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;
  12860. }
  12861. }]);
  12862. return MergedCellCoords;
  12863. }();
  12864. exports.default = MergedCellCoords;
  12865. /***/ }),
  12866. /* 96 */
  12867. /***/ (function(module, exports, __webpack_require__) {
  12868. "use strict";
  12869. var strong = __webpack_require__(97);
  12870. var validate = __webpack_require__(45);
  12871. var MAP = 'Map';
  12872. // 23.1 Map Objects
  12873. module.exports = __webpack_require__(66)(MAP, function (get) {
  12874. return function Map() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
  12875. }, {
  12876. // 23.1.3.6 Map.prototype.get(key)
  12877. get: function get(key) {
  12878. var entry = strong.getEntry(validate(this, MAP), key);
  12879. return entry && entry.v;
  12880. },
  12881. // 23.1.3.9 Map.prototype.set(key, value)
  12882. set: function set(key, value) {
  12883. return strong.def(validate(this, MAP), key === 0 ? 0 : key, value);
  12884. }
  12885. }, strong, true);
  12886. /***/ }),
  12887. /* 97 */
  12888. /***/ (function(module, exports, __webpack_require__) {
  12889. "use strict";
  12890. var dP = __webpack_require__(20).f;
  12891. var create = __webpack_require__(74);
  12892. var redefineAll = __webpack_require__(61);
  12893. var ctx = __webpack_require__(32);
  12894. var anInstance = __webpack_require__(63);
  12895. var forOf = __webpack_require__(64);
  12896. var $iterDefine = __webpack_require__(106);
  12897. var step = __webpack_require__(108);
  12898. var setSpecies = __webpack_require__(109);
  12899. var DESCRIPTORS = __webpack_require__(22);
  12900. var fastKey = __webpack_require__(34).fastKey;
  12901. var validate = __webpack_require__(45);
  12902. var SIZE = DESCRIPTORS ? '_s' : 'size';
  12903. var getEntry = function (that, key) {
  12904. // fast case
  12905. var index = fastKey(key);
  12906. var entry;
  12907. if (index !== 'F') return that._i[index];
  12908. // frozen object case
  12909. for (entry = that._f; entry; entry = entry.n) {
  12910. if (entry.k == key) return entry;
  12911. }
  12912. };
  12913. module.exports = {
  12914. getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {
  12915. var C = wrapper(function (that, iterable) {
  12916. anInstance(that, C, NAME, '_i');
  12917. that._t = NAME; // collection type
  12918. that._i = create(null); // index
  12919. that._f = undefined; // first entry
  12920. that._l = undefined; // last entry
  12921. that[SIZE] = 0; // size
  12922. if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
  12923. });
  12924. redefineAll(C.prototype, {
  12925. // 23.1.3.1 Map.prototype.clear()
  12926. // 23.2.3.2 Set.prototype.clear()
  12927. clear: function clear() {
  12928. for (var that = validate(this, NAME), data = that._i, entry = that._f; entry; entry = entry.n) {
  12929. entry.r = true;
  12930. if (entry.p) entry.p = entry.p.n = undefined;
  12931. delete data[entry.i];
  12932. }
  12933. that._f = that._l = undefined;
  12934. that[SIZE] = 0;
  12935. },
  12936. // 23.1.3.3 Map.prototype.delete(key)
  12937. // 23.2.3.4 Set.prototype.delete(value)
  12938. 'delete': function (key) {
  12939. var that = validate(this, NAME);
  12940. var entry = getEntry(that, key);
  12941. if (entry) {
  12942. var next = entry.n;
  12943. var prev = entry.p;
  12944. delete that._i[entry.i];
  12945. entry.r = true;
  12946. if (prev) prev.n = next;
  12947. if (next) next.p = prev;
  12948. if (that._f == entry) that._f = next;
  12949. if (that._l == entry) that._l = prev;
  12950. that[SIZE]--;
  12951. } return !!entry;
  12952. },
  12953. // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
  12954. // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)
  12955. forEach: function forEach(callbackfn /* , that = undefined */) {
  12956. validate(this, NAME);
  12957. var f = ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);
  12958. var entry;
  12959. while (entry = entry ? entry.n : this._f) {
  12960. f(entry.v, entry.k, this);
  12961. // revert to the last existing entry
  12962. while (entry && entry.r) entry = entry.p;
  12963. }
  12964. },
  12965. // 23.1.3.7 Map.prototype.has(key)
  12966. // 23.2.3.7 Set.prototype.has(value)
  12967. has: function has(key) {
  12968. return !!getEntry(validate(this, NAME), key);
  12969. }
  12970. });
  12971. if (DESCRIPTORS) dP(C.prototype, 'size', {
  12972. get: function () {
  12973. return validate(this, NAME)[SIZE];
  12974. }
  12975. });
  12976. return C;
  12977. },
  12978. def: function (that, key, value) {
  12979. var entry = getEntry(that, key);
  12980. var prev, index;
  12981. // change existing entry
  12982. if (entry) {
  12983. entry.v = value;
  12984. // create new entry
  12985. } else {
  12986. that._l = entry = {
  12987. i: index = fastKey(key, true), // <- index
  12988. k: key, // <- key
  12989. v: value, // <- value
  12990. p: prev = that._l, // <- previous entry
  12991. n: undefined, // <- next entry
  12992. r: false // <- removed
  12993. };
  12994. if (!that._f) that._f = entry;
  12995. if (prev) prev.n = entry;
  12996. that[SIZE]++;
  12997. // add to index
  12998. if (index !== 'F') that._i[index] = entry;
  12999. } return that;
  13000. },
  13001. getEntry: getEntry,
  13002. setStrong: function (C, NAME, IS_MAP) {
  13003. // add .keys, .values, .entries, [@@iterator]
  13004. // 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
  13005. $iterDefine(C, NAME, function (iterated, kind) {
  13006. this._t = validate(iterated, NAME); // target
  13007. this._k = kind; // kind
  13008. this._l = undefined; // previous
  13009. }, function () {
  13010. var that = this;
  13011. var kind = that._k;
  13012. var entry = that._l;
  13013. // revert to the last existing entry
  13014. while (entry && entry.r) entry = entry.p;
  13015. // get next entry
  13016. if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) {
  13017. // or finish the iteration
  13018. that._t = undefined;
  13019. return step(1);
  13020. }
  13021. // return step by kind
  13022. if (kind == 'keys') return step(0, entry.k);
  13023. if (kind == 'values') return step(0, entry.v);
  13024. return step(0, [entry.k, entry.v]);
  13025. }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
  13026. // add [@@species], 23.1.2.2, 23.2.2.2
  13027. setSpecies(NAME);
  13028. }
  13029. };
  13030. /***/ }),
  13031. /* 98 */
  13032. /***/ (function(module, exports, __webpack_require__) {
  13033. module.exports = !__webpack_require__(22) && !__webpack_require__(23)(function () {
  13034. return Object.defineProperty(__webpack_require__(72)('div'), 'a', { get: function () { return 7; } }).a != 7;
  13035. });
  13036. /***/ }),
  13037. /* 99 */
  13038. /***/ (function(module, exports, __webpack_require__) {
  13039. var has = __webpack_require__(29);
  13040. var toIObject = __webpack_require__(24);
  13041. var arrayIndexOf = __webpack_require__(100)(false);
  13042. var IE_PROTO = __webpack_require__(76)('IE_PROTO');
  13043. module.exports = function (object, names) {
  13044. var O = toIObject(object);
  13045. var i = 0;
  13046. var result = [];
  13047. var key;
  13048. for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key);
  13049. // Don't enum bug & hidden keys
  13050. while (names.length > i) if (has(O, key = names[i++])) {
  13051. ~arrayIndexOf(result, key) || result.push(key);
  13052. }
  13053. return result;
  13054. };
  13055. /***/ }),
  13056. /* 100 */
  13057. /***/ (function(module, exports, __webpack_require__) {
  13058. // false -> Array#indexOf
  13059. // true -> Array#includes
  13060. var toIObject = __webpack_require__(24);
  13061. var toLength = __webpack_require__(25);
  13062. var toAbsoluteIndex = __webpack_require__(60);
  13063. module.exports = function (IS_INCLUDES) {
  13064. return function ($this, el, fromIndex) {
  13065. var O = toIObject($this);
  13066. var length = toLength(O.length);
  13067. var index = toAbsoluteIndex(fromIndex, length);
  13068. var value;
  13069. // Array#includes uses SameValueZero equality algorithm
  13070. // eslint-disable-next-line no-self-compare
  13071. if (IS_INCLUDES && el != el) while (length > index) {
  13072. value = O[index++];
  13073. // eslint-disable-next-line no-self-compare
  13074. if (value != value) return true;
  13075. // Array#indexOf ignores holes, Array#includes - not
  13076. } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
  13077. if (O[index] === el) return IS_INCLUDES || index || 0;
  13078. } return !IS_INCLUDES && -1;
  13079. };
  13080. };
  13081. /***/ }),
  13082. /* 101 */
  13083. /***/ (function(module, exports, __webpack_require__) {
  13084. var document = __webpack_require__(14).document;
  13085. module.exports = document && document.documentElement;
  13086. /***/ }),
  13087. /* 102 */
  13088. /***/ (function(module, exports, __webpack_require__) {
  13089. // call something on iterator step with safe closing on error
  13090. var anObject = __webpack_require__(18);
  13091. module.exports = function (iterator, fn, value, entries) {
  13092. try {
  13093. return entries ? fn(anObject(value)[0], value[1]) : fn(value);
  13094. // 7.4.6 IteratorClose(iterator, completion)
  13095. } catch (e) {
  13096. var ret = iterator['return'];
  13097. if (ret !== undefined) anObject(ret.call(iterator));
  13098. throw e;
  13099. }
  13100. };
  13101. /***/ }),
  13102. /* 103 */
  13103. /***/ (function(module, exports, __webpack_require__) {
  13104. // check on default Array iterator
  13105. var Iterators = __webpack_require__(50);
  13106. var ITERATOR = __webpack_require__(11)('iterator');
  13107. var ArrayProto = Array.prototype;
  13108. module.exports = function (it) {
  13109. return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
  13110. };
  13111. /***/ }),
  13112. /* 104 */
  13113. /***/ (function(module, exports, __webpack_require__) {
  13114. var classof = __webpack_require__(105);
  13115. var ITERATOR = __webpack_require__(11)('iterator');
  13116. var Iterators = __webpack_require__(50);
  13117. module.exports = __webpack_require__(44).getIteratorMethod = function (it) {
  13118. if (it != undefined) return it[ITERATOR]
  13119. || it['@@iterator']
  13120. || Iterators[classof(it)];
  13121. };
  13122. /***/ }),
  13123. /* 105 */
  13124. /***/ (function(module, exports, __webpack_require__) {
  13125. // getting tag from 19.1.3.6 Object.prototype.toString()
  13126. var cof = __webpack_require__(43);
  13127. var TAG = __webpack_require__(11)('toStringTag');
  13128. // ES3 wrong here
  13129. var ARG = cof(function () { return arguments; }()) == 'Arguments';
  13130. // fallback for IE11 Script Access Denied error
  13131. var tryGet = function (it, key) {
  13132. try {
  13133. return it[key];
  13134. } catch (e) { /* empty */ }
  13135. };
  13136. module.exports = function (it) {
  13137. var O, T, B;
  13138. return it === undefined ? 'Undefined' : it === null ? 'Null'
  13139. // @@toStringTag case
  13140. : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
  13141. // builtinTag case
  13142. : ARG ? cof(O)
  13143. // ES3 arguments fallback
  13144. : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
  13145. };
  13146. /***/ }),
  13147. /* 106 */
  13148. /***/ (function(module, exports, __webpack_require__) {
  13149. "use strict";
  13150. var LIBRARY = __webpack_require__(65);
  13151. var $export = __webpack_require__(3);
  13152. var redefine = __webpack_require__(30);
  13153. var hide = __webpack_require__(31);
  13154. var Iterators = __webpack_require__(50);
  13155. var $iterCreate = __webpack_require__(208);
  13156. var setToStringTag = __webpack_require__(51);
  13157. var getPrototypeOf = __webpack_require__(107);
  13158. var ITERATOR = __webpack_require__(11)('iterator');
  13159. var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
  13160. var FF_ITERATOR = '@@iterator';
  13161. var KEYS = 'keys';
  13162. var VALUES = 'values';
  13163. var returnThis = function () { return this; };
  13164. module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
  13165. $iterCreate(Constructor, NAME, next);
  13166. var getMethod = function (kind) {
  13167. if (!BUGGY && kind in proto) return proto[kind];
  13168. switch (kind) {
  13169. case KEYS: return function keys() { return new Constructor(this, kind); };
  13170. case VALUES: return function values() { return new Constructor(this, kind); };
  13171. } return function entries() { return new Constructor(this, kind); };
  13172. };
  13173. var TAG = NAME + ' Iterator';
  13174. var DEF_VALUES = DEFAULT == VALUES;
  13175. var VALUES_BUG = false;
  13176. var proto = Base.prototype;
  13177. var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
  13178. var $default = $native || getMethod(DEFAULT);
  13179. var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
  13180. var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
  13181. var methods, key, IteratorPrototype;
  13182. // Fix native
  13183. if ($anyNative) {
  13184. IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
  13185. if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
  13186. // Set @@toStringTag to native iterators
  13187. setToStringTag(IteratorPrototype, TAG, true);
  13188. // fix for some old engines
  13189. if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis);
  13190. }
  13191. }
  13192. // fix Array#{values, @@iterator}.name in V8 / FF
  13193. if (DEF_VALUES && $native && $native.name !== VALUES) {
  13194. VALUES_BUG = true;
  13195. $default = function values() { return $native.call(this); };
  13196. }
  13197. // Define iterator
  13198. if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
  13199. hide(proto, ITERATOR, $default);
  13200. }
  13201. // Plug for library
  13202. Iterators[NAME] = $default;
  13203. Iterators[TAG] = returnThis;
  13204. if (DEFAULT) {
  13205. methods = {
  13206. values: DEF_VALUES ? $default : getMethod(VALUES),
  13207. keys: IS_SET ? $default : getMethod(KEYS),
  13208. entries: $entries
  13209. };
  13210. if (FORCED) for (key in methods) {
  13211. if (!(key in proto)) redefine(proto, key, methods[key]);
  13212. } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
  13213. }
  13214. return methods;
  13215. };
  13216. /***/ }),
  13217. /* 107 */
  13218. /***/ (function(module, exports, __webpack_require__) {
  13219. // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
  13220. var has = __webpack_require__(29);
  13221. var toObject = __webpack_require__(33);
  13222. var IE_PROTO = __webpack_require__(76)('IE_PROTO');
  13223. var ObjectProto = Object.prototype;
  13224. module.exports = Object.getPrototypeOf || function (O) {
  13225. O = toObject(O);
  13226. if (has(O, IE_PROTO)) return O[IE_PROTO];
  13227. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  13228. return O.constructor.prototype;
  13229. } return O instanceof Object ? ObjectProto : null;
  13230. };
  13231. /***/ }),
  13232. /* 108 */
  13233. /***/ (function(module, exports) {
  13234. module.exports = function (done, value) {
  13235. return { value: value, done: !!done };
  13236. };
  13237. /***/ }),
  13238. /* 109 */
  13239. /***/ (function(module, exports, __webpack_require__) {
  13240. "use strict";
  13241. var global = __webpack_require__(14);
  13242. var dP = __webpack_require__(20);
  13243. var DESCRIPTORS = __webpack_require__(22);
  13244. var SPECIES = __webpack_require__(11)('species');
  13245. module.exports = function (KEY) {
  13246. var C = global[KEY];
  13247. if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, {
  13248. configurable: true,
  13249. get: function () { return this; }
  13250. });
  13251. };
  13252. /***/ }),
  13253. /* 110 */
  13254. /***/ (function(module, exports, __webpack_require__) {
  13255. // Works with __proto__ only. Old v8 can't work with null proto objects.
  13256. /* eslint-disable no-proto */
  13257. var isObject = __webpack_require__(9);
  13258. var anObject = __webpack_require__(18);
  13259. var check = function (O, proto) {
  13260. anObject(O);
  13261. if (!isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!");
  13262. };
  13263. module.exports = {
  13264. set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line
  13265. function (test, buggy, set) {
  13266. try {
  13267. set = __webpack_require__(32)(Function.call, __webpack_require__(67).f(Object.prototype, '__proto__').set, 2);
  13268. set(test, []);
  13269. buggy = !(test instanceof Array);
  13270. } catch (e) { buggy = true; }
  13271. return function setPrototypeOf(O, proto) {
  13272. check(O, proto);
  13273. if (buggy) O.__proto__ = proto;
  13274. else set(O, proto);
  13275. return O;
  13276. };
  13277. }({}, false) : undefined),
  13278. check: check
  13279. };
  13280. /***/ }),
  13281. /* 111 */
  13282. /***/ (function(module, exports, __webpack_require__) {
  13283. "use strict";
  13284. var strong = __webpack_require__(97);
  13285. var validate = __webpack_require__(45);
  13286. var SET = 'Set';
  13287. // 23.2 Set Objects
  13288. module.exports = __webpack_require__(66)(SET, function (get) {
  13289. return function Set() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
  13290. }, {
  13291. // 23.2.3.1 Set.prototype.add(value)
  13292. add: function add(value) {
  13293. return strong.def(validate(this, SET), value = value === 0 ? 0 : value, value);
  13294. }
  13295. }, strong);
  13296. /***/ }),
  13297. /* 112 */
  13298. /***/ (function(module, exports, __webpack_require__) {
  13299. "use strict";
  13300. var each = __webpack_require__(68)(0);
  13301. var redefine = __webpack_require__(30);
  13302. var meta = __webpack_require__(34);
  13303. var assign = __webpack_require__(114);
  13304. var weak = __webpack_require__(115);
  13305. var isObject = __webpack_require__(9);
  13306. var fails = __webpack_require__(23);
  13307. var validate = __webpack_require__(45);
  13308. var WEAK_MAP = 'WeakMap';
  13309. var getWeak = meta.getWeak;
  13310. var isExtensible = Object.isExtensible;
  13311. var uncaughtFrozenStore = weak.ufstore;
  13312. var tmp = {};
  13313. var InternalMap;
  13314. var wrapper = function (get) {
  13315. return function WeakMap() {
  13316. return get(this, arguments.length > 0 ? arguments[0] : undefined);
  13317. };
  13318. };
  13319. var methods = {
  13320. // 23.3.3.3 WeakMap.prototype.get(key)
  13321. get: function get(key) {
  13322. if (isObject(key)) {
  13323. var data = getWeak(key);
  13324. if (data === true) return uncaughtFrozenStore(validate(this, WEAK_MAP)).get(key);
  13325. return data ? data[this._i] : undefined;
  13326. }
  13327. },
  13328. // 23.3.3.5 WeakMap.prototype.set(key, value)
  13329. set: function set(key, value) {
  13330. return weak.def(validate(this, WEAK_MAP), key, value);
  13331. }
  13332. };
  13333. // 23.3 WeakMap Objects
  13334. var $WeakMap = module.exports = __webpack_require__(66)(WEAK_MAP, wrapper, methods, weak, true, true);
  13335. // IE11 WeakMap frozen keys fix
  13336. if (fails(function () { return new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7; })) {
  13337. InternalMap = weak.getConstructor(wrapper, WEAK_MAP);
  13338. assign(InternalMap.prototype, methods);
  13339. meta.NEED = true;
  13340. each(['delete', 'has', 'get', 'set'], function (key) {
  13341. var proto = $WeakMap.prototype;
  13342. var method = proto[key];
  13343. redefine(proto, key, function (a, b) {
  13344. // store frozen objects on internal weakmap shim
  13345. if (isObject(a) && !isExtensible(a)) {
  13346. if (!this._f) this._f = new InternalMap();
  13347. var result = this._f[key](a, b);
  13348. return key == 'set' ? this : result;
  13349. // store all the rest on native weakmap
  13350. } return method.call(this, a, b);
  13351. });
  13352. });
  13353. }
  13354. /***/ }),
  13355. /* 113 */
  13356. /***/ (function(module, exports, __webpack_require__) {
  13357. // 7.2.2 IsArray(argument)
  13358. var cof = __webpack_require__(43);
  13359. module.exports = Array.isArray || function isArray(arg) {
  13360. return cof(arg) == 'Array';
  13361. };
  13362. /***/ }),
  13363. /* 114 */
  13364. /***/ (function(module, exports, __webpack_require__) {
  13365. "use strict";
  13366. // 19.1.2.1 Object.assign(target, source, ...)
  13367. var getKeys = __webpack_require__(37);
  13368. var gOPS = __webpack_require__(69);
  13369. var pIE = __webpack_require__(52);
  13370. var toObject = __webpack_require__(33);
  13371. var IObject = __webpack_require__(75);
  13372. var $assign = Object.assign;
  13373. // should work with symbols and should have deterministic property order (V8 bug)
  13374. module.exports = !$assign || __webpack_require__(23)(function () {
  13375. var A = {};
  13376. var B = {};
  13377. // eslint-disable-next-line no-undef
  13378. var S = Symbol();
  13379. var K = 'abcdefghijklmnopqrst';
  13380. A[S] = 7;
  13381. K.split('').forEach(function (k) { B[k] = k; });
  13382. return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
  13383. }) ? function assign(target, source) { // eslint-disable-line no-unused-vars
  13384. var T = toObject(target);
  13385. var aLen = arguments.length;
  13386. var index = 1;
  13387. var getSymbols = gOPS.f;
  13388. var isEnum = pIE.f;
  13389. while (aLen > index) {
  13390. var S = IObject(arguments[index++]);
  13391. var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);
  13392. var length = keys.length;
  13393. var j = 0;
  13394. var key;
  13395. while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
  13396. } return T;
  13397. } : $assign;
  13398. /***/ }),
  13399. /* 115 */
  13400. /***/ (function(module, exports, __webpack_require__) {
  13401. "use strict";
  13402. var redefineAll = __webpack_require__(61);
  13403. var getWeak = __webpack_require__(34).getWeak;
  13404. var anObject = __webpack_require__(18);
  13405. var isObject = __webpack_require__(9);
  13406. var anInstance = __webpack_require__(63);
  13407. var forOf = __webpack_require__(64);
  13408. var createArrayMethod = __webpack_require__(68);
  13409. var $has = __webpack_require__(29);
  13410. var validate = __webpack_require__(45);
  13411. var arrayFind = createArrayMethod(5);
  13412. var arrayFindIndex = createArrayMethod(6);
  13413. var id = 0;
  13414. // fallback for uncaught frozen keys
  13415. var uncaughtFrozenStore = function (that) {
  13416. return that._l || (that._l = new UncaughtFrozenStore());
  13417. };
  13418. var UncaughtFrozenStore = function () {
  13419. this.a = [];
  13420. };
  13421. var findUncaughtFrozen = function (store, key) {
  13422. return arrayFind(store.a, function (it) {
  13423. return it[0] === key;
  13424. });
  13425. };
  13426. UncaughtFrozenStore.prototype = {
  13427. get: function (key) {
  13428. var entry = findUncaughtFrozen(this, key);
  13429. if (entry) return entry[1];
  13430. },
  13431. has: function (key) {
  13432. return !!findUncaughtFrozen(this, key);
  13433. },
  13434. set: function (key, value) {
  13435. var entry = findUncaughtFrozen(this, key);
  13436. if (entry) entry[1] = value;
  13437. else this.a.push([key, value]);
  13438. },
  13439. 'delete': function (key) {
  13440. var index = arrayFindIndex(this.a, function (it) {
  13441. return it[0] === key;
  13442. });
  13443. if (~index) this.a.splice(index, 1);
  13444. return !!~index;
  13445. }
  13446. };
  13447. module.exports = {
  13448. getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {
  13449. var C = wrapper(function (that, iterable) {
  13450. anInstance(that, C, NAME, '_i');
  13451. that._t = NAME; // collection type
  13452. that._i = id++; // collection id
  13453. that._l = undefined; // leak store for uncaught frozen objects
  13454. if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
  13455. });
  13456. redefineAll(C.prototype, {
  13457. // 23.3.3.2 WeakMap.prototype.delete(key)
  13458. // 23.4.3.3 WeakSet.prototype.delete(value)
  13459. 'delete': function (key) {
  13460. if (!isObject(key)) return false;
  13461. var data = getWeak(key);
  13462. if (data === true) return uncaughtFrozenStore(validate(this, NAME))['delete'](key);
  13463. return data && $has(data, this._i) && delete data[this._i];
  13464. },
  13465. // 23.3.3.4 WeakMap.prototype.has(key)
  13466. // 23.4.3.4 WeakSet.prototype.has(value)
  13467. has: function has(key) {
  13468. if (!isObject(key)) return false;
  13469. var data = getWeak(key);
  13470. if (data === true) return uncaughtFrozenStore(validate(this, NAME)).has(key);
  13471. return data && $has(data, this._i);
  13472. }
  13473. });
  13474. return C;
  13475. },
  13476. def: function (that, key, value) {
  13477. var data = getWeak(anObject(key), true);
  13478. if (data === true) uncaughtFrozenStore(that).set(key, value);
  13479. else data[that._i] = value;
  13480. return that;
  13481. },
  13482. ufstore: uncaughtFrozenStore
  13483. };
  13484. /***/ }),
  13485. /* 116 */
  13486. /***/ (function(module, exports, __webpack_require__) {
  13487. "use strict";
  13488. var weak = __webpack_require__(115);
  13489. var validate = __webpack_require__(45);
  13490. var WEAK_SET = 'WeakSet';
  13491. // 23.4 WeakSet Objects
  13492. __webpack_require__(66)(WEAK_SET, function (get) {
  13493. return function WeakSet() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
  13494. }, {
  13495. // 23.4.3.1 WeakSet.prototype.add(value)
  13496. add: function add(value) {
  13497. return weak.def(validate(this, WEAK_SET), value, true);
  13498. }
  13499. }, weak, false, true);
  13500. /***/ }),
  13501. /* 117 */
  13502. /***/ (function(module, exports, __webpack_require__) {
  13503. "use strict";
  13504. var LIBRARY = __webpack_require__(65);
  13505. var global = __webpack_require__(14);
  13506. var ctx = __webpack_require__(32);
  13507. var classof = __webpack_require__(105);
  13508. var $export = __webpack_require__(3);
  13509. var isObject = __webpack_require__(9);
  13510. var aFunction = __webpack_require__(62);
  13511. var anInstance = __webpack_require__(63);
  13512. var forOf = __webpack_require__(64);
  13513. var speciesConstructor = __webpack_require__(212);
  13514. var task = __webpack_require__(80).set;
  13515. var microtask = __webpack_require__(214)();
  13516. var newPromiseCapabilityModule = __webpack_require__(118);
  13517. var perform = __webpack_require__(215);
  13518. var promiseResolve = __webpack_require__(216);
  13519. var PROMISE = 'Promise';
  13520. var TypeError = global.TypeError;
  13521. var process = global.process;
  13522. var $Promise = global[PROMISE];
  13523. var isNode = classof(process) == 'process';
  13524. var empty = function () { /* empty */ };
  13525. var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;
  13526. var newPromiseCapability = newGenericPromiseCapability = newPromiseCapabilityModule.f;
  13527. var USE_NATIVE = !!function () {
  13528. try {
  13529. // correct subclassing with @@species support
  13530. var promise = $Promise.resolve(1);
  13531. var FakePromise = (promise.constructor = {})[__webpack_require__(11)('species')] = function (exec) {
  13532. exec(empty, empty);
  13533. };
  13534. // unhandled rejections tracking support, NodeJS Promise without it fails @@species test
  13535. return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise;
  13536. } catch (e) { /* empty */ }
  13537. }();
  13538. // helpers
  13539. var isThenable = function (it) {
  13540. var then;
  13541. return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
  13542. };
  13543. var notify = function (promise, isReject) {
  13544. if (promise._n) return;
  13545. promise._n = true;
  13546. var chain = promise._c;
  13547. microtask(function () {
  13548. var value = promise._v;
  13549. var ok = promise._s == 1;
  13550. var i = 0;
  13551. var run = function (reaction) {
  13552. var handler = ok ? reaction.ok : reaction.fail;
  13553. var resolve = reaction.resolve;
  13554. var reject = reaction.reject;
  13555. var domain = reaction.domain;
  13556. var result, then, exited;
  13557. try {
  13558. if (handler) {
  13559. if (!ok) {
  13560. if (promise._h == 2) onHandleUnhandled(promise);
  13561. promise._h = 1;
  13562. }
  13563. if (handler === true) result = value;
  13564. else {
  13565. if (domain) domain.enter();
  13566. result = handler(value); // may throw
  13567. if (domain) {
  13568. domain.exit();
  13569. exited = true;
  13570. }
  13571. }
  13572. if (result === reaction.promise) {
  13573. reject(TypeError('Promise-chain cycle'));
  13574. } else if (then = isThenable(result)) {
  13575. then.call(result, resolve, reject);
  13576. } else resolve(result);
  13577. } else reject(value);
  13578. } catch (e) {
  13579. if (domain && !exited) domain.exit();
  13580. reject(e);
  13581. }
  13582. };
  13583. while (chain.length > i) run(chain[i++]); // variable length - can't use forEach
  13584. promise._c = [];
  13585. promise._n = false;
  13586. if (isReject && !promise._h) onUnhandled(promise);
  13587. });
  13588. };
  13589. var onUnhandled = function (promise) {
  13590. task.call(global, function () {
  13591. var value = promise._v;
  13592. var unhandled = isUnhandled(promise);
  13593. var result, handler, console;
  13594. if (unhandled) {
  13595. result = perform(function () {
  13596. if (isNode) {
  13597. process.emit('unhandledRejection', value, promise);
  13598. } else if (handler = global.onunhandledrejection) {
  13599. handler({ promise: promise, reason: value });
  13600. } else if ((console = global.console) && console.error) {
  13601. console.error('Unhandled promise rejection', value);
  13602. }
  13603. });
  13604. // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
  13605. promise._h = isNode || isUnhandled(promise) ? 2 : 1;
  13606. } promise._a = undefined;
  13607. if (unhandled && result.e) throw result.v;
  13608. });
  13609. };
  13610. var isUnhandled = function (promise) {
  13611. return promise._h !== 1 && (promise._a || promise._c).length === 0;
  13612. };
  13613. var onHandleUnhandled = function (promise) {
  13614. task.call(global, function () {
  13615. var handler;
  13616. if (isNode) {
  13617. process.emit('rejectionHandled', promise);
  13618. } else if (handler = global.onrejectionhandled) {
  13619. handler({ promise: promise, reason: promise._v });
  13620. }
  13621. });
  13622. };
  13623. var $reject = function (value) {
  13624. var promise = this;
  13625. if (promise._d) return;
  13626. promise._d = true;
  13627. promise = promise._w || promise; // unwrap
  13628. promise._v = value;
  13629. promise._s = 2;
  13630. if (!promise._a) promise._a = promise._c.slice();
  13631. notify(promise, true);
  13632. };
  13633. var $resolve = function (value) {
  13634. var promise = this;
  13635. var then;
  13636. if (promise._d) return;
  13637. promise._d = true;
  13638. promise = promise._w || promise; // unwrap
  13639. try {
  13640. if (promise === value) throw TypeError("Promise can't be resolved itself");
  13641. if (then = isThenable(value)) {
  13642. microtask(function () {
  13643. var wrapper = { _w: promise, _d: false }; // wrap
  13644. try {
  13645. then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
  13646. } catch (e) {
  13647. $reject.call(wrapper, e);
  13648. }
  13649. });
  13650. } else {
  13651. promise._v = value;
  13652. promise._s = 1;
  13653. notify(promise, false);
  13654. }
  13655. } catch (e) {
  13656. $reject.call({ _w: promise, _d: false }, e); // wrap
  13657. }
  13658. };
  13659. // constructor polyfill
  13660. if (!USE_NATIVE) {
  13661. // 25.4.3.1 Promise(executor)
  13662. $Promise = function Promise(executor) {
  13663. anInstance(this, $Promise, PROMISE, '_h');
  13664. aFunction(executor);
  13665. Internal.call(this);
  13666. try {
  13667. executor(ctx($resolve, this, 1), ctx($reject, this, 1));
  13668. } catch (err) {
  13669. $reject.call(this, err);
  13670. }
  13671. };
  13672. // eslint-disable-next-line no-unused-vars
  13673. Internal = function Promise(executor) {
  13674. this._c = []; // <- awaiting reactions
  13675. this._a = undefined; // <- checked in isUnhandled reactions
  13676. this._s = 0; // <- state
  13677. this._d = false; // <- done
  13678. this._v = undefined; // <- value
  13679. this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled
  13680. this._n = false; // <- notify
  13681. };
  13682. Internal.prototype = __webpack_require__(61)($Promise.prototype, {
  13683. // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
  13684. then: function then(onFulfilled, onRejected) {
  13685. var reaction = newPromiseCapability(speciesConstructor(this, $Promise));
  13686. reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
  13687. reaction.fail = typeof onRejected == 'function' && onRejected;
  13688. reaction.domain = isNode ? process.domain : undefined;
  13689. this._c.push(reaction);
  13690. if (this._a) this._a.push(reaction);
  13691. if (this._s) notify(this, false);
  13692. return reaction.promise;
  13693. },
  13694. // 25.4.5.1 Promise.prototype.catch(onRejected)
  13695. 'catch': function (onRejected) {
  13696. return this.then(undefined, onRejected);
  13697. }
  13698. });
  13699. OwnPromiseCapability = function () {
  13700. var promise = new Internal();
  13701. this.promise = promise;
  13702. this.resolve = ctx($resolve, promise, 1);
  13703. this.reject = ctx($reject, promise, 1);
  13704. };
  13705. newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
  13706. return C === $Promise || C === Wrapper
  13707. ? new OwnPromiseCapability(C)
  13708. : newGenericPromiseCapability(C);
  13709. };
  13710. }
  13711. $export($export.G + $export.W + $export.F * !USE_NATIVE, { Promise: $Promise });
  13712. __webpack_require__(51)($Promise, PROMISE);
  13713. __webpack_require__(109)(PROMISE);
  13714. Wrapper = __webpack_require__(44)[PROMISE];
  13715. // statics
  13716. $export($export.S + $export.F * !USE_NATIVE, PROMISE, {
  13717. // 25.4.4.5 Promise.reject(r)
  13718. reject: function reject(r) {
  13719. var capability = newPromiseCapability(this);
  13720. var $$reject = capability.reject;
  13721. $$reject(r);
  13722. return capability.promise;
  13723. }
  13724. });
  13725. $export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {
  13726. // 25.4.4.6 Promise.resolve(x)
  13727. resolve: function resolve(x) {
  13728. return promiseResolve(LIBRARY && this === Wrapper ? $Promise : this, x);
  13729. }
  13730. });
  13731. $export($export.S + $export.F * !(USE_NATIVE && __webpack_require__(79)(function (iter) {
  13732. $Promise.all(iter)['catch'](empty);
  13733. })), PROMISE, {
  13734. // 25.4.4.1 Promise.all(iterable)
  13735. all: function all(iterable) {
  13736. var C = this;
  13737. var capability = newPromiseCapability(C);
  13738. var resolve = capability.resolve;
  13739. var reject = capability.reject;
  13740. var result = perform(function () {
  13741. var values = [];
  13742. var index = 0;
  13743. var remaining = 1;
  13744. forOf(iterable, false, function (promise) {
  13745. var $index = index++;
  13746. var alreadyCalled = false;
  13747. values.push(undefined);
  13748. remaining++;
  13749. C.resolve(promise).then(function (value) {
  13750. if (alreadyCalled) return;
  13751. alreadyCalled = true;
  13752. values[$index] = value;
  13753. --remaining || resolve(values);
  13754. }, reject);
  13755. });
  13756. --remaining || resolve(values);
  13757. });
  13758. if (result.e) reject(result.v);
  13759. return capability.promise;
  13760. },
  13761. // 25.4.4.4 Promise.race(iterable)
  13762. race: function race(iterable) {
  13763. var C = this;
  13764. var capability = newPromiseCapability(C);
  13765. var reject = capability.reject;
  13766. var result = perform(function () {
  13767. forOf(iterable, false, function (promise) {
  13768. C.resolve(promise).then(capability.resolve, reject);
  13769. });
  13770. });
  13771. if (result.e) reject(result.v);
  13772. return capability.promise;
  13773. }
  13774. });
  13775. /***/ }),
  13776. /* 118 */
  13777. /***/ (function(module, exports, __webpack_require__) {
  13778. "use strict";
  13779. // 25.4.1.5 NewPromiseCapability(C)
  13780. var aFunction = __webpack_require__(62);
  13781. function PromiseCapability(C) {
  13782. var resolve, reject;
  13783. this.promise = new C(function ($$resolve, $$reject) {
  13784. if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
  13785. resolve = $$resolve;
  13786. reject = $$reject;
  13787. });
  13788. this.resolve = aFunction(resolve);
  13789. this.reject = aFunction(reject);
  13790. }
  13791. module.exports.f = function (C) {
  13792. return new PromiseCapability(C);
  13793. };
  13794. /***/ }),
  13795. /* 119 */
  13796. /***/ (function(module, exports, __webpack_require__) {
  13797. "use strict";
  13798. // ECMAScript 6 symbols shim
  13799. var global = __webpack_require__(14);
  13800. var has = __webpack_require__(29);
  13801. var DESCRIPTORS = __webpack_require__(22);
  13802. var $export = __webpack_require__(3);
  13803. var redefine = __webpack_require__(30);
  13804. var META = __webpack_require__(34).KEY;
  13805. var $fails = __webpack_require__(23);
  13806. var shared = __webpack_require__(77);
  13807. var setToStringTag = __webpack_require__(51);
  13808. var uid = __webpack_require__(48);
  13809. var wks = __webpack_require__(11);
  13810. var wksExt = __webpack_require__(120);
  13811. var wksDefine = __webpack_require__(217);
  13812. var enumKeys = __webpack_require__(218);
  13813. var isArray = __webpack_require__(113);
  13814. var anObject = __webpack_require__(18);
  13815. var isObject = __webpack_require__(9);
  13816. var toIObject = __webpack_require__(24);
  13817. var toPrimitive = __webpack_require__(73);
  13818. var createDesc = __webpack_require__(49);
  13819. var _create = __webpack_require__(74);
  13820. var gOPNExt = __webpack_require__(121);
  13821. var $GOPD = __webpack_require__(67);
  13822. var $DP = __webpack_require__(20);
  13823. var $keys = __webpack_require__(37);
  13824. var gOPD = $GOPD.f;
  13825. var dP = $DP.f;
  13826. var gOPN = gOPNExt.f;
  13827. var $Symbol = global.Symbol;
  13828. var $JSON = global.JSON;
  13829. var _stringify = $JSON && $JSON.stringify;
  13830. var PROTOTYPE = 'prototype';
  13831. var HIDDEN = wks('_hidden');
  13832. var TO_PRIMITIVE = wks('toPrimitive');
  13833. var isEnum = {}.propertyIsEnumerable;
  13834. var SymbolRegistry = shared('symbol-registry');
  13835. var AllSymbols = shared('symbols');
  13836. var OPSymbols = shared('op-symbols');
  13837. var ObjectProto = Object[PROTOTYPE];
  13838. var USE_NATIVE = typeof $Symbol == 'function';
  13839. var QObject = global.QObject;
  13840. // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
  13841. var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
  13842. // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
  13843. var setSymbolDesc = DESCRIPTORS && $fails(function () {
  13844. return _create(dP({}, 'a', {
  13845. get: function () { return dP(this, 'a', { value: 7 }).a; }
  13846. })).a != 7;
  13847. }) ? function (it, key, D) {
  13848. var protoDesc = gOPD(ObjectProto, key);
  13849. if (protoDesc) delete ObjectProto[key];
  13850. dP(it, key, D);
  13851. if (protoDesc && it !== ObjectProto) dP(ObjectProto, key, protoDesc);
  13852. } : dP;
  13853. var wrap = function (tag) {
  13854. var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
  13855. sym._k = tag;
  13856. return sym;
  13857. };
  13858. var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function (it) {
  13859. return typeof it == 'symbol';
  13860. } : function (it) {
  13861. return it instanceof $Symbol;
  13862. };
  13863. var $defineProperty = function defineProperty(it, key, D) {
  13864. if (it === ObjectProto) $defineProperty(OPSymbols, key, D);
  13865. anObject(it);
  13866. key = toPrimitive(key, true);
  13867. anObject(D);
  13868. if (has(AllSymbols, key)) {
  13869. if (!D.enumerable) {
  13870. if (!has(it, HIDDEN)) dP(it, HIDDEN, createDesc(1, {}));
  13871. it[HIDDEN][key] = true;
  13872. } else {
  13873. if (has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false;
  13874. D = _create(D, { enumerable: createDesc(0, false) });
  13875. } return setSymbolDesc(it, key, D);
  13876. } return dP(it, key, D);
  13877. };
  13878. var $defineProperties = function defineProperties(it, P) {
  13879. anObject(it);
  13880. var keys = enumKeys(P = toIObject(P));
  13881. var i = 0;
  13882. var l = keys.length;
  13883. var key;
  13884. while (l > i) $defineProperty(it, key = keys[i++], P[key]);
  13885. return it;
  13886. };
  13887. var $create = function create(it, P) {
  13888. return P === undefined ? _create(it) : $defineProperties(_create(it), P);
  13889. };
  13890. var $propertyIsEnumerable = function propertyIsEnumerable(key) {
  13891. var E = isEnum.call(this, key = toPrimitive(key, true));
  13892. if (this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return false;
  13893. return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
  13894. };
  13895. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {
  13896. it = toIObject(it);
  13897. key = toPrimitive(key, true);
  13898. if (it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return;
  13899. var D = gOPD(it, key);
  13900. if (D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true;
  13901. return D;
  13902. };
  13903. var $getOwnPropertyNames = function getOwnPropertyNames(it) {
  13904. var names = gOPN(toIObject(it));
  13905. var result = [];
  13906. var i = 0;
  13907. var key;
  13908. while (names.length > i) {
  13909. if (!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key);
  13910. } return result;
  13911. };
  13912. var $getOwnPropertySymbols = function getOwnPropertySymbols(it) {
  13913. var IS_OP = it === ObjectProto;
  13914. var names = gOPN(IS_OP ? OPSymbols : toIObject(it));
  13915. var result = [];
  13916. var i = 0;
  13917. var key;
  13918. while (names.length > i) {
  13919. if (has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true)) result.push(AllSymbols[key]);
  13920. } return result;
  13921. };
  13922. // 19.4.1.1 Symbol([description])
  13923. if (!USE_NATIVE) {
  13924. $Symbol = function Symbol() {
  13925. if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!');
  13926. var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
  13927. var $set = function (value) {
  13928. if (this === ObjectProto) $set.call(OPSymbols, value);
  13929. if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
  13930. setSymbolDesc(this, tag, createDesc(1, value));
  13931. };
  13932. if (DESCRIPTORS && setter) setSymbolDesc(ObjectProto, tag, { configurable: true, set: $set });
  13933. return wrap(tag);
  13934. };
  13935. redefine($Symbol[PROTOTYPE], 'toString', function toString() {
  13936. return this._k;
  13937. });
  13938. $GOPD.f = $getOwnPropertyDescriptor;
  13939. $DP.f = $defineProperty;
  13940. __webpack_require__(81).f = gOPNExt.f = $getOwnPropertyNames;
  13941. __webpack_require__(52).f = $propertyIsEnumerable;
  13942. __webpack_require__(69).f = $getOwnPropertySymbols;
  13943. if (DESCRIPTORS && !__webpack_require__(65)) {
  13944. redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
  13945. }
  13946. wksExt.f = function (name) {
  13947. return wrap(wks(name));
  13948. };
  13949. }
  13950. $export($export.G + $export.W + $export.F * !USE_NATIVE, { Symbol: $Symbol });
  13951. for (var es6Symbols = (
  13952. // 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
  13953. 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'
  13954. ).split(','), j = 0; es6Symbols.length > j;)wks(es6Symbols[j++]);
  13955. for (var wellKnownSymbols = $keys(wks.store), k = 0; wellKnownSymbols.length > k;) wksDefine(wellKnownSymbols[k++]);
  13956. $export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
  13957. // 19.4.2.1 Symbol.for(key)
  13958. 'for': function (key) {
  13959. return has(SymbolRegistry, key += '')
  13960. ? SymbolRegistry[key]
  13961. : SymbolRegistry[key] = $Symbol(key);
  13962. },
  13963. // 19.4.2.5 Symbol.keyFor(sym)
  13964. keyFor: function keyFor(sym) {
  13965. if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!');
  13966. for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key;
  13967. },
  13968. useSetter: function () { setter = true; },
  13969. useSimple: function () { setter = false; }
  13970. });
  13971. $export($export.S + $export.F * !USE_NATIVE, 'Object', {
  13972. // 19.1.2.2 Object.create(O [, Properties])
  13973. create: $create,
  13974. // 19.1.2.4 Object.defineProperty(O, P, Attributes)
  13975. defineProperty: $defineProperty,
  13976. // 19.1.2.3 Object.defineProperties(O, Properties)
  13977. defineProperties: $defineProperties,
  13978. // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
  13979. getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
  13980. // 19.1.2.7 Object.getOwnPropertyNames(O)
  13981. getOwnPropertyNames: $getOwnPropertyNames,
  13982. // 19.1.2.8 Object.getOwnPropertySymbols(O)
  13983. getOwnPropertySymbols: $getOwnPropertySymbols
  13984. });
  13985. // 24.3.2 JSON.stringify(value [, replacer [, space]])
  13986. $JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function () {
  13987. var S = $Symbol();
  13988. // MS Edge converts symbol values to JSON as {}
  13989. // WebKit converts symbol values to JSON as null
  13990. // V8 throws on boxed symbols
  13991. return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}';
  13992. })), 'JSON', {
  13993. stringify: function stringify(it) {
  13994. var args = [it];
  13995. var i = 1;
  13996. var replacer, $replacer;
  13997. while (arguments.length > i) args.push(arguments[i++]);
  13998. $replacer = replacer = args[1];
  13999. if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
  14000. if (!isArray(replacer)) replacer = function (key, value) {
  14001. if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
  14002. if (!isSymbol(value)) return value;
  14003. };
  14004. args[1] = replacer;
  14005. return _stringify.apply($JSON, args);
  14006. }
  14007. });
  14008. // 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)
  14009. $Symbol[PROTOTYPE][TO_PRIMITIVE] || __webpack_require__(31)($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
  14010. // 19.4.3.5 Symbol.prototype[@@toStringTag]
  14011. setToStringTag($Symbol, 'Symbol');
  14012. // 20.2.1.9 Math[@@toStringTag]
  14013. setToStringTag(Math, 'Math', true);
  14014. // 24.3.3 JSON[@@toStringTag]
  14015. setToStringTag(global.JSON, 'JSON', true);
  14016. /***/ }),
  14017. /* 120 */
  14018. /***/ (function(module, exports, __webpack_require__) {
  14019. exports.f = __webpack_require__(11);
  14020. /***/ }),
  14021. /* 121 */
  14022. /***/ (function(module, exports, __webpack_require__) {
  14023. // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
  14024. var toIObject = __webpack_require__(24);
  14025. var gOPN = __webpack_require__(81).f;
  14026. var toString = {}.toString;
  14027. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
  14028. ? Object.getOwnPropertyNames(window) : [];
  14029. var getWindowNames = function (it) {
  14030. try {
  14031. return gOPN(it);
  14032. } catch (e) {
  14033. return windowNames.slice();
  14034. }
  14035. };
  14036. module.exports.f = function getOwnPropertyNames(it) {
  14037. return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));
  14038. };
  14039. /***/ }),
  14040. /* 122 */
  14041. /***/ (function(module, exports, __webpack_require__) {
  14042. // 19.1.2.5 Object.freeze(O)
  14043. var isObject = __webpack_require__(9);
  14044. var meta = __webpack_require__(34).onFreeze;
  14045. __webpack_require__(26)('freeze', function ($freeze) {
  14046. return function freeze(it) {
  14047. return $freeze && isObject(it) ? $freeze(meta(it)) : it;
  14048. };
  14049. });
  14050. /***/ }),
  14051. /* 123 */
  14052. /***/ (function(module, exports, __webpack_require__) {
  14053. // 19.1.2.17 Object.seal(O)
  14054. var isObject = __webpack_require__(9);
  14055. var meta = __webpack_require__(34).onFreeze;
  14056. __webpack_require__(26)('seal', function ($seal) {
  14057. return function seal(it) {
  14058. return $seal && isObject(it) ? $seal(meta(it)) : it;
  14059. };
  14060. });
  14061. /***/ }),
  14062. /* 124 */
  14063. /***/ (function(module, exports, __webpack_require__) {
  14064. // 19.1.2.15 Object.preventExtensions(O)
  14065. var isObject = __webpack_require__(9);
  14066. var meta = __webpack_require__(34).onFreeze;
  14067. __webpack_require__(26)('preventExtensions', function ($preventExtensions) {
  14068. return function preventExtensions(it) {
  14069. return $preventExtensions && isObject(it) ? $preventExtensions(meta(it)) : it;
  14070. };
  14071. });
  14072. /***/ }),
  14073. /* 125 */
  14074. /***/ (function(module, exports, __webpack_require__) {
  14075. // 19.1.2.12 Object.isFrozen(O)
  14076. var isObject = __webpack_require__(9);
  14077. __webpack_require__(26)('isFrozen', function ($isFrozen) {
  14078. return function isFrozen(it) {
  14079. return isObject(it) ? $isFrozen ? $isFrozen(it) : false : true;
  14080. };
  14081. });
  14082. /***/ }),
  14083. /* 126 */
  14084. /***/ (function(module, exports, __webpack_require__) {
  14085. // 19.1.2.13 Object.isSealed(O)
  14086. var isObject = __webpack_require__(9);
  14087. __webpack_require__(26)('isSealed', function ($isSealed) {
  14088. return function isSealed(it) {
  14089. return isObject(it) ? $isSealed ? $isSealed(it) : false : true;
  14090. };
  14091. });
  14092. /***/ }),
  14093. /* 127 */
  14094. /***/ (function(module, exports, __webpack_require__) {
  14095. // 19.1.2.11 Object.isExtensible(O)
  14096. var isObject = __webpack_require__(9);
  14097. __webpack_require__(26)('isExtensible', function ($isExtensible) {
  14098. return function isExtensible(it) {
  14099. return isObject(it) ? $isExtensible ? $isExtensible(it) : true : false;
  14100. };
  14101. });
  14102. /***/ }),
  14103. /* 128 */
  14104. /***/ (function(module, exports, __webpack_require__) {
  14105. // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
  14106. var toIObject = __webpack_require__(24);
  14107. var $getOwnPropertyDescriptor = __webpack_require__(67).f;
  14108. __webpack_require__(26)('getOwnPropertyDescriptor', function () {
  14109. return function getOwnPropertyDescriptor(it, key) {
  14110. return $getOwnPropertyDescriptor(toIObject(it), key);
  14111. };
  14112. });
  14113. /***/ }),
  14114. /* 129 */
  14115. /***/ (function(module, exports, __webpack_require__) {
  14116. // 19.1.2.9 Object.getPrototypeOf(O)
  14117. var toObject = __webpack_require__(33);
  14118. var $getPrototypeOf = __webpack_require__(107);
  14119. __webpack_require__(26)('getPrototypeOf', function () {
  14120. return function getPrototypeOf(it) {
  14121. return $getPrototypeOf(toObject(it));
  14122. };
  14123. });
  14124. /***/ }),
  14125. /* 130 */
  14126. /***/ (function(module, exports, __webpack_require__) {
  14127. // 19.1.2.14 Object.keys(O)
  14128. var toObject = __webpack_require__(33);
  14129. var $keys = __webpack_require__(37);
  14130. __webpack_require__(26)('keys', function () {
  14131. return function keys(it) {
  14132. return $keys(toObject(it));
  14133. };
  14134. });
  14135. /***/ }),
  14136. /* 131 */
  14137. /***/ (function(module, exports, __webpack_require__) {
  14138. // 19.1.2.7 Object.getOwnPropertyNames(O)
  14139. __webpack_require__(26)('getOwnPropertyNames', function () {
  14140. return __webpack_require__(121).f;
  14141. });
  14142. /***/ }),
  14143. /* 132 */
  14144. /***/ (function(module, exports, __webpack_require__) {
  14145. // 19.1.3.1 Object.assign(target, source)
  14146. var $export = __webpack_require__(3);
  14147. $export($export.S + $export.F, 'Object', { assign: __webpack_require__(114) });
  14148. /***/ }),
  14149. /* 133 */
  14150. /***/ (function(module, exports, __webpack_require__) {
  14151. // 19.1.3.10 Object.is(value1, value2)
  14152. var $export = __webpack_require__(3);
  14153. $export($export.S, 'Object', { is: __webpack_require__(219) });
  14154. /***/ }),
  14155. /* 134 */
  14156. /***/ (function(module, exports, __webpack_require__) {
  14157. // 19.1.3.19 Object.setPrototypeOf(O, proto)
  14158. var $export = __webpack_require__(3);
  14159. $export($export.S, 'Object', { setPrototypeOf: __webpack_require__(110).set });
  14160. /***/ }),
  14161. /* 135 */
  14162. /***/ (function(module, exports, __webpack_require__) {
  14163. var dP = __webpack_require__(20).f;
  14164. var FProto = Function.prototype;
  14165. var nameRE = /^\s*function ([^ (]*)/;
  14166. var NAME = 'name';
  14167. // 19.2.4.2 name
  14168. NAME in FProto || __webpack_require__(22) && dP(FProto, NAME, {
  14169. configurable: true,
  14170. get: function () {
  14171. try {
  14172. return ('' + this).match(nameRE)[1];
  14173. } catch (e) {
  14174. return '';
  14175. }
  14176. }
  14177. });
  14178. /***/ }),
  14179. /* 136 */
  14180. /***/ (function(module, exports, __webpack_require__) {
  14181. var $export = __webpack_require__(3);
  14182. var toIObject = __webpack_require__(24);
  14183. var toLength = __webpack_require__(25);
  14184. $export($export.S, 'String', {
  14185. // 21.1.2.4 String.raw(callSite, ...substitutions)
  14186. raw: function raw(callSite) {
  14187. var tpl = toIObject(callSite.raw);
  14188. var len = toLength(tpl.length);
  14189. var aLen = arguments.length;
  14190. var res = [];
  14191. var i = 0;
  14192. while (len > i) {
  14193. res.push(String(tpl[i++]));
  14194. if (i < aLen) res.push(String(arguments[i]));
  14195. } return res.join('');
  14196. }
  14197. });
  14198. /***/ }),
  14199. /* 137 */
  14200. /***/ (function(module, exports, __webpack_require__) {
  14201. var $export = __webpack_require__(3);
  14202. var toAbsoluteIndex = __webpack_require__(60);
  14203. var fromCharCode = String.fromCharCode;
  14204. var $fromCodePoint = String.fromCodePoint;
  14205. // length should be 1, old FF problem
  14206. $export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
  14207. // 21.1.2.2 String.fromCodePoint(...codePoints)
  14208. fromCodePoint: function fromCodePoint(x) { // eslint-disable-line no-unused-vars
  14209. var res = [];
  14210. var aLen = arguments.length;
  14211. var i = 0;
  14212. var code;
  14213. while (aLen > i) {
  14214. code = +arguments[i++];
  14215. if (toAbsoluteIndex(code, 0x10ffff) !== code) throw RangeError(code + ' is not a valid code point');
  14216. res.push(code < 0x10000
  14217. ? fromCharCode(code)
  14218. : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)
  14219. );
  14220. } return res.join('');
  14221. }
  14222. });
  14223. /***/ }),
  14224. /* 138 */
  14225. /***/ (function(module, exports, __webpack_require__) {
  14226. "use strict";
  14227. var $export = __webpack_require__(3);
  14228. var $at = __webpack_require__(220)(false);
  14229. $export($export.P, 'String', {
  14230. // 21.1.3.3 String.prototype.codePointAt(pos)
  14231. codePointAt: function codePointAt(pos) {
  14232. return $at(this, pos);
  14233. }
  14234. });
  14235. /***/ }),
  14236. /* 139 */
  14237. /***/ (function(module, exports, __webpack_require__) {
  14238. var $export = __webpack_require__(3);
  14239. $export($export.P, 'String', {
  14240. // 21.1.3.13 String.prototype.repeat(count)
  14241. repeat: __webpack_require__(140)
  14242. });
  14243. /***/ }),
  14244. /* 140 */
  14245. /***/ (function(module, exports, __webpack_require__) {
  14246. "use strict";
  14247. var toInteger = __webpack_require__(59);
  14248. var defined = __webpack_require__(38);
  14249. module.exports = function repeat(count) {
  14250. var str = String(defined(this));
  14251. var res = '';
  14252. var n = toInteger(count);
  14253. if (n < 0 || n == Infinity) throw RangeError("Count can't be negative");
  14254. for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) res += str;
  14255. return res;
  14256. };
  14257. /***/ }),
  14258. /* 141 */
  14259. /***/ (function(module, exports, __webpack_require__) {
  14260. "use strict";
  14261. // 21.1.3.18 String.prototype.startsWith(searchString [, position ])
  14262. var $export = __webpack_require__(3);
  14263. var toLength = __webpack_require__(25);
  14264. var context = __webpack_require__(82);
  14265. var STARTS_WITH = 'startsWith';
  14266. var $startsWith = ''[STARTS_WITH];
  14267. $export($export.P + $export.F * __webpack_require__(83)(STARTS_WITH), 'String', {
  14268. startsWith: function startsWith(searchString /* , position = 0 */) {
  14269. var that = context(this, searchString, STARTS_WITH);
  14270. var index = toLength(Math.min(arguments.length > 1 ? arguments[1] : undefined, that.length));
  14271. var search = String(searchString);
  14272. return $startsWith
  14273. ? $startsWith.call(that, search, index)
  14274. : that.slice(index, index + search.length) === search;
  14275. }
  14276. });
  14277. /***/ }),
  14278. /* 142 */
  14279. /***/ (function(module, exports, __webpack_require__) {
  14280. // 7.2.8 IsRegExp(argument)
  14281. var isObject = __webpack_require__(9);
  14282. var cof = __webpack_require__(43);
  14283. var MATCH = __webpack_require__(11)('match');
  14284. module.exports = function (it) {
  14285. var isRegExp;
  14286. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp');
  14287. };
  14288. /***/ }),
  14289. /* 143 */
  14290. /***/ (function(module, exports, __webpack_require__) {
  14291. "use strict";
  14292. // 21.1.3.6 String.prototype.endsWith(searchString [, endPosition])
  14293. var $export = __webpack_require__(3);
  14294. var toLength = __webpack_require__(25);
  14295. var context = __webpack_require__(82);
  14296. var ENDS_WITH = 'endsWith';
  14297. var $endsWith = ''[ENDS_WITH];
  14298. $export($export.P + $export.F * __webpack_require__(83)(ENDS_WITH), 'String', {
  14299. endsWith: function endsWith(searchString /* , endPosition = @length */) {
  14300. var that = context(this, searchString, ENDS_WITH);
  14301. var endPosition = arguments.length > 1 ? arguments[1] : undefined;
  14302. var len = toLength(that.length);
  14303. var end = endPosition === undefined ? len : Math.min(toLength(endPosition), len);
  14304. var search = String(searchString);
  14305. return $endsWith
  14306. ? $endsWith.call(that, search, end)
  14307. : that.slice(end - search.length, end) === search;
  14308. }
  14309. });
  14310. /***/ }),
  14311. /* 144 */
  14312. /***/ (function(module, exports, __webpack_require__) {
  14313. "use strict";
  14314. // 21.1.3.7 String.prototype.includes(searchString, position = 0)
  14315. var $export = __webpack_require__(3);
  14316. var context = __webpack_require__(82);
  14317. var INCLUDES = 'includes';
  14318. $export($export.P + $export.F * __webpack_require__(83)(INCLUDES), 'String', {
  14319. includes: function includes(searchString /* , position = 0 */) {
  14320. return !!~context(this, searchString, INCLUDES)
  14321. .indexOf(searchString, arguments.length > 1 ? arguments[1] : undefined);
  14322. }
  14323. });
  14324. /***/ }),
  14325. /* 145 */
  14326. /***/ (function(module, exports, __webpack_require__) {
  14327. // 21.2.5.3 get RegExp.prototype.flags()
  14328. if (__webpack_require__(22) && /./g.flags != 'g') __webpack_require__(20).f(RegExp.prototype, 'flags', {
  14329. configurable: true,
  14330. get: __webpack_require__(221)
  14331. });
  14332. /***/ }),
  14333. /* 146 */
  14334. /***/ (function(module, exports, __webpack_require__) {
  14335. // @@match logic
  14336. __webpack_require__(70)('match', 1, function (defined, MATCH, $match) {
  14337. // 21.1.3.11 String.prototype.match(regexp)
  14338. return [function match(regexp) {
  14339. 'use strict';
  14340. var O = defined(this);
  14341. var fn = regexp == undefined ? undefined : regexp[MATCH];
  14342. return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
  14343. }, $match];
  14344. });
  14345. /***/ }),
  14346. /* 147 */
  14347. /***/ (function(module, exports, __webpack_require__) {
  14348. // @@replace logic
  14349. __webpack_require__(70)('replace', 2, function (defined, REPLACE, $replace) {
  14350. // 21.1.3.14 String.prototype.replace(searchValue, replaceValue)
  14351. return [function replace(searchValue, replaceValue) {
  14352. 'use strict';
  14353. var O = defined(this);
  14354. var fn = searchValue == undefined ? undefined : searchValue[REPLACE];
  14355. return fn !== undefined
  14356. ? fn.call(searchValue, O, replaceValue)
  14357. : $replace.call(String(O), searchValue, replaceValue);
  14358. }, $replace];
  14359. });
  14360. /***/ }),
  14361. /* 148 */
  14362. /***/ (function(module, exports, __webpack_require__) {
  14363. // @@split logic
  14364. __webpack_require__(70)('split', 2, function (defined, SPLIT, $split) {
  14365. 'use strict';
  14366. var isRegExp = __webpack_require__(142);
  14367. var _split = $split;
  14368. var $push = [].push;
  14369. var $SPLIT = 'split';
  14370. var LENGTH = 'length';
  14371. var LAST_INDEX = 'lastIndex';
  14372. if (
  14373. 'abbc'[$SPLIT](/(b)*/)[1] == 'c' ||
  14374. 'test'[$SPLIT](/(?:)/, -1)[LENGTH] != 4 ||
  14375. 'ab'[$SPLIT](/(?:ab)*/)[LENGTH] != 2 ||
  14376. '.'[$SPLIT](/(.?)(.?)/)[LENGTH] != 4 ||
  14377. '.'[$SPLIT](/()()/)[LENGTH] > 1 ||
  14378. ''[$SPLIT](/.?/)[LENGTH]
  14379. ) {
  14380. var NPCG = /()??/.exec('')[1] === undefined; // nonparticipating capturing group
  14381. // based on es5-shim implementation, need to rework it
  14382. $split = function (separator, limit) {
  14383. var string = String(this);
  14384. if (separator === undefined && limit === 0) return [];
  14385. // If `separator` is not a regex, use native split
  14386. if (!isRegExp(separator)) return _split.call(string, separator, limit);
  14387. var output = [];
  14388. var flags = (separator.ignoreCase ? 'i' : '') +
  14389. (separator.multiline ? 'm' : '') +
  14390. (separator.unicode ? 'u' : '') +
  14391. (separator.sticky ? 'y' : '');
  14392. var lastLastIndex = 0;
  14393. var splitLimit = limit === undefined ? 4294967295 : limit >>> 0;
  14394. // Make `global` and avoid `lastIndex` issues by working with a copy
  14395. var separatorCopy = new RegExp(separator.source, flags + 'g');
  14396. var separator2, match, lastIndex, lastLength, i;
  14397. // Doesn't need flags gy, but they don't hurt
  14398. if (!NPCG) separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags);
  14399. while (match = separatorCopy.exec(string)) {
  14400. // `separatorCopy.lastIndex` is not reliable cross-browser
  14401. lastIndex = match.index + match[0][LENGTH];
  14402. if (lastIndex > lastLastIndex) {
  14403. output.push(string.slice(lastLastIndex, match.index));
  14404. // Fix browsers whose `exec` methods don't consistently return `undefined` for NPCG
  14405. // eslint-disable-next-line no-loop-func
  14406. if (!NPCG && match[LENGTH] > 1) match[0].replace(separator2, function () {
  14407. for (i = 1; i < arguments[LENGTH] - 2; i++) if (arguments[i] === undefined) match[i] = undefined;
  14408. });
  14409. if (match[LENGTH] > 1 && match.index < string[LENGTH]) $push.apply(output, match.slice(1));
  14410. lastLength = match[0][LENGTH];
  14411. lastLastIndex = lastIndex;
  14412. if (output[LENGTH] >= splitLimit) break;
  14413. }
  14414. if (separatorCopy[LAST_INDEX] === match.index) separatorCopy[LAST_INDEX]++; // Avoid an infinite loop
  14415. }
  14416. if (lastLastIndex === string[LENGTH]) {
  14417. if (lastLength || !separatorCopy.test('')) output.push('');
  14418. } else output.push(string.slice(lastLastIndex));
  14419. return output[LENGTH] > splitLimit ? output.slice(0, splitLimit) : output;
  14420. };
  14421. // Chakra, V8
  14422. } else if ('0'[$SPLIT](undefined, 0)[LENGTH]) {
  14423. $split = function (separator, limit) {
  14424. return separator === undefined && limit === 0 ? [] : _split.call(this, separator, limit);
  14425. };
  14426. }
  14427. // 21.1.3.17 String.prototype.split(separator, limit)
  14428. return [function split(separator, limit) {
  14429. var O = defined(this);
  14430. var fn = separator == undefined ? undefined : separator[SPLIT];
  14431. return fn !== undefined ? fn.call(separator, O, limit) : $split.call(String(O), separator, limit);
  14432. }, $split];
  14433. });
  14434. /***/ }),
  14435. /* 149 */
  14436. /***/ (function(module, exports, __webpack_require__) {
  14437. // @@search logic
  14438. __webpack_require__(70)('search', 1, function (defined, SEARCH, $search) {
  14439. // 21.1.3.15 String.prototype.search(regexp)
  14440. return [function search(regexp) {
  14441. 'use strict';
  14442. var O = defined(this);
  14443. var fn = regexp == undefined ? undefined : regexp[SEARCH];
  14444. return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O));
  14445. }, $search];
  14446. });
  14447. /***/ }),
  14448. /* 150 */
  14449. /***/ (function(module, exports, __webpack_require__) {
  14450. "use strict";
  14451. var ctx = __webpack_require__(32);
  14452. var $export = __webpack_require__(3);
  14453. var toObject = __webpack_require__(33);
  14454. var call = __webpack_require__(102);
  14455. var isArrayIter = __webpack_require__(103);
  14456. var toLength = __webpack_require__(25);
  14457. var createProperty = __webpack_require__(84);
  14458. var getIterFn = __webpack_require__(104);
  14459. $export($export.S + $export.F * !__webpack_require__(79)(function (iter) { Array.from(iter); }), 'Array', {
  14460. // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
  14461. from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
  14462. var O = toObject(arrayLike);
  14463. var C = typeof this == 'function' ? this : Array;
  14464. var aLen = arguments.length;
  14465. var mapfn = aLen > 1 ? arguments[1] : undefined;
  14466. var mapping = mapfn !== undefined;
  14467. var index = 0;
  14468. var iterFn = getIterFn(O);
  14469. var length, result, step, iterator;
  14470. if (mapping) mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
  14471. // if object isn't iterable or it's array with default iterator - use simple case
  14472. if (iterFn != undefined && !(C == Array && isArrayIter(iterFn))) {
  14473. for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) {
  14474. createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);
  14475. }
  14476. } else {
  14477. length = toLength(O.length);
  14478. for (result = new C(length); length > index; index++) {
  14479. createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
  14480. }
  14481. }
  14482. result.length = index;
  14483. return result;
  14484. }
  14485. });
  14486. /***/ }),
  14487. /* 151 */
  14488. /***/ (function(module, exports, __webpack_require__) {
  14489. "use strict";
  14490. var $export = __webpack_require__(3);
  14491. var createProperty = __webpack_require__(84);
  14492. // WebKit Array.of isn't generic
  14493. $export($export.S + $export.F * __webpack_require__(23)(function () {
  14494. function F() { /* empty */ }
  14495. return !(Array.of.call(F) instanceof F);
  14496. }), 'Array', {
  14497. // 22.1.2.3 Array.of( ...items)
  14498. of: function of(/* ...args */) {
  14499. var index = 0;
  14500. var aLen = arguments.length;
  14501. var result = new (typeof this == 'function' ? this : Array)(aLen);
  14502. while (aLen > index) createProperty(result, index, arguments[index++]);
  14503. result.length = aLen;
  14504. return result;
  14505. }
  14506. });
  14507. /***/ }),
  14508. /* 152 */
  14509. /***/ (function(module, exports, __webpack_require__) {
  14510. // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
  14511. var $export = __webpack_require__(3);
  14512. $export($export.P, 'Array', { copyWithin: __webpack_require__(222) });
  14513. __webpack_require__(46)('copyWithin');
  14514. /***/ }),
  14515. /* 153 */
  14516. /***/ (function(module, exports, __webpack_require__) {
  14517. "use strict";
  14518. // 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined)
  14519. var $export = __webpack_require__(3);
  14520. var $find = __webpack_require__(68)(5);
  14521. var KEY = 'find';
  14522. var forced = true;
  14523. // Shouldn't skip holes
  14524. if (KEY in []) Array(1)[KEY](function () { forced = false; });
  14525. $export($export.P + $export.F * forced, 'Array', {
  14526. find: function find(callbackfn /* , that = undefined */) {
  14527. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  14528. }
  14529. });
  14530. __webpack_require__(46)(KEY);
  14531. /***/ }),
  14532. /* 154 */
  14533. /***/ (function(module, exports, __webpack_require__) {
  14534. "use strict";
  14535. // 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined)
  14536. var $export = __webpack_require__(3);
  14537. var $find = __webpack_require__(68)(6);
  14538. var KEY = 'findIndex';
  14539. var forced = true;
  14540. // Shouldn't skip holes
  14541. if (KEY in []) Array(1)[KEY](function () { forced = false; });
  14542. $export($export.P + $export.F * forced, 'Array', {
  14543. findIndex: function findIndex(callbackfn /* , that = undefined */) {
  14544. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  14545. }
  14546. });
  14547. __webpack_require__(46)(KEY);
  14548. /***/ }),
  14549. /* 155 */
  14550. /***/ (function(module, exports, __webpack_require__) {
  14551. // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
  14552. var $export = __webpack_require__(3);
  14553. $export($export.P, 'Array', { fill: __webpack_require__(223) });
  14554. __webpack_require__(46)('fill');
  14555. /***/ }),
  14556. /* 156 */
  14557. /***/ (function(module, exports, __webpack_require__) {
  14558. // 20.1.2.2 Number.isFinite(number)
  14559. var $export = __webpack_require__(3);
  14560. var _isFinite = __webpack_require__(14).isFinite;
  14561. $export($export.S, 'Number', {
  14562. isFinite: function isFinite(it) {
  14563. return typeof it == 'number' && _isFinite(it);
  14564. }
  14565. });
  14566. /***/ }),
  14567. /* 157 */
  14568. /***/ (function(module, exports, __webpack_require__) {
  14569. // 20.1.2.3 Number.isInteger(number)
  14570. var $export = __webpack_require__(3);
  14571. $export($export.S, 'Number', { isInteger: __webpack_require__(158) });
  14572. /***/ }),
  14573. /* 158 */
  14574. /***/ (function(module, exports, __webpack_require__) {
  14575. // 20.1.2.3 Number.isInteger(number)
  14576. var isObject = __webpack_require__(9);
  14577. var floor = Math.floor;
  14578. module.exports = function isInteger(it) {
  14579. return !isObject(it) && isFinite(it) && floor(it) === it;
  14580. };
  14581. /***/ }),
  14582. /* 159 */
  14583. /***/ (function(module, exports, __webpack_require__) {
  14584. // 20.1.2.5 Number.isSafeInteger(number)
  14585. var $export = __webpack_require__(3);
  14586. var isInteger = __webpack_require__(158);
  14587. var abs = Math.abs;
  14588. $export($export.S, 'Number', {
  14589. isSafeInteger: function isSafeInteger(number) {
  14590. return isInteger(number) && abs(number) <= 0x1fffffffffffff;
  14591. }
  14592. });
  14593. /***/ }),
  14594. /* 160 */
  14595. /***/ (function(module, exports, __webpack_require__) {
  14596. // 20.1.2.4 Number.isNaN(number)
  14597. var $export = __webpack_require__(3);
  14598. $export($export.S, 'Number', {
  14599. isNaN: function isNaN(number) {
  14600. // eslint-disable-next-line no-self-compare
  14601. return number != number;
  14602. }
  14603. });
  14604. /***/ }),
  14605. /* 161 */
  14606. /***/ (function(module, exports, __webpack_require__) {
  14607. // 20.1.2.1 Number.EPSILON
  14608. var $export = __webpack_require__(3);
  14609. $export($export.S, 'Number', { EPSILON: Math.pow(2, -52) });
  14610. /***/ }),
  14611. /* 162 */
  14612. /***/ (function(module, exports, __webpack_require__) {
  14613. // 20.1.2.10 Number.MIN_SAFE_INTEGER
  14614. var $export = __webpack_require__(3);
  14615. $export($export.S, 'Number', { MIN_SAFE_INTEGER: -0x1fffffffffffff });
  14616. /***/ }),
  14617. /* 163 */
  14618. /***/ (function(module, exports, __webpack_require__) {
  14619. // 20.1.2.6 Number.MAX_SAFE_INTEGER
  14620. var $export = __webpack_require__(3);
  14621. $export($export.S, 'Number', { MAX_SAFE_INTEGER: 0x1fffffffffffff });
  14622. /***/ }),
  14623. /* 164 */
  14624. /***/ (function(module, exports, __webpack_require__) {
  14625. "use strict";
  14626. // https://github.com/tc39/Array.prototype.includes
  14627. var $export = __webpack_require__(3);
  14628. var $includes = __webpack_require__(100)(true);
  14629. $export($export.P, 'Array', {
  14630. includes: function includes(el /* , fromIndex = 0 */) {
  14631. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  14632. }
  14633. });
  14634. __webpack_require__(46)('includes');
  14635. /***/ }),
  14636. /* 165 */
  14637. /***/ (function(module, exports, __webpack_require__) {
  14638. // https://github.com/tc39/proposal-object-values-entries
  14639. var $export = __webpack_require__(3);
  14640. var $values = __webpack_require__(166)(false);
  14641. $export($export.S, 'Object', {
  14642. values: function values(it) {
  14643. return $values(it);
  14644. }
  14645. });
  14646. /***/ }),
  14647. /* 166 */
  14648. /***/ (function(module, exports, __webpack_require__) {
  14649. var getKeys = __webpack_require__(37);
  14650. var toIObject = __webpack_require__(24);
  14651. var isEnum = __webpack_require__(52).f;
  14652. module.exports = function (isEntries) {
  14653. return function (it) {
  14654. var O = toIObject(it);
  14655. var keys = getKeys(O);
  14656. var length = keys.length;
  14657. var i = 0;
  14658. var result = [];
  14659. var key;
  14660. while (length > i) if (isEnum.call(O, key = keys[i++])) {
  14661. result.push(isEntries ? [key, O[key]] : O[key]);
  14662. } return result;
  14663. };
  14664. };
  14665. /***/ }),
  14666. /* 167 */
  14667. /***/ (function(module, exports, __webpack_require__) {
  14668. // https://github.com/tc39/proposal-object-values-entries
  14669. var $export = __webpack_require__(3);
  14670. var $entries = __webpack_require__(166)(true);
  14671. $export($export.S, 'Object', {
  14672. entries: function entries(it) {
  14673. return $entries(it);
  14674. }
  14675. });
  14676. /***/ }),
  14677. /* 168 */
  14678. /***/ (function(module, exports, __webpack_require__) {
  14679. // https://github.com/tc39/proposal-object-getownpropertydescriptors
  14680. var $export = __webpack_require__(3);
  14681. var ownKeys = __webpack_require__(224);
  14682. var toIObject = __webpack_require__(24);
  14683. var gOPD = __webpack_require__(67);
  14684. var createProperty = __webpack_require__(84);
  14685. $export($export.S, 'Object', {
  14686. getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) {
  14687. var O = toIObject(object);
  14688. var getDesc = gOPD.f;
  14689. var keys = ownKeys(O);
  14690. var result = {};
  14691. var i = 0;
  14692. var key, desc;
  14693. while (keys.length > i) {
  14694. desc = getDesc(O, key = keys[i++]);
  14695. if (desc !== undefined) createProperty(result, key, desc);
  14696. }
  14697. return result;
  14698. }
  14699. });
  14700. /***/ }),
  14701. /* 169 */
  14702. /***/ (function(module, exports, __webpack_require__) {
  14703. "use strict";
  14704. // https://github.com/tc39/proposal-string-pad-start-end
  14705. var $export = __webpack_require__(3);
  14706. var $pad = __webpack_require__(170);
  14707. var userAgent = __webpack_require__(171);
  14708. // https://github.com/zloirock/core-js/issues/280
  14709. $export($export.P + $export.F * /Version\/10\.\d+(\.\d+)? Safari\//.test(userAgent), 'String', {
  14710. padStart: function padStart(maxLength /* , fillString = ' ' */) {
  14711. return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, true);
  14712. }
  14713. });
  14714. /***/ }),
  14715. /* 170 */
  14716. /***/ (function(module, exports, __webpack_require__) {
  14717. // https://github.com/tc39/proposal-string-pad-start-end
  14718. var toLength = __webpack_require__(25);
  14719. var repeat = __webpack_require__(140);
  14720. var defined = __webpack_require__(38);
  14721. module.exports = function (that, maxLength, fillString, left) {
  14722. var S = String(defined(that));
  14723. var stringLength = S.length;
  14724. var fillStr = fillString === undefined ? ' ' : String(fillString);
  14725. var intMaxLength = toLength(maxLength);
  14726. if (intMaxLength <= stringLength || fillStr == '') return S;
  14727. var fillLen = intMaxLength - stringLength;
  14728. var stringFiller = repeat.call(fillStr, Math.ceil(fillLen / fillStr.length));
  14729. if (stringFiller.length > fillLen) stringFiller = stringFiller.slice(0, fillLen);
  14730. return left ? stringFiller + S : S + stringFiller;
  14731. };
  14732. /***/ }),
  14733. /* 171 */
  14734. /***/ (function(module, exports, __webpack_require__) {
  14735. var global = __webpack_require__(14);
  14736. var navigator = global.navigator;
  14737. module.exports = navigator && navigator.userAgent || '';
  14738. /***/ }),
  14739. /* 172 */
  14740. /***/ (function(module, exports, __webpack_require__) {
  14741. "use strict";
  14742. // https://github.com/tc39/proposal-string-pad-start-end
  14743. var $export = __webpack_require__(3);
  14744. var $pad = __webpack_require__(170);
  14745. var userAgent = __webpack_require__(171);
  14746. // https://github.com/zloirock/core-js/issues/280
  14747. $export($export.P + $export.F * /Version\/10\.\d+(\.\d+)? Safari\//.test(userAgent), 'String', {
  14748. padEnd: function padEnd(maxLength /* , fillString = ' ' */) {
  14749. return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, false);
  14750. }
  14751. });
  14752. /***/ }),
  14753. /* 173 */
  14754. /***/ (function(module, exports, __webpack_require__) {
  14755. var $export = __webpack_require__(3);
  14756. var $task = __webpack_require__(80);
  14757. $export($export.G + $export.B, {
  14758. setImmediate: $task.set,
  14759. clearImmediate: $task.clear
  14760. });
  14761. /***/ }),
  14762. /* 174 */
  14763. /***/ (function(module, exports, __webpack_require__) {
  14764. var $iterators = __webpack_require__(85);
  14765. var getKeys = __webpack_require__(37);
  14766. var redefine = __webpack_require__(30);
  14767. var global = __webpack_require__(14);
  14768. var hide = __webpack_require__(31);
  14769. var Iterators = __webpack_require__(50);
  14770. var wks = __webpack_require__(11);
  14771. var ITERATOR = wks('iterator');
  14772. var TO_STRING_TAG = wks('toStringTag');
  14773. var ArrayValues = Iterators.Array;
  14774. var DOMIterables = {
  14775. CSSRuleList: true, // TODO: Not spec compliant, should be false.
  14776. CSSStyleDeclaration: false,
  14777. CSSValueList: false,
  14778. ClientRectList: false,
  14779. DOMRectList: false,
  14780. DOMStringList: false,
  14781. DOMTokenList: true,
  14782. DataTransferItemList: false,
  14783. FileList: false,
  14784. HTMLAllCollection: false,
  14785. HTMLCollection: false,
  14786. HTMLFormElement: false,
  14787. HTMLSelectElement: false,
  14788. MediaList: true, // TODO: Not spec compliant, should be false.
  14789. MimeTypeArray: false,
  14790. NamedNodeMap: false,
  14791. NodeList: true,
  14792. PaintRequestList: false,
  14793. Plugin: false,
  14794. PluginArray: false,
  14795. SVGLengthList: false,
  14796. SVGNumberList: false,
  14797. SVGPathSegList: false,
  14798. SVGPointList: false,
  14799. SVGStringList: false,
  14800. SVGTransformList: false,
  14801. SourceBufferList: false,
  14802. StyleSheetList: true, // TODO: Not spec compliant, should be false.
  14803. TextTrackCueList: false,
  14804. TextTrackList: false,
  14805. TouchList: false
  14806. };
  14807. for (var collections = getKeys(DOMIterables), i = 0; i < collections.length; i++) {
  14808. var NAME = collections[i];
  14809. var explicit = DOMIterables[NAME];
  14810. var Collection = global[NAME];
  14811. var proto = Collection && Collection.prototype;
  14812. var key;
  14813. if (proto) {
  14814. if (!proto[ITERATOR]) hide(proto, ITERATOR, ArrayValues);
  14815. if (!proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME);
  14816. Iterators[NAME] = ArrayValues;
  14817. if (explicit) for (key in $iterators) if (!proto[key]) redefine(proto, key, $iterators[key], true);
  14818. }
  14819. }
  14820. /***/ }),
  14821. /* 175 */
  14822. /***/ (function(module, exports, __webpack_require__) {
  14823. "use strict";
  14824. exports.__esModule = true;
  14825. 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; }; }();
  14826. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14827. var privatePool = new WeakMap();
  14828. /**
  14829. * Calculates indexes of columns to render OR columns that are visible.
  14830. * To redo the calculation, you need to create a new calculator.
  14831. *
  14832. * @class ViewportColumnsCalculator
  14833. */
  14834. var ViewportColumnsCalculator = function () {
  14835. _createClass(ViewportColumnsCalculator, null, [{
  14836. key: 'DEFAULT_WIDTH',
  14837. /**
  14838. * Default column width
  14839. *
  14840. * @type {Number}
  14841. */
  14842. get: function get() {
  14843. return 50;
  14844. }
  14845. /**
  14846. * @param {Number} viewportWidth Width of the viewport
  14847. * @param {Number} scrollOffset Current horizontal scroll position of the viewport
  14848. * @param {Number} totalColumns Total number of rows
  14849. * @param {Function} columnWidthFn Function that returns the width of the column at a given index (in px)
  14850. * @param {Function} overrideFn Function that changes calculated this.startRow, this.endRow (used by MergeCells plugin)
  14851. * @param {Boolean} onlyFullyVisible if `true`, only startRow and endRow will be indexes of rows that are fully in viewport
  14852. * @param {Boolean} stretchH
  14853. * @param {Function} [stretchingColumnWidthFn] Function that returns the new width of the stretched column.
  14854. */
  14855. }]);
  14856. function ViewportColumnsCalculator(viewportWidth, scrollOffset, totalColumns, columnWidthFn, overrideFn, onlyFullyVisible, stretchH) {
  14857. var stretchingColumnWidthFn = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : function (width) {
  14858. return width;
  14859. };
  14860. _classCallCheck(this, ViewportColumnsCalculator);
  14861. privatePool.set(this, {
  14862. viewportWidth: viewportWidth,
  14863. scrollOffset: scrollOffset,
  14864. totalColumns: totalColumns,
  14865. columnWidthFn: columnWidthFn,
  14866. overrideFn: overrideFn,
  14867. onlyFullyVisible: onlyFullyVisible,
  14868. stretchingColumnWidthFn: stretchingColumnWidthFn
  14869. });
  14870. /**
  14871. * Number of rendered/visible columns
  14872. *
  14873. * @type {Number}
  14874. */
  14875. this.count = 0;
  14876. /**
  14877. * Index of the first rendered/visible column (can be overwritten using overrideFn)
  14878. *
  14879. * @type {Number|null}
  14880. */
  14881. this.startColumn = null;
  14882. /**
  14883. * Index of the last rendered/visible column (can be overwritten using overrideFn)
  14884. *
  14885. * @type {null}
  14886. */
  14887. this.endColumn = null;
  14888. /**
  14889. * Position of the first rendered/visible column (in px)
  14890. *
  14891. * @type {Number|null}
  14892. */
  14893. this.startPosition = null;
  14894. this.stretchAllRatio = 0;
  14895. this.stretchLastWidth = 0;
  14896. this.stretch = stretchH;
  14897. this.totalTargetWidth = 0;
  14898. this.needVerifyLastColumnWidth = true;
  14899. this.stretchAllColumnsWidth = [];
  14900. this.calculate();
  14901. }
  14902. /**
  14903. * Calculates viewport
  14904. */
  14905. _createClass(ViewportColumnsCalculator, [{
  14906. key: 'calculate',
  14907. value: function calculate() {
  14908. var sum = 0;
  14909. var needReverse = true;
  14910. var startPositions = [];
  14911. var columnWidth = void 0;
  14912. var priv = privatePool.get(this);
  14913. var onlyFullyVisible = priv.onlyFullyVisible;
  14914. var overrideFn = priv.overrideFn;
  14915. var scrollOffset = priv.scrollOffset;
  14916. var totalColumns = priv.totalColumns;
  14917. var viewportWidth = priv.viewportWidth;
  14918. for (var i = 0; i < totalColumns; i++) {
  14919. columnWidth = this._getColumnWidth(i);
  14920. if (sum <= scrollOffset && !onlyFullyVisible) {
  14921. this.startColumn = i;
  14922. }
  14923. // +1 pixel for row header width compensation for horizontal scroll > 0
  14924. var compensatedViewportWidth = scrollOffset > 0 ? viewportWidth + 1 : viewportWidth;
  14925. if (sum >= scrollOffset && sum + columnWidth <= scrollOffset + compensatedViewportWidth) {
  14926. if (this.startColumn == null) {
  14927. this.startColumn = i;
  14928. }
  14929. this.endColumn = i;
  14930. }
  14931. startPositions.push(sum);
  14932. sum += columnWidth;
  14933. if (!onlyFullyVisible) {
  14934. this.endColumn = i;
  14935. }
  14936. if (sum >= scrollOffset + viewportWidth) {
  14937. needReverse = false;
  14938. break;
  14939. }
  14940. }
  14941. if (this.endColumn === totalColumns - 1 && needReverse) {
  14942. this.startColumn = this.endColumn;
  14943. while (this.startColumn > 0) {
  14944. var viewportSum = startPositions[this.endColumn] + columnWidth - startPositions[this.startColumn - 1];
  14945. if (viewportSum <= viewportWidth || !onlyFullyVisible) {
  14946. this.startColumn--;
  14947. }
  14948. if (viewportSum > viewportWidth) {
  14949. break;
  14950. }
  14951. }
  14952. }
  14953. if (this.startColumn !== null && overrideFn) {
  14954. overrideFn(this);
  14955. }
  14956. this.startPosition = startPositions[this.startColumn];
  14957. if (this.startPosition == void 0) {
  14958. this.startPosition = null;
  14959. }
  14960. if (this.startColumn !== null) {
  14961. this.count = this.endColumn - this.startColumn + 1;
  14962. }
  14963. }
  14964. /**
  14965. * Recalculate columns stretching.
  14966. *
  14967. * @param {Number} totalWidth
  14968. */
  14969. }, {
  14970. key: 'refreshStretching',
  14971. value: function refreshStretching(totalWidth) {
  14972. if (this.stretch === 'none') {
  14973. return;
  14974. }
  14975. this.totalTargetWidth = totalWidth;
  14976. var priv = privatePool.get(this);
  14977. var totalColumns = priv.totalColumns;
  14978. var sumAll = 0;
  14979. for (var i = 0; i < totalColumns; i++) {
  14980. var columnWidth = this._getColumnWidth(i);
  14981. var permanentColumnWidth = priv.stretchingColumnWidthFn(void 0, i);
  14982. if (typeof permanentColumnWidth === 'number') {
  14983. totalWidth -= permanentColumnWidth;
  14984. } else {
  14985. sumAll += columnWidth;
  14986. }
  14987. }
  14988. var remainingSize = totalWidth - sumAll;
  14989. if (this.stretch === 'all' && remainingSize > 0) {
  14990. this.stretchAllRatio = totalWidth / sumAll;
  14991. this.stretchAllColumnsWidth = [];
  14992. this.needVerifyLastColumnWidth = true;
  14993. } else if (this.stretch === 'last' && totalWidth !== Infinity) {
  14994. var _columnWidth = this._getColumnWidth(totalColumns - 1);
  14995. var lastColumnWidth = remainingSize + _columnWidth;
  14996. this.stretchLastWidth = lastColumnWidth >= 0 ? lastColumnWidth : _columnWidth;
  14997. }
  14998. }
  14999. /**
  15000. * Get stretched column width based on stretchH (all or last) setting passed in handsontable instance.
  15001. *
  15002. * @param {Number} column
  15003. * @param {Number} baseWidth
  15004. * @returns {Number|null}
  15005. */
  15006. }, {
  15007. key: 'getStretchedColumnWidth',
  15008. value: function getStretchedColumnWidth(column, baseWidth) {
  15009. var result = null;
  15010. if (this.stretch === 'all' && this.stretchAllRatio !== 0) {
  15011. result = this._getStretchedAllColumnWidth(column, baseWidth);
  15012. } else if (this.stretch === 'last' && this.stretchLastWidth !== 0) {
  15013. result = this._getStretchedLastColumnWidth(column);
  15014. }
  15015. return result;
  15016. }
  15017. /**
  15018. * @param {Number} column
  15019. * @param {Number} baseWidth
  15020. * @returns {Number}
  15021. * @private
  15022. */
  15023. }, {
  15024. key: '_getStretchedAllColumnWidth',
  15025. value: function _getStretchedAllColumnWidth(column, baseWidth) {
  15026. var sumRatioWidth = 0;
  15027. var priv = privatePool.get(this);
  15028. var totalColumns = priv.totalColumns;
  15029. if (!this.stretchAllColumnsWidth[column]) {
  15030. var stretchedWidth = Math.round(baseWidth * this.stretchAllRatio);
  15031. var newStretchedWidth = priv.stretchingColumnWidthFn(stretchedWidth, column);
  15032. if (newStretchedWidth === void 0) {
  15033. this.stretchAllColumnsWidth[column] = stretchedWidth;
  15034. } else {
  15035. this.stretchAllColumnsWidth[column] = isNaN(newStretchedWidth) ? this._getColumnWidth(column) : newStretchedWidth;
  15036. }
  15037. }
  15038. if (this.stretchAllColumnsWidth.length === totalColumns && this.needVerifyLastColumnWidth) {
  15039. this.needVerifyLastColumnWidth = false;
  15040. for (var i = 0; i < this.stretchAllColumnsWidth.length; i++) {
  15041. sumRatioWidth += this.stretchAllColumnsWidth[i];
  15042. }
  15043. if (sumRatioWidth !== this.totalTargetWidth) {
  15044. this.stretchAllColumnsWidth[this.stretchAllColumnsWidth.length - 1] += this.totalTargetWidth - sumRatioWidth;
  15045. }
  15046. }
  15047. return this.stretchAllColumnsWidth[column];
  15048. }
  15049. /**
  15050. * @param {Number} column
  15051. * @returns {Number|null}
  15052. * @private
  15053. */
  15054. }, {
  15055. key: '_getStretchedLastColumnWidth',
  15056. value: function _getStretchedLastColumnWidth(column) {
  15057. var priv = privatePool.get(this);
  15058. var totalColumns = priv.totalColumns;
  15059. if (column === totalColumns - 1) {
  15060. return this.stretchLastWidth;
  15061. }
  15062. return null;
  15063. }
  15064. /**
  15065. * @param {Number} column Column index.
  15066. * @returns {Number}
  15067. * @private
  15068. */
  15069. }, {
  15070. key: '_getColumnWidth',
  15071. value: function _getColumnWidth(column) {
  15072. var width = privatePool.get(this).columnWidthFn(column);
  15073. if (width === void 0) {
  15074. width = ViewportColumnsCalculator.DEFAULT_WIDTH;
  15075. }
  15076. return width;
  15077. }
  15078. }]);
  15079. return ViewportColumnsCalculator;
  15080. }();
  15081. exports.default = ViewportColumnsCalculator;
  15082. /***/ }),
  15083. /* 176 */
  15084. /***/ (function(module, exports, __webpack_require__) {
  15085. "use strict";
  15086. exports.__esModule = true;
  15087. 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; }; }();
  15088. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15089. var privatePool = new WeakMap();
  15090. /**
  15091. * Calculates indexes of rows to render OR rows that are visible.
  15092. * To redo the calculation, you need to create a new calculator.
  15093. *
  15094. * @class ViewportRowsCalculator
  15095. */
  15096. var ViewportRowsCalculator = function () {
  15097. _createClass(ViewportRowsCalculator, null, [{
  15098. key: "DEFAULT_HEIGHT",
  15099. /**
  15100. * Default row height
  15101. *
  15102. * @type {Number}
  15103. */
  15104. get: function get() {
  15105. return 23;
  15106. }
  15107. /**
  15108. * @param {Number} viewportHeight Height of the viewport
  15109. * @param {Number} scrollOffset Current vertical scroll position of the viewport
  15110. * @param {Number} totalRows Total number of rows
  15111. * @param {Function} rowHeightFn Function that returns the height of the row at a given index (in px)
  15112. * @param {Function} overrideFn Function that changes calculated this.startRow, this.endRow (used by MergeCells plugin)
  15113. * @param {Boolean} onlyFullyVisible if `true`, only startRow and endRow will be indexes of rows that are fully in viewport
  15114. * @param {Number} horizontalScrollbarHeight
  15115. */
  15116. }]);
  15117. function ViewportRowsCalculator(viewportHeight, scrollOffset, totalRows, rowHeightFn, overrideFn, onlyFullyVisible, horizontalScrollbarHeight) {
  15118. _classCallCheck(this, ViewportRowsCalculator);
  15119. privatePool.set(this, {
  15120. viewportHeight: viewportHeight,
  15121. scrollOffset: scrollOffset,
  15122. totalRows: totalRows,
  15123. rowHeightFn: rowHeightFn,
  15124. overrideFn: overrideFn,
  15125. onlyFullyVisible: onlyFullyVisible,
  15126. horizontalScrollbarHeight: horizontalScrollbarHeight
  15127. });
  15128. /**
  15129. * Number of rendered/visible rows
  15130. *
  15131. * @type {Number}
  15132. */
  15133. this.count = 0;
  15134. /**
  15135. * Index of the first rendered/visible row (can be overwritten using overrideFn)
  15136. *
  15137. * @type {Number|null}
  15138. */
  15139. this.startRow = null;
  15140. /**
  15141. * Index of the last rendered/visible row (can be overwritten using overrideFn)
  15142. *
  15143. * @type {null}
  15144. */
  15145. this.endRow = null;
  15146. /**
  15147. * Position of the first rendered/visible row (in px)
  15148. *
  15149. * @type {Number|null}
  15150. */
  15151. this.startPosition = null;
  15152. this.calculate();
  15153. }
  15154. /**
  15155. * Calculates viewport
  15156. */
  15157. _createClass(ViewportRowsCalculator, [{
  15158. key: "calculate",
  15159. value: function calculate() {
  15160. var sum = 0;
  15161. var needReverse = true;
  15162. var startPositions = [];
  15163. var priv = privatePool.get(this);
  15164. var onlyFullyVisible = priv.onlyFullyVisible;
  15165. var overrideFn = priv.overrideFn;
  15166. var rowHeightFn = priv.rowHeightFn;
  15167. var scrollOffset = priv.scrollOffset;
  15168. var totalRows = priv.totalRows;
  15169. var viewportHeight = priv.viewportHeight;
  15170. var horizontalScrollbarHeight = priv.horizontalScrollbarHeight || 0;
  15171. var rowHeight = void 0;
  15172. // Calculate the number (start and end index) of rows needed
  15173. for (var i = 0; i < totalRows; i++) {
  15174. rowHeight = rowHeightFn(i);
  15175. if (rowHeight === undefined) {
  15176. rowHeight = ViewportRowsCalculator.DEFAULT_HEIGHT;
  15177. }
  15178. if (sum <= scrollOffset && !onlyFullyVisible) {
  15179. this.startRow = i;
  15180. }
  15181. // the row is within the "visible range"
  15182. if (sum >= scrollOffset && sum + rowHeight <= scrollOffset + viewportHeight - horizontalScrollbarHeight) {
  15183. if (this.startRow === null) {
  15184. this.startRow = i;
  15185. }
  15186. this.endRow = i;
  15187. }
  15188. startPositions.push(sum);
  15189. sum += rowHeight;
  15190. if (!onlyFullyVisible) {
  15191. this.endRow = i;
  15192. }
  15193. if (sum >= scrollOffset + viewportHeight - horizontalScrollbarHeight) {
  15194. needReverse = false;
  15195. break;
  15196. }
  15197. }
  15198. // If the estimation has reached the last row and there is still some space available in the viewport,
  15199. // we need to render in reverse in order to fill the whole viewport with rows
  15200. if (this.endRow === totalRows - 1 && needReverse) {
  15201. this.startRow = this.endRow;
  15202. while (this.startRow > 0) {
  15203. // rowHeight is the height of the last row
  15204. var viewportSum = startPositions[this.endRow] + rowHeight - startPositions[this.startRow - 1];
  15205. if (viewportSum <= viewportHeight - horizontalScrollbarHeight || !onlyFullyVisible) {
  15206. this.startRow--;
  15207. }
  15208. if (viewportSum >= viewportHeight - horizontalScrollbarHeight) {
  15209. break;
  15210. }
  15211. }
  15212. }
  15213. if (this.startRow !== null && overrideFn) {
  15214. overrideFn(this);
  15215. }
  15216. this.startPosition = startPositions[this.startRow];
  15217. if (this.startPosition == void 0) {
  15218. this.startPosition = null;
  15219. }
  15220. if (this.startRow !== null) {
  15221. this.count = this.endRow - this.startRow + 1;
  15222. }
  15223. }
  15224. }]);
  15225. return ViewportRowsCalculator;
  15226. }();
  15227. exports.default = ViewportRowsCalculator;
  15228. /***/ }),
  15229. /* 177 */
  15230. /***/ (function(module, exports, __webpack_require__) {
  15231. "use strict";
  15232. exports.__esModule = true;
  15233. 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; }; }();
  15234. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15235. /**
  15236. * @class ColumnFilter
  15237. */
  15238. var ColumnFilter = function () {
  15239. /**
  15240. * @param {Number} offset
  15241. * @param {Number} total
  15242. * @param {Number} countTH
  15243. */
  15244. function ColumnFilter(offset, total, countTH) {
  15245. _classCallCheck(this, ColumnFilter);
  15246. this.offset = offset;
  15247. this.total = total;
  15248. this.countTH = countTH;
  15249. }
  15250. /**
  15251. * @param index
  15252. * @returns {Number}
  15253. */
  15254. _createClass(ColumnFilter, [{
  15255. key: "offsetted",
  15256. value: function offsetted(index) {
  15257. return index + this.offset;
  15258. }
  15259. /**
  15260. * @param index
  15261. * @returns {Number}
  15262. */
  15263. }, {
  15264. key: "unOffsetted",
  15265. value: function unOffsetted(index) {
  15266. return index - this.offset;
  15267. }
  15268. /**
  15269. * @param index
  15270. * @returns {Number}
  15271. */
  15272. }, {
  15273. key: "renderedToSource",
  15274. value: function renderedToSource(index) {
  15275. return this.offsetted(index);
  15276. }
  15277. /**
  15278. * @param index
  15279. * @returns {Number}
  15280. */
  15281. }, {
  15282. key: "sourceToRendered",
  15283. value: function sourceToRendered(index) {
  15284. return this.unOffsetted(index);
  15285. }
  15286. /**
  15287. * @param index
  15288. * @returns {Number}
  15289. */
  15290. }, {
  15291. key: "offsettedTH",
  15292. value: function offsettedTH(index) {
  15293. return index - this.countTH;
  15294. }
  15295. /**
  15296. * @param index
  15297. * @returns {Number}
  15298. */
  15299. }, {
  15300. key: "unOffsettedTH",
  15301. value: function unOffsettedTH(index) {
  15302. return index + this.countTH;
  15303. }
  15304. /**
  15305. * @param index
  15306. * @returns {Number}
  15307. */
  15308. }, {
  15309. key: "visibleRowHeadedColumnToSourceColumn",
  15310. value: function visibleRowHeadedColumnToSourceColumn(index) {
  15311. return this.renderedToSource(this.offsettedTH(index));
  15312. }
  15313. /**
  15314. * @param index
  15315. * @returns {Number}
  15316. */
  15317. }, {
  15318. key: "sourceColumnToVisibleRowHeadedColumn",
  15319. value: function sourceColumnToVisibleRowHeadedColumn(index) {
  15320. return this.unOffsettedTH(this.sourceToRendered(index));
  15321. }
  15322. }]);
  15323. return ColumnFilter;
  15324. }();
  15325. exports.default = ColumnFilter;
  15326. /***/ }),
  15327. /* 178 */
  15328. /***/ (function(module, exports, __webpack_require__) {
  15329. "use strict";
  15330. exports.__esModule = true;
  15331. 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; }; }();
  15332. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15333. /**
  15334. * @class RowFilter
  15335. */
  15336. var RowFilter = function () {
  15337. /**
  15338. * @param {Number} offset
  15339. * @param {Number} total
  15340. * @param {Number} countTH
  15341. */
  15342. function RowFilter(offset, total, countTH) {
  15343. _classCallCheck(this, RowFilter);
  15344. this.offset = offset;
  15345. this.total = total;
  15346. this.countTH = countTH;
  15347. }
  15348. /**
  15349. * @param index
  15350. * @returns {Number}
  15351. */
  15352. _createClass(RowFilter, [{
  15353. key: "offsetted",
  15354. value: function offsetted(index) {
  15355. return index + this.offset;
  15356. }
  15357. /**
  15358. * @param index
  15359. * @returns {Number}
  15360. */
  15361. }, {
  15362. key: "unOffsetted",
  15363. value: function unOffsetted(index) {
  15364. return index - this.offset;
  15365. }
  15366. /**
  15367. * @param index
  15368. * @returns {Number}
  15369. */
  15370. }, {
  15371. key: "renderedToSource",
  15372. value: function renderedToSource(index) {
  15373. return this.offsetted(index);
  15374. }
  15375. /**
  15376. * @param index
  15377. * @returns {Number}
  15378. */
  15379. }, {
  15380. key: "sourceToRendered",
  15381. value: function sourceToRendered(index) {
  15382. return this.unOffsetted(index);
  15383. }
  15384. /**
  15385. * @param index
  15386. * @returns {Number}
  15387. */
  15388. }, {
  15389. key: "offsettedTH",
  15390. value: function offsettedTH(index) {
  15391. return index - this.countTH;
  15392. }
  15393. /**
  15394. * @param index
  15395. * @returns {Number}
  15396. */
  15397. }, {
  15398. key: "unOffsettedTH",
  15399. value: function unOffsettedTH(index) {
  15400. return index + this.countTH;
  15401. }
  15402. /**
  15403. * @param index
  15404. * @returns {Number}
  15405. */
  15406. }, {
  15407. key: "visibleColHeadedRowToSourceRow",
  15408. value: function visibleColHeadedRowToSourceRow(index) {
  15409. return this.renderedToSource(this.offsettedTH(index));
  15410. }
  15411. /**
  15412. * @param index
  15413. * @returns {Number}
  15414. */
  15415. }, {
  15416. key: "sourceRowToVisibleColHeadedRow",
  15417. value: function sourceRowToVisibleColHeadedRow(index) {
  15418. return this.unOffsettedTH(this.sourceToRendered(index));
  15419. }
  15420. }]);
  15421. return RowFilter;
  15422. }();
  15423. exports.default = RowFilter;
  15424. /***/ }),
  15425. /* 179 */
  15426. /***/ (function(module, exports, __webpack_require__) {
  15427. "use strict";
  15428. exports.__esModule = true;
  15429. 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; }; }();
  15430. var _element = __webpack_require__(0);
  15431. var _object = __webpack_require__(2);
  15432. var _string = __webpack_require__(36);
  15433. var _event = __webpack_require__(180);
  15434. var _event2 = _interopRequireDefault(_event);
  15435. var _overlays = __webpack_require__(181);
  15436. var _overlays2 = _interopRequireDefault(_overlays);
  15437. var _scroll = __webpack_require__(182);
  15438. var _scroll2 = _interopRequireDefault(_scroll);
  15439. var _settings = __webpack_require__(183);
  15440. var _settings2 = _interopRequireDefault(_settings);
  15441. var _table = __webpack_require__(184);
  15442. var _table2 = _interopRequireDefault(_table);
  15443. var _viewport = __webpack_require__(186);
  15444. var _viewport2 = _interopRequireDefault(_viewport);
  15445. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  15446. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15447. /**
  15448. * @class Walkontable
  15449. */
  15450. var Walkontable = function () {
  15451. /**
  15452. * @param {Object} settings
  15453. */
  15454. function Walkontable(settings) {
  15455. _classCallCheck(this, Walkontable);
  15456. var originalHeaders = [];
  15457. // this is the namespace for global events
  15458. this.guid = 'wt_' + (0, _string.randomString)();
  15459. // bootstrap from settings
  15460. if (settings.cloneSource) {
  15461. this.cloneSource = settings.cloneSource;
  15462. this.cloneOverlay = settings.cloneOverlay;
  15463. this.wtSettings = settings.cloneSource.wtSettings;
  15464. this.wtTable = new _table2.default(this, settings.table, settings.wtRootElement);
  15465. this.wtScroll = new _scroll2.default(this);
  15466. this.wtViewport = settings.cloneSource.wtViewport;
  15467. this.wtEvent = new _event2.default(this);
  15468. this.selections = this.cloneSource.selections;
  15469. } else {
  15470. this.wtSettings = new _settings2.default(this, settings);
  15471. this.wtTable = new _table2.default(this, settings.table);
  15472. this.wtScroll = new _scroll2.default(this);
  15473. this.wtViewport = new _viewport2.default(this);
  15474. this.wtEvent = new _event2.default(this);
  15475. this.selections = this.getSetting('selections');
  15476. this.wtOverlays = new _overlays2.default(this);
  15477. this.exportSettingsAsClassNames();
  15478. }
  15479. // find original headers
  15480. if (this.wtTable.THEAD.childNodes.length && this.wtTable.THEAD.childNodes[0].childNodes.length) {
  15481. for (var c = 0, clen = this.wtTable.THEAD.childNodes[0].childNodes.length; c < clen; c++) {
  15482. originalHeaders.push(this.wtTable.THEAD.childNodes[0].childNodes[c].innerHTML);
  15483. }
  15484. if (!this.getSetting('columnHeaders').length) {
  15485. this.update('columnHeaders', [function (column, TH) {
  15486. (0, _element.fastInnerText)(TH, originalHeaders[column]);
  15487. }]);
  15488. }
  15489. }
  15490. this.drawn = false;
  15491. this.drawInterrupted = false;
  15492. }
  15493. /**
  15494. * Force rerender of Walkontable
  15495. *
  15496. * @param {Boolean} [fastDraw=false] When `true`, try to refresh only the positions of borders without rerendering
  15497. * the data. It will only work if Table.draw() does not force
  15498. * rendering anyway
  15499. * @returns {Walkontable}
  15500. */
  15501. _createClass(Walkontable, [{
  15502. key: 'draw',
  15503. value: function draw() {
  15504. var fastDraw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  15505. this.drawInterrupted = false;
  15506. if (!fastDraw && !(0, _element.isVisible)(this.wtTable.TABLE)) {
  15507. // draw interrupted because TABLE is not visible
  15508. this.drawInterrupted = true;
  15509. } else {
  15510. this.wtTable.draw(fastDraw);
  15511. }
  15512. return this;
  15513. }
  15514. /**
  15515. * Returns the TD at coords. If topmost is set to true, returns TD from the topmost overlay layer,
  15516. * if not set or set to false, returns TD from the master table.
  15517. *
  15518. * @param {CellCoords} coords
  15519. * @param {Boolean} [topmost=false]
  15520. * @returns {Object}
  15521. */
  15522. }, {
  15523. key: 'getCell',
  15524. value: function getCell(coords) {
  15525. var topmost = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  15526. if (!topmost) {
  15527. return this.wtTable.getCell(coords);
  15528. }
  15529. var totalRows = this.wtSettings.getSetting('totalRows');
  15530. var fixedRowsTop = this.wtSettings.getSetting('fixedRowsTop');
  15531. var fixedRowsBottom = this.wtSettings.getSetting('fixedRowsBottom');
  15532. var fixedColumns = this.wtSettings.getSetting('fixedColumnsLeft');
  15533. if (coords.row < fixedRowsTop && coords.col < fixedColumns) {
  15534. return this.wtOverlays.topLeftCornerOverlay.clone.wtTable.getCell(coords);
  15535. } else if (coords.row < fixedRowsTop) {
  15536. return this.wtOverlays.topOverlay.clone.wtTable.getCell(coords);
  15537. } else if (coords.col < fixedColumns && coords.row >= totalRows - fixedRowsBottom) {
  15538. if (this.wtOverlays.bottomLeftCornerOverlay && this.wtOverlays.bottomLeftCornerOverlay.clone) {
  15539. return this.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.getCell(coords);
  15540. }
  15541. } else if (coords.col < fixedColumns) {
  15542. return this.wtOverlays.leftOverlay.clone.wtTable.getCell(coords);
  15543. } else if (coords.row < totalRows && coords.row > totalRows - fixedRowsBottom) {
  15544. if (this.wtOverlays.bottomOverlay && this.wtOverlays.bottomOverlay.clone) {
  15545. return this.wtOverlays.bottomOverlay.clone.wtTable.getCell(coords);
  15546. }
  15547. }
  15548. return this.wtTable.getCell(coords);
  15549. }
  15550. /**
  15551. * @param {Object} settings
  15552. * @param {*} value
  15553. * @returns {Walkontable}
  15554. */
  15555. }, {
  15556. key: 'update',
  15557. value: function update(settings, value) {
  15558. return this.wtSettings.update(settings, value);
  15559. }
  15560. /**
  15561. * Scroll the viewport to a row at the given index in the data source
  15562. *
  15563. * @param {Number} row
  15564. * @returns {Walkontable}
  15565. */
  15566. }, {
  15567. key: 'scrollVertical',
  15568. value: function scrollVertical(row) {
  15569. this.wtOverlays.topOverlay.scrollTo(row);
  15570. this.getSetting('onScrollVertically');
  15571. return this;
  15572. }
  15573. /**
  15574. * Scroll the viewport to a column at the given index in the data source
  15575. *
  15576. * @param {Number} column
  15577. * @returns {Walkontable}
  15578. */
  15579. }, {
  15580. key: 'scrollHorizontal',
  15581. value: function scrollHorizontal(column) {
  15582. this.wtOverlays.leftOverlay.scrollTo(column);
  15583. this.getSetting('onScrollHorizontally');
  15584. return this;
  15585. }
  15586. /**
  15587. * Scrolls the viewport to a cell (rerenders if needed)
  15588. *
  15589. * @param {CellCoords} coords
  15590. * @returns {Walkontable}
  15591. */
  15592. }, {
  15593. key: 'scrollViewport',
  15594. value: function scrollViewport(coords) {
  15595. this.wtScroll.scrollViewport(coords);
  15596. return this;
  15597. }
  15598. /**
  15599. * @returns {Array}
  15600. */
  15601. }, {
  15602. key: 'getViewport',
  15603. value: function getViewport() {
  15604. return [this.wtTable.getFirstVisibleRow(), this.wtTable.getFirstVisibleColumn(), this.wtTable.getLastVisibleRow(), this.wtTable.getLastVisibleColumn()];
  15605. }
  15606. /**
  15607. * Get overlay name
  15608. *
  15609. * @returns {String}
  15610. */
  15611. }, {
  15612. key: 'getOverlayName',
  15613. value: function getOverlayName() {
  15614. return this.cloneOverlay ? this.cloneOverlay.type : 'master';
  15615. }
  15616. /**
  15617. * Check overlay type of this Walkontable instance.
  15618. *
  15619. * @param {String} name Clone type @see {Overlay.CLONE_TYPES}.
  15620. * @returns {Boolean}
  15621. */
  15622. }, {
  15623. key: 'isOverlayName',
  15624. value: function isOverlayName(name) {
  15625. if (this.cloneOverlay) {
  15626. return this.cloneOverlay.type === name;
  15627. }
  15628. return false;
  15629. }
  15630. /**
  15631. * Export settings as class names added to the parent element of the table.
  15632. */
  15633. }, {
  15634. key: 'exportSettingsAsClassNames',
  15635. value: function exportSettingsAsClassNames() {
  15636. var _this = this;
  15637. var toExport = {
  15638. rowHeaders: ['array'],
  15639. columnHeaders: ['array']
  15640. };
  15641. var allClassNames = [];
  15642. var newClassNames = [];
  15643. (0, _object.objectEach)(toExport, function (optionType, key) {
  15644. if (optionType.indexOf('array') > -1 && _this.getSetting(key).length) {
  15645. newClassNames.push('ht' + (0, _string.toUpperCaseFirst)(key));
  15646. }
  15647. allClassNames.push('ht' + (0, _string.toUpperCaseFirst)(key));
  15648. });
  15649. (0, _element.removeClass)(this.wtTable.wtRootElement.parentNode, allClassNames);
  15650. (0, _element.addClass)(this.wtTable.wtRootElement.parentNode, newClassNames);
  15651. }
  15652. /**
  15653. * Get/Set Walkontable instance setting
  15654. *
  15655. * @param {String} key
  15656. * @param {*} [param1]
  15657. * @param {*} [param2]
  15658. * @param {*} [param3]
  15659. * @param {*} [param4]
  15660. * @returns {*}
  15661. */
  15662. }, {
  15663. key: 'getSetting',
  15664. value: function getSetting(key, param1, param2, param3, param4) {
  15665. // this is faster than .apply - https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips
  15666. return this.wtSettings.getSetting(key, param1, param2, param3, param4);
  15667. }
  15668. /**
  15669. * Checks if setting exists
  15670. *
  15671. * @param {String} key
  15672. * @returns {Boolean}
  15673. */
  15674. }, {
  15675. key: 'hasSetting',
  15676. value: function hasSetting(key) {
  15677. return this.wtSettings.has(key);
  15678. }
  15679. /**
  15680. * Destroy instance
  15681. */
  15682. }, {
  15683. key: 'destroy',
  15684. value: function destroy() {
  15685. this.wtOverlays.destroy();
  15686. this.wtEvent.destroy();
  15687. }
  15688. }]);
  15689. return Walkontable;
  15690. }();
  15691. exports.default = Walkontable;
  15692. /***/ }),
  15693. /* 180 */
  15694. /***/ (function(module, exports, __webpack_require__) {
  15695. "use strict";
  15696. exports.__esModule = true;
  15697. var _element = __webpack_require__(0);
  15698. var _function = __webpack_require__(42);
  15699. var _browser = __webpack_require__(27);
  15700. var _eventManager = __webpack_require__(6);
  15701. var _eventManager2 = _interopRequireDefault(_eventManager);
  15702. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  15703. /**
  15704. *
  15705. */
  15706. function Event(instance) {
  15707. var that = this;
  15708. var eventManager = new _eventManager2.default(instance);
  15709. var selectedCellBeforeTouchEnd = void 0;
  15710. this.instance = instance;
  15711. var dblClickOrigin = [null, null];
  15712. this.dblClickTimeout = [null, null];
  15713. var onMouseDown = function onMouseDown(event) {
  15714. var activeElement = document.activeElement;
  15715. var getParentNode = (0, _function.partial)(_element.getParent, event.realTarget);
  15716. var realTarget = event.realTarget;
  15717. // ignore focusable element from mouse down processing (https://github.com/handsontable/handsontable/issues/3555)
  15718. if (realTarget === activeElement || getParentNode(0) === activeElement || getParentNode(1) === activeElement) {
  15719. return;
  15720. }
  15721. var cell = that.parentCell(realTarget);
  15722. if ((0, _element.hasClass)(realTarget, 'corner')) {
  15723. that.instance.getSetting('onCellCornerMouseDown', event, realTarget);
  15724. } else if (cell.TD) {
  15725. if (that.instance.hasSetting('onCellMouseDown')) {
  15726. that.instance.getSetting('onCellMouseDown', event, cell.coords, cell.TD, that.instance);
  15727. }
  15728. }
  15729. if (event.button !== 2) {
  15730. // if not right mouse button
  15731. if (cell.TD) {
  15732. dblClickOrigin[0] = cell.TD;
  15733. clearTimeout(that.dblClickTimeout[0]);
  15734. that.dblClickTimeout[0] = setTimeout(function () {
  15735. dblClickOrigin[0] = null;
  15736. }, 1000);
  15737. }
  15738. }
  15739. };
  15740. var onTouchMove = function onTouchMove(event) {
  15741. that.instance.touchMoving = true;
  15742. };
  15743. var onTouchStart = function onTouchStart(event) {
  15744. eventManager.addEventListener(this, 'touchmove', onTouchMove);
  15745. // Prevent cell selection when scrolling with touch event - not the best solution performance-wise
  15746. that.checkIfTouchMove = setTimeout(function () {
  15747. if (that.instance.touchMoving === true) {
  15748. that.instance.touchMoving = void 0;
  15749. eventManager.removeEventListener('touchmove', onTouchMove, false);
  15750. }
  15751. onMouseDown(event);
  15752. }, 30);
  15753. };
  15754. var onMouseOver = function onMouseOver(event) {
  15755. var table, td, mainWOT;
  15756. if (that.instance.hasSetting('onCellMouseOver')) {
  15757. table = that.instance.wtTable.TABLE;
  15758. td = (0, _element.closestDown)(event.realTarget, ['TD', 'TH'], table);
  15759. mainWOT = that.instance.cloneSource || that.instance;
  15760. if (td && td !== mainWOT.lastMouseOver && (0, _element.isChildOf)(td, table)) {
  15761. mainWOT.lastMouseOver = td;
  15762. that.instance.getSetting('onCellMouseOver', event, that.instance.wtTable.getCoords(td), td, that.instance);
  15763. }
  15764. }
  15765. };
  15766. var onMouseOut = function onMouseOut(event) {
  15767. var table = void 0;
  15768. var lastTD = void 0;
  15769. var nextTD = void 0;
  15770. if (that.instance.hasSetting('onCellMouseOut')) {
  15771. table = that.instance.wtTable.TABLE;
  15772. lastTD = (0, _element.closestDown)(event.realTarget, ['TD', 'TH'], table);
  15773. nextTD = (0, _element.closestDown)(event.relatedTarget, ['TD', 'TH'], table);
  15774. if (lastTD && lastTD !== nextTD && (0, _element.isChildOf)(lastTD, table)) {
  15775. that.instance.getSetting('onCellMouseOut', event, that.instance.wtTable.getCoords(lastTD), lastTD, that.instance);
  15776. }
  15777. }
  15778. };
  15779. var onMouseUp = function onMouseUp(event) {
  15780. if (event.button !== 2) {
  15781. // if not right mouse button
  15782. var cell = that.parentCell(event.realTarget);
  15783. if (cell.TD === dblClickOrigin[0] && cell.TD === dblClickOrigin[1]) {
  15784. if ((0, _element.hasClass)(event.realTarget, 'corner')) {
  15785. that.instance.getSetting('onCellCornerDblClick', event, cell.coords, cell.TD, that.instance);
  15786. } else {
  15787. that.instance.getSetting('onCellDblClick', event, cell.coords, cell.TD, that.instance);
  15788. }
  15789. dblClickOrigin[0] = null;
  15790. dblClickOrigin[1] = null;
  15791. } else if (cell.TD === dblClickOrigin[0]) {
  15792. that.instance.getSetting('onCellMouseUp', event, cell.coords, cell.TD, that.instance);
  15793. dblClickOrigin[1] = cell.TD;
  15794. clearTimeout(that.dblClickTimeout[1]);
  15795. that.dblClickTimeout[1] = setTimeout(function () {
  15796. dblClickOrigin[1] = null;
  15797. }, 500);
  15798. } else if (cell.TD && that.instance.hasSetting('onCellMouseUp')) {
  15799. that.instance.getSetting('onCellMouseUp', event, cell.coords, cell.TD, that.instance);
  15800. }
  15801. }
  15802. };
  15803. var selectedCellWasTouched = function selectedCellWasTouched(touchTarget) {
  15804. var cellUnderFinger = that.parentCell(touchTarget);
  15805. var coordsOfCellUnderFinger = cellUnderFinger.coords;
  15806. if (selectedCellBeforeTouchEnd && coordsOfCellUnderFinger) {
  15807. var _ref = [coordsOfCellUnderFinger.row, selectedCellBeforeTouchEnd.from.row],
  15808. rowTouched = _ref[0],
  15809. rowSelected = _ref[1];
  15810. var _ref2 = [coordsOfCellUnderFinger.col, selectedCellBeforeTouchEnd.from.col],
  15811. colTouched = _ref2[0],
  15812. colSelected = _ref2[1];
  15813. return rowTouched === rowSelected && colTouched === colSelected;
  15814. }
  15815. return false;
  15816. };
  15817. var onTouchEnd = function onTouchEnd(event) {
  15818. var excludeTags = ['A', 'BUTTON', 'INPUT'];
  15819. var target = event.target;
  15820. // touched link which was placed inside a cell (a cell with DOM `a` element) WILL NOT trigger the below function calls
  15821. // and as consequence will behave as standard (open the link).
  15822. if (selectedCellWasTouched(target) === false || excludeTags.includes(target.tagName) === false) {
  15823. event.preventDefault();
  15824. onMouseUp(event);
  15825. }
  15826. };
  15827. eventManager.addEventListener(this.instance.wtTable.holder, 'mousedown', onMouseDown);
  15828. eventManager.addEventListener(this.instance.wtTable.TABLE, 'mouseover', onMouseOver);
  15829. eventManager.addEventListener(this.instance.wtTable.TABLE, 'mouseout', onMouseOut);
  15830. eventManager.addEventListener(this.instance.wtTable.holder, 'mouseup', onMouseUp);
  15831. // check if full HOT instance, or detached WOT AND run on mobile device
  15832. if (this.instance.wtTable.holder.parentNode.parentNode && (0, _browser.isMobileBrowser)() && !that.instance.wtTable.isWorkingOnClone()) {
  15833. var classSelector = '.' + this.instance.wtTable.holder.parentNode.className.split(' ').join('.');
  15834. eventManager.addEventListener(this.instance.wtTable.holder, 'touchstart', function (event) {
  15835. selectedCellBeforeTouchEnd = instance.selections.getCell().cellRange;
  15836. that.instance.touchApplied = true;
  15837. if ((0, _element.isChildOf)(event.target, classSelector)) {
  15838. onTouchStart.call(event.target, event);
  15839. }
  15840. });
  15841. eventManager.addEventListener(this.instance.wtTable.holder, 'touchend', function (event) {
  15842. that.instance.touchApplied = false;
  15843. if ((0, _element.isChildOf)(event.target, classSelector)) {
  15844. onTouchEnd.call(event.target, event);
  15845. }
  15846. });
  15847. if (!that.instance.momentumScrolling) {
  15848. that.instance.momentumScrolling = {};
  15849. }
  15850. eventManager.addEventListener(this.instance.wtTable.holder, 'scroll', function (event) {
  15851. clearTimeout(that.instance.momentumScrolling._timeout);
  15852. if (!that.instance.momentumScrolling.ongoing) {
  15853. that.instance.getSetting('onBeforeTouchScroll');
  15854. }
  15855. that.instance.momentumScrolling.ongoing = true;
  15856. that.instance.momentumScrolling._timeout = setTimeout(function () {
  15857. if (!that.instance.touchApplied) {
  15858. that.instance.momentumScrolling.ongoing = false;
  15859. that.instance.getSetting('onAfterMomentumScroll');
  15860. }
  15861. }, 200);
  15862. });
  15863. }
  15864. eventManager.addEventListener(window, 'resize', function () {
  15865. if (that.instance.getSetting('stretchH') !== 'none') {
  15866. that.instance.draw();
  15867. }
  15868. });
  15869. this.destroy = function () {
  15870. clearTimeout(this.dblClickTimeout[0]);
  15871. clearTimeout(this.dblClickTimeout[1]);
  15872. eventManager.destroy();
  15873. };
  15874. }
  15875. Event.prototype.parentCell = function (elem) {
  15876. var cell = {};
  15877. var TABLE = this.instance.wtTable.TABLE;
  15878. var TD = (0, _element.closestDown)(elem, ['TD', 'TH'], TABLE);
  15879. if (TD) {
  15880. cell.coords = this.instance.wtTable.getCoords(TD);
  15881. cell.TD = TD;
  15882. } else if ((0, _element.hasClass)(elem, 'wtBorder') && (0, _element.hasClass)(elem, 'current')) {
  15883. cell.coords = this.instance.selections.getCell().cellRange.highlight;
  15884. cell.TD = this.instance.wtTable.getCell(cell.coords);
  15885. } else if ((0, _element.hasClass)(elem, 'wtBorder') && (0, _element.hasClass)(elem, 'area')) {
  15886. if (this.instance.selections.createOrGetArea().cellRange) {
  15887. cell.coords = this.instance.selections.createOrGetArea().cellRange.to;
  15888. cell.TD = this.instance.wtTable.getCell(cell.coords);
  15889. }
  15890. }
  15891. return cell;
  15892. };
  15893. exports.default = Event;
  15894. /***/ }),
  15895. /* 181 */
  15896. /***/ (function(module, exports, __webpack_require__) {
  15897. "use strict";
  15898. exports.__esModule = true;
  15899. 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; }; }();
  15900. var _element = __webpack_require__(0);
  15901. var _array = __webpack_require__(1);
  15902. var _unicode = __webpack_require__(21);
  15903. var _browser = __webpack_require__(27);
  15904. var _eventManager = __webpack_require__(6);
  15905. var _eventManager2 = _interopRequireDefault(_eventManager);
  15906. var _base = __webpack_require__(35);
  15907. var _base2 = _interopRequireDefault(_base);
  15908. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  15909. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15910. /**
  15911. * @class Overlays
  15912. */
  15913. var Overlays = function () {
  15914. /**
  15915. * @param {Walkontable} wotInstance
  15916. */
  15917. function Overlays(wotInstance) {
  15918. _classCallCheck(this, Overlays);
  15919. /**
  15920. * Sometimes `line-height` might be set to 'normal'. In that case, a default `font-size` should be multiplied by roughly 1.2.
  15921. * https://developer.mozilla.org/pl/docs/Web/CSS/line-height#Values
  15922. */
  15923. var BODY_LINE_HEIGHT = parseInt(getComputedStyle(document.body).lineHeight, 10);
  15924. var FALLBACK_BODY_LINE_HEIGHT = parseInt(getComputedStyle(document.body).fontSize, 10) * 1.2;
  15925. this.wot = wotInstance;
  15926. // legacy support
  15927. this.instance = this.wot;
  15928. this.eventManager = new _eventManager2.default(this.wot);
  15929. this.wot.update('scrollbarWidth', (0, _element.getScrollbarWidth)());
  15930. this.wot.update('scrollbarHeight', (0, _element.getScrollbarWidth)());
  15931. this.scrollableElement = (0, _element.getScrollableElement)(this.wot.wtTable.TABLE);
  15932. this.prepareOverlays();
  15933. this.destroyed = false;
  15934. this.keyPressed = false;
  15935. this.spreaderLastSize = {
  15936. width: null,
  15937. height: null
  15938. };
  15939. this.overlayScrollPositions = {
  15940. master: {
  15941. top: 0,
  15942. left: 0
  15943. },
  15944. top: {
  15945. top: null,
  15946. left: 0
  15947. },
  15948. bottom: {
  15949. top: null,
  15950. left: 0
  15951. },
  15952. left: {
  15953. top: 0,
  15954. left: null
  15955. }
  15956. };
  15957. this.pendingScrollCallbacks = {
  15958. master: {
  15959. top: 0,
  15960. left: 0
  15961. },
  15962. top: {
  15963. left: 0
  15964. },
  15965. bottom: {
  15966. left: 0
  15967. },
  15968. left: {
  15969. top: 0
  15970. }
  15971. };
  15972. this.verticalScrolling = false;
  15973. this.horizontalScrolling = false;
  15974. this.delegatedScrollCallback = false;
  15975. this.registeredListeners = [];
  15976. this.browserLineHeight = BODY_LINE_HEIGHT || FALLBACK_BODY_LINE_HEIGHT;
  15977. this.registerListeners();
  15978. }
  15979. /**
  15980. * Prepare overlays based on user settings.
  15981. *
  15982. * @returns {Boolean} Returns `true` if changes applied to overlay needs scroll synchronization.
  15983. */
  15984. _createClass(Overlays, [{
  15985. key: 'prepareOverlays',
  15986. value: function prepareOverlays() {
  15987. var syncScroll = false;
  15988. if (this.topOverlay) {
  15989. syncScroll = this.topOverlay.updateStateOfRendering() || syncScroll;
  15990. } else {
  15991. this.topOverlay = _base2.default.createOverlay(_base2.default.CLONE_TOP, this.wot);
  15992. }
  15993. if (!_base2.default.hasOverlay(_base2.default.CLONE_BOTTOM)) {
  15994. this.bottomOverlay = {
  15995. needFullRender: false,
  15996. updateStateOfRendering: function updateStateOfRendering() {
  15997. return false;
  15998. }
  15999. };
  16000. }
  16001. if (!_base2.default.hasOverlay(_base2.default.CLONE_BOTTOM_LEFT_CORNER)) {
  16002. this.bottomLeftCornerOverlay = {
  16003. needFullRender: false,
  16004. updateStateOfRendering: function updateStateOfRendering() {
  16005. return false;
  16006. }
  16007. };
  16008. }
  16009. if (this.bottomOverlay) {
  16010. syncScroll = this.bottomOverlay.updateStateOfRendering() || syncScroll;
  16011. } else {
  16012. this.bottomOverlay = _base2.default.createOverlay(_base2.default.CLONE_BOTTOM, this.wot);
  16013. }
  16014. if (this.leftOverlay) {
  16015. syncScroll = this.leftOverlay.updateStateOfRendering() || syncScroll;
  16016. } else {
  16017. this.leftOverlay = _base2.default.createOverlay(_base2.default.CLONE_LEFT, this.wot);
  16018. }
  16019. if (this.topOverlay.needFullRender && this.leftOverlay.needFullRender) {
  16020. if (this.topLeftCornerOverlay) {
  16021. syncScroll = this.topLeftCornerOverlay.updateStateOfRendering() || syncScroll;
  16022. } else {
  16023. this.topLeftCornerOverlay = _base2.default.createOverlay(_base2.default.CLONE_TOP_LEFT_CORNER, this.wot);
  16024. }
  16025. }
  16026. if (this.bottomOverlay.needFullRender && this.leftOverlay.needFullRender) {
  16027. if (this.bottomLeftCornerOverlay) {
  16028. syncScroll = this.bottomLeftCornerOverlay.updateStateOfRendering() || syncScroll;
  16029. } else {
  16030. this.bottomLeftCornerOverlay = _base2.default.createOverlay(_base2.default.CLONE_BOTTOM_LEFT_CORNER, this.wot);
  16031. }
  16032. }
  16033. if (this.wot.getSetting('debug') && !this.debug) {
  16034. this.debug = _base2.default.createOverlay(_base2.default.CLONE_DEBUG, this.wot);
  16035. }
  16036. return syncScroll;
  16037. }
  16038. /**
  16039. * Refresh and redraw table
  16040. */
  16041. }, {
  16042. key: 'refreshAll',
  16043. value: function refreshAll() {
  16044. if (!this.wot.drawn) {
  16045. return;
  16046. }
  16047. if (!this.wot.wtTable.holder.parentNode) {
  16048. // Walkontable was detached from DOM, but this handler was not removed
  16049. this.destroy();
  16050. return;
  16051. }
  16052. this.wot.draw(true);
  16053. if (this.verticalScrolling) {
  16054. this.leftOverlay.onScroll();
  16055. }
  16056. if (this.horizontalScrolling) {
  16057. this.topOverlay.onScroll();
  16058. }
  16059. this.verticalScrolling = false;
  16060. this.horizontalScrolling = false;
  16061. }
  16062. /**
  16063. * Register all necessary event listeners.
  16064. */
  16065. }, {
  16066. key: 'registerListeners',
  16067. value: function registerListeners() {
  16068. var _this = this;
  16069. var topOverlayScrollable = this.topOverlay.mainTableScrollableElement;
  16070. var leftOverlayScrollable = this.leftOverlay.mainTableScrollableElement;
  16071. var listenersToRegister = [];
  16072. listenersToRegister.push([document.documentElement, 'keydown', function (event) {
  16073. return _this.onKeyDown(event);
  16074. }]);
  16075. listenersToRegister.push([document.documentElement, 'keyup', function () {
  16076. return _this.onKeyUp();
  16077. }]);
  16078. listenersToRegister.push([document, 'visibilitychange', function () {
  16079. return _this.onKeyUp();
  16080. }]);
  16081. listenersToRegister.push([topOverlayScrollable, 'scroll', function (event) {
  16082. return _this.onTableScroll(event);
  16083. }]);
  16084. if (topOverlayScrollable !== leftOverlayScrollable) {
  16085. listenersToRegister.push([leftOverlayScrollable, 'scroll', function (event) {
  16086. return _this.onTableScroll(event);
  16087. }]);
  16088. }
  16089. var isHighPixelRatio = window.devicePixelRatio && window.devicePixelRatio > 1;
  16090. if (isHighPixelRatio || !(0, _browser.isChrome)()) {
  16091. listenersToRegister.push([this.instance.wtTable.wtRootElement.parentNode, 'wheel', function (event) {
  16092. return _this.onCloneWheel(event);
  16093. }]);
  16094. } else {
  16095. if (this.topOverlay.needFullRender) {
  16096. listenersToRegister.push([this.topOverlay.clone.wtTable.holder, 'wheel', function (event) {
  16097. return _this.onCloneWheel(event);
  16098. }]);
  16099. }
  16100. if (this.bottomOverlay.needFullRender) {
  16101. listenersToRegister.push([this.bottomOverlay.clone.wtTable.holder, 'wheel', function (event) {
  16102. return _this.onCloneWheel(event);
  16103. }]);
  16104. }
  16105. if (this.leftOverlay.needFullRender) {
  16106. listenersToRegister.push([this.leftOverlay.clone.wtTable.holder, 'wheel', function (event) {
  16107. return _this.onCloneWheel(event);
  16108. }]);
  16109. }
  16110. if (this.topLeftCornerOverlay && this.topLeftCornerOverlay.needFullRender) {
  16111. listenersToRegister.push([this.topLeftCornerOverlay.clone.wtTable.holder, 'wheel', function (event) {
  16112. return _this.onCloneWheel(event);
  16113. }]);
  16114. }
  16115. if (this.bottomLeftCornerOverlay && this.bottomLeftCornerOverlay.needFullRender) {
  16116. listenersToRegister.push([this.bottomLeftCornerOverlay.clone.wtTable.holder, 'wheel', function (event) {
  16117. return _this.onCloneWheel(event);
  16118. }]);
  16119. }
  16120. }
  16121. if (this.topOverlay.trimmingContainer !== window && this.leftOverlay.trimmingContainer !== window) {
  16122. // This is necessary?
  16123. // eventManager.addEventListener(window, 'scroll', (event) => this.refreshAll(event));
  16124. listenersToRegister.push([window, 'wheel', function (event) {
  16125. var overlay = void 0;
  16126. var deltaY = event.wheelDeltaY || event.deltaY;
  16127. var deltaX = event.wheelDeltaX || event.deltaX;
  16128. if (_this.topOverlay.clone.wtTable.holder.contains(event.realTarget)) {
  16129. overlay = 'top';
  16130. } else if (_this.bottomOverlay.clone && _this.bottomOverlay.clone.wtTable.holder.contains(event.realTarget)) {
  16131. overlay = 'bottom';
  16132. } else if (_this.leftOverlay.clone.wtTable.holder.contains(event.realTarget)) {
  16133. overlay = 'left';
  16134. } else if (_this.topLeftCornerOverlay && _this.topLeftCornerOverlay.clone && _this.topLeftCornerOverlay.clone.wtTable.holder.contains(event.realTarget)) {
  16135. overlay = 'topLeft';
  16136. } else if (_this.bottomLeftCornerOverlay && _this.bottomLeftCornerOverlay.clone && _this.bottomLeftCornerOverlay.clone.wtTable.holder.contains(event.realTarget)) {
  16137. overlay = 'bottomLeft';
  16138. }
  16139. if (overlay === 'top' && deltaY !== 0 || overlay === 'left' && deltaX !== 0 || overlay === 'bottom' && deltaY !== 0 || (overlay === 'topLeft' || overlay === 'bottomLeft') && (deltaY !== 0 || deltaX !== 0)) {
  16140. event.preventDefault();
  16141. }
  16142. }]);
  16143. }
  16144. while (listenersToRegister.length) {
  16145. var listener = listenersToRegister.pop();
  16146. this.eventManager.addEventListener(listener[0], listener[1], listener[2]);
  16147. this.registeredListeners.push(listener);
  16148. }
  16149. }
  16150. /**
  16151. * Deregister all previously registered listeners.
  16152. */
  16153. }, {
  16154. key: 'deregisterListeners',
  16155. value: function deregisterListeners() {
  16156. while (this.registeredListeners.length) {
  16157. var listener = this.registeredListeners.pop();
  16158. this.eventManager.removeEventListener(listener[0], listener[1], listener[2]);
  16159. }
  16160. }
  16161. /**
  16162. * Scroll listener
  16163. *
  16164. * @param {Event} event
  16165. */
  16166. }, {
  16167. key: 'onTableScroll',
  16168. value: function onTableScroll(event) {
  16169. // There was if statement which controlled flow of this function. It avoided the execution of the next lines
  16170. // on mobile devices. It was changed. Broader description of this case is included within issue #4856.
  16171. var masterHorizontal = this.leftOverlay.mainTableScrollableElement;
  16172. var masterVertical = this.topOverlay.mainTableScrollableElement;
  16173. var target = event.target;
  16174. // For key press, sync only master -> overlay position because while pressing Walkontable.render is triggered
  16175. // by hot.refreshBorder
  16176. if (this.keyPressed) {
  16177. if (masterVertical !== window && target !== window && !event.target.contains(masterVertical) || masterHorizontal !== window && target !== window && !event.target.contains(masterHorizontal)) {
  16178. return;
  16179. }
  16180. }
  16181. this.syncScrollPositions(event);
  16182. }
  16183. /**
  16184. * Wheel listener for cloned overlays.
  16185. *
  16186. * @param {Event} event
  16187. */
  16188. }, {
  16189. key: 'onCloneWheel',
  16190. value: function onCloneWheel(event) {
  16191. if (this.scrollableElement !== window) {
  16192. event.preventDefault();
  16193. }
  16194. // There was if statement which controlled flow of this function. It avoided the execution of the next lines
  16195. // on mobile devices. It was changed. Broader description of this case is included within issue #4856.
  16196. var masterHorizontal = this.leftOverlay.mainTableScrollableElement;
  16197. var masterVertical = this.topOverlay.mainTableScrollableElement;
  16198. var target = event.target;
  16199. // For key press, sync only master -> overlay position because while pressing Walkontable.render is triggered
  16200. // by hot.refreshBorder
  16201. var shouldNotWheelVertically = masterVertical !== window && target !== window && !event.target.contains(masterVertical);
  16202. var shouldNotWheelHorizontally = masterHorizontal !== window && target !== window && !event.target.contains(masterHorizontal);
  16203. if (this.keyPressed && (shouldNotWheelVertically || shouldNotWheelHorizontally)) {
  16204. return;
  16205. }
  16206. this.translateMouseWheelToScroll(event);
  16207. }
  16208. /**
  16209. * Key down listener
  16210. */
  16211. }, {
  16212. key: 'onKeyDown',
  16213. value: function onKeyDown(event) {
  16214. this.keyPressed = (0, _unicode.isKey)(event.keyCode, 'ARROW_UP|ARROW_RIGHT|ARROW_DOWN|ARROW_LEFT');
  16215. }
  16216. /**
  16217. * Key up listener
  16218. */
  16219. }, {
  16220. key: 'onKeyUp',
  16221. value: function onKeyUp() {
  16222. this.keyPressed = false;
  16223. }
  16224. /**
  16225. * Translate wheel event into scroll event and sync scroll overlays position
  16226. *
  16227. * @private
  16228. * @param {Event} event
  16229. * @returns {Boolean}
  16230. */
  16231. }, {
  16232. key: 'translateMouseWheelToScroll',
  16233. value: function translateMouseWheelToScroll(event) {
  16234. var deltaY = isNaN(event.deltaY) ? -1 * event.wheelDeltaY : event.deltaY;
  16235. var deltaX = isNaN(event.deltaX) ? -1 * event.wheelDeltaX : event.deltaX;
  16236. if (event.deltaMode === 1) {
  16237. deltaX += deltaX * this.browserLineHeight;
  16238. deltaY += deltaY * this.browserLineHeight;
  16239. }
  16240. this.scrollVertically(deltaY);
  16241. this.scrollHorizontally(deltaX);
  16242. return false;
  16243. }
  16244. }, {
  16245. key: 'scrollVertically',
  16246. value: function scrollVertically(distance) {
  16247. if (distance === 0) {
  16248. return 0;
  16249. }
  16250. this.scrollableElement.scrollTop += distance;
  16251. }
  16252. }, {
  16253. key: 'scrollHorizontally',
  16254. value: function scrollHorizontally(distance) {
  16255. if (distance === 0) {
  16256. return 0;
  16257. }
  16258. this.scrollableElement.scrollLeft += distance;
  16259. }
  16260. /**
  16261. * Synchronize scroll position between master table and overlay table.
  16262. *
  16263. * @private
  16264. * @param {Event|Object} event
  16265. */
  16266. }, {
  16267. key: 'syncScrollPositions',
  16268. value: function syncScrollPositions(event) {
  16269. if (this.destroyed) {
  16270. return;
  16271. }
  16272. var topHolder = this.topOverlay.clone.wtTable.holder;
  16273. var leftHolder = this.leftOverlay.clone.wtTable.holder;
  16274. var _ref = [this.scrollableElement.scrollLeft, this.scrollableElement.scrollTop],
  16275. scrollLeft = _ref[0],
  16276. scrollTop = _ref[1];
  16277. this.horizontalScrolling = topHolder.scrollLeft !== scrollLeft;
  16278. this.verticalScrolling = leftHolder.scrollTop !== scrollTop;
  16279. if (this.horizontalScrolling) {
  16280. topHolder.scrollLeft = scrollLeft;
  16281. }
  16282. if (this.verticalScrolling) {
  16283. leftHolder.scrollTop = scrollTop;
  16284. if (this.bottomOverlay.needFullRender) {
  16285. this.bottomOverlay.clone.wtTable.holder.scrollLeft = scrollLeft;
  16286. }
  16287. }
  16288. this.refreshAll();
  16289. }
  16290. /**
  16291. * Synchronize overlay scrollbars with the master scrollbar
  16292. */
  16293. }, {
  16294. key: 'syncScrollWithMaster',
  16295. value: function syncScrollWithMaster() {
  16296. var master = this.topOverlay.mainTableScrollableElement;
  16297. var scrollLeft = master.scrollLeft,
  16298. scrollTop = master.scrollTop;
  16299. if (this.topOverlay.needFullRender) {
  16300. this.topOverlay.clone.wtTable.holder.scrollLeft = scrollLeft;
  16301. }
  16302. if (this.bottomOverlay.needFullRender) {
  16303. this.bottomOverlay.clone.wtTable.holder.scrollLeft = scrollLeft;
  16304. }
  16305. if (this.leftOverlay.needFullRender) {
  16306. this.leftOverlay.clone.wtTable.holder.scrollTop = scrollTop;
  16307. }
  16308. }
  16309. /**
  16310. * Update the main scrollable elements for all the overlays.
  16311. */
  16312. }, {
  16313. key: 'updateMainScrollableElements',
  16314. value: function updateMainScrollableElements() {
  16315. this.deregisterListeners();
  16316. this.leftOverlay.updateMainScrollableElement();
  16317. this.topOverlay.updateMainScrollableElement();
  16318. if (this.bottomOverlay.needFullRender) {
  16319. this.bottomOverlay.updateMainScrollableElement();
  16320. }
  16321. this.scrollableElement = (0, _element.getScrollableElement)(this.wot.wtTable.TABLE);
  16322. this.registerListeners();
  16323. }
  16324. /**
  16325. *
  16326. */
  16327. }, {
  16328. key: 'destroy',
  16329. value: function destroy() {
  16330. this.eventManager.destroy();
  16331. this.topOverlay.destroy();
  16332. if (this.bottomOverlay.clone) {
  16333. this.bottomOverlay.destroy();
  16334. }
  16335. this.leftOverlay.destroy();
  16336. if (this.topLeftCornerOverlay) {
  16337. this.topLeftCornerOverlay.destroy();
  16338. }
  16339. if (this.bottomLeftCornerOverlay && this.bottomLeftCornerOverlay.clone) {
  16340. this.bottomLeftCornerOverlay.destroy();
  16341. }
  16342. if (this.debug) {
  16343. this.debug.destroy();
  16344. }
  16345. this.destroyed = true;
  16346. }
  16347. /**
  16348. * @param {Boolean} [fastDraw=false]
  16349. */
  16350. }, {
  16351. key: 'refresh',
  16352. value: function refresh() {
  16353. var fastDraw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  16354. if (this.topOverlay.areElementSizesAdjusted && this.leftOverlay.areElementSizesAdjusted) {
  16355. var container = this.wot.wtTable.wtRootElement.parentNode || this.wot.wtTable.wtRootElement;
  16356. var width = container.clientWidth;
  16357. var height = container.clientHeight;
  16358. if (width !== this.spreaderLastSize.width || height !== this.spreaderLastSize.height) {
  16359. this.spreaderLastSize.width = width;
  16360. this.spreaderLastSize.height = height;
  16361. this.adjustElementsSize();
  16362. }
  16363. }
  16364. if (this.bottomOverlay.clone) {
  16365. this.bottomOverlay.refresh(fastDraw);
  16366. }
  16367. this.leftOverlay.refresh(fastDraw);
  16368. this.topOverlay.refresh(fastDraw);
  16369. if (this.topLeftCornerOverlay) {
  16370. this.topLeftCornerOverlay.refresh(fastDraw);
  16371. }
  16372. if (this.bottomLeftCornerOverlay && this.bottomLeftCornerOverlay.clone) {
  16373. this.bottomLeftCornerOverlay.refresh(fastDraw);
  16374. }
  16375. if (this.debug) {
  16376. this.debug.refresh(fastDraw);
  16377. }
  16378. }
  16379. /**
  16380. * Adjust overlays elements size and master table size
  16381. *
  16382. * @param {Boolean} [force=false]
  16383. */
  16384. }, {
  16385. key: 'adjustElementsSize',
  16386. value: function adjustElementsSize() {
  16387. var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  16388. var totalColumns = this.wot.getSetting('totalColumns');
  16389. var totalRows = this.wot.getSetting('totalRows');
  16390. var headerRowSize = this.wot.wtViewport.getRowHeaderWidth();
  16391. var headerColumnSize = this.wot.wtViewport.getColumnHeaderHeight();
  16392. var hiderStyle = this.wot.wtTable.hider.style;
  16393. hiderStyle.width = headerRowSize + this.leftOverlay.sumCellSizes(0, totalColumns) + 'px';
  16394. hiderStyle.height = headerColumnSize + this.topOverlay.sumCellSizes(0, totalRows) + 1 + 'px';
  16395. this.topOverlay.adjustElementsSize(force);
  16396. this.leftOverlay.adjustElementsSize(force);
  16397. if (this.bottomOverlay.clone) {
  16398. this.bottomOverlay.adjustElementsSize(force);
  16399. }
  16400. }
  16401. /**
  16402. *
  16403. */
  16404. }, {
  16405. key: 'applyToDOM',
  16406. value: function applyToDOM() {
  16407. if (!this.topOverlay.areElementSizesAdjusted || !this.leftOverlay.areElementSizesAdjusted) {
  16408. this.adjustElementsSize();
  16409. }
  16410. this.topOverlay.applyToDOM();
  16411. if (this.bottomOverlay.clone) {
  16412. this.bottomOverlay.applyToDOM();
  16413. }
  16414. this.leftOverlay.applyToDOM();
  16415. }
  16416. /**
  16417. * Get the parent overlay of the provided element.
  16418. *
  16419. * @param {HTMLElement} element
  16420. * @returns {Object|null}
  16421. */
  16422. }, {
  16423. key: 'getParentOverlay',
  16424. value: function getParentOverlay(element) {
  16425. if (!element) {
  16426. return null;
  16427. }
  16428. var overlays = [this.topOverlay, this.leftOverlay, this.bottomOverlay, this.topLeftCornerOverlay, this.bottomLeftCornerOverlay];
  16429. var result = null;
  16430. (0, _array.arrayEach)(overlays, function (elem, i) {
  16431. if (!elem) {
  16432. return;
  16433. }
  16434. if (elem.clone && elem.clone.wtTable.TABLE.contains(element)) {
  16435. result = elem.clone;
  16436. }
  16437. });
  16438. return result;
  16439. }
  16440. }]);
  16441. return Overlays;
  16442. }();
  16443. exports.default = Overlays;
  16444. /***/ }),
  16445. /* 182 */
  16446. /***/ (function(module, exports, __webpack_require__) {
  16447. "use strict";
  16448. exports.__esModule = true;
  16449. 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; }; }();
  16450. var _element = __webpack_require__(0);
  16451. var _number = __webpack_require__(5);
  16452. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16453. /**
  16454. * @class Scroll
  16455. */
  16456. var Scroll = function () {
  16457. /**
  16458. * @param {Walkontable} wotInstance
  16459. */
  16460. function Scroll(wotInstance) {
  16461. _classCallCheck(this, Scroll);
  16462. this.wot = wotInstance;
  16463. // legacy support
  16464. this.instance = wotInstance;
  16465. }
  16466. /**
  16467. * Scrolls viewport to a cell by minimum number of cells
  16468. *
  16469. * @param {CellCoords} coords
  16470. */
  16471. _createClass(Scroll, [{
  16472. key: 'scrollViewport',
  16473. value: function scrollViewport(coords) {
  16474. if (!this.wot.drawn) {
  16475. return;
  16476. }
  16477. var _getVariables2 = this._getVariables(),
  16478. topOverlay = _getVariables2.topOverlay,
  16479. leftOverlay = _getVariables2.leftOverlay,
  16480. totalRows = _getVariables2.totalRows,
  16481. totalColumns = _getVariables2.totalColumns,
  16482. fixedRowsTop = _getVariables2.fixedRowsTop,
  16483. fixedRowsBottom = _getVariables2.fixedRowsBottom,
  16484. fixedColumnsLeft = _getVariables2.fixedColumnsLeft;
  16485. if (coords.row < 0 || coords.row > Math.max(totalRows - 1, 0)) {
  16486. throw new Error('row ' + coords.row + ' does not exist');
  16487. }
  16488. if (coords.col < 0 || coords.col > Math.max(totalColumns - 1, 0)) {
  16489. throw new Error('column ' + coords.col + ' does not exist');
  16490. }
  16491. if (coords.row >= fixedRowsTop && coords.row < this.getFirstVisibleRow()) {
  16492. topOverlay.scrollTo(coords.row);
  16493. } else if (coords.row > this.getLastVisibleRow() && coords.row < totalRows - fixedRowsBottom) {
  16494. topOverlay.scrollTo(coords.row, true);
  16495. }
  16496. if (coords.col >= fixedColumnsLeft && coords.col < this.getFirstVisibleColumn()) {
  16497. leftOverlay.scrollTo(coords.col);
  16498. } else if (coords.col > this.getLastVisibleColumn()) {
  16499. leftOverlay.scrollTo(coords.col, true);
  16500. }
  16501. }
  16502. /**
  16503. * Get first visible row based on virtual dom and how table is visible in browser window viewport.
  16504. *
  16505. * @returns {Number}
  16506. */
  16507. }, {
  16508. key: 'getFirstVisibleRow',
  16509. value: function getFirstVisibleRow() {
  16510. var _getVariables3 = this._getVariables(),
  16511. topOverlay = _getVariables3.topOverlay,
  16512. wtTable = _getVariables3.wtTable,
  16513. wtViewport = _getVariables3.wtViewport,
  16514. totalRows = _getVariables3.totalRows,
  16515. fixedRowsTop = _getVariables3.fixedRowsTop;
  16516. var firstVisibleRow = wtTable.getFirstVisibleRow();
  16517. if (topOverlay.mainTableScrollableElement === window) {
  16518. var rootElementOffset = (0, _element.offset)(wtTable.wtRootElement);
  16519. var totalTableHeight = (0, _element.innerHeight)(wtTable.hider);
  16520. var windowHeight = (0, _element.innerHeight)(window);
  16521. var windowScrollTop = (0, _element.getScrollTop)(window);
  16522. // Only calculate firstVisibleRow when table didn't filled (from up) whole viewport space
  16523. if (rootElementOffset.top + totalTableHeight - windowHeight <= windowScrollTop) {
  16524. var rowsHeight = wtViewport.getColumnHeaderHeight();
  16525. rowsHeight += topOverlay.sumCellSizes(0, fixedRowsTop);
  16526. (0, _number.rangeEachReverse)(totalRows, 1, function (row) {
  16527. rowsHeight += topOverlay.sumCellSizes(row - 1, row);
  16528. if (rootElementOffset.top + totalTableHeight - rowsHeight <= windowScrollTop) {
  16529. // Return physical row + 1
  16530. firstVisibleRow = row;
  16531. return false;
  16532. }
  16533. });
  16534. }
  16535. }
  16536. return firstVisibleRow;
  16537. }
  16538. /**
  16539. * Get last visible row based on virtual dom and how table is visible in browser window viewport.
  16540. *
  16541. * @returns {Number}
  16542. */
  16543. }, {
  16544. key: 'getLastVisibleRow',
  16545. value: function getLastVisibleRow() {
  16546. var _getVariables4 = this._getVariables(),
  16547. topOverlay = _getVariables4.topOverlay,
  16548. wtTable = _getVariables4.wtTable,
  16549. wtViewport = _getVariables4.wtViewport,
  16550. totalRows = _getVariables4.totalRows;
  16551. var lastVisibleRow = wtTable.getLastVisibleRow();
  16552. if (topOverlay.mainTableScrollableElement === window) {
  16553. var rootElementOffset = (0, _element.offset)(wtTable.wtRootElement);
  16554. var windowHeight = (0, _element.innerHeight)(window);
  16555. var windowScrollTop = (0, _element.getScrollTop)(window);
  16556. // Only calculate lastVisibleRow when table didn't filled (from bottom) whole viewport space
  16557. if (rootElementOffset.top > windowScrollTop) {
  16558. var rowsHeight = wtViewport.getColumnHeaderHeight();
  16559. (0, _number.rangeEach)(1, totalRows, function (row) {
  16560. rowsHeight += topOverlay.sumCellSizes(row - 1, row);
  16561. if (rootElementOffset.top + rowsHeight - windowScrollTop >= windowHeight) {
  16562. // Return physical row - 1 (-2 because rangeEach gives row index + 1 - sumCellSizes requirements)
  16563. lastVisibleRow = row - 2;
  16564. return false;
  16565. }
  16566. });
  16567. }
  16568. }
  16569. return lastVisibleRow;
  16570. }
  16571. /**
  16572. * Get first visible column based on virtual dom and how table is visible in browser window viewport.
  16573. *
  16574. * @returns {Number}
  16575. */
  16576. }, {
  16577. key: 'getFirstVisibleColumn',
  16578. value: function getFirstVisibleColumn() {
  16579. var _getVariables5 = this._getVariables(),
  16580. leftOverlay = _getVariables5.leftOverlay,
  16581. wtTable = _getVariables5.wtTable,
  16582. wtViewport = _getVariables5.wtViewport,
  16583. totalColumns = _getVariables5.totalColumns,
  16584. fixedColumnsLeft = _getVariables5.fixedColumnsLeft;
  16585. var firstVisibleColumn = wtTable.getFirstVisibleColumn();
  16586. if (leftOverlay.mainTableScrollableElement === window) {
  16587. var rootElementOffset = (0, _element.offset)(wtTable.wtRootElement);
  16588. var totalTableWidth = (0, _element.innerWidth)(wtTable.hider);
  16589. var windowWidth = (0, _element.innerWidth)(window);
  16590. var windowScrollLeft = (0, _element.getScrollLeft)(window);
  16591. // Only calculate firstVisibleColumn when table didn't filled (from left) whole viewport space
  16592. if (rootElementOffset.left + totalTableWidth - windowWidth <= windowScrollLeft) {
  16593. var columnsWidth = wtViewport.getRowHeaderWidth();
  16594. (0, _number.rangeEachReverse)(totalColumns, 1, function (column) {
  16595. columnsWidth += leftOverlay.sumCellSizes(column - 1, column);
  16596. if (rootElementOffset.left + totalTableWidth - columnsWidth <= windowScrollLeft) {
  16597. // Return physical column + 1
  16598. firstVisibleColumn = column;
  16599. return false;
  16600. }
  16601. });
  16602. }
  16603. }
  16604. return firstVisibleColumn;
  16605. }
  16606. /**
  16607. * Get last visible column based on virtual dom and how table is visible in browser window viewport.
  16608. *
  16609. * @returns {Number}
  16610. */
  16611. }, {
  16612. key: 'getLastVisibleColumn',
  16613. value: function getLastVisibleColumn() {
  16614. var _getVariables6 = this._getVariables(),
  16615. leftOverlay = _getVariables6.leftOverlay,
  16616. wtTable = _getVariables6.wtTable,
  16617. wtViewport = _getVariables6.wtViewport,
  16618. totalColumns = _getVariables6.totalColumns;
  16619. var lastVisibleColumn = wtTable.getLastVisibleColumn();
  16620. if (leftOverlay.mainTableScrollableElement === window) {
  16621. var rootElementOffset = (0, _element.offset)(wtTable.wtRootElement);
  16622. var windowWidth = (0, _element.innerWidth)(window);
  16623. var windowScrollLeft = (0, _element.getScrollLeft)(window);
  16624. // Only calculate lastVisibleColumn when table didn't filled (from right) whole viewport space
  16625. if (rootElementOffset.left > windowScrollLeft) {
  16626. var columnsWidth = wtViewport.getRowHeaderWidth();
  16627. (0, _number.rangeEach)(1, totalColumns, function (column) {
  16628. columnsWidth += leftOverlay.sumCellSizes(column - 1, column);
  16629. if (rootElementOffset.left + columnsWidth - windowScrollLeft >= windowWidth) {
  16630. // Return physical column - 1 (-2 because rangeEach gives column index + 1 - sumCellSizes requirements)
  16631. lastVisibleColumn = column - 2;
  16632. return false;
  16633. }
  16634. });
  16635. }
  16636. }
  16637. return lastVisibleColumn;
  16638. }
  16639. /**
  16640. * Returns collection of variables used to rows and columns visibility calculations.
  16641. *
  16642. * @returns {Object}
  16643. * @private
  16644. */
  16645. }, {
  16646. key: '_getVariables',
  16647. value: function _getVariables() {
  16648. var wot = this.wot;
  16649. var topOverlay = wot.wtOverlays.topOverlay;
  16650. var leftOverlay = wot.wtOverlays.leftOverlay;
  16651. var wtTable = wot.wtTable;
  16652. var wtViewport = wot.wtViewport;
  16653. var totalRows = wot.getSetting('totalRows');
  16654. var totalColumns = wot.getSetting('totalColumns');
  16655. var fixedRowsTop = wot.getSetting('fixedRowsTop');
  16656. var fixedRowsBottom = wot.getSetting('fixedRowsBottom');
  16657. var fixedColumnsLeft = wot.getSetting('fixedColumnsLeft');
  16658. return {
  16659. topOverlay: topOverlay,
  16660. leftOverlay: leftOverlay,
  16661. wtTable: wtTable,
  16662. wtViewport: wtViewport,
  16663. totalRows: totalRows,
  16664. totalColumns: totalColumns,
  16665. fixedRowsTop: fixedRowsTop,
  16666. fixedRowsBottom: fixedRowsBottom,
  16667. fixedColumnsLeft: fixedColumnsLeft
  16668. };
  16669. }
  16670. }]);
  16671. return Scroll;
  16672. }();
  16673. exports.default = Scroll;
  16674. /***/ }),
  16675. /* 183 */
  16676. /***/ (function(module, exports, __webpack_require__) {
  16677. "use strict";
  16678. exports.__esModule = true;
  16679. 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; }; }();
  16680. var _element = __webpack_require__(0);
  16681. var _object = __webpack_require__(2);
  16682. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16683. /**
  16684. * @class Settings
  16685. */
  16686. var Settings = function () {
  16687. /**
  16688. * @param {Walkontable} wotInstance
  16689. * @param {Object} settings
  16690. */
  16691. function Settings(wotInstance, settings) {
  16692. var _this = this;
  16693. _classCallCheck(this, Settings);
  16694. this.wot = wotInstance;
  16695. // legacy support
  16696. this.instance = wotInstance;
  16697. // default settings. void 0 means it is required, null means it can be empty
  16698. this.defaults = {
  16699. table: void 0,
  16700. debug: false, // shows WalkontableDebugOverlay
  16701. // presentation mode
  16702. externalRowCalculator: false,
  16703. stretchH: 'none', // values: all, last, none
  16704. currentRowClassName: null,
  16705. currentColumnClassName: null,
  16706. preventOverflow: function preventOverflow() {
  16707. return false;
  16708. },
  16709. // data source
  16710. data: void 0,
  16711. freezeOverlays: false,
  16712. fixedColumnsLeft: 0,
  16713. fixedRowsTop: 0,
  16714. fixedRowsBottom: 0,
  16715. minSpareRows: 0,
  16716. // this must be array of functions: [function (row, TH) {}]
  16717. rowHeaders: function rowHeaders() {
  16718. return [];
  16719. },
  16720. // this must be array of functions: [function (column, TH) {}]
  16721. columnHeaders: function columnHeaders() {
  16722. return [];
  16723. },
  16724. totalRows: void 0,
  16725. totalColumns: void 0,
  16726. cellRenderer: function cellRenderer(row, column, TD) {
  16727. var cellData = _this.getSetting('data', row, column);
  16728. (0, _element.fastInnerText)(TD, cellData === void 0 || cellData === null ? '' : cellData);
  16729. },
  16730. // columnWidth: 50,
  16731. columnWidth: function columnWidth(col) {
  16732. // return undefined means use default size for the rendered cell content
  16733. },
  16734. rowHeight: function rowHeight(row) {
  16735. // return undefined means use default size for the rendered cell content
  16736. },
  16737. defaultRowHeight: 23,
  16738. defaultColumnWidth: 50,
  16739. selections: null,
  16740. hideBorderOnMouseDownOver: false,
  16741. viewportRowCalculatorOverride: null,
  16742. viewportColumnCalculatorOverride: null,
  16743. // callbacks
  16744. onCellMouseDown: null,
  16745. onCellMouseOver: null,
  16746. onCellMouseOut: null,
  16747. onCellMouseUp: null,
  16748. // onCellMouseOut: null,
  16749. onCellDblClick: null,
  16750. onCellCornerMouseDown: null,
  16751. onCellCornerDblClick: null,
  16752. beforeDraw: null,
  16753. onDraw: null,
  16754. onBeforeRemoveCellClassNames: null,
  16755. onAfterDrawSelection: null,
  16756. onBeforeDrawBorders: null,
  16757. onScrollVertically: null,
  16758. onScrollHorizontally: null,
  16759. onBeforeTouchScroll: null,
  16760. onAfterMomentumScroll: null,
  16761. onBeforeStretchingColumnWidth: function onBeforeStretchingColumnWidth(width) {
  16762. return width;
  16763. },
  16764. onModifyRowHeaderWidth: null,
  16765. onModifyGetCellCoords: null,
  16766. // constants
  16767. scrollbarWidth: 10,
  16768. scrollbarHeight: 10,
  16769. renderAllRows: false,
  16770. groups: false,
  16771. rowHeaderWidth: null,
  16772. columnHeaderHeight: null,
  16773. headerClassName: null
  16774. };
  16775. // reference to settings
  16776. this.settings = {};
  16777. for (var i in this.defaults) {
  16778. if ((0, _object.hasOwnProperty)(this.defaults, i)) {
  16779. if (settings[i] !== void 0) {
  16780. this.settings[i] = settings[i];
  16781. } else if (this.defaults[i] === void 0) {
  16782. throw new Error('A required setting "' + i + '" was not provided');
  16783. } else {
  16784. this.settings[i] = this.defaults[i];
  16785. }
  16786. }
  16787. }
  16788. }
  16789. /**
  16790. * Update settings
  16791. *
  16792. * @param {Object} settings
  16793. * @param {*} value
  16794. * @returns {Walkontable}
  16795. */
  16796. _createClass(Settings, [{
  16797. key: 'update',
  16798. value: function update(settings, value) {
  16799. if (value === void 0) {
  16800. // settings is object
  16801. for (var i in settings) {
  16802. if ((0, _object.hasOwnProperty)(settings, i)) {
  16803. this.settings[i] = settings[i];
  16804. }
  16805. }
  16806. } else {
  16807. // if value is defined then settings is the key
  16808. this.settings[settings] = value;
  16809. }
  16810. return this.wot;
  16811. }
  16812. /**
  16813. * Get setting by name
  16814. *
  16815. * @param {String} key
  16816. * @param {*} param1
  16817. * @param {*} param2
  16818. * @param {*} param3
  16819. * @param {*} param4
  16820. * @returns {*}
  16821. */
  16822. }, {
  16823. key: 'getSetting',
  16824. value: function getSetting(key, param1, param2, param3, param4) {
  16825. if (typeof this.settings[key] === 'function') {
  16826. // this is faster than .apply - https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips
  16827. return this.settings[key](param1, param2, param3, param4);
  16828. } else if (param1 !== void 0 && Array.isArray(this.settings[key])) {
  16829. // perhaps this can be removed, it is only used in tests
  16830. return this.settings[key][param1];
  16831. }
  16832. return this.settings[key];
  16833. }
  16834. /**
  16835. * Checks if setting exists
  16836. *
  16837. * @param {Boolean} key
  16838. * @returns {Boolean}
  16839. */
  16840. }, {
  16841. key: 'has',
  16842. value: function has(key) {
  16843. return !!this.settings[key];
  16844. }
  16845. }]);
  16846. return Settings;
  16847. }();
  16848. exports.default = Settings;
  16849. /***/ }),
  16850. /* 184 */
  16851. /***/ (function(module, exports, __webpack_require__) {
  16852. "use strict";
  16853. exports.__esModule = true;
  16854. 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; };
  16855. 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"); } }; }();
  16856. 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; }; }();
  16857. var _element = __webpack_require__(0);
  16858. var _function = __webpack_require__(42);
  16859. var _coords = __webpack_require__(54);
  16860. var _coords2 = _interopRequireDefault(_coords);
  16861. var _range = __webpack_require__(86);
  16862. var _range2 = _interopRequireDefault(_range);
  16863. var _column = __webpack_require__(177);
  16864. var _column2 = _interopRequireDefault(_column);
  16865. var _row = __webpack_require__(178);
  16866. var _row2 = _interopRequireDefault(_row);
  16867. var _tableRenderer = __webpack_require__(185);
  16868. var _tableRenderer2 = _interopRequireDefault(_tableRenderer);
  16869. var _base = __webpack_require__(35);
  16870. var _base2 = _interopRequireDefault(_base);
  16871. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  16872. 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); } }
  16873. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16874. /**
  16875. *
  16876. */
  16877. var Table = function () {
  16878. /**
  16879. * @param {Walkontable} wotInstance
  16880. * @param {HTMLTableElement} table
  16881. */
  16882. function Table(wotInstance, table) {
  16883. var _this = this;
  16884. _classCallCheck(this, Table);
  16885. this.wot = wotInstance;
  16886. // legacy support
  16887. this.instance = this.wot;
  16888. this.TABLE = table;
  16889. this.TBODY = null;
  16890. this.THEAD = null;
  16891. this.COLGROUP = null;
  16892. this.tableOffset = 0;
  16893. this.holderOffset = 0;
  16894. (0, _element.removeTextNodes)(this.TABLE);
  16895. this.spreader = this.createSpreader(this.TABLE);
  16896. this.hider = this.createHider(this.spreader);
  16897. this.holder = this.createHolder(this.hider);
  16898. this.wtRootElement = this.holder.parentNode;
  16899. this.alignOverlaysWithTrimmingContainer();
  16900. this.fixTableDomTree();
  16901. this.colgroupChildrenLength = this.COLGROUP.childNodes.length;
  16902. this.theadChildrenLength = this.THEAD.firstChild ? this.THEAD.firstChild.childNodes.length : 0;
  16903. this.tbodyChildrenLength = this.TBODY.childNodes.length;
  16904. this.rowFilter = null;
  16905. this.columnFilter = null;
  16906. this.correctHeaderWidth = false;
  16907. var origRowHeaderWidth = this.wot.wtSettings.settings.rowHeaderWidth;
  16908. // Fix for jumping row headers (https://github.com/handsontable/handsontable/issues/3850)
  16909. this.wot.wtSettings.settings.rowHeaderWidth = function () {
  16910. return _this._modifyRowHeaderWidth(origRowHeaderWidth);
  16911. };
  16912. }
  16913. /**
  16914. *
  16915. */
  16916. _createClass(Table, [{
  16917. key: 'fixTableDomTree',
  16918. value: function fixTableDomTree() {
  16919. this.TBODY = this.TABLE.querySelector('tbody');
  16920. if (!this.TBODY) {
  16921. this.TBODY = document.createElement('tbody');
  16922. this.TABLE.appendChild(this.TBODY);
  16923. }
  16924. this.THEAD = this.TABLE.querySelector('thead');
  16925. if (!this.THEAD) {
  16926. this.THEAD = document.createElement('thead');
  16927. this.TABLE.insertBefore(this.THEAD, this.TBODY);
  16928. }
  16929. this.COLGROUP = this.TABLE.querySelector('colgroup');
  16930. if (!this.COLGROUP) {
  16931. this.COLGROUP = document.createElement('colgroup');
  16932. this.TABLE.insertBefore(this.COLGROUP, this.THEAD);
  16933. }
  16934. if (this.wot.getSetting('columnHeaders').length && !this.THEAD.childNodes.length) {
  16935. this.THEAD.appendChild(document.createElement('TR'));
  16936. }
  16937. }
  16938. /**
  16939. * @param table
  16940. * @returns {HTMLElement}
  16941. */
  16942. }, {
  16943. key: 'createSpreader',
  16944. value: function createSpreader(table) {
  16945. var parent = table.parentNode;
  16946. var spreader = void 0;
  16947. if (!parent || parent.nodeType !== 1 || !(0, _element.hasClass)(parent, 'wtHolder')) {
  16948. spreader = document.createElement('div');
  16949. spreader.className = 'wtSpreader';
  16950. if (parent) {
  16951. // if TABLE is detached (e.g. in Jasmine test), it has no parentNode so we cannot attach holder to it
  16952. parent.insertBefore(spreader, table);
  16953. }
  16954. spreader.appendChild(table);
  16955. }
  16956. spreader.style.position = 'relative';
  16957. return spreader;
  16958. }
  16959. /**
  16960. * @param spreader
  16961. * @returns {HTMLElement}
  16962. */
  16963. }, {
  16964. key: 'createHider',
  16965. value: function createHider(spreader) {
  16966. var parent = spreader.parentNode;
  16967. var hider = void 0;
  16968. if (!parent || parent.nodeType !== 1 || !(0, _element.hasClass)(parent, 'wtHolder')) {
  16969. hider = document.createElement('div');
  16970. hider.className = 'wtHider';
  16971. if (parent) {
  16972. // if TABLE is detached (e.g. in Jasmine test), it has no parentNode so we cannot attach holder to it
  16973. parent.insertBefore(hider, spreader);
  16974. }
  16975. hider.appendChild(spreader);
  16976. }
  16977. return hider;
  16978. }
  16979. /**
  16980. *
  16981. * @param hider
  16982. * @returns {HTMLElement}
  16983. */
  16984. }, {
  16985. key: 'createHolder',
  16986. value: function createHolder(hider) {
  16987. var parent = hider.parentNode;
  16988. var holder = void 0;
  16989. if (!parent || parent.nodeType !== 1 || !(0, _element.hasClass)(parent, 'wtHolder')) {
  16990. holder = document.createElement('div');
  16991. holder.style.position = 'relative';
  16992. holder.className = 'wtHolder';
  16993. if (parent) {
  16994. // if TABLE is detached (e.g. in Jasmine test), it has no parentNode so we cannot attach holder to it
  16995. parent.insertBefore(holder, hider);
  16996. }
  16997. if (!this.isWorkingOnClone()) {
  16998. holder.parentNode.className += 'ht_master handsontable';
  16999. }
  17000. holder.appendChild(hider);
  17001. }
  17002. return holder;
  17003. }
  17004. }, {
  17005. key: 'alignOverlaysWithTrimmingContainer',
  17006. value: function alignOverlaysWithTrimmingContainer() {
  17007. var trimmingElement = (0, _element.getTrimmingContainer)(this.wtRootElement);
  17008. if (!this.isWorkingOnClone()) {
  17009. this.holder.parentNode.style.position = 'relative';
  17010. if (trimmingElement === window) {
  17011. var preventOverflow = this.wot.getSetting('preventOverflow');
  17012. if (!preventOverflow) {
  17013. this.holder.style.overflow = 'visible';
  17014. this.wtRootElement.style.overflow = 'visible';
  17015. }
  17016. } else {
  17017. this.holder.style.width = (0, _element.getStyle)(trimmingElement, 'width');
  17018. this.holder.style.height = (0, _element.getStyle)(trimmingElement, 'height');
  17019. this.holder.style.overflow = '';
  17020. }
  17021. }
  17022. }
  17023. }, {
  17024. key: 'isWorkingOnClone',
  17025. value: function isWorkingOnClone() {
  17026. return !!this.wot.cloneSource;
  17027. }
  17028. /**
  17029. * Redraws the table
  17030. *
  17031. * @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
  17032. * @returns {Table}
  17033. */
  17034. }, {
  17035. key: 'draw',
  17036. value: function draw(fastDraw) {
  17037. var _wot = this.wot,
  17038. wtOverlays = _wot.wtOverlays,
  17039. wtViewport = _wot.wtViewport;
  17040. var totalRows = this.instance.getSetting('totalRows');
  17041. var rowHeaders = this.wot.getSetting('rowHeaders').length;
  17042. var columnHeaders = this.wot.getSetting('columnHeaders').length;
  17043. var syncScroll = false;
  17044. if (!this.isWorkingOnClone()) {
  17045. this.holderOffset = (0, _element.offset)(this.holder);
  17046. fastDraw = wtViewport.createRenderCalculators(fastDraw);
  17047. if (rowHeaders && !this.wot.getSetting('fixedColumnsLeft')) {
  17048. var leftScrollPos = wtOverlays.leftOverlay.getScrollPosition();
  17049. var previousState = this.correctHeaderWidth;
  17050. this.correctHeaderWidth = leftScrollPos > 0;
  17051. if (previousState !== this.correctHeaderWidth) {
  17052. fastDraw = false;
  17053. }
  17054. }
  17055. }
  17056. if (!this.isWorkingOnClone()) {
  17057. syncScroll = wtOverlays.prepareOverlays();
  17058. }
  17059. if (fastDraw) {
  17060. if (!this.isWorkingOnClone()) {
  17061. // in case we only scrolled without redraw, update visible rows information in oldRowsCalculator
  17062. wtViewport.createVisibleCalculators();
  17063. }
  17064. if (wtOverlays) {
  17065. wtOverlays.refresh(true);
  17066. }
  17067. } else {
  17068. if (this.isWorkingOnClone()) {
  17069. this.tableOffset = this.wot.cloneSource.wtTable.tableOffset;
  17070. } else {
  17071. this.tableOffset = (0, _element.offset)(this.TABLE);
  17072. }
  17073. var startRow = void 0;
  17074. 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)) {
  17075. startRow = 0;
  17076. } else if (_base2.default.isOverlayTypeOf(this.instance.cloneOverlay, _base2.default.CLONE_BOTTOM) || _base2.default.isOverlayTypeOf(this.instance.cloneOverlay, _base2.default.CLONE_BOTTOM_LEFT_CORNER)) {
  17077. startRow = Math.max(totalRows - this.wot.getSetting('fixedRowsBottom'), 0);
  17078. } else {
  17079. startRow = wtViewport.rowsRenderCalculator.startRow;
  17080. }
  17081. var startColumn = void 0;
  17082. 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)) {
  17083. startColumn = 0;
  17084. } else {
  17085. startColumn = wtViewport.columnsRenderCalculator.startColumn;
  17086. }
  17087. this.rowFilter = new _row2.default(startRow, totalRows, columnHeaders);
  17088. this.columnFilter = new _column2.default(startColumn, this.wot.getSetting('totalColumns'), rowHeaders);
  17089. this.alignOverlaysWithTrimmingContainer();
  17090. this._doDraw(); // creates calculator after draw
  17091. }
  17092. this.refreshSelections(fastDraw);
  17093. if (!this.isWorkingOnClone()) {
  17094. wtOverlays.topOverlay.resetFixedPosition();
  17095. if (wtOverlays.bottomOverlay.clone) {
  17096. wtOverlays.bottomOverlay.resetFixedPosition();
  17097. }
  17098. wtOverlays.leftOverlay.resetFixedPosition();
  17099. if (wtOverlays.topLeftCornerOverlay) {
  17100. wtOverlays.topLeftCornerOverlay.resetFixedPosition();
  17101. }
  17102. if (wtOverlays.bottomLeftCornerOverlay && wtOverlays.bottomLeftCornerOverlay.clone) {
  17103. wtOverlays.bottomLeftCornerOverlay.resetFixedPosition();
  17104. }
  17105. }
  17106. if (syncScroll) {
  17107. wtOverlays.syncScrollWithMaster();
  17108. }
  17109. this.wot.drawn = true;
  17110. return this;
  17111. }
  17112. }, {
  17113. key: '_doDraw',
  17114. value: function _doDraw() {
  17115. var wtRenderer = new _tableRenderer2.default(this);
  17116. wtRenderer.render();
  17117. }
  17118. }, {
  17119. key: 'removeClassFromCells',
  17120. value: function removeClassFromCells(className) {
  17121. var nodes = this.TABLE.querySelectorAll('.' + className);
  17122. for (var i = 0, len = nodes.length; i < len; i++) {
  17123. (0, _element.removeClass)(nodes[i], className);
  17124. }
  17125. }
  17126. /**
  17127. * Refresh the table selection by re-rendering Selection instances connected with that instance.
  17128. *
  17129. * @param {Boolean} fastDraw If fast drawing is enabled than additionally className clearing is applied.
  17130. */
  17131. }, {
  17132. key: 'refreshSelections',
  17133. value: function refreshSelections(fastDraw) {
  17134. if (!this.wot.selections) {
  17135. return;
  17136. }
  17137. var highlights = Array.from(this.wot.selections);
  17138. var len = highlights.length;
  17139. if (fastDraw) {
  17140. var classesToRemove = [];
  17141. for (var i = 0; i < len; i++) {
  17142. var _highlights$i$setting = highlights[i].settings,
  17143. highlightHeaderClassName = _highlights$i$setting.highlightHeaderClassName,
  17144. highlightRowClassName = _highlights$i$setting.highlightRowClassName,
  17145. highlightColumnClassName = _highlights$i$setting.highlightColumnClassName;
  17146. var classNames = highlights[i].classNames;
  17147. var classNamesLength = classNames.length;
  17148. for (var j = 0; j < classNamesLength; j++) {
  17149. if (!classesToRemove.includes(classNames[j])) {
  17150. classesToRemove.push(classNames[j]);
  17151. }
  17152. }
  17153. if (highlightHeaderClassName && !classesToRemove.includes(highlightHeaderClassName)) {
  17154. classesToRemove.push(highlightHeaderClassName);
  17155. }
  17156. if (highlightRowClassName && !classesToRemove.includes(highlightRowClassName)) {
  17157. classesToRemove.push(highlightRowClassName);
  17158. }
  17159. if (highlightColumnClassName && !classesToRemove.includes(highlightColumnClassName)) {
  17160. classesToRemove.push(highlightColumnClassName);
  17161. }
  17162. }
  17163. var additionalClassesToRemove = this.wot.getSetting('onBeforeRemoveCellClassNames');
  17164. if (Array.isArray(additionalClassesToRemove)) {
  17165. for (var _i = 0; _i < additionalClassesToRemove.length; _i++) {
  17166. classesToRemove.push(additionalClassesToRemove[_i]);
  17167. }
  17168. }
  17169. var classesToRemoveLength = classesToRemove.length;
  17170. for (var _i2 = 0; _i2 < classesToRemoveLength; _i2++) {
  17171. // there was no rerender, so we need to remove classNames by ourselves
  17172. this.removeClassFromCells(classesToRemove[_i2]);
  17173. }
  17174. }
  17175. for (var _i3 = 0; _i3 < len; _i3++) {
  17176. highlights[_i3].draw(this.wot, fastDraw);
  17177. }
  17178. }
  17179. /**
  17180. * Get cell element at coords.
  17181. *
  17182. * @param {CellCoords} coords
  17183. * @returns {HTMLElement|Number} HTMLElement on success or Number one of the exit codes on error:
  17184. * -1 row before viewport
  17185. * -2 row after viewport
  17186. */
  17187. }, {
  17188. key: 'getCell',
  17189. value: function getCell(coords) {
  17190. var row = coords.row;
  17191. var column = coords.col;
  17192. var hookResult = this.wot.getSetting('onModifyGetCellCoords', row, column);
  17193. if (hookResult && Array.isArray(hookResult)) {
  17194. var _hookResult = _slicedToArray(hookResult, 2);
  17195. row = _hookResult[0];
  17196. column = _hookResult[1];
  17197. }
  17198. if (this.isRowBeforeRenderedRows(row)) {
  17199. // row before rendered rows
  17200. return -1;
  17201. } else if (this.isRowAfterRenderedRows(row)) {
  17202. // row after rendered rows
  17203. return -2;
  17204. }
  17205. var TR = this.TBODY.childNodes[this.rowFilter.sourceToRendered(row)];
  17206. if (TR) {
  17207. return TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(column)];
  17208. }
  17209. }
  17210. /**
  17211. * getColumnHeader
  17212. *
  17213. * @param {Number} col Column index
  17214. * @param {Number} [level=0] Header level (0 = most distant to the table)
  17215. * @returns {Object} HTMLElement on success or undefined on error
  17216. */
  17217. }, {
  17218. key: 'getColumnHeader',
  17219. value: function getColumnHeader(col) {
  17220. var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  17221. var TR = this.THEAD.childNodes[level];
  17222. if (TR) {
  17223. return TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(col)];
  17224. }
  17225. }
  17226. /**
  17227. * getRowHeader
  17228. *
  17229. * @param {Number} row Row index
  17230. * @returns {HTMLElement} HTMLElement on success or Number one of the exit codes on error: `null table doesn't have row headers`
  17231. */
  17232. }, {
  17233. key: 'getRowHeader',
  17234. value: function getRowHeader(row) {
  17235. if (this.columnFilter.sourceColumnToVisibleRowHeadedColumn(0) === 0) {
  17236. return null;
  17237. }
  17238. var TR = this.TBODY.childNodes[this.rowFilter.sourceToRendered(row)];
  17239. if (TR) {
  17240. return TR.childNodes[0];
  17241. }
  17242. }
  17243. /**
  17244. * Returns cell coords object for a given TD (or a child element of a TD element).
  17245. *
  17246. * @param {HTMLTableCellElement} TD A cell DOM element (or a child of one).
  17247. * @returns {CellCoords|null} The coordinates of the provided TD element (or the closest TD element) or null, if the provided element is not applicable.
  17248. */
  17249. }, {
  17250. key: 'getCoords',
  17251. value: function getCoords(TD) {
  17252. if (TD.nodeName !== 'TD' && TD.nodeName !== 'TH') {
  17253. TD = (0, _element.closest)(TD, ['TD', 'TH']);
  17254. }
  17255. if (TD === null) {
  17256. return null;
  17257. }
  17258. var TR = TD.parentNode;
  17259. var CONTAINER = TR.parentNode;
  17260. var row = (0, _element.index)(TR);
  17261. var col = TD.cellIndex;
  17262. if ((0, _element.overlayContainsElement)(_base2.default.CLONE_TOP_LEFT_CORNER, TD) || (0, _element.overlayContainsElement)(_base2.default.CLONE_TOP, TD)) {
  17263. if (CONTAINER.nodeName === 'THEAD') {
  17264. row -= CONTAINER.childNodes.length;
  17265. }
  17266. } else if (CONTAINER === this.THEAD) {
  17267. row = this.rowFilter.visibleColHeadedRowToSourceRow(row);
  17268. } else {
  17269. row = this.rowFilter.renderedToSource(row);
  17270. }
  17271. if ((0, _element.overlayContainsElement)(_base2.default.CLONE_TOP_LEFT_CORNER, TD) || (0, _element.overlayContainsElement)(_base2.default.CLONE_LEFT, TD)) {
  17272. col = this.columnFilter.offsettedTH(col);
  17273. } else {
  17274. col = this.columnFilter.visibleRowHeadedColumnToSourceColumn(col);
  17275. }
  17276. return new _coords2.default(row, col);
  17277. }
  17278. }, {
  17279. key: 'getTrForRow',
  17280. value: function getTrForRow(row) {
  17281. return this.TBODY.childNodes[this.rowFilter.sourceToRendered(row)];
  17282. }
  17283. }, {
  17284. key: 'getFirstRenderedRow',
  17285. value: function getFirstRenderedRow() {
  17286. return this.wot.wtViewport.rowsRenderCalculator.startRow;
  17287. }
  17288. }, {
  17289. key: 'getFirstVisibleRow',
  17290. value: function getFirstVisibleRow() {
  17291. return this.wot.wtViewport.rowsVisibleCalculator.startRow;
  17292. }
  17293. }, {
  17294. key: 'getFirstRenderedColumn',
  17295. value: function getFirstRenderedColumn() {
  17296. return this.wot.wtViewport.columnsRenderCalculator.startColumn;
  17297. }
  17298. /**
  17299. * @returns {Number} Returns -1 if no row is visible
  17300. */
  17301. }, {
  17302. key: 'getFirstVisibleColumn',
  17303. value: function getFirstVisibleColumn() {
  17304. return this.wot.wtViewport.columnsVisibleCalculator.startColumn;
  17305. }
  17306. /**
  17307. * @returns {Number} Returns -1 if no row is visible
  17308. */
  17309. }, {
  17310. key: 'getLastRenderedRow',
  17311. value: function getLastRenderedRow() {
  17312. return this.wot.wtViewport.rowsRenderCalculator.endRow;
  17313. }
  17314. }, {
  17315. key: 'getLastVisibleRow',
  17316. value: function getLastVisibleRow() {
  17317. return this.wot.wtViewport.rowsVisibleCalculator.endRow;
  17318. }
  17319. }, {
  17320. key: 'getLastRenderedColumn',
  17321. value: function getLastRenderedColumn() {
  17322. return this.wot.wtViewport.columnsRenderCalculator.endColumn;
  17323. }
  17324. /**
  17325. * @returns {Number} Returns -1 if no column is visible
  17326. */
  17327. }, {
  17328. key: 'getLastVisibleColumn',
  17329. value: function getLastVisibleColumn() {
  17330. return this.wot.wtViewport.columnsVisibleCalculator.endColumn;
  17331. }
  17332. }, {
  17333. key: 'isRowBeforeRenderedRows',
  17334. value: function isRowBeforeRenderedRows(row) {
  17335. return this.rowFilter && this.rowFilter.sourceToRendered(row) < 0 && row >= 0;
  17336. }
  17337. }, {
  17338. key: 'isRowAfterViewport',
  17339. value: function isRowAfterViewport(row) {
  17340. return this.rowFilter && this.rowFilter.sourceToRendered(row) > this.getLastVisibleRow();
  17341. }
  17342. }, {
  17343. key: 'isRowAfterRenderedRows',
  17344. value: function isRowAfterRenderedRows(row) {
  17345. return this.rowFilter && this.rowFilter.sourceToRendered(row) > this.getLastRenderedRow();
  17346. }
  17347. }, {
  17348. key: 'isColumnBeforeViewport',
  17349. value: function isColumnBeforeViewport(column) {
  17350. return this.columnFilter && this.columnFilter.sourceToRendered(column) < 0 && column >= 0;
  17351. }
  17352. }, {
  17353. key: 'isColumnAfterViewport',
  17354. value: function isColumnAfterViewport(column) {
  17355. return this.columnFilter && this.columnFilter.sourceToRendered(column) > this.getLastVisibleColumn();
  17356. }
  17357. }, {
  17358. key: 'isLastRowFullyVisible',
  17359. value: function isLastRowFullyVisible() {
  17360. return this.getLastVisibleRow() === this.getLastRenderedRow();
  17361. }
  17362. }, {
  17363. key: 'isLastColumnFullyVisible',
  17364. value: function isLastColumnFullyVisible() {
  17365. return this.getLastVisibleColumn() === this.getLastRenderedColumn();
  17366. }
  17367. }, {
  17368. key: 'getRenderedColumnsCount',
  17369. value: function getRenderedColumnsCount() {
  17370. var columnsCount = this.wot.wtViewport.columnsRenderCalculator.count;
  17371. var totalColumns = this.wot.getSetting('totalColumns');
  17372. if (this.wot.isOverlayName(_base2.default.CLONE_DEBUG)) {
  17373. columnsCount = totalColumns;
  17374. } 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)) {
  17375. return Math.min(this.wot.getSetting('fixedColumnsLeft'), totalColumns);
  17376. }
  17377. return columnsCount;
  17378. }
  17379. }, {
  17380. key: 'getRenderedRowsCount',
  17381. value: function getRenderedRowsCount() {
  17382. var rowsCount = this.wot.wtViewport.rowsRenderCalculator.count;
  17383. var totalRows = this.wot.getSetting('totalRows');
  17384. if (this.wot.isOverlayName(_base2.default.CLONE_DEBUG)) {
  17385. rowsCount = totalRows;
  17386. } else if (this.wot.isOverlayName(_base2.default.CLONE_TOP) || this.wot.isOverlayName(_base2.default.CLONE_TOP_LEFT_CORNER)) {
  17387. rowsCount = Math.min(this.wot.getSetting('fixedRowsTop'), totalRows);
  17388. } else if (this.wot.isOverlayName(_base2.default.CLONE_BOTTOM) || this.wot.isOverlayName(_base2.default.CLONE_BOTTOM_LEFT_CORNER)) {
  17389. rowsCount = Math.min(this.wot.getSetting('fixedRowsBottom'), totalRows);
  17390. }
  17391. return rowsCount;
  17392. }
  17393. }, {
  17394. key: 'getVisibleRowsCount',
  17395. value: function getVisibleRowsCount() {
  17396. return this.wot.wtViewport.rowsVisibleCalculator.count;
  17397. }
  17398. }, {
  17399. key: 'allRowsInViewport',
  17400. value: function allRowsInViewport() {
  17401. return this.wot.getSetting('totalRows') == this.getVisibleRowsCount();
  17402. }
  17403. /**
  17404. * Checks if any of the row's cells content exceeds its initial height, and if so, returns the oversized height
  17405. *
  17406. * @param {Number} sourceRow
  17407. * @returns {Number}
  17408. */
  17409. }, {
  17410. key: 'getRowHeight',
  17411. value: function getRowHeight(sourceRow) {
  17412. var height = this.wot.wtSettings.settings.rowHeight(sourceRow);
  17413. var oversizedHeight = this.wot.wtViewport.oversizedRows[sourceRow];
  17414. if (oversizedHeight !== void 0) {
  17415. height = height === void 0 ? oversizedHeight : Math.max(height, oversizedHeight);
  17416. }
  17417. return height;
  17418. }
  17419. }, {
  17420. key: 'getColumnHeaderHeight',
  17421. value: function getColumnHeaderHeight(level) {
  17422. var height = this.wot.wtSettings.settings.defaultRowHeight;
  17423. var oversizedHeight = this.wot.wtViewport.oversizedColumnHeaders[level];
  17424. if (oversizedHeight !== void 0) {
  17425. height = height ? Math.max(height, oversizedHeight) : oversizedHeight;
  17426. }
  17427. return height;
  17428. }
  17429. }, {
  17430. key: 'getVisibleColumnsCount',
  17431. value: function getVisibleColumnsCount() {
  17432. return this.wot.wtViewport.columnsVisibleCalculator.count;
  17433. }
  17434. }, {
  17435. key: 'allColumnsInViewport',
  17436. value: function allColumnsInViewport() {
  17437. return this.wot.getSetting('totalColumns') == this.getVisibleColumnsCount();
  17438. }
  17439. }, {
  17440. key: 'getColumnWidth',
  17441. value: function getColumnWidth(sourceColumn) {
  17442. var width = this.wot.wtSettings.settings.columnWidth;
  17443. if (typeof width === 'function') {
  17444. width = width(sourceColumn);
  17445. } else if ((typeof width === 'undefined' ? 'undefined' : _typeof(width)) === 'object') {
  17446. width = width[sourceColumn];
  17447. }
  17448. return width || this.wot.wtSettings.settings.defaultColumnWidth;
  17449. }
  17450. }, {
  17451. key: 'getStretchedColumnWidth',
  17452. value: function getStretchedColumnWidth(sourceColumn) {
  17453. var columnWidth = this.getColumnWidth(sourceColumn);
  17454. var width = columnWidth == null ? this.instance.wtSettings.settings.defaultColumnWidth : columnWidth;
  17455. var calculator = this.wot.wtViewport.columnsRenderCalculator;
  17456. if (calculator) {
  17457. var stretchedWidth = calculator.getStretchedColumnWidth(sourceColumn, width);
  17458. if (stretchedWidth) {
  17459. width = stretchedWidth;
  17460. }
  17461. }
  17462. return width;
  17463. }
  17464. /**
  17465. * Modify row header widths provided by user in class contructor.
  17466. *
  17467. * @private
  17468. */
  17469. }, {
  17470. key: '_modifyRowHeaderWidth',
  17471. value: function _modifyRowHeaderWidth(rowHeaderWidthFactory) {
  17472. var widths = (0, _function.isFunction)(rowHeaderWidthFactory) ? rowHeaderWidthFactory() : null;
  17473. if (Array.isArray(widths)) {
  17474. widths = [].concat(_toConsumableArray(widths));
  17475. widths[widths.length - 1] = this._correctRowHeaderWidth(widths[widths.length - 1]);
  17476. } else {
  17477. widths = this._correctRowHeaderWidth(widths);
  17478. }
  17479. return widths;
  17480. }
  17481. /**
  17482. * Correct row header width if necessary.
  17483. *
  17484. * @private
  17485. */
  17486. }, {
  17487. key: '_correctRowHeaderWidth',
  17488. value: function _correctRowHeaderWidth(width) {
  17489. if (typeof width !== 'number') {
  17490. width = this.wot.getSetting('defaultColumnWidth');
  17491. }
  17492. if (this.correctHeaderWidth) {
  17493. width++;
  17494. }
  17495. return width;
  17496. }
  17497. }]);
  17498. return Table;
  17499. }();
  17500. exports.default = Table;
  17501. /***/ }),
  17502. /* 185 */
  17503. /***/ (function(module, exports, __webpack_require__) {
  17504. "use strict";
  17505. exports.__esModule = true;
  17506. 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; }; }();
  17507. 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.']);
  17508. var _element = __webpack_require__(0);
  17509. var _console = __webpack_require__(56);
  17510. var _templateLiteralTag = __webpack_require__(41);
  17511. var _base = __webpack_require__(35);
  17512. var _base2 = _interopRequireDefault(_base);
  17513. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17514. function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
  17515. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17516. var performanceWarningAppeared = false;
  17517. /**
  17518. * @class TableRenderer
  17519. */
  17520. var TableRenderer = function () {
  17521. /**
  17522. * @param {WalkontableTable} wtTable
  17523. */
  17524. function TableRenderer(wtTable) {
  17525. _classCallCheck(this, TableRenderer);
  17526. this.wtTable = wtTable;
  17527. this.wot = wtTable.instance;
  17528. // legacy support
  17529. this.instance = wtTable.instance;
  17530. this.rowFilter = wtTable.rowFilter;
  17531. this.columnFilter = wtTable.columnFilter;
  17532. this.TABLE = wtTable.TABLE;
  17533. this.THEAD = wtTable.THEAD;
  17534. this.TBODY = wtTable.TBODY;
  17535. this.COLGROUP = wtTable.COLGROUP;
  17536. this.rowHeaders = [];
  17537. this.rowHeaderCount = 0;
  17538. this.columnHeaders = [];
  17539. this.columnHeaderCount = 0;
  17540. this.fixedRowsTop = 0;
  17541. this.fixedRowsBottom = 0;
  17542. }
  17543. /**
  17544. *
  17545. */
  17546. _createClass(TableRenderer, [{
  17547. key: 'render',
  17548. value: function render() {
  17549. if (!this.wtTable.isWorkingOnClone()) {
  17550. var skipRender = {};
  17551. this.wot.getSetting('beforeDraw', true, skipRender);
  17552. if (skipRender.skipRender === true) {
  17553. return;
  17554. }
  17555. }
  17556. this.rowHeaders = this.wot.getSetting('rowHeaders');
  17557. this.rowHeaderCount = this.rowHeaders.length;
  17558. this.fixedRowsTop = this.wot.getSetting('fixedRowsTop');
  17559. this.fixedRowsBottom = this.wot.getSetting('fixedRowsBottom');
  17560. this.columnHeaders = this.wot.getSetting('columnHeaders');
  17561. this.columnHeaderCount = this.columnHeaders.length;
  17562. var columnsToRender = this.wtTable.getRenderedColumnsCount();
  17563. var rowsToRender = this.wtTable.getRenderedRowsCount();
  17564. var totalColumns = this.wot.getSetting('totalColumns');
  17565. var totalRows = this.wot.getSetting('totalRows');
  17566. var workspaceWidth = void 0;
  17567. var adjusted = false;
  17568. if (_base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_BOTTOM) || _base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_BOTTOM_LEFT_CORNER)) {
  17569. // do NOT render headers on the bottom or bottom-left corner overlay
  17570. this.columnHeaders = [];
  17571. this.columnHeaderCount = 0;
  17572. }
  17573. if (totalColumns >= 0) {
  17574. // prepare COL and TH elements for rendering
  17575. this.adjustAvailableNodes();
  17576. adjusted = true;
  17577. // adjust column widths according to user widths settings
  17578. this.renderColumnHeaders();
  17579. // Render table rows
  17580. this.renderRows(totalRows, rowsToRender, columnsToRender);
  17581. if (!this.wtTable.isWorkingOnClone()) {
  17582. workspaceWidth = this.wot.wtViewport.getWorkspaceWidth();
  17583. this.wot.wtViewport.containerWidth = null;
  17584. }
  17585. this.adjustColumnWidths(columnsToRender);
  17586. this.markOversizedColumnHeaders();
  17587. this.adjustColumnHeaderHeights();
  17588. }
  17589. if (!adjusted) {
  17590. this.adjustAvailableNodes();
  17591. }
  17592. this.removeRedundantRows(rowsToRender);
  17593. if (!this.wtTable.isWorkingOnClone() || this.wot.isOverlayName(_base2.default.CLONE_BOTTOM)) {
  17594. this.markOversizedRows();
  17595. }
  17596. if (!this.wtTable.isWorkingOnClone()) {
  17597. this.wot.wtViewport.createVisibleCalculators();
  17598. this.wot.wtOverlays.refresh(false);
  17599. this.wot.wtOverlays.applyToDOM();
  17600. var hiderWidth = (0, _element.outerWidth)(this.wtTable.hider);
  17601. var tableWidth = (0, _element.outerWidth)(this.wtTable.TABLE);
  17602. if (hiderWidth !== 0 && tableWidth !== hiderWidth) {
  17603. // Recalculate the column widths, if width changes made in the overlays removed the scrollbar, thus changing the viewport width.
  17604. this.adjustColumnWidths(columnsToRender);
  17605. }
  17606. if (workspaceWidth !== this.wot.wtViewport.getWorkspaceWidth()) {
  17607. // workspace width changed though to shown/hidden vertical scrollbar. Let's reapply stretching
  17608. this.wot.wtViewport.containerWidth = null;
  17609. var firstRendered = this.wtTable.getFirstRenderedColumn();
  17610. var lastRendered = this.wtTable.getLastRenderedColumn();
  17611. var defaultColumnWidth = this.wot.getSetting('defaultColumnWidth');
  17612. var rowHeaderWidthSetting = this.wot.getSetting('rowHeaderWidth');
  17613. rowHeaderWidthSetting = this.instance.getSetting('onModifyRowHeaderWidth', rowHeaderWidthSetting);
  17614. if (rowHeaderWidthSetting != null) {
  17615. for (var i = 0; i < this.rowHeaderCount; i++) {
  17616. var width = Array.isArray(rowHeaderWidthSetting) ? rowHeaderWidthSetting[i] : rowHeaderWidthSetting;
  17617. width = width == null ? defaultColumnWidth : width;
  17618. this.COLGROUP.childNodes[i].style.width = width + 'px';
  17619. }
  17620. }
  17621. for (var _i = firstRendered; _i < lastRendered; _i++) {
  17622. var _width = this.wtTable.getStretchedColumnWidth(_i);
  17623. var renderedIndex = this.columnFilter.sourceToRendered(_i);
  17624. this.COLGROUP.childNodes[renderedIndex + this.rowHeaderCount].style.width = _width + 'px';
  17625. }
  17626. }
  17627. this.wot.getSetting('onDraw', true);
  17628. } else if (this.wot.isOverlayName(_base2.default.CLONE_BOTTOM)) {
  17629. this.wot.cloneSource.wtOverlays.adjustElementsSize();
  17630. }
  17631. }
  17632. /**
  17633. * @param {Number} renderedRowsCount
  17634. */
  17635. }, {
  17636. key: 'removeRedundantRows',
  17637. value: function removeRedundantRows(renderedRowsCount) {
  17638. while (this.wtTable.tbodyChildrenLength > renderedRowsCount) {
  17639. this.TBODY.removeChild(this.TBODY.lastChild);
  17640. this.wtTable.tbodyChildrenLength--;
  17641. }
  17642. }
  17643. /**
  17644. * @param {Number} totalRows
  17645. * @param {Number} rowsToRender
  17646. * @param {Number} columnsToRender
  17647. */
  17648. }, {
  17649. key: 'renderRows',
  17650. value: function renderRows(totalRows, rowsToRender, columnsToRender) {
  17651. var lastTD = void 0;
  17652. var TR = void 0;
  17653. var visibleRowIndex = 0;
  17654. var sourceRowIndex = this.rowFilter.renderedToSource(visibleRowIndex);
  17655. var isWorkingOnClone = this.wtTable.isWorkingOnClone();
  17656. while (sourceRowIndex < totalRows && sourceRowIndex >= 0) {
  17657. if (!performanceWarningAppeared && visibleRowIndex > 1000) {
  17658. performanceWarningAppeared = true;
  17659. (0, _console.warn)((0, _templateLiteralTag.toSingleLine)(_templateObject));
  17660. }
  17661. if (rowsToRender !== void 0 && visibleRowIndex === rowsToRender) {
  17662. // We have as much rows as needed for this clone
  17663. break;
  17664. }
  17665. TR = this.getOrCreateTrForRow(visibleRowIndex, TR);
  17666. // Render row headers
  17667. this.renderRowHeaders(sourceRowIndex, TR);
  17668. // Add and/or remove TDs to TR to match the desired number
  17669. this.adjustColumns(TR, columnsToRender + this.rowHeaderCount);
  17670. lastTD = this.renderCells(sourceRowIndex, TR, columnsToRender);
  17671. if (!isWorkingOnClone ||
  17672. // Necessary to refresh oversized row heights after editing cell in overlays
  17673. this.wot.isOverlayName(_base2.default.CLONE_BOTTOM)) {
  17674. // Reset the oversized row cache for this row
  17675. this.resetOversizedRow(sourceRowIndex);
  17676. }
  17677. if (TR.firstChild) {
  17678. // if I have 2 fixed columns with one-line content and the 3rd column has a multiline content, this is
  17679. // the way to make sure that the overlay will has same row height
  17680. var height = this.wot.wtTable.getRowHeight(sourceRowIndex);
  17681. if (height) {
  17682. // Decrease height. 1 pixel will be "replaced" by 1px border top
  17683. height--;
  17684. TR.firstChild.style.height = height + 'px';
  17685. } else {
  17686. TR.firstChild.style.height = '';
  17687. }
  17688. }
  17689. visibleRowIndex++;
  17690. sourceRowIndex = this.rowFilter.renderedToSource(visibleRowIndex);
  17691. }
  17692. }
  17693. /**
  17694. * Reset the oversized row cache for the provided index
  17695. *
  17696. * @param {Number} sourceRow Row index
  17697. */
  17698. }, {
  17699. key: 'resetOversizedRow',
  17700. value: function resetOversizedRow(sourceRow) {
  17701. if (this.wot.getSetting('externalRowCalculator')) {
  17702. return;
  17703. }
  17704. if (this.wot.wtViewport.oversizedRows && this.wot.wtViewport.oversizedRows[sourceRow]) {
  17705. this.wot.wtViewport.oversizedRows[sourceRow] = void 0;
  17706. }
  17707. }
  17708. /**
  17709. * Check if any of the rendered rows is higher than expected, and if so, cache them
  17710. */
  17711. }, {
  17712. key: 'markOversizedRows',
  17713. value: function markOversizedRows() {
  17714. if (this.wot.getSetting('externalRowCalculator')) {
  17715. return;
  17716. }
  17717. var rowCount = this.instance.wtTable.TBODY.childNodes.length;
  17718. var expectedTableHeight = rowCount * this.instance.wtSettings.settings.defaultRowHeight;
  17719. var actualTableHeight = (0, _element.innerHeight)(this.instance.wtTable.TBODY) - 1;
  17720. var previousRowHeight = void 0;
  17721. var rowInnerHeight = void 0;
  17722. var sourceRowIndex = void 0;
  17723. var currentTr = void 0;
  17724. var rowHeader = void 0;
  17725. var totalRows = this.instance.getSetting('totalRows');
  17726. if (expectedTableHeight === actualTableHeight && !this.instance.getSetting('fixedRowsBottom')) {
  17727. // If the actual table height equals rowCount * default single row height, no row is oversized -> no need to iterate over them
  17728. return;
  17729. }
  17730. while (rowCount) {
  17731. rowCount--;
  17732. sourceRowIndex = this.instance.wtTable.rowFilter.renderedToSource(rowCount);
  17733. previousRowHeight = this.instance.wtTable.getRowHeight(sourceRowIndex);
  17734. currentTr = this.instance.wtTable.getTrForRow(sourceRowIndex);
  17735. rowHeader = currentTr.querySelector('th');
  17736. if (rowHeader) {
  17737. rowInnerHeight = (0, _element.innerHeight)(rowHeader);
  17738. } else {
  17739. rowInnerHeight = (0, _element.innerHeight)(currentTr) - 1;
  17740. }
  17741. if (!previousRowHeight && this.instance.wtSettings.settings.defaultRowHeight < rowInnerHeight || previousRowHeight < rowInnerHeight) {
  17742. this.instance.wtViewport.oversizedRows[sourceRowIndex] = ++rowInnerHeight;
  17743. }
  17744. }
  17745. }
  17746. /**
  17747. * Check if any of the rendered columns is higher than expected, and if so, cache them.
  17748. */
  17749. }, {
  17750. key: 'markOversizedColumnHeaders',
  17751. value: function markOversizedColumnHeaders() {
  17752. var overlayName = this.wot.getOverlayName();
  17753. if (!this.columnHeaderCount || this.wot.wtViewport.hasOversizedColumnHeadersMarked[overlayName] || this.wtTable.isWorkingOnClone()) {
  17754. return;
  17755. }
  17756. var columnCount = this.wtTable.getRenderedColumnsCount();
  17757. for (var i = 0; i < this.columnHeaderCount; i++) {
  17758. for (var renderedColumnIndex = -1 * this.rowHeaderCount; renderedColumnIndex < columnCount; renderedColumnIndex++) {
  17759. this.markIfOversizedColumnHeader(renderedColumnIndex);
  17760. }
  17761. }
  17762. this.wot.wtViewport.hasOversizedColumnHeadersMarked[overlayName] = true;
  17763. }
  17764. /**
  17765. *
  17766. */
  17767. }, {
  17768. key: 'adjustColumnHeaderHeights',
  17769. value: function adjustColumnHeaderHeights() {
  17770. var columnHeaders = this.wot.getSetting('columnHeaders');
  17771. var children = this.wot.wtTable.THEAD.childNodes;
  17772. var oversizedColumnHeaders = this.wot.wtViewport.oversizedColumnHeaders;
  17773. for (var i = 0, len = columnHeaders.length; i < len; i++) {
  17774. if (oversizedColumnHeaders[i]) {
  17775. if (!children[i] || children[i].childNodes.length === 0) {
  17776. return;
  17777. }
  17778. children[i].childNodes[0].style.height = oversizedColumnHeaders[i] + 'px';
  17779. }
  17780. }
  17781. }
  17782. /**
  17783. * Check if column header for the specified column is higher than expected, and if so, cache it
  17784. *
  17785. * @param {Number} col Index of column
  17786. */
  17787. }, {
  17788. key: 'markIfOversizedColumnHeader',
  17789. value: function markIfOversizedColumnHeader(col) {
  17790. var sourceColIndex = this.wot.wtTable.columnFilter.renderedToSource(col);
  17791. var level = this.columnHeaderCount;
  17792. var defaultRowHeight = this.wot.wtSettings.settings.defaultRowHeight;
  17793. var previousColHeaderHeight = void 0;
  17794. var currentHeader = void 0;
  17795. var currentHeaderHeight = void 0;
  17796. var columnHeaderHeightSetting = this.wot.getSetting('columnHeaderHeight') || [];
  17797. while (level) {
  17798. level--;
  17799. previousColHeaderHeight = this.wot.wtTable.getColumnHeaderHeight(level);
  17800. currentHeader = this.wot.wtTable.getColumnHeader(sourceColIndex, level);
  17801. if (!currentHeader) {
  17802. /* eslint-disable no-continue */
  17803. continue;
  17804. }
  17805. currentHeaderHeight = (0, _element.innerHeight)(currentHeader);
  17806. if (!previousColHeaderHeight && defaultRowHeight < currentHeaderHeight || previousColHeaderHeight < currentHeaderHeight) {
  17807. this.wot.wtViewport.oversizedColumnHeaders[level] = currentHeaderHeight;
  17808. }
  17809. if (Array.isArray(columnHeaderHeightSetting)) {
  17810. if (columnHeaderHeightSetting[level] != null) {
  17811. this.wot.wtViewport.oversizedColumnHeaders[level] = columnHeaderHeightSetting[level];
  17812. }
  17813. } else if (!isNaN(columnHeaderHeightSetting)) {
  17814. this.wot.wtViewport.oversizedColumnHeaders[level] = columnHeaderHeightSetting;
  17815. }
  17816. if (this.wot.wtViewport.oversizedColumnHeaders[level] < (columnHeaderHeightSetting[level] || columnHeaderHeightSetting)) {
  17817. this.wot.wtViewport.oversizedColumnHeaders[level] = columnHeaderHeightSetting[level] || columnHeaderHeightSetting;
  17818. }
  17819. }
  17820. }
  17821. /**
  17822. * @param {Number} sourceRowIndex
  17823. * @param {HTMLTableRowElement} TR
  17824. * @param {Number} columnsToRender
  17825. * @returns {HTMLTableCellElement}
  17826. */
  17827. }, {
  17828. key: 'renderCells',
  17829. value: function renderCells(sourceRowIndex, TR, columnsToRender) {
  17830. var TD = void 0;
  17831. var sourceColIndex = void 0;
  17832. for (var visibleColIndex = 0; visibleColIndex < columnsToRender; visibleColIndex++) {
  17833. sourceColIndex = this.columnFilter.renderedToSource(visibleColIndex);
  17834. if (visibleColIndex === 0) {
  17835. TD = TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(sourceColIndex)];
  17836. } else {
  17837. TD = TD.nextSibling; // http://jsperf.com/nextsibling-vs-indexed-childnodes
  17838. }
  17839. // If the number of headers has been reduced, we need to replace excess TH with TD
  17840. if (TD.nodeName == 'TH') {
  17841. TD = replaceThWithTd(TD, TR);
  17842. }
  17843. if (!(0, _element.hasClass)(TD, 'hide')) {
  17844. TD.className = '';
  17845. }
  17846. TD.removeAttribute('style');
  17847. this.wot.wtSettings.settings.cellRenderer(sourceRowIndex, sourceColIndex, TD);
  17848. }
  17849. return TD;
  17850. }
  17851. /**
  17852. * @param {Number} columnsToRender Number of columns to render.
  17853. */
  17854. }, {
  17855. key: 'adjustColumnWidths',
  17856. value: function adjustColumnWidths(columnsToRender) {
  17857. var scrollbarCompensation = 0;
  17858. var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot;
  17859. var mainHolder = sourceInstance.wtTable.holder;
  17860. var defaultColumnWidth = this.wot.getSetting('defaultColumnWidth');
  17861. var rowHeaderWidthSetting = this.wot.getSetting('rowHeaderWidth');
  17862. if (mainHolder.offsetHeight < mainHolder.scrollHeight) {
  17863. scrollbarCompensation = (0, _element.getScrollbarWidth)();
  17864. }
  17865. this.wot.wtViewport.columnsRenderCalculator.refreshStretching(this.wot.wtViewport.getViewportWidth() - scrollbarCompensation);
  17866. rowHeaderWidthSetting = this.instance.getSetting('onModifyRowHeaderWidth', rowHeaderWidthSetting);
  17867. if (rowHeaderWidthSetting != null) {
  17868. for (var i = 0; i < this.rowHeaderCount; i++) {
  17869. var width = Array.isArray(rowHeaderWidthSetting) ? rowHeaderWidthSetting[i] : rowHeaderWidthSetting;
  17870. width = width == null ? defaultColumnWidth : width;
  17871. this.COLGROUP.childNodes[i].style.width = width + 'px';
  17872. }
  17873. }
  17874. for (var renderedColIndex = 0; renderedColIndex < columnsToRender; renderedColIndex++) {
  17875. var _width2 = this.wtTable.getStretchedColumnWidth(this.columnFilter.renderedToSource(renderedColIndex));
  17876. this.COLGROUP.childNodes[renderedColIndex + this.rowHeaderCount].style.width = _width2 + 'px';
  17877. }
  17878. }
  17879. /**
  17880. * @param {HTMLTableCellElement} TR
  17881. */
  17882. }, {
  17883. key: 'appendToTbody',
  17884. value: function appendToTbody(TR) {
  17885. this.TBODY.appendChild(TR);
  17886. this.wtTable.tbodyChildrenLength++;
  17887. }
  17888. /**
  17889. * @param {Number} rowIndex
  17890. * @param {HTMLTableRowElement} currentTr
  17891. * @returns {HTMLTableCellElement}
  17892. */
  17893. }, {
  17894. key: 'getOrCreateTrForRow',
  17895. value: function getOrCreateTrForRow(rowIndex, currentTr) {
  17896. var TR = void 0;
  17897. if (rowIndex >= this.wtTable.tbodyChildrenLength) {
  17898. TR = this.createRow();
  17899. this.appendToTbody(TR);
  17900. } else if (rowIndex === 0) {
  17901. TR = this.TBODY.firstChild;
  17902. } else {
  17903. // http://jsperf.com/nextsibling-vs-indexed-childnodes
  17904. TR = currentTr.nextSibling;
  17905. }
  17906. if (TR.className) {
  17907. TR.removeAttribute('class');
  17908. }
  17909. return TR;
  17910. }
  17911. /**
  17912. * @returns {HTMLTableCellElement}
  17913. */
  17914. }, {
  17915. key: 'createRow',
  17916. value: function createRow() {
  17917. var TR = document.createElement('TR');
  17918. for (var visibleColIndex = 0; visibleColIndex < this.rowHeaderCount; visibleColIndex++) {
  17919. TR.appendChild(document.createElement('TH'));
  17920. }
  17921. return TR;
  17922. }
  17923. /**
  17924. * @param {Number} row
  17925. * @param {Number} col
  17926. * @param {HTMLTableCellElement} TH
  17927. */
  17928. }, {
  17929. key: 'renderRowHeader',
  17930. value: function renderRowHeader(row, col, TH) {
  17931. TH.className = '';
  17932. TH.removeAttribute('style');
  17933. this.rowHeaders[col](row, TH, col);
  17934. }
  17935. /**
  17936. * @param {Number} row
  17937. * @param {HTMLTableCellElement} TR
  17938. */
  17939. }, {
  17940. key: 'renderRowHeaders',
  17941. value: function renderRowHeaders(row, TR) {
  17942. for (var TH = TR.firstChild, visibleColIndex = 0; visibleColIndex < this.rowHeaderCount; visibleColIndex++) {
  17943. // If the number of row headers increased we need to create TH or replace an existing TD node with TH
  17944. if (!TH) {
  17945. TH = document.createElement('TH');
  17946. TR.appendChild(TH);
  17947. } else if (TH.nodeName == 'TD') {
  17948. TH = replaceTdWithTh(TH, TR);
  17949. }
  17950. this.renderRowHeader(row, visibleColIndex, TH);
  17951. // http://jsperf.com/nextsibling-vs-indexed-childnodes
  17952. TH = TH.nextSibling;
  17953. }
  17954. }
  17955. /**
  17956. * Adjust the number of COL and TH elements to match the number of columns and headers that need to be rendered
  17957. */
  17958. }, {
  17959. key: 'adjustAvailableNodes',
  17960. value: function adjustAvailableNodes() {
  17961. this.adjustColGroups();
  17962. this.adjustThead();
  17963. }
  17964. /**
  17965. * Renders the column headers
  17966. */
  17967. }, {
  17968. key: 'renderColumnHeaders',
  17969. value: function renderColumnHeaders() {
  17970. if (!this.columnHeaderCount) {
  17971. return;
  17972. }
  17973. var columnCount = this.wtTable.getRenderedColumnsCount();
  17974. for (var i = 0; i < this.columnHeaderCount; i++) {
  17975. var TR = this.getTrForColumnHeaders(i);
  17976. for (var renderedColumnIndex = -1 * this.rowHeaderCount; renderedColumnIndex < columnCount; renderedColumnIndex++) {
  17977. var sourceCol = this.columnFilter.renderedToSource(renderedColumnIndex);
  17978. this.renderColumnHeader(i, sourceCol, TR.childNodes[renderedColumnIndex + this.rowHeaderCount]);
  17979. }
  17980. }
  17981. }
  17982. /**
  17983. * Adjusts the number of COL elements to match the number of columns that need to be rendered
  17984. */
  17985. }, {
  17986. key: 'adjustColGroups',
  17987. value: function adjustColGroups() {
  17988. var columnCount = this.wtTable.getRenderedColumnsCount();
  17989. while (this.wtTable.colgroupChildrenLength < columnCount + this.rowHeaderCount) {
  17990. this.COLGROUP.appendChild(document.createElement('COL'));
  17991. this.wtTable.colgroupChildrenLength++;
  17992. }
  17993. while (this.wtTable.colgroupChildrenLength > columnCount + this.rowHeaderCount) {
  17994. this.COLGROUP.removeChild(this.COLGROUP.lastChild);
  17995. this.wtTable.colgroupChildrenLength--;
  17996. }
  17997. if (this.rowHeaderCount) {
  17998. (0, _element.addClass)(this.COLGROUP.childNodes[0], 'rowHeader');
  17999. }
  18000. }
  18001. /**
  18002. * Adjusts the number of TH elements in THEAD to match the number of headers and columns that need to be rendered
  18003. */
  18004. }, {
  18005. key: 'adjustThead',
  18006. value: function adjustThead() {
  18007. var columnCount = this.wtTable.getRenderedColumnsCount();
  18008. var TR = this.THEAD.firstChild;
  18009. if (this.columnHeaders.length) {
  18010. for (var i = 0, len = this.columnHeaders.length; i < len; i++) {
  18011. TR = this.THEAD.childNodes[i];
  18012. if (!TR) {
  18013. TR = document.createElement('TR');
  18014. this.THEAD.appendChild(TR);
  18015. }
  18016. this.theadChildrenLength = TR.childNodes.length;
  18017. while (this.theadChildrenLength < columnCount + this.rowHeaderCount) {
  18018. TR.appendChild(document.createElement('TH'));
  18019. this.theadChildrenLength++;
  18020. }
  18021. while (this.theadChildrenLength > columnCount + this.rowHeaderCount) {
  18022. TR.removeChild(TR.lastChild);
  18023. this.theadChildrenLength--;
  18024. }
  18025. }
  18026. var theadChildrenLength = this.THEAD.childNodes.length;
  18027. if (theadChildrenLength > this.columnHeaders.length) {
  18028. for (var _i2 = this.columnHeaders.length; _i2 < theadChildrenLength; _i2++) {
  18029. this.THEAD.removeChild(this.THEAD.lastChild);
  18030. }
  18031. }
  18032. } else if (TR) {
  18033. (0, _element.empty)(TR);
  18034. }
  18035. }
  18036. /**
  18037. * @param {Number} index
  18038. * @returns {HTMLTableCellElement}
  18039. */
  18040. }, {
  18041. key: 'getTrForColumnHeaders',
  18042. value: function getTrForColumnHeaders(index) {
  18043. return this.THEAD.childNodes[index];
  18044. }
  18045. /**
  18046. * @param {Number} row
  18047. * @param {Number} col
  18048. * @param {HTMLTableCellElement} TH
  18049. * @returns {*}
  18050. */
  18051. }, {
  18052. key: 'renderColumnHeader',
  18053. value: function renderColumnHeader(row, col, TH) {
  18054. TH.className = '';
  18055. TH.removeAttribute('style');
  18056. return this.columnHeaders[row](col, TH, row);
  18057. }
  18058. /**
  18059. * Add and/or remove the TDs to match the desired number
  18060. *
  18061. * @param {HTMLTableCellElement} TR Table row in question
  18062. * @param {Number} desiredCount The desired number of TDs in the TR
  18063. */
  18064. }, {
  18065. key: 'adjustColumns',
  18066. value: function adjustColumns(TR, desiredCount) {
  18067. var count = TR.childNodes.length;
  18068. while (count < desiredCount) {
  18069. var TD = document.createElement('TD');
  18070. TR.appendChild(TD);
  18071. count++;
  18072. }
  18073. while (count > desiredCount) {
  18074. TR.removeChild(TR.lastChild);
  18075. count--;
  18076. }
  18077. }
  18078. /**
  18079. * @param {Number} columnsToRender
  18080. */
  18081. }, {
  18082. key: 'removeRedundantColumns',
  18083. value: function removeRedundantColumns(columnsToRender) {
  18084. while (this.wtTable.tbodyChildrenLength > columnsToRender) {
  18085. this.TBODY.removeChild(this.TBODY.lastChild);
  18086. this.wtTable.tbodyChildrenLength--;
  18087. }
  18088. }
  18089. }]);
  18090. return TableRenderer;
  18091. }();
  18092. function replaceTdWithTh(TD, TR) {
  18093. var TH = document.createElement('TH');
  18094. TR.insertBefore(TH, TD);
  18095. TR.removeChild(TD);
  18096. return TH;
  18097. }
  18098. function replaceThWithTd(TH, TR) {
  18099. var TD = document.createElement('TD');
  18100. TR.insertBefore(TD, TH);
  18101. TR.removeChild(TH);
  18102. return TD;
  18103. }
  18104. exports.default = TableRenderer;
  18105. /***/ }),
  18106. /* 186 */
  18107. /***/ (function(module, exports, __webpack_require__) {
  18108. "use strict";
  18109. exports.__esModule = true;
  18110. 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; }; }();
  18111. var _element = __webpack_require__(0);
  18112. var _object = __webpack_require__(2);
  18113. var _eventManager = __webpack_require__(6);
  18114. var _eventManager2 = _interopRequireDefault(_eventManager);
  18115. var _viewportColumns = __webpack_require__(175);
  18116. var _viewportColumns2 = _interopRequireDefault(_viewportColumns);
  18117. var _viewportRows = __webpack_require__(176);
  18118. var _viewportRows2 = _interopRequireDefault(_viewportRows);
  18119. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  18120. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18121. /**
  18122. * @class Viewport
  18123. */
  18124. var Viewport = function () {
  18125. /**
  18126. * @param wotInstance
  18127. */
  18128. function Viewport(wotInstance) {
  18129. var _this = this;
  18130. _classCallCheck(this, Viewport);
  18131. this.wot = wotInstance;
  18132. // legacy support
  18133. this.instance = this.wot;
  18134. this.oversizedRows = [];
  18135. this.oversizedColumnHeaders = [];
  18136. this.hasOversizedColumnHeadersMarked = {};
  18137. this.clientHeight = 0;
  18138. this.containerWidth = NaN;
  18139. this.rowHeaderWidth = NaN;
  18140. this.rowsVisibleCalculator = null;
  18141. this.columnsVisibleCalculator = null;
  18142. this.eventManager = new _eventManager2.default(this.wot);
  18143. this.eventManager.addEventListener(window, 'resize', function () {
  18144. _this.clientHeight = _this.getWorkspaceHeight();
  18145. });
  18146. }
  18147. /**
  18148. * @returns {number}
  18149. */
  18150. _createClass(Viewport, [{
  18151. key: 'getWorkspaceHeight',
  18152. value: function getWorkspaceHeight() {
  18153. var trimmingContainer = this.instance.wtOverlays.topOverlay.trimmingContainer;
  18154. var elemHeight = void 0;
  18155. var height = 0;
  18156. if (trimmingContainer === window) {
  18157. height = document.documentElement.clientHeight;
  18158. } else {
  18159. elemHeight = (0, _element.outerHeight)(trimmingContainer);
  18160. // returns height without DIV scrollbar
  18161. height = elemHeight > 0 && trimmingContainer.clientHeight > 0 ? trimmingContainer.clientHeight : Infinity;
  18162. }
  18163. return height;
  18164. }
  18165. }, {
  18166. key: 'getWorkspaceWidth',
  18167. value: function getWorkspaceWidth() {
  18168. var width = void 0;
  18169. var totalColumns = this.wot.getSetting('totalColumns');
  18170. var trimmingContainer = this.instance.wtOverlays.leftOverlay.trimmingContainer;
  18171. var overflow = void 0;
  18172. var stretchSetting = this.wot.getSetting('stretchH');
  18173. var docOffsetWidth = document.documentElement.offsetWidth;
  18174. var preventOverflow = this.wot.getSetting('preventOverflow');
  18175. if (preventOverflow) {
  18176. return (0, _element.outerWidth)(this.instance.wtTable.wtRootElement);
  18177. }
  18178. if (this.wot.getSetting('freezeOverlays')) {
  18179. width = Math.min(docOffsetWidth - this.getWorkspaceOffset().left, docOffsetWidth);
  18180. } else {
  18181. width = Math.min(this.getContainerFillWidth(), docOffsetWidth - this.getWorkspaceOffset().left, docOffsetWidth);
  18182. }
  18183. if (trimmingContainer === window && totalColumns > 0 && this.sumColumnWidths(0, totalColumns - 1) > width) {
  18184. // in case sum of column widths is higher than available stylesheet width, let's assume using the whole window
  18185. // otherwise continue below, which will allow stretching
  18186. // this is used in `scroll_window.html`
  18187. // TODO test me
  18188. return document.documentElement.clientWidth;
  18189. }
  18190. if (trimmingContainer !== window) {
  18191. overflow = (0, _element.getStyle)(this.instance.wtOverlays.leftOverlay.trimmingContainer, 'overflow');
  18192. if (overflow == 'scroll' || overflow == 'hidden' || overflow == 'auto') {
  18193. // this is used in `scroll.html`
  18194. // TODO test me
  18195. return Math.max(width, trimmingContainer.clientWidth);
  18196. }
  18197. }
  18198. if (stretchSetting === 'none' || !stretchSetting) {
  18199. // if no stretching is used, return the maximum used workspace width
  18200. return Math.max(width, (0, _element.outerWidth)(this.instance.wtTable.TABLE));
  18201. }
  18202. // if stretching is used, return the actual container width, so the columns can fit inside it
  18203. return width;
  18204. }
  18205. /**
  18206. * Checks if viewport has vertical scroll
  18207. *
  18208. * @returns {Boolean}
  18209. */
  18210. }, {
  18211. key: 'hasVerticalScroll',
  18212. value: function hasVerticalScroll() {
  18213. return this.getWorkspaceActualHeight() > this.getWorkspaceHeight();
  18214. }
  18215. /**
  18216. * Checks if viewport has horizontal scroll
  18217. *
  18218. * @returns {Boolean}
  18219. */
  18220. }, {
  18221. key: 'hasHorizontalScroll',
  18222. value: function hasHorizontalScroll() {
  18223. return this.getWorkspaceActualWidth() > this.getWorkspaceWidth();
  18224. }
  18225. /**
  18226. * @param from
  18227. * @param length
  18228. * @returns {Number}
  18229. */
  18230. }, {
  18231. key: 'sumColumnWidths',
  18232. value: function sumColumnWidths(from, length) {
  18233. var sum = 0;
  18234. while (from < length) {
  18235. sum += this.wot.wtTable.getColumnWidth(from);
  18236. from++;
  18237. }
  18238. return sum;
  18239. }
  18240. /**
  18241. * @returns {Number}
  18242. */
  18243. }, {
  18244. key: 'getContainerFillWidth',
  18245. value: function getContainerFillWidth() {
  18246. if (this.containerWidth) {
  18247. return this.containerWidth;
  18248. }
  18249. var mainContainer = this.instance.wtTable.holder;
  18250. var fillWidth = void 0;
  18251. var dummyElement = void 0;
  18252. dummyElement = document.createElement('div');
  18253. dummyElement.style.width = '100%';
  18254. dummyElement.style.height = '1px';
  18255. mainContainer.appendChild(dummyElement);
  18256. fillWidth = dummyElement.offsetWidth;
  18257. this.containerWidth = fillWidth;
  18258. mainContainer.removeChild(dummyElement);
  18259. return fillWidth;
  18260. }
  18261. /**
  18262. * @returns {Number}
  18263. */
  18264. }, {
  18265. key: 'getWorkspaceOffset',
  18266. value: function getWorkspaceOffset() {
  18267. return (0, _element.offset)(this.wot.wtTable.TABLE);
  18268. }
  18269. /**
  18270. * @returns {Number}
  18271. */
  18272. }, {
  18273. key: 'getWorkspaceActualHeight',
  18274. value: function getWorkspaceActualHeight() {
  18275. return (0, _element.outerHeight)(this.wot.wtTable.TABLE);
  18276. }
  18277. /**
  18278. * @returns {Number}
  18279. */
  18280. }, {
  18281. key: 'getWorkspaceActualWidth',
  18282. value: function getWorkspaceActualWidth() {
  18283. 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;
  18284. }
  18285. /**
  18286. * @returns {Number}
  18287. */
  18288. }, {
  18289. key: 'getColumnHeaderHeight',
  18290. value: function getColumnHeaderHeight() {
  18291. if (isNaN(this.columnHeaderHeight)) {
  18292. this.columnHeaderHeight = (0, _element.outerHeight)(this.wot.wtTable.THEAD);
  18293. }
  18294. return this.columnHeaderHeight;
  18295. }
  18296. /**
  18297. * @returns {Number}
  18298. */
  18299. }, {
  18300. key: 'getViewportHeight',
  18301. value: function getViewportHeight() {
  18302. var containerHeight = this.getWorkspaceHeight();
  18303. var columnHeaderHeight = void 0;
  18304. if (containerHeight === Infinity) {
  18305. return containerHeight;
  18306. }
  18307. columnHeaderHeight = this.getColumnHeaderHeight();
  18308. if (columnHeaderHeight > 0) {
  18309. containerHeight -= columnHeaderHeight;
  18310. }
  18311. return containerHeight;
  18312. }
  18313. /**
  18314. * @returns {Number}
  18315. */
  18316. }, {
  18317. key: 'getRowHeaderWidth',
  18318. value: function getRowHeaderWidth() {
  18319. var rowHeadersHeightSetting = this.instance.getSetting('rowHeaderWidth');
  18320. var rowHeaders = this.instance.getSetting('rowHeaders');
  18321. if (rowHeadersHeightSetting) {
  18322. this.rowHeaderWidth = 0;
  18323. for (var i = 0, len = rowHeaders.length; i < len; i++) {
  18324. this.rowHeaderWidth += rowHeadersHeightSetting[i] || rowHeadersHeightSetting;
  18325. }
  18326. }
  18327. if (this.wot.cloneSource) {
  18328. return this.wot.cloneSource.wtViewport.getRowHeaderWidth();
  18329. }
  18330. if (isNaN(this.rowHeaderWidth)) {
  18331. if (rowHeaders.length) {
  18332. var TH = this.instance.wtTable.TABLE.querySelector('TH');
  18333. this.rowHeaderWidth = 0;
  18334. for (var _i = 0, _len = rowHeaders.length; _i < _len; _i++) {
  18335. if (TH) {
  18336. this.rowHeaderWidth += (0, _element.outerWidth)(TH);
  18337. TH = TH.nextSibling;
  18338. } else {
  18339. // yes this is a cheat but it worked like that before, just taking assumption from CSS instead of measuring.
  18340. // TODO: proper fix
  18341. this.rowHeaderWidth += 50;
  18342. }
  18343. }
  18344. } else {
  18345. this.rowHeaderWidth = 0;
  18346. }
  18347. }
  18348. this.rowHeaderWidth = this.instance.getSetting('onModifyRowHeaderWidth', this.rowHeaderWidth) || this.rowHeaderWidth;
  18349. return this.rowHeaderWidth;
  18350. }
  18351. /**
  18352. * @returns {Number}
  18353. */
  18354. }, {
  18355. key: 'getViewportWidth',
  18356. value: function getViewportWidth() {
  18357. var containerWidth = this.getWorkspaceWidth();
  18358. var rowHeaderWidth = void 0;
  18359. if (containerWidth === Infinity) {
  18360. return containerWidth;
  18361. }
  18362. rowHeaderWidth = this.getRowHeaderWidth();
  18363. if (rowHeaderWidth > 0) {
  18364. return containerWidth - rowHeaderWidth;
  18365. }
  18366. return containerWidth;
  18367. }
  18368. /**
  18369. * Creates:
  18370. * - rowsRenderCalculator (before draw, to qualify rows for rendering)
  18371. * - rowsVisibleCalculator (after draw, to measure which rows are actually visible)
  18372. *
  18373. * @returns {ViewportRowsCalculator}
  18374. */
  18375. }, {
  18376. key: 'createRowsCalculator',
  18377. value: function createRowsCalculator() {
  18378. var _this2 = this;
  18379. var visible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  18380. var height = void 0;
  18381. var pos = void 0;
  18382. var fixedRowsTop = void 0;
  18383. var scrollbarHeight = void 0;
  18384. var fixedRowsBottom = void 0;
  18385. var fixedRowsHeight = void 0;
  18386. var totalRows = void 0;
  18387. this.rowHeaderWidth = NaN;
  18388. if (this.wot.wtSettings.settings.renderAllRows && !visible) {
  18389. height = Infinity;
  18390. } else {
  18391. height = this.getViewportHeight();
  18392. }
  18393. pos = this.wot.wtOverlays.topOverlay.getScrollPosition() - this.wot.wtOverlays.topOverlay.getTableParentOffset();
  18394. if (pos < 0) {
  18395. pos = 0;
  18396. }
  18397. fixedRowsTop = this.wot.getSetting('fixedRowsTop');
  18398. fixedRowsBottom = this.wot.getSetting('fixedRowsBottom');
  18399. totalRows = this.wot.getSetting('totalRows');
  18400. if (fixedRowsTop) {
  18401. fixedRowsHeight = this.wot.wtOverlays.topOverlay.sumCellSizes(0, fixedRowsTop);
  18402. pos += fixedRowsHeight;
  18403. height -= fixedRowsHeight;
  18404. }
  18405. if (fixedRowsBottom && this.wot.wtOverlays.bottomOverlay.clone) {
  18406. fixedRowsHeight = this.wot.wtOverlays.bottomOverlay.sumCellSizes(totalRows - fixedRowsBottom, totalRows);
  18407. height -= fixedRowsHeight;
  18408. }
  18409. if (this.wot.wtTable.holder.clientHeight === this.wot.wtTable.holder.offsetHeight) {
  18410. scrollbarHeight = 0;
  18411. } else {
  18412. scrollbarHeight = (0, _element.getScrollbarWidth)();
  18413. }
  18414. return new _viewportRows2.default(height, pos, this.wot.getSetting('totalRows'), function (sourceRow) {
  18415. return _this2.wot.wtTable.getRowHeight(sourceRow);
  18416. }, visible ? null : this.wot.wtSettings.settings.viewportRowCalculatorOverride, visible, scrollbarHeight);
  18417. }
  18418. /**
  18419. * Creates:
  18420. * - columnsRenderCalculator (before draw, to qualify columns for rendering)
  18421. * - columnsVisibleCalculator (after draw, to measure which columns are actually visible)
  18422. *
  18423. * @returns {ViewportRowsCalculator}
  18424. */
  18425. }, {
  18426. key: 'createColumnsCalculator',
  18427. value: function createColumnsCalculator() {
  18428. var _this3 = this;
  18429. var visible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  18430. var width = this.getViewportWidth();
  18431. var pos = void 0;
  18432. var fixedColumnsLeft = void 0;
  18433. this.columnHeaderHeight = NaN;
  18434. pos = this.wot.wtOverlays.leftOverlay.getScrollPosition() - this.wot.wtOverlays.leftOverlay.getTableParentOffset();
  18435. if (pos < 0) {
  18436. pos = 0;
  18437. }
  18438. fixedColumnsLeft = this.wot.getSetting('fixedColumnsLeft');
  18439. if (fixedColumnsLeft) {
  18440. var fixedColumnsWidth = this.wot.wtOverlays.leftOverlay.sumCellSizes(0, fixedColumnsLeft);
  18441. pos += fixedColumnsWidth;
  18442. width -= fixedColumnsWidth;
  18443. }
  18444. if (this.wot.wtTable.holder.clientWidth !== this.wot.wtTable.holder.offsetWidth) {
  18445. width -= (0, _element.getScrollbarWidth)();
  18446. }
  18447. return new _viewportColumns2.default(width, pos, this.wot.getSetting('totalColumns'), function (sourceCol) {
  18448. return _this3.wot.wtTable.getColumnWidth(sourceCol);
  18449. }, visible ? null : this.wot.wtSettings.settings.viewportColumnCalculatorOverride, visible, this.wot.getSetting('stretchH'), function (stretchedWidth, column) {
  18450. return _this3.wot.getSetting('onBeforeStretchingColumnWidth', stretchedWidth, column);
  18451. });
  18452. }
  18453. /**
  18454. * Creates rowsRenderCalculator and columnsRenderCalculator (before draw, to determine what rows and
  18455. * cols should be rendered)
  18456. *
  18457. * @param fastDraw {Boolean} If `true`, will try to avoid full redraw and only update the border positions.
  18458. * If `false` or `undefined`, will perform a full redraw
  18459. * @returns fastDraw {Boolean} The fastDraw value, possibly modified
  18460. */
  18461. }, {
  18462. key: 'createRenderCalculators',
  18463. value: function createRenderCalculators() {
  18464. var fastDraw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  18465. if (fastDraw) {
  18466. var proposedRowsVisibleCalculator = this.createRowsCalculator(true);
  18467. var proposedColumnsVisibleCalculator = this.createColumnsCalculator(true);
  18468. if (!(this.areAllProposedVisibleRowsAlreadyRendered(proposedRowsVisibleCalculator) && this.areAllProposedVisibleColumnsAlreadyRendered(proposedColumnsVisibleCalculator))) {
  18469. fastDraw = false;
  18470. }
  18471. }
  18472. if (!fastDraw) {
  18473. this.rowsRenderCalculator = this.createRowsCalculator();
  18474. this.columnsRenderCalculator = this.createColumnsCalculator();
  18475. }
  18476. // delete temporarily to make sure that renderers always use rowsRenderCalculator, not rowsVisibleCalculator
  18477. this.rowsVisibleCalculator = null;
  18478. this.columnsVisibleCalculator = null;
  18479. return fastDraw;
  18480. }
  18481. /**
  18482. * Creates rowsVisibleCalculator and columnsVisibleCalculator (after draw, to determine what are
  18483. * the actually visible rows and columns)
  18484. */
  18485. }, {
  18486. key: 'createVisibleCalculators',
  18487. value: function createVisibleCalculators() {
  18488. this.rowsVisibleCalculator = this.createRowsCalculator(true);
  18489. this.columnsVisibleCalculator = this.createColumnsCalculator(true);
  18490. }
  18491. /**
  18492. * Returns information whether proposedRowsVisibleCalculator viewport
  18493. * is contained inside rows rendered in previous draw (cached in rowsRenderCalculator)
  18494. *
  18495. * @param {Object} proposedRowsVisibleCalculator
  18496. * @returns {Boolean} Returns `true` if all proposed visible rows are already rendered (meaning: redraw is not needed).
  18497. * Returns `false` if at least one proposed visible row is not already rendered (meaning: redraw is needed)
  18498. */
  18499. }, {
  18500. key: 'areAllProposedVisibleRowsAlreadyRendered',
  18501. value: function areAllProposedVisibleRowsAlreadyRendered(proposedRowsVisibleCalculator) {
  18502. if (this.rowsVisibleCalculator) {
  18503. if (proposedRowsVisibleCalculator.startRow < this.rowsRenderCalculator.startRow || proposedRowsVisibleCalculator.startRow === this.rowsRenderCalculator.startRow && proposedRowsVisibleCalculator.startRow > 0) {
  18504. return false;
  18505. } else if (proposedRowsVisibleCalculator.endRow > this.rowsRenderCalculator.endRow || proposedRowsVisibleCalculator.endRow === this.rowsRenderCalculator.endRow && proposedRowsVisibleCalculator.endRow < this.wot.getSetting('totalRows') - 1) {
  18506. return false;
  18507. }
  18508. return true;
  18509. }
  18510. return false;
  18511. }
  18512. /**
  18513. * Returns information whether proposedColumnsVisibleCalculator viewport
  18514. * is contained inside column rendered in previous draw (cached in columnsRenderCalculator)
  18515. *
  18516. * @param {Object} proposedColumnsVisibleCalculator
  18517. * @returns {Boolean} Returns `true` if all proposed visible columns are already rendered (meaning: redraw is not needed).
  18518. * Returns `false` if at least one proposed visible column is not already rendered (meaning: redraw is needed)
  18519. */
  18520. }, {
  18521. key: 'areAllProposedVisibleColumnsAlreadyRendered',
  18522. value: function areAllProposedVisibleColumnsAlreadyRendered(proposedColumnsVisibleCalculator) {
  18523. if (this.columnsVisibleCalculator) {
  18524. if (proposedColumnsVisibleCalculator.startColumn < this.columnsRenderCalculator.startColumn || proposedColumnsVisibleCalculator.startColumn === this.columnsRenderCalculator.startColumn && proposedColumnsVisibleCalculator.startColumn > 0) {
  18525. return false;
  18526. } else if (proposedColumnsVisibleCalculator.endColumn > this.columnsRenderCalculator.endColumn || proposedColumnsVisibleCalculator.endColumn === this.columnsRenderCalculator.endColumn && proposedColumnsVisibleCalculator.endColumn < this.wot.getSetting('totalColumns') - 1) {
  18527. return false;
  18528. }
  18529. return true;
  18530. }
  18531. return false;
  18532. }
  18533. /**
  18534. * Resets values in keys of the hasOversizedColumnHeadersMarked object after updateSettings.
  18535. */
  18536. }, {
  18537. key: 'resetHasOversizedColumnHeadersMarked',
  18538. value: function resetHasOversizedColumnHeadersMarked() {
  18539. (0, _object.objectEach)(this.hasOversizedColumnHeadersMarked, function (value, key, object) {
  18540. object[key] = void 0;
  18541. });
  18542. }
  18543. }]);
  18544. return Viewport;
  18545. }();
  18546. exports.default = Viewport;
  18547. /***/ }),
  18548. /* 187 */
  18549. /***/ (function(module, exports, __webpack_require__) {
  18550. "use strict";
  18551. exports.__esModule = true;
  18552. 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"); } }; }();
  18553. 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; }; }();
  18554. var _element = __webpack_require__(0);
  18555. var _event = __webpack_require__(12);
  18556. var _object = __webpack_require__(2);
  18557. var _browser = __webpack_require__(27);
  18558. var _eventManager = __webpack_require__(6);
  18559. var _eventManager2 = _interopRequireDefault(_eventManager);
  18560. var _coords = __webpack_require__(54);
  18561. var _coords2 = _interopRequireDefault(_coords);
  18562. var _base = __webpack_require__(35);
  18563. var _base2 = _interopRequireDefault(_base);
  18564. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  18565. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18566. /**
  18567. *
  18568. */
  18569. var Border = function () {
  18570. /**
  18571. * @param {Walkontable} wotInstance
  18572. * @param {Object} settings
  18573. */
  18574. function Border(wotInstance, settings) {
  18575. _classCallCheck(this, Border);
  18576. if (!settings) {
  18577. return;
  18578. }
  18579. this.eventManager = new _eventManager2.default(wotInstance);
  18580. this.instance = wotInstance;
  18581. this.wot = wotInstance;
  18582. this.settings = settings;
  18583. this.mouseDown = false;
  18584. this.main = null;
  18585. this.top = null;
  18586. this.left = null;
  18587. this.bottom = null;
  18588. this.right = null;
  18589. this.topStyle = null;
  18590. this.leftStyle = null;
  18591. this.bottomStyle = null;
  18592. this.rightStyle = null;
  18593. this.cornerDefaultStyle = {
  18594. width: '6px',
  18595. height: '6px',
  18596. borderWidth: '1px',
  18597. borderStyle: 'solid',
  18598. borderColor: '#FFF'
  18599. };
  18600. this.corner = null;
  18601. this.cornerStyle = null;
  18602. this.createBorders(settings);
  18603. this.registerListeners();
  18604. }
  18605. /**
  18606. * Register all necessary events
  18607. */
  18608. _createClass(Border, [{
  18609. key: 'registerListeners',
  18610. value: function registerListeners() {
  18611. var _this2 = this;
  18612. this.eventManager.addEventListener(document.body, 'mousedown', function () {
  18613. return _this2.onMouseDown();
  18614. });
  18615. this.eventManager.addEventListener(document.body, 'mouseup', function () {
  18616. return _this2.onMouseUp();
  18617. });
  18618. var _loop = function _loop(c, len) {
  18619. _this2.eventManager.addEventListener(_this2.main.childNodes[c], 'mouseenter', function (event) {
  18620. return _this2.onMouseEnter(event, _this2.main.childNodes[c]);
  18621. });
  18622. };
  18623. for (var c = 0, len = this.main.childNodes.length; c < len; c++) {
  18624. _loop(c, len);
  18625. }
  18626. }
  18627. /**
  18628. * Mouse down listener
  18629. *
  18630. * @private
  18631. */
  18632. }, {
  18633. key: 'onMouseDown',
  18634. value: function onMouseDown() {
  18635. this.mouseDown = true;
  18636. }
  18637. /**
  18638. * Mouse up listener
  18639. *
  18640. * @private
  18641. */
  18642. }, {
  18643. key: 'onMouseUp',
  18644. value: function onMouseUp() {
  18645. this.mouseDown = false;
  18646. }
  18647. /**
  18648. * Mouse enter listener for fragment selection functionality.
  18649. *
  18650. * @private
  18651. * @param {Event} event Dom event
  18652. * @param {HTMLElement} parentElement Part of border element.
  18653. */
  18654. }, {
  18655. key: 'onMouseEnter',
  18656. value: function onMouseEnter(event, parentElement) {
  18657. if (!this.mouseDown || !this.wot.getSetting('hideBorderOnMouseDownOver')) {
  18658. return;
  18659. }
  18660. event.preventDefault();
  18661. (0, _event.stopImmediatePropagation)(event);
  18662. var _this = this;
  18663. var bounds = parentElement.getBoundingClientRect();
  18664. // Hide border to prevents selection jumping when fragmentSelection is enabled.
  18665. parentElement.style.display = 'none';
  18666. function isOutside(event) {
  18667. if (event.clientY < Math.floor(bounds.top)) {
  18668. return true;
  18669. }
  18670. if (event.clientY > Math.ceil(bounds.top + bounds.height)) {
  18671. return true;
  18672. }
  18673. if (event.clientX < Math.floor(bounds.left)) {
  18674. return true;
  18675. }
  18676. if (event.clientX > Math.ceil(bounds.left + bounds.width)) {
  18677. return true;
  18678. }
  18679. }
  18680. function handler(event) {
  18681. if (isOutside(event)) {
  18682. _this.eventManager.removeEventListener(document.body, 'mousemove', handler);
  18683. parentElement.style.display = 'block';
  18684. }
  18685. }
  18686. this.eventManager.addEventListener(document.body, 'mousemove', handler);
  18687. }
  18688. /**
  18689. * Create border elements
  18690. *
  18691. * @param {Object} settings
  18692. */
  18693. }, {
  18694. key: 'createBorders',
  18695. value: function createBorders(settings) {
  18696. this.main = document.createElement('div');
  18697. var borderDivs = ['top', 'left', 'bottom', 'right', 'corner'];
  18698. var style = this.main.style;
  18699. style.position = 'absolute';
  18700. style.top = 0;
  18701. style.left = 0;
  18702. for (var i = 0; i < 5; i++) {
  18703. var position = borderDivs[i];
  18704. var div = document.createElement('div');
  18705. div.className = 'wtBorder ' + (this.settings.className || ''); // + borderDivs[i];
  18706. if (this.settings[position] && this.settings[position].hide) {
  18707. div.className += ' hidden';
  18708. }
  18709. style = div.style;
  18710. style.backgroundColor = this.settings[position] && this.settings[position].color ? this.settings[position].color : settings.border.color;
  18711. style.height = this.settings[position] && this.settings[position].width ? this.settings[position].width + 'px' : settings.border.width + 'px';
  18712. style.width = this.settings[position] && this.settings[position].width ? this.settings[position].width + 'px' : settings.border.width + 'px';
  18713. this.main.appendChild(div);
  18714. }
  18715. this.top = this.main.childNodes[0];
  18716. this.left = this.main.childNodes[1];
  18717. this.bottom = this.main.childNodes[2];
  18718. this.right = this.main.childNodes[3];
  18719. this.topStyle = this.top.style;
  18720. this.leftStyle = this.left.style;
  18721. this.bottomStyle = this.bottom.style;
  18722. this.rightStyle = this.right.style;
  18723. this.corner = this.main.childNodes[4];
  18724. this.corner.className += ' corner';
  18725. this.cornerStyle = this.corner.style;
  18726. this.cornerStyle.width = this.cornerDefaultStyle.width;
  18727. this.cornerStyle.height = this.cornerDefaultStyle.height;
  18728. this.cornerStyle.border = [this.cornerDefaultStyle.borderWidth, this.cornerDefaultStyle.borderStyle, this.cornerDefaultStyle.borderColor].join(' ');
  18729. if ((0, _browser.isMobileBrowser)()) {
  18730. this.createMultipleSelectorHandles();
  18731. }
  18732. this.disappear();
  18733. if (!this.wot.wtTable.bordersHolder) {
  18734. this.wot.wtTable.bordersHolder = document.createElement('div');
  18735. this.wot.wtTable.bordersHolder.className = 'htBorders';
  18736. this.wot.wtTable.spreader.appendChild(this.wot.wtTable.bordersHolder);
  18737. }
  18738. this.wot.wtTable.bordersHolder.insertBefore(this.main, this.wot.wtTable.bordersHolder.firstChild);
  18739. }
  18740. /**
  18741. * Create multiple selector handler for mobile devices
  18742. */
  18743. }, {
  18744. key: 'createMultipleSelectorHandles',
  18745. value: function createMultipleSelectorHandles() {
  18746. this.selectionHandles = {
  18747. topLeft: document.createElement('DIV'),
  18748. topLeftHitArea: document.createElement('DIV'),
  18749. bottomRight: document.createElement('DIV'),
  18750. bottomRightHitArea: document.createElement('DIV')
  18751. };
  18752. var width = 10;
  18753. var hitAreaWidth = 40;
  18754. this.selectionHandles.topLeft.className = 'topLeftSelectionHandle';
  18755. this.selectionHandles.topLeftHitArea.className = 'topLeftSelectionHandle-HitArea';
  18756. this.selectionHandles.bottomRight.className = 'bottomRightSelectionHandle';
  18757. this.selectionHandles.bottomRightHitArea.className = 'bottomRightSelectionHandle-HitArea';
  18758. this.selectionHandles.styles = {
  18759. topLeft: this.selectionHandles.topLeft.style,
  18760. topLeftHitArea: this.selectionHandles.topLeftHitArea.style,
  18761. bottomRight: this.selectionHandles.bottomRight.style,
  18762. bottomRightHitArea: this.selectionHandles.bottomRightHitArea.style
  18763. };
  18764. var hitAreaStyle = {
  18765. position: 'absolute',
  18766. height: hitAreaWidth + 'px',
  18767. width: hitAreaWidth + 'px',
  18768. 'border-radius': parseInt(hitAreaWidth / 1.5, 10) + 'px'
  18769. };
  18770. for (var prop in hitAreaStyle) {
  18771. if ((0, _object.hasOwnProperty)(hitAreaStyle, prop)) {
  18772. this.selectionHandles.styles.bottomRightHitArea[prop] = hitAreaStyle[prop];
  18773. this.selectionHandles.styles.topLeftHitArea[prop] = hitAreaStyle[prop];
  18774. }
  18775. }
  18776. var handleStyle = {
  18777. position: 'absolute',
  18778. height: width + 'px',
  18779. width: width + 'px',
  18780. 'border-radius': parseInt(width / 1.5, 10) + 'px',
  18781. background: '#F5F5FF',
  18782. border: '1px solid #4285c8'
  18783. };
  18784. for (var _prop in handleStyle) {
  18785. if ((0, _object.hasOwnProperty)(handleStyle, _prop)) {
  18786. this.selectionHandles.styles.bottomRight[_prop] = handleStyle[_prop];
  18787. this.selectionHandles.styles.topLeft[_prop] = handleStyle[_prop];
  18788. }
  18789. }
  18790. this.main.appendChild(this.selectionHandles.topLeft);
  18791. this.main.appendChild(this.selectionHandles.bottomRight);
  18792. this.main.appendChild(this.selectionHandles.topLeftHitArea);
  18793. this.main.appendChild(this.selectionHandles.bottomRightHitArea);
  18794. }
  18795. }, {
  18796. key: 'isPartRange',
  18797. value: function isPartRange(row, col) {
  18798. var areaSelection = this.wot.selections.createOrGetArea();
  18799. if (areaSelection.cellRange) {
  18800. if (row != areaSelection.cellRange.to.row || col != areaSelection.cellRange.to.col) {
  18801. return true;
  18802. }
  18803. }
  18804. return false;
  18805. }
  18806. }, {
  18807. key: 'updateMultipleSelectionHandlesPosition',
  18808. value: function updateMultipleSelectionHandlesPosition(row, col, top, left, width, height) {
  18809. var handleWidth = parseInt(this.selectionHandles.styles.topLeft.width, 10);
  18810. var hitAreaWidth = parseInt(this.selectionHandles.styles.topLeftHitArea.width, 10);
  18811. this.selectionHandles.styles.topLeft.top = parseInt(top - handleWidth, 10) + 'px';
  18812. this.selectionHandles.styles.topLeft.left = parseInt(left - handleWidth, 10) + 'px';
  18813. this.selectionHandles.styles.topLeftHitArea.top = parseInt(top - hitAreaWidth / 4 * 3, 10) + 'px';
  18814. this.selectionHandles.styles.topLeftHitArea.left = parseInt(left - hitAreaWidth / 4 * 3, 10) + 'px';
  18815. this.selectionHandles.styles.bottomRight.top = parseInt(top + height, 10) + 'px';
  18816. this.selectionHandles.styles.bottomRight.left = parseInt(left + width, 10) + 'px';
  18817. this.selectionHandles.styles.bottomRightHitArea.top = parseInt(top + height - hitAreaWidth / 4, 10) + 'px';
  18818. this.selectionHandles.styles.bottomRightHitArea.left = parseInt(left + width - hitAreaWidth / 4, 10) + 'px';
  18819. if (this.settings.border.cornerVisible && this.settings.border.cornerVisible()) {
  18820. this.selectionHandles.styles.topLeft.display = 'block';
  18821. this.selectionHandles.styles.topLeftHitArea.display = 'block';
  18822. if (this.isPartRange(row, col)) {
  18823. this.selectionHandles.styles.bottomRight.display = 'none';
  18824. this.selectionHandles.styles.bottomRightHitArea.display = 'none';
  18825. } else {
  18826. this.selectionHandles.styles.bottomRight.display = 'block';
  18827. this.selectionHandles.styles.bottomRightHitArea.display = 'block';
  18828. }
  18829. } else {
  18830. this.selectionHandles.styles.topLeft.display = 'none';
  18831. this.selectionHandles.styles.bottomRight.display = 'none';
  18832. this.selectionHandles.styles.topLeftHitArea.display = 'none';
  18833. this.selectionHandles.styles.bottomRightHitArea.display = 'none';
  18834. }
  18835. if (row == this.wot.wtSettings.getSetting('fixedRowsTop') || col == this.wot.wtSettings.getSetting('fixedColumnsLeft')) {
  18836. this.selectionHandles.styles.topLeft.zIndex = '9999';
  18837. this.selectionHandles.styles.topLeftHitArea.zIndex = '9999';
  18838. } else {
  18839. this.selectionHandles.styles.topLeft.zIndex = '';
  18840. this.selectionHandles.styles.topLeftHitArea.zIndex = '';
  18841. }
  18842. }
  18843. /**
  18844. * Show border around one or many cells
  18845. *
  18846. * @param {Array} corners
  18847. */
  18848. }, {
  18849. key: 'appear',
  18850. value: function appear(corners) {
  18851. if (this.disabled) {
  18852. return;
  18853. }
  18854. var fromRow = void 0;
  18855. var toRow = void 0;
  18856. var fromColumn = void 0;
  18857. var toColumn = void 0;
  18858. var rowsCount = this.wot.wtTable.getRenderedRowsCount();
  18859. for (var i = 0; i < rowsCount; i += 1) {
  18860. var s = this.wot.wtTable.rowFilter.renderedToSource(i);
  18861. if (s >= corners[0] && s <= corners[2]) {
  18862. fromRow = s;
  18863. break;
  18864. }
  18865. }
  18866. for (var _i = rowsCount - 1; _i >= 0; _i -= 1) {
  18867. var _s = this.wot.wtTable.rowFilter.renderedToSource(_i);
  18868. if (_s >= corners[0] && _s <= corners[2]) {
  18869. toRow = _s;
  18870. break;
  18871. }
  18872. }
  18873. var columnsCount = this.wot.wtTable.getRenderedColumnsCount();
  18874. for (var _i2 = 0; _i2 < columnsCount; _i2 += 1) {
  18875. var _s2 = this.wot.wtTable.columnFilter.renderedToSource(_i2);
  18876. if (_s2 >= corners[1] && _s2 <= corners[3]) {
  18877. fromColumn = _s2;
  18878. break;
  18879. }
  18880. }
  18881. for (var _i3 = columnsCount - 1; _i3 >= 0; _i3 -= 1) {
  18882. var _s3 = this.wot.wtTable.columnFilter.renderedToSource(_i3);
  18883. if (_s3 >= corners[1] && _s3 <= corners[3]) {
  18884. toColumn = _s3;
  18885. break;
  18886. }
  18887. }
  18888. if (fromRow === void 0 || fromColumn === void 0) {
  18889. this.disappear();
  18890. return;
  18891. }
  18892. var fromTD = this.wot.wtTable.getCell(new _coords2.default(fromRow, fromColumn));
  18893. var isMultiple = fromRow !== toRow || fromColumn !== toColumn;
  18894. var toTD = isMultiple ? this.wot.wtTable.getCell(new _coords2.default(toRow, toColumn)) : fromTD;
  18895. var fromOffset = (0, _element.offset)(fromTD);
  18896. var toOffset = isMultiple ? (0, _element.offset)(toTD) : fromOffset;
  18897. var containerOffset = (0, _element.offset)(this.wot.wtTable.TABLE);
  18898. var minTop = fromOffset.top;
  18899. var minLeft = fromOffset.left;
  18900. var left = minLeft - containerOffset.left - 1;
  18901. var width = toOffset.left + (0, _element.outerWidth)(toTD) - minLeft;
  18902. if (this.isEntireColumnSelected(fromRow, toRow)) {
  18903. var modifiedValues = this.getDimensionsFromHeader('columns', fromColumn, toColumn, containerOffset);
  18904. var fromTH = null;
  18905. if (modifiedValues) {
  18906. var _modifiedValues = _slicedToArray(modifiedValues, 3);
  18907. fromTH = _modifiedValues[0];
  18908. left = _modifiedValues[1];
  18909. width = _modifiedValues[2];
  18910. }
  18911. if (fromTH) {
  18912. fromTD = fromTH;
  18913. }
  18914. }
  18915. var top = minTop - containerOffset.top - 1;
  18916. var height = toOffset.top + (0, _element.outerHeight)(toTD) - minTop;
  18917. if (this.isEntireRowSelected(fromColumn, toColumn)) {
  18918. var _modifiedValues2 = this.getDimensionsFromHeader('rows', fromRow, toRow, containerOffset);
  18919. var _fromTH = null;
  18920. if (_modifiedValues2) {
  18921. var _modifiedValues3 = _slicedToArray(_modifiedValues2, 3);
  18922. _fromTH = _modifiedValues3[0];
  18923. top = _modifiedValues3[1];
  18924. height = _modifiedValues3[2];
  18925. }
  18926. if (_fromTH) {
  18927. fromTD = _fromTH;
  18928. }
  18929. }
  18930. var style = (0, _element.getComputedStyle)(fromTD);
  18931. if (parseInt(style.borderTopWidth, 10) > 0) {
  18932. top += 1;
  18933. height = height > 0 ? height - 1 : 0;
  18934. }
  18935. if (parseInt(style.borderLeftWidth, 10) > 0) {
  18936. left += 1;
  18937. width = width > 0 ? width - 1 : 0;
  18938. }
  18939. this.topStyle.top = top + 'px';
  18940. this.topStyle.left = left + 'px';
  18941. this.topStyle.width = width + 'px';
  18942. this.topStyle.display = 'block';
  18943. this.leftStyle.top = top + 'px';
  18944. this.leftStyle.left = left + 'px';
  18945. this.leftStyle.height = height + 'px';
  18946. this.leftStyle.display = 'block';
  18947. var delta = Math.floor(this.settings.border.width / 2);
  18948. this.bottomStyle.top = top + height - delta + 'px';
  18949. this.bottomStyle.left = left + 'px';
  18950. this.bottomStyle.width = width + 'px';
  18951. this.bottomStyle.display = 'block';
  18952. this.rightStyle.top = top + 'px';
  18953. this.rightStyle.left = left + width - delta + 'px';
  18954. this.rightStyle.height = height + 1 + 'px';
  18955. this.rightStyle.display = 'block';
  18956. var cornerVisibleSetting = this.settings.border.cornerVisible;
  18957. cornerVisibleSetting = typeof cornerVisibleSetting === 'function' ? cornerVisibleSetting(this.settings.layerLevel) : cornerVisibleSetting;
  18958. var hookResult = this.wot.getSetting('onModifyGetCellCoords', toRow, toColumn);
  18959. var checkRow = toRow,
  18960. checkCol = toColumn;
  18961. if (hookResult && Array.isArray(hookResult)) {
  18962. var _hookResult = _slicedToArray(hookResult, 4);
  18963. checkRow = _hookResult[2];
  18964. checkCol = _hookResult[3];
  18965. }
  18966. if ((0, _browser.isMobileBrowser)() || !cornerVisibleSetting || this.isPartRange(checkRow, checkCol)) {
  18967. this.cornerStyle.display = 'none';
  18968. } else {
  18969. this.cornerStyle.top = top + height - 4 + 'px';
  18970. this.cornerStyle.left = left + width - 4 + 'px';
  18971. this.cornerStyle.borderRightWidth = this.cornerDefaultStyle.borderWidth;
  18972. this.cornerStyle.width = this.cornerDefaultStyle.width;
  18973. // Hide the fill handle, so the possible further adjustments won't force unneeded scrollbars.
  18974. this.cornerStyle.display = 'none';
  18975. var trimmingContainer = (0, _element.getTrimmingContainer)(this.wot.wtTable.TABLE);
  18976. if (toColumn === this.wot.getSetting('totalColumns') - 1) {
  18977. var cornerOverlappingContainer = toTD.offsetLeft + (0, _element.outerWidth)(toTD) + parseInt(this.cornerDefaultStyle.width, 10) / 2 >= (0, _element.innerWidth)(trimmingContainer);
  18978. if (cornerOverlappingContainer) {
  18979. this.cornerStyle.left = Math.floor(left + width - 3 - parseInt(this.cornerDefaultStyle.width, 10) / 2) + 'px';
  18980. this.cornerStyle.borderRightWidth = 0;
  18981. }
  18982. }
  18983. if (toRow === this.wot.getSetting('totalRows') - 1) {
  18984. var _cornerOverlappingContainer = toTD.offsetTop + (0, _element.outerHeight)(toTD) + parseInt(this.cornerDefaultStyle.height, 10) / 2 >= (0, _element.innerHeight)(trimmingContainer);
  18985. if (_cornerOverlappingContainer) {
  18986. this.cornerStyle.top = Math.floor(top + height - 3 - parseInt(this.cornerDefaultStyle.height, 10) / 2) + 'px';
  18987. this.cornerStyle.borderBottomWidth = 0;
  18988. }
  18989. }
  18990. this.cornerStyle.display = 'block';
  18991. }
  18992. if ((0, _browser.isMobileBrowser)()) {
  18993. this.updateMultipleSelectionHandlesPosition(toRow, toColumn, top, left, width, height);
  18994. }
  18995. }
  18996. /**
  18997. * Check whether an entire column of cells is selected.
  18998. *
  18999. * @private
  19000. * @param {Number} startRowIndex Start row index.
  19001. * @param {Number} endRowIndex End row index.
  19002. */
  19003. }, {
  19004. key: 'isEntireColumnSelected',
  19005. value: function isEntireColumnSelected(startRowIndex, endRowIndex) {
  19006. return startRowIndex === this.wot.wtTable.getFirstRenderedRow() && endRowIndex === this.wot.wtTable.getLastRenderedRow();
  19007. }
  19008. /**
  19009. * Check whether an entire row of cells is selected.
  19010. *
  19011. * @private
  19012. * @param {Number} startColumnIndex Start column index.
  19013. * @param {Number} endColumnIndex End column index.
  19014. */
  19015. }, {
  19016. key: 'isEntireRowSelected',
  19017. value: function isEntireRowSelected(startColumnIndex, endColumnIndex) {
  19018. return startColumnIndex === this.wot.wtTable.getFirstRenderedColumn() && endColumnIndex === this.wot.wtTable.getLastRenderedColumn();
  19019. }
  19020. /**
  19021. * Get left/top index and width/height depending on the `direction` provided.
  19022. *
  19023. * @private
  19024. * @param {String} direction `rows` or `columns`, defines if an entire column or row is selected.
  19025. * @param {Number} fromIndex Start index of the selection.
  19026. * @param {Number} toIndex End index of the selection.
  19027. * @param {Number} containerOffset offset of the container.
  19028. * @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).
  19029. */
  19030. }, {
  19031. key: 'getDimensionsFromHeader',
  19032. value: function getDimensionsFromHeader(direction, fromIndex, toIndex, containerOffset) {
  19033. var _this3 = this;
  19034. var rootHotElement = this.wot.wtTable.wtRootElement.parentNode;
  19035. var getHeaderFn = null;
  19036. var dimensionFn = null;
  19037. var entireSelectionClassname = null;
  19038. var index = null;
  19039. var dimension = null;
  19040. var dimensionProperty = null;
  19041. var startHeader = null;
  19042. var endHeader = null;
  19043. switch (direction) {
  19044. case 'rows':
  19045. getHeaderFn = function getHeaderFn() {
  19046. var _wot$wtTable;
  19047. return (_wot$wtTable = _this3.wot.wtTable).getRowHeader.apply(_wot$wtTable, arguments);
  19048. };
  19049. dimensionFn = function dimensionFn() {
  19050. return _element.outerHeight.apply(undefined, arguments);
  19051. };
  19052. entireSelectionClassname = 'ht__selection--rows';
  19053. dimensionProperty = 'top';
  19054. break;
  19055. case 'columns':
  19056. getHeaderFn = function getHeaderFn() {
  19057. var _wot$wtTable2;
  19058. return (_wot$wtTable2 = _this3.wot.wtTable).getColumnHeader.apply(_wot$wtTable2, arguments);
  19059. };
  19060. dimensionFn = function dimensionFn() {
  19061. return _element.outerWidth.apply(undefined, arguments);
  19062. };
  19063. entireSelectionClassname = 'ht__selection--columns';
  19064. dimensionProperty = 'left';
  19065. break;
  19066. default:
  19067. }
  19068. if (rootHotElement.className.includes(entireSelectionClassname)) {
  19069. var columnHeaderLevelCount = this.wot.getSetting('columnHeaders').length;
  19070. startHeader = getHeaderFn(fromIndex, columnHeaderLevelCount - 1);
  19071. endHeader = getHeaderFn(toIndex, columnHeaderLevelCount - 1);
  19072. if (!startHeader || !endHeader) {
  19073. return false;
  19074. }
  19075. var startHeaderOffset = (0, _element.offset)(startHeader);
  19076. var endOffset = (0, _element.offset)(endHeader);
  19077. if (startHeader && endHeader) {
  19078. index = startHeaderOffset[dimensionProperty] - containerOffset[dimensionProperty] - 1;
  19079. dimension = endOffset[dimensionProperty] + dimensionFn(endHeader) - startHeaderOffset[dimensionProperty];
  19080. }
  19081. return [startHeader, index, dimension];
  19082. }
  19083. return false;
  19084. }
  19085. /**
  19086. * Hide border
  19087. */
  19088. }, {
  19089. key: 'disappear',
  19090. value: function disappear() {
  19091. this.topStyle.display = 'none';
  19092. this.leftStyle.display = 'none';
  19093. this.bottomStyle.display = 'none';
  19094. this.rightStyle.display = 'none';
  19095. this.cornerStyle.display = 'none';
  19096. if ((0, _browser.isMobileBrowser)()) {
  19097. this.selectionHandles.styles.topLeft.display = 'none';
  19098. this.selectionHandles.styles.bottomRight.display = 'none';
  19099. }
  19100. }
  19101. }]);
  19102. return Border;
  19103. }();
  19104. exports.default = Border;
  19105. /***/ }),
  19106. /* 188 */
  19107. /***/ (function(module, exports, __webpack_require__) {
  19108. "use strict";
  19109. exports.__esModule = true;
  19110. var _unicode = __webpack_require__(21);
  19111. var _mixed = __webpack_require__(16);
  19112. var _string = __webpack_require__(36);
  19113. var _array = __webpack_require__(1);
  19114. var _element = __webpack_require__(0);
  19115. var _handsontableEditor = __webpack_require__(189);
  19116. var _handsontableEditor2 = _interopRequireDefault(_handsontableEditor);
  19117. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  19118. var AutocompleteEditor = _handsontableEditor2.default.prototype.extend();
  19119. /**
  19120. * @private
  19121. * @editor AutocompleteEditor
  19122. * @class AutocompleteEditor
  19123. * @dependencies HandsontableEditor
  19124. */
  19125. AutocompleteEditor.prototype.init = function () {
  19126. _handsontableEditor2.default.prototype.init.apply(this, arguments);
  19127. this.query = null;
  19128. this.strippedChoices = [];
  19129. this.rawChoices = [];
  19130. };
  19131. AutocompleteEditor.prototype.getValue = function () {
  19132. var _this2 = this;
  19133. var selectedValue = this.rawChoices.find(function (value) {
  19134. var strippedValue = _this2.stripValueIfNeeded(value);
  19135. return strippedValue === _this2.TEXTAREA.value;
  19136. });
  19137. if ((0, _mixed.isDefined)(selectedValue)) {
  19138. return selectedValue;
  19139. }
  19140. return this.TEXTAREA.value;
  19141. };
  19142. AutocompleteEditor.prototype.createElements = function () {
  19143. _handsontableEditor2.default.prototype.createElements.apply(this, arguments);
  19144. (0, _element.addClass)(this.htContainer, 'autocompleteEditor');
  19145. (0, _element.addClass)(this.htContainer, window.navigator.platform.indexOf('Mac') === -1 ? '' : 'htMacScroll');
  19146. };
  19147. var skipOne = false;
  19148. function onBeforeKeyDown(event) {
  19149. skipOne = false;
  19150. var editor = this.getActiveEditor();
  19151. if ((0, _unicode.isPrintableChar)(event.keyCode) || event.keyCode === _unicode.KEY_CODES.BACKSPACE || event.keyCode === _unicode.KEY_CODES.DELETE || event.keyCode === _unicode.KEY_CODES.INSERT) {
  19152. var timeOffset = 0;
  19153. // on ctl+c / cmd+c don't update suggestion list
  19154. if (event.keyCode === _unicode.KEY_CODES.C && (event.ctrlKey || event.metaKey)) {
  19155. return;
  19156. }
  19157. if (!editor.isOpened()) {
  19158. timeOffset += 10;
  19159. }
  19160. if (editor.htEditor) {
  19161. editor.instance._registerTimeout(setTimeout(function () {
  19162. editor.queryChoices(editor.TEXTAREA.value);
  19163. skipOne = true;
  19164. }, timeOffset));
  19165. }
  19166. }
  19167. }
  19168. AutocompleteEditor.prototype.prepare = function () {
  19169. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  19170. _handsontableEditor2.default.prototype.prepare.apply(this, arguments);
  19171. };
  19172. AutocompleteEditor.prototype.open = function () {
  19173. // Ugly fix for handsontable which grab window object for autocomplete scroll listener instead table element.
  19174. this.TEXTAREA_PARENT.style.overflow = 'auto';
  19175. _handsontableEditor2.default.prototype.open.apply(this, arguments);
  19176. this.TEXTAREA_PARENT.style.overflow = '';
  19177. var choicesListHot = this.htEditor.getInstance();
  19178. var _this = this;
  19179. var trimDropdown = this.cellProperties.trimDropdown === void 0 ? true : this.cellProperties.trimDropdown;
  19180. this.TEXTAREA.style.visibility = 'visible';
  19181. this.focus();
  19182. choicesListHot.updateSettings({
  19183. colWidths: trimDropdown ? [(0, _element.outerWidth)(this.TEXTAREA) - 2] : void 0,
  19184. width: trimDropdown ? (0, _element.outerWidth)(this.TEXTAREA) + (0, _element.getScrollbarWidth)() + 2 : void 0,
  19185. afterRenderer: function afterRenderer(TD, row, col, prop, value, cellProperties) {
  19186. var _this$cellProperties = _this.cellProperties,
  19187. filteringCaseSensitive = _this$cellProperties.filteringCaseSensitive,
  19188. allowHtml = _this$cellProperties.allowHtml;
  19189. var indexOfMatch = void 0;
  19190. var match = void 0;
  19191. value = (0, _mixed.stringify)(value);
  19192. if (value && !allowHtml) {
  19193. indexOfMatch = filteringCaseSensitive === true ? value.indexOf(this.query) : value.toLowerCase().indexOf(_this.query.toLowerCase());
  19194. if (indexOfMatch !== -1) {
  19195. match = value.substr(indexOfMatch, _this.query.length);
  19196. value = value.replace(match, '<strong>' + match + '</strong>');
  19197. }
  19198. }
  19199. TD.innerHTML = value;
  19200. },
  19201. autoColumnSize: true,
  19202. modifyColWidth: function modifyColWidth(width, col) {
  19203. // workaround for <strong> text overlapping the dropdown, not really accurate
  19204. var autoWidths = this.getPlugin('autoColumnSize').widths;
  19205. if (autoWidths[col]) {
  19206. width = autoWidths[col];
  19207. }
  19208. return trimDropdown ? width : width + 15;
  19209. }
  19210. });
  19211. // Add additional space for autocomplete holder
  19212. this.htEditor.view.wt.wtTable.holder.parentNode.style['padding-right'] = (0, _element.getScrollbarWidth)() + 2 + 'px';
  19213. if (skipOne) {
  19214. skipOne = false;
  19215. }
  19216. _this.instance._registerTimeout(setTimeout(function () {
  19217. _this.queryChoices(_this.TEXTAREA.value);
  19218. }, 0));
  19219. };
  19220. AutocompleteEditor.prototype.close = function () {
  19221. _handsontableEditor2.default.prototype.close.apply(this, arguments);
  19222. };
  19223. AutocompleteEditor.prototype.queryChoices = function (query) {
  19224. var _this3 = this;
  19225. this.query = query;
  19226. var source = this.cellProperties.source;
  19227. if (typeof source == 'function') {
  19228. source.call(this.cellProperties, query, function (choices) {
  19229. _this3.rawChoices = choices;
  19230. _this3.updateChoicesList(_this3.stripValuesIfNeeded(choices));
  19231. });
  19232. } else if (Array.isArray(source)) {
  19233. this.rawChoices = source;
  19234. this.updateChoicesList(this.stripValuesIfNeeded(source));
  19235. } else {
  19236. this.updateChoicesList([]);
  19237. }
  19238. };
  19239. AutocompleteEditor.prototype.updateChoicesList = function (choices) {
  19240. var pos = (0, _element.getCaretPosition)(this.TEXTAREA);
  19241. var endPos = (0, _element.getSelectionEndPosition)(this.TEXTAREA);
  19242. var sortByRelevanceSetting = this.cellProperties.sortByRelevance;
  19243. var filterSetting = this.cellProperties.filter;
  19244. var orderByRelevance = null;
  19245. var highlightIndex = null;
  19246. if (sortByRelevanceSetting) {
  19247. orderByRelevance = AutocompleteEditor.sortByRelevance(this.stripValueIfNeeded(this.getValue()), choices, this.cellProperties.filteringCaseSensitive);
  19248. }
  19249. var orderByRelevanceLength = Array.isArray(orderByRelevance) ? orderByRelevance.length : 0;
  19250. if (filterSetting === false) {
  19251. if (orderByRelevanceLength) {
  19252. highlightIndex = orderByRelevance[0];
  19253. }
  19254. } else {
  19255. var sorted = [];
  19256. for (var i = 0, choicesCount = choices.length; i < choicesCount; i++) {
  19257. if (sortByRelevanceSetting && orderByRelevanceLength <= i) {
  19258. break;
  19259. }
  19260. if (orderByRelevanceLength) {
  19261. sorted.push(choices[orderByRelevance[i]]);
  19262. } else {
  19263. sorted.push(choices[i]);
  19264. }
  19265. }
  19266. highlightIndex = 0;
  19267. choices = sorted;
  19268. }
  19269. this.strippedChoices = choices;
  19270. this.htEditor.loadData((0, _array.pivot)([choices]));
  19271. this.updateDropdownHeight();
  19272. this.flipDropdownIfNeeded();
  19273. if (this.cellProperties.strict === true) {
  19274. this.highlightBestMatchingChoice(highlightIndex);
  19275. }
  19276. this.instance.listen(false);
  19277. (0, _element.setCaretPosition)(this.TEXTAREA, pos, pos === endPos ? void 0 : endPos);
  19278. };
  19279. AutocompleteEditor.prototype.flipDropdownIfNeeded = function () {
  19280. var textareaOffset = (0, _element.offset)(this.TEXTAREA);
  19281. var textareaHeight = (0, _element.outerHeight)(this.TEXTAREA);
  19282. var dropdownHeight = this.getDropdownHeight();
  19283. var trimmingContainer = (0, _element.getTrimmingContainer)(this.instance.view.wt.wtTable.TABLE);
  19284. var trimmingContainerScrollTop = trimmingContainer.scrollTop;
  19285. var headersHeight = (0, _element.outerHeight)(this.instance.view.wt.wtTable.THEAD);
  19286. var containerOffset = {
  19287. row: 0,
  19288. col: 0
  19289. };
  19290. if (trimmingContainer !== window) {
  19291. containerOffset = (0, _element.offset)(trimmingContainer);
  19292. }
  19293. var spaceAbove = textareaOffset.top - containerOffset.top - headersHeight + trimmingContainerScrollTop;
  19294. var spaceBelow = trimmingContainer.scrollHeight - spaceAbove - headersHeight - textareaHeight;
  19295. var flipNeeded = dropdownHeight > spaceBelow && spaceAbove > spaceBelow;
  19296. if (flipNeeded) {
  19297. this.flipDropdown(dropdownHeight);
  19298. } else {
  19299. this.unflipDropdown();
  19300. }
  19301. this.limitDropdownIfNeeded(flipNeeded ? spaceAbove : spaceBelow, dropdownHeight);
  19302. return flipNeeded;
  19303. };
  19304. AutocompleteEditor.prototype.limitDropdownIfNeeded = function (spaceAvailable, dropdownHeight) {
  19305. if (dropdownHeight > spaceAvailable) {
  19306. var tempHeight = 0;
  19307. var i = 0;
  19308. var lastRowHeight = 0;
  19309. var height = null;
  19310. do {
  19311. lastRowHeight = this.htEditor.getRowHeight(i) || this.htEditor.view.wt.wtSettings.settings.defaultRowHeight;
  19312. tempHeight += lastRowHeight;
  19313. i++;
  19314. } while (tempHeight < spaceAvailable);
  19315. height = tempHeight - lastRowHeight;
  19316. if (this.htEditor.flipped) {
  19317. this.htEditor.rootElement.style.top = parseInt(this.htEditor.rootElement.style.top, 10) + dropdownHeight - height + 'px';
  19318. }
  19319. this.setDropdownHeight(tempHeight - lastRowHeight);
  19320. }
  19321. };
  19322. AutocompleteEditor.prototype.flipDropdown = function (dropdownHeight) {
  19323. var dropdownStyle = this.htEditor.rootElement.style;
  19324. dropdownStyle.position = 'absolute';
  19325. dropdownStyle.top = -dropdownHeight + 'px';
  19326. this.htEditor.flipped = true;
  19327. };
  19328. AutocompleteEditor.prototype.unflipDropdown = function () {
  19329. var dropdownStyle = this.htEditor.rootElement.style;
  19330. if (dropdownStyle.position === 'absolute') {
  19331. dropdownStyle.position = '';
  19332. dropdownStyle.top = '';
  19333. }
  19334. this.htEditor.flipped = void 0;
  19335. };
  19336. AutocompleteEditor.prototype.updateDropdownHeight = function () {
  19337. var currentDropdownWidth = this.htEditor.getColWidth(0) + (0, _element.getScrollbarWidth)() + 2;
  19338. var trimDropdown = this.cellProperties.trimDropdown;
  19339. this.htEditor.updateSettings({
  19340. height: this.getDropdownHeight(),
  19341. width: trimDropdown ? void 0 : currentDropdownWidth
  19342. });
  19343. this.htEditor.view.wt.wtTable.alignOverlaysWithTrimmingContainer();
  19344. };
  19345. AutocompleteEditor.prototype.setDropdownHeight = function (height) {
  19346. this.htEditor.updateSettings({
  19347. height: height
  19348. });
  19349. };
  19350. AutocompleteEditor.prototype.finishEditing = function (restoreOriginalValue) {
  19351. if (!restoreOriginalValue) {
  19352. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  19353. }
  19354. _handsontableEditor2.default.prototype.finishEditing.apply(this, arguments);
  19355. };
  19356. AutocompleteEditor.prototype.highlightBestMatchingChoice = function (index) {
  19357. if (typeof index === 'number') {
  19358. this.htEditor.selectCell(index, 0, void 0, void 0, void 0, false);
  19359. } else {
  19360. this.htEditor.deselectCell();
  19361. }
  19362. };
  19363. /**
  19364. * Filters and sorts by relevance
  19365. * @param value
  19366. * @param choices
  19367. * @param caseSensitive
  19368. * @returns {Array} array of indexes in original choices array
  19369. */
  19370. AutocompleteEditor.sortByRelevance = function (value, choices, caseSensitive) {
  19371. var choicesRelevance = [];
  19372. var currentItem = void 0;
  19373. var valueLength = value.length;
  19374. var valueIndex = void 0;
  19375. var charsLeft = void 0;
  19376. var result = [];
  19377. var i = void 0;
  19378. var choicesCount = choices.length;
  19379. if (valueLength === 0) {
  19380. for (i = 0; i < choicesCount; i++) {
  19381. result.push(i);
  19382. }
  19383. return result;
  19384. }
  19385. for (i = 0; i < choicesCount; i++) {
  19386. currentItem = (0, _string.stripTags)((0, _mixed.stringify)(choices[i]));
  19387. if (caseSensitive) {
  19388. valueIndex = currentItem.indexOf(value);
  19389. } else {
  19390. valueIndex = currentItem.toLowerCase().indexOf(value.toLowerCase());
  19391. }
  19392. if (valueIndex !== -1) {
  19393. charsLeft = currentItem.length - valueIndex - valueLength;
  19394. choicesRelevance.push({
  19395. baseIndex: i,
  19396. index: valueIndex,
  19397. charsLeft: charsLeft,
  19398. value: currentItem
  19399. });
  19400. }
  19401. }
  19402. choicesRelevance.sort(function (a, b) {
  19403. if (b.index === -1) {
  19404. return -1;
  19405. }
  19406. if (a.index === -1) {
  19407. return 1;
  19408. }
  19409. if (a.index < b.index) {
  19410. return -1;
  19411. } else if (b.index < a.index) {
  19412. return 1;
  19413. } else if (a.index === b.index) {
  19414. if (a.charsLeft < b.charsLeft) {
  19415. return -1;
  19416. } else if (a.charsLeft > b.charsLeft) {
  19417. return 1;
  19418. }
  19419. }
  19420. return 0;
  19421. });
  19422. for (i = 0, choicesCount = choicesRelevance.length; i < choicesCount; i++) {
  19423. result.push(choicesRelevance[i].baseIndex);
  19424. }
  19425. return result;
  19426. };
  19427. AutocompleteEditor.prototype.getDropdownHeight = function () {
  19428. var firstRowHeight = this.htEditor.getInstance().getRowHeight(0) || 23;
  19429. var visibleRows = this.cellProperties.visibleRows;
  19430. return this.strippedChoices.length >= visibleRows ? visibleRows * firstRowHeight : this.strippedChoices.length * firstRowHeight + 8;
  19431. };
  19432. AutocompleteEditor.prototype.stripValueIfNeeded = function (value) {
  19433. return this.stripValuesIfNeeded([value])[0];
  19434. };
  19435. AutocompleteEditor.prototype.stripValuesIfNeeded = function (values) {
  19436. var allowHtml = this.cellProperties.allowHtml;
  19437. var stringifiedValues = (0, _array.arrayMap)(values, function (value) {
  19438. return (0, _mixed.stringify)(value);
  19439. });
  19440. var strippedValues = (0, _array.arrayMap)(stringifiedValues, function (value) {
  19441. return allowHtml ? value : (0, _string.stripTags)(value);
  19442. });
  19443. return strippedValues;
  19444. };
  19445. AutocompleteEditor.prototype.allowKeyEventPropagation = function (keyCode) {
  19446. var selectedRange = this.htEditor.getSelectedRangeLast();
  19447. var selected = { row: selectedRange ? selectedRange.from.row : -1 };
  19448. var allowed = false;
  19449. if (keyCode === _unicode.KEY_CODES.ARROW_DOWN && selected.row > 0 && selected.row < this.htEditor.countRows() - 1) {
  19450. allowed = true;
  19451. }
  19452. if (keyCode === _unicode.KEY_CODES.ARROW_UP && selected.row > -1) {
  19453. allowed = true;
  19454. }
  19455. return allowed;
  19456. };
  19457. AutocompleteEditor.prototype.discardEditor = function (result) {
  19458. _handsontableEditor2.default.prototype.discardEditor.apply(this, arguments);
  19459. this.instance.view.render();
  19460. };
  19461. exports.default = AutocompleteEditor;
  19462. /***/ }),
  19463. /* 189 */
  19464. /***/ (function(module, exports, __webpack_require__) {
  19465. "use strict";
  19466. exports.__esModule = true;
  19467. var _unicode = __webpack_require__(21);
  19468. var _object = __webpack_require__(2);
  19469. var _element = __webpack_require__(0);
  19470. var _event = __webpack_require__(12);
  19471. var _textEditor = __webpack_require__(57);
  19472. var _textEditor2 = _interopRequireDefault(_textEditor);
  19473. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  19474. var HandsontableEditor = _textEditor2.default.prototype.extend();
  19475. /**
  19476. * @private
  19477. * @editor HandsontableEditor
  19478. * @class HandsontableEditor
  19479. * @dependencies TextEditor
  19480. */
  19481. HandsontableEditor.prototype.createElements = function () {
  19482. _textEditor2.default.prototype.createElements.apply(this, arguments);
  19483. var DIV = document.createElement('DIV');
  19484. DIV.className = 'handsontableEditor';
  19485. this.TEXTAREA_PARENT.appendChild(DIV);
  19486. this.htContainer = DIV;
  19487. this.assignHooks();
  19488. };
  19489. HandsontableEditor.prototype.prepare = function (td, row, col, prop, value, cellProperties) {
  19490. _textEditor2.default.prototype.prepare.apply(this, arguments);
  19491. var parent = this;
  19492. var options = {
  19493. startRows: 0,
  19494. startCols: 0,
  19495. minRows: 0,
  19496. minCols: 0,
  19497. className: 'listbox',
  19498. copyPaste: false,
  19499. autoColumnSize: false,
  19500. autoRowSize: false,
  19501. readOnly: true,
  19502. fillHandle: false,
  19503. afterOnCellMouseDown: function afterOnCellMouseDown(_, coords) {
  19504. var value = this.getSourceData(coords.row, coords.col);
  19505. // if the value is undefined then it means we don't want to set the value
  19506. if (value !== void 0) {
  19507. parent.setValue(value);
  19508. }
  19509. parent.instance.destroyEditor();
  19510. }
  19511. };
  19512. if (this.cellProperties.handsontable) {
  19513. (0, _object.extend)(options, cellProperties.handsontable);
  19514. }
  19515. this.htOptions = options;
  19516. };
  19517. var onBeforeKeyDown = function onBeforeKeyDown(event) {
  19518. if ((0, _event.isImmediatePropagationStopped)(event)) {
  19519. return;
  19520. }
  19521. var editor = this.getActiveEditor();
  19522. var innerHOT = editor.htEditor.getInstance();
  19523. var rowToSelect;
  19524. var selectedRow;
  19525. if (event.keyCode == _unicode.KEY_CODES.ARROW_DOWN) {
  19526. if (!innerHOT.getSelectedLast() && !innerHOT.flipped) {
  19527. rowToSelect = 0;
  19528. } else if (innerHOT.getSelectedLast()) {
  19529. if (innerHOT.flipped) {
  19530. rowToSelect = innerHOT.getSelectedLast()[0] + 1;
  19531. } else if (!innerHOT.flipped) {
  19532. selectedRow = innerHOT.getSelectedLast()[0];
  19533. var lastRow = innerHOT.countRows() - 1;
  19534. rowToSelect = Math.min(lastRow, selectedRow + 1);
  19535. }
  19536. }
  19537. } else if (event.keyCode == _unicode.KEY_CODES.ARROW_UP) {
  19538. if (!innerHOT.getSelectedLast() && innerHOT.flipped) {
  19539. rowToSelect = innerHOT.countRows() - 1;
  19540. } else if (innerHOT.getSelectedLast()) {
  19541. if (innerHOT.flipped) {
  19542. selectedRow = innerHOT.getSelectedLast()[0];
  19543. rowToSelect = Math.max(0, selectedRow - 1);
  19544. } else {
  19545. selectedRow = innerHOT.getSelectedLast()[0];
  19546. rowToSelect = selectedRow - 1;
  19547. }
  19548. }
  19549. }
  19550. if (rowToSelect !== void 0) {
  19551. if (rowToSelect < 0 || innerHOT.flipped && rowToSelect > innerHOT.countRows() - 1) {
  19552. innerHOT.deselectCell();
  19553. } else {
  19554. innerHOT.selectCell(rowToSelect, 0);
  19555. }
  19556. if (innerHOT.getData().length) {
  19557. event.preventDefault();
  19558. (0, _event.stopImmediatePropagation)(event);
  19559. editor.instance.listen();
  19560. editor.TEXTAREA.focus();
  19561. }
  19562. }
  19563. };
  19564. HandsontableEditor.prototype.open = function () {
  19565. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  19566. _textEditor2.default.prototype.open.apply(this, arguments);
  19567. if (this.htEditor) {
  19568. this.htEditor.destroy();
  19569. }
  19570. // Construct and initialise a new Handsontable
  19571. this.htEditor = new this.instance.constructor(this.htContainer, this.htOptions);
  19572. this.htEditor.init();
  19573. if (this.cellProperties.strict) {
  19574. this.htEditor.selectCell(0, 0);
  19575. this.TEXTAREA.style.visibility = 'hidden';
  19576. } else {
  19577. this.htEditor.deselectCell();
  19578. this.TEXTAREA.style.visibility = 'visible';
  19579. }
  19580. (0, _element.setCaretPosition)(this.TEXTAREA, 0, this.TEXTAREA.value.length);
  19581. };
  19582. HandsontableEditor.prototype.close = function () {
  19583. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  19584. this.instance.listen();
  19585. _textEditor2.default.prototype.close.apply(this, arguments);
  19586. };
  19587. HandsontableEditor.prototype.focus = function () {
  19588. this.instance.listen();
  19589. _textEditor2.default.prototype.focus.apply(this, arguments);
  19590. };
  19591. HandsontableEditor.prototype.beginEditing = function (initialValue) {
  19592. var onBeginEditing = this.instance.getSettings().onBeginEditing;
  19593. if (onBeginEditing && onBeginEditing() === false) {
  19594. return;
  19595. }
  19596. _textEditor2.default.prototype.beginEditing.apply(this, arguments);
  19597. };
  19598. HandsontableEditor.prototype.finishEditing = function (isCancelled, ctrlDown) {
  19599. if (this.htEditor && this.htEditor.isListening()) {
  19600. // if focus is still in the HOT editor
  19601. this.instance.listen(); // return the focus to the parent HOT instance
  19602. }
  19603. if (this.htEditor && this.htEditor.getSelectedLast()) {
  19604. var value = this.htEditor.getInstance().getValue();
  19605. if (value !== void 0) {
  19606. // if the value is undefined then it means we don't want to set the value
  19607. this.setValue(value);
  19608. }
  19609. }
  19610. return _textEditor2.default.prototype.finishEditing.apply(this, arguments);
  19611. };
  19612. HandsontableEditor.prototype.assignHooks = function () {
  19613. var _this = this;
  19614. this.instance.addHook('afterDestroy', function () {
  19615. if (_this.htEditor) {
  19616. _this.htEditor.destroy();
  19617. }
  19618. });
  19619. };
  19620. exports.default = HandsontableEditor;
  19621. /***/ }),
  19622. /* 190 */
  19623. /***/ (function(module, exports, __webpack_require__) {
  19624. "use strict";
  19625. exports.__esModule = true;
  19626. exports.getNormalizedDate = getNormalizedDate;
  19627. /* eslint-disable import/prefer-default-export */
  19628. /**
  19629. * Get normalized Date object for the ISO formatted date strings.
  19630. * 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.
  19631. * See: Github issue #3338.
  19632. *
  19633. * @param {String} dateString String representing the date.
  19634. * @returns {Date} The proper Date object.
  19635. */
  19636. function getNormalizedDate(dateString) {
  19637. var nativeDate = new Date(dateString);
  19638. // NaN if dateString is not in ISO format
  19639. if (!isNaN(new Date(dateString + "T00:00").getDate())) {
  19640. // Compensate timezone offset
  19641. return new Date(nativeDate.getTime() + nativeDate.getTimezoneOffset() * 60000);
  19642. }
  19643. return nativeDate;
  19644. }
  19645. /***/ }),
  19646. /* 191 */
  19647. /***/ (function(module, exports, __webpack_require__) {
  19648. "use strict";
  19649. /**
  19650. * SheetClip - Spreadsheet Clipboard Parser
  19651. * version 0.2
  19652. *
  19653. * This tiny library transforms JavaScript arrays to strings that are pasteable by LibreOffice, OpenOffice,
  19654. * Google Docs and Microsoft Excel.
  19655. *
  19656. * Copyright 2012, Marcin Warpechowski
  19657. * Licensed under the MIT license.
  19658. * http://github.com/warpech/sheetclip/
  19659. */
  19660. /*jslint white: true*/
  19661. (function (global) {
  19662. "use strict";
  19663. function countQuotes(str) {
  19664. return str.split('"').length - 1;
  19665. }
  19666. var SheetClip = {
  19667. /**
  19668. * Decode spreadsheet string into array
  19669. *
  19670. * @param {String} str
  19671. * @returns {Array}
  19672. */
  19673. parse: function parse(str) {
  19674. var r,
  19675. rLen,
  19676. rows,
  19677. arr = [],
  19678. a = 0,
  19679. c,
  19680. cLen,
  19681. multiline,
  19682. last;
  19683. rows = str.split('\n');
  19684. if (rows.length > 1 && rows[rows.length - 1] === '') {
  19685. rows.pop();
  19686. }
  19687. for (r = 0, rLen = rows.length; r < rLen; r += 1) {
  19688. rows[r] = rows[r].split('\t');
  19689. for (c = 0, cLen = rows[r].length; c < cLen; c += 1) {
  19690. if (!arr[a]) {
  19691. arr[a] = [];
  19692. }
  19693. if (multiline && c === 0) {
  19694. last = arr[a].length - 1;
  19695. arr[a][last] = arr[a][last] + '\n' + rows[r][0];
  19696. if (multiline && countQuotes(rows[r][0]) & 1) {
  19697. //& 1 is a bitwise way of performing mod 2
  19698. multiline = false;
  19699. arr[a][last] = arr[a][last].substring(0, arr[a][last].length - 1).replace(/""/g, '"');
  19700. }
  19701. } else {
  19702. if (c === cLen - 1 && rows[r][c].indexOf('"') === 0 && countQuotes(rows[r][c]) & 1) {
  19703. arr[a].push(rows[r][c].substring(1).replace(/""/g, '"'));
  19704. multiline = true;
  19705. } else {
  19706. arr[a].push(rows[r][c].replace(/""/g, '"'));
  19707. multiline = false;
  19708. }
  19709. }
  19710. }
  19711. if (!multiline) {
  19712. a += 1;
  19713. }
  19714. }
  19715. return arr;
  19716. },
  19717. /**
  19718. * Encode array into valid spreadsheet string
  19719. *
  19720. * @param arr
  19721. * @returns {String}
  19722. */
  19723. stringify: function stringify(arr) {
  19724. var r,
  19725. rLen,
  19726. c,
  19727. cLen,
  19728. str = '',
  19729. val;
  19730. for (r = 0, rLen = arr.length; r < rLen; r += 1) {
  19731. cLen = arr[r].length;
  19732. for (c = 0; c < cLen; c += 1) {
  19733. if (c > 0) {
  19734. str += '\t';
  19735. }
  19736. val = arr[r][c];
  19737. if (typeof val === 'string') {
  19738. if (val.indexOf('\n') > -1) {
  19739. str += '"' + val.replace(/"/g, '""') + '"';
  19740. } else {
  19741. str += val;
  19742. }
  19743. } else if (val === null || val === void 0) {
  19744. // void 0 resolves to undefined
  19745. str += '';
  19746. } else {
  19747. str += val;
  19748. }
  19749. }
  19750. if (r !== rLen - 1) {
  19751. str += '\n';
  19752. }
  19753. }
  19754. return str;
  19755. }
  19756. };
  19757. if (true) {
  19758. exports.parse = SheetClip.parse;
  19759. exports.stringify = SheetClip.stringify;
  19760. } else {
  19761. global.SheetClip = SheetClip;
  19762. }
  19763. })(window);
  19764. /***/ }),
  19765. /* 192 */
  19766. /***/ (function(module, exports, __webpack_require__) {
  19767. "use strict";
  19768. exports.__esModule = true;
  19769. exports.mouseDown = mouseDown;
  19770. exports.mouseOver = mouseOver;
  19771. exports.handleMouseEvent = handleMouseEvent;
  19772. var _event = __webpack_require__(12);
  19773. var _src = __webpack_require__(4);
  19774. /**
  19775. * MouseDown handler.
  19776. *
  19777. * @param {Object} options
  19778. * @param {Boolean} options.isShiftKey The flag which indicates if the shift key is pressed.
  19779. * @param {Boolean} options.isLeftClick The flag which indicates if the left mouse button is pressed.
  19780. * @param {Boolean} options.isRightClick The flag which indicates if the right mouse button is pressed.
  19781. * @param {CellRange} options.coords The CellCoords object with defined visual coordinates.
  19782. * @param {Selection} options.selection The Selection class instance.
  19783. * @param {Object} options.controller An object with keys `row`, `column`, `cell` which indicate what
  19784. * operation will be performed in later selection stages.
  19785. */
  19786. function mouseDown(_ref) {
  19787. var isShiftKey = _ref.isShiftKey,
  19788. isLeftClick = _ref.isLeftClick,
  19789. isRightClick = _ref.isRightClick,
  19790. coords = _ref.coords,
  19791. selection = _ref.selection,
  19792. controller = _ref.controller;
  19793. var currentSelection = selection.isSelected() ? selection.getSelectedRange().current() : null;
  19794. var selectedCorner = selection.isSelectedByCorner();
  19795. var selectedRow = selection.isSelectedByRowHeader();
  19796. var selectedColumn = selection.isSelectedByColumnHeader();
  19797. if (isShiftKey && currentSelection) {
  19798. if (coords.row >= 0 && coords.col >= 0 && !controller.cells) {
  19799. selection.setRangeEnd(coords);
  19800. } else if ((selectedCorner || selectedRow) && coords.row >= 0 && coords.col >= 0 && !controller.cells) {
  19801. selection.setRangeEnd(new _src.CellCoords(coords.row, coords.col));
  19802. } else if (selectedCorner && coords.row < 0 && !controller.column) {
  19803. selection.setRangeEnd(new _src.CellCoords(currentSelection.to.row, coords.col));
  19804. } else if (selectedRow && coords.col < 0 && !controller.row) {
  19805. selection.setRangeEnd(new _src.CellCoords(coords.row, currentSelection.to.col));
  19806. } else if ((!selectedCorner && !selectedRow && coords.col < 0 || selectedCorner && coords.col < 0) && !controller.row) {
  19807. selection.selectRows(currentSelection.from.row, coords.row);
  19808. } else if ((!selectedCorner && !selectedRow && coords.row < 0 || selectedRow && coords.row < 0) && !controller.column) {
  19809. selection.selectColumns(currentSelection.from.col, coords.col);
  19810. }
  19811. } else {
  19812. var newCoord = new _src.CellCoords(coords.row, coords.col);
  19813. if (newCoord.row < 0) {
  19814. newCoord.row = 0;
  19815. }
  19816. if (newCoord.col < 0) {
  19817. newCoord.col = 0;
  19818. }
  19819. var allowRightClickSelection = !selection.inInSelection(newCoord);
  19820. var performSelection = isLeftClick || isRightClick && allowRightClickSelection;
  19821. // clicked row header and when some column was selected
  19822. if (coords.row < 0 && coords.col >= 0 && !controller.column) {
  19823. if (performSelection) {
  19824. selection.selectColumns(coords.col);
  19825. }
  19826. // clicked column header and when some row was selected
  19827. } else if (coords.col < 0 && coords.row >= 0 && !controller.row) {
  19828. if (performSelection) {
  19829. selection.selectRows(coords.row);
  19830. }
  19831. } else if (coords.col >= 0 && coords.row >= 0 && !controller.cells) {
  19832. if (performSelection) {
  19833. selection.setRangeStart(coords);
  19834. }
  19835. } else if (coords.col < 0 && coords.row < 0) {
  19836. selection.setRangeStart(coords);
  19837. }
  19838. }
  19839. }
  19840. /**
  19841. * MouseOver handler.
  19842. *
  19843. * @param {Object} options
  19844. * @param {Boolean} options.isLeftClick
  19845. * @param {CellRange} options.coords The CellCoords object with defined visual coordinates.
  19846. * @param {Selection} options.selection The Selection class instance.
  19847. * @param {Object} options.controller An object with keys `row`, `column`, `cell` which indicate what
  19848. * operation will be performed in later selection stages.
  19849. */
  19850. function mouseOver(_ref2) {
  19851. var isLeftClick = _ref2.isLeftClick,
  19852. coords = _ref2.coords,
  19853. selection = _ref2.selection,
  19854. controller = _ref2.controller;
  19855. if (!isLeftClick) {
  19856. return;
  19857. }
  19858. var selectedRow = selection.isSelectedByRowHeader();
  19859. var selectedColumn = selection.isSelectedByColumnHeader();
  19860. var countCols = selection.tableProps.countCols();
  19861. var countRows = selection.tableProps.countRows();
  19862. if (selectedColumn && !controller.column) {
  19863. selection.setRangeEnd(new _src.CellCoords(countRows - 1, coords.col));
  19864. } else if (selectedRow && !controller.row) {
  19865. selection.setRangeEnd(new _src.CellCoords(coords.row, countCols - 1));
  19866. } else if (!controller.cell) {
  19867. selection.setRangeEnd(coords);
  19868. }
  19869. }
  19870. var handlers = new Map([['mousedown', mouseDown], ['mouseover', mouseOver], ['touchstart', mouseDown]]);
  19871. /**
  19872. * Mouse handler for selection functionality.
  19873. *
  19874. * @param {Event} event An native event to handle.
  19875. * @param {Object} options
  19876. * @param {CellRange} options.coords The CellCoords object with defined visual coordinates.
  19877. * @param {Selection} options.selection The Selection class instance.
  19878. * @param {Object} options.controller An object with keys `row`, `column`, `cell` which indicate what
  19879. * operation will be performed in later selection stages.
  19880. */
  19881. function handleMouseEvent(event, _ref3) {
  19882. var coords = _ref3.coords,
  19883. selection = _ref3.selection,
  19884. controller = _ref3.controller;
  19885. handlers.get(event.type)({
  19886. coords: coords,
  19887. selection: selection,
  19888. controller: controller,
  19889. isShiftKey: event.shiftKey,
  19890. isLeftClick: (0, _event.isLeftClick)(event) || event.type === 'touchstart',
  19891. isRightClick: (0, _event.isRightClick)(event)
  19892. });
  19893. }
  19894. /***/ }),
  19895. /* 193 */
  19896. /***/ (function(module, exports, __webpack_require__) {
  19897. "use strict";
  19898. exports.__esModule = true;
  19899. exports.RecordTranslator = undefined;
  19900. 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; }; }();
  19901. exports.registerIdentity = registerIdentity;
  19902. exports.getTranslator = getTranslator;
  19903. var _core = __webpack_require__(88);
  19904. var _core2 = _interopRequireDefault(_core);
  19905. var _object = __webpack_require__(2);
  19906. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  19907. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  19908. /**
  19909. * @class RecordTranslator
  19910. * @util
  19911. */
  19912. var RecordTranslator = function () {
  19913. function RecordTranslator(hot) {
  19914. _classCallCheck(this, RecordTranslator);
  19915. this.hot = hot;
  19916. }
  19917. /**
  19918. * Translate physical row index into visual.
  19919. *
  19920. * @param {Number} row Physical row index.
  19921. * @returns {Number} Returns visual row index.
  19922. */
  19923. _createClass(RecordTranslator, [{
  19924. key: 'toVisualRow',
  19925. value: function toVisualRow(row) {
  19926. return this.hot.runHooks('unmodifyRow', row);
  19927. }
  19928. /**
  19929. * Translate physical column index into visual.
  19930. *
  19931. * @param {Number} column Physical column index.
  19932. * @returns {Number} Returns visual column index.
  19933. */
  19934. }, {
  19935. key: 'toVisualColumn',
  19936. value: function toVisualColumn(column) {
  19937. return this.hot.runHooks('unmodifyCol', column);
  19938. }
  19939. /**
  19940. * Translate physical coordinates into visual. Can be passed as separate 2 arguments (row, column) or as an object in first
  19941. * argument with `row` and `column` keys.
  19942. *
  19943. * @param {Number|Object} row Physical coordinates or row index.
  19944. * @param {Number} [column] Physical column index.
  19945. * @returns {Object|Array} Returns an object with visual records or an array if coordinates passed as separate arguments.
  19946. */
  19947. }, {
  19948. key: 'toVisual',
  19949. value: function toVisual(row, column) {
  19950. var result = void 0;
  19951. if ((0, _object.isObject)(row)) {
  19952. result = {
  19953. row: this.toVisualRow(row.row),
  19954. column: this.toVisualColumn(row.column)
  19955. };
  19956. } else {
  19957. result = [this.toVisualRow(row), this.toVisualColumn(column)];
  19958. }
  19959. return result;
  19960. }
  19961. /**
  19962. * Translate visual row index into physical.
  19963. *
  19964. * @param {Number} row Visual row index.
  19965. * @returns {Number} Returns physical row index.
  19966. */
  19967. }, {
  19968. key: 'toPhysicalRow',
  19969. value: function toPhysicalRow(row) {
  19970. return this.hot.runHooks('modifyRow', row);
  19971. }
  19972. /**
  19973. * Translate visual column index into physical.
  19974. *
  19975. * @param {Number} column Visual column index.
  19976. * @returns {Number} Returns physical column index.
  19977. */
  19978. }, {
  19979. key: 'toPhysicalColumn',
  19980. value: function toPhysicalColumn(column) {
  19981. return this.hot.runHooks('modifyCol', column);
  19982. }
  19983. /**
  19984. * Translate visual coordinates into physical. Can be passed as separate 2 arguments (row, column) or as an object in first
  19985. * argument with `row` and `column` keys.
  19986. *
  19987. * @param {Number|Object} row Visual coordinates or row index.
  19988. * @param {Number} [column] Visual column index.
  19989. * @returns {Object|Array} Returns an object with physical records or an array if coordinates passed as separate arguments.
  19990. */
  19991. }, {
  19992. key: 'toPhysical',
  19993. value: function toPhysical(row, column) {
  19994. var result = void 0;
  19995. if ((0, _object.isObject)(row)) {
  19996. result = {
  19997. row: this.toPhysicalRow(row.row),
  19998. column: this.toPhysicalColumn(row.column)
  19999. };
  20000. } else {
  20001. result = [this.toPhysicalRow(row), this.toPhysicalColumn(column)];
  20002. }
  20003. return result;
  20004. }
  20005. }]);
  20006. return RecordTranslator;
  20007. }();
  20008. exports.RecordTranslator = RecordTranslator;
  20009. var identities = new WeakMap();
  20010. var translatorSingletons = new WeakMap();
  20011. function registerIdentity(identity, hot) {
  20012. identities.set(identity, hot);
  20013. }
  20014. function getTranslator(identity) {
  20015. var singleton = void 0;
  20016. if (!(identity instanceof _core2.default)) {
  20017. if (!identities.has(identity)) {
  20018. throw Error('Record translator was not registered for this object identity');
  20019. }
  20020. identity = identities.get(identity);
  20021. }
  20022. if (translatorSingletons.has(identity)) {
  20023. singleton = translatorSingletons.get(identity);
  20024. } else {
  20025. singleton = new RecordTranslator(identity);
  20026. translatorSingletons.set(identity, singleton);
  20027. }
  20028. return singleton;
  20029. }
  20030. /***/ }),
  20031. /* 194 */
  20032. /***/ (function(module, exports, __webpack_require__) {
  20033. "use strict";
  20034. exports.__esModule = true;
  20035. exports.registerAsRootInstance = registerAsRootInstance;
  20036. exports.hasValidParameter = hasValidParameter;
  20037. exports.isRootInstance = isRootInstance;
  20038. var holder = exports.holder = new WeakMap();
  20039. var rootInstanceSymbol = exports.rootInstanceSymbol = Symbol('rootInstance');
  20040. /**
  20041. * Register an object as a root instance.
  20042. *
  20043. * @param {Object} object An object to associate with root instance flag.
  20044. */
  20045. function registerAsRootInstance(object) {
  20046. holder.set(object, true);
  20047. }
  20048. /**
  20049. * Check if the source of the root indication call is valid.
  20050. *
  20051. * @param {Symbol} rootSymbol A symbol as a source of truth.
  20052. * @return {Boolean}
  20053. */
  20054. function hasValidParameter(rootSymbol) {
  20055. return rootSymbol === rootInstanceSymbol;
  20056. }
  20057. /**
  20058. * Check if passed an object was flagged as a root instance.
  20059. *
  20060. * @param {Object} object An object to check.
  20061. * @return {Boolean}
  20062. */
  20063. function isRootInstance(object) {
  20064. return holder.has(object);
  20065. }
  20066. /***/ }),
  20067. /* 195 */
  20068. /***/ (function(module, exports, __webpack_require__) {
  20069. "use strict";
  20070. exports.__esModule = true;
  20071. 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; };
  20072. var _mixed = __webpack_require__(16);
  20073. var _object = __webpack_require__(2);
  20074. /**
  20075. * @alias Options
  20076. * @constructor
  20077. * @description
  20078. * ## Constructor options
  20079. *
  20080. * Constructor options are applied using an object literal passed as a second argument to the Handsontable constructor.
  20081. *
  20082. * ```js
  20083. * var hot = new Handsontable(document.getElementById('example1'), {
  20084. * data: myArray,
  20085. * width: 400,
  20086. * height: 300
  20087. * });
  20088. * ```
  20089. *
  20090. * ---
  20091. * ## Cascading configuration
  20092. *
  20093. * Handsontable 0.9 and newer is using *Cascading Configuration*, which is a fast way to provide configuration options
  20094. * for the entire table, including its columns and particular cells.
  20095. *
  20096. * Consider the following example:
  20097. * ```js
  20098. * var hot = new Handsontable(document.getElementById('example'), {
  20099. * readOnly: true,
  20100. * columns: [
  20101. * {readOnly: false},
  20102. * {},
  20103. * {}
  20104. * ],
  20105. * cells: function (row, col, prop) {
  20106. * var cellProperties = {};
  20107. *
  20108. * if (row === 0 && col === 0) {
  20109. * cellProperties.readOnly = true;
  20110. * }
  20111. *
  20112. * return cellProperties;
  20113. * }
  20114. * });
  20115. * ```
  20116. *
  20117. * 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*.
  20118. *
  20119. * ### The Cascading Configuration model
  20120. *
  20121. * ##### 1. Constructor
  20122. *
  20123. * Configuration options that are provided using first-level `handsontable(container, {option: "value"})` and `updateSettings` method.
  20124. *
  20125. * ##### 2. Columns
  20126. *
  20127. * Configuration options that are provided using second-level object `handsontable(container, {columns: {option: "value"}]})`
  20128. *
  20129. * ##### 3. Cells
  20130. *
  20131. * Configuration options that are provided using third-level function `handsontable(container, {cells: function: (row, col, prop){ }})`
  20132. *
  20133. * ---
  20134. * ## Architecture performance
  20135. *
  20136. * The Cascading Configuration model is based on prototypical inheritance. It is much faster and memory efficient compared
  20137. * to the previous model that used jQuery extend. See: [http://jsperf.com/extending-settings](http://jsperf.com/extending-settings).
  20138. *
  20139. * ---
  20140. * __Important notice:__ In order for the data separation to work properly, make sure that each instance of Handsontable has a unique `id`.
  20141. */
  20142. function DefaultSettings() {};
  20143. DefaultSettings.prototype = {
  20144. /**
  20145. * License key for commercial version of Handsontable.
  20146. *
  20147. * @pro
  20148. * @type {String}
  20149. * @default 'trial'
  20150. */
  20151. licenseKey: 'trial',
  20152. /**
  20153. * @description
  20154. * Initial data source that will be bound to the data grid __by reference__ (editing data grid alters the data source).
  20155. * Can be declared as an Array of Arrays, Array of Objects or a Function.
  20156. *
  20157. * See [Understanding binding as reference](http://docs.handsontable.com/tutorial-data-binding.html#page-reference).
  20158. *
  20159. * @type {Array|Function}
  20160. * @default undefined
  20161. */
  20162. data: void 0,
  20163. /**
  20164. * @description
  20165. * Defines the structure of a new row when data source is an array of objects.
  20166. *
  20167. * See [data-schema](http://docs.handsontable.com/tutorial-data-sources.html#page-data-schema) for examples.
  20168. *
  20169. * @type {Object}
  20170. * @default undefined
  20171. */
  20172. dataSchema: void 0,
  20173. /**
  20174. * Width of the grid. Can be a value or a function that returns a value.
  20175. *
  20176. * @type {Number|Function}
  20177. * @default undefined
  20178. */
  20179. width: void 0,
  20180. /**
  20181. * Height of the grid. Can be a number or a function that returns a number.
  20182. *
  20183. * @type {Number|Function}
  20184. * @default undefined
  20185. */
  20186. height: void 0,
  20187. /**
  20188. * @description
  20189. * Initial number of rows.
  20190. *
  20191. * __Notice:__ This option only has effect in Handsontable constructor and only if `data` option is not provided
  20192. *
  20193. * @type {Number}
  20194. * @default 5
  20195. */
  20196. startRows: 5,
  20197. /**
  20198. * @description
  20199. * Initial number of columns.
  20200. *
  20201. * __Notice:__ This option only has effect in Handsontable constructor and only if `data` option is not provided
  20202. *
  20203. * @type {Number}
  20204. * @default 5
  20205. */
  20206. startCols: 5,
  20207. /**
  20208. * Setting `true` or `false` will enable or disable the default row headers (1, 2, 3).
  20209. * You can also define an array `['One', 'Two', 'Three', ...]` or a function to define the headers.
  20210. * If a function is set the index of the row is passed as a parameter.
  20211. *
  20212. * @type {Boolean|Array|Function}
  20213. * @default null
  20214. * @example
  20215. * ```js
  20216. * ...
  20217. * // as boolean
  20218. * rowHeaders: true,
  20219. * ...
  20220. *
  20221. * ...
  20222. * // as array
  20223. * rowHeaders: [1, 2, 3],
  20224. * ...
  20225. *
  20226. * ...
  20227. * // as function
  20228. * rowHeaders: function(index) {
  20229. * return index + ': AB';
  20230. * },
  20231. * ...
  20232. * ```
  20233. */
  20234. rowHeaders: void 0,
  20235. /**
  20236. * Setting `true` or `false` will enable or disable the default column headers (A, B, C).
  20237. * You can also define an array `['One', 'Two', 'Three', ...]` or a function to define the headers.
  20238. * If a function is set, then the index of the column is passed as a parameter.
  20239. *
  20240. * @type {Boolean|Array|Function}
  20241. * @default null
  20242. * @example
  20243. * ```js
  20244. * ...
  20245. * // as boolean
  20246. * colHeaders: true,
  20247. * ...
  20248. *
  20249. * ...
  20250. * // as array
  20251. * colHeaders: ['A', 'B', 'C'],
  20252. * ...
  20253. *
  20254. * ...
  20255. * // as function
  20256. * colHeaders: function(index) {
  20257. * return index + ': AB';
  20258. * },
  20259. * ...
  20260. * ```
  20261. */
  20262. colHeaders: null,
  20263. /**
  20264. * Defines column widths in pixels. Accepts number, string (that will be converted to a number),
  20265. * array of numbers (if you want to define column width separately for each column) or a
  20266. * function (if you want to set column width dynamically on each render).
  20267. *
  20268. * @type {Array|Function|Number|String}
  20269. * @default undefined
  20270. * @example
  20271. * ```js
  20272. * ...
  20273. * // as numeric, for each column.
  20274. * colWidths: 100,
  20275. * ...
  20276. *
  20277. * * ...
  20278. * // as string, for each column.
  20279. * colWidths: '100px',
  20280. * ...
  20281. *
  20282. * ...
  20283. * // as array, based on visual indexes. The rest of the columns have a default width.
  20284. * colWidths: [100, 120, 90],
  20285. * ...
  20286. *
  20287. * ...
  20288. * // as function, based on visual indexes.
  20289. * colWidths: function(index) {
  20290. * return index * 10;
  20291. * },
  20292. * ...
  20293. * ```
  20294. */
  20295. colWidths: void 0,
  20296. /**
  20297. * Defines row heights in pixels. Accepts numbers, strings (that will be converted into a number),
  20298. * array of numbers (if you want to define row height separately for each row) or a
  20299. * function (if you want to set row height dynamically on each render).
  20300. * If the ManualRowResize or AutoRowSize plugins are enabled, this is also the minimum height that can be set
  20301. * via either of those two plugins.
  20302. * Height should be equal or greater than 23px. Table is rendered incorrectly if height is less than 23px.
  20303. *
  20304. * @type {Array|Function|Number|String}
  20305. * @default undefined
  20306. * @example
  20307. * ```js
  20308. * ...
  20309. * // as numeric, for each row.
  20310. * rowHeights: 100,
  20311. * ...
  20312. *
  20313. * * ...
  20314. * // as string, for each row.
  20315. * rowHeights: '100px',
  20316. * ...
  20317. *
  20318. * ...
  20319. * // as array, based on visual indexes. The rest of the rows have a default height.
  20320. * rowHeights: [100, 120, 90],
  20321. * ...
  20322. *
  20323. * ...
  20324. * // as function, based on visual indexes.
  20325. * rowHeights: function(index) {
  20326. * return index * 10;
  20327. * },
  20328. * ...
  20329. * ```
  20330. */
  20331. rowHeights: void 0,
  20332. /**
  20333. * @description
  20334. * Defines the cell properties and data binding for certain columns.
  20335. *
  20336. * __Notice:__ Using this option sets a fixed number of columns (options `startCols`, `minCols`, `maxCols` will be ignored).
  20337. *
  20338. * See [documentation -> datasources.html](http://docs.handsontable.com/tutorial-data-sources.html#page-nested) for examples.
  20339. *
  20340. * @type {Array|Function}
  20341. * @default undefined
  20342. * @example
  20343. * ```js
  20344. * ...
  20345. * // as an array of objects. Order of the objects in array is representation of physical indexes.
  20346. * columns: [
  20347. * {
  20348. * // column options for the first column
  20349. * type: 'numeric',
  20350. * numericFormat: {
  20351. * pattern: '0,0.00 $'
  20352. * }
  20353. * },
  20354. * {
  20355. * // column options for the second column
  20356. * type: 'text',
  20357. * readOnly: true
  20358. * }
  20359. * ],
  20360. * ...
  20361. *
  20362. * // or as function, based on physical indexes
  20363. * ...
  20364. * columns: function(index) {
  20365. * return {
  20366. * type: index > 0 ? 'numeric' : 'text',
  20367. * readOnly: index < 1
  20368. * }
  20369. * }
  20370. * ...
  20371. * ```
  20372. */
  20373. columns: void 0,
  20374. /**
  20375. * @description
  20376. * Defines the cell properties for given `row`, `col`, `prop` coordinates.
  20377. * Any constructor or column option may be overwritten for a particular cell (row/column combination)
  20378. * using the `cells` property in the Handsontable constructor.
  20379. *
  20380. * __Note:__ Parameters `row` and `col` always represent __physical indexes__. Example below show how to execute
  20381. * operations based on the __visual__ representation of Handsontable.
  20382. *
  20383. * Possible values of `prop`:
  20384. * - property name for column's data source object, when dataset is an [array of objects](/tutorial-data-sources.html#page-object)
  20385. * - the same number as `col`, when dataset is an [array of arrays](/tutorial-data-sources.html#page-array)
  20386. *
  20387. * @type {Function}
  20388. * @default undefined
  20389. * @example
  20390. * ```js
  20391. * ...
  20392. * cells: function (row, col, prop) {
  20393. * var cellProperties = {};
  20394. * var visualRowIndex = this.instance.toVisualRow(row);
  20395. * var visualColIndex = this.instance.toVisualColumn(col);
  20396. *
  20397. * if (visualRowIndex === 0 && visualColIndex === 0) {
  20398. * cellProperties.readOnly = true;
  20399. * }
  20400. *
  20401. * return cellProperties;
  20402. * },
  20403. * ...
  20404. * ```
  20405. */
  20406. cells: void 0,
  20407. /**
  20408. * Any constructor or column option may be overwritten for a particular cell (row/column combination), using `cell`
  20409. * array passed to the Handsontable constructor.
  20410. *
  20411. * @type {Array}
  20412. * @default []
  20413. * @example
  20414. * ```js
  20415. * ...
  20416. * cell: [
  20417. * {row: 0, col: 0, readOnly: true}
  20418. * ],
  20419. * ...
  20420. * ```
  20421. */
  20422. cell: [],
  20423. /**
  20424. * @description
  20425. * If `true`, enables the {@link Comments} plugin, which enables an option to apply cell comments through the context menu
  20426. * (configurable with context menu keys `commentsAddEdit`, `commentsRemove`).
  20427. *
  20428. * To initialize Handsontable with predefined comments, provide cell coordinates and comment text values in a form of an array.
  20429. *
  20430. * See [Comments](http://docs.handsontable.com/demo-comments_.html) demo for examples.
  20431. *
  20432. * @since 0.11.0
  20433. * @type {Boolean|Array}
  20434. * @default false
  20435. * @example
  20436. * ```js
  20437. * ...
  20438. * comments: [{row: 1, col: 1, comment: {value: "Test comment"}}],
  20439. * ...
  20440. * ```
  20441. */
  20442. comments: false,
  20443. /**
  20444. * @description
  20445. * 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`).
  20446. *
  20447. * To initialize Handsontable with predefined custom borders, provide cell coordinates and border styles in a form of an array.
  20448. *
  20449. * See [Custom Borders](http://docs.handsontable.com/demo-custom-borders.html) demo for examples.
  20450. *
  20451. * @since 0.11.0
  20452. * @type {Boolean|Array}
  20453. * @default false
  20454. * @example
  20455. * ```js
  20456. * ...
  20457. * customBorders: [
  20458. * {range: {
  20459. * from: {row: 1, col: 1},
  20460. * to: {row: 3, col: 4}},
  20461. * left: {},
  20462. * right: {},
  20463. * top: {},
  20464. * bottom: {}
  20465. * }
  20466. * ],
  20467. * ...
  20468. *
  20469. * // or
  20470. * ...
  20471. * customBorders: [
  20472. * {row: 2, col: 2, left: {width: 2, color: 'red'},
  20473. * right: {width: 1, color: 'green'}, top: '', bottom: ''}
  20474. * ],
  20475. * ...
  20476. * ```
  20477. */
  20478. customBorders: false,
  20479. /**
  20480. * Minimum number of rows. At least that number of rows will be created during initialization.
  20481. *
  20482. * @type {Number}
  20483. * @default 0
  20484. */
  20485. minRows: 0,
  20486. /**
  20487. * Minimum number of columns. At least that number of columns will be created during initialization.
  20488. *
  20489. * @type {Number}
  20490. * @default 0
  20491. */
  20492. minCols: 0,
  20493. /**
  20494. * 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.
  20495. *
  20496. * @type {Number}
  20497. * @default Infinity
  20498. */
  20499. maxRows: Infinity,
  20500. /**
  20501. * 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.
  20502. *
  20503. * @type {Number}
  20504. * @default Infinity
  20505. */
  20506. maxCols: Infinity,
  20507. /**
  20508. * When set to 1 (or more), Handsontable will add a new row at the end of grid if there are no more empty rows.
  20509. * (unless the number of rows exceeds the one set in the `maxRows` property)
  20510. *
  20511. * @type {Number}
  20512. * @default 0
  20513. */
  20514. minSpareRows: 0,
  20515. /**
  20516. * When set to 1 (or more), Handsontable will add a new column at the end of grid if there are no more empty columns.
  20517. * (unless the number of rows exceeds the one set in the `maxCols` property)
  20518. *
  20519. * @type {Number}
  20520. * @default 0
  20521. */
  20522. minSpareCols: 0,
  20523. /**
  20524. * If set to `false`, there won't be an option to insert new rows in the Context Menu.
  20525. *
  20526. * @type {Boolean}
  20527. * @default true
  20528. */
  20529. allowInsertRow: true,
  20530. /**
  20531. * If set to `false`, there won't be an option to insert new columns in the Context Menu.
  20532. *
  20533. * @type {Boolean}
  20534. * @default true
  20535. */
  20536. allowInsertColumn: true,
  20537. /**
  20538. * If set to `false`, there won't be an option to remove rows in the Context Menu.
  20539. *
  20540. * @type {Boolean}
  20541. * @default true
  20542. */
  20543. allowRemoveRow: true,
  20544. /**
  20545. * If set to `false`, there won't be an option to remove columns in the Context Menu.
  20546. *
  20547. * @type {Boolean}
  20548. * @default true
  20549. */
  20550. allowRemoveColumn: true,
  20551. /**
  20552. * @description
  20553. * Defines how the table selection reacts. The selection support three different behaviors defined as:
  20554. * * `'single'` Only a single cell can be selected.
  20555. * * `'range'` Multiple cells within a single range can be selected.
  20556. * * `'multiple'` Multiple ranges of cells can be selected.
  20557. *
  20558. * To see how to interact with selection by getting selected data or change styles of the selected cells go to
  20559. * [https://docs.handsontable.com/demo-selecting-ranges.html](https://docs.handsontable.com/demo-selecting-ranges.html).
  20560. *
  20561. * @since 0.36.0
  20562. * @type {String}
  20563. * @default 'multiple'
  20564. */
  20565. selectionMode: 'multiple',
  20566. /**
  20567. * Enables the fill handle (drag-down and copy-down) functionality, which shows a small rectangle in bottom
  20568. * right corner of the selected area, that let's you expand values to the adjacent cells.
  20569. *
  20570. * Possible values: `true` (to enable in all directions), `'vertical'` or `'horizontal'` (to enable in one direction),
  20571. * `false` (to disable completely). Setting to `true` enables the fillHandle plugin.
  20572. *
  20573. * Since 0.23.0 you can pass object to plugin which allows you to add more options for this functionality. If `autoInsertRow`
  20574. * option is `true`, fill-handler will create new rows till it reaches the last row. It is enabled by default.
  20575. *
  20576. * @example
  20577. * ```js
  20578. * ...
  20579. * fillHandle: true // enable plugin in all directions and with autoInsertRow as true
  20580. * ...
  20581. * // or
  20582. * ...
  20583. * fillHandle: 'vertical' // enable plugin in vertical direction and with autoInsertRow as true
  20584. * ...
  20585. * // or
  20586. * ...
  20587. * fillHandle: { // enable plugin in both directions and with autoInsertRow as false
  20588. * autoInsertRow: false,
  20589. * }
  20590. * // or
  20591. * ...
  20592. * fillHandle: { // enable plugin in vertical direction and with autoInsertRow as false
  20593. * autoInsertRow: false,
  20594. * direction: 'vertical' // 'vertical' or 'horizontal'
  20595. * }
  20596. * ```
  20597. *
  20598. * @type {Boolean|String|Object}
  20599. * @default true
  20600. */
  20601. fillHandle: true,
  20602. /**
  20603. * Allows to specify the number of fixed (or *frozen*) rows at the top of the table.
  20604. *
  20605. * @type {Number}
  20606. * @default 0
  20607. * @example
  20608. * ```js
  20609. * fixedRowsTop: 3 // This would freeze the top 3 rows of the table.
  20610. * ```
  20611. */
  20612. fixedRowsTop: 0,
  20613. /**
  20614. * Allows to specify the number of fixed (or *frozen*) rows at the bottom of the table.
  20615. *
  20616. * @pro
  20617. * @type {Number}
  20618. * @default 0
  20619. * @example
  20620. * ```js
  20621. * fixedRowsBottom: 3 // This would freeze the top 3 rows of the table.
  20622. * ```
  20623. */
  20624. fixedRowsBottom: 0,
  20625. /**
  20626. * Allows to specify the number of fixed (or *frozen*) columns on the left of the table.
  20627. *
  20628. * @type {Number}
  20629. * @default 0
  20630. * @example
  20631. * ```js
  20632. * fixedColumnsLeft: 3 // This would freeze the top 3 rows of the table.
  20633. * ```
  20634. */
  20635. fixedColumnsLeft: 0,
  20636. /**
  20637. * If `true`, mouse click outside the grid will deselect the current selection.
  20638. * Can be a function that takes the click event target and returns a boolean.
  20639. *
  20640. * @type {Boolean|Function}
  20641. * @default true
  20642. */
  20643. outsideClickDeselects: true,
  20644. /**
  20645. * If `true`, <kbd>ENTER</kbd> begins editing mode (like in Google Docs). If `false`, <kbd>ENTER</kbd> moves to next
  20646. * row (like Excel) and adds a new row if necessary. <kbd>TAB</kbd> adds new column if necessary.
  20647. *
  20648. * @type {Boolean}
  20649. * @default true
  20650. */
  20651. enterBeginsEditing: true,
  20652. /**
  20653. * Defines the cursor movement after <kbd>ENTER</kbd> was pressed (<kbd>SHIFT</kbd> + <kbd>ENTER</kbd> uses a negative vector).
  20654. * Can be an object or a function that returns an object. The event argument passed to the function
  20655. * is a DOM Event object received after the <kbd>ENTER</kbd> key has been pressed. This event object can be used to check
  20656. * whether user pressed <kbd>ENTER</kbd> or <kbd>SHIFT</kbd> + <kbd>ENTER</kbd>.
  20657. *
  20658. * @type {Object|Function}
  20659. * @default {row: 1, col: 0}
  20660. */
  20661. enterMoves: { row: 1, col: 0 },
  20662. /**
  20663. * Defines the cursor movement after <kbd>TAB</kbd> is pressed (<kbd>SHIFT</kbd> + <kbd>TAB</kbd> uses a negative vector).
  20664. * Can be an object or a function that returns an object. The event argument passed to the function
  20665. * is a DOM Event object received after the <kbd>TAB</kbd> key has been pressed. This event object can be used to check
  20666. * whether user pressed <kbd>TAB</kbd> or <kbd>SHIFT</kbd> + <kbd>TAB</kbd>.
  20667. *
  20668. * @type {Object}
  20669. * @default {row: 0, col: 1}
  20670. */
  20671. tabMoves: { row: 0, col: 1 },
  20672. /**
  20673. * If `true`, pressing <kbd>TAB</kbd> or right arrow in the last column will move to first column in next row.
  20674. *
  20675. * @type {Boolean}
  20676. * @default false
  20677. */
  20678. autoWrapRow: false,
  20679. /**
  20680. * If `true`, pressing <kbd>ENTER</kbd> or down arrow in the last row will move to the first row in the next column.
  20681. *
  20682. * @type {Boolean}
  20683. * @default false
  20684. */
  20685. autoWrapCol: false,
  20686. /**
  20687. * @description
  20688. * Turns on saving the state of column sorting, column positions and column sizes in local storage.
  20689. *
  20690. * You can save any sort of data in local storage to preserve table state between page reloads.
  20691. * In order to enable data storage mechanism, `persistentState` option must be set to `true` (you can set it
  20692. * either during Handsontable initialization or using the `updateSettings` method). When `persistentState` is enabled it exposes 3 hooks:
  20693. *
  20694. * __persistentStateSave__ (key: String, value: Mixed)
  20695. *
  20696. * * Saves value under given key in browser local storage.
  20697. *
  20698. * __persistentStateLoad__ (key: String, valuePlaceholder: Object)
  20699. *
  20700. * * Loads `value`, saved under given key, form browser local storage. The loaded `value` will be saved in `valuePlaceholder.value`
  20701. * (this is due to specific behaviour of `Hooks.run()` method). If no value have been saved under key `valuePlaceholder.value`
  20702. * will be `undefined`.
  20703. *
  20704. * __persistentStateReset__ (key: String)
  20705. *
  20706. * * Clears the value saved under `key`. If no `key` is given, all values associated with table will be cleared.
  20707. *
  20708. * __Note:__ The main reason behind using `persistentState` hooks rather than regular LocalStorage API is that it
  20709. * ensures separation of data stored by multiple Handsontable instances. In other words, if you have two (or more)
  20710. * instances of Handsontable on one page, data saved by one instance won't be accessible by the second instance.
  20711. * Those two instances can store data under the same key and no data would be overwritten.
  20712. *
  20713. * __Important:__ In order for the data separation to work properly, make sure that each instance of Handsontable has a unique `id`.
  20714. *
  20715. * @type {Boolean}
  20716. * @default false
  20717. */
  20718. persistentState: void 0,
  20719. /**
  20720. * Class name for all visible rows in the current selection.
  20721. *
  20722. * @type {String}
  20723. * @default undefined
  20724. * @example
  20725. * ```js
  20726. * currentRowClassName: 'currentRow' // This will add a 'currentRow' class name to appropriate table cells.
  20727. * ```
  20728. */
  20729. currentRowClassName: void 0,
  20730. /**
  20731. * Class name for all visible columns in the current selection.
  20732. *
  20733. * @type {String}
  20734. * @default undefined
  20735. * @example
  20736. * ```js
  20737. * currentColClassName: 'currentColumn' // This will add a 'currentColumn' class name to appropriate table cells.
  20738. * ```
  20739. */
  20740. currentColClassName: void 0,
  20741. /**
  20742. * Class name for all visible headers in current selection.
  20743. *
  20744. * @type {String}
  20745. * @since 0.27.0
  20746. * @default 'ht__highlight'
  20747. * @example
  20748. * ```js
  20749. * currentHeaderClassName: 'ht__highlight' // This will add a 'ht__highlight' class name to appropriate table headers.
  20750. * ```
  20751. */
  20752. currentHeaderClassName: 'ht__highlight',
  20753. /**
  20754. * Class name for all active headers in selections. The header will be marked with this class name
  20755. * only when a whole column or row will be selected.
  20756. *
  20757. * @type {String}
  20758. * @since 0.38.2
  20759. * @default 'ht__active_highlight'
  20760. * @example
  20761. * ```js
  20762. * activeHeaderClassName: 'ht__active_highlight' // This will add a 'ht__active_highlight' class name to appropriate table headers.
  20763. * ```
  20764. */
  20765. activeHeaderClassName: 'ht__active_highlight',
  20766. /**
  20767. * Class name for the Handsontable container element.
  20768. *
  20769. * @type {String|Array}
  20770. * @default undefined
  20771. */
  20772. className: void 0,
  20773. /**
  20774. * Class name for all tables inside container element.
  20775. *
  20776. * @since 0.17.0
  20777. * @type {String|Array}
  20778. * @default undefined
  20779. */
  20780. tableClassName: void 0,
  20781. /**
  20782. * @description
  20783. * Defines how the columns react, when the declared table width is different than the calculated sum of all column widths.
  20784. * [See more](http://docs.handsontable.com/demo-stretching.html) mode. Possible values:
  20785. * * `'none'` Disable stretching
  20786. * * `'last'` Stretch only the last column
  20787. * * `'all'` Stretch all the columns evenly
  20788. *
  20789. * @type {String}
  20790. * @default 'none'
  20791. */
  20792. stretchH: 'none',
  20793. /**
  20794. * Lets you overwrite the default `isEmptyRow` method, which checks if row at the provided index is empty.
  20795. *
  20796. * @type {Function}
  20797. * @param {Number} row Visual row index.
  20798. * @returns {Boolean}
  20799. */
  20800. isEmptyRow: function isEmptyRow(row) {
  20801. var col, colLen, value, meta;
  20802. for (col = 0, colLen = this.countCols(); col < colLen; col++) {
  20803. value = this.getDataAtCell(row, col);
  20804. if (value !== '' && value !== null && (0, _mixed.isDefined)(value)) {
  20805. if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
  20806. meta = this.getCellMeta(row, col);
  20807. return (0, _object.isObjectEqual)(this.getSchema()[meta.prop], value);
  20808. }
  20809. return false;
  20810. }
  20811. }
  20812. return true;
  20813. },
  20814. /**
  20815. * Lets you overwrite the default `isEmptyCol` method, which checks if column at the provided index is empty.
  20816. *
  20817. * @type {Function}
  20818. * @param {Number} col Visual column index
  20819. * @returns {Boolean}
  20820. */
  20821. isEmptyCol: function isEmptyCol(col) {
  20822. var row, rowLen, value;
  20823. for (row = 0, rowLen = this.countRows(); row < rowLen; row++) {
  20824. value = this.getDataAtCell(row, col);
  20825. if (value !== '' && value !== null && (0, _mixed.isDefined)(value)) {
  20826. return false;
  20827. }
  20828. }
  20829. return true;
  20830. },
  20831. /**
  20832. * When set to `true`, the table is re-rendered when it is detected that it was made visible in DOM.
  20833. *
  20834. * @type {Boolean}
  20835. * @default true
  20836. */
  20837. observeDOMVisibility: true,
  20838. /**
  20839. * If set to `true`, Handsontable will accept values that were marked as invalid by the cell `validator`.
  20840. * It will result with *invalid* cells being treated as *valid* (will save the *invalid* value into the Handsontable data source).
  20841. * If set to `false`, Handsontable will *not* accept the invalid values and won't allow the user to close the editor.
  20842. * This option will be particularly useful when used with the Autocomplete's `strict` mode.
  20843. *
  20844. * @type {Boolean}
  20845. * @default true
  20846. * @since 0.9.5
  20847. */
  20848. allowInvalid: true,
  20849. /**
  20850. * If set to `true`, Handsontable will accept values that are empty (`null`, `undefined` or `''`).
  20851. * If set to `false`, Handsontable will *not* accept the empty values and mark cell as invalid.
  20852. *
  20853. * @example
  20854. * ```js
  20855. * ...
  20856. * allowEmpty: true // allow empty values for all cells (whole table)
  20857. * ...
  20858. * // or
  20859. * ...
  20860. * columns: [
  20861. * // allow empty values only for 'date' column
  20862. * {data: 'date', dateFormat: 'DD/MM/YYYY', allowEmpty: true}
  20863. * ]
  20864. * ...
  20865. * ```
  20866. *
  20867. * @type {Boolean}
  20868. * @default true
  20869. * @since 0.23.0
  20870. */
  20871. allowEmpty: true,
  20872. /**
  20873. * CSS class name for cells that did not pass validation.
  20874. *
  20875. * @type {String}
  20876. * @default 'htInvalid'
  20877. */
  20878. invalidCellClassName: 'htInvalid',
  20879. /**
  20880. * When set to an non-empty string, displayed as the cell content for empty cells. If a value of a different type is provided,
  20881. * it will be stringified and applied as a string.
  20882. *
  20883. * @type {Mixed}
  20884. * @default false
  20885. */
  20886. placeholder: false,
  20887. /**
  20888. * CSS class name for cells that have a placeholder in use.
  20889. *
  20890. * @type {String}
  20891. * @default 'htPlaceholder'
  20892. */
  20893. placeholderCellClassName: 'htPlaceholder',
  20894. /**
  20895. * CSS class name for read-only cells.
  20896. *
  20897. * @type {String}
  20898. * @default 'htDimmed'
  20899. */
  20900. readOnlyCellClassName: 'htDimmed',
  20901. /**
  20902. * @description
  20903. * If a string is provided, it may be one of the following predefined values:
  20904. * * `autocomplete`,
  20905. * * `checkbox`,
  20906. * * `html`,
  20907. * * `numeric`,
  20908. * * `password`.
  20909. * * `text`.
  20910. *
  20911. * Or you can [register](http://docs.handsontable.com/demo-custom-renderers.html) the custom renderer under specified name and use
  20912. * its name as an alias in your configuration.
  20913. *
  20914. * If a function is provided, it will receive the following arguments:
  20915. * ```js
  20916. * function(instance, TD, row, col, prop, value, cellProperties) {}
  20917. * ```
  20918. *
  20919. * You can read more about custom renderes [in the documentation](http://docs.handsontable.com/demo-custom-renderers.html).
  20920. *
  20921. * @example
  20922. * ```js
  20923. * ...
  20924. * Handsontable.renderers.registerRenderer('my.renderer', function(instance, TD, row, col, prop, value, cellProperties) {
  20925. * TD.innerHTML = value;
  20926. * });
  20927. * ...
  20928. * columns: [
  20929. * {
  20930. * editor: 'select',
  20931. * renderer: 'autocomplete' // as string
  20932. * },
  20933. * {
  20934. * renderer: 'my.renderer' // custom renderer as an alias
  20935. * },
  20936. * {
  20937. * // renderer as custom function
  20938. * renderer: function(hotInstance, TD, row, col, prop, value, cellProperties) {
  20939. * TD.style.color = 'blue';
  20940. * TD.innerHTML = value;
  20941. * }
  20942. * }
  20943. * ]
  20944. * ...
  20945. * ```
  20946. *
  20947. * @type {String|Function}
  20948. * @default undefined
  20949. */
  20950. renderer: void 0,
  20951. /**
  20952. * CSS class name added to the commented cells.
  20953. *
  20954. * @type {String}
  20955. * @default 'htCommentCell'
  20956. */
  20957. commentedCellClassName: 'htCommentCell',
  20958. /**
  20959. * 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.
  20960. * If set to `'cell'`, it enables the possibility of selecting a fragment of the text within a single cell's body.
  20961. *
  20962. * @type {Boolean|String}
  20963. * @default false
  20964. */
  20965. fragmentSelection: false,
  20966. /**
  20967. * @description
  20968. * Make cell [read only](http://docs.handsontable.com/demo-read-only.html).
  20969. *
  20970. * @type {Boolean}
  20971. * @default false
  20972. */
  20973. readOnly: false,
  20974. /**
  20975. * @description
  20976. * When added to a `column` property, it skips the column on paste and pastes the data on the next column to the right.
  20977. *
  20978. * @type {Boolean}
  20979. * @default false
  20980. */
  20981. skipColumnOnPaste: false,
  20982. /**
  20983. * @description
  20984. * Setting to true enables the search plugin (see [demo](http://docs.handsontable.com/demo-search-for-values.html)).
  20985. *
  20986. * @type {Boolean}
  20987. * @default false
  20988. */
  20989. search: false,
  20990. /**
  20991. * @description
  20992. * Shortcut to define the combination of the cell renderer, editor and validator for the column, cell or whole table.
  20993. *
  20994. * Possible values:
  20995. * * [autocomplete](http://docs.handsontable.com/demo-autocomplete.html)
  20996. * * [checkbox](http://docs.handsontable.com/demo-checkbox.html)
  20997. * * [date](http://docs.handsontable.com/demo-date.html)
  20998. * * [dropdown](http://docs.handsontable.com/demo-dropdown.html)
  20999. * * [handsontable](http://docs.handsontable.com/demo-handsontable.html)
  21000. * * [numeric](http://docs.handsontable.com/demo-numeric.html)
  21001. * * [password](http://docs.handsontable.com/demo-password.html)
  21002. * * text
  21003. * * [time](http://docs.handsontable.com/demo-time.html)
  21004. *
  21005. * Or you can register the custom cell type under specified name and use
  21006. * its name as an alias in your configuration.
  21007. *
  21008. * @example
  21009. * ```js
  21010. * ...
  21011. * Handsontable.cellTypes.registerCellType('my.type', {
  21012. * editor: MyEditorClass,
  21013. * renderer: function(hot, td, row, col, prop, value, cellProperties) {
  21014. * td.innerHTML = value;
  21015. * },
  21016. * validator: function(value, callback) {
  21017. * callback(value === 'foo' ? true : false);
  21018. * }
  21019. * });
  21020. * ...
  21021. * columns: [
  21022. * {
  21023. * type: 'text'
  21024. * },
  21025. * {
  21026. * type: 'my.type' // an alias to custom type
  21027. * },
  21028. * {
  21029. * type: 'checkbox'
  21030. * }
  21031. * ]
  21032. * ...
  21033. * ```
  21034. *
  21035. * @type {String}
  21036. * @default 'text'
  21037. */
  21038. type: 'text',
  21039. /**
  21040. * @description
  21041. * Make cell copyable (pressing <kbd>CTRL</kbd> + <kbd>C</kbd> on your keyboard moves its value to system clipboard).
  21042. *
  21043. * __Note:__ this setting is `false` by default for cells with type `password`.
  21044. *
  21045. * @type {Boolean}
  21046. * @default true
  21047. * @since 0.10.2
  21048. */
  21049. copyable: true,
  21050. /**
  21051. * Defines the editor for the table/column/cell.
  21052. *
  21053. * If a string is provided, it may be one of the following predefined values:
  21054. * * [autocomplete](http://docs.handsontable.com/demo-autocomplete.html)
  21055. * * [checkbox](http://docs.handsontable.com/demo-checkbox.html)
  21056. * * [date](http://docs.handsontable.com/demo-date.html)
  21057. * * [dropdown](http://docs.handsontable.com/demo-dropdown.html)
  21058. * * [handsontable](http://docs.handsontable.com/demo-handsontable.html)
  21059. * * [mobile](http://docs.handsontable.com/demo-mobiles-and-tablets.html)
  21060. * * [password](http://docs.handsontable.com/demo-password.html)
  21061. * * [select](http://docs.handsontable.com/demo-select.html)
  21062. * * text
  21063. *
  21064. * Or you can [register](http://docs.handsontable.com/tutorial-cell-editor.html#registering-an-editor) the custom editor under specified name and use
  21065. * its name as an alias in your configuration.
  21066. *
  21067. * To disable cell editing completely set `editor` property to `false`.
  21068. *
  21069. * @example
  21070. * ```js
  21071. * ...
  21072. * columns: [
  21073. * {
  21074. * editor: 'select'
  21075. * },
  21076. * {
  21077. * editor: false
  21078. * }
  21079. * ]
  21080. * ...
  21081. * ```
  21082. *
  21083. * @type {String|Function|Boolean}
  21084. * @default 'text'
  21085. */
  21086. editor: void 0,
  21087. /**
  21088. * @description
  21089. * Autocomplete definitions. See [autocomplete demo](http://docs.handsontable.com/demo-autocomplete.html) for examples and definitions.
  21090. *
  21091. * @type {Array}
  21092. * @default undefined
  21093. */
  21094. autoComplete: void 0,
  21095. /**
  21096. * Control number of choices for the autocomplete (or dropdown) typed cells. After exceeding it, a scrollbar for the dropdown list of choices will appear.
  21097. *
  21098. * @since 0.18.0
  21099. * @type {Number}
  21100. * @default 10
  21101. */
  21102. visibleRows: 10,
  21103. /**
  21104. * Makes autocomplete or dropdown width the same as the edited cell width. If `false` then editor will be scaled
  21105. * according to its content.
  21106. *
  21107. * @since 0.17.0
  21108. * @type {Boolean}
  21109. * @default true
  21110. */
  21111. trimDropdown: true,
  21112. /**
  21113. * Setting to true enables the debug mode, currently used to test the correctness of the row and column
  21114. * header fixed positioning on a layer above the master table.
  21115. *
  21116. * @type {Boolean}
  21117. * @default false
  21118. */
  21119. debug: false,
  21120. /**
  21121. * When set to `true`, the text of the cell content is wrapped if it does not fit in the fixed column width.
  21122. *
  21123. * @type {Boolean}
  21124. * @default true
  21125. * @since 0.11.0
  21126. */
  21127. wordWrap: true,
  21128. /**
  21129. * CSS class name added to cells with cell meta `wordWrap: false`.
  21130. *
  21131. * @type {String}
  21132. * @default 'htNoWrap'
  21133. * @since 0.11.0
  21134. */
  21135. noWordWrapClassName: 'htNoWrap',
  21136. /**
  21137. * @description
  21138. * Defines if the right-click context menu should be enabled. Context menu allows to create new row or
  21139. * column at any place in the grid among [other features](http://docs.handsontable.com/demo-context-menu.html).
  21140. * Possible values:
  21141. * * `true` (to enable default options),
  21142. * * `false` (to disable completely)
  21143. * * an array of [predefined options](https://docs.handsontable.com/demo-context-menu.html#page-specific),
  21144. * * an object [with defined structure](http://docs.handsontable.com/demo-context-menu.html#page-custom)
  21145. *
  21146. * See [the context menu demo](http://docs.handsontable.com/demo-context-menu.html) for examples.
  21147. *
  21148. * @example
  21149. * ```js
  21150. * ...
  21151. * // as a boolean
  21152. * contextMenu: true
  21153. * ...
  21154. * // as an array
  21155. * contextMenu: ['row_above', 'row_below', '--------', 'undo', 'redo']
  21156. * ...
  21157. * ```
  21158. * ...
  21159. * // as an object (`name` attribute is required in the custom keys)
  21160. * contextMenu: {
  21161. * items: {
  21162. * "option1": {
  21163. * name: "option1"
  21164. * },
  21165. * "option2": {
  21166. * name: "option2",
  21167. * submenu: {
  21168. * items: [
  21169. * {
  21170. * key: "option2:suboption1",
  21171. * name: "option2:suboption1",
  21172. * callback: function(key, options) {
  21173. * ...
  21174. * }
  21175. * },
  21176. * ...
  21177. * ]
  21178. * }
  21179. * }
  21180. * }
  21181. * }
  21182. * ...
  21183. * ```
  21184. * @type {Boolean|Array|Object}
  21185. * @default undefined
  21186. */
  21187. contextMenu: void 0,
  21188. /**
  21189. * @description
  21190. * Disable or enable the copy/paste functionality.
  21191. *
  21192. * @example
  21193. * ```js
  21194. * ...
  21195. * copyPaste: false,
  21196. * ...
  21197. * ```
  21198. *
  21199. * @type {Boolean}
  21200. * @default true
  21201. */
  21202. copyPaste: true,
  21203. /**
  21204. * If `true`, undo/redo functionality is enabled.
  21205. *
  21206. * @type {Boolean}
  21207. * @default undefined
  21208. */
  21209. undo: void 0,
  21210. /**
  21211. * @description
  21212. * Turns on [Column sorting](http://docs.handsontable.com/demo-sorting-data.html).
  21213. * Can be either a boolean (true/false) or an object with a declared sorting options. See the below example:
  21214. *
  21215. * @example
  21216. * ```js
  21217. * ...
  21218. * // as boolean
  21219. * columnSorting: true
  21220. * ...
  21221. * // as a object with initial order (sort ascending column at index 2)
  21222. * columnSorting: {
  21223. * column: 2,
  21224. * sortOrder: true, // true = ascending, false = descending, undefined = original order
  21225. * sortEmptyCells: true // true = the table sorts empty cells, false = the table moves all empty cells to the end of the table
  21226. * }
  21227. * ...
  21228. * ```
  21229. *
  21230. * @type {Boolean|Object}
  21231. * @default undefined
  21232. */
  21233. columnSorting: void 0,
  21234. /**
  21235. * @description
  21236. * Turns on [Manual column move](http://docs.handsontable.com/demo-moving-rows-and-columns.html), if set to a boolean or define initial
  21237. * column order, if set to an array of column indexes.
  21238. *
  21239. * @example
  21240. * ```js
  21241. * ...
  21242. * // as boolean
  21243. * manualColumnMove: true
  21244. * ...
  21245. * // as a array with initial order (move column index at 0 to 1 and move column index at 1 to 4)
  21246. * manualColumnMove: [1, 4]
  21247. * ...
  21248. * ```
  21249. *
  21250. * @type {Boolean|Array}
  21251. * @default undefined
  21252. */
  21253. manualColumnMove: void 0,
  21254. /**
  21255. * @description
  21256. * Turns on [Manual column resize](http://docs.handsontable.com/demo-resizing.html), if set to a boolean or define initial
  21257. * column resized widths, if set to an array of numbers.
  21258. *
  21259. * @example
  21260. * ```js
  21261. * ...
  21262. * // as boolean
  21263. * manualColumnResize: true
  21264. * ...
  21265. * // as a array with initial widths (column at 0 index has 40px and column at 1 index has 50px)
  21266. * manualColumnResize: [40, 50]
  21267. * ...
  21268. * ```
  21269. *
  21270. * @type {Boolean|Array}
  21271. * @default undefined
  21272. */
  21273. manualColumnResize: void 0,
  21274. /**
  21275. * @description
  21276. * Turns on [Manual row move](http://docs.handsontable.com/demo-moving-rows-and-columns.html), if set to a boolean or define initial
  21277. * row order, if set to an array of row indexes.
  21278. *
  21279. * @example
  21280. * ```js
  21281. * ...
  21282. * // as boolean
  21283. * manualRowMove: true
  21284. * ...
  21285. * // as a array with initial order (move row index at 0 to 1 and move row index at 1 to 4)
  21286. * manualRowMove: [1, 4]
  21287. * ...
  21288. * ```
  21289. *
  21290. * @type {Boolean|Array}
  21291. * @default undefined
  21292. * @since 0.11.0
  21293. */
  21294. manualRowMove: void 0,
  21295. /**
  21296. * @description
  21297. * Turns on [Manual row resize](http://docs.handsontable.com/demo-resizing.html), if set to a boolean or define initial
  21298. * row resized heights, if set to an array of numbers.
  21299. *
  21300. * @example
  21301. * ```js
  21302. * ...
  21303. * // as boolean
  21304. * manualRowResize: true
  21305. * ...
  21306. * // as a array with initial heights (row at 0 index has 40px and row at 1 index has 50px)
  21307. * manualRowResize: [40, 50]
  21308. * ...
  21309. * ```
  21310. *
  21311. * @type {Boolean|Array}
  21312. * @default undefined
  21313. * @since 0.11.0
  21314. */
  21315. manualRowResize: void 0,
  21316. /**
  21317. * @description
  21318. * 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).
  21319. * [More information on the demo page.](http://docs.handsontable.com/demo-merge-cells.html)
  21320. *
  21321. * @example
  21322. * ```js
  21323. * // enables the mergeCells plugin:
  21324. * margeCells: true
  21325. * ...
  21326. * // declares a list of merged sections:
  21327. * mergeCells: [
  21328. * {row: 1, col: 1, rowspan: 3, colspan: 3}, // rowspan and colspan properties declare the width and height of a merged section in cells
  21329. * {row: 3, col: 4, rowspan: 2, colspan: 2},
  21330. * {row: 5, col: 6, rowspan: 3, colspan: 3}
  21331. * ]
  21332. * ```
  21333. * @type {Boolean|Array}
  21334. * @default false
  21335. */
  21336. mergeCells: false,
  21337. /**
  21338. * Number of rows to be rendered outside of the visible part of the table.
  21339. * By default, it's set to `'auto'`, which makes Handsontable to attempt to calculate the best offset performance-wise.
  21340. *
  21341. * You may test out different values to find the best one that works for your specific implementation.
  21342. *
  21343. * @type {Number|String}
  21344. * @default 'auto'
  21345. */
  21346. viewportRowRenderingOffset: 'auto',
  21347. /**
  21348. * Number of columns to be rendered outside of the visible part of the table.
  21349. * By default, it's set to `'auto'`, which makes Handsontable try calculating the best offset performance-wise.
  21350. *
  21351. * You may experiment with the value to find the one that works best for your specific implementation.
  21352. *
  21353. * @type {Number|String}
  21354. * @default 'auto'
  21355. */
  21356. viewportColumnRenderingOffset: 'auto',
  21357. /**
  21358. * A function, regular expression or a string, which will be used in the process of cell validation.
  21359. * If a function is used, be sure to execute the callback argument with either `true` (`callback(true)`) if the validation passed
  21360. * or with `false` (`callback(false)`), if the validation failed.
  21361. * Note, that `this` in the function points to the `cellProperties` object.
  21362. *
  21363. * If a string is provided, it may be one of the following predefined values:
  21364. * * `autocomplete`,
  21365. * * `date`,
  21366. * * `numeric`,
  21367. * * `time`.
  21368. *
  21369. * Or you can [register](http://docs.handsontable.com/demo-data-validation.html) the validator function under specified name and use
  21370. * its name as an alias in your configuration.
  21371. *
  21372. * See more [in the demo](http://docs.handsontable.com/demo-data-validation.html).
  21373. *
  21374. * @example
  21375. * ```js
  21376. * // as a function
  21377. * columns: [
  21378. * {
  21379. * validator: function(value, callback) { // validation rules }
  21380. * }
  21381. * ]
  21382. * ...
  21383. * // as a regexp
  21384. * columns: [
  21385. * {
  21386. * validator: /^[0-9]$/ // regular expression
  21387. * }
  21388. * ]
  21389. * // as a string
  21390. * columns: [
  21391. * {
  21392. * validator: 'numeric'
  21393. * }
  21394. * ]
  21395. * ```
  21396. * @type {Function|RegExp|String}
  21397. * @default undefined
  21398. * @since 0.9.5
  21399. */
  21400. validator: void 0,
  21401. /**
  21402. * @description
  21403. * Disable visual cells selection.
  21404. *
  21405. * Possible values:
  21406. * * `true` - Disables any type of visual selection (current and area selection),
  21407. * * `false` - Enables any type of visual selection. This is default value.
  21408. * * `'current'` - Disables the selection of a currently selected cell, the area selection is still present.
  21409. * * `'area'` - Disables the area selection, the currently selected cell selection is still present.
  21410. * * `'header'` - Disables the headers selection, the currently selected cell selection is still present (available since 0.36.0).
  21411. *
  21412. * @type {Boolean|String|Array}
  21413. * @default false
  21414. * @since 0.13.2
  21415. * @example
  21416. * ```js
  21417. * ...
  21418. * // as boolean
  21419. * disableVisualSelection: true,
  21420. * ...
  21421. *
  21422. * ...
  21423. * // as string ('current', 'area' or 'header')
  21424. * disableVisualSelection: 'current',
  21425. * ...
  21426. *
  21427. * ...
  21428. * // as array
  21429. * disableVisualSelection: ['current', 'area'],
  21430. * ...
  21431. * ```
  21432. */
  21433. disableVisualSelection: false,
  21434. /**
  21435. * @description
  21436. * Set whether to display the current sorting order indicator (a triangle icon in the column header, specifying the sorting order).
  21437. *
  21438. * @type {Boolean}
  21439. * @default false
  21440. * @since 0.15.0-beta3
  21441. */
  21442. sortIndicator: void 0,
  21443. /**
  21444. * Disable or enable ManualColumnFreeze plugin.
  21445. *
  21446. * @type {Boolean}
  21447. * @default false
  21448. */
  21449. manualColumnFreeze: void 0,
  21450. /**
  21451. * @description
  21452. * Defines whether Handsontable should trim the whitespace at the beginning and the end of the cell contents.
  21453. *
  21454. * @type {Boolean}
  21455. * @default true
  21456. */
  21457. trimWhitespace: true,
  21458. settings: void 0,
  21459. /**
  21460. * @description
  21461. * Defines data source for Autocomplete or Dropdown cell types.
  21462. *
  21463. * @example
  21464. * ```js
  21465. * ...
  21466. * // source as a array
  21467. * columns: [{
  21468. * type: 'autocomplete',
  21469. * source: ['A', 'B', 'C', 'D']
  21470. * }]
  21471. * ...
  21472. * // source as a function
  21473. * columns: [{
  21474. * type: 'autocomplete',
  21475. * source: function(query, callback) {
  21476. * fetch('http://example.com/query?q=' + query, function(response) {
  21477. * callback(response.items);
  21478. * })
  21479. * }
  21480. * }]
  21481. * ...
  21482. * ```
  21483. *
  21484. * @type {Array|Function}
  21485. * @default undefined
  21486. */
  21487. source: void 0,
  21488. /**
  21489. * @description
  21490. * Defines the column header name.
  21491. *
  21492. * @example
  21493. * ```js
  21494. * ...
  21495. * columns: [{
  21496. * title: 'First name',
  21497. * type: 'text',
  21498. * },
  21499. * {
  21500. * title: 'Last name',
  21501. * type: 'text',
  21502. * }]
  21503. * ...
  21504. * ```
  21505. *
  21506. * @type {String}
  21507. * @default undefined
  21508. */
  21509. title: void 0,
  21510. /**
  21511. * Data template for `'checkbox'` type when checkbox is checked.
  21512. *
  21513. * @example
  21514. * ```js
  21515. * checkedTemplate: 'good'
  21516. *
  21517. * // if a checkbox-typed cell is checked, then getDataAtCell(x,y), where x and y are the coordinates of the cell
  21518. * // will return 'good'.
  21519. * ```
  21520. * @type {Boolean|String}
  21521. * @default true
  21522. */
  21523. checkedTemplate: void 0,
  21524. /**
  21525. * Data template for `'checkbox'` type when checkbox is unchecked.
  21526. *
  21527. * @example
  21528. * ```js
  21529. * uncheckedTemplate: 'bad'
  21530. *
  21531. * // if a checkbox-typed cell is not checked, then getDataAtCell(x,y), where x and y are the coordinates of the cell
  21532. * // will return 'bad'.
  21533. * ```
  21534. * @type {Boolean|String}
  21535. * @default false
  21536. */
  21537. uncheckedTemplate: void 0,
  21538. /**
  21539. * @description
  21540. * Object which describes if renderer should create checkbox element with label element as a parent. Option desired for
  21541. * [checkbox](http://docs.handsontable.com/demo-checkbox.html)-typed cells.
  21542. *
  21543. * By default the [checkbox](http://docs.handsontable.com/demo-checkbox.html) renderer renders the checkbox without a label.
  21544. *
  21545. * Possible object properties:
  21546. * * `property` - Defines the property name of the data object, which will to be used as a label.
  21547. * (eg. `label: {property: 'name.last'}`). This option works only if data was passed as an array of objects.
  21548. * * `position` - String which describes where to place the label text (before or after checkbox element).
  21549. * Valid values are `'before'` and '`after`' (defaults to `'after'`).
  21550. * * `value` - String or a Function which will be used as label text.
  21551. *
  21552. * @example
  21553. * ```js
  21554. * ...
  21555. * columns: [{
  21556. * type: 'checkbox',
  21557. * label: {position: 'after', value: 'My label: '}
  21558. * }]
  21559. * ...
  21560. * ```
  21561. *
  21562. * @since 0.19.0
  21563. * @type {Object}
  21564. * @default undefined
  21565. */
  21566. label: void 0,
  21567. /**
  21568. * Display format. This option is desired for [numeric-typed](http://docs.handsontable.com/demo-numeric.html) cells. Format is described by two properties:
  21569. *
  21570. * - 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).
  21571. * - 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).
  21572. *
  21573. * __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.
  21574. *
  21575. * Since 0.26.0 Handsontable uses [numbro](http://numbrojs.com/) as a main library for numbers formatting.
  21576. *
  21577. * @example
  21578. * ```js
  21579. * ...
  21580. * columns: [{
  21581. * type: 'numeric',
  21582. * numericFormat: {
  21583. * pattern: '0,00',
  21584. * culture: 'en-US'
  21585. * }
  21586. * }]
  21587. * ...
  21588. * ```
  21589. *
  21590. * @since 0.35.0
  21591. * @type {Object}
  21592. */
  21593. numericFormat: void 0,
  21594. /**
  21595. * Language for Handsontable translation. Possible language codes are: `en-US`, `pl-PL`.
  21596. *
  21597. * @type {String}
  21598. * @default 'en-US'
  21599. */
  21600. language: void 0,
  21601. /**
  21602. * @description
  21603. * Data source for [select](http://docs.handsontable.com/demo-select.html)-typed cells.
  21604. *
  21605. * @example
  21606. * ```js
  21607. * ...
  21608. * columns: [{
  21609. * editor: 'select',
  21610. * selectOptions: ['A', 'B', 'C'],
  21611. * }]
  21612. * ...
  21613. * ```
  21614. *
  21615. * @type {Array}
  21616. */
  21617. selectOptions: void 0,
  21618. /**
  21619. * Enables or disables the autoColumnSize plugin. Default value is `undefined`, which has the same effect as `true`.
  21620. * Disabling this plugin can increase performance, as no size-related calculations would be done.
  21621. *
  21622. * Column width calculations are divided into sync and async part. Each of this parts has their own advantages and
  21623. * disadvantages. Synchronous calculations are faster but they block the browser UI, while the slower asynchronous operations don't
  21624. * block the browser UI.
  21625. *
  21626. * To configure the sync/async distribution, you can pass an absolute value (number of columns) or a percentage value.
  21627. * `syncLimit` option is available since 0.16.0.
  21628. *
  21629. * You can also use the `useHeaders` option to take the column headers with into calculation.
  21630. *
  21631. * @example
  21632. * ```js
  21633. * ...
  21634. * // as a number (300 columns in sync, rest async)
  21635. * autoColumnSize: {syncLimit: 300},
  21636. * ...
  21637. *
  21638. * ...
  21639. * // as a string (percent)
  21640. * autoColumnSize: {syncLimit: '40%'},
  21641. * ...
  21642. *
  21643. * ...
  21644. * // use headers width while calculation the column width
  21645. * autoColumnSize: {useHeaders: true},
  21646. * ...
  21647. *
  21648. * ```
  21649. *
  21650. * @type {Object|Boolean}
  21651. * @default {syncLimit: 50}
  21652. */
  21653. autoColumnSize: void 0,
  21654. /**
  21655. * Enables or disables autoRowSize plugin. Default value is `undefined`, which has the same effect as `false` (disabled).
  21656. * Enabling this plugin can decrease performance, as size-related calculations would be performed.
  21657. *
  21658. * Row height calculations are divided into sync and async stages. Each of these stages has their own advantages and
  21659. * disadvantages. Synchronous calculations are faster but they block the browser UI, while the slower asynchronous operations don't
  21660. * block the browser UI.
  21661. *
  21662. * To configure the sync/async distribution, you can pass an absolute value (number of columns) or a percentage value.
  21663. * `syncLimit` options is available since 0.16.0.
  21664. *
  21665. * @example
  21666. * ```js
  21667. * ...
  21668. * // as number (300 columns in sync, rest async)
  21669. * autoRowSize: {syncLimit: 300},
  21670. * ...
  21671. *
  21672. * ...
  21673. * // as string (percent)
  21674. * autoRowSize: {syncLimit: '40%'},
  21675. * ...
  21676. * ```
  21677. * @type {Object|Boolean}
  21678. * @default {syncLimit: 1000}
  21679. */
  21680. autoRowSize: void 0,
  21681. /**
  21682. * Date validation format.
  21683. *
  21684. * Option desired for `'date'` - typed cells.
  21685. *
  21686. * @example
  21687. * ```js
  21688. * ...
  21689. * columns: [{
  21690. * type: 'date',
  21691. * dateFormat: 'MM/DD/YYYY'
  21692. * }]
  21693. * ...
  21694. * ```
  21695. *
  21696. * @type {String}
  21697. * @default 'DD/MM/YYYY'
  21698. */
  21699. dateFormat: void 0,
  21700. /**
  21701. * If `true` then dates will be automatically formatted to match the desired format.
  21702. *
  21703. * Option desired for `'date'`-typed typed cells.
  21704. *
  21705. * @example
  21706. * ```js
  21707. * ...
  21708. * columns: [{
  21709. * type: 'date',
  21710. * dateFormat: 'YYYY-MM-DD',
  21711. * correctFormat: true
  21712. * }]
  21713. * ...
  21714. * ```
  21715. *
  21716. * @type {Boolean}
  21717. * @default false
  21718. */
  21719. correctFormat: false,
  21720. /**
  21721. * Definition of default value which will fill the empty cells.
  21722. *
  21723. * Option desired for `'date'`-typed cells.
  21724. *
  21725. * @example
  21726. * ```js
  21727. * ...
  21728. * columns: [{
  21729. * type: 'date',
  21730. * defaultData: '2015-02-02'
  21731. * }]
  21732. * ...
  21733. * ```
  21734. *
  21735. * @type {String}
  21736. */
  21737. defaultDate: void 0,
  21738. /**
  21739. * If set to `true`, the value entered into the cell must match (case-sensitive) the autocomplete source. Otherwise, cell won't pass the validation.
  21740. * When filtering the autocomplete source list, the editor will be working in case-insensitive mode.
  21741. *
  21742. * Option desired for `autocomplete`-typed cells.
  21743. *
  21744. * @example
  21745. * ```js
  21746. * ...
  21747. * columns: [{
  21748. * type: 'autocomplete',
  21749. * source: ['A', 'B', 'C'],
  21750. * strict: true
  21751. * }]
  21752. * ...
  21753. * ```
  21754. *
  21755. * @type {Boolean}
  21756. */
  21757. strict: void 0,
  21758. /**
  21759. * @description
  21760. * If typed `true`, data defined in `source` of the autocomplete or dropdown cell will be treated as HTML.
  21761. *
  21762. * __Warning:__ Enabling this option can cause serious XSS vulnerabilities.
  21763. *
  21764. * Option desired for `'autocomplete'`-typed cells.
  21765. * @example
  21766. * ```js
  21767. * ...
  21768. * columns: [{
  21769. * type: 'autocomplete',
  21770. * allowHtml: true,
  21771. * source: ['<b>foo</b>', '<b>bar</b>']
  21772. * }]
  21773. * ...
  21774. * ```
  21775. * @type {Boolean}
  21776. * @default false
  21777. */
  21778. allowHtml: false,
  21779. /**
  21780. * If typed `true` then virtual rendering mechanism for handsontable will be disabled.
  21781. *
  21782. * @type {Boolean}
  21783. */
  21784. renderAllRows: void 0,
  21785. /**
  21786. * Prevents table to overlap outside the parent element. If `'horizontal'` option is chosen then table will appear horizontal
  21787. * scrollbar in case where parent's width is narrower then table's width.
  21788. *
  21789. * Possible values:
  21790. * * `false` - Disables functionality (Default option).
  21791. * * `horizontal` - Prevents horizontal overflow table.
  21792. * * `vertical` - Prevents vertical overflow table (Not implemented yet).
  21793. *
  21794. * @since 0.20.3
  21795. * @example
  21796. * ```js
  21797. * ...
  21798. * preventOverflow: 'horizontal'
  21799. * ...
  21800. * ```
  21801. *
  21802. * @type {String|Boolean}
  21803. */
  21804. preventOverflow: false,
  21805. /**
  21806. * @description
  21807. * Plugin allowing binding the table rows with their headers.
  21808. * If the plugin is enabled, the table row headers will "stick" to the rows, when they are hidden/moved. Basically, if at the initialization
  21809. * row 0 has a header titled "A", it will have it no matter what you do with the table.
  21810. *
  21811. * @pro
  21812. * @since 1.0.0-beta1
  21813. * @type {Boolean|String}
  21814. * @example
  21815. *
  21816. * ```js
  21817. * ...
  21818. * var hot = new Handsontable(document.getElementById('example'), {
  21819. * date: getData(),
  21820. * bindRowsWithHeaders: true
  21821. * });
  21822. * ...
  21823. * ```
  21824. *
  21825. */
  21826. bindRowsWithHeaders: void 0,
  21827. /**
  21828. * @description
  21829. * The CollapsibleColumns plugin allows collapsing of columns, covered by a header with the `colspan` property defined.
  21830. *
  21831. * Clicking the "collapse/expand" button collapses (or expands) all "child" headers except the first one.
  21832. *
  21833. * Setting the `collapsibleColumns` property to `true` will display a "collapse/expand" button in every header with a defined
  21834. * `colspan` property.
  21835. *
  21836. * To limit this functionality to a smaller group of headers, define the `collapsibleColumns` property as an array of objects, as in
  21837. * the example below.
  21838. *
  21839. * @pro
  21840. * @since 1.0.0-beta1
  21841. * @type {Boolean|Array}
  21842. * @example
  21843. * ```js
  21844. * ...
  21845. * collapsibleColumns: [
  21846. * {row: -4, col: 1, collapsible: true},
  21847. * {row: -3, col: 5, collapsible: true}
  21848. * ]
  21849. * ...
  21850. * // or
  21851. * ...
  21852. * collapsibleColumns: true
  21853. * ...
  21854. * ```
  21855. */
  21856. collapsibleColumns: void 0,
  21857. /**
  21858. * @description
  21859. * Allows making pre-defined calculations on the cell values and display the results within Handsontable.
  21860. * See the demo for more information.
  21861. *
  21862. * @pro
  21863. * @since 1.0.0-beta1
  21864. * @type {Object}
  21865. */
  21866. columnSummary: void 0,
  21867. /**
  21868. * This plugin allows adding a configurable dropdown menu to the table's column headers.
  21869. * The dropdown menu acts like the Context Menu, but is triggered by clicking the button in the header.
  21870. *
  21871. * @pro
  21872. * @since 1.0.0-beta1
  21873. * @type {Boolean|Object|Array}
  21874. */
  21875. dropdownMenu: void 0,
  21876. /**
  21877. * The filters plugin.
  21878. * It allows filtering the table data either by the built-in component or with the API.
  21879. *
  21880. * @pro
  21881. * @since 1.0.0-beta1
  21882. * @type {Boolean}
  21883. */
  21884. filters: void 0,
  21885. /**
  21886. * It allows Handsontable to process formula expressions defined in the provided data.
  21887. *
  21888. * @pro
  21889. * @since 1.7.0
  21890. * @type {Boolean}
  21891. */
  21892. formulas: void 0,
  21893. /**
  21894. * @description
  21895. * GanttChart plugin enables a possibility to create a Gantt chart using a Handsontable instance.
  21896. * In this case, the whole table becomes read-only.
  21897. *
  21898. * @pro
  21899. * @since 1.0.0-beta1
  21900. * @type {Object}
  21901. */
  21902. ganttChart: void 0,
  21903. /**
  21904. * @description
  21905. * Allows adding a tooltip to the table headers.
  21906. *
  21907. * Available options:
  21908. * * the `rows` property defines if tooltips should be added to row headers,
  21909. * * the `columns` property defines if tooltips should be added to column headers,
  21910. * * 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).
  21911. *
  21912. * @pro
  21913. * @since 1.0.0-beta1
  21914. * @type {Boolean|Object}
  21915. */
  21916. headerTooltips: void 0,
  21917. /**
  21918. * Plugin allowing hiding of certain columns.
  21919. *
  21920. * @pro
  21921. * @since 1.0.0-beta1
  21922. * @type {Boolean|Object}
  21923. */
  21924. hiddenColumns: void 0,
  21925. /**
  21926. * @description
  21927. * Plugin allowing hiding of certain rows.
  21928. *
  21929. * @pro
  21930. * @since 1.0.0-beta1
  21931. * @type {Boolean|Object}
  21932. */
  21933. hiddenRows: void 0,
  21934. /**
  21935. * @description
  21936. * Allows creating a nested header structure, using the HTML's colspan attribute.
  21937. *
  21938. * @pro
  21939. * @since 1.0.0-beta1
  21940. * @type {Array}
  21941. */
  21942. nestedHeaders: void 0,
  21943. /**
  21944. * @description
  21945. * Plugin allowing hiding of certain rows.
  21946. *
  21947. * @pro
  21948. * @since 1.0.0-beta1
  21949. * @type {Boolean|Array}
  21950. */
  21951. trimRows: void 0,
  21952. /**
  21953. * @description
  21954. * 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.
  21955. *
  21956. * @since 0.22.0
  21957. * @type {Number|Array}
  21958. */
  21959. rowHeaderWidth: void 0,
  21960. /**
  21961. * @description
  21962. * 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.
  21963. *
  21964. * @since 0.22.0
  21965. * @type {Number|Array}
  21966. */
  21967. columnHeaderHeight: void 0,
  21968. /**
  21969. * @description
  21970. * Enabling this plugin switches table into one-way data binding where changes are applied into data source (from outside table)
  21971. * will be automatically reflected in the table.
  21972. *
  21973. * For every data change [afterChangesObserved](Hooks.html#event:afterChangesObserved) hook will be fired.
  21974. *
  21975. * @type {Boolean}
  21976. * @default false
  21977. */
  21978. observeChanges: void 0,
  21979. /**
  21980. * @description
  21981. * When passed to the `column` property, allows specifying a custom sorting function for the desired column.
  21982. *
  21983. * @since 0.24.0
  21984. * @type {Function}
  21985. * @example
  21986. * ```js
  21987. * columns: [
  21988. * {
  21989. * sortFunction: function(sortOrder) {
  21990. * return function(a, b) {
  21991. * // sorting function body.
  21992. * //
  21993. * // Function parameters:
  21994. * // sortOrder: If true, the order is ascending, if false - descending. undefined = original order
  21995. * // a, b: Two compared elements. These are 2-element arrays, with the first element being the row index, the second - cell value.
  21996. * }
  21997. * }
  21998. * }
  21999. * ]
  22000. * ```
  22001. */
  22002. sortFunction: void 0,
  22003. /**
  22004. * 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).
  22005. *
  22006. * Option desired for cells of the `'autocomplete'` type.
  22007. *
  22008. * @type {Boolean}
  22009. * @default true
  22010. */
  22011. sortByRelevance: true,
  22012. /**
  22013. * If defined as 'true', when the user types into the input area the Autocomplete's suggestion list is updated to only
  22014. * include those choices starting with what has been typed; if defined as 'false' all suggestions remain shown, with
  22015. * those matching what has been typed marked in bold.
  22016. *
  22017. * @type {Boolean}
  22018. * @default true
  22019. */
  22020. filter: true,
  22021. /**
  22022. * If defined as 'true', filtering in the Autocomplete Editor will be case-sensitive.
  22023. *
  22024. * @type {Boolean}
  22025. * @default: false
  22026. */
  22027. filteringCaseSensitive: false,
  22028. /**
  22029. * @description
  22030. * Disable or enable the drag to scroll functionality.
  22031. *
  22032. * @example
  22033. * ```js
  22034. * ...
  22035. * dragToScroll: false,
  22036. * ...
  22037. * ```
  22038. *
  22039. * @type {Boolean}
  22040. * @default true
  22041. */
  22042. dragToScroll: true
  22043. };
  22044. exports.default = DefaultSettings;
  22045. /***/ }),
  22046. /* 196 */
  22047. /***/ (function(module, exports, __webpack_require__) {
  22048. "use strict";
  22049. exports.__esModule = true;
  22050. exports.getTranslatedPhrase = getTranslatedPhrase;
  22051. var _array = __webpack_require__(1);
  22052. var _dictionariesManager = __webpack_require__(71);
  22053. var _phraseFormatters = __webpack_require__(270);
  22054. var _mixed = __webpack_require__(16);
  22055. /**
  22056. * Get phrase for specified dictionary key.
  22057. *
  22058. * @param {String} languageCode Language code for specific language i.e. 'en-US', 'pt-BR', 'de-DE'.
  22059. * @param {String} dictionaryKey Constant which is dictionary key.
  22060. * @param {*} argumentsForFormatters Arguments which will be handled by formatters.
  22061. *
  22062. * @returns {String}
  22063. */
  22064. // eslint-disable-next-line import/prefer-default-export
  22065. function getTranslatedPhrase(languageCode, dictionaryKey, argumentsForFormatters) {
  22066. var languageDictionary = (0, _dictionariesManager.getLanguageDictionary)(languageCode);
  22067. if (languageDictionary === null) {
  22068. return null;
  22069. }
  22070. var phrasePropositions = languageDictionary[dictionaryKey];
  22071. if ((0, _mixed.isUndefined)(phrasePropositions)) {
  22072. return null;
  22073. }
  22074. var formattedPhrase = getFormattedPhrase(phrasePropositions, argumentsForFormatters);
  22075. if (Array.isArray(formattedPhrase)) {
  22076. return formattedPhrase[0];
  22077. }
  22078. return formattedPhrase;
  22079. }
  22080. /**
  22081. * Get formatted phrase from phrases propositions for specified dictionary key.
  22082. *
  22083. * @private
  22084. * @param {Array|string} phrasePropositions List of phrase propositions.
  22085. * @param {*} argumentsForFormatters Arguments which will be handled by formatters.
  22086. *
  22087. * @returns {Array|string}
  22088. */
  22089. function getFormattedPhrase(phrasePropositions, argumentsForFormatters) {
  22090. var formattedPhrasePropositions = phrasePropositions;
  22091. (0, _array.arrayEach)((0, _phraseFormatters.getPhraseFormatters)(), function (formatter) {
  22092. formattedPhrasePropositions = formatter(phrasePropositions, argumentsForFormatters);
  22093. });
  22094. return formattedPhrasePropositions;
  22095. }
  22096. /***/ }),
  22097. /* 197 */
  22098. /***/ (function(module, exports, __webpack_require__) {
  22099. "use strict";
  22100. exports.__esModule = true;
  22101. 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.']);
  22102. exports.extendNotExistingKeys = extendNotExistingKeys;
  22103. exports.createCellHeadersRange = createCellHeadersRange;
  22104. exports.normalizeLanguageCode = normalizeLanguageCode;
  22105. exports.applyLanguageSetting = applyLanguageSetting;
  22106. exports.warnUserAboutLanguageRegistration = warnUserAboutLanguageRegistration;
  22107. var _mixed = __webpack_require__(16);
  22108. var _object = __webpack_require__(2);
  22109. var _console = __webpack_require__(56);
  22110. var _templateLiteralTag = __webpack_require__(41);
  22111. var _dictionariesManager = __webpack_require__(71);
  22112. function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
  22113. /**
  22114. * Perform shallow extend of a target object with only this extension's properties which doesn't exist in the target.
  22115. *
  22116. * @param {Object} target An object that will receive the new properties.
  22117. * @param {Object} extension An object containing additional properties to merge into the target.
  22118. */
  22119. // TODO: Maybe it should be moved to global helpers? It's changed `extend` function.
  22120. function extendNotExistingKeys(target, extension) {
  22121. (0, _object.objectEach)(extension, function (value, key) {
  22122. if ((0, _mixed.isUndefined)(target[key])) {
  22123. target[key] = value;
  22124. }
  22125. });
  22126. return target;
  22127. }
  22128. /**
  22129. * Create range of values basing on cell indexes. For example, it will create below ranges for specified function arguments:
  22130. *
  22131. * createCellHeadersRange(2, 7) => `2-7`
  22132. * createCellHeadersRange(7, 2) => `2-7`
  22133. * createCellHeadersRange(0, 4, 'A', 'D') => `A-D`
  22134. * createCellHeadersRange(4, 0, 'D', 'A') => `A-D`
  22135. *
  22136. * @param {number} firstRowIndex Index of "first" cell
  22137. * @param {number} nextRowIndex Index of "next" cell
  22138. * @param {*} fromValue Value which will represent "first" cell
  22139. * @param {*} toValue Value which will represent "next" cell
  22140. * @returns {String} Value representing range i.e. A-Z, 11-15.
  22141. */
  22142. function createCellHeadersRange(firstRowIndex, nextRowIndex) {
  22143. var fromValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : firstRowIndex;
  22144. var toValue = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : nextRowIndex;
  22145. // Will swap `fromValue` with `toValue` if it's necessary.
  22146. if (firstRowIndex > nextRowIndex) {
  22147. var _ref = [toValue, fromValue];
  22148. fromValue = _ref[0];
  22149. toValue = _ref[1];
  22150. }
  22151. return fromValue + '-' + toValue;
  22152. }
  22153. /**
  22154. * Normalize language code. It takes handled languageCode proposition and change it to proper languageCode.
  22155. * For example, when it takes `eN-us` as parameter it return `en-US`
  22156. *
  22157. * @param {String} languageCode Language code for specific language i.e. 'en-US', 'pt-BR', 'de-DE'.
  22158. * @returns {String}
  22159. */
  22160. function normalizeLanguageCode(languageCode) {
  22161. var languageCodePattern = /^([a-zA-Z]{2})-([a-zA-Z]{2})$/;
  22162. var partsOfLanguageCode = languageCodePattern.exec(languageCode);
  22163. if (partsOfLanguageCode) {
  22164. return partsOfLanguageCode[1].toLowerCase() + '-' + partsOfLanguageCode[2].toUpperCase();
  22165. }
  22166. return languageCode;
  22167. }
  22168. /**
  22169. * Set proper start language code. User may set language code which is not proper.
  22170. *
  22171. * @param {Object} settings Settings object.
  22172. * @param {String} languageCode Language code for specific language i.e. 'en-US', 'pt-BR', 'de-DE'.
  22173. * @returns {String}
  22174. */
  22175. function applyLanguageSetting(settings, languageCode) {
  22176. var normalizedLanguageCode = normalizeLanguageCode(languageCode);
  22177. if ((0, _dictionariesManager.hasLanguageDictionary)(normalizedLanguageCode)) {
  22178. settings.language = normalizedLanguageCode;
  22179. } else {
  22180. settings.language = _dictionariesManager.DEFAULT_LANGUAGE_CODE;
  22181. warnUserAboutLanguageRegistration(languageCode);
  22182. }
  22183. }
  22184. /**
  22185. *
  22186. * Warn user if there is no registered language.
  22187. *
  22188. * @param {String} languageCode Language code for specific language i.e. 'en-US', 'pt-BR', 'de-DE'.
  22189. */
  22190. function warnUserAboutLanguageRegistration(languageCode) {
  22191. if ((0, _mixed.isDefined)(languageCode)) {
  22192. (0, _console.error)((0, _templateLiteralTag.toSingleLine)(_templateObject, languageCode));
  22193. }
  22194. }
  22195. /***/ }),
  22196. /* 198 */
  22197. /***/ (function(module, exports, __webpack_require__) {
  22198. "use strict";
  22199. exports.__esModule = true;
  22200. exports.stopObserving = exports.startObserving = exports.isPressedCtrlKey = exports.isPressed = exports._resetState = exports._getRefCount = undefined;
  22201. var _eventManager = __webpack_require__(6);
  22202. var _eventManager2 = _interopRequireDefault(_eventManager);
  22203. var _unicode = __webpack_require__(21);
  22204. var _array = __webpack_require__(1);
  22205. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  22206. var eventManager = new _eventManager2.default();
  22207. var pressedKeys = new Set();
  22208. var refCount = 0;
  22209. /**
  22210. * Begins observing keyboard keys states.
  22211. */
  22212. function startObserving() {
  22213. if (refCount === 0) {
  22214. eventManager.addEventListener(document, 'keydown', function (event) {
  22215. if (!pressedKeys.has(event.keyCode)) {
  22216. pressedKeys.add(event.keyCode);
  22217. }
  22218. });
  22219. eventManager.addEventListener(document, 'keyup', function (event) {
  22220. if (pressedKeys.has(event.keyCode)) {
  22221. pressedKeys.delete(event.keyCode);
  22222. }
  22223. });
  22224. eventManager.addEventListener(document, 'visibilitychange', function () {
  22225. if (document.hidden) {
  22226. pressedKeys.clear();
  22227. }
  22228. });
  22229. }
  22230. refCount += 1;
  22231. }
  22232. /**
  22233. * Stops observing keyboard keys states and clear all previously saved states.
  22234. */
  22235. function stopObserving() {
  22236. if (refCount > 0) {
  22237. refCount -= 1;
  22238. }
  22239. if (refCount === 0) {
  22240. _resetState();
  22241. }
  22242. }
  22243. /**
  22244. * Remove all listeners attached to the DOM and clear all previously saved states.
  22245. */
  22246. function _resetState() {
  22247. eventManager.clearEvents();
  22248. pressedKeys.clear();
  22249. refCount = 0;
  22250. }
  22251. /**
  22252. * Checks if provided keyCode or keyCodes are pressed.
  22253. *
  22254. * @param {String} keyCodes The key codes passed as a string defined in helpers/unicode.js file delimited with '|'.
  22255. * @return {Boolean}
  22256. */
  22257. function isPressed(keyCodes) {
  22258. return Array.from(pressedKeys.values()).some(function (_keyCode) {
  22259. return (0, _unicode.isKey)(_keyCode, keyCodes);
  22260. });
  22261. }
  22262. /**
  22263. * Checks if ctrl keys are pressed.
  22264. *
  22265. * @return {Boolean}
  22266. */
  22267. function isPressedCtrlKey() {
  22268. return Array.from(pressedKeys.values()).some(function (_keyCode) {
  22269. return (0, _unicode.isCtrlMetaKey)(_keyCode);
  22270. });
  22271. }
  22272. /**
  22273. * Returns reference count. Useful for debugging and testing purposes.
  22274. *
  22275. * @return {Number}
  22276. */
  22277. function _getRefCount() {
  22278. return refCount;
  22279. }
  22280. exports._getRefCount = _getRefCount;
  22281. exports._resetState = _resetState;
  22282. exports.isPressed = isPressed;
  22283. exports.isPressedCtrlKey = isPressedCtrlKey;
  22284. exports.startObserving = startObserving;
  22285. exports.stopObserving = stopObserving;
  22286. /***/ }),
  22287. /* 199 */
  22288. /***/ (function(module, exports, __webpack_require__) {
  22289. "use strict";
  22290. exports.__esModule = true;
  22291. exports.HEADER_TYPE = exports.FILL_TYPE = exports.CELL_TYPE = exports.AREA_TYPE = exports.ACTIVE_HEADER_TYPE = undefined;
  22292. 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; }; }();
  22293. var _types = __webpack_require__(273);
  22294. var _array = __webpack_require__(1);
  22295. 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); } }
  22296. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  22297. var ACTIVE_HEADER_TYPE = exports.ACTIVE_HEADER_TYPE = 'active-header';
  22298. var AREA_TYPE = exports.AREA_TYPE = 'area';
  22299. var CELL_TYPE = exports.CELL_TYPE = 'cell';
  22300. var FILL_TYPE = exports.FILL_TYPE = 'fill';
  22301. var HEADER_TYPE = exports.HEADER_TYPE = 'header';
  22302. /**
  22303. * Highlight class responsible for managing Walkontable Selection classes.
  22304. *
  22305. * With Highlight object you can manipulate four different highlight types:
  22306. * - `cell` can be added only to a single cell at a time and it defines currently selected cell;
  22307. * - `fill` can occur only once and its highlight defines selection of autofill functionality (managed by the plugin with the same name);
  22308. * - `areas` can be added to multiple cells at a time. This type highlights selected cell or multiple cells.
  22309. * The multiple cells have to be defined as an uninterrupted order (regular shape). Otherwise, the new layer of
  22310. * that type should be created to manage not-consecutive selection;
  22311. * - `header` can occur multiple times. This type is designed to highlight only headers. Like `area` type it
  22312. * can appear with multiple highlights (accessed under different level layers).
  22313. *
  22314. * @class Highlight
  22315. * @util
  22316. */
  22317. var Highlight = function () {
  22318. function Highlight(options) {
  22319. _classCallCheck(this, Highlight);
  22320. /**
  22321. * Options consumed by Highlight class and Walkontable Selection classes.
  22322. *
  22323. * @type {Object}
  22324. */
  22325. this.options = options;
  22326. /**
  22327. * The property which describes which layer level of the visual selection will be modified.
  22328. * This option is valid only for `area` and `header` highlight types which occurs multiple times on
  22329. * the table (as a non-consecutive selection).
  22330. *
  22331. * An order of the layers is the same as the order of added new non-consecutive selections.
  22332. *
  22333. * @type {Number}
  22334. * @default 0
  22335. */
  22336. this.layerLevel = 0;
  22337. /**
  22338. * `cell` highlight object which describes attributes for the currently selected cell.
  22339. * It can only occur only once on the table.
  22340. *
  22341. * @type {Selection}
  22342. */
  22343. this.cell = (0, _types.createHighlight)(CELL_TYPE, options);
  22344. /**
  22345. * `fill` highlight object which describes attributes for the borders for autofill functionality.
  22346. * It can only occur only once on the table.
  22347. *
  22348. * @type {Selection}
  22349. */
  22350. this.fill = (0, _types.createHighlight)(FILL_TYPE, options);
  22351. /**
  22352. * Collection of the `area` highlights. That objects describes attributes for the borders and selection of
  22353. * the multiple selected cells. It can occur multiple times on the table.
  22354. *
  22355. * @type {Map.<number, Selection>}
  22356. */
  22357. this.areas = new Map();
  22358. /**
  22359. * Collection of the `header` highlights. That objects describes attributes for the selection of
  22360. * the multiple selected rows and columns in the table header. It can occur multiple times on the table.
  22361. *
  22362. * @type {Map.<number, Selection>}
  22363. */
  22364. this.headers = new Map();
  22365. /**
  22366. * Collection of the `active-header` highlights. That objects describes attributes for the selection of
  22367. * the multiple selected rows and columns in the table header. The table headers which have selected all items in
  22368. * a row will be marked as `active-header`.
  22369. *
  22370. * @type {Map.<number, Selection>}
  22371. */
  22372. this.activeHeaders = new Map();
  22373. /**
  22374. * The temporary property, holder for borders added through CustomBorders plugin.
  22375. *
  22376. * @type {Selection[]}
  22377. */
  22378. this.borders = [];
  22379. }
  22380. /**
  22381. * Check if highlight cell rendering is disabled for specyfied highlight type.
  22382. *
  22383. * @param {String} highlightType Highlight type. Possible values are: `cell`, `area`, `fill` or `header`.
  22384. * @return {Boolean}
  22385. */
  22386. _createClass(Highlight, [{
  22387. key: 'isEnabledFor',
  22388. value: function isEnabledFor(highlightType) {
  22389. var disableHighlight = this.options.disableHighlight;
  22390. // Legacy compatibility.
  22391. if (highlightType === 'current') {
  22392. highlightType = CELL_TYPE;
  22393. }
  22394. if (typeof disableHighlight === 'string') {
  22395. disableHighlight = [disableHighlight];
  22396. }
  22397. return disableHighlight === false || Array.isArray(disableHighlight) && !disableHighlight.includes(highlightType);
  22398. }
  22399. /**
  22400. * Set a new layer level to make access to the desire `area` and `header` highlights.
  22401. *
  22402. * @param {Number} [level=0] Layer level to use.
  22403. * @returns {Highlight}
  22404. */
  22405. }, {
  22406. key: 'useLayerLevel',
  22407. value: function useLayerLevel() {
  22408. var level = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  22409. this.layerLevel = level;
  22410. return this;
  22411. }
  22412. /**
  22413. * Get Walkontable Selection instance created for controlling highlight of the currently selected/edited cell.
  22414. *
  22415. * @return {Selection}
  22416. */
  22417. }, {
  22418. key: 'getCell',
  22419. value: function getCell() {
  22420. return this.cell;
  22421. }
  22422. /**
  22423. * Get Walkontable Selection instance created for controlling highlight of the autofill functionality.
  22424. *
  22425. * @return {Selection}
  22426. */
  22427. }, {
  22428. key: 'getFill',
  22429. value: function getFill() {
  22430. return this.fill;
  22431. }
  22432. /**
  22433. * Get or create (if not exist in the cache) Walkontable Selection instance created for controlling highlight
  22434. * of the multiple selected cells.
  22435. *
  22436. * @return {Selection}
  22437. */
  22438. }, {
  22439. key: 'createOrGetArea',
  22440. value: function createOrGetArea() {
  22441. var layerLevel = this.layerLevel;
  22442. var area = void 0;
  22443. if (this.areas.has(layerLevel)) {
  22444. area = this.areas.get(layerLevel);
  22445. } else {
  22446. area = (0, _types.createHighlight)(AREA_TYPE, Object.assign({ layerLevel: layerLevel }, this.options));
  22447. this.areas.set(layerLevel, area);
  22448. }
  22449. return area;
  22450. }
  22451. /**
  22452. * Get all Walkontable Selection instances which describes the state of the visual highlight of the cells.
  22453. *
  22454. * @return {Selection[]}
  22455. */
  22456. }, {
  22457. key: 'getAreas',
  22458. value: function getAreas() {
  22459. return [].concat(_toConsumableArray(this.areas.values()));
  22460. }
  22461. /**
  22462. * Get or create (if not exist in the cache) Walkontable Selection instance created for controlling highlight
  22463. * of the multiple selected header cells.
  22464. *
  22465. * @return {Selection}
  22466. */
  22467. }, {
  22468. key: 'createOrGetHeader',
  22469. value: function createOrGetHeader() {
  22470. var layerLevel = this.layerLevel;
  22471. var header = void 0;
  22472. if (this.headers.has(layerLevel)) {
  22473. header = this.headers.get(layerLevel);
  22474. } else {
  22475. header = (0, _types.createHighlight)(HEADER_TYPE, Object.assign({}, this.options));
  22476. this.headers.set(layerLevel, header);
  22477. }
  22478. return header;
  22479. }
  22480. /**
  22481. * Get all Walkontable Selection instances which describes the state of the visual highlight of the headers.
  22482. *
  22483. * @return {Selection[]}
  22484. */
  22485. }, {
  22486. key: 'getHeaders',
  22487. value: function getHeaders() {
  22488. return [].concat(_toConsumableArray(this.headers.values()));
  22489. }
  22490. /**
  22491. * Get or create (if not exist in the cache) Walkontable Selection instance created for controlling highlight
  22492. * of the multiple selected active header cells.
  22493. *
  22494. * @return {Selection}
  22495. */
  22496. }, {
  22497. key: 'createOrGetActiveHeader',
  22498. value: function createOrGetActiveHeader() {
  22499. var layerLevel = this.layerLevel;
  22500. var header = void 0;
  22501. if (this.activeHeaders.has(layerLevel)) {
  22502. header = this.activeHeaders.get(layerLevel);
  22503. } else {
  22504. header = (0, _types.createHighlight)(ACTIVE_HEADER_TYPE, Object.assign({}, this.options));
  22505. this.activeHeaders.set(layerLevel, header);
  22506. }
  22507. return header;
  22508. }
  22509. /**
  22510. * Get all Walkontable Selection instances which describes the state of the visual highlight of the active headers.
  22511. *
  22512. * @return {Selection[]}
  22513. */
  22514. }, {
  22515. key: 'getActiveHeaders',
  22516. value: function getActiveHeaders() {
  22517. return [].concat(_toConsumableArray(this.activeHeaders.values()));
  22518. }
  22519. /**
  22520. * Perform cleaning visual highlights for the whole table.
  22521. */
  22522. }, {
  22523. key: 'clear',
  22524. value: function clear() {
  22525. this.cell.clear();
  22526. this.fill.clear();
  22527. (0, _array.arrayEach)(this.areas.values(), function (highlight) {
  22528. return void highlight.clear();
  22529. });
  22530. (0, _array.arrayEach)(this.headers.values(), function (highlight) {
  22531. return void highlight.clear();
  22532. });
  22533. (0, _array.arrayEach)(this.activeHeaders.values(), function (highlight) {
  22534. return void highlight.clear();
  22535. });
  22536. }
  22537. /**
  22538. * This object can be iterate over using `for of` syntax or using internal `arrayEach` helper.
  22539. */
  22540. }, {
  22541. key: Symbol.iterator,
  22542. value: function value() {
  22543. return [this.cell, this.fill].concat(_toConsumableArray(this.areas.values()), _toConsumableArray(this.headers.values()), _toConsumableArray(this.activeHeaders.values()), _toConsumableArray(this.borders))[Symbol.iterator]();
  22544. }
  22545. }]);
  22546. return Highlight;
  22547. }();
  22548. exports.default = Highlight;
  22549. /***/ }),
  22550. /* 200 */
  22551. /***/ (function(module, exports, __webpack_require__) {
  22552. "use strict";
  22553. exports.__esModule = true;
  22554. 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; }; }();
  22555. var _object = __webpack_require__(2);
  22556. var _number = __webpack_require__(5);
  22557. var _mixed = __webpack_require__(16);
  22558. 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; }
  22559. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  22560. /**
  22561. * @class SamplesGenerator
  22562. * @util
  22563. */
  22564. var SamplesGenerator = function () {
  22565. _createClass(SamplesGenerator, null, [{
  22566. key: 'SAMPLE_COUNT',
  22567. /**
  22568. * Number of samples to take of each value length.
  22569. *
  22570. * @type {Number}
  22571. */
  22572. get: function get() {
  22573. return 3;
  22574. }
  22575. }]);
  22576. function SamplesGenerator(dataFactory) {
  22577. _classCallCheck(this, SamplesGenerator);
  22578. /**
  22579. * Samples prepared for calculations.
  22580. *
  22581. * @type {Map}
  22582. * @default {null}
  22583. */
  22584. this.samples = null;
  22585. /**
  22586. * Function which give the data to collect samples.
  22587. *
  22588. * @type {Function}
  22589. */
  22590. this.dataFactory = dataFactory;
  22591. /**
  22592. * Custom number of samples to take of each value length.
  22593. *
  22594. * @type {Number}
  22595. * @default {null}
  22596. */
  22597. this.customSampleCount = null;
  22598. /**
  22599. * `true` if duplicate samples collection should be allowed, `false` otherwise.
  22600. *
  22601. * @type {Boolean}
  22602. * @default {false}
  22603. */
  22604. this.allowDuplicates = false;
  22605. }
  22606. /**
  22607. * Get the sample count for this instance.
  22608. *
  22609. * @returns {Number}
  22610. */
  22611. _createClass(SamplesGenerator, [{
  22612. key: 'getSampleCount',
  22613. value: function getSampleCount() {
  22614. if (this.customSampleCount) {
  22615. return this.customSampleCount;
  22616. }
  22617. return SamplesGenerator.SAMPLE_COUNT;
  22618. }
  22619. }, {
  22620. key: 'setSampleCount',
  22621. /**
  22622. * Set the sample count.
  22623. *
  22624. * @param {Number} sampleCount Number of samples to be collected.
  22625. */
  22626. value: function setSampleCount(sampleCount) {
  22627. this.customSampleCount = sampleCount;
  22628. }
  22629. /**
  22630. * Set if the generator should accept duplicate values.
  22631. *
  22632. * @param {Boolean} allowDuplicates `true` to allow duplicate values.
  22633. */
  22634. }, {
  22635. key: 'setAllowDuplicates',
  22636. value: function setAllowDuplicates(allowDuplicates) {
  22637. this.allowDuplicates = allowDuplicates;
  22638. }
  22639. /**
  22640. * Generate samples for row. You can control which area should be sampled by passing `rowRange` object and `colRange` object.
  22641. *
  22642. * @param {Object|Number} rowRange
  22643. * @param {Object} colRange
  22644. * @returns {Object}
  22645. */
  22646. }, {
  22647. key: 'generateRowSamples',
  22648. value: function generateRowSamples(rowRange, colRange) {
  22649. return this.generateSamples('row', colRange, rowRange);
  22650. }
  22651. /**
  22652. * Generate samples for column. You can control which area should be sampled by passing `colRange` object and `rowRange` object.
  22653. *
  22654. * @param {Object} colRange Column index.
  22655. * @param {Object} rowRange Column index.
  22656. * @returns {Object}
  22657. */
  22658. }, {
  22659. key: 'generateColumnSamples',
  22660. value: function generateColumnSamples(colRange, rowRange) {
  22661. return this.generateSamples('col', rowRange, colRange);
  22662. }
  22663. /**
  22664. * Generate collection of samples.
  22665. *
  22666. * @param {String} type Type to generate. Can be `col` or `row`.
  22667. * @param {Object} range
  22668. * @param {Object|Number} specifierRange
  22669. * @returns {Map}
  22670. */
  22671. }, {
  22672. key: 'generateSamples',
  22673. value: function generateSamples(type, range, specifierRange) {
  22674. var _this = this;
  22675. var samples = new Map();
  22676. if (typeof specifierRange === 'number') {
  22677. specifierRange = { from: specifierRange, to: specifierRange };
  22678. }
  22679. (0, _number.rangeEach)(specifierRange.from, specifierRange.to, function (index) {
  22680. var sample = _this.generateSample(type, range, index);
  22681. samples.set(index, sample);
  22682. });
  22683. return samples;
  22684. }
  22685. /**
  22686. * Generate sample for specified type (`row` or `col`).
  22687. *
  22688. * @param {String} type Samples type `row` or `col`.
  22689. * @param {Object} range
  22690. * @param {Number} specifierValue
  22691. * @returns {Map}
  22692. */
  22693. }, {
  22694. key: 'generateSample',
  22695. value: function generateSample(type, range, specifierValue) {
  22696. var _this2 = this;
  22697. var samples = new Map();
  22698. var sampledValues = [];
  22699. var length = void 0;
  22700. (0, _number.rangeEach)(range.from, range.to, function (index) {
  22701. var value = void 0;
  22702. if (type === 'row') {
  22703. value = _this2.dataFactory(specifierValue, index);
  22704. } else if (type === 'col') {
  22705. value = _this2.dataFactory(index, specifierValue);
  22706. } else {
  22707. throw new Error('Unsupported sample type');
  22708. }
  22709. if ((0, _object.isObject)(value)) {
  22710. length = Object.keys(value).length;
  22711. } else if (Array.isArray(value)) {
  22712. length = value.length;
  22713. } else {
  22714. length = (0, _mixed.stringify)(value).length;
  22715. }
  22716. if (!samples.has(length)) {
  22717. samples.set(length, {
  22718. needed: _this2.getSampleCount(),
  22719. strings: []
  22720. });
  22721. }
  22722. var sample = samples.get(length);
  22723. if (sample.needed) {
  22724. var duplicate = sampledValues.indexOf(value) > -1;
  22725. if (!duplicate || _this2.allowDuplicates) {
  22726. var computedKey = type === 'row' ? 'col' : 'row';
  22727. sample.strings.push(_defineProperty({ value: value }, computedKey, index));
  22728. sampledValues.push(value);
  22729. sample.needed--;
  22730. }
  22731. }
  22732. });
  22733. return samples;
  22734. }
  22735. }]);
  22736. return SamplesGenerator;
  22737. }();
  22738. exports.default = SamplesGenerator;
  22739. /***/ }),
  22740. /* 201 */
  22741. /***/ (function(module, exports, __webpack_require__) {
  22742. "use strict";
  22743. exports.__esModule = true;
  22744. var _array = __webpack_require__(1);
  22745. var _object = __webpack_require__(2);
  22746. var _number = __webpack_require__(5);
  22747. 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); } }
  22748. var MIXIN_NAME = 'arrayMapper';
  22749. /**
  22750. * @type {Object}
  22751. */
  22752. var arrayMapper = {
  22753. _arrayMap: [],
  22754. /**
  22755. * Get translated index by its physical index.
  22756. *
  22757. * @param {Number} physicalIndex Physical index.
  22758. * @return {Number|null} Returns translated index mapped by passed physical index.
  22759. */
  22760. getValueByIndex: function getValueByIndex(physicalIndex) {
  22761. var length = this._arrayMap.length;
  22762. var translatedIndex = null;
  22763. if (physicalIndex < length) {
  22764. translatedIndex = this._arrayMap[physicalIndex];
  22765. }
  22766. return translatedIndex;
  22767. },
  22768. /**
  22769. * Get physical index by its translated index.
  22770. *
  22771. * @param {*} translatedIndex Value to search.
  22772. * @returns {Number|null} Returns a physical index of the array mapper.
  22773. */
  22774. getIndexByValue: function getIndexByValue(translatedIndex) {
  22775. var physicalIndex = void 0;
  22776. // eslint-disable-next-line no-cond-assign, no-return-assign
  22777. return (physicalIndex = this._arrayMap.indexOf(translatedIndex)) === -1 ? null : physicalIndex;
  22778. },
  22779. /**
  22780. * Insert new items to array mapper starting at passed index. New entries will be a continuation of last value in the array.
  22781. *
  22782. * @param {Number} physicalIndex Array index.
  22783. * @param {Number} [amount=1] Defines how many items will be created to an array.
  22784. * @returns {Array} Returns added items.
  22785. */
  22786. insertItems: function insertItems(physicalIndex) {
  22787. var _this = this;
  22788. var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  22789. var newIndex = (0, _array.arrayMax)(this._arrayMap) + 1;
  22790. var addedItems = [];
  22791. (0, _number.rangeEach)(amount - 1, function (count) {
  22792. addedItems.push(_this._arrayMap.splice(physicalIndex + count, 0, newIndex + count));
  22793. });
  22794. return addedItems;
  22795. },
  22796. /**
  22797. * Remove items from array mapper.
  22798. *
  22799. * @param {Number} physicalIndex Array index.
  22800. * @param {Number} [amount=1] Defines how many items will be created to an array.
  22801. * @returns {Array} Returns removed items.
  22802. */
  22803. removeItems: function removeItems(physicalIndex) {
  22804. var _this2 = this;
  22805. var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  22806. var removedItems = [];
  22807. if (Array.isArray(physicalIndex)) {
  22808. var mapCopy = [].concat(this._arrayMap);
  22809. // Sort descending
  22810. physicalIndex.sort(function (a, b) {
  22811. return b - a;
  22812. });
  22813. removedItems = (0, _array.arrayReduce)(physicalIndex, function (acc, item) {
  22814. _this2._arrayMap.splice(item, 1);
  22815. return acc.concat(mapCopy.slice(item, item + 1));
  22816. }, []);
  22817. } else {
  22818. removedItems = this._arrayMap.splice(physicalIndex, amount);
  22819. }
  22820. return removedItems;
  22821. },
  22822. /**
  22823. * Unshift items (remove and shift chunk of array to the left).
  22824. *
  22825. * @param {Number|Array} physicalIndex Array index or Array of indexes to unshift.
  22826. * @param {Number} [amount=1] Defines how many items will be removed from an array (when index is passed as number).
  22827. */
  22828. unshiftItems: function unshiftItems(physicalIndex) {
  22829. var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  22830. var removedItems = this.removeItems(physicalIndex, amount);
  22831. function countRowShift(logicalRow) {
  22832. // Todo: compare perf between reduce vs sort->each->brake
  22833. return (0, _array.arrayReduce)(removedItems, function (count, removedLogicalRow) {
  22834. if (logicalRow > removedLogicalRow) {
  22835. count++;
  22836. }
  22837. return count;
  22838. }, 0);
  22839. }
  22840. this._arrayMap = (0, _array.arrayMap)(this._arrayMap, function (logicalRow, physicalRow) {
  22841. var rowShift = countRowShift(logicalRow);
  22842. if (rowShift) {
  22843. logicalRow -= rowShift;
  22844. }
  22845. return logicalRow;
  22846. });
  22847. },
  22848. /**
  22849. * Shift (right shifting) items starting at passed index.
  22850. *
  22851. * @param {Number} physicalIndex Array index.
  22852. * @param {Number} [amount=1] Defines how many items will be created to an array.
  22853. */
  22854. shiftItems: function shiftItems(physicalIndex) {
  22855. var _this3 = this;
  22856. var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  22857. this._arrayMap = (0, _array.arrayMap)(this._arrayMap, function (row) {
  22858. if (row >= physicalIndex) {
  22859. row += amount;
  22860. }
  22861. return row;
  22862. });
  22863. (0, _number.rangeEach)(amount - 1, function (count) {
  22864. _this3._arrayMap.splice(physicalIndex + count, 0, physicalIndex + count);
  22865. });
  22866. },
  22867. /**
  22868. * Swap indexes in arrayMapper.
  22869. *
  22870. * @param {Number} physicalIndexFrom index to move.
  22871. * @param {Number} physicalIndexTo index to.
  22872. */
  22873. swapIndexes: function swapIndexes(physicalIndexFrom, physicalIndexTo) {
  22874. var _arrayMap;
  22875. (_arrayMap = this._arrayMap).splice.apply(_arrayMap, [physicalIndexTo, 0].concat(_toConsumableArray(this._arrayMap.splice(physicalIndexFrom, 1))));
  22876. },
  22877. /**
  22878. * Clear all stored index<->value information from an array.
  22879. */
  22880. clearMap: function clearMap() {
  22881. this._arrayMap.length = 0;
  22882. }
  22883. };
  22884. (0, _object.defineGetter)(arrayMapper, 'MIXIN_NAME', MIXIN_NAME, {
  22885. writable: false,
  22886. enumerable: false
  22887. });
  22888. exports.default = arrayMapper;
  22889. /***/ }),
  22890. /* 202 */
  22891. /***/ (function(module, exports, __webpack_require__) {
  22892. "use strict";
  22893. exports.__esModule = true;
  22894. 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; }; }();
  22895. var _number = __webpack_require__(5);
  22896. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  22897. var STATE_INITIALIZED = 0;
  22898. var STATE_BUILT = 1;
  22899. var STATE_APPENDED = 2;
  22900. var UNIT = 'px';
  22901. /**
  22902. * @class
  22903. * @private
  22904. */
  22905. var BaseUI = function () {
  22906. function BaseUI(hotInstance) {
  22907. _classCallCheck(this, BaseUI);
  22908. /**
  22909. * Instance of Handsontable.
  22910. *
  22911. * @type {Core}
  22912. */
  22913. this.hot = hotInstance;
  22914. /**
  22915. * DOM element representing the ui element.
  22916. *
  22917. * @type {HTMLElement}
  22918. * @private
  22919. */
  22920. this._element = null;
  22921. /**
  22922. * Flag which determines build state of element.
  22923. *
  22924. * @type {Boolean}
  22925. */
  22926. this.state = STATE_INITIALIZED;
  22927. }
  22928. /**
  22929. * Add created UI elements to table.
  22930. *
  22931. * @param {HTMLElement} wrapper Element which are parent for our UI element.
  22932. */
  22933. _createClass(BaseUI, [{
  22934. key: 'appendTo',
  22935. value: function appendTo(wrapper) {
  22936. wrapper.appendChild(this._element);
  22937. this.state = STATE_APPENDED;
  22938. }
  22939. /**
  22940. * Method for create UI element. Only create, without append to table.
  22941. */
  22942. }, {
  22943. key: 'build',
  22944. value: function build() {
  22945. this._element = document.createElement('div');
  22946. this.state = STATE_BUILT;
  22947. }
  22948. /**
  22949. * Method for remove UI element.
  22950. */
  22951. }, {
  22952. key: 'destroy',
  22953. value: function destroy() {
  22954. if (this.isAppended()) {
  22955. this._element.parentElement.removeChild(this._element);
  22956. }
  22957. this._element = null;
  22958. this.state = STATE_INITIALIZED;
  22959. }
  22960. /**
  22961. * Check if UI element are appended.
  22962. *
  22963. * @returns {Boolean}
  22964. */
  22965. }, {
  22966. key: 'isAppended',
  22967. value: function isAppended() {
  22968. return this.state === STATE_APPENDED;
  22969. }
  22970. /**
  22971. * Check if UI element are built.
  22972. *
  22973. * @returns {Boolean}
  22974. */
  22975. }, {
  22976. key: 'isBuilt',
  22977. value: function isBuilt() {
  22978. return this.state >= STATE_BUILT;
  22979. }
  22980. /**
  22981. * Setter for position.
  22982. *
  22983. * @param {Number} top New top position of the element.
  22984. * @param {Number} left New left position of the element.
  22985. */
  22986. }, {
  22987. key: 'setPosition',
  22988. value: function setPosition(top, left) {
  22989. if ((0, _number.isNumeric)(top)) {
  22990. this._element.style.top = top + UNIT;
  22991. }
  22992. if ((0, _number.isNumeric)(left)) {
  22993. this._element.style.left = left + UNIT;
  22994. }
  22995. }
  22996. /**
  22997. * Getter for the element position.
  22998. *
  22999. * @returns {Object} Object contains left and top position of the element.
  23000. */
  23001. }, {
  23002. key: 'getPosition',
  23003. value: function getPosition() {
  23004. return {
  23005. top: this._element.style.top ? parseInt(this._element.style.top, 10) : 0,
  23006. left: this._element.style.left ? parseInt(this._element.style.left, 10) : 0
  23007. };
  23008. }
  23009. /**
  23010. * Setter for the element size.
  23011. *
  23012. * @param {Number} width New width of the element.
  23013. * @param {Number} height New height of the element.
  23014. */
  23015. }, {
  23016. key: 'setSize',
  23017. value: function setSize(width, height) {
  23018. if ((0, _number.isNumeric)(width)) {
  23019. this._element.style.width = width + UNIT;
  23020. }
  23021. if ((0, _number.isNumeric)(height)) {
  23022. this._element.style.height = height + UNIT;
  23023. }
  23024. }
  23025. /**
  23026. * Getter for the element position.
  23027. *
  23028. * @returns {Object} Object contains height and width of the element.
  23029. */
  23030. }, {
  23031. key: 'getSize',
  23032. value: function getSize() {
  23033. return {
  23034. width: this._element.style.width ? parseInt(this._element.style.width, 10) : 0,
  23035. height: this._element.style.height ? parseInt(this._element.style.height, 10) : 0
  23036. };
  23037. }
  23038. /**
  23039. * Setter for the element offset. Offset means marginTop and marginLeft of the element.
  23040. *
  23041. * @param {Number} top New margin top of the element.
  23042. * @param {Number} left New margin left of the element.
  23043. */
  23044. }, {
  23045. key: 'setOffset',
  23046. value: function setOffset(top, left) {
  23047. if ((0, _number.isNumeric)(top)) {
  23048. this._element.style.marginTop = top + UNIT;
  23049. }
  23050. if ((0, _number.isNumeric)(left)) {
  23051. this._element.style.marginLeft = left + UNIT;
  23052. }
  23053. }
  23054. /**
  23055. * Getter for the element offset.
  23056. *
  23057. * @returns {Object} Object contains top and left offset of the element.
  23058. */
  23059. }, {
  23060. key: 'getOffset',
  23061. value: function getOffset() {
  23062. return {
  23063. top: this._element.style.marginTop ? parseInt(this._element.style.marginTop, 10) : 0,
  23064. left: this._element.style.marginLeft ? parseInt(this._element.style.marginLeft, 10) : 0
  23065. };
  23066. }
  23067. }]);
  23068. return BaseUI;
  23069. }();
  23070. exports.default = BaseUI;
  23071. /***/ }),
  23072. /* 203 */
  23073. /***/ (function(module, exports, __webpack_require__) {
  23074. "use strict";
  23075. exports.__esModule = true;
  23076. 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; }; }();
  23077. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  23078. var STATE_INITIALIZED = 0;
  23079. var STATE_BUILT = 1;
  23080. var STATE_APPENDED = 2;
  23081. var UNIT = 'px';
  23082. /**
  23083. * @class
  23084. * @private
  23085. */
  23086. var BaseUI = function () {
  23087. function BaseUI(hotInstance) {
  23088. _classCallCheck(this, BaseUI);
  23089. /**
  23090. * Instance of Handsontable.
  23091. *
  23092. * @type {Core}
  23093. */
  23094. this.hot = hotInstance;
  23095. /**
  23096. * DOM element representing the ui element.
  23097. *
  23098. * @type {HTMLElement}
  23099. * @private
  23100. */
  23101. this._element = null;
  23102. /**
  23103. * Flag which determines build state of element.
  23104. *
  23105. * @type {Boolean}
  23106. */
  23107. this.state = STATE_INITIALIZED;
  23108. }
  23109. /**
  23110. * Add created UI elements to table.
  23111. *
  23112. * @param {HTMLElement} wrapper Element which are parent for our UI element.
  23113. */
  23114. _createClass(BaseUI, [{
  23115. key: 'appendTo',
  23116. value: function appendTo(wrapper) {
  23117. wrapper.appendChild(this._element);
  23118. this.state = STATE_APPENDED;
  23119. }
  23120. /**
  23121. * Method for create UI element. Only create, without append to table.
  23122. */
  23123. }, {
  23124. key: 'build',
  23125. value: function build() {
  23126. this._element = document.createElement('div');
  23127. this.state = STATE_BUILT;
  23128. }
  23129. /**
  23130. * Method for remove UI element.
  23131. */
  23132. }, {
  23133. key: 'destroy',
  23134. value: function destroy() {
  23135. if (this.isAppended()) {
  23136. this._element.parentElement.removeChild(this._element);
  23137. }
  23138. this._element = null;
  23139. this.state = STATE_INITIALIZED;
  23140. }
  23141. /**
  23142. * Check if UI element are appended.
  23143. *
  23144. * @returns {Boolean}
  23145. */
  23146. }, {
  23147. key: 'isAppended',
  23148. value: function isAppended() {
  23149. return this.state === STATE_APPENDED;
  23150. }
  23151. /**
  23152. * Check if UI element are built.
  23153. *
  23154. * @returns {Boolean}
  23155. */
  23156. }, {
  23157. key: 'isBuilt',
  23158. value: function isBuilt() {
  23159. return this.state >= STATE_BUILT;
  23160. }
  23161. /**
  23162. * Setter for position.
  23163. *
  23164. * @param {Number} top New top position of the element.
  23165. * @param {Number} left New left position of the element.
  23166. */
  23167. }, {
  23168. key: 'setPosition',
  23169. value: function setPosition(top, left) {
  23170. if (top !== void 0) {
  23171. this._element.style.top = top + UNIT;
  23172. }
  23173. if (left !== void 0) {
  23174. this._element.style.left = left + UNIT;
  23175. }
  23176. }
  23177. /**
  23178. * Getter for the element position.
  23179. *
  23180. * @returns {Object} Object contains left and top position of the element.
  23181. */
  23182. }, {
  23183. key: 'getPosition',
  23184. value: function getPosition() {
  23185. return {
  23186. top: this._element.style.top ? parseInt(this._element.style.top, 10) : 0,
  23187. left: this._element.style.left ? parseInt(this._element.style.left, 10) : 0
  23188. };
  23189. }
  23190. /**
  23191. * Setter for the element size.
  23192. *
  23193. * @param {Number} width New width of the element.
  23194. * @param {Number} height New height of the element.
  23195. */
  23196. }, {
  23197. key: 'setSize',
  23198. value: function setSize(width, height) {
  23199. if (width) {
  23200. this._element.style.width = width + UNIT;
  23201. }
  23202. if (height) {
  23203. this._element.style.height = height + UNIT;
  23204. }
  23205. }
  23206. /**
  23207. * Getter for the element position.
  23208. *
  23209. * @returns {Object} Object contains height and width of the element.
  23210. */
  23211. }, {
  23212. key: 'getSize',
  23213. value: function getSize() {
  23214. return {
  23215. width: this._element.style.width ? parseInt(this._element.style.width, 10) : 0,
  23216. height: this._element.style.height ? parseInt(this._element.style.height, 10) : 0
  23217. };
  23218. }
  23219. /**
  23220. * Setter for the element offset. Offset means marginTop and marginLeft of the element.
  23221. *
  23222. * @param {Number} top New margin top of the element.
  23223. * @param {Number} left New margin left of the element.
  23224. */
  23225. }, {
  23226. key: 'setOffset',
  23227. value: function setOffset(top, left) {
  23228. if (top) {
  23229. this._element.style.marginTop = top + UNIT;
  23230. }
  23231. if (left) {
  23232. this._element.style.marginLeft = left + UNIT;
  23233. }
  23234. }
  23235. /**
  23236. * Getter for the element offset.
  23237. *
  23238. * @returns {Object} Object contains top and left offset of the element.
  23239. */
  23240. }, {
  23241. key: 'getOffset',
  23242. value: function getOffset() {
  23243. return {
  23244. top: this._element.style.marginTop ? parseInt(this._element.style.marginTop, 10) : 0,
  23245. left: this._element.style.marginLeft ? parseInt(this._element.style.marginLeft, 10) : 0
  23246. };
  23247. }
  23248. }]);
  23249. return BaseUI;
  23250. }();
  23251. exports.default = BaseUI;
  23252. /***/ }),
  23253. /* 204 */
  23254. /***/ (function(module, exports, __webpack_require__) {
  23255. "use strict";
  23256. exports.__esModule = true;
  23257. exports.applySpanProperties = applySpanProperties;
  23258. /**
  23259. * Apply the `colspan`/`rowspan` properties.
  23260. *
  23261. * @param {HTMLElement} TD The soon-to-be-modified cell.
  23262. * @param {MergedCellCoords} merged cellInfo The merged cell in question.
  23263. * @param {Number} row Row index.
  23264. * @param {Number} col Column index.
  23265. */
  23266. // eslint-disable-next-line import/prefer-default-export
  23267. function applySpanProperties(TD, mergedCellInfo, row, col) {
  23268. if (mergedCellInfo) {
  23269. if (mergedCellInfo.row === row && mergedCellInfo.col === col) {
  23270. TD.setAttribute('rowspan', mergedCellInfo.rowspan.toString());
  23271. TD.setAttribute('colspan', mergedCellInfo.colspan.toString());
  23272. } else {
  23273. TD.removeAttribute('rowspan');
  23274. TD.removeAttribute('colspan');
  23275. TD.style.display = 'none';
  23276. }
  23277. } else {
  23278. TD.removeAttribute('rowspan');
  23279. TD.removeAttribute('colspan');
  23280. TD.style.display = '';
  23281. }
  23282. }
  23283. /***/ }),
  23284. /* 205 */
  23285. /***/ (function(module, exports, __webpack_require__) {
  23286. "use strict";
  23287. 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; };
  23288. /*!
  23289. * https://github.com/Starcounter-Jack/JSON-Patch
  23290. * json-patch-duplex.js version: 0.5.7
  23291. * (c) 2013 Joachim Wester
  23292. * MIT license
  23293. */
  23294. var __extends = undefined && undefined.__extends || function (d, b) {
  23295. for (var p in b) {
  23296. if (b.hasOwnProperty(p)) d[p] = b[p];
  23297. }function __() {
  23298. this.constructor = d;
  23299. }
  23300. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  23301. };
  23302. var OriginalError = Error;
  23303. var jsonpatch;
  23304. (function (jsonpatch) {
  23305. var _objectKeys = function _objectKeys(obj) {
  23306. if (_isArray(obj)) {
  23307. var keys = new Array(obj.length);
  23308. for (var k = 0; k < keys.length; k++) {
  23309. keys[k] = "" + k;
  23310. }
  23311. return keys;
  23312. }
  23313. if (Object.keys) {
  23314. return Object.keys(obj);
  23315. }
  23316. var keys = [];
  23317. for (var i in obj) {
  23318. if (obj.hasOwnProperty(i)) {
  23319. keys.push(i);
  23320. }
  23321. }
  23322. return keys;
  23323. };
  23324. function _equals(a, b) {
  23325. switch (typeof a === 'undefined' ? 'undefined' : _typeof(a)) {
  23326. case 'undefined': //backward compatibility, but really I think we should return false
  23327. case 'boolean':
  23328. case 'string':
  23329. case 'number':
  23330. return a === b;
  23331. case 'object':
  23332. if (a === null) return b === null;
  23333. if (_isArray(a)) {
  23334. if (!_isArray(b) || a.length !== b.length) return false;
  23335. for (var i = 0, l = a.length; i < l; i++) {
  23336. if (!_equals(a[i], b[i])) return false;
  23337. }return true;
  23338. }
  23339. var bKeys = _objectKeys(b);
  23340. var bLength = bKeys.length;
  23341. if (_objectKeys(a).length !== bLength) return false;
  23342. for (var i = 0; i < bLength; i++) {
  23343. if (!_equals(a[i], b[i])) return false;
  23344. }return true;
  23345. default:
  23346. return false;
  23347. }
  23348. }
  23349. /* We use a Javascript hash to store each
  23350. function. Each hash entry (property) uses
  23351. the operation identifiers specified in rfc6902.
  23352. In this way, we can map each patch operation
  23353. to its dedicated function in efficient way.
  23354. */
  23355. /* The operations applicable to an object */
  23356. var objOps = {
  23357. add: function add(obj, key) {
  23358. obj[key] = this.value;
  23359. return true;
  23360. },
  23361. remove: function remove(obj, key) {
  23362. delete obj[key];
  23363. return true;
  23364. },
  23365. replace: function replace(obj, key) {
  23366. obj[key] = this.value;
  23367. return true;
  23368. },
  23369. move: function move(obj, key, tree) {
  23370. var temp = { op: "_get", path: this.from };
  23371. apply(tree, [temp]);
  23372. apply(tree, [{ op: "remove", path: this.from }]);
  23373. apply(tree, [{ op: "add", path: this.path, value: temp.value }]);
  23374. return true;
  23375. },
  23376. copy: function copy(obj, key, tree) {
  23377. var temp = { op: "_get", path: this.from };
  23378. apply(tree, [temp]);
  23379. apply(tree, [{ op: "add", path: this.path, value: temp.value }]);
  23380. return true;
  23381. },
  23382. test: function test(obj, key) {
  23383. return _equals(obj[key], this.value);
  23384. },
  23385. _get: function _get(obj, key) {
  23386. this.value = obj[key];
  23387. }
  23388. };
  23389. /* The operations applicable to an array. Many are the same as for the object */
  23390. var arrOps = {
  23391. add: function add(arr, i) {
  23392. arr.splice(i, 0, this.value);
  23393. return true;
  23394. },
  23395. remove: function remove(arr, i) {
  23396. arr.splice(i, 1);
  23397. return true;
  23398. },
  23399. replace: function replace(arr, i) {
  23400. arr[i] = this.value;
  23401. return true;
  23402. },
  23403. move: objOps.move,
  23404. copy: objOps.copy,
  23405. test: objOps.test,
  23406. _get: objOps._get
  23407. };
  23408. /* The operations applicable to object root. Many are the same as for the object */
  23409. var rootOps = {
  23410. add: function add(obj) {
  23411. rootOps.remove.call(this, obj);
  23412. for (var key in this.value) {
  23413. if (this.value.hasOwnProperty(key)) {
  23414. obj[key] = this.value[key];
  23415. }
  23416. }
  23417. return true;
  23418. },
  23419. remove: function remove(obj) {
  23420. for (var key in obj) {
  23421. if (obj.hasOwnProperty(key)) {
  23422. objOps.remove.call(this, obj, key);
  23423. }
  23424. }
  23425. return true;
  23426. },
  23427. replace: function replace(obj) {
  23428. apply(obj, [{ op: "remove", path: this.path }]);
  23429. apply(obj, [{ op: "add", path: this.path, value: this.value }]);
  23430. return true;
  23431. },
  23432. move: objOps.move,
  23433. copy: objOps.copy,
  23434. test: function test(obj) {
  23435. return JSON.stringify(obj) === JSON.stringify(this.value);
  23436. },
  23437. _get: function _get(obj) {
  23438. this.value = obj;
  23439. }
  23440. };
  23441. var observeOps = {
  23442. add: function add(patches, path) {
  23443. var patch = {
  23444. op: "add",
  23445. path: path + escapePathComponent(this.name),
  23446. value: this.object[this.name] };
  23447. patches.push(patch);
  23448. },
  23449. 'delete': function _delete(patches, path) {
  23450. var patch = {
  23451. op: "remove",
  23452. path: path + escapePathComponent(this.name)
  23453. };
  23454. patches.push(patch);
  23455. },
  23456. update: function update(patches, path) {
  23457. var patch = {
  23458. op: "replace",
  23459. path: path + escapePathComponent(this.name),
  23460. value: this.object[this.name]
  23461. };
  23462. patches.push(patch);
  23463. }
  23464. };
  23465. function escapePathComponent(str) {
  23466. if (str.indexOf('/') === -1 && str.indexOf('~') === -1) return str;
  23467. return str.replace(/~/g, '~0').replace(/\//g, '~1');
  23468. }
  23469. function _getPathRecursive(root, obj) {
  23470. var found;
  23471. for (var key in root) {
  23472. if (root.hasOwnProperty(key)) {
  23473. if (root[key] === obj) {
  23474. return escapePathComponent(key) + '/';
  23475. } else if (_typeof(root[key]) === 'object') {
  23476. found = _getPathRecursive(root[key], obj);
  23477. if (found != '') {
  23478. return escapePathComponent(key) + '/' + found;
  23479. }
  23480. }
  23481. }
  23482. }
  23483. return '';
  23484. }
  23485. function getPath(root, obj) {
  23486. if (root === obj) {
  23487. return '/';
  23488. }
  23489. var path = _getPathRecursive(root, obj);
  23490. if (path === '') {
  23491. throw new OriginalError("Object not found in root");
  23492. }
  23493. return '/' + path;
  23494. }
  23495. var beforeDict = [];
  23496. var Mirror = function () {
  23497. function Mirror(obj) {
  23498. this.observers = [];
  23499. this.obj = obj;
  23500. }
  23501. return Mirror;
  23502. }();
  23503. var ObserverInfo = function () {
  23504. function ObserverInfo(callback, observer) {
  23505. this.callback = callback;
  23506. this.observer = observer;
  23507. }
  23508. return ObserverInfo;
  23509. }();
  23510. function getMirror(obj) {
  23511. for (var i = 0, ilen = beforeDict.length; i < ilen; i++) {
  23512. if (beforeDict[i].obj === obj) {
  23513. return beforeDict[i];
  23514. }
  23515. }
  23516. }
  23517. function getObserverFromMirror(mirror, callback) {
  23518. for (var j = 0, jlen = mirror.observers.length; j < jlen; j++) {
  23519. if (mirror.observers[j].callback === callback) {
  23520. return mirror.observers[j].observer;
  23521. }
  23522. }
  23523. }
  23524. function removeObserverFromMirror(mirror, observer) {
  23525. for (var j = 0, jlen = mirror.observers.length; j < jlen; j++) {
  23526. if (mirror.observers[j].observer === observer) {
  23527. mirror.observers.splice(j, 1);
  23528. return;
  23529. }
  23530. }
  23531. }
  23532. function unobserve(root, observer) {
  23533. observer.unobserve();
  23534. }
  23535. jsonpatch.unobserve = unobserve;
  23536. function deepClone(obj) {
  23537. if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === "object") {
  23538. return JSON.parse(JSON.stringify(obj)); //Faster than ES5 clone - http://jsperf.com/deep-cloning-of-objects/5
  23539. } else {
  23540. return obj; //no need to clone primitives
  23541. }
  23542. }
  23543. function observe(obj, callback) {
  23544. var patches = [];
  23545. var root = obj;
  23546. var observer;
  23547. var mirror = getMirror(obj);
  23548. if (!mirror) {
  23549. mirror = new Mirror(obj);
  23550. beforeDict.push(mirror);
  23551. } else {
  23552. observer = getObserverFromMirror(mirror, callback);
  23553. }
  23554. if (observer) {
  23555. return observer;
  23556. }
  23557. observer = {};
  23558. mirror.value = deepClone(obj);
  23559. if (callback) {
  23560. observer.callback = callback;
  23561. observer.next = null;
  23562. var intervals = this.intervals || [100, 1000, 10000, 60000];
  23563. if (intervals.push === void 0) {
  23564. throw new OriginalError("jsonpatch.intervals must be an array");
  23565. }
  23566. var currentInterval = 0;
  23567. var dirtyCheck = function dirtyCheck() {
  23568. generate(observer);
  23569. };
  23570. var fastCheck = function fastCheck() {
  23571. clearTimeout(observer.next);
  23572. observer.next = setTimeout(function () {
  23573. dirtyCheck();
  23574. currentInterval = 0;
  23575. observer.next = setTimeout(slowCheck, intervals[currentInterval++]);
  23576. }, 0);
  23577. };
  23578. var slowCheck = function slowCheck() {
  23579. dirtyCheck();
  23580. if (currentInterval == intervals.length) currentInterval = intervals.length - 1;
  23581. observer.next = setTimeout(slowCheck, intervals[currentInterval++]);
  23582. };
  23583. if (typeof window !== 'undefined') {
  23584. if (window.addEventListener) {
  23585. window.addEventListener('mousedown', fastCheck);
  23586. window.addEventListener('mouseup', fastCheck);
  23587. window.addEventListener('keydown', fastCheck);
  23588. } else {
  23589. document.documentElement.attachEvent('onmousedown', fastCheck);
  23590. document.documentElement.attachEvent('onmouseup', fastCheck);
  23591. document.documentElement.attachEvent('onkeydown', fastCheck);
  23592. }
  23593. }
  23594. observer.next = setTimeout(slowCheck, intervals[currentInterval++]);
  23595. }
  23596. observer.patches = patches;
  23597. observer.object = obj;
  23598. observer.unobserve = function () {
  23599. generate(observer);
  23600. clearTimeout(observer.next);
  23601. removeObserverFromMirror(mirror, observer);
  23602. if (typeof window !== 'undefined') {
  23603. if (window.removeEventListener) {
  23604. window.removeEventListener('mousedown', fastCheck);
  23605. window.removeEventListener('mouseup', fastCheck);
  23606. window.removeEventListener('keydown', fastCheck);
  23607. } else {
  23608. document.documentElement.detachEvent('onmousedown', fastCheck);
  23609. document.documentElement.detachEvent('onmouseup', fastCheck);
  23610. document.documentElement.detachEvent('onkeydown', fastCheck);
  23611. }
  23612. }
  23613. };
  23614. mirror.observers.push(new ObserverInfo(callback, observer));
  23615. return observer;
  23616. }
  23617. jsonpatch.observe = observe;
  23618. function generate(observer) {
  23619. var mirror;
  23620. for (var i = 0, ilen = beforeDict.length; i < ilen; i++) {
  23621. if (beforeDict[i].obj === observer.object) {
  23622. mirror = beforeDict[i];
  23623. break;
  23624. }
  23625. }
  23626. _generate(mirror.value, observer.object, observer.patches, "");
  23627. if (observer.patches.length) {
  23628. apply(mirror.value, observer.patches);
  23629. }
  23630. var temp = observer.patches;
  23631. if (temp.length > 0) {
  23632. observer.patches = [];
  23633. if (observer.callback) {
  23634. observer.callback(temp);
  23635. }
  23636. }
  23637. return temp;
  23638. }
  23639. jsonpatch.generate = generate;
  23640. // Dirty check if obj is different from mirror, generate patches and update mirror
  23641. function _generate(mirror, obj, patches, path) {
  23642. var newKeys = _objectKeys(obj);
  23643. var oldKeys = _objectKeys(mirror);
  23644. var changed = false;
  23645. var deleted = false;
  23646. //if ever "move" operation is implemented here, make sure this test runs OK: "should not generate the same patch twice (move)"
  23647. for (var t = oldKeys.length - 1; t >= 0; t--) {
  23648. var key = oldKeys[t];
  23649. var oldVal = mirror[key];
  23650. if (obj.hasOwnProperty(key)) {
  23651. var newVal = obj[key];
  23652. if ((typeof oldVal === 'undefined' ? 'undefined' : _typeof(oldVal)) == "object" && oldVal != null && (typeof newVal === 'undefined' ? 'undefined' : _typeof(newVal)) == "object" && newVal != null) {
  23653. _generate(oldVal, newVal, patches, path + "/" + escapePathComponent(key));
  23654. } else {
  23655. if (oldVal != newVal) {
  23656. changed = true;
  23657. patches.push({ op: "replace", path: path + "/" + escapePathComponent(key), value: deepClone(newVal) });
  23658. }
  23659. }
  23660. } else {
  23661. patches.push({ op: "remove", path: path + "/" + escapePathComponent(key) });
  23662. deleted = true; // property has been deleted
  23663. }
  23664. }
  23665. if (!deleted && newKeys.length == oldKeys.length) {
  23666. return;
  23667. }
  23668. for (var t = 0; t < newKeys.length; t++) {
  23669. var key = newKeys[t];
  23670. if (!mirror.hasOwnProperty(key)) {
  23671. patches.push({ op: "add", path: path + "/" + escapePathComponent(key), value: deepClone(obj[key]) });
  23672. }
  23673. }
  23674. }
  23675. var _isArray;
  23676. if (Array.isArray) {
  23677. _isArray = Array.isArray;
  23678. } else {
  23679. _isArray = function _isArray(obj) {
  23680. return obj.push && typeof obj.length === 'number';
  23681. };
  23682. }
  23683. //3x faster than cached /^\d+$/.test(str)
  23684. function isInteger(str) {
  23685. var i = 0;
  23686. var len = str.length;
  23687. var charCode;
  23688. while (i < len) {
  23689. charCode = str.charCodeAt(i);
  23690. if (charCode >= 48 && charCode <= 57) {
  23691. i++;
  23692. continue;
  23693. }
  23694. return false;
  23695. }
  23696. return true;
  23697. }
  23698. /// Apply a json-patch operation on an object tree
  23699. function apply(tree, patches, validate) {
  23700. var result = false,
  23701. p = 0,
  23702. plen = patches.length,
  23703. patch,
  23704. key;
  23705. while (p < plen) {
  23706. patch = patches[p];
  23707. p++;
  23708. // Find the object
  23709. var path = patch.path || "";
  23710. var keys = path.split('/');
  23711. var obj = tree;
  23712. var t = 1; //skip empty element - http://jsperf.com/to-shift-or-not-to-shift
  23713. var len = keys.length;
  23714. var existingPathFragment = undefined;
  23715. while (true) {
  23716. key = keys[t];
  23717. if (validate) {
  23718. if (existingPathFragment === undefined) {
  23719. if (obj[key] === undefined) {
  23720. existingPathFragment = keys.slice(0, t).join('/');
  23721. } else if (t == len - 1) {
  23722. existingPathFragment = patch.path;
  23723. }
  23724. if (existingPathFragment !== undefined) {
  23725. this.validator(patch, p - 1, tree, existingPathFragment);
  23726. }
  23727. }
  23728. }
  23729. t++;
  23730. if (key === undefined) {
  23731. if (t >= len) {
  23732. result = rootOps[patch.op].call(patch, obj, key, tree); // Apply patch
  23733. break;
  23734. }
  23735. }
  23736. if (_isArray(obj)) {
  23737. if (key === '-') {
  23738. key = obj.length;
  23739. } else {
  23740. if (validate && !isInteger(key)) {
  23741. 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);
  23742. }
  23743. key = parseInt(key, 10);
  23744. }
  23745. if (t >= len) {
  23746. if (validate && patch.op === "add" && key > obj.length) {
  23747. 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);
  23748. }
  23749. result = arrOps[patch.op].call(patch, obj, key, tree); // Apply patch
  23750. break;
  23751. }
  23752. } else {
  23753. if (key && key.indexOf('~') != -1) key = key.replace(/~1/g, '/').replace(/~0/g, '~'); // escape chars
  23754. if (t >= len) {
  23755. result = objOps[patch.op].call(patch, obj, key, tree); // Apply patch
  23756. break;
  23757. }
  23758. }
  23759. obj = obj[key];
  23760. }
  23761. }
  23762. return result;
  23763. }
  23764. jsonpatch.apply = apply;
  23765. function compare(tree1, tree2) {
  23766. var patches = [];
  23767. _generate(tree1, tree2, patches, '');
  23768. return patches;
  23769. }
  23770. jsonpatch.compare = compare;
  23771. var JsonPatchError = function (_super) {
  23772. __extends(JsonPatchError, _super);
  23773. function JsonPatchError(message, name, index, operation, tree) {
  23774. _super.call(this, message);
  23775. this.message = message;
  23776. this.name = name;
  23777. this.index = index;
  23778. this.operation = operation;
  23779. this.tree = tree;
  23780. }
  23781. return JsonPatchError;
  23782. }(OriginalError);
  23783. jsonpatch.JsonPatchError = JsonPatchError;
  23784. jsonpatch.Error = JsonPatchError;
  23785. /**
  23786. * Recursively checks whether an object has any undefined values inside.
  23787. */
  23788. function hasUndefined(obj) {
  23789. if (obj === undefined) {
  23790. return true;
  23791. }
  23792. if (typeof obj == "array" || (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) == "object") {
  23793. for (var i in obj) {
  23794. if (hasUndefined(obj[i])) {
  23795. return true;
  23796. }
  23797. }
  23798. }
  23799. return false;
  23800. }
  23801. /**
  23802. * Validates a single operation. Called from `jsonpatch.validate`. Throws `JsonPatchError` in case of an error.
  23803. * @param {object} operation - operation object (patch)
  23804. * @param {number} index - index of operation in the sequence
  23805. * @param {object} [tree] - object where the operation is supposed to be applied
  23806. * @param {string} [existingPathFragment] - comes along with `tree`
  23807. */
  23808. function validator(operation, index, tree, existingPathFragment) {
  23809. if ((typeof operation === 'undefined' ? 'undefined' : _typeof(operation)) !== 'object' || operation === null || _isArray(operation)) {
  23810. throw new JsonPatchError('Operation is not an object', 'OPERATION_NOT_AN_OBJECT', index, operation, tree);
  23811. } else if (!objOps[operation.op]) {
  23812. throw new JsonPatchError('Operation `op` property is not one of operations defined in RFC-6902', 'OPERATION_OP_INVALID', index, operation, tree);
  23813. } else if (typeof operation.path !== 'string') {
  23814. throw new JsonPatchError('Operation `path` property is not a string', 'OPERATION_PATH_INVALID', index, operation, tree);
  23815. } else if ((operation.op === 'move' || operation.op === 'copy') && typeof operation.from !== 'string') {
  23816. throw new JsonPatchError('Operation `from` property is not present (applicable in `move` and `copy` operations)', 'OPERATION_FROM_REQUIRED', index, operation, tree);
  23817. } else if ((operation.op === 'add' || operation.op === 'replace' || operation.op === 'test') && operation.value === undefined) {
  23818. throw new JsonPatchError('Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)', 'OPERATION_VALUE_REQUIRED', index, operation, tree);
  23819. } else if ((operation.op === 'add' || operation.op === 'replace' || operation.op === 'test') && hasUndefined(operation.value)) {
  23820. throw new JsonPatchError('Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)', 'OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED', index, operation, tree);
  23821. } else if (tree) {
  23822. if (operation.op == "add") {
  23823. var pathLen = operation.path.split("/").length;
  23824. var existingPathLen = existingPathFragment.split("/").length;
  23825. if (pathLen !== existingPathLen + 1 && pathLen !== existingPathLen) {
  23826. throw new JsonPatchError('Cannot perform an `add` operation at the desired path', 'OPERATION_PATH_CANNOT_ADD', index, operation, tree);
  23827. }
  23828. } else if (operation.op === 'replace' || operation.op === 'remove' || operation.op === '_get') {
  23829. if (operation.path !== existingPathFragment) {
  23830. throw new JsonPatchError('Cannot perform the operation at a path that does not exist', 'OPERATION_PATH_UNRESOLVABLE', index, operation, tree);
  23831. }
  23832. } else if (operation.op === 'move' || operation.op === 'copy') {
  23833. var existingValue = { op: "_get", path: operation.from, value: undefined };
  23834. var error = jsonpatch.validate([existingValue], tree);
  23835. if (error && error.name === 'OPERATION_PATH_UNRESOLVABLE') {
  23836. throw new JsonPatchError('Cannot perform the operation from a path that does not exist', 'OPERATION_FROM_UNRESOLVABLE', index, operation, tree);
  23837. }
  23838. }
  23839. }
  23840. }
  23841. jsonpatch.validator = validator;
  23842. /**
  23843. * Validates a sequence of operations. If `tree` parameter is provided, the sequence is additionally validated against the object tree.
  23844. * If error is encountered, returns a JsonPatchError object
  23845. * @param sequence
  23846. * @param tree
  23847. * @returns {JsonPatchError|undefined}
  23848. */
  23849. function validate(sequence, tree) {
  23850. try {
  23851. if (!_isArray(sequence)) {
  23852. throw new JsonPatchError('Patch sequence must be an array', 'SEQUENCE_NOT_AN_ARRAY');
  23853. }
  23854. if (tree) {
  23855. tree = JSON.parse(JSON.stringify(tree)); //clone tree so that we can safely try applying operations
  23856. apply.call(this, tree, sequence, true);
  23857. } else {
  23858. for (var i = 0; i < sequence.length; i++) {
  23859. this.validator(sequence[i], i);
  23860. }
  23861. }
  23862. } catch (e) {
  23863. if (e instanceof JsonPatchError) {
  23864. return e;
  23865. } else {
  23866. throw e;
  23867. }
  23868. }
  23869. }
  23870. jsonpatch.validate = validate;
  23871. })(jsonpatch || (jsonpatch = {}));
  23872. if (true) {
  23873. exports.apply = jsonpatch.apply;
  23874. exports.observe = jsonpatch.observe;
  23875. exports.unobserve = jsonpatch.unobserve;
  23876. exports.generate = jsonpatch.generate;
  23877. exports.compare = jsonpatch.compare;
  23878. exports.validate = jsonpatch.validate;
  23879. exports.validator = jsonpatch.validator;
  23880. exports.JsonPatchError = jsonpatch.JsonPatchError;
  23881. exports.Error = jsonpatch.Error;
  23882. }
  23883. /***/ }),
  23884. /* 206 */
  23885. /***/ (function(module, exports, __webpack_require__) {
  23886. "use strict";
  23887. exports.__esModule = true;
  23888. __webpack_require__(96);
  23889. __webpack_require__(111);
  23890. __webpack_require__(112);
  23891. __webpack_require__(116);
  23892. __webpack_require__(117);
  23893. __webpack_require__(119);
  23894. __webpack_require__(122);
  23895. __webpack_require__(123);
  23896. __webpack_require__(124);
  23897. __webpack_require__(125);
  23898. __webpack_require__(126);
  23899. __webpack_require__(127);
  23900. __webpack_require__(128);
  23901. __webpack_require__(129);
  23902. __webpack_require__(130);
  23903. __webpack_require__(131);
  23904. __webpack_require__(132);
  23905. __webpack_require__(133);
  23906. __webpack_require__(134);
  23907. __webpack_require__(135);
  23908. __webpack_require__(136);
  23909. __webpack_require__(137);
  23910. __webpack_require__(138);
  23911. __webpack_require__(139);
  23912. __webpack_require__(141);
  23913. __webpack_require__(143);
  23914. __webpack_require__(144);
  23915. __webpack_require__(145);
  23916. __webpack_require__(146);
  23917. __webpack_require__(147);
  23918. __webpack_require__(148);
  23919. __webpack_require__(149);
  23920. __webpack_require__(150);
  23921. __webpack_require__(151);
  23922. __webpack_require__(152);
  23923. __webpack_require__(153);
  23924. __webpack_require__(154);
  23925. __webpack_require__(155);
  23926. __webpack_require__(85);
  23927. __webpack_require__(156);
  23928. __webpack_require__(157);
  23929. __webpack_require__(159);
  23930. __webpack_require__(160);
  23931. __webpack_require__(161);
  23932. __webpack_require__(162);
  23933. __webpack_require__(163);
  23934. __webpack_require__(164);
  23935. __webpack_require__(165);
  23936. __webpack_require__(167);
  23937. __webpack_require__(168);
  23938. __webpack_require__(169);
  23939. __webpack_require__(172);
  23940. __webpack_require__(173);
  23941. __webpack_require__(174);
  23942. __webpack_require__(225);
  23943. __webpack_require__(226);
  23944. __webpack_require__(227);
  23945. var _editors = __webpack_require__(17);
  23946. var _renderers = __webpack_require__(13);
  23947. var _validators = __webpack_require__(28);
  23948. var _cellTypes = __webpack_require__(87);
  23949. var _core = __webpack_require__(88);
  23950. var _core2 = _interopRequireDefault(_core);
  23951. var _jquery = __webpack_require__(282);
  23952. var _jquery2 = _interopRequireDefault(_jquery);
  23953. var _eventManager = __webpack_require__(6);
  23954. var _eventManager2 = _interopRequireDefault(_eventManager);
  23955. var _pluginHooks = __webpack_require__(15);
  23956. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  23957. var _ghostTable = __webpack_require__(92);
  23958. var _ghostTable2 = _interopRequireDefault(_ghostTable);
  23959. var _array = __webpack_require__(1);
  23960. var arrayHelpers = _interopRequireWildcard(_array);
  23961. var _browser = __webpack_require__(27);
  23962. var browserHelpers = _interopRequireWildcard(_browser);
  23963. var _data = __webpack_require__(90);
  23964. var dataHelpers = _interopRequireWildcard(_data);
  23965. var _date = __webpack_require__(190);
  23966. var dateHelpers = _interopRequireWildcard(_date);
  23967. var _feature = __webpack_require__(40);
  23968. var featureHelpers = _interopRequireWildcard(_feature);
  23969. var _function = __webpack_require__(42);
  23970. var functionHelpers = _interopRequireWildcard(_function);
  23971. var _mixed = __webpack_require__(16);
  23972. var mixedHelpers = _interopRequireWildcard(_mixed);
  23973. var _number = __webpack_require__(5);
  23974. var numberHelpers = _interopRequireWildcard(_number);
  23975. var _object = __webpack_require__(2);
  23976. var objectHelpers = _interopRequireWildcard(_object);
  23977. var _setting = __webpack_require__(89);
  23978. var settingHelpers = _interopRequireWildcard(_setting);
  23979. var _string = __webpack_require__(36);
  23980. var stringHelpers = _interopRequireWildcard(_string);
  23981. var _unicode = __webpack_require__(21);
  23982. var unicodeHelpers = _interopRequireWildcard(_unicode);
  23983. var _element = __webpack_require__(0);
  23984. var domHelpers = _interopRequireWildcard(_element);
  23985. var _event = __webpack_require__(12);
  23986. var domEventHelpers = _interopRequireWildcard(_event);
  23987. var _index = __webpack_require__(283);
  23988. var plugins = _interopRequireWildcard(_index);
  23989. var _plugins = __webpack_require__(8);
  23990. var _defaultSettings = __webpack_require__(195);
  23991. var _defaultSettings2 = _interopRequireDefault(_defaultSettings);
  23992. var _rootInstance = __webpack_require__(194);
  23993. var _i18n = __webpack_require__(196);
  23994. var _constants = __webpack_require__(7);
  23995. var constants = _interopRequireWildcard(_constants);
  23996. var _dictionariesManager = __webpack_require__(71);
  23997. 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; } }
  23998. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  23999. function Handsontable(rootElement, userSettings) {
  24000. var instance = new _core2.default(rootElement, userSettings || {}, _rootInstance.rootInstanceSymbol);
  24001. instance.init();
  24002. return instance;
  24003. }
  24004. (0, _jquery2.default)(Handsontable);
  24005. Handsontable.Core = _core2.default;
  24006. Handsontable.DefaultSettings = _defaultSettings2.default;
  24007. Handsontable.EventManager = _eventManager2.default;
  24008. Handsontable._getListenersCounter = _eventManager.getListenersCounter; // For MemoryLeak tests
  24009. Handsontable.buildDate = '10/04/2018 11:38:33';
  24010. Handsontable.packageName = 'handsontable';
  24011. Handsontable.version = '2.0.0';
  24012. var baseVersion = '';
  24013. if (baseVersion) {
  24014. Handsontable.baseVersion = baseVersion;
  24015. }
  24016. // Export Hooks singleton
  24017. Handsontable.hooks = _pluginHooks2.default.getSingleton();
  24018. // TODO: Remove this exports after rewrite tests about this module
  24019. Handsontable.__GhostTable = _ghostTable2.default;
  24020. //
  24021. // Export all helpers to the Handsontable object
  24022. var HELPERS = [arrayHelpers, browserHelpers, dataHelpers, dateHelpers, featureHelpers, functionHelpers, mixedHelpers, numberHelpers, objectHelpers, settingHelpers, stringHelpers, unicodeHelpers];
  24023. var DOM = [domHelpers, domEventHelpers];
  24024. Handsontable.helper = {};
  24025. Handsontable.dom = {};
  24026. // Fill general helpers.
  24027. arrayHelpers.arrayEach(HELPERS, function (helper) {
  24028. arrayHelpers.arrayEach(Object.getOwnPropertyNames(helper), function (key) {
  24029. if (key.charAt(0) !== '_') {
  24030. Handsontable.helper[key] = helper[key];
  24031. }
  24032. });
  24033. });
  24034. // Fill DOM helpers.
  24035. arrayHelpers.arrayEach(DOM, function (helper) {
  24036. arrayHelpers.arrayEach(Object.getOwnPropertyNames(helper), function (key) {
  24037. if (key.charAt(0) !== '_') {
  24038. Handsontable.dom[key] = helper[key];
  24039. }
  24040. });
  24041. });
  24042. // Export cell types.
  24043. Handsontable.cellTypes = {};
  24044. arrayHelpers.arrayEach((0, _cellTypes.getRegisteredCellTypeNames)(), function (cellTypeName) {
  24045. Handsontable.cellTypes[cellTypeName] = (0, _cellTypes.getCellType)(cellTypeName);
  24046. });
  24047. Handsontable.cellTypes.registerCellType = _cellTypes.registerCellType;
  24048. Handsontable.cellTypes.getCellType = _cellTypes.getCellType;
  24049. // Export all registered editors from the Handsontable.
  24050. Handsontable.editors = {};
  24051. arrayHelpers.arrayEach((0, _editors.getRegisteredEditorNames)(), function (editorName) {
  24052. Handsontable.editors[stringHelpers.toUpperCaseFirst(editorName) + 'Editor'] = (0, _editors.getEditor)(editorName);
  24053. });
  24054. Handsontable.editors.registerEditor = _editors.registerEditor;
  24055. Handsontable.editors.getEditor = _editors.getEditor;
  24056. // Export all registered renderers from the Handsontable.
  24057. Handsontable.renderers = {};
  24058. arrayHelpers.arrayEach((0, _renderers.getRegisteredRendererNames)(), function (rendererName) {
  24059. var renderer = (0, _renderers.getRenderer)(rendererName);
  24060. if (rendererName === 'base') {
  24061. Handsontable.renderers.cellDecorator = renderer;
  24062. }
  24063. Handsontable.renderers[stringHelpers.toUpperCaseFirst(rendererName) + 'Renderer'] = renderer;
  24064. });
  24065. Handsontable.renderers.registerRenderer = _renderers.registerRenderer;
  24066. Handsontable.renderers.getRenderer = _renderers.getRenderer;
  24067. // Export all registered validators from the Handsontable.
  24068. Handsontable.validators = {};
  24069. arrayHelpers.arrayEach((0, _validators.getRegisteredValidatorNames)(), function (validatorName) {
  24070. Handsontable.validators[stringHelpers.toUpperCaseFirst(validatorName) + 'Validator'] = (0, _validators.getValidator)(validatorName);
  24071. });
  24072. Handsontable.validators.registerValidator = _validators.registerValidator;
  24073. Handsontable.validators.getValidator = _validators.getValidator;
  24074. // Export all registered plugins from the Handsontable.
  24075. Handsontable.plugins = {};
  24076. arrayHelpers.arrayEach(Object.getOwnPropertyNames(plugins), function (pluginName) {
  24077. var plugin = plugins[pluginName];
  24078. if (pluginName === 'Base') {
  24079. Handsontable.plugins[pluginName + 'Plugin'] = plugin;
  24080. } else {
  24081. Handsontable.plugins[pluginName] = plugin;
  24082. }
  24083. });
  24084. Handsontable.plugins.registerPlugin = _plugins.registerPlugin;
  24085. Handsontable.languages = {};
  24086. Handsontable.languages.dictionaryKeys = constants;
  24087. Handsontable.languages.getLanguageDictionary = _dictionariesManager.getLanguageDictionary;
  24088. Handsontable.languages.getLanguagesDictionaries = _dictionariesManager.getLanguagesDictionaries;
  24089. Handsontable.languages.registerLanguageDictionary = _dictionariesManager.registerLanguageDictionary;
  24090. // Alias to `getTranslatedPhrase` function, for more information check it API.
  24091. Handsontable.languages.getTranslatedPhrase = function () {
  24092. return _i18n.getTranslatedPhrase.apply(undefined, arguments);
  24093. };
  24094. exports.default = Handsontable;
  24095. /***/ }),
  24096. /* 207 */
  24097. /***/ (function(module, exports, __webpack_require__) {
  24098. var dP = __webpack_require__(20);
  24099. var anObject = __webpack_require__(18);
  24100. var getKeys = __webpack_require__(37);
  24101. module.exports = __webpack_require__(22) ? Object.defineProperties : function defineProperties(O, Properties) {
  24102. anObject(O);
  24103. var keys = getKeys(Properties);
  24104. var length = keys.length;
  24105. var i = 0;
  24106. var P;
  24107. while (length > i) dP.f(O, P = keys[i++], Properties[P]);
  24108. return O;
  24109. };
  24110. /***/ }),
  24111. /* 208 */
  24112. /***/ (function(module, exports, __webpack_require__) {
  24113. "use strict";
  24114. var create = __webpack_require__(74);
  24115. var descriptor = __webpack_require__(49);
  24116. var setToStringTag = __webpack_require__(51);
  24117. var IteratorPrototype = {};
  24118. // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
  24119. __webpack_require__(31)(IteratorPrototype, __webpack_require__(11)('iterator'), function () { return this; });
  24120. module.exports = function (Constructor, NAME, next) {
  24121. Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });
  24122. setToStringTag(Constructor, NAME + ' Iterator');
  24123. };
  24124. /***/ }),
  24125. /* 209 */
  24126. /***/ (function(module, exports, __webpack_require__) {
  24127. var isObject = __webpack_require__(9);
  24128. var setPrototypeOf = __webpack_require__(110).set;
  24129. module.exports = function (that, target, C) {
  24130. var S = target.constructor;
  24131. var P;
  24132. if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && setPrototypeOf) {
  24133. setPrototypeOf(that, P);
  24134. } return that;
  24135. };
  24136. /***/ }),
  24137. /* 210 */
  24138. /***/ (function(module, exports, __webpack_require__) {
  24139. // 9.4.2.3 ArraySpeciesCreate(originalArray, length)
  24140. var speciesConstructor = __webpack_require__(211);
  24141. module.exports = function (original, length) {
  24142. return new (speciesConstructor(original))(length);
  24143. };
  24144. /***/ }),
  24145. /* 211 */
  24146. /***/ (function(module, exports, __webpack_require__) {
  24147. var isObject = __webpack_require__(9);
  24148. var isArray = __webpack_require__(113);
  24149. var SPECIES = __webpack_require__(11)('species');
  24150. module.exports = function (original) {
  24151. var C;
  24152. if (isArray(original)) {
  24153. C = original.constructor;
  24154. // cross-realm fallback
  24155. if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
  24156. if (isObject(C)) {
  24157. C = C[SPECIES];
  24158. if (C === null) C = undefined;
  24159. }
  24160. } return C === undefined ? Array : C;
  24161. };
  24162. /***/ }),
  24163. /* 212 */
  24164. /***/ (function(module, exports, __webpack_require__) {
  24165. // 7.3.20 SpeciesConstructor(O, defaultConstructor)
  24166. var anObject = __webpack_require__(18);
  24167. var aFunction = __webpack_require__(62);
  24168. var SPECIES = __webpack_require__(11)('species');
  24169. module.exports = function (O, D) {
  24170. var C = anObject(O).constructor;
  24171. var S;
  24172. return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
  24173. };
  24174. /***/ }),
  24175. /* 213 */
  24176. /***/ (function(module, exports) {
  24177. // fast apply, http://jsperf.lnkit.com/fast-apply/5
  24178. module.exports = function (fn, args, that) {
  24179. var un = that === undefined;
  24180. switch (args.length) {
  24181. case 0: return un ? fn()
  24182. : fn.call(that);
  24183. case 1: return un ? fn(args[0])
  24184. : fn.call(that, args[0]);
  24185. case 2: return un ? fn(args[0], args[1])
  24186. : fn.call(that, args[0], args[1]);
  24187. case 3: return un ? fn(args[0], args[1], args[2])
  24188. : fn.call(that, args[0], args[1], args[2]);
  24189. case 4: return un ? fn(args[0], args[1], args[2], args[3])
  24190. : fn.call(that, args[0], args[1], args[2], args[3]);
  24191. } return fn.apply(that, args);
  24192. };
  24193. /***/ }),
  24194. /* 214 */
  24195. /***/ (function(module, exports, __webpack_require__) {
  24196. var global = __webpack_require__(14);
  24197. var macrotask = __webpack_require__(80).set;
  24198. var Observer = global.MutationObserver || global.WebKitMutationObserver;
  24199. var process = global.process;
  24200. var Promise = global.Promise;
  24201. var isNode = __webpack_require__(43)(process) == 'process';
  24202. module.exports = function () {
  24203. var head, last, notify;
  24204. var flush = function () {
  24205. var parent, fn;
  24206. if (isNode && (parent = process.domain)) parent.exit();
  24207. while (head) {
  24208. fn = head.fn;
  24209. head = head.next;
  24210. try {
  24211. fn();
  24212. } catch (e) {
  24213. if (head) notify();
  24214. else last = undefined;
  24215. throw e;
  24216. }
  24217. } last = undefined;
  24218. if (parent) parent.enter();
  24219. };
  24220. // Node.js
  24221. if (isNode) {
  24222. notify = function () {
  24223. process.nextTick(flush);
  24224. };
  24225. // browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339
  24226. } else if (Observer && !(global.navigator && global.navigator.standalone)) {
  24227. var toggle = true;
  24228. var node = document.createTextNode('');
  24229. new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new
  24230. notify = function () {
  24231. node.data = toggle = !toggle;
  24232. };
  24233. // environments with maybe non-completely correct, but existent Promise
  24234. } else if (Promise && Promise.resolve) {
  24235. var promise = Promise.resolve();
  24236. notify = function () {
  24237. promise.then(flush);
  24238. };
  24239. // for other environments - macrotask based on:
  24240. // - setImmediate
  24241. // - MessageChannel
  24242. // - window.postMessag
  24243. // - onreadystatechange
  24244. // - setTimeout
  24245. } else {
  24246. notify = function () {
  24247. // strange IE + webpack dev server bug - use .call(global)
  24248. macrotask.call(global, flush);
  24249. };
  24250. }
  24251. return function (fn) {
  24252. var task = { fn: fn, next: undefined };
  24253. if (last) last.next = task;
  24254. if (!head) {
  24255. head = task;
  24256. notify();
  24257. } last = task;
  24258. };
  24259. };
  24260. /***/ }),
  24261. /* 215 */
  24262. /***/ (function(module, exports) {
  24263. module.exports = function (exec) {
  24264. try {
  24265. return { e: false, v: exec() };
  24266. } catch (e) {
  24267. return { e: true, v: e };
  24268. }
  24269. };
  24270. /***/ }),
  24271. /* 216 */
  24272. /***/ (function(module, exports, __webpack_require__) {
  24273. var anObject = __webpack_require__(18);
  24274. var isObject = __webpack_require__(9);
  24275. var newPromiseCapability = __webpack_require__(118);
  24276. module.exports = function (C, x) {
  24277. anObject(C);
  24278. if (isObject(x) && x.constructor === C) return x;
  24279. var promiseCapability = newPromiseCapability.f(C);
  24280. var resolve = promiseCapability.resolve;
  24281. resolve(x);
  24282. return promiseCapability.promise;
  24283. };
  24284. /***/ }),
  24285. /* 217 */
  24286. /***/ (function(module, exports, __webpack_require__) {
  24287. var global = __webpack_require__(14);
  24288. var core = __webpack_require__(44);
  24289. var LIBRARY = __webpack_require__(65);
  24290. var wksExt = __webpack_require__(120);
  24291. var defineProperty = __webpack_require__(20).f;
  24292. module.exports = function (name) {
  24293. var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
  24294. if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) });
  24295. };
  24296. /***/ }),
  24297. /* 218 */
  24298. /***/ (function(module, exports, __webpack_require__) {
  24299. // all enumerable object keys, includes symbols
  24300. var getKeys = __webpack_require__(37);
  24301. var gOPS = __webpack_require__(69);
  24302. var pIE = __webpack_require__(52);
  24303. module.exports = function (it) {
  24304. var result = getKeys(it);
  24305. var getSymbols = gOPS.f;
  24306. if (getSymbols) {
  24307. var symbols = getSymbols(it);
  24308. var isEnum = pIE.f;
  24309. var i = 0;
  24310. var key;
  24311. while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key);
  24312. } return result;
  24313. };
  24314. /***/ }),
  24315. /* 219 */
  24316. /***/ (function(module, exports) {
  24317. // 7.2.9 SameValue(x, y)
  24318. module.exports = Object.is || function is(x, y) {
  24319. // eslint-disable-next-line no-self-compare
  24320. return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;
  24321. };
  24322. /***/ }),
  24323. /* 220 */
  24324. /***/ (function(module, exports, __webpack_require__) {
  24325. var toInteger = __webpack_require__(59);
  24326. var defined = __webpack_require__(38);
  24327. // true -> String#at
  24328. // false -> String#codePointAt
  24329. module.exports = function (TO_STRING) {
  24330. return function (that, pos) {
  24331. var s = String(defined(that));
  24332. var i = toInteger(pos);
  24333. var l = s.length;
  24334. var a, b;
  24335. if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
  24336. a = s.charCodeAt(i);
  24337. return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
  24338. ? TO_STRING ? s.charAt(i) : a
  24339. : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
  24340. };
  24341. };
  24342. /***/ }),
  24343. /* 221 */
  24344. /***/ (function(module, exports, __webpack_require__) {
  24345. "use strict";
  24346. // 21.2.5.3 get RegExp.prototype.flags
  24347. var anObject = __webpack_require__(18);
  24348. module.exports = function () {
  24349. var that = anObject(this);
  24350. var result = '';
  24351. if (that.global) result += 'g';
  24352. if (that.ignoreCase) result += 'i';
  24353. if (that.multiline) result += 'm';
  24354. if (that.unicode) result += 'u';
  24355. if (that.sticky) result += 'y';
  24356. return result;
  24357. };
  24358. /***/ }),
  24359. /* 222 */
  24360. /***/ (function(module, exports, __webpack_require__) {
  24361. "use strict";
  24362. // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
  24363. var toObject = __webpack_require__(33);
  24364. var toAbsoluteIndex = __webpack_require__(60);
  24365. var toLength = __webpack_require__(25);
  24366. module.exports = [].copyWithin || function copyWithin(target /* = 0 */, start /* = 0, end = @length */) {
  24367. var O = toObject(this);
  24368. var len = toLength(O.length);
  24369. var to = toAbsoluteIndex(target, len);
  24370. var from = toAbsoluteIndex(start, len);
  24371. var end = arguments.length > 2 ? arguments[2] : undefined;
  24372. var count = Math.min((end === undefined ? len : toAbsoluteIndex(end, len)) - from, len - to);
  24373. var inc = 1;
  24374. if (from < to && to < from + count) {
  24375. inc = -1;
  24376. from += count - 1;
  24377. to += count - 1;
  24378. }
  24379. while (count-- > 0) {
  24380. if (from in O) O[to] = O[from];
  24381. else delete O[to];
  24382. to += inc;
  24383. from += inc;
  24384. } return O;
  24385. };
  24386. /***/ }),
  24387. /* 223 */
  24388. /***/ (function(module, exports, __webpack_require__) {
  24389. "use strict";
  24390. // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
  24391. var toObject = __webpack_require__(33);
  24392. var toAbsoluteIndex = __webpack_require__(60);
  24393. var toLength = __webpack_require__(25);
  24394. module.exports = function fill(value /* , start = 0, end = @length */) {
  24395. var O = toObject(this);
  24396. var length = toLength(O.length);
  24397. var aLen = arguments.length;
  24398. var index = toAbsoluteIndex(aLen > 1 ? arguments[1] : undefined, length);
  24399. var end = aLen > 2 ? arguments[2] : undefined;
  24400. var endPos = end === undefined ? length : toAbsoluteIndex(end, length);
  24401. while (endPos > index) O[index++] = value;
  24402. return O;
  24403. };
  24404. /***/ }),
  24405. /* 224 */
  24406. /***/ (function(module, exports, __webpack_require__) {
  24407. // all object keys, includes non-enumerable and symbols
  24408. var gOPN = __webpack_require__(81);
  24409. var gOPS = __webpack_require__(69);
  24410. var anObject = __webpack_require__(18);
  24411. var Reflect = __webpack_require__(14).Reflect;
  24412. module.exports = Reflect && Reflect.ownKeys || function ownKeys(it) {
  24413. var keys = gOPN.f(anObject(it));
  24414. var getSymbols = gOPS.f;
  24415. return getSymbols ? keys.concat(getSymbols(it)) : keys;
  24416. };
  24417. /***/ }),
  24418. /* 225 */
  24419. /***/ (function(module, exports) {
  24420. // removed by extract-text-webpack-plugin
  24421. /***/ }),
  24422. /* 226 */
  24423. /***/ (function(module, exports) {
  24424. // removed by extract-text-webpack-plugin
  24425. /***/ }),
  24426. /* 227 */
  24427. /***/ (function(module, exports) {
  24428. // removed by extract-text-webpack-plugin
  24429. /***/ }),
  24430. /* 228 */
  24431. /***/ (function(module, exports, __webpack_require__) {
  24432. "use strict";
  24433. exports.__esModule = true;
  24434. var _element = __webpack_require__(0);
  24435. var _base = __webpack_require__(35);
  24436. var _base2 = _interopRequireDefault(_base);
  24437. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  24438. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  24439. 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; }
  24440. 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; }
  24441. /**
  24442. * A overlay that renders ALL available rows & columns positioned on top of the original Walkontable instance and all other overlays.
  24443. * Used for debugging purposes to see if the other overlays (that render only part of the rows & columns) are positioned correctly
  24444. *
  24445. * @class DebugOverlay
  24446. */
  24447. var DebugOverlay = function (_Overlay) {
  24448. _inherits(DebugOverlay, _Overlay);
  24449. /**
  24450. * @param {Walkontable} wotInstance
  24451. */
  24452. function DebugOverlay(wotInstance) {
  24453. _classCallCheck(this, DebugOverlay);
  24454. var _this = _possibleConstructorReturn(this, (DebugOverlay.__proto__ || Object.getPrototypeOf(DebugOverlay)).call(this, wotInstance));
  24455. _this.clone = _this.makeClone(_base2.default.CLONE_DEBUG);
  24456. _this.clone.wtTable.holder.style.opacity = 0.4;
  24457. _this.clone.wtTable.holder.style.textShadow = '0 0 2px #ff0000';
  24458. (0, _element.addClass)(_this.clone.wtTable.holder.parentNode, 'wtDebugVisible');
  24459. return _this;
  24460. }
  24461. return DebugOverlay;
  24462. }(_base2.default);
  24463. _base2.default.registerOverlay(_base2.default.CLONE_DEBUG, DebugOverlay);
  24464. exports.default = DebugOverlay;
  24465. /***/ }),
  24466. /* 229 */
  24467. /***/ (function(module, exports, __webpack_require__) {
  24468. "use strict";
  24469. exports.__esModule = true;
  24470. 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; }; }();
  24471. var _element = __webpack_require__(0);
  24472. var _base = __webpack_require__(35);
  24473. var _base2 = _interopRequireDefault(_base);
  24474. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  24475. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  24476. 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; }
  24477. 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; }
  24478. /**
  24479. * @class LeftOverlay
  24480. */
  24481. var LeftOverlay = function (_Overlay) {
  24482. _inherits(LeftOverlay, _Overlay);
  24483. /**
  24484. * @param {Walkontable} wotInstance
  24485. */
  24486. function LeftOverlay(wotInstance) {
  24487. _classCallCheck(this, LeftOverlay);
  24488. var _this = _possibleConstructorReturn(this, (LeftOverlay.__proto__ || Object.getPrototypeOf(LeftOverlay)).call(this, wotInstance));
  24489. _this.clone = _this.makeClone(_base2.default.CLONE_LEFT);
  24490. return _this;
  24491. }
  24492. /**
  24493. * Checks if overlay should be fully rendered
  24494. *
  24495. * @returns {Boolean}
  24496. */
  24497. _createClass(LeftOverlay, [{
  24498. key: 'shouldBeRendered',
  24499. value: function shouldBeRendered() {
  24500. return !!(this.wot.getSetting('fixedColumnsLeft') || this.wot.getSetting('rowHeaders').length);
  24501. }
  24502. /**
  24503. * Updates the left overlay position
  24504. */
  24505. }, {
  24506. key: 'resetFixedPosition',
  24507. value: function resetFixedPosition() {
  24508. if (!this.needFullRender || !this.wot.wtTable.holder.parentNode) {
  24509. // removed from DOM
  24510. return;
  24511. }
  24512. var overlayRoot = this.clone.wtTable.holder.parentNode;
  24513. var headerPosition = 0;
  24514. var preventOverflow = this.wot.getSetting('preventOverflow');
  24515. if (this.trimmingContainer === window && (!preventOverflow || preventOverflow !== 'horizontal')) {
  24516. var box = this.wot.wtTable.hider.getBoundingClientRect();
  24517. var left = Math.ceil(box.left);
  24518. var right = Math.ceil(box.right);
  24519. var finalLeft = void 0;
  24520. var finalTop = void 0;
  24521. finalTop = this.wot.wtTable.hider.style.top;
  24522. finalTop = finalTop === '' ? 0 : finalTop;
  24523. if (left < 0 && right - overlayRoot.offsetWidth > 0) {
  24524. finalLeft = -left;
  24525. } else {
  24526. finalLeft = 0;
  24527. }
  24528. headerPosition = finalLeft;
  24529. finalLeft += 'px';
  24530. (0, _element.setOverlayPosition)(overlayRoot, finalLeft, finalTop);
  24531. } else {
  24532. headerPosition = this.getScrollPosition();
  24533. (0, _element.resetCssTransform)(overlayRoot);
  24534. }
  24535. this.adjustHeaderBordersPosition(headerPosition);
  24536. this.adjustElementsSize();
  24537. }
  24538. /**
  24539. * Sets the main overlay's horizontal scroll position
  24540. *
  24541. * @param {Number} pos
  24542. */
  24543. }, {
  24544. key: 'setScrollPosition',
  24545. value: function setScrollPosition(pos) {
  24546. if (this.mainTableScrollableElement === window) {
  24547. window.scrollTo(pos, (0, _element.getWindowScrollTop)());
  24548. } else {
  24549. this.mainTableScrollableElement.scrollLeft = pos;
  24550. }
  24551. }
  24552. /**
  24553. * Triggers onScroll hook callback
  24554. */
  24555. }, {
  24556. key: 'onScroll',
  24557. value: function onScroll() {
  24558. this.wot.getSetting('onScrollVertically');
  24559. }
  24560. /**
  24561. * Calculates total sum cells width
  24562. *
  24563. * @param {Number} from Column index which calculates started from
  24564. * @param {Number} to Column index where calculation is finished
  24565. * @returns {Number} Width sum
  24566. */
  24567. }, {
  24568. key: 'sumCellSizes',
  24569. value: function sumCellSizes(from, to) {
  24570. var sum = 0;
  24571. var defaultColumnWidth = this.wot.wtSettings.defaultColumnWidth;
  24572. while (from < to) {
  24573. sum += this.wot.wtTable.getStretchedColumnWidth(from) || defaultColumnWidth;
  24574. from++;
  24575. }
  24576. return sum;
  24577. }
  24578. /**
  24579. * Adjust overlay root element, childs and master table element sizes (width, height).
  24580. *
  24581. * @param {Boolean} [force=false]
  24582. */
  24583. }, {
  24584. key: 'adjustElementsSize',
  24585. value: function adjustElementsSize() {
  24586. var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  24587. this.updateTrimmingContainer();
  24588. if (this.needFullRender || force) {
  24589. this.adjustRootElementSize();
  24590. this.adjustRootChildrenSize();
  24591. if (!force) {
  24592. this.areElementSizesAdjusted = true;
  24593. }
  24594. }
  24595. }
  24596. /**
  24597. * Adjust overlay root element size (width and height).
  24598. */
  24599. }, {
  24600. key: 'adjustRootElementSize',
  24601. value: function adjustRootElementSize() {
  24602. var masterHolder = this.wot.wtTable.holder;
  24603. var scrollbarHeight = masterHolder.clientHeight === masterHolder.offsetHeight ? 0 : (0, _element.getScrollbarWidth)();
  24604. var overlayRoot = this.clone.wtTable.holder.parentNode;
  24605. var overlayRootStyle = overlayRoot.style;
  24606. var preventOverflow = this.wot.getSetting('preventOverflow');
  24607. var tableWidth = void 0;
  24608. if (this.trimmingContainer !== window || preventOverflow === 'vertical') {
  24609. var height = this.wot.wtViewport.getWorkspaceHeight() - scrollbarHeight;
  24610. height = Math.min(height, (0, _element.innerHeight)(this.wot.wtTable.wtRootElement));
  24611. overlayRootStyle.height = height + 'px';
  24612. } else {
  24613. overlayRootStyle.height = '';
  24614. }
  24615. this.clone.wtTable.holder.style.height = overlayRootStyle.height;
  24616. tableWidth = (0, _element.outerWidth)(this.clone.wtTable.TABLE);
  24617. overlayRootStyle.width = (tableWidth === 0 ? tableWidth : tableWidth + 4) + 'px';
  24618. }
  24619. /**
  24620. * Adjust overlay root childs size
  24621. */
  24622. }, {
  24623. key: 'adjustRootChildrenSize',
  24624. value: function adjustRootChildrenSize() {
  24625. var scrollbarWidth = (0, _element.getScrollbarWidth)();
  24626. this.clone.wtTable.hider.style.height = this.hider.style.height;
  24627. this.clone.wtTable.holder.style.height = this.clone.wtTable.holder.parentNode.style.height;
  24628. if (scrollbarWidth === 0) {
  24629. scrollbarWidth = 30;
  24630. }
  24631. this.clone.wtTable.holder.style.width = parseInt(this.clone.wtTable.holder.parentNode.style.width, 10) + scrollbarWidth + 'px';
  24632. }
  24633. /**
  24634. * Adjust the overlay dimensions and position
  24635. */
  24636. }, {
  24637. key: 'applyToDOM',
  24638. value: function applyToDOM() {
  24639. var total = this.wot.getSetting('totalColumns');
  24640. if (!this.areElementSizesAdjusted) {
  24641. this.adjustElementsSize();
  24642. }
  24643. if (typeof this.wot.wtViewport.columnsRenderCalculator.startPosition === 'number') {
  24644. this.spreader.style.left = this.wot.wtViewport.columnsRenderCalculator.startPosition + 'px';
  24645. } else if (total === 0) {
  24646. this.spreader.style.left = '0';
  24647. } else {
  24648. throw new Error('Incorrect value of the columnsRenderCalculator');
  24649. }
  24650. this.spreader.style.right = '';
  24651. if (this.needFullRender) {
  24652. this.syncOverlayOffset();
  24653. }
  24654. }
  24655. /**
  24656. * Synchronize calculated top position to an element
  24657. */
  24658. }, {
  24659. key: 'syncOverlayOffset',
  24660. value: function syncOverlayOffset() {
  24661. if (typeof this.wot.wtViewport.rowsRenderCalculator.startPosition === 'number') {
  24662. this.clone.wtTable.spreader.style.top = this.wot.wtViewport.rowsRenderCalculator.startPosition + 'px';
  24663. } else {
  24664. this.clone.wtTable.spreader.style.top = '';
  24665. }
  24666. }
  24667. /**
  24668. * Scrolls horizontally to a column at the left edge of the viewport
  24669. *
  24670. * @param sourceCol {Number} Column index which you want to scroll to
  24671. * @param [beyondRendered=false] {Boolean} if `true`, scrolls according to the bottom edge (top edge is by default)
  24672. */
  24673. }, {
  24674. key: 'scrollTo',
  24675. value: function scrollTo(sourceCol, beyondRendered) {
  24676. var newX = this.getTableParentOffset();
  24677. var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot;
  24678. var mainHolder = sourceInstance.wtTable.holder;
  24679. var scrollbarCompensation = 0;
  24680. if (beyondRendered && mainHolder.offsetWidth !== mainHolder.clientWidth) {
  24681. scrollbarCompensation = (0, _element.getScrollbarWidth)();
  24682. }
  24683. if (beyondRendered) {
  24684. newX += this.sumCellSizes(0, sourceCol + 1);
  24685. newX -= this.wot.wtViewport.getViewportWidth();
  24686. } else {
  24687. newX += this.sumCellSizes(this.wot.getSetting('fixedColumnsLeft'), sourceCol);
  24688. }
  24689. newX += scrollbarCompensation;
  24690. this.setScrollPosition(newX);
  24691. }
  24692. /**
  24693. * Gets table parent left position
  24694. *
  24695. * @returns {Number}
  24696. */
  24697. }, {
  24698. key: 'getTableParentOffset',
  24699. value: function getTableParentOffset() {
  24700. var preventOverflow = this.wot.getSetting('preventOverflow');
  24701. var offset = 0;
  24702. if (!preventOverflow && this.trimmingContainer === window) {
  24703. offset = this.wot.wtTable.holderOffset.left;
  24704. }
  24705. return offset;
  24706. }
  24707. /**
  24708. * Gets the main overlay's horizontal scroll position
  24709. *
  24710. * @returns {Number} Main table's vertical scroll position
  24711. */
  24712. }, {
  24713. key: 'getScrollPosition',
  24714. value: function getScrollPosition() {
  24715. return (0, _element.getScrollLeft)(this.mainTableScrollableElement);
  24716. }
  24717. /**
  24718. * Adds css classes to hide the header border's header (cell-selection border hiding issue)
  24719. *
  24720. * @param {Number} position Header X position if trimming container is window or scroll top if not
  24721. */
  24722. }, {
  24723. key: 'adjustHeaderBordersPosition',
  24724. value: function adjustHeaderBordersPosition(position) {
  24725. var masterParent = this.wot.wtTable.holder.parentNode;
  24726. var rowHeaders = this.wot.getSetting('rowHeaders');
  24727. var fixedColumnsLeft = this.wot.getSetting('fixedColumnsLeft');
  24728. var totalRows = this.wot.getSetting('totalRows');
  24729. if (totalRows) {
  24730. (0, _element.removeClass)(masterParent, 'emptyRows');
  24731. } else {
  24732. (0, _element.addClass)(masterParent, 'emptyRows');
  24733. }
  24734. if (fixedColumnsLeft && !rowHeaders.length) {
  24735. (0, _element.addClass)(masterParent, 'innerBorderLeft');
  24736. } else if (!fixedColumnsLeft && rowHeaders.length) {
  24737. var previousState = (0, _element.hasClass)(masterParent, 'innerBorderLeft');
  24738. if (position) {
  24739. (0, _element.addClass)(masterParent, 'innerBorderLeft');
  24740. } else {
  24741. (0, _element.removeClass)(masterParent, 'innerBorderLeft');
  24742. }
  24743. if (!previousState && position || previousState && !position) {
  24744. this.wot.wtOverlays.adjustElementsSize();
  24745. }
  24746. }
  24747. }
  24748. }]);
  24749. return LeftOverlay;
  24750. }(_base2.default);
  24751. _base2.default.registerOverlay(_base2.default.CLONE_LEFT, LeftOverlay);
  24752. exports.default = LeftOverlay;
  24753. /***/ }),
  24754. /* 230 */
  24755. /***/ (function(module, exports, __webpack_require__) {
  24756. "use strict";
  24757. exports.__esModule = true;
  24758. 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; }; }();
  24759. var _element = __webpack_require__(0);
  24760. var _array = __webpack_require__(1);
  24761. var _base = __webpack_require__(35);
  24762. var _base2 = _interopRequireDefault(_base);
  24763. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  24764. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  24765. 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; }
  24766. 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; }
  24767. /**
  24768. * @class TopOverlay
  24769. */
  24770. var TopOverlay = function (_Overlay) {
  24771. _inherits(TopOverlay, _Overlay);
  24772. /**
  24773. * @param {Walkontable} wotInstance
  24774. */
  24775. function TopOverlay(wotInstance) {
  24776. _classCallCheck(this, TopOverlay);
  24777. var _this = _possibleConstructorReturn(this, (TopOverlay.__proto__ || Object.getPrototypeOf(TopOverlay)).call(this, wotInstance));
  24778. _this.clone = _this.makeClone(_base2.default.CLONE_TOP);
  24779. return _this;
  24780. }
  24781. /**
  24782. * Checks if overlay should be fully rendered
  24783. *
  24784. * @returns {Boolean}
  24785. */
  24786. _createClass(TopOverlay, [{
  24787. key: 'shouldBeRendered',
  24788. value: function shouldBeRendered() {
  24789. return !!(this.wot.getSetting('fixedRowsTop') || this.wot.getSetting('columnHeaders').length);
  24790. }
  24791. /**
  24792. * Updates the top overlay position
  24793. */
  24794. }, {
  24795. key: 'resetFixedPosition',
  24796. value: function resetFixedPosition() {
  24797. if (!this.needFullRender || !this.wot.wtTable.holder.parentNode) {
  24798. // removed from DOM
  24799. return;
  24800. }
  24801. var overlayRoot = this.clone.wtTable.holder.parentNode;
  24802. var headerPosition = 0;
  24803. var preventOverflow = this.wot.getSetting('preventOverflow');
  24804. if (this.trimmingContainer === window && (!preventOverflow || preventOverflow !== 'vertical')) {
  24805. var box = this.wot.wtTable.hider.getBoundingClientRect();
  24806. var top = Math.ceil(box.top);
  24807. var bottom = Math.ceil(box.bottom);
  24808. var finalLeft = void 0;
  24809. var finalTop = void 0;
  24810. finalLeft = this.wot.wtTable.hider.style.left;
  24811. finalLeft = finalLeft === '' ? 0 : finalLeft;
  24812. if (top < 0 && bottom - overlayRoot.offsetHeight > 0) {
  24813. finalTop = -top;
  24814. } else {
  24815. finalTop = 0;
  24816. }
  24817. headerPosition = finalTop;
  24818. finalTop += 'px';
  24819. (0, _element.setOverlayPosition)(overlayRoot, finalLeft, finalTop);
  24820. } else {
  24821. headerPosition = this.getScrollPosition();
  24822. (0, _element.resetCssTransform)(overlayRoot);
  24823. }
  24824. this.adjustHeaderBordersPosition(headerPosition);
  24825. this.adjustElementsSize();
  24826. }
  24827. /**
  24828. * Sets the main overlay's vertical scroll position
  24829. *
  24830. * @param {Number} pos
  24831. */
  24832. }, {
  24833. key: 'setScrollPosition',
  24834. value: function setScrollPosition(pos) {
  24835. if (this.mainTableScrollableElement === window) {
  24836. window.scrollTo((0, _element.getWindowScrollLeft)(), pos);
  24837. } else {
  24838. this.mainTableScrollableElement.scrollTop = pos;
  24839. }
  24840. }
  24841. /**
  24842. * Triggers onScroll hook callback
  24843. */
  24844. }, {
  24845. key: 'onScroll',
  24846. value: function onScroll() {
  24847. this.wot.getSetting('onScrollHorizontally');
  24848. }
  24849. /**
  24850. * Calculates total sum cells height
  24851. *
  24852. * @param {Number} from Row index which calculates started from
  24853. * @param {Number} to Row index where calculation is finished
  24854. * @returns {Number} Height sum
  24855. */
  24856. }, {
  24857. key: 'sumCellSizes',
  24858. value: function sumCellSizes(from, to) {
  24859. var sum = 0;
  24860. var defaultRowHeight = this.wot.wtSettings.settings.defaultRowHeight;
  24861. while (from < to) {
  24862. var height = this.wot.wtTable.getRowHeight(from);
  24863. sum += height === void 0 ? defaultRowHeight : height;
  24864. from++;
  24865. }
  24866. return sum;
  24867. }
  24868. /**
  24869. * Adjust overlay root element, childs and master table element sizes (width, height).
  24870. *
  24871. * @param {Boolean} [force=false]
  24872. */
  24873. }, {
  24874. key: 'adjustElementsSize',
  24875. value: function adjustElementsSize() {
  24876. var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  24877. this.updateTrimmingContainer();
  24878. if (this.needFullRender || force) {
  24879. this.adjustRootElementSize();
  24880. this.adjustRootChildrenSize();
  24881. if (!force) {
  24882. this.areElementSizesAdjusted = true;
  24883. }
  24884. }
  24885. }
  24886. /**
  24887. * Adjust overlay root element size (width and height).
  24888. */
  24889. }, {
  24890. key: 'adjustRootElementSize',
  24891. value: function adjustRootElementSize() {
  24892. var masterHolder = this.wot.wtTable.holder;
  24893. var scrollbarWidth = masterHolder.clientWidth === masterHolder.offsetWidth ? 0 : (0, _element.getScrollbarWidth)();
  24894. var overlayRoot = this.clone.wtTable.holder.parentNode;
  24895. var overlayRootStyle = overlayRoot.style;
  24896. var preventOverflow = this.wot.getSetting('preventOverflow');
  24897. var tableHeight = void 0;
  24898. if (this.trimmingContainer !== window || preventOverflow === 'horizontal') {
  24899. var width = this.wot.wtViewport.getWorkspaceWidth() - scrollbarWidth;
  24900. width = Math.min(width, (0, _element.innerWidth)(this.wot.wtTable.wtRootElement));
  24901. overlayRootStyle.width = width + 'px';
  24902. } else {
  24903. overlayRootStyle.width = '';
  24904. }
  24905. this.clone.wtTable.holder.style.width = overlayRootStyle.width;
  24906. tableHeight = (0, _element.outerHeight)(this.clone.wtTable.TABLE);
  24907. overlayRootStyle.height = (tableHeight === 0 ? tableHeight : tableHeight + 4) + 'px';
  24908. }
  24909. /**
  24910. * Adjust overlay root childs size
  24911. */
  24912. }, {
  24913. key: 'adjustRootChildrenSize',
  24914. value: function adjustRootChildrenSize() {
  24915. var scrollbarWidth = (0, _element.getScrollbarWidth)();
  24916. this.clone.wtTable.hider.style.width = this.hider.style.width;
  24917. this.clone.wtTable.holder.style.width = this.clone.wtTable.holder.parentNode.style.width;
  24918. if (scrollbarWidth === 0) {
  24919. scrollbarWidth = 30;
  24920. }
  24921. this.clone.wtTable.holder.style.height = parseInt(this.clone.wtTable.holder.parentNode.style.height, 10) + scrollbarWidth + 'px';
  24922. }
  24923. /**
  24924. * Adjust the overlay dimensions and position
  24925. */
  24926. }, {
  24927. key: 'applyToDOM',
  24928. value: function applyToDOM() {
  24929. var total = this.wot.getSetting('totalRows');
  24930. if (!this.areElementSizesAdjusted) {
  24931. this.adjustElementsSize();
  24932. }
  24933. if (typeof this.wot.wtViewport.rowsRenderCalculator.startPosition === 'number') {
  24934. this.spreader.style.top = this.wot.wtViewport.rowsRenderCalculator.startPosition + 'px';
  24935. } else if (total === 0) {
  24936. // can happen if there are 0 rows
  24937. this.spreader.style.top = '0';
  24938. } else {
  24939. throw new Error('Incorrect value of the rowsRenderCalculator');
  24940. }
  24941. this.spreader.style.bottom = '';
  24942. if (this.needFullRender) {
  24943. this.syncOverlayOffset();
  24944. }
  24945. }
  24946. /**
  24947. * Synchronize calculated left position to an element
  24948. */
  24949. }, {
  24950. key: 'syncOverlayOffset',
  24951. value: function syncOverlayOffset() {
  24952. if (typeof this.wot.wtViewport.columnsRenderCalculator.startPosition === 'number') {
  24953. this.clone.wtTable.spreader.style.left = this.wot.wtViewport.columnsRenderCalculator.startPosition + 'px';
  24954. } else {
  24955. this.clone.wtTable.spreader.style.left = '';
  24956. }
  24957. }
  24958. /**
  24959. * Scrolls vertically to a row
  24960. *
  24961. * @param sourceRow {Number} Row index which you want to scroll to
  24962. * @param [bottomEdge=false] {Boolean} if `true`, scrolls according to the bottom edge (top edge is by default)
  24963. */
  24964. }, {
  24965. key: 'scrollTo',
  24966. value: function scrollTo(sourceRow, bottomEdge) {
  24967. var newY = this.getTableParentOffset();
  24968. var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot;
  24969. var mainHolder = sourceInstance.wtTable.holder;
  24970. var scrollbarCompensation = 0;
  24971. if (bottomEdge && mainHolder.offsetHeight !== mainHolder.clientHeight) {
  24972. scrollbarCompensation = (0, _element.getScrollbarWidth)();
  24973. }
  24974. if (bottomEdge) {
  24975. var fixedRowsBottom = this.wot.getSetting('fixedRowsBottom');
  24976. var fixedRowsTop = this.wot.getSetting('fixedRowsTop');
  24977. var totalRows = this.wot.getSetting('totalRows');
  24978. newY += this.sumCellSizes(0, sourceRow + 1);
  24979. newY -= this.wot.wtViewport.getViewportHeight() - this.sumCellSizes(totalRows - fixedRowsBottom, totalRows);
  24980. // Fix 1 pixel offset when cell is selected
  24981. newY += 1;
  24982. } else {
  24983. newY += this.sumCellSizes(this.wot.getSetting('fixedRowsTop'), sourceRow);
  24984. }
  24985. newY += scrollbarCompensation;
  24986. this.setScrollPosition(newY);
  24987. }
  24988. /**
  24989. * Gets table parent top position
  24990. *
  24991. * @returns {Number}
  24992. */
  24993. }, {
  24994. key: 'getTableParentOffset',
  24995. value: function getTableParentOffset() {
  24996. if (this.mainTableScrollableElement === window) {
  24997. return this.wot.wtTable.holderOffset.top;
  24998. }
  24999. return 0;
  25000. }
  25001. /**
  25002. * Gets the main overlay's vertical scroll position
  25003. *
  25004. * @returns {Number} Main table's vertical scroll position
  25005. */
  25006. }, {
  25007. key: 'getScrollPosition',
  25008. value: function getScrollPosition() {
  25009. return (0, _element.getScrollTop)(this.mainTableScrollableElement);
  25010. }
  25011. /**
  25012. * Redraw borders of selection
  25013. *
  25014. * @param {WalkontableSelection} selection Selection for redraw
  25015. */
  25016. }, {
  25017. key: 'redrawSelectionBorders',
  25018. value: function redrawSelectionBorders(selection) {
  25019. if (selection && selection.cellRange) {
  25020. var border = selection.getBorder(this.wot);
  25021. var corners = selection.getCorners();
  25022. border.disappear();
  25023. border.appear(corners);
  25024. }
  25025. }
  25026. /**
  25027. * Redrawing borders of all selections
  25028. */
  25029. }, {
  25030. key: 'redrawAllSelectionsBorders',
  25031. value: function redrawAllSelectionsBorders() {
  25032. var _this2 = this;
  25033. var selections = this.wot.selections;
  25034. this.redrawSelectionBorders(selections.getCell());
  25035. (0, _array.arrayEach)(selections.getAreas(), function (area) {
  25036. _this2.redrawSelectionBorders(area);
  25037. });
  25038. this.redrawSelectionBorders(selections.getFill());
  25039. this.wot.wtTable.wot.wtOverlays.leftOverlay.refresh();
  25040. }
  25041. /**
  25042. * Adds css classes to hide the header border's header (cell-selection border hiding issue)
  25043. *
  25044. * @param {Number} position Header Y position if trimming container is window or scroll top if not
  25045. */
  25046. }, {
  25047. key: 'adjustHeaderBordersPosition',
  25048. value: function adjustHeaderBordersPosition(position) {
  25049. var masterParent = this.wot.wtTable.holder.parentNode;
  25050. var totalColumns = this.wot.getSetting('totalColumns');
  25051. if (totalColumns) {
  25052. (0, _element.removeClass)(masterParent, 'emptyColumns');
  25053. } else {
  25054. (0, _element.addClass)(masterParent, 'emptyColumns');
  25055. }
  25056. if (this.wot.getSetting('fixedRowsTop') === 0 && this.wot.getSetting('columnHeaders').length > 0) {
  25057. var previousState = (0, _element.hasClass)(masterParent, 'innerBorderTop');
  25058. if (position || this.wot.getSetting('totalRows') === 0) {
  25059. (0, _element.addClass)(masterParent, 'innerBorderTop');
  25060. } else {
  25061. (0, _element.removeClass)(masterParent, 'innerBorderTop');
  25062. }
  25063. if (!previousState && position || previousState && !position) {
  25064. this.wot.wtOverlays.adjustElementsSize();
  25065. // cell borders should be positioned once again,
  25066. // because we added / removed 1px border from table header
  25067. this.redrawAllSelectionsBorders();
  25068. }
  25069. }
  25070. // nasty workaround for double border in the header, TODO: find a pure-css solution
  25071. if (this.wot.getSetting('rowHeaders').length === 0) {
  25072. var secondHeaderCell = this.clone.wtTable.THEAD.querySelectorAll('th:nth-of-type(2)');
  25073. if (secondHeaderCell) {
  25074. for (var i = 0; i < secondHeaderCell.length; i++) {
  25075. secondHeaderCell[i].style['border-left-width'] = 0;
  25076. }
  25077. }
  25078. }
  25079. }
  25080. }]);
  25081. return TopOverlay;
  25082. }(_base2.default);
  25083. _base2.default.registerOverlay(_base2.default.CLONE_TOP, TopOverlay);
  25084. exports.default = TopOverlay;
  25085. /***/ }),
  25086. /* 231 */
  25087. /***/ (function(module, exports, __webpack_require__) {
  25088. "use strict";
  25089. exports.__esModule = true;
  25090. 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; }; }();
  25091. var _element = __webpack_require__(0);
  25092. var _base = __webpack_require__(35);
  25093. var _base2 = _interopRequireDefault(_base);
  25094. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  25095. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  25096. 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; }
  25097. 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; }
  25098. /**
  25099. * @class TopLeftCornerOverlay
  25100. */
  25101. var TopLeftCornerOverlay = function (_Overlay) {
  25102. _inherits(TopLeftCornerOverlay, _Overlay);
  25103. /**
  25104. * @param {Walkontable} wotInstance
  25105. */
  25106. function TopLeftCornerOverlay(wotInstance) {
  25107. _classCallCheck(this, TopLeftCornerOverlay);
  25108. var _this = _possibleConstructorReturn(this, (TopLeftCornerOverlay.__proto__ || Object.getPrototypeOf(TopLeftCornerOverlay)).call(this, wotInstance));
  25109. _this.clone = _this.makeClone(_base2.default.CLONE_TOP_LEFT_CORNER);
  25110. return _this;
  25111. }
  25112. /**
  25113. * Checks if overlay should be fully rendered
  25114. *
  25115. * @returns {Boolean}
  25116. */
  25117. _createClass(TopLeftCornerOverlay, [{
  25118. key: 'shouldBeRendered',
  25119. value: function shouldBeRendered() {
  25120. return !!((this.wot.getSetting('fixedRowsTop') || this.wot.getSetting('columnHeaders').length) && (this.wot.getSetting('fixedColumnsLeft') || this.wot.getSetting('rowHeaders').length));
  25121. }
  25122. /**
  25123. * Updates the corner overlay position
  25124. */
  25125. }, {
  25126. key: 'resetFixedPosition',
  25127. value: function resetFixedPosition() {
  25128. this.updateTrimmingContainer();
  25129. if (!this.wot.wtTable.holder.parentNode) {
  25130. // removed from DOM
  25131. return;
  25132. }
  25133. var overlayRoot = this.clone.wtTable.holder.parentNode;
  25134. var tableHeight = (0, _element.outerHeight)(this.clone.wtTable.TABLE);
  25135. var tableWidth = (0, _element.outerWidth)(this.clone.wtTable.TABLE);
  25136. var preventOverflow = this.wot.getSetting('preventOverflow');
  25137. if (this.trimmingContainer === window) {
  25138. var box = this.wot.wtTable.hider.getBoundingClientRect();
  25139. var top = Math.ceil(box.top);
  25140. var left = Math.ceil(box.left);
  25141. var bottom = Math.ceil(box.bottom);
  25142. var right = Math.ceil(box.right);
  25143. var finalLeft = '0';
  25144. var finalTop = '0';
  25145. if (!preventOverflow || preventOverflow === 'vertical') {
  25146. if (left < 0 && right - overlayRoot.offsetWidth > 0) {
  25147. finalLeft = -left + 'px';
  25148. }
  25149. }
  25150. if (!preventOverflow || preventOverflow === 'horizontal') {
  25151. if (top < 0 && bottom - overlayRoot.offsetHeight > 0) {
  25152. finalTop = -top + 'px';
  25153. }
  25154. }
  25155. (0, _element.setOverlayPosition)(overlayRoot, finalLeft, finalTop);
  25156. } else {
  25157. (0, _element.resetCssTransform)(overlayRoot);
  25158. }
  25159. overlayRoot.style.height = (tableHeight === 0 ? tableHeight : tableHeight + 4) + 'px';
  25160. overlayRoot.style.width = (tableWidth === 0 ? tableWidth : tableWidth + 4) + 'px';
  25161. }
  25162. }]);
  25163. return TopLeftCornerOverlay;
  25164. }(_base2.default);
  25165. _base2.default.registerOverlay(_base2.default.CLONE_TOP_LEFT_CORNER, TopLeftCornerOverlay);
  25166. exports.default = TopLeftCornerOverlay;
  25167. /***/ }),
  25168. /* 232 */
  25169. /***/ (function(module, exports, __webpack_require__) {
  25170. "use strict";
  25171. exports.__esModule = true;
  25172. 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"); } }; }();
  25173. 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; };
  25174. 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; }; }();
  25175. var _element = __webpack_require__(0);
  25176. var _border = __webpack_require__(187);
  25177. var _border2 = _interopRequireDefault(_border);
  25178. var _coords = __webpack_require__(54);
  25179. var _coords2 = _interopRequireDefault(_coords);
  25180. var _range = __webpack_require__(86);
  25181. var _range2 = _interopRequireDefault(_range);
  25182. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  25183. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  25184. /**
  25185. * @class Selection
  25186. */
  25187. var Selection = function () {
  25188. /**
  25189. * @param {Object} settings
  25190. * @param {CellRange} cellRange
  25191. */
  25192. function Selection(settings, cellRange) {
  25193. _classCallCheck(this, Selection);
  25194. this.settings = settings;
  25195. this.cellRange = cellRange || null;
  25196. this.instanceBorders = {};
  25197. this.classNames = [this.settings.className];
  25198. this.classNameGenerator = this.linearClassNameGenerator(this.settings.className, this.settings.layerLevel);
  25199. }
  25200. /**
  25201. * Each Walkontable clone requires it's own border for every selection. This method creates and returns selection
  25202. * borders per instance
  25203. *
  25204. * @param {Walkontable} wotInstance
  25205. * @returns {Border}
  25206. */
  25207. _createClass(Selection, [{
  25208. key: 'getBorder',
  25209. value: function getBorder(wotInstance) {
  25210. if (!this.instanceBorders[wotInstance.guid]) {
  25211. this.instanceBorders[wotInstance.guid] = new _border2.default(wotInstance, this.settings);
  25212. }
  25213. return this.instanceBorders[wotInstance.guid];
  25214. }
  25215. /**
  25216. * Checks if selection is empty
  25217. *
  25218. * @returns {Boolean}
  25219. */
  25220. }, {
  25221. key: 'isEmpty',
  25222. value: function isEmpty() {
  25223. return this.cellRange === null;
  25224. }
  25225. /**
  25226. * Adds a cell coords to the selection
  25227. *
  25228. * @param {CellCoords} coords
  25229. */
  25230. }, {
  25231. key: 'add',
  25232. value: function add(coords) {
  25233. if (this.isEmpty()) {
  25234. this.cellRange = new _range2.default(coords);
  25235. } else {
  25236. this.cellRange.expand(coords);
  25237. }
  25238. return this;
  25239. }
  25240. /**
  25241. * If selection range from or to property equals oldCoords, replace it with newCoords. Return boolean
  25242. * information about success
  25243. *
  25244. * @param {CellCoords} oldCoords
  25245. * @param {CellCoords} newCoords
  25246. * @returns {Boolean}
  25247. */
  25248. }, {
  25249. key: 'replace',
  25250. value: function replace(oldCoords, newCoords) {
  25251. if (!this.isEmpty()) {
  25252. if (this.cellRange.from.isEqual(oldCoords)) {
  25253. this.cellRange.from = newCoords;
  25254. return true;
  25255. }
  25256. if (this.cellRange.to.isEqual(oldCoords)) {
  25257. this.cellRange.to = newCoords;
  25258. return true;
  25259. }
  25260. }
  25261. return false;
  25262. }
  25263. /**
  25264. * Clears selection
  25265. *
  25266. * @returns {Selection}
  25267. */
  25268. }, {
  25269. key: 'clear',
  25270. value: function clear() {
  25271. this.cellRange = null;
  25272. return this;
  25273. }
  25274. /**
  25275. * Returns the top left (TL) and bottom right (BR) selection coordinates
  25276. *
  25277. * @returns {Array} Returns array of coordinates for example `[1, 1, 5, 5]`
  25278. */
  25279. }, {
  25280. key: 'getCorners',
  25281. value: function getCorners() {
  25282. var topLeft = this.cellRange.getTopLeftCorner();
  25283. var bottomRight = this.cellRange.getBottomRightCorner();
  25284. return [topLeft.row, topLeft.col, bottomRight.row, bottomRight.col];
  25285. }
  25286. /**
  25287. * Adds class name to cell element at given coords
  25288. *
  25289. * @param {Walkontable} wotInstance Walkontable instance
  25290. * @param {Number} sourceRow Cell row coord
  25291. * @param {Number} sourceColumn Cell column coord
  25292. * @param {String} className Class name
  25293. * @param {Boolean} [markIntersections=false] If `true`, linear className generator will be used to add CSS classes
  25294. * in a continuous way.
  25295. * @returns {Selection}
  25296. */
  25297. }, {
  25298. key: 'addClassAtCoords',
  25299. value: function addClassAtCoords(wotInstance, sourceRow, sourceColumn, className) {
  25300. var markIntersections = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  25301. var TD = wotInstance.wtTable.getCell(new _coords2.default(sourceRow, sourceColumn));
  25302. if ((typeof TD === 'undefined' ? 'undefined' : _typeof(TD)) === 'object') {
  25303. if (markIntersections) {
  25304. className = this.classNameGenerator(TD);
  25305. if (!this.classNames.includes(className)) {
  25306. this.classNames.push(className);
  25307. }
  25308. }
  25309. (0, _element.addClass)(TD, className);
  25310. }
  25311. return this;
  25312. }
  25313. /**
  25314. * Generate helper for calculating classNames based on previously added base className.
  25315. * The generated className is always generated as a continuation of the previous className. For example, when
  25316. * the currently checked element has 'area-2' className the generated new className will be 'area-3'. When
  25317. * the element doesn't have any classNames than the base className will be returned ('area');
  25318. *
  25319. * @param {String} baseClassName Base className to be used.
  25320. * @param {Number} layerLevelOwner Layer level which the instance of the Selection belongs to.
  25321. * @return {Function}
  25322. */
  25323. }, {
  25324. key: 'linearClassNameGenerator',
  25325. value: function linearClassNameGenerator(baseClassName, layerLevelOwner) {
  25326. // TODO: Make this recursive function Proper Tail Calls (TCO/PTC) friendly.
  25327. return function calcClassName(element) {
  25328. var previousIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
  25329. if (layerLevelOwner === 0 || previousIndex === 0) {
  25330. return baseClassName;
  25331. }
  25332. var index = previousIndex >= 0 ? previousIndex : layerLevelOwner;
  25333. var className = baseClassName;
  25334. index -= 1;
  25335. var previousClassName = index === 0 ? baseClassName : baseClassName + '-' + index;
  25336. if ((0, _element.hasClass)(element, previousClassName)) {
  25337. var currentLayer = index + 1;
  25338. className = baseClassName + '-' + currentLayer;
  25339. } else {
  25340. className = calcClassName(element, index);
  25341. }
  25342. return className;
  25343. };
  25344. }
  25345. /**
  25346. * @param wotInstance
  25347. */
  25348. }, {
  25349. key: 'draw',
  25350. value: function draw(wotInstance) {
  25351. if (this.isEmpty()) {
  25352. if (this.settings.border) {
  25353. this.getBorder(wotInstance).disappear();
  25354. }
  25355. return;
  25356. }
  25357. var renderedRows = wotInstance.wtTable.getRenderedRowsCount();
  25358. var renderedColumns = wotInstance.wtTable.getRenderedColumnsCount();
  25359. var corners = this.getCorners();
  25360. var _corners = _slicedToArray(corners, 4),
  25361. topRow = _corners[0],
  25362. topColumn = _corners[1],
  25363. bottomRow = _corners[2],
  25364. bottomColumn = _corners[3];
  25365. for (var column = 0; column < renderedColumns; column += 1) {
  25366. var sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(column);
  25367. if (sourceCol >= topColumn && sourceCol <= bottomColumn) {
  25368. var TH = wotInstance.wtTable.getColumnHeader(sourceCol);
  25369. if (TH) {
  25370. var newClasses = [];
  25371. if (this.settings.highlightHeaderClassName) {
  25372. newClasses.push(this.settings.highlightHeaderClassName);
  25373. }
  25374. if (this.settings.highlightColumnClassName) {
  25375. newClasses.push(this.settings.highlightColumnClassName);
  25376. }
  25377. (0, _element.addClass)(TH, newClasses);
  25378. }
  25379. }
  25380. }
  25381. for (var row = 0; row < renderedRows; row += 1) {
  25382. var sourceRow = wotInstance.wtTable.rowFilter.renderedToSource(row);
  25383. if (sourceRow >= topRow && sourceRow <= bottomRow) {
  25384. var _TH = wotInstance.wtTable.getRowHeader(sourceRow);
  25385. if (_TH) {
  25386. var _newClasses = [];
  25387. if (this.settings.highlightHeaderClassName) {
  25388. _newClasses.push(this.settings.highlightHeaderClassName);
  25389. }
  25390. if (this.settings.highlightRowClassName) {
  25391. _newClasses.push(this.settings.highlightRowClassName);
  25392. }
  25393. (0, _element.addClass)(_TH, _newClasses);
  25394. }
  25395. }
  25396. for (var _column = 0; _column < renderedColumns; _column += 1) {
  25397. var _sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(_column);
  25398. if (sourceRow >= topRow && sourceRow <= bottomRow && _sourceCol >= topColumn && _sourceCol <= bottomColumn) {
  25399. // selected cell
  25400. if (this.settings.className) {
  25401. this.addClassAtCoords(wotInstance, sourceRow, _sourceCol, this.settings.className, this.settings.markIntersections);
  25402. }
  25403. } else if (sourceRow >= topRow && sourceRow <= bottomRow) {
  25404. // selection is in this row
  25405. if (this.settings.highlightRowClassName) {
  25406. this.addClassAtCoords(wotInstance, sourceRow, _sourceCol, this.settings.highlightRowClassName);
  25407. }
  25408. } else if (_sourceCol >= topColumn && _sourceCol <= bottomColumn) {
  25409. // selection is in this column
  25410. if (this.settings.highlightColumnClassName) {
  25411. this.addClassAtCoords(wotInstance, sourceRow, _sourceCol, this.settings.highlightColumnClassName);
  25412. }
  25413. }
  25414. var additionalSelectionClass = wotInstance.getSetting('onAfterDrawSelection', sourceRow, _sourceCol, corners, this.settings.layerLevel);
  25415. if (typeof additionalSelectionClass === 'string') {
  25416. this.addClassAtCoords(wotInstance, sourceRow, _sourceCol, additionalSelectionClass);
  25417. }
  25418. }
  25419. }
  25420. wotInstance.getSetting('onBeforeDrawBorders', corners, this.settings.className);
  25421. if (this.settings.border) {
  25422. // warning! border.appear modifies corners!
  25423. this.getBorder(wotInstance).appear(corners);
  25424. }
  25425. }
  25426. }]);
  25427. return Selection;
  25428. }();
  25429. exports.default = Selection;
  25430. /***/ }),
  25431. /* 233 */
  25432. /***/ (function(module, exports, __webpack_require__) {
  25433. "use strict";
  25434. /**
  25435. * autoResize - resizes a DOM element to the width and height of another DOM element
  25436. *
  25437. * Copyright 2014, Marcin Warpechowski
  25438. * Licensed under the MIT license
  25439. */
  25440. function autoResize() {
  25441. var defaults = {
  25442. minHeight: 200,
  25443. maxHeight: 300,
  25444. minWidth: 100,
  25445. maxWidth: 300
  25446. },
  25447. el,
  25448. body = document.body,
  25449. text = document.createTextNode(''),
  25450. span = document.createElement('SPAN'),
  25451. observe = function observe(element, event, handler) {
  25452. if (element.attachEvent) {
  25453. element.attachEvent('on' + event, handler);
  25454. } else {
  25455. element.addEventListener(event, handler, false);
  25456. }
  25457. },
  25458. _unObserve = function _unObserve(element, event, handler) {
  25459. if (element.removeEventListener) {
  25460. element.removeEventListener(event, handler, false);
  25461. } else {
  25462. element.detachEvent('on' + event, handler);
  25463. }
  25464. },
  25465. resize = function resize(newChar) {
  25466. var width, scrollHeight;
  25467. if (!newChar) {
  25468. newChar = "";
  25469. } else if (!/^[a-zA-Z \.,\\\/\|0-9]$/.test(newChar)) {
  25470. newChar = ".";
  25471. }
  25472. if (text.textContent !== void 0) {
  25473. text.textContent = el.value + newChar;
  25474. } else {
  25475. text.data = el.value + newChar; //IE8
  25476. }
  25477. span.style.fontSize = getComputedStyle(el).fontSize;
  25478. span.style.fontFamily = getComputedStyle(el).fontFamily;
  25479. span.style.whiteSpace = "pre";
  25480. body.appendChild(span);
  25481. width = span.clientWidth + 2;
  25482. body.removeChild(span);
  25483. el.style.height = defaults.minHeight + 'px';
  25484. if (defaults.minWidth > width) {
  25485. el.style.width = defaults.minWidth + 'px';
  25486. } else if (width > defaults.maxWidth) {
  25487. el.style.width = defaults.maxWidth + 'px';
  25488. } else {
  25489. el.style.width = width + 'px';
  25490. }
  25491. scrollHeight = el.scrollHeight ? el.scrollHeight - 1 : 0;
  25492. if (defaults.minHeight > scrollHeight) {
  25493. el.style.height = defaults.minHeight + 'px';
  25494. } else if (defaults.maxHeight < scrollHeight) {
  25495. el.style.height = defaults.maxHeight + 'px';
  25496. el.style.overflowY = 'visible';
  25497. } else {
  25498. el.style.height = scrollHeight + 'px';
  25499. }
  25500. },
  25501. delayedResize = function delayedResize() {
  25502. window.setTimeout(resize, 0);
  25503. },
  25504. extendDefaults = function extendDefaults(config) {
  25505. if (config && config.minHeight) {
  25506. if (config.minHeight == 'inherit') {
  25507. defaults.minHeight = el.clientHeight;
  25508. } else {
  25509. var minHeight = parseInt(config.minHeight);
  25510. if (!isNaN(minHeight)) {
  25511. defaults.minHeight = minHeight;
  25512. }
  25513. }
  25514. }
  25515. if (config && config.maxHeight) {
  25516. if (config.maxHeight == 'inherit') {
  25517. defaults.maxHeight = el.clientHeight;
  25518. } else {
  25519. var maxHeight = parseInt(config.maxHeight);
  25520. if (!isNaN(maxHeight)) {
  25521. defaults.maxHeight = maxHeight;
  25522. }
  25523. }
  25524. }
  25525. if (config && config.minWidth) {
  25526. if (config.minWidth == 'inherit') {
  25527. defaults.minWidth = el.clientWidth;
  25528. } else {
  25529. var minWidth = parseInt(config.minWidth);
  25530. if (!isNaN(minWidth)) {
  25531. defaults.minWidth = minWidth;
  25532. }
  25533. }
  25534. }
  25535. if (config && config.maxWidth) {
  25536. if (config.maxWidth == 'inherit') {
  25537. defaults.maxWidth = el.clientWidth;
  25538. } else {
  25539. var maxWidth = parseInt(config.maxWidth);
  25540. if (!isNaN(maxWidth)) {
  25541. defaults.maxWidth = maxWidth;
  25542. }
  25543. }
  25544. }
  25545. if (!span.firstChild) {
  25546. span.className = "autoResize";
  25547. span.style.display = 'inline-block';
  25548. span.appendChild(text);
  25549. }
  25550. },
  25551. _init = function _init(el_, config, doObserve) {
  25552. el = el_;
  25553. extendDefaults(config);
  25554. if (el.nodeName == 'TEXTAREA') {
  25555. el.style.resize = 'none';
  25556. el.style.overflowY = '';
  25557. el.style.height = defaults.minHeight + 'px';
  25558. el.style.minWidth = defaults.minWidth + 'px';
  25559. el.style.maxWidth = defaults.maxWidth + 'px';
  25560. el.style.overflowY = 'hidden';
  25561. }
  25562. if (doObserve) {
  25563. observe(el, 'change', resize);
  25564. observe(el, 'cut', delayedResize);
  25565. observe(el, 'paste', delayedResize);
  25566. observe(el, 'drop', delayedResize);
  25567. observe(el, 'keydown', delayedResize);
  25568. observe(el, 'focus', resize);
  25569. }
  25570. resize();
  25571. };
  25572. function getComputedStyle(element) {
  25573. return element.currentStyle || document.defaultView.getComputedStyle(element);
  25574. }
  25575. return {
  25576. init: function init(el_, config, doObserve) {
  25577. _init(el_, config, doObserve);
  25578. },
  25579. unObserve: function unObserve() {
  25580. _unObserve(el, 'change', resize);
  25581. _unObserve(el, 'cut', delayedResize);
  25582. _unObserve(el, 'paste', delayedResize);
  25583. _unObserve(el, 'drop', delayedResize);
  25584. _unObserve(el, 'keydown', delayedResize);
  25585. _unObserve(el, 'focus', resize);
  25586. },
  25587. resize: resize
  25588. };
  25589. }
  25590. if (true) {
  25591. module.exports = autoResize;
  25592. }
  25593. /***/ }),
  25594. /* 234 */
  25595. /***/ (function(module, exports, __webpack_require__) {
  25596. "use strict";
  25597. exports.__esModule = true;
  25598. 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; }; }();
  25599. var _baseEditor = __webpack_require__(53);
  25600. var _baseEditor2 = _interopRequireDefault(_baseEditor);
  25601. var _element = __webpack_require__(0);
  25602. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  25603. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  25604. 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; }
  25605. 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; }
  25606. /**
  25607. * @private
  25608. * @editor CheckboxEditor
  25609. * @class CheckboxEditor
  25610. */
  25611. var CheckboxEditor = function (_BaseEditor) {
  25612. _inherits(CheckboxEditor, _BaseEditor);
  25613. function CheckboxEditor() {
  25614. _classCallCheck(this, CheckboxEditor);
  25615. return _possibleConstructorReturn(this, (CheckboxEditor.__proto__ || Object.getPrototypeOf(CheckboxEditor)).apply(this, arguments));
  25616. }
  25617. _createClass(CheckboxEditor, [{
  25618. key: 'beginEditing',
  25619. value: function beginEditing(initialValue, event) {
  25620. // Just some events connected with checkbox editor are delegated here. Some `keydown` events like `enter` and `space` key press
  25621. // are handled inside `checkboxRenderer`. Some events come here from `editorManager`. Below `if` statement was created by author
  25622. // for purpose of handling only `doubleclick` event which may be done on a cell with checkbox.
  25623. if (event.type === 'mouseup') {
  25624. var checkbox = this.TD.querySelector('input[type="checkbox"]');
  25625. if (!(0, _element.hasClass)(checkbox, 'htBadValue')) {
  25626. checkbox.click();
  25627. }
  25628. }
  25629. }
  25630. }, {
  25631. key: 'finishEditing',
  25632. value: function finishEditing() {}
  25633. }, {
  25634. key: 'init',
  25635. value: function init() {}
  25636. }, {
  25637. key: 'open',
  25638. value: function open() {}
  25639. }, {
  25640. key: 'close',
  25641. value: function close() {}
  25642. }, {
  25643. key: 'getValue',
  25644. value: function getValue() {}
  25645. }, {
  25646. key: 'setValue',
  25647. value: function setValue() {}
  25648. }, {
  25649. key: 'focus',
  25650. value: function focus() {}
  25651. }]);
  25652. return CheckboxEditor;
  25653. }(_baseEditor2.default);
  25654. exports.default = CheckboxEditor;
  25655. /***/ }),
  25656. /* 235 */
  25657. /***/ (function(module, exports, __webpack_require__) {
  25658. "use strict";
  25659. exports.__esModule = true;
  25660. 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; }; }();
  25661. 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); } };
  25662. var _moment = __webpack_require__(55);
  25663. var _moment2 = _interopRequireDefault(_moment);
  25664. var _pikaday = __webpack_require__(236);
  25665. var _pikaday2 = _interopRequireDefault(_pikaday);
  25666. __webpack_require__(237);
  25667. var _element = __webpack_require__(0);
  25668. var _object = __webpack_require__(2);
  25669. var _eventManager = __webpack_require__(6);
  25670. var _eventManager2 = _interopRequireDefault(_eventManager);
  25671. var _unicode = __webpack_require__(21);
  25672. var _event = __webpack_require__(12);
  25673. var _textEditor = __webpack_require__(57);
  25674. var _textEditor2 = _interopRequireDefault(_textEditor);
  25675. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  25676. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  25677. 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; }
  25678. 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; }
  25679. /**
  25680. * @private
  25681. * @editor DateEditor
  25682. * @class DateEditor
  25683. * @dependencies TextEditor moment pikaday
  25684. */
  25685. var DateEditor = function (_TextEditor) {
  25686. _inherits(DateEditor, _TextEditor);
  25687. /**
  25688. * @param {Core} hotInstance Handsontable instance
  25689. * @private
  25690. */
  25691. function DateEditor(hotInstance) {
  25692. _classCallCheck(this, DateEditor);
  25693. // TODO: Move this option to general settings
  25694. var _this = _possibleConstructorReturn(this, (DateEditor.__proto__ || Object.getPrototypeOf(DateEditor)).call(this, hotInstance));
  25695. _this.defaultDateFormat = 'DD/MM/YYYY';
  25696. _this.isCellEdited = false;
  25697. _this.parentDestroyed = false;
  25698. return _this;
  25699. }
  25700. _createClass(DateEditor, [{
  25701. key: 'init',
  25702. value: function init() {
  25703. var _this2 = this;
  25704. if (typeof _moment2.default !== 'function') {
  25705. throw new Error('You need to include moment.js to your project.');
  25706. }
  25707. if (typeof _pikaday2.default !== 'function') {
  25708. throw new Error('You need to include Pikaday to your project.');
  25709. }
  25710. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'init', this).call(this);
  25711. this.instance.addHook('afterDestroy', function () {
  25712. _this2.parentDestroyed = true;
  25713. _this2.destroyElements();
  25714. });
  25715. }
  25716. /**
  25717. * Create data picker instance
  25718. */
  25719. }, {
  25720. key: 'createElements',
  25721. value: function createElements() {
  25722. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'createElements', this).call(this);
  25723. this.datePicker = document.createElement('DIV');
  25724. this.datePickerStyle = this.datePicker.style;
  25725. this.datePickerStyle.position = 'absolute';
  25726. this.datePickerStyle.top = 0;
  25727. this.datePickerStyle.left = 0;
  25728. this.datePickerStyle.zIndex = 9999;
  25729. (0, _element.addClass)(this.datePicker, 'htDatepickerHolder');
  25730. document.body.appendChild(this.datePicker);
  25731. this.$datePicker = new _pikaday2.default(this.getDatePickerConfig());
  25732. var eventManager = new _eventManager2.default(this);
  25733. /**
  25734. * Prevent recognizing clicking on datepicker as clicking outside of table
  25735. */
  25736. eventManager.addEventListener(this.datePicker, 'mousedown', function (event) {
  25737. return (0, _event.stopPropagation)(event);
  25738. });
  25739. this.hideDatepicker();
  25740. }
  25741. /**
  25742. * Destroy data picker instance
  25743. */
  25744. }, {
  25745. key: 'destroyElements',
  25746. value: function destroyElements() {
  25747. this.$datePicker.destroy();
  25748. }
  25749. /**
  25750. * Prepare editor to appear
  25751. *
  25752. * @param {Number} row Row index
  25753. * @param {Number} col Column index
  25754. * @param {String} prop Property name (passed when datasource is an array of objects)
  25755. * @param {HTMLTableCellElement} td Table cell element
  25756. * @param {*} originalValue Original value
  25757. * @param {Object} cellProperties Object with cell properties ({@see Core#getCellMeta})
  25758. */
  25759. }, {
  25760. key: 'prepare',
  25761. value: function prepare(row, col, prop, td, originalValue, cellProperties) {
  25762. this._opened = false;
  25763. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'prepare', this).call(this, row, col, prop, td, originalValue, cellProperties);
  25764. }
  25765. /**
  25766. * Open editor
  25767. *
  25768. * @param {Event} [event=null]
  25769. */
  25770. }, {
  25771. key: 'open',
  25772. value: function open() {
  25773. var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  25774. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'open', this).call(this);
  25775. this.showDatepicker(event);
  25776. }
  25777. /**
  25778. * Close editor
  25779. */
  25780. }, {
  25781. key: 'close',
  25782. value: function close() {
  25783. var _this3 = this;
  25784. this._opened = false;
  25785. this.instance._registerTimeout(setTimeout(function () {
  25786. _this3.instance._refreshBorders();
  25787. }, 0));
  25788. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'close', this).call(this);
  25789. }
  25790. /**
  25791. * @param {Boolean} [isCancelled=false]
  25792. * @param {Boolean} [ctrlDown=false]
  25793. */
  25794. }, {
  25795. key: 'finishEditing',
  25796. value: function finishEditing() {
  25797. var isCancelled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  25798. var ctrlDown = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  25799. if (isCancelled) {
  25800. // pressed ESC, restore original value
  25801. // var value = this.instance.getDataAtCell(this.row, this.col);
  25802. var value = this.originalValue;
  25803. if (value !== void 0) {
  25804. this.setValue(value);
  25805. }
  25806. }
  25807. this.hideDatepicker();
  25808. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'finishEditing', this).call(this, isCancelled, ctrlDown);
  25809. }
  25810. /**
  25811. * Show data picker
  25812. *
  25813. * @param {Event} event
  25814. */
  25815. }, {
  25816. key: 'showDatepicker',
  25817. value: function showDatepicker(event) {
  25818. this.$datePicker.config(this.getDatePickerConfig());
  25819. var offset = this.TD.getBoundingClientRect();
  25820. var dateFormat = this.cellProperties.dateFormat || this.defaultDateFormat;
  25821. var datePickerConfig = this.$datePicker.config();
  25822. var dateStr = void 0;
  25823. var isMouseDown = this.instance.view.isMouseDown();
  25824. var isMeta = event ? (0, _unicode.isMetaKey)(event.keyCode) : false;
  25825. this.datePickerStyle.top = window.pageYOffset + offset.top + (0, _element.outerHeight)(this.TD) + 'px';
  25826. this.datePickerStyle.left = window.pageXOffset + offset.left + 'px';
  25827. this.$datePicker._onInputFocus = function () {};
  25828. datePickerConfig.format = dateFormat;
  25829. if (this.originalValue) {
  25830. dateStr = this.originalValue;
  25831. if ((0, _moment2.default)(dateStr, dateFormat, true).isValid()) {
  25832. this.$datePicker.setMoment((0, _moment2.default)(dateStr, dateFormat), true);
  25833. }
  25834. // workaround for date/time cells - pikaday resets the cell value to 12:00 AM by default, this will overwrite the value.
  25835. if (this.getValue() !== this.originalValue) {
  25836. this.setValue(this.originalValue);
  25837. }
  25838. if (!isMeta && !isMouseDown) {
  25839. this.setValue('');
  25840. }
  25841. } else if (this.cellProperties.defaultDate) {
  25842. dateStr = this.cellProperties.defaultDate;
  25843. datePickerConfig.defaultDate = dateStr;
  25844. if ((0, _moment2.default)(dateStr, dateFormat, true).isValid()) {
  25845. this.$datePicker.setMoment((0, _moment2.default)(dateStr, dateFormat), true);
  25846. }
  25847. if (!isMeta && !isMouseDown) {
  25848. this.setValue('');
  25849. }
  25850. } else {
  25851. // if a default date is not defined, set a soft-default-date: display the current day and month in the
  25852. // datepicker, but don't fill the editor input
  25853. this.$datePicker.gotoToday();
  25854. }
  25855. this.datePickerStyle.display = 'block';
  25856. this.$datePicker.show();
  25857. }
  25858. /**
  25859. * Hide data picker
  25860. */
  25861. }, {
  25862. key: 'hideDatepicker',
  25863. value: function hideDatepicker() {
  25864. this.datePickerStyle.display = 'none';
  25865. this.$datePicker.hide();
  25866. }
  25867. /**
  25868. * Get date picker options.
  25869. *
  25870. * @returns {Object}
  25871. */
  25872. }, {
  25873. key: 'getDatePickerConfig',
  25874. value: function getDatePickerConfig() {
  25875. var _this4 = this;
  25876. var htInput = this.TEXTAREA;
  25877. var options = {};
  25878. if (this.cellProperties && this.cellProperties.datePickerConfig) {
  25879. (0, _object.deepExtend)(options, this.cellProperties.datePickerConfig);
  25880. }
  25881. var origOnSelect = options.onSelect;
  25882. var origOnClose = options.onClose;
  25883. options.field = htInput;
  25884. options.trigger = htInput;
  25885. options.container = this.datePicker;
  25886. options.bound = false;
  25887. options.format = options.format || this.defaultDateFormat;
  25888. options.reposition = options.reposition || false;
  25889. options.onSelect = function (dateStr) {
  25890. if (!isNaN(dateStr.getTime())) {
  25891. dateStr = (0, _moment2.default)(dateStr).format(_this4.cellProperties.dateFormat || _this4.defaultDateFormat);
  25892. }
  25893. _this4.setValue(dateStr);
  25894. _this4.hideDatepicker();
  25895. if (origOnSelect) {
  25896. origOnSelect();
  25897. }
  25898. };
  25899. options.onClose = function () {
  25900. if (!_this4.parentDestroyed) {
  25901. _this4.finishEditing(false);
  25902. }
  25903. if (origOnClose) {
  25904. origOnClose();
  25905. }
  25906. };
  25907. return options;
  25908. }
  25909. }]);
  25910. return DateEditor;
  25911. }(_textEditor2.default);
  25912. exports.default = DateEditor;
  25913. /***/ }),
  25914. /* 236 */
  25915. /***/ (function(module, exports) {
  25916. module.exports = __WEBPACK_EXTERNAL_MODULE_236__;
  25917. /***/ }),
  25918. /* 237 */
  25919. /***/ (function(module, exports) {
  25920. /***/ }),
  25921. /* 238 */
  25922. /***/ (function(module, exports, __webpack_require__) {
  25923. "use strict";
  25924. exports.__esModule = true;
  25925. 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; }; }();
  25926. 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); } };
  25927. var _autocompleteEditor = __webpack_require__(188);
  25928. var _autocompleteEditor2 = _interopRequireDefault(_autocompleteEditor);
  25929. var _pluginHooks = __webpack_require__(15);
  25930. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  25931. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  25932. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  25933. 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; }
  25934. 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; }
  25935. /**
  25936. * @private
  25937. * @editor DropdownEditor
  25938. * @class DropdownEditor
  25939. * @dependencies AutocompleteEditor
  25940. */
  25941. var DropdownEditor = function (_AutocompleteEditor) {
  25942. _inherits(DropdownEditor, _AutocompleteEditor);
  25943. function DropdownEditor() {
  25944. _classCallCheck(this, DropdownEditor);
  25945. return _possibleConstructorReturn(this, (DropdownEditor.__proto__ || Object.getPrototypeOf(DropdownEditor)).apply(this, arguments));
  25946. }
  25947. _createClass(DropdownEditor, [{
  25948. key: 'prepare',
  25949. value: function prepare(row, col, prop, td, originalValue, cellProperties) {
  25950. _get(DropdownEditor.prototype.__proto__ || Object.getPrototypeOf(DropdownEditor.prototype), 'prepare', this).call(this, row, col, prop, td, originalValue, cellProperties);
  25951. this.cellProperties.filter = false;
  25952. this.cellProperties.strict = true;
  25953. }
  25954. }]);
  25955. return DropdownEditor;
  25956. }(_autocompleteEditor2.default);
  25957. _pluginHooks2.default.getSingleton().add('beforeValidate', function (value, row, col, source) {
  25958. var cellMeta = this.getCellMeta(row, this.propToCol(col));
  25959. if (cellMeta.editor === DropdownEditor) {
  25960. if (cellMeta.strict === void 0) {
  25961. cellMeta.filter = false;
  25962. cellMeta.strict = true;
  25963. }
  25964. }
  25965. });
  25966. exports.default = DropdownEditor;
  25967. /***/ }),
  25968. /* 239 */
  25969. /***/ (function(module, exports, __webpack_require__) {
  25970. "use strict";
  25971. exports.__esModule = true;
  25972. var _textEditor = __webpack_require__(57);
  25973. var _textEditor2 = _interopRequireDefault(_textEditor);
  25974. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  25975. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  25976. 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; }
  25977. 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; }
  25978. /**
  25979. * @private
  25980. * @editor NumericEditor
  25981. * @class NumericEditor
  25982. */
  25983. var NumericEditor = function (_TextEditor) {
  25984. _inherits(NumericEditor, _TextEditor);
  25985. function NumericEditor() {
  25986. _classCallCheck(this, NumericEditor);
  25987. return _possibleConstructorReturn(this, (NumericEditor.__proto__ || Object.getPrototypeOf(NumericEditor)).apply(this, arguments));
  25988. }
  25989. return NumericEditor;
  25990. }(_textEditor2.default);
  25991. exports.default = NumericEditor;
  25992. /***/ }),
  25993. /* 240 */
  25994. /***/ (function(module, exports, __webpack_require__) {
  25995. "use strict";
  25996. exports.__esModule = true;
  25997. 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; }; }();
  25998. 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); } };
  25999. var _element = __webpack_require__(0);
  26000. var _textEditor = __webpack_require__(57);
  26001. var _textEditor2 = _interopRequireDefault(_textEditor);
  26002. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  26003. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  26004. 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; }
  26005. 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; }
  26006. /**
  26007. * @private
  26008. * @editor PasswordEditor
  26009. * @class PasswordEditor
  26010. * @dependencies TextEditor
  26011. */
  26012. var PasswordEditor = function (_TextEditor) {
  26013. _inherits(PasswordEditor, _TextEditor);
  26014. function PasswordEditor() {
  26015. _classCallCheck(this, PasswordEditor);
  26016. return _possibleConstructorReturn(this, (PasswordEditor.__proto__ || Object.getPrototypeOf(PasswordEditor)).apply(this, arguments));
  26017. }
  26018. _createClass(PasswordEditor, [{
  26019. key: 'createElements',
  26020. value: function createElements() {
  26021. _get(PasswordEditor.prototype.__proto__ || Object.getPrototypeOf(PasswordEditor.prototype), 'createElements', this).call(this);
  26022. this.TEXTAREA = document.createElement('input');
  26023. this.TEXTAREA.setAttribute('type', 'password');
  26024. this.TEXTAREA.className = 'handsontableInput';
  26025. this.textareaStyle = this.TEXTAREA.style;
  26026. this.textareaStyle.width = 0;
  26027. this.textareaStyle.height = 0;
  26028. (0, _element.empty)(this.TEXTAREA_PARENT);
  26029. this.TEXTAREA_PARENT.appendChild(this.TEXTAREA);
  26030. }
  26031. }]);
  26032. return PasswordEditor;
  26033. }(_textEditor2.default);
  26034. exports.default = PasswordEditor;
  26035. /***/ }),
  26036. /* 241 */
  26037. /***/ (function(module, exports, __webpack_require__) {
  26038. "use strict";
  26039. exports.__esModule = true;
  26040. 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; };
  26041. var _element = __webpack_require__(0);
  26042. var _event = __webpack_require__(12);
  26043. var _unicode = __webpack_require__(21);
  26044. var _baseEditor = __webpack_require__(53);
  26045. var _baseEditor2 = _interopRequireDefault(_baseEditor);
  26046. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  26047. var SelectEditor = _baseEditor2.default.prototype.extend();
  26048. /**
  26049. * @private
  26050. * @editor SelectEditor
  26051. * @class SelectEditor
  26052. */
  26053. SelectEditor.prototype.init = function () {
  26054. this.select = document.createElement('SELECT');
  26055. (0, _element.addClass)(this.select, 'htSelectEditor');
  26056. this.select.style.display = 'none';
  26057. this.instance.rootElement.appendChild(this.select);
  26058. this.registerHooks();
  26059. };
  26060. SelectEditor.prototype.registerHooks = function () {
  26061. var _this = this;
  26062. this.instance.addHook('afterScrollHorizontally', function () {
  26063. return _this.refreshDimensions();
  26064. });
  26065. this.instance.addHook('afterScrollVertically', function () {
  26066. return _this.refreshDimensions();
  26067. });
  26068. this.instance.addHook('afterColumnResize', function () {
  26069. return _this.refreshDimensions();
  26070. });
  26071. this.instance.addHook('afterRowResize', function () {
  26072. return _this.refreshDimensions();
  26073. });
  26074. };
  26075. SelectEditor.prototype.prepare = function () {
  26076. _baseEditor2.default.prototype.prepare.apply(this, arguments);
  26077. var selectOptions = this.cellProperties.selectOptions;
  26078. var options;
  26079. if (typeof selectOptions == 'function') {
  26080. options = this.prepareOptions(selectOptions(this.row, this.col, this.prop));
  26081. } else {
  26082. options = this.prepareOptions(selectOptions);
  26083. }
  26084. (0, _element.empty)(this.select);
  26085. for (var option in options) {
  26086. if (Object.prototype.hasOwnProperty.call(options, option)) {
  26087. var optionElement = document.createElement('OPTION');
  26088. optionElement.value = option;
  26089. (0, _element.fastInnerHTML)(optionElement, options[option]);
  26090. this.select.appendChild(optionElement);
  26091. }
  26092. }
  26093. };
  26094. SelectEditor.prototype.prepareOptions = function (optionsToPrepare) {
  26095. var preparedOptions = {};
  26096. if (Array.isArray(optionsToPrepare)) {
  26097. for (var i = 0, len = optionsToPrepare.length; i < len; i++) {
  26098. preparedOptions[optionsToPrepare[i]] = optionsToPrepare[i];
  26099. }
  26100. } else if ((typeof optionsToPrepare === 'undefined' ? 'undefined' : _typeof(optionsToPrepare)) == 'object') {
  26101. preparedOptions = optionsToPrepare;
  26102. }
  26103. return preparedOptions;
  26104. };
  26105. SelectEditor.prototype.getValue = function () {
  26106. return this.select.value;
  26107. };
  26108. SelectEditor.prototype.setValue = function (value) {
  26109. this.select.value = value;
  26110. };
  26111. var onBeforeKeyDown = function onBeforeKeyDown(event) {
  26112. var instance = this;
  26113. var editor = instance.getActiveEditor();
  26114. switch (event.keyCode) {
  26115. case _unicode.KEY_CODES.ARROW_UP:
  26116. var previousOptionIndex = editor.select.selectedIndex - 1;
  26117. if (previousOptionIndex >= 0) {
  26118. editor.select[previousOptionIndex].selected = true;
  26119. }
  26120. (0, _event.stopImmediatePropagation)(event);
  26121. event.preventDefault();
  26122. break;
  26123. case _unicode.KEY_CODES.ARROW_DOWN:
  26124. var nextOptionIndex = editor.select.selectedIndex + 1;
  26125. if (nextOptionIndex <= editor.select.length - 1) {
  26126. editor.select[nextOptionIndex].selected = true;
  26127. }
  26128. (0, _event.stopImmediatePropagation)(event);
  26129. event.preventDefault();
  26130. break;
  26131. default:
  26132. break;
  26133. }
  26134. };
  26135. SelectEditor.prototype.open = function () {
  26136. this._opened = true;
  26137. this.refreshDimensions();
  26138. this.select.style.display = '';
  26139. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  26140. };
  26141. SelectEditor.prototype.close = function () {
  26142. this._opened = false;
  26143. this.select.style.display = 'none';
  26144. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  26145. };
  26146. SelectEditor.prototype.focus = function () {
  26147. this.select.focus();
  26148. };
  26149. SelectEditor.prototype.refreshValue = function () {
  26150. var sourceData = this.instance.getSourceDataAtCell(this.row, this.prop);
  26151. this.originalValue = sourceData;
  26152. this.setValue(sourceData);
  26153. this.refreshDimensions();
  26154. };
  26155. SelectEditor.prototype.refreshDimensions = function () {
  26156. if (this.state !== _baseEditor.EditorState.EDITING) {
  26157. return;
  26158. }
  26159. this.TD = this.getEditedCell();
  26160. // TD is outside of the viewport.
  26161. if (!this.TD) {
  26162. this.close();
  26163. return;
  26164. }
  26165. var width = (0, _element.outerWidth)(this.TD) + 1,
  26166. height = (0, _element.outerHeight)(this.TD) + 1,
  26167. currentOffset = (0, _element.offset)(this.TD),
  26168. containerOffset = (0, _element.offset)(this.instance.rootElement),
  26169. scrollableContainer = (0, _element.getScrollableElement)(this.TD),
  26170. editTop = currentOffset.top - containerOffset.top - 1 - (scrollableContainer.scrollTop || 0),
  26171. editLeft = currentOffset.left - containerOffset.left - 1 - (scrollableContainer.scrollLeft || 0),
  26172. editorSection = this.checkEditorSection(),
  26173. cssTransformOffset;
  26174. var settings = this.instance.getSettings();
  26175. var rowHeadersCount = settings.rowHeaders ? 1 : 0;
  26176. var colHeadersCount = settings.colHeaders ? 1 : 0;
  26177. switch (editorSection) {
  26178. case 'top':
  26179. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.holder.parentNode);
  26180. break;
  26181. case 'left':
  26182. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.holder.parentNode);
  26183. break;
  26184. case 'top-left-corner':
  26185. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.holder.parentNode);
  26186. break;
  26187. case 'bottom-left-corner':
  26188. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.holder.parentNode);
  26189. break;
  26190. case 'bottom':
  26191. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.bottomOverlay.clone.wtTable.holder.parentNode);
  26192. break;
  26193. default:
  26194. break;
  26195. }
  26196. if (this.instance.getSelectedLast()[0] === 0) {
  26197. editTop += 1;
  26198. }
  26199. if (this.instance.getSelectedLast()[1] === 0) {
  26200. editLeft += 1;
  26201. }
  26202. var selectStyle = this.select.style;
  26203. if (cssTransformOffset && cssTransformOffset != -1) {
  26204. selectStyle[cssTransformOffset[0]] = cssTransformOffset[1];
  26205. } else {
  26206. (0, _element.resetCssTransform)(this.select);
  26207. }
  26208. var cellComputedStyle = (0, _element.getComputedStyle)(this.TD);
  26209. if (parseInt(cellComputedStyle.borderTopWidth, 10) > 0) {
  26210. height -= 1;
  26211. }
  26212. if (parseInt(cellComputedStyle.borderLeftWidth, 10) > 0) {
  26213. width -= 1;
  26214. }
  26215. selectStyle.height = height + 'px';
  26216. selectStyle.minWidth = width + 'px';
  26217. selectStyle.top = editTop + 'px';
  26218. selectStyle.left = editLeft + 'px';
  26219. selectStyle.margin = '0px';
  26220. };
  26221. SelectEditor.prototype.getEditedCell = function () {
  26222. var editorSection = this.checkEditorSection(),
  26223. editedCell;
  26224. switch (editorSection) {
  26225. case 'top':
  26226. editedCell = this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.getCell({
  26227. row: this.row,
  26228. col: this.col
  26229. });
  26230. this.select.style.zIndex = 101;
  26231. break;
  26232. case 'corner':
  26233. editedCell = this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.getCell({
  26234. row: this.row,
  26235. col: this.col
  26236. });
  26237. this.select.style.zIndex = 103;
  26238. break;
  26239. case 'left':
  26240. editedCell = this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.getCell({
  26241. row: this.row,
  26242. col: this.col
  26243. });
  26244. this.select.style.zIndex = 102;
  26245. break;
  26246. default:
  26247. editedCell = this.instance.getCell(this.row, this.col);
  26248. this.select.style.zIndex = '';
  26249. break;
  26250. }
  26251. return editedCell != -1 && editedCell != -2 ? editedCell : void 0;
  26252. };
  26253. exports.default = SelectEditor;
  26254. /***/ }),
  26255. /* 242 */
  26256. /***/ (function(module, exports, __webpack_require__) {
  26257. "use strict";
  26258. exports.__esModule = true;
  26259. var _element = __webpack_require__(0);
  26260. function cellDecorator(instance, TD, row, col, prop, value, cellProperties) {
  26261. var classesToAdd = [];
  26262. var classesToRemove = [];
  26263. if (cellProperties.className) {
  26264. if (TD.className) {
  26265. TD.className = TD.className + ' ' + cellProperties.className;
  26266. } else {
  26267. TD.className = cellProperties.className;
  26268. }
  26269. }
  26270. if (cellProperties.readOnly) {
  26271. classesToAdd.push(cellProperties.readOnlyCellClassName);
  26272. }
  26273. if (cellProperties.valid === false && cellProperties.invalidCellClassName) {
  26274. classesToAdd.push(cellProperties.invalidCellClassName);
  26275. } else {
  26276. classesToRemove.push(cellProperties.invalidCellClassName);
  26277. }
  26278. if (cellProperties.wordWrap === false && cellProperties.noWordWrapClassName) {
  26279. classesToAdd.push(cellProperties.noWordWrapClassName);
  26280. }
  26281. if (!value && cellProperties.placeholder) {
  26282. classesToAdd.push(cellProperties.placeholderCellClassName);
  26283. }
  26284. (0, _element.removeClass)(TD, classesToRemove);
  26285. (0, _element.addClass)(TD, classesToAdd);
  26286. } /**
  26287. * Adds appropriate CSS class to table cell, based on cellProperties
  26288. */
  26289. exports.default = cellDecorator;
  26290. /***/ }),
  26291. /* 243 */
  26292. /***/ (function(module, exports, __webpack_require__) {
  26293. "use strict";
  26294. exports.__esModule = true;
  26295. var _element = __webpack_require__(0);
  26296. var _eventManager = __webpack_require__(6);
  26297. var _eventManager2 = _interopRequireDefault(_eventManager);
  26298. var _src = __webpack_require__(4);
  26299. var _index = __webpack_require__(13);
  26300. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  26301. var clonableWRAPPER = document.createElement('DIV');
  26302. clonableWRAPPER.className = 'htAutocompleteWrapper';
  26303. var clonableARROW = document.createElement('DIV');
  26304. clonableARROW.className = 'htAutocompleteArrow';
  26305. // workaround for https://github.com/handsontable/handsontable/issues/1946
  26306. // this is faster than innerHTML. See: https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips
  26307. clonableARROW.appendChild(document.createTextNode(String.fromCharCode(9660)));
  26308. var wrapTdContentWithWrapper = function wrapTdContentWithWrapper(TD, WRAPPER) {
  26309. WRAPPER.innerHTML = TD.innerHTML;
  26310. (0, _element.empty)(TD);
  26311. TD.appendChild(WRAPPER);
  26312. };
  26313. /**
  26314. * Autocomplete renderer
  26315. *
  26316. * @private
  26317. * @renderer AutocompleteRenderer
  26318. * @param {Object} instance Handsontable instance
  26319. * @param {Element} TD Table cell where to render
  26320. * @param {Number} row
  26321. * @param {Number} col
  26322. * @param {String|Number} prop Row object property name
  26323. * @param value Value to render (remember to escape unsafe HTML before inserting to DOM!)
  26324. * @param {Object} cellProperties Cell properites (shared by cell renderer and editor)
  26325. */
  26326. function autocompleteRenderer(instance, TD, row, col, prop, value, cellProperties) {
  26327. var WRAPPER = clonableWRAPPER.cloneNode(true); // this is faster than createElement
  26328. var ARROW = clonableARROW.cloneNode(true); // this is faster than createElement
  26329. if (cellProperties.allowHtml) {
  26330. (0, _index.getRenderer)('html').apply(this, arguments);
  26331. } else {
  26332. (0, _index.getRenderer)('text').apply(this, arguments);
  26333. }
  26334. TD.appendChild(ARROW);
  26335. (0, _element.addClass)(TD, 'htAutocomplete');
  26336. if (!TD.firstChild) {
  26337. // http://jsperf.com/empty-node-if-needed
  26338. // otherwise empty fields appear borderless in demo/renderers.html (IE)
  26339. TD.appendChild(document.createTextNode(String.fromCharCode(160))); // workaround for https://github.com/handsontable/handsontable/issues/1946
  26340. // this is faster than innerHTML. See: https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips
  26341. }
  26342. if (!instance.acArrowListener) {
  26343. var eventManager = new _eventManager2.default(instance);
  26344. // not very elegant but easy and fast
  26345. instance.acArrowListener = function (event) {
  26346. if ((0, _element.hasClass)(event.target, 'htAutocompleteArrow')) {
  26347. instance.view.wt.getSetting('onCellDblClick', null, new _src.CellCoords(row, col), TD);
  26348. }
  26349. };
  26350. eventManager.addEventListener(instance.rootElement, 'mousedown', instance.acArrowListener);
  26351. // We need to unbind the listener after the table has been destroyed
  26352. instance.addHookOnce('afterDestroy', function () {
  26353. eventManager.destroy();
  26354. });
  26355. }
  26356. }
  26357. exports.default = autocompleteRenderer;
  26358. /***/ }),
  26359. /* 244 */
  26360. /***/ (function(module, exports, __webpack_require__) {
  26361. "use strict";
  26362. exports.__esModule = true;
  26363. var _element = __webpack_require__(0);
  26364. var _string = __webpack_require__(36);
  26365. var _eventManager = __webpack_require__(6);
  26366. var _eventManager2 = _interopRequireDefault(_eventManager);
  26367. var _unicode = __webpack_require__(21);
  26368. var _function = __webpack_require__(42);
  26369. var _event = __webpack_require__(12);
  26370. var _index = __webpack_require__(13);
  26371. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  26372. var isListeningKeyDownEvent = new WeakMap();
  26373. var isCheckboxListenerAdded = new WeakMap();
  26374. var BAD_VALUE_CLASS = 'htBadValue';
  26375. /**
  26376. * Checkbox renderer
  26377. *
  26378. * @private
  26379. * @param {Object} instance Handsontable instance
  26380. * @param {Element} TD Table cell where to render
  26381. * @param {Number} row
  26382. * @param {Number} col
  26383. * @param {String|Number} prop Row object property name
  26384. * @param value Value to render (remember to escape unsafe HTML before inserting to DOM!)
  26385. * @param {Object} cellProperties Cell properties (shared by cell renderer and editor)
  26386. */
  26387. function checkboxRenderer(instance, TD, row, col, prop, value, cellProperties) {
  26388. (0, _index.getRenderer)('base').apply(this, arguments);
  26389. var eventManager = registerEvents(instance);
  26390. var input = createInput();
  26391. var labelOptions = cellProperties.label;
  26392. var badValue = false;
  26393. if (typeof cellProperties.checkedTemplate === 'undefined') {
  26394. cellProperties.checkedTemplate = true;
  26395. }
  26396. if (typeof cellProperties.uncheckedTemplate === 'undefined') {
  26397. cellProperties.uncheckedTemplate = false;
  26398. }
  26399. (0, _element.empty)(TD); // TODO identify under what circumstances this line can be removed
  26400. if (value === cellProperties.checkedTemplate || (0, _string.equalsIgnoreCase)(value, cellProperties.checkedTemplate)) {
  26401. input.checked = true;
  26402. } else if (value === cellProperties.uncheckedTemplate || (0, _string.equalsIgnoreCase)(value, cellProperties.uncheckedTemplate)) {
  26403. input.checked = false;
  26404. } else if (value === null) {
  26405. // default value
  26406. (0, _element.addClass)(input, 'noValue');
  26407. } else {
  26408. input.style.display = 'none';
  26409. (0, _element.addClass)(input, BAD_VALUE_CLASS);
  26410. badValue = true;
  26411. }
  26412. input.setAttribute('data-row', row);
  26413. input.setAttribute('data-col', col);
  26414. if (!badValue && labelOptions) {
  26415. var labelText = '';
  26416. if (labelOptions.value) {
  26417. labelText = typeof labelOptions.value === 'function' ? labelOptions.value.call(this, row, col, prop, value) : labelOptions.value;
  26418. } else if (labelOptions.property) {
  26419. labelText = instance.getDataAtRowProp(row, labelOptions.property);
  26420. }
  26421. var label = createLabel(labelText);
  26422. if (labelOptions.position === 'before') {
  26423. label.appendChild(input);
  26424. } else {
  26425. label.insertBefore(input, label.firstChild);
  26426. }
  26427. input = label;
  26428. }
  26429. TD.appendChild(input);
  26430. if (badValue) {
  26431. TD.appendChild(document.createTextNode('#bad-value#'));
  26432. }
  26433. if (!isListeningKeyDownEvent.has(instance)) {
  26434. isListeningKeyDownEvent.set(instance, true);
  26435. instance.addHook('beforeKeyDown', onBeforeKeyDown);
  26436. }
  26437. /**
  26438. * On before key down DOM listener.
  26439. *
  26440. * @private
  26441. * @param {Event} event
  26442. */
  26443. function onBeforeKeyDown(event) {
  26444. var toggleKeys = 'SPACE|ENTER';
  26445. var switchOffKeys = 'DELETE|BACKSPACE';
  26446. var isKeyCode = (0, _function.partial)(_unicode.isKey, event.keyCode);
  26447. if (isKeyCode(toggleKeys + '|' + switchOffKeys) && !(0, _event.isImmediatePropagationStopped)(event)) {
  26448. eachSelectedCheckboxCell(function () {
  26449. (0, _event.stopImmediatePropagation)(event);
  26450. event.preventDefault();
  26451. });
  26452. }
  26453. if (isKeyCode(toggleKeys)) {
  26454. changeSelectedCheckboxesState();
  26455. }
  26456. if (isKeyCode(switchOffKeys)) {
  26457. changeSelectedCheckboxesState(true);
  26458. }
  26459. }
  26460. /**
  26461. * Change checkbox checked property
  26462. *
  26463. * @private
  26464. * @param {Boolean} [uncheckCheckbox=false]
  26465. */
  26466. function changeSelectedCheckboxesState() {
  26467. var uncheckCheckbox = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  26468. var selRange = instance.getSelectedRangeLast();
  26469. if (!selRange) {
  26470. return;
  26471. }
  26472. var _selRange$getTopLeftC = selRange.getTopLeftCorner(),
  26473. startRow = _selRange$getTopLeftC.row,
  26474. startColumn = _selRange$getTopLeftC.col;
  26475. var _selRange$getBottomRi = selRange.getBottomRightCorner(),
  26476. endRow = _selRange$getBottomRi.row,
  26477. endColumn = _selRange$getBottomRi.col;
  26478. var changes = [];
  26479. for (var _row = startRow; _row <= endRow; _row += 1) {
  26480. for (var _col = startColumn; _col <= endColumn; _col += 1) {
  26481. var _cellProperties = instance.getCellMeta(_row, _col);
  26482. if (_cellProperties.type !== 'checkbox') {
  26483. return;
  26484. }
  26485. /* eslint-disable no-continue */
  26486. if (_cellProperties.readOnly === true) {
  26487. continue;
  26488. }
  26489. if (typeof _cellProperties.checkedTemplate === 'undefined') {
  26490. _cellProperties.checkedTemplate = true;
  26491. }
  26492. if (typeof _cellProperties.uncheckedTemplate === 'undefined') {
  26493. _cellProperties.uncheckedTemplate = false;
  26494. }
  26495. var dataAtCell = instance.getDataAtCell(_row, _col);
  26496. if (uncheckCheckbox === false) {
  26497. if ([_cellProperties.checkedTemplate, _cellProperties.checkedTemplate.toString()].includes(dataAtCell)) {
  26498. changes.push([_row, _col, _cellProperties.uncheckedTemplate]);
  26499. } else if ([_cellProperties.uncheckedTemplate, _cellProperties.uncheckedTemplate.toString(), null, void 0].includes(dataAtCell)) {
  26500. changes.push([_row, _col, _cellProperties.checkedTemplate]);
  26501. }
  26502. } else {
  26503. changes.push([_row, _col, _cellProperties.uncheckedTemplate]);
  26504. }
  26505. }
  26506. }
  26507. if (changes.length > 0) {
  26508. instance.setDataAtCell(changes);
  26509. }
  26510. }
  26511. /**
  26512. * Call callback for each found selected cell with checkbox type.
  26513. *
  26514. * @private
  26515. * @param {Function} callback
  26516. */
  26517. function eachSelectedCheckboxCell(callback) {
  26518. var selRange = instance.getSelectedRangeLast();
  26519. if (!selRange) {
  26520. return;
  26521. }
  26522. var topLeft = selRange.getTopLeftCorner();
  26523. var bottomRight = selRange.getBottomRightCorner();
  26524. for (var _row2 = topLeft.row; _row2 <= bottomRight.row; _row2++) {
  26525. for (var _col2 = topLeft.col; _col2 <= bottomRight.col; _col2++) {
  26526. var _cellProperties2 = instance.getCellMeta(_row2, _col2);
  26527. if (_cellProperties2.type !== 'checkbox') {
  26528. return;
  26529. }
  26530. var cell = instance.getCell(_row2, _col2);
  26531. if (cell == null) {
  26532. callback(_row2, _col2, _cellProperties2);
  26533. } else {
  26534. var checkboxes = cell.querySelectorAll('input[type=checkbox]');
  26535. if (checkboxes.length > 0 && !_cellProperties2.readOnly) {
  26536. callback(checkboxes);
  26537. }
  26538. }
  26539. }
  26540. }
  26541. }
  26542. }
  26543. /**
  26544. * Register checkbox listeners.
  26545. *
  26546. * @param {Handsontable} instance Handsontable instance.
  26547. * @returns {EventManager}
  26548. */
  26549. function registerEvents(instance) {
  26550. var eventManager = isCheckboxListenerAdded.get(instance);
  26551. if (!eventManager) {
  26552. eventManager = new _eventManager2.default(instance);
  26553. eventManager.addEventListener(instance.rootElement, 'click', function (event) {
  26554. return onClick(event, instance);
  26555. });
  26556. eventManager.addEventListener(instance.rootElement, 'mouseup', function (event) {
  26557. return onMouseUp(event, instance);
  26558. });
  26559. eventManager.addEventListener(instance.rootElement, 'change', function (event) {
  26560. return onChange(event, instance);
  26561. });
  26562. isCheckboxListenerAdded.set(instance, eventManager);
  26563. }
  26564. return eventManager;
  26565. }
  26566. /**
  26567. * Create input element.
  26568. *
  26569. * @returns {Node}
  26570. */
  26571. function createInput() {
  26572. var input = document.createElement('input');
  26573. input.className = 'htCheckboxRendererInput';
  26574. input.type = 'checkbox';
  26575. input.setAttribute('autocomplete', 'off');
  26576. input.setAttribute('tabindex', '-1');
  26577. return input.cloneNode(false);
  26578. }
  26579. /**
  26580. * Create label element.
  26581. *
  26582. * @returns {Node}
  26583. */
  26584. function createLabel(text) {
  26585. var label = document.createElement('label');
  26586. label.className = 'htCheckboxRendererLabel';
  26587. label.appendChild(document.createTextNode(text));
  26588. return label.cloneNode(true);
  26589. }
  26590. /**
  26591. * `mouseup` callback.
  26592. *
  26593. * @private
  26594. * @param {Event} event `mouseup` event.
  26595. * @param {Object} instance Handsontable instance.
  26596. */
  26597. function onMouseUp(event, instance) {
  26598. if (!isCheckboxInput(event.target)) {
  26599. return;
  26600. }
  26601. setTimeout(instance.listen, 10);
  26602. }
  26603. /**
  26604. * `click` callback.
  26605. *
  26606. * @private
  26607. * @param {Event} event `click` event.
  26608. * @param {Object} instance Handsontable instance.
  26609. */
  26610. function onClick(event, instance) {
  26611. if (!isCheckboxInput(event.target)) {
  26612. return false;
  26613. }
  26614. var row = parseInt(event.target.getAttribute('data-row'), 10);
  26615. var col = parseInt(event.target.getAttribute('data-col'), 10);
  26616. var cellProperties = instance.getCellMeta(row, col);
  26617. if (cellProperties.readOnly) {
  26618. event.preventDefault();
  26619. }
  26620. }
  26621. /**
  26622. * `change` callback.
  26623. *
  26624. * @param {Event} event `change` event.
  26625. * @param {Object} instance Handsontable instance.
  26626. * @param {Object} cellProperties Reference to cell properties.
  26627. * @returns {Boolean}
  26628. */
  26629. function onChange(event, instance) {
  26630. if (!isCheckboxInput(event.target)) {
  26631. return false;
  26632. }
  26633. var row = parseInt(event.target.getAttribute('data-row'), 10);
  26634. var col = parseInt(event.target.getAttribute('data-col'), 10);
  26635. var cellProperties = instance.getCellMeta(row, col);
  26636. if (!cellProperties.readOnly) {
  26637. var newCheckboxValue = null;
  26638. if (event.target.checked) {
  26639. newCheckboxValue = cellProperties.uncheckedTemplate === void 0 ? true : cellProperties.checkedTemplate;
  26640. } else {
  26641. newCheckboxValue = cellProperties.uncheckedTemplate === void 0 ? false : cellProperties.uncheckedTemplate;
  26642. }
  26643. instance.setDataAtCell(row, col, newCheckboxValue);
  26644. }
  26645. }
  26646. /**
  26647. * Check if the provided element is the checkbox input.
  26648. *
  26649. * @private
  26650. * @param {HTMLElement} element The element in question.
  26651. * @returns {Boolean}
  26652. */
  26653. function isCheckboxInput(element) {
  26654. return element.tagName === 'INPUT' && element.getAttribute('type') === 'checkbox';
  26655. }
  26656. exports.default = checkboxRenderer;
  26657. /***/ }),
  26658. /* 245 */
  26659. /***/ (function(module, exports, __webpack_require__) {
  26660. "use strict";
  26661. exports.__esModule = true;
  26662. var _element = __webpack_require__(0);
  26663. var _index = __webpack_require__(13);
  26664. /**
  26665. * @private
  26666. * @renderer HtmlRenderer
  26667. * @param instance
  26668. * @param TD
  26669. * @param row
  26670. * @param col
  26671. * @param prop
  26672. * @param value
  26673. * @param cellProperties
  26674. */
  26675. function htmlRenderer(instance, TD, row, col, prop, value, cellProperties) {
  26676. (0, _index.getRenderer)('base').apply(this, arguments);
  26677. if (value === null || value === void 0) {
  26678. value = '';
  26679. }
  26680. (0, _element.fastInnerHTML)(TD, value);
  26681. }
  26682. exports.default = htmlRenderer;
  26683. /***/ }),
  26684. /* 246 */
  26685. /***/ (function(module, exports, __webpack_require__) {
  26686. "use strict";
  26687. exports.__esModule = true;
  26688. var _numbro = __webpack_require__(247);
  26689. var _numbro2 = _interopRequireDefault(_numbro);
  26690. var _index = __webpack_require__(13);
  26691. var _number = __webpack_require__(5);
  26692. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  26693. /**
  26694. * Numeric cell renderer
  26695. *
  26696. * @private
  26697. * @renderer NumericRenderer
  26698. * @dependencies numbro
  26699. * @param {Object} instance Handsontable instance
  26700. * @param {Element} TD Table cell where to render
  26701. * @param {Number} row
  26702. * @param {Number} col
  26703. * @param {String|Number} prop Row object property name
  26704. * @param value Value to render (remember to escape unsafe HTML before inserting to DOM!)
  26705. * @param {Object} cellProperties Cell properties (shared by cell renderer and editor)
  26706. */
  26707. function numericRenderer(instance, TD, row, col, prop, value, cellProperties) {
  26708. if ((0, _number.isNumeric)(value)) {
  26709. var numericFormat = cellProperties.numericFormat;
  26710. var cellCulture = numericFormat && numericFormat.culture;
  26711. var cellFormatPattern = numericFormat && numericFormat.pattern;
  26712. var className = cellProperties.className || '';
  26713. var classArr = className.length ? className.split(' ') : [];
  26714. if (typeof cellCulture !== 'undefined') {
  26715. _numbro2.default.culture(cellCulture);
  26716. }
  26717. value = (0, _numbro2.default)(value).format(cellFormatPattern || '0');
  26718. if (classArr.indexOf('htLeft') < 0 && classArr.indexOf('htCenter') < 0 && classArr.indexOf('htRight') < 0 && classArr.indexOf('htJustify') < 0) {
  26719. classArr.push('htRight');
  26720. }
  26721. if (classArr.indexOf('htNumeric') < 0) {
  26722. classArr.push('htNumeric');
  26723. }
  26724. cellProperties.className = classArr.join(' ');
  26725. }
  26726. (0, _index.getRenderer)('text')(instance, TD, row, col, prop, value, cellProperties);
  26727. }
  26728. exports.default = numericRenderer;
  26729. /***/ }),
  26730. /* 247 */
  26731. /***/ (function(module, exports) {
  26732. module.exports = __WEBPACK_EXTERNAL_MODULE_247__;
  26733. /***/ }),
  26734. /* 248 */
  26735. /***/ (function(module, exports, __webpack_require__) {
  26736. "use strict";
  26737. exports.__esModule = true;
  26738. var _element = __webpack_require__(0);
  26739. var _index = __webpack_require__(13);
  26740. var _number = __webpack_require__(5);
  26741. /**
  26742. * @private
  26743. * @renderer PasswordRenderer
  26744. * @param instance
  26745. * @param TD
  26746. * @param row
  26747. * @param col
  26748. * @param prop
  26749. * @param value
  26750. * @param cellProperties
  26751. */
  26752. function passwordRenderer(instance, TD, row, col, prop, value, cellProperties) {
  26753. (0, _index.getRenderer)('text').apply(this, arguments);
  26754. value = TD.innerHTML;
  26755. var hashLength = cellProperties.hashLength || value.length;
  26756. var hashSymbol = cellProperties.hashSymbol || '*';
  26757. var hash = '';
  26758. (0, _number.rangeEach)(hashLength - 1, function () {
  26759. hash += hashSymbol;
  26760. });
  26761. (0, _element.fastInnerHTML)(TD, hash);
  26762. }
  26763. exports.default = passwordRenderer;
  26764. /***/ }),
  26765. /* 249 */
  26766. /***/ (function(module, exports, __webpack_require__) {
  26767. "use strict";
  26768. exports.__esModule = true;
  26769. var _element = __webpack_require__(0);
  26770. var _mixed = __webpack_require__(16);
  26771. var _index = __webpack_require__(13);
  26772. /**
  26773. * Default text renderer
  26774. *
  26775. * @private
  26776. * @renderer TextRenderer
  26777. * @param {Object} instance Handsontable instance
  26778. * @param {Element} TD Table cell where to render
  26779. * @param {Number} row
  26780. * @param {Number} col
  26781. * @param {String|Number} prop Row object property name
  26782. * @param value Value to render (remember to escape unsafe HTML before inserting to DOM!)
  26783. * @param {Object} cellProperties Cell properties (shared by cell renderer and editor)
  26784. */
  26785. function textRenderer(instance, TD, row, col, prop, value, cellProperties) {
  26786. (0, _index.getRenderer)('base').apply(this, arguments);
  26787. if (!value && cellProperties.placeholder) {
  26788. value = cellProperties.placeholder;
  26789. }
  26790. var escaped = (0, _mixed.stringify)(value);
  26791. if (!instance.getSettings().trimWhitespace) {
  26792. escaped = escaped.replace(/ /g, String.fromCharCode(160));
  26793. }
  26794. if (cellProperties.rendererTemplate) {
  26795. (0, _element.empty)(TD);
  26796. var TEMPLATE = document.createElement('TEMPLATE');
  26797. TEMPLATE.setAttribute('bind', '{{}}');
  26798. TEMPLATE.innerHTML = cellProperties.rendererTemplate;
  26799. HTMLTemplateElement.decorate(TEMPLATE);
  26800. TEMPLATE.model = instance.getSourceDataAtRow(row);
  26801. TD.appendChild(TEMPLATE);
  26802. } else {
  26803. // this is faster than innerHTML. See: https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips
  26804. (0, _element.fastInnerText)(TD, escaped);
  26805. }
  26806. }
  26807. exports.default = textRenderer;
  26808. /***/ }),
  26809. /* 250 */
  26810. /***/ (function(module, exports, __webpack_require__) {
  26811. "use strict";
  26812. exports.__esModule = true;
  26813. exports.default = autocompleteValidator;
  26814. /**
  26815. * Autocomplete cell validator.
  26816. *
  26817. * @private
  26818. * @validator AutocompleteValidator
  26819. * @param {*} value - Value of edited cell
  26820. * @param {Function} callback - Callback called with validation result
  26821. */
  26822. function autocompleteValidator(value, callback) {
  26823. if (value == null) {
  26824. value = '';
  26825. }
  26826. if (this.allowEmpty && value === '') {
  26827. callback(true);
  26828. return;
  26829. }
  26830. if (this.strict && this.source) {
  26831. if (typeof this.source === 'function') {
  26832. this.source(value, process(value, callback));
  26833. } else {
  26834. process(value, callback)(this.source);
  26835. }
  26836. } else {
  26837. callback(true);
  26838. }
  26839. };
  26840. /**
  26841. * Function responsible for validation of autocomplete value.
  26842. *
  26843. * @param {*} value - Value of edited cell
  26844. * @param {Function} callback - Callback called with validation result
  26845. */
  26846. function process(value, callback) {
  26847. var originalVal = value;
  26848. return function (source) {
  26849. var found = false;
  26850. for (var s = 0, slen = source.length; s < slen; s++) {
  26851. if (originalVal === source[s]) {
  26852. found = true; // perfect match
  26853. break;
  26854. }
  26855. }
  26856. callback(found);
  26857. };
  26858. }
  26859. /***/ }),
  26860. /* 251 */
  26861. /***/ (function(module, exports, __webpack_require__) {
  26862. "use strict";
  26863. exports.__esModule = true;
  26864. exports.default = dateValidator;
  26865. exports.correctFormat = correctFormat;
  26866. var _moment = __webpack_require__(55);
  26867. var _moment2 = _interopRequireDefault(_moment);
  26868. var _date = __webpack_require__(190);
  26869. var _editors = __webpack_require__(17);
  26870. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  26871. /**
  26872. * Date cell validator
  26873. *
  26874. * @private
  26875. * @validator DateValidator
  26876. * @dependencies moment
  26877. * @param {*} value - Value of edited cell
  26878. * @param {Function} callback - Callback called with validation result
  26879. */
  26880. function dateValidator(value, callback) {
  26881. var valid = true;
  26882. var dateEditor = (0, _editors.getEditorInstance)('date', this.instance);
  26883. if (value == null) {
  26884. value = '';
  26885. }
  26886. var isValidDate = (0, _moment2.default)(new Date(value)).isValid() || (0, _moment2.default)(value, dateEditor.defaultDateFormat).isValid();
  26887. // is it in the specified format
  26888. var isValidFormat = (0, _moment2.default)(value, this.dateFormat || dateEditor.defaultDateFormat, true).isValid();
  26889. if (this.allowEmpty && value === '') {
  26890. isValidDate = true;
  26891. isValidFormat = true;
  26892. }
  26893. if (!isValidDate) {
  26894. valid = false;
  26895. }
  26896. if (!isValidDate && isValidFormat) {
  26897. valid = true;
  26898. }
  26899. if (isValidDate && !isValidFormat) {
  26900. if (this.correctFormat === true) {
  26901. // if format correction is enabled
  26902. var correctedValue = correctFormat(value, this.dateFormat);
  26903. var row = this.instance.runHooks('unmodifyRow', this.row);
  26904. var column = this.instance.runHooks('unmodifyCol', this.col);
  26905. this.instance.setDataAtCell(row, column, correctedValue, 'dateValidator');
  26906. valid = true;
  26907. } else {
  26908. valid = false;
  26909. }
  26910. }
  26911. callback(valid);
  26912. };
  26913. /**
  26914. * Format the given string using moment.js' format feature
  26915. *
  26916. * @param {String} value
  26917. * @param {String} dateFormat
  26918. * @returns {String}
  26919. */
  26920. function correctFormat(value, dateFormat) {
  26921. var dateFromDate = (0, _moment2.default)((0, _date.getNormalizedDate)(value));
  26922. var dateFromMoment = (0, _moment2.default)(value, dateFormat);
  26923. var isAlphanumeric = value.search(/[A-z]/g) > -1;
  26924. var date = void 0;
  26925. if (dateFromDate.isValid() && dateFromDate.format('x') === dateFromMoment.format('x') || !dateFromMoment.isValid() || isAlphanumeric) {
  26926. date = dateFromDate;
  26927. } else {
  26928. date = dateFromMoment;
  26929. }
  26930. return date.format(dateFormat);
  26931. };
  26932. /***/ }),
  26933. /* 252 */
  26934. /***/ (function(module, exports, __webpack_require__) {
  26935. "use strict";
  26936. exports.__esModule = true;
  26937. exports.default = numericValidator;
  26938. /**
  26939. * Numeric cell validator
  26940. *
  26941. * @private
  26942. * @validator NumericValidator
  26943. * @param {*} value - Value of edited cell
  26944. * @param {*} callback - Callback called with validation result
  26945. */
  26946. function numericValidator(value, callback) {
  26947. if (value == null) {
  26948. value = '';
  26949. }
  26950. if (this.allowEmpty && value === '') {
  26951. callback(true);
  26952. } else if (value === '') {
  26953. callback(false);
  26954. } else {
  26955. callback(/^-?\d*(\.|,)?\d*$/.test(value));
  26956. }
  26957. };
  26958. /***/ }),
  26959. /* 253 */
  26960. /***/ (function(module, exports, __webpack_require__) {
  26961. "use strict";
  26962. exports.__esModule = true;
  26963. exports.default = timeValidator;
  26964. var _moment = __webpack_require__(55);
  26965. var _moment2 = _interopRequireDefault(_moment);
  26966. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  26967. // Formats which are correctly parsed to time (supported by momentjs)
  26968. var STRICT_FORMATS = ['YYYY-MM-DDTHH:mm:ss.SSSZ', 'X', // Unix timestamp
  26969. 'x' // Unix ms timestamp
  26970. ];
  26971. /**
  26972. * Time cell validator
  26973. *
  26974. * @private
  26975. * @validator TimeValidator
  26976. * @dependencies moment
  26977. * @param {*} value - Value of edited cell
  26978. * @param {Function} callback - Callback called with validation result
  26979. */
  26980. function timeValidator(value, callback) {
  26981. var valid = true;
  26982. var timeFormat = this.timeFormat || 'h:mm:ss a';
  26983. if (value === null) {
  26984. value = '';
  26985. }
  26986. value = /^\d{3,}$/.test(value) ? parseInt(value, 10) : value;
  26987. var twoDigitValue = /^\d{1,2}$/.test(value);
  26988. if (twoDigitValue) {
  26989. value += ':00';
  26990. }
  26991. var date = (0, _moment2.default)(value, STRICT_FORMATS, true).isValid() ? (0, _moment2.default)(value) : (0, _moment2.default)(value, timeFormat);
  26992. var isValidTime = date.isValid();
  26993. // is it in the specified format
  26994. var isValidFormat = (0, _moment2.default)(value, timeFormat, true).isValid() && !twoDigitValue;
  26995. if (this.allowEmpty && value === '') {
  26996. isValidTime = true;
  26997. isValidFormat = true;
  26998. }
  26999. if (!isValidTime) {
  27000. valid = false;
  27001. }
  27002. if (!isValidTime && isValidFormat) {
  27003. valid = true;
  27004. }
  27005. if (isValidTime && !isValidFormat) {
  27006. if (this.correctFormat === true) {
  27007. // if format correction is enabled
  27008. var correctedValue = date.format(timeFormat);
  27009. var row = this.instance.runHooks('unmodifyRow', this.row);
  27010. var column = this.instance.runHooks('unmodifyCol', this.col);
  27011. this.instance.setDataAtCell(row, column, correctedValue, 'timeValidator');
  27012. valid = true;
  27013. } else {
  27014. valid = false;
  27015. }
  27016. }
  27017. callback(valid);
  27018. };
  27019. /***/ }),
  27020. /* 254 */
  27021. /***/ (function(module, exports, __webpack_require__) {
  27022. "use strict";
  27023. exports.__esModule = true;
  27024. var _editors = __webpack_require__(17);
  27025. var _renderers = __webpack_require__(13);
  27026. var _validators = __webpack_require__(28);
  27027. var CELL_TYPE = 'autocomplete';
  27028. exports.default = {
  27029. editor: (0, _editors.getEditor)(CELL_TYPE),
  27030. renderer: (0, _renderers.getRenderer)(CELL_TYPE),
  27031. validator: (0, _validators.getValidator)(CELL_TYPE)
  27032. };
  27033. /***/ }),
  27034. /* 255 */
  27035. /***/ (function(module, exports, __webpack_require__) {
  27036. "use strict";
  27037. exports.__esModule = true;
  27038. var _editors = __webpack_require__(17);
  27039. var _renderers = __webpack_require__(13);
  27040. var CELL_TYPE = 'checkbox';
  27041. exports.default = {
  27042. editor: (0, _editors.getEditor)(CELL_TYPE),
  27043. renderer: (0, _renderers.getRenderer)(CELL_TYPE)
  27044. };
  27045. /***/ }),
  27046. /* 256 */
  27047. /***/ (function(module, exports, __webpack_require__) {
  27048. "use strict";
  27049. exports.__esModule = true;
  27050. var _editors = __webpack_require__(17);
  27051. var _renderers = __webpack_require__(13);
  27052. var _validators = __webpack_require__(28);
  27053. var CELL_TYPE = 'date';
  27054. exports.default = {
  27055. editor: (0, _editors.getEditor)(CELL_TYPE),
  27056. // displays small gray arrow on right side of the cell
  27057. renderer: (0, _renderers.getRenderer)('autocomplete'),
  27058. validator: (0, _validators.getValidator)(CELL_TYPE)
  27059. };
  27060. /***/ }),
  27061. /* 257 */
  27062. /***/ (function(module, exports, __webpack_require__) {
  27063. "use strict";
  27064. exports.__esModule = true;
  27065. var _editors = __webpack_require__(17);
  27066. var _renderers = __webpack_require__(13);
  27067. var _validators = __webpack_require__(28);
  27068. var CELL_TYPE = 'dropdown';
  27069. exports.default = {
  27070. editor: (0, _editors.getEditor)(CELL_TYPE),
  27071. // displays small gray arrow on right side of the cell
  27072. renderer: (0, _renderers.getRenderer)('autocomplete'),
  27073. validator: (0, _validators.getValidator)('autocomplete')
  27074. };
  27075. /***/ }),
  27076. /* 258 */
  27077. /***/ (function(module, exports, __webpack_require__) {
  27078. "use strict";
  27079. exports.__esModule = true;
  27080. var _editors = __webpack_require__(17);
  27081. var _renderers = __webpack_require__(13);
  27082. var CELL_TYPE = 'handsontable';
  27083. exports.default = {
  27084. editor: (0, _editors.getEditor)(CELL_TYPE),
  27085. // displays small gray arrow on right side of the cell
  27086. renderer: (0, _renderers.getRenderer)('autocomplete')
  27087. };
  27088. /***/ }),
  27089. /* 259 */
  27090. /***/ (function(module, exports, __webpack_require__) {
  27091. "use strict";
  27092. exports.__esModule = true;
  27093. var _editors = __webpack_require__(17);
  27094. var _renderers = __webpack_require__(13);
  27095. var _validators = __webpack_require__(28);
  27096. var CELL_TYPE = 'numeric';
  27097. exports.default = {
  27098. editor: (0, _editors.getEditor)(CELL_TYPE),
  27099. renderer: (0, _renderers.getRenderer)(CELL_TYPE),
  27100. validator: (0, _validators.getValidator)(CELL_TYPE),
  27101. dataType: 'number'
  27102. };
  27103. /***/ }),
  27104. /* 260 */
  27105. /***/ (function(module, exports, __webpack_require__) {
  27106. "use strict";
  27107. exports.__esModule = true;
  27108. var _editors = __webpack_require__(17);
  27109. var _renderers = __webpack_require__(13);
  27110. var _validators = __webpack_require__(28);
  27111. var CELL_TYPE = 'password';
  27112. exports.default = {
  27113. editor: (0, _editors.getEditor)(CELL_TYPE),
  27114. renderer: (0, _renderers.getRenderer)(CELL_TYPE),
  27115. copyable: false
  27116. };
  27117. /***/ }),
  27118. /* 261 */
  27119. /***/ (function(module, exports, __webpack_require__) {
  27120. "use strict";
  27121. exports.__esModule = true;
  27122. var _browser = __webpack_require__(27);
  27123. var _editors = __webpack_require__(17);
  27124. var _renderers = __webpack_require__(13);
  27125. var CELL_TYPE = 'text';
  27126. exports.default = {
  27127. editor: (0, _editors.getEditor)(CELL_TYPE),
  27128. renderer: (0, _renderers.getRenderer)(CELL_TYPE)
  27129. };
  27130. /***/ }),
  27131. /* 262 */
  27132. /***/ (function(module, exports, __webpack_require__) {
  27133. "use strict";
  27134. exports.__esModule = true;
  27135. var _editors = __webpack_require__(17);
  27136. var _renderers = __webpack_require__(13);
  27137. var _validators = __webpack_require__(28);
  27138. var CELL_TYPE = 'time';
  27139. exports.default = {
  27140. editor: (0, _editors.getEditor)('text'),
  27141. // displays small gray arrow on right side of the cell
  27142. renderer: (0, _renderers.getRenderer)('text'),
  27143. validator: (0, _validators.getValidator)(CELL_TYPE)
  27144. };
  27145. /***/ }),
  27146. /* 263 */
  27147. /***/ (function(module, exports, __webpack_require__) {
  27148. "use strict";
  27149. exports.__esModule = true;
  27150. 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; };
  27151. var _SheetClip = __webpack_require__(191);
  27152. var _SheetClip2 = _interopRequireDefault(_SheetClip);
  27153. var _data = __webpack_require__(90);
  27154. var _setting = __webpack_require__(89);
  27155. var _object = __webpack_require__(2);
  27156. var _array = __webpack_require__(1);
  27157. var _interval = __webpack_require__(264);
  27158. var _interval2 = _interopRequireDefault(_interval);
  27159. var _number = __webpack_require__(5);
  27160. var _multiMap = __webpack_require__(265);
  27161. var _multiMap2 = _interopRequireDefault(_multiMap);
  27162. var _pluginHooks = __webpack_require__(15);
  27163. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  27164. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  27165. /**
  27166. * Utility class that gets and saves data from/to the data source using mapping of columns numbers to object property names
  27167. * @todo refactor arguments of methods getRange, getText to be numbers (not objects)
  27168. * @todo remove priv, GridSettings from object constructor
  27169. *
  27170. * @param {Object} instance Instance of Handsontable
  27171. * @param {*} priv
  27172. * @param {*} GridSettings Grid settings
  27173. * @util
  27174. * @class DataMap
  27175. */
  27176. function DataMap(instance, priv, GridSettings) {
  27177. var _this = this;
  27178. this.instance = instance;
  27179. this.priv = priv;
  27180. this.GridSettings = GridSettings;
  27181. this.dataSource = this.instance.getSettings().data;
  27182. this.cachedLength = null;
  27183. this.skipCache = false;
  27184. this.latestSourceRowsCount = 0;
  27185. if (this.dataSource && this.dataSource[0]) {
  27186. this.duckSchema = this.recursiveDuckSchema(this.dataSource[0]);
  27187. } else {
  27188. this.duckSchema = {};
  27189. }
  27190. this.createMap();
  27191. this.interval = _interval2.default.create(function () {
  27192. return _this.clearLengthCache();
  27193. }, '15fps');
  27194. this.instance.addHook('skipLengthCache', function (delay) {
  27195. return _this.onSkipLengthCache(delay);
  27196. });
  27197. this.onSkipLengthCache(500);
  27198. }
  27199. DataMap.prototype.DESTINATION_RENDERER = 1;
  27200. DataMap.prototype.DESTINATION_CLIPBOARD_GENERATOR = 2;
  27201. /**
  27202. * @param {Object|Array} object
  27203. * @returns {Object|Array}
  27204. */
  27205. DataMap.prototype.recursiveDuckSchema = function (object) {
  27206. return (0, _object.duckSchema)(object);
  27207. };
  27208. /**
  27209. * @param {Object} schema
  27210. * @param {Number} lastCol
  27211. * @param {Number} parent
  27212. * @returns {Number}
  27213. */
  27214. DataMap.prototype.recursiveDuckColumns = function (schema, lastCol, parent) {
  27215. var prop, i;
  27216. if (typeof lastCol === 'undefined') {
  27217. lastCol = 0;
  27218. parent = '';
  27219. }
  27220. if ((typeof schema === 'undefined' ? 'undefined' : _typeof(schema)) === 'object' && !Array.isArray(schema)) {
  27221. for (i in schema) {
  27222. if ((0, _object.hasOwnProperty)(schema, i)) {
  27223. if (schema[i] === null) {
  27224. prop = parent + i;
  27225. this.colToPropCache.push(prop);
  27226. this.propToColCache.set(prop, lastCol);
  27227. lastCol++;
  27228. } else {
  27229. lastCol = this.recursiveDuckColumns(schema[i], lastCol, i + '.');
  27230. }
  27231. }
  27232. }
  27233. }
  27234. return lastCol;
  27235. };
  27236. DataMap.prototype.createMap = function () {
  27237. var i = void 0;
  27238. var schema = this.getSchema();
  27239. if (typeof schema === 'undefined') {
  27240. throw new Error('trying to create `columns` definition but you didn\'t provide `schema` nor `data`');
  27241. }
  27242. this.colToPropCache = [];
  27243. this.propToColCache = new _multiMap2.default();
  27244. var columns = this.instance.getSettings().columns;
  27245. if (columns) {
  27246. var maxCols = this.instance.getSettings().maxCols;
  27247. var columnsLen = Math.min(maxCols, columns.length);
  27248. var filteredIndex = 0;
  27249. var columnsAsFunc = false;
  27250. var schemaLen = (0, _object.deepObjectSize)(schema);
  27251. if (typeof columns === 'function') {
  27252. columnsLen = schemaLen > 0 ? schemaLen : this.instance.countSourceCols();
  27253. columnsAsFunc = true;
  27254. }
  27255. for (i = 0; i < columnsLen; i++) {
  27256. var column = columnsAsFunc ? columns(i) : columns[i];
  27257. if ((0, _object.isObject)(column)) {
  27258. if (typeof column.data !== 'undefined') {
  27259. var index = columnsAsFunc ? filteredIndex : i;
  27260. this.colToPropCache[index] = column.data;
  27261. this.propToColCache.set(column.data, index);
  27262. }
  27263. filteredIndex++;
  27264. }
  27265. }
  27266. } else {
  27267. this.recursiveDuckColumns(schema);
  27268. }
  27269. };
  27270. /**
  27271. * Returns property name that corresponds with the given column index.
  27272. *
  27273. * @param {Number} col Visual column index.
  27274. * @returns {Number} Physical column index.
  27275. */
  27276. DataMap.prototype.colToProp = function (col) {
  27277. col = this.instance.runHooks('modifyCol', col);
  27278. if (!isNaN(col) && this.colToPropCache && typeof this.colToPropCache[col] !== 'undefined') {
  27279. return this.colToPropCache[col];
  27280. }
  27281. return col;
  27282. };
  27283. /**
  27284. * @param {Object} prop
  27285. * @fires Hooks#modifyCol
  27286. * @returns {*}
  27287. */
  27288. DataMap.prototype.propToCol = function (prop) {
  27289. var col;
  27290. if (typeof this.propToColCache.get(prop) === 'undefined') {
  27291. col = prop;
  27292. } else {
  27293. col = this.propToColCache.get(prop);
  27294. }
  27295. col = this.instance.runHooks('unmodifyCol', col);
  27296. return col;
  27297. };
  27298. /**
  27299. * @returns {Object}
  27300. */
  27301. DataMap.prototype.getSchema = function () {
  27302. var schema = this.instance.getSettings().dataSchema;
  27303. if (schema) {
  27304. if (typeof schema === 'function') {
  27305. return schema();
  27306. }
  27307. return schema;
  27308. }
  27309. return this.duckSchema;
  27310. };
  27311. /**
  27312. * Creates row at the bottom of the data array.
  27313. *
  27314. * @param {Number} [index] Physical index of the row before which the new row will be inserted.
  27315. * @param {Number} [amount=1] An amount of rows to add.
  27316. * @param {String} [source] Source of method call.
  27317. * @fires Hooks#afterCreateRow
  27318. * @returns {Number} Returns number of created rows.
  27319. */
  27320. DataMap.prototype.createRow = function (index) {
  27321. var _this2 = this;
  27322. var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  27323. var source = arguments[2];
  27324. var numberOfCreatedRows = 0;
  27325. if (typeof index !== 'number' || index >= this.instance.countSourceRows()) {
  27326. index = this.instance.countSourceRows();
  27327. }
  27328. var continueProcess = this.instance.runHooks('beforeCreateRow', index, amount, source);
  27329. if (continueProcess === false) {
  27330. return 0;
  27331. }
  27332. var maxRows = this.instance.getSettings().maxRows;
  27333. var columnCount = this.instance.countCols();
  27334. var _loop = function _loop() {
  27335. var row = null;
  27336. if (_this2.instance.dataType === 'array') {
  27337. if (_this2.instance.getSettings().dataSchema) {
  27338. // Clone template array
  27339. row = (0, _object.deepClone)(_this2.getSchema());
  27340. } else {
  27341. row = [];
  27342. /* eslint-disable no-loop-func */
  27343. (0, _number.rangeEach)(columnCount - 1, function () {
  27344. return row.push(null);
  27345. });
  27346. }
  27347. } else if (_this2.instance.dataType === 'function') {
  27348. row = _this2.instance.getSettings().dataSchema(index);
  27349. } else {
  27350. row = {};
  27351. (0, _object.deepExtend)(row, _this2.getSchema());
  27352. }
  27353. if (index === _this2.instance.countSourceRows()) {
  27354. _this2.dataSource.push(row);
  27355. } else {
  27356. _this2.spliceData(index, 0, row);
  27357. }
  27358. numberOfCreatedRows++;
  27359. };
  27360. while (numberOfCreatedRows < amount && this.instance.countSourceRows() < maxRows) {
  27361. _loop();
  27362. }
  27363. this.instance.runHooks('afterCreateRow', index, numberOfCreatedRows, source);
  27364. this.instance.forceFullRender = true; // used when data was changed
  27365. return numberOfCreatedRows;
  27366. };
  27367. /**
  27368. * Creates col at the right of the data array.
  27369. *
  27370. * @param {Number} [index] Visual index of the column before which the new column will be inserted
  27371. * @param {Number} [amount] An amount of columns to add.
  27372. * @param {String} [source] Source of method call.
  27373. * @fires Hooks#afterCreateCol
  27374. * @returns {Number} Returns number of created columns
  27375. */
  27376. DataMap.prototype.createCol = function (index, amount, source) {
  27377. if (!this.instance.isColumnModificationAllowed()) {
  27378. 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.');
  27379. }
  27380. var rlen = this.instance.countSourceRows(),
  27381. data = this.dataSource,
  27382. constructor,
  27383. numberOfCreatedCols = 0,
  27384. currentIndex;
  27385. if (!amount) {
  27386. amount = 1;
  27387. }
  27388. if (typeof index !== 'number' || index >= this.instance.countCols()) {
  27389. index = this.instance.countCols();
  27390. }
  27391. this.instance.runHooks('beforeCreateCol', index, amount, source);
  27392. currentIndex = index;
  27393. var maxCols = this.instance.getSettings().maxCols;
  27394. while (numberOfCreatedCols < amount && this.instance.countCols() < maxCols) {
  27395. constructor = (0, _setting.columnFactory)(this.GridSettings, this.priv.columnsSettingConflicts);
  27396. if (typeof index !== 'number' || index >= this.instance.countCols()) {
  27397. if (rlen > 0) {
  27398. for (var r = 0; r < rlen; r++) {
  27399. if (typeof data[r] === 'undefined') {
  27400. data[r] = [];
  27401. }
  27402. data[r].push(null);
  27403. }
  27404. } else {
  27405. data.push([null]);
  27406. }
  27407. // Add new column constructor
  27408. this.priv.columnSettings.push(constructor);
  27409. } else {
  27410. for (var _r = 0; _r < rlen; _r++) {
  27411. data[_r].splice(currentIndex, 0, null);
  27412. }
  27413. // Add new column constructor at given index
  27414. this.priv.columnSettings.splice(currentIndex, 0, constructor);
  27415. }
  27416. numberOfCreatedCols++;
  27417. currentIndex++;
  27418. }
  27419. this.instance.runHooks('afterCreateCol', index, numberOfCreatedCols, source);
  27420. this.instance.forceFullRender = true; // used when data was changed
  27421. return numberOfCreatedCols;
  27422. };
  27423. /**
  27424. * Removes row from the data array.
  27425. *
  27426. * @param {Number} [index] Visual index of the row to be removed. If not provided, the last row will be removed
  27427. * @param {Number} [amount] Amount of the rows to be removed. If not provided, one row will be removed
  27428. * @param {String} [source] Source of method call.
  27429. * @fires Hooks#beforeRemoveRow
  27430. * @fires Hooks#afterRemoveRow
  27431. */
  27432. DataMap.prototype.removeRow = function (index, amount, source) {
  27433. if (!amount) {
  27434. amount = 1;
  27435. }
  27436. if (typeof index !== 'number') {
  27437. index = -amount;
  27438. }
  27439. amount = this.instance.runHooks('modifyRemovedAmount', amount, index);
  27440. index = (this.instance.countSourceRows() + index) % this.instance.countSourceRows();
  27441. var logicRows = this.visualRowsToPhysical(index, amount);
  27442. var actionWasNotCancelled = this.instance.runHooks('beforeRemoveRow', index, amount, logicRows, source);
  27443. if (actionWasNotCancelled === false) {
  27444. return;
  27445. }
  27446. var data = this.dataSource;
  27447. var newData = void 0;
  27448. newData = this.filterData(index, amount);
  27449. if (newData) {
  27450. data.length = 0;
  27451. Array.prototype.push.apply(data, newData);
  27452. }
  27453. this.instance.runHooks('afterRemoveRow', index, amount, logicRows, source);
  27454. this.instance.forceFullRender = true; // used when data was changed
  27455. };
  27456. /**
  27457. * Removes column from the data array.
  27458. *
  27459. * @param {Number} [index] Visual index of the column to be removed. If not provided, the last column will be removed
  27460. * @param {Number} [amount] Amount of the columns to be removed. If not provided, one column will be removed
  27461. * @param {String} [source] Source of method call.
  27462. * @fires Hooks#beforeRemoveCol
  27463. * @fires Hooks#afterRemoveCol
  27464. */
  27465. DataMap.prototype.removeCol = function (index, amount, source) {
  27466. if (this.instance.dataType === 'object' || this.instance.getSettings().columns) {
  27467. throw new Error('cannot remove column with object data source or columns option specified');
  27468. }
  27469. if (!amount) {
  27470. amount = 1;
  27471. }
  27472. if (typeof index !== 'number') {
  27473. index = -amount;
  27474. }
  27475. index = (this.instance.countCols() + index) % this.instance.countCols();
  27476. var logicColumns = this.visualColumnsToPhysical(index, amount);
  27477. var descendingLogicColumns = logicColumns.slice(0).sort(function (a, b) {
  27478. return b - a;
  27479. });
  27480. var actionWasNotCancelled = this.instance.runHooks('beforeRemoveCol', index, amount, logicColumns, source);
  27481. if (actionWasNotCancelled === false) {
  27482. return;
  27483. }
  27484. var isTableUniform = true;
  27485. var removedColumnsCount = descendingLogicColumns.length;
  27486. var data = this.dataSource;
  27487. for (var c = 0; c < removedColumnsCount; c++) {
  27488. if (isTableUniform && logicColumns[0] !== logicColumns[c] - c) {
  27489. isTableUniform = false;
  27490. }
  27491. }
  27492. if (isTableUniform) {
  27493. for (var r = 0, rlen = this.instance.countSourceRows(); r < rlen; r++) {
  27494. data[r].splice(logicColumns[0], amount);
  27495. }
  27496. } else {
  27497. for (var _r2 = 0, _rlen = this.instance.countSourceRows(); _r2 < _rlen; _r2++) {
  27498. for (var _c = 0; _c < removedColumnsCount; _c++) {
  27499. data[_r2].splice(descendingLogicColumns[_c], 1);
  27500. }
  27501. }
  27502. for (var _c2 = 0; _c2 < removedColumnsCount; _c2++) {
  27503. this.priv.columnSettings.splice(logicColumns[_c2], 1);
  27504. }
  27505. }
  27506. this.instance.runHooks('afterRemoveCol', index, amount, logicColumns, source);
  27507. this.instance.forceFullRender = true; // used when data was changed
  27508. };
  27509. /**
  27510. * Add/Removes data from the column.
  27511. *
  27512. * @param {Number} col Physical index of column in which do you want to do splice
  27513. * @param {Number} index Index at which to start changing the array. If negative, will begin that many elements from the end
  27514. * @param {Number} amount An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed
  27515. * @returns {Array} Returns removed portion of columns
  27516. */
  27517. DataMap.prototype.spliceCol = function (col, index, amount /* , elements... */) {
  27518. var elements = arguments.length >= 4 ? [].slice.call(arguments, 3) : [];
  27519. var colData = this.instance.getDataAtCol(col);
  27520. var removed = colData.slice(index, index + amount);
  27521. var after = colData.slice(index + amount);
  27522. (0, _array.extendArray)(elements, after);
  27523. var i = 0;
  27524. while (i < amount) {
  27525. elements.push(null); // add null in place of removed elements
  27526. i++;
  27527. }
  27528. (0, _array.to2dArray)(elements);
  27529. this.instance.populateFromArray(index, col, elements, null, null, 'spliceCol');
  27530. return removed;
  27531. };
  27532. /**
  27533. * Add/Removes data from the row.
  27534. *
  27535. * @param {Number} row Physical index of row in which do you want to do splice
  27536. * @param {Number} index Index at which to start changing the array. If negative, will begin that many elements from the end.
  27537. * @param {Number} amount An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed.
  27538. * @returns {Array} Returns removed portion of rows
  27539. */
  27540. DataMap.prototype.spliceRow = function (row, index, amount /* , elements... */) {
  27541. var elements = arguments.length >= 4 ? [].slice.call(arguments, 3) : [];
  27542. var rowData = this.instance.getSourceDataAtRow(row);
  27543. var removed = rowData.slice(index, index + amount);
  27544. var after = rowData.slice(index + amount);
  27545. (0, _array.extendArray)(elements, after);
  27546. var i = 0;
  27547. while (i < amount) {
  27548. elements.push(null); // add null in place of removed elements
  27549. i++;
  27550. }
  27551. this.instance.populateFromArray(row, index, [elements], null, null, 'spliceRow');
  27552. return removed;
  27553. };
  27554. /**
  27555. * Add/remove row(s) to/from the data source.
  27556. *
  27557. * @param {Number} index Physical index of the element to remove.
  27558. * @param {Number} amount Number of rows to add/remove.
  27559. * @param {Object} element Row to add.
  27560. */
  27561. DataMap.prototype.spliceData = function (index, amount, element) {
  27562. var continueSplicing = this.instance.runHooks('beforeDataSplice', index, amount, element);
  27563. if (continueSplicing !== false) {
  27564. this.dataSource.splice(index, amount, element);
  27565. }
  27566. };
  27567. /**
  27568. * Filter unwanted data elements from the data source.
  27569. *
  27570. * @param {Number} index Visual index of the element to remove.
  27571. * @param {Number} amount Number of rows to add/remove.
  27572. * @returns {Array}
  27573. */
  27574. DataMap.prototype.filterData = function (index, amount) {
  27575. var physicalRows = this.visualRowsToPhysical(index, amount);
  27576. var continueSplicing = this.instance.runHooks('beforeDataFilter', index, amount, physicalRows);
  27577. if (continueSplicing !== false) {
  27578. var newData = this.dataSource.filter(function (row, index) {
  27579. return physicalRows.indexOf(index) == -1;
  27580. });
  27581. return newData;
  27582. }
  27583. };
  27584. /**
  27585. * Returns single value from the data array.
  27586. *
  27587. * @param {Number} row Visual row index.
  27588. * @param {Number} prop
  27589. */
  27590. DataMap.prototype.get = function (row, prop) {
  27591. row = this.instance.runHooks('modifyRow', row);
  27592. var dataRow = this.dataSource[row];
  27593. // TODO: To remove, use 'modifyData' hook instead (see below)
  27594. var modifiedRowData = this.instance.runHooks('modifyRowData', row);
  27595. dataRow = isNaN(modifiedRowData) ? modifiedRowData : dataRow;
  27596. //
  27597. var value = null;
  27598. // try to get value under property `prop` (includes dot)
  27599. if (dataRow && dataRow.hasOwnProperty && (0, _object.hasOwnProperty)(dataRow, prop)) {
  27600. value = dataRow[prop];
  27601. } else if (typeof prop === 'string' && prop.indexOf('.') > -1) {
  27602. var sliced = prop.split('.');
  27603. var out = dataRow;
  27604. if (!out) {
  27605. return null;
  27606. }
  27607. for (var i = 0, ilen = sliced.length; i < ilen; i++) {
  27608. out = out[sliced[i]];
  27609. if (typeof out === 'undefined') {
  27610. return null;
  27611. }
  27612. }
  27613. value = out;
  27614. } else if (typeof prop === 'function') {
  27615. /**
  27616. * allows for interacting with complex structures, for example
  27617. * d3/jQuery getter/setter properties:
  27618. *
  27619. * {columns: [{
  27620. * data: function(row, value){
  27621. * if(arguments.length === 1){
  27622. * return row.property();
  27623. * }
  27624. * row.property(value);
  27625. * }
  27626. * }]}
  27627. */
  27628. value = prop(this.dataSource.slice(row, row + 1)[0]);
  27629. }
  27630. if (this.instance.hasHook('modifyData')) {
  27631. var valueHolder = (0, _object.createObjectPropListener)(value);
  27632. this.instance.runHooks('modifyData', row, this.propToCol(prop), valueHolder, 'get');
  27633. if (valueHolder.isTouched()) {
  27634. value = valueHolder.value;
  27635. }
  27636. }
  27637. return value;
  27638. };
  27639. var copyableLookup = (0, _data.cellMethodLookupFactory)('copyable', false);
  27640. /**
  27641. * Returns single value from the data array (intended for clipboard copy to an external application).
  27642. *
  27643. * @param {Number} row Physical row index.
  27644. * @param {Number} prop
  27645. * @returns {String}
  27646. */
  27647. DataMap.prototype.getCopyable = function (row, prop) {
  27648. if (copyableLookup.call(this.instance, row, this.propToCol(prop))) {
  27649. return this.get(row, prop);
  27650. }
  27651. return '';
  27652. };
  27653. /**
  27654. * Saves single value to the data array.
  27655. *
  27656. * @param {Number} row Visual row index.
  27657. * @param {Number} prop
  27658. * @param {String} value
  27659. * @param {String} [source] Source of hook runner.
  27660. */
  27661. DataMap.prototype.set = function (row, prop, value, source) {
  27662. row = this.instance.runHooks('modifyRow', row, source || 'datamapGet');
  27663. var dataRow = this.dataSource[row];
  27664. // TODO: To remove, use 'modifyData' hook instead (see below)
  27665. var modifiedRowData = this.instance.runHooks('modifyRowData', row);
  27666. dataRow = isNaN(modifiedRowData) ? modifiedRowData : dataRow;
  27667. //
  27668. if (this.instance.hasHook('modifyData')) {
  27669. var valueHolder = (0, _object.createObjectPropListener)(value);
  27670. this.instance.runHooks('modifyData', row, this.propToCol(prop), valueHolder, 'set');
  27671. if (valueHolder.isTouched()) {
  27672. value = valueHolder.value;
  27673. }
  27674. }
  27675. // try to set value under property `prop` (includes dot)
  27676. if (dataRow && dataRow.hasOwnProperty && (0, _object.hasOwnProperty)(dataRow, prop)) {
  27677. dataRow[prop] = value;
  27678. } else if (typeof prop === 'string' && prop.indexOf('.') > -1) {
  27679. var sliced = prop.split('.');
  27680. var out = dataRow;
  27681. var i = 0;
  27682. var ilen = void 0;
  27683. for (i = 0, ilen = sliced.length - 1; i < ilen; i++) {
  27684. if (typeof out[sliced[i]] === 'undefined') {
  27685. out[sliced[i]] = {};
  27686. }
  27687. out = out[sliced[i]];
  27688. }
  27689. out[sliced[i]] = value;
  27690. } else if (typeof prop === 'function') {
  27691. /* see the `function` handler in `get` */
  27692. prop(this.dataSource.slice(row, row + 1)[0], value);
  27693. } else {
  27694. dataRow[prop] = value;
  27695. }
  27696. };
  27697. /**
  27698. * This ridiculous piece of code maps rows Id that are present in table data to those displayed for user.
  27699. * The trick is, the physical row id (stored in settings.data) is not necessary the same
  27700. * as the visual (displayed) row id (e.g. when sorting is applied).
  27701. *
  27702. * @param {Number} index Visual row index.
  27703. * @param {Number} amount
  27704. * @fires Hooks#modifyRow
  27705. * @returns {Number}
  27706. */
  27707. DataMap.prototype.visualRowsToPhysical = function (index, amount) {
  27708. var totalRows = this.instance.countSourceRows();
  27709. var physicRow = (totalRows + index) % totalRows;
  27710. var logicRows = [];
  27711. var rowsToRemove = amount;
  27712. var row;
  27713. while (physicRow < totalRows && rowsToRemove) {
  27714. row = this.instance.runHooks('modifyRow', physicRow);
  27715. logicRows.push(row);
  27716. rowsToRemove--;
  27717. physicRow++;
  27718. }
  27719. return logicRows;
  27720. };
  27721. /**
  27722. *
  27723. * @param index Visual column index.
  27724. * @param amount
  27725. * @returns {Array}
  27726. */
  27727. DataMap.prototype.visualColumnsToPhysical = function (index, amount) {
  27728. var totalCols = this.instance.countCols();
  27729. var physicalCol = (totalCols + index) % totalCols;
  27730. var visualCols = [];
  27731. var colsToRemove = amount;
  27732. while (physicalCol < totalCols && colsToRemove) {
  27733. var col = this.instance.runHooks('modifyCol', physicalCol);
  27734. visualCols.push(col);
  27735. colsToRemove--;
  27736. physicalCol++;
  27737. }
  27738. return visualCols;
  27739. };
  27740. /**
  27741. * Clears the data array.
  27742. */
  27743. DataMap.prototype.clear = function () {
  27744. for (var r = 0; r < this.instance.countSourceRows(); r++) {
  27745. for (var c = 0; c < this.instance.countCols(); c++) {
  27746. this.set(r, this.colToProp(c), '');
  27747. }
  27748. }
  27749. };
  27750. /**
  27751. * Clear cached data length.
  27752. */
  27753. DataMap.prototype.clearLengthCache = function () {
  27754. this.cachedLength = null;
  27755. };
  27756. /**
  27757. * Get data length.
  27758. *
  27759. * @returns {Number}
  27760. */
  27761. DataMap.prototype.getLength = function () {
  27762. var _this3 = this;
  27763. var maxRows = void 0,
  27764. maxRowsFromSettings = this.instance.getSettings().maxRows;
  27765. if (maxRowsFromSettings < 0 || maxRowsFromSettings === 0) {
  27766. maxRows = 0;
  27767. } else {
  27768. maxRows = maxRowsFromSettings || Infinity;
  27769. }
  27770. var length = this.instance.countSourceRows();
  27771. if (this.instance.hasHook('modifyRow')) {
  27772. var reValidate = this.skipCache;
  27773. this.interval.start();
  27774. if (length !== this.latestSourceRowsCount) {
  27775. reValidate = true;
  27776. }
  27777. this.latestSourceRowsCount = length;
  27778. if (this.cachedLength === null || reValidate) {
  27779. (0, _number.rangeEach)(length - 1, function (row) {
  27780. row = _this3.instance.runHooks('modifyRow', row);
  27781. if (row === null) {
  27782. --length;
  27783. }
  27784. });
  27785. this.cachedLength = length;
  27786. } else {
  27787. length = this.cachedLength;
  27788. }
  27789. } else {
  27790. this.interval.stop();
  27791. }
  27792. return Math.min(length, maxRows);
  27793. };
  27794. /**
  27795. * Returns the data array.
  27796. *
  27797. * @returns {Array}
  27798. */
  27799. DataMap.prototype.getAll = function () {
  27800. var start = {
  27801. row: 0,
  27802. col: 0
  27803. };
  27804. var end = {
  27805. row: Math.max(this.instance.countSourceRows() - 1, 0),
  27806. col: Math.max(this.instance.countCols() - 1, 0)
  27807. };
  27808. if (start.row - end.row === 0 && !this.instance.countSourceRows()) {
  27809. return [];
  27810. }
  27811. return this.getRange(start, end, DataMap.prototype.DESTINATION_RENDERER);
  27812. };
  27813. /**
  27814. * Returns data range as array.
  27815. *
  27816. * @param {Object} [start] Start selection position. Visual indexes.
  27817. * @param {Object} [end] End selection position. Visual indexes.
  27818. * @param {Number} destination Destination of datamap.get
  27819. * @returns {Array}
  27820. */
  27821. DataMap.prototype.getRange = function (start, end, destination) {
  27822. var r,
  27823. rlen,
  27824. c,
  27825. clen,
  27826. output = [],
  27827. row;
  27828. var maxRows = this.instance.getSettings().maxRows;
  27829. var maxCols = this.instance.getSettings().maxCols;
  27830. if (maxRows === 0 || maxCols === 0) {
  27831. return [];
  27832. }
  27833. var getFn = destination === this.DESTINATION_CLIPBOARD_GENERATOR ? this.getCopyable : this.get;
  27834. rlen = Math.min(Math.max(maxRows - 1, 0), Math.max(start.row, end.row));
  27835. clen = Math.min(Math.max(maxCols - 1, 0), Math.max(start.col, end.col));
  27836. for (r = Math.min(start.row, end.row); r <= rlen; r++) {
  27837. row = [];
  27838. var physicalRow = this.instance.runHooks('modifyRow', r);
  27839. for (c = Math.min(start.col, end.col); c <= clen; c++) {
  27840. if (physicalRow === null) {
  27841. break;
  27842. }
  27843. row.push(getFn.call(this, r, this.colToProp(c)));
  27844. }
  27845. if (physicalRow !== null) {
  27846. output.push(row);
  27847. }
  27848. }
  27849. return output;
  27850. };
  27851. /**
  27852. * Return data as text (tab separated columns).
  27853. *
  27854. * @param {Object} [start] Start selection position. Visual indexes.
  27855. * @param {Object} [end] End selection position. Visual indexes.
  27856. * @returns {String}
  27857. */
  27858. DataMap.prototype.getText = function (start, end) {
  27859. return _SheetClip2.default.stringify(this.getRange(start, end, this.DESTINATION_RENDERER));
  27860. };
  27861. /**
  27862. * Return data as copyable text (tab separated columns intended for clipboard copy to an external application).
  27863. *
  27864. * @param {Object} [start] Start selection position. Visual indexes.
  27865. * @param {Object} [end] End selection position. Visual indexes.
  27866. * @returns {String}
  27867. */
  27868. DataMap.prototype.getCopyableText = function (start, end) {
  27869. return _SheetClip2.default.stringify(this.getRange(start, end, this.DESTINATION_CLIPBOARD_GENERATOR));
  27870. };
  27871. /**
  27872. * `skipLengthCache` callback.
  27873. * @private
  27874. * @param {Number} delay Time of the delay in milliseconds.
  27875. */
  27876. DataMap.prototype.onSkipLengthCache = function (delay) {
  27877. var _this4 = this;
  27878. this.skipCache = true;
  27879. setTimeout(function () {
  27880. _this4.skipCache = false;
  27881. }, delay);
  27882. };
  27883. /**
  27884. * Destroy instance.
  27885. */
  27886. DataMap.prototype.destroy = function () {
  27887. this.interval.stop();
  27888. this.interval = null;
  27889. this.instance = null;
  27890. this.priv = null;
  27891. this.GridSettings = null;
  27892. this.dataSource = null;
  27893. this.cachedLength = null;
  27894. this.duckSchema = null;
  27895. };
  27896. exports.default = DataMap;
  27897. /***/ }),
  27898. /* 264 */
  27899. /***/ (function(module, exports, __webpack_require__) {
  27900. "use strict";
  27901. exports.__esModule = true;
  27902. 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; }; }();
  27903. exports.parseDelay = parseDelay;
  27904. var _feature = __webpack_require__(40);
  27905. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  27906. /**
  27907. * @class Interval
  27908. * @util
  27909. */
  27910. var Interval = function () {
  27911. _createClass(Interval, null, [{
  27912. key: 'create',
  27913. value: function create(func, delay) {
  27914. return new Interval(func, delay);
  27915. }
  27916. }]);
  27917. function Interval(func, delay) {
  27918. var _this = this;
  27919. _classCallCheck(this, Interval);
  27920. /**
  27921. * Animation frame request id.
  27922. *
  27923. * @type {Number}
  27924. */
  27925. this.timer = null;
  27926. /**
  27927. * Function to invoke repeatedly.
  27928. *
  27929. * @type {Function}
  27930. */
  27931. this.func = func;
  27932. /**
  27933. * Number of milliseconds that function should wait before next call.
  27934. */
  27935. this.delay = parseDelay(delay);
  27936. /**
  27937. * Flag which indicates if interval object was stopped.
  27938. *
  27939. * @type {Boolean}
  27940. * @default true
  27941. */
  27942. this.stopped = true;
  27943. /**
  27944. * Interval time (in milliseconds) of the last callback call.
  27945. *
  27946. * @private
  27947. * @type {Number}
  27948. */
  27949. this._then = null;
  27950. /**
  27951. * Bounded function `func`.
  27952. *
  27953. * @private
  27954. * @type {Function}
  27955. */
  27956. this._callback = function () {
  27957. return _this.__callback();
  27958. };
  27959. }
  27960. /**
  27961. * Start loop.
  27962. *
  27963. * @returns {Interval}
  27964. */
  27965. _createClass(Interval, [{
  27966. key: 'start',
  27967. value: function start() {
  27968. if (this.stopped) {
  27969. this._then = Date.now();
  27970. this.stopped = false;
  27971. this.timer = (0, _feature.requestAnimationFrame)(this._callback);
  27972. }
  27973. return this;
  27974. }
  27975. /**
  27976. * Stop looping.
  27977. *
  27978. * @returns {Interval}
  27979. */
  27980. }, {
  27981. key: 'stop',
  27982. value: function stop() {
  27983. if (!this.stopped) {
  27984. this.stopped = true;
  27985. (0, _feature.cancelAnimationFrame)(this.timer);
  27986. this.timer = null;
  27987. }
  27988. return this;
  27989. }
  27990. /**
  27991. * Loop callback, fired on every animation frame.
  27992. *
  27993. * @private
  27994. */
  27995. }, {
  27996. key: '__callback',
  27997. value: function __callback() {
  27998. this.timer = (0, _feature.requestAnimationFrame)(this._callback);
  27999. if (this.delay) {
  28000. var now = Date.now();
  28001. var elapsed = now - this._then;
  28002. if (elapsed > this.delay) {
  28003. this._then = now - elapsed % this.delay;
  28004. this.func();
  28005. }
  28006. } else {
  28007. this.func();
  28008. }
  28009. }
  28010. }]);
  28011. return Interval;
  28012. }();
  28013. exports.default = Interval;
  28014. function parseDelay(delay) {
  28015. if (typeof delay === 'string' && /fps$/.test(delay)) {
  28016. delay = 1000 / parseInt(delay.replace('fps', '') || 0, 10);
  28017. }
  28018. return delay;
  28019. }
  28020. /***/ }),
  28021. /* 265 */
  28022. /***/ (function(module, exports, __webpack_require__) {
  28023. "use strict";
  28024. exports.__esModule = true;
  28025. 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; };
  28026. function MultiMap() {
  28027. var map = {
  28028. arrayMap: [],
  28029. weakMap: new WeakMap()
  28030. };
  28031. return {
  28032. get: function get(key) {
  28033. if (canBeAnArrayMapKey(key)) {
  28034. return map.arrayMap[key];
  28035. } else if (canBeAWeakMapKey(key)) {
  28036. return map.weakMap.get(key);
  28037. }
  28038. },
  28039. set: function set(key, value) {
  28040. if (canBeAnArrayMapKey(key)) {
  28041. map.arrayMap[key] = value;
  28042. } else if (canBeAWeakMapKey(key)) {
  28043. map.weakMap.set(key, value);
  28044. } else {
  28045. throw new Error('Invalid key type');
  28046. }
  28047. },
  28048. delete: function _delete(key) {
  28049. if (canBeAnArrayMapKey(key)) {
  28050. delete map.arrayMap[key];
  28051. } else if (canBeAWeakMapKey(key)) {
  28052. map.weakMap.delete(key);
  28053. }
  28054. }
  28055. };
  28056. function canBeAnArrayMapKey(obj) {
  28057. return obj !== null && !isNaNSymbol(obj) && (typeof obj == 'string' || typeof obj == 'number');
  28058. }
  28059. function canBeAWeakMapKey(obj) {
  28060. return obj !== null && ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) == 'object' || typeof obj == 'function');
  28061. }
  28062. function isNaNSymbol(obj) {
  28063. /* eslint-disable no-self-compare */
  28064. return obj !== obj; // NaN === NaN is always false
  28065. }
  28066. }
  28067. exports.default = MultiMap;
  28068. /***/ }),
  28069. /* 266 */
  28070. /***/ (function(module, exports, __webpack_require__) {
  28071. "use strict";
  28072. exports.__esModule = true;
  28073. var _src = __webpack_require__(4);
  28074. var _unicode = __webpack_require__(21);
  28075. var _event = __webpack_require__(12);
  28076. var _editors = __webpack_require__(17);
  28077. var _eventManager = __webpack_require__(6);
  28078. var _eventManager2 = _interopRequireDefault(_eventManager);
  28079. var _baseEditor = __webpack_require__(53);
  28080. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28081. function EditorManager(instance, priv, selection) {
  28082. var _this = this,
  28083. destroyed = false,
  28084. lock = false,
  28085. eventManager,
  28086. activeEditor;
  28087. eventManager = new _eventManager2.default(instance);
  28088. function moveSelectionAfterEnter(shiftKey) {
  28089. var enterMoves = typeof priv.settings.enterMoves === 'function' ? priv.settings.enterMoves(event) : priv.settings.enterMoves;
  28090. if (shiftKey) {
  28091. // move selection up
  28092. selection.transformStart(-enterMoves.row, -enterMoves.col);
  28093. } else {
  28094. // move selection down (add a new row if needed)
  28095. selection.transformStart(enterMoves.row, enterMoves.col, true);
  28096. }
  28097. }
  28098. function moveSelectionUp(shiftKey) {
  28099. if (shiftKey) {
  28100. selection.transformEnd(-1, 0);
  28101. } else {
  28102. selection.transformStart(-1, 0);
  28103. }
  28104. }
  28105. function moveSelectionDown(shiftKey) {
  28106. if (shiftKey) {
  28107. // expanding selection down with shift
  28108. selection.transformEnd(1, 0);
  28109. } else {
  28110. selection.transformStart(1, 0);
  28111. }
  28112. }
  28113. function moveSelectionRight(shiftKey) {
  28114. if (shiftKey) {
  28115. selection.transformEnd(0, 1);
  28116. } else {
  28117. selection.transformStart(0, 1);
  28118. }
  28119. }
  28120. function moveSelectionLeft(shiftKey) {
  28121. if (shiftKey) {
  28122. selection.transformEnd(0, -1);
  28123. } else {
  28124. selection.transformStart(0, -1);
  28125. }
  28126. }
  28127. function onKeyDown(event) {
  28128. if (!instance.isListening()) {
  28129. return;
  28130. }
  28131. instance.runHooks('beforeKeyDown', event);
  28132. if (destroyed) {
  28133. return;
  28134. }
  28135. if ((0, _event.isImmediatePropagationStopped)(event)) {
  28136. return;
  28137. }
  28138. priv.lastKeyCode = event.keyCode;
  28139. if (!selection.isSelected()) {
  28140. return;
  28141. }
  28142. // catch CTRL but not right ALT (which in some systems triggers ALT+CTRL)
  28143. var ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  28144. if (activeEditor && !activeEditor.isWaiting()) {
  28145. if (!(0, _unicode.isMetaKey)(event.keyCode) && !(0, _unicode.isCtrlMetaKey)(event.keyCode) && !ctrlDown && !_this.isEditorOpened()) {
  28146. _this.openEditor('', event);
  28147. return;
  28148. }
  28149. }
  28150. var rangeModifier = event.shiftKey ? selection.setRangeEnd : selection.setRangeStart;
  28151. var tabMoves = void 0;
  28152. switch (event.keyCode) {
  28153. case _unicode.KEY_CODES.A:
  28154. if (!_this.isEditorOpened() && ctrlDown) {
  28155. instance.selectAll();
  28156. event.preventDefault();
  28157. (0, _event.stopPropagation)(event);
  28158. }
  28159. break;
  28160. case _unicode.KEY_CODES.ARROW_UP:
  28161. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  28162. _this.closeEditorAndSaveChanges(ctrlDown);
  28163. }
  28164. moveSelectionUp(event.shiftKey);
  28165. event.preventDefault();
  28166. (0, _event.stopPropagation)(event);
  28167. break;
  28168. case _unicode.KEY_CODES.ARROW_DOWN:
  28169. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  28170. _this.closeEditorAndSaveChanges(ctrlDown);
  28171. }
  28172. moveSelectionDown(event.shiftKey);
  28173. event.preventDefault();
  28174. (0, _event.stopPropagation)(event);
  28175. break;
  28176. case _unicode.KEY_CODES.ARROW_RIGHT:
  28177. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  28178. _this.closeEditorAndSaveChanges(ctrlDown);
  28179. }
  28180. moveSelectionRight(event.shiftKey);
  28181. event.preventDefault();
  28182. (0, _event.stopPropagation)(event);
  28183. break;
  28184. case _unicode.KEY_CODES.ARROW_LEFT:
  28185. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  28186. _this.closeEditorAndSaveChanges(ctrlDown);
  28187. }
  28188. moveSelectionLeft(event.shiftKey);
  28189. event.preventDefault();
  28190. (0, _event.stopPropagation)(event);
  28191. break;
  28192. case _unicode.KEY_CODES.TAB:
  28193. tabMoves = typeof priv.settings.tabMoves === 'function' ? priv.settings.tabMoves(event) : priv.settings.tabMoves;
  28194. if (event.shiftKey) {
  28195. // move selection left
  28196. selection.transformStart(-tabMoves.row, -tabMoves.col);
  28197. } else {
  28198. // move selection right (add a new column if needed)
  28199. selection.transformStart(tabMoves.row, tabMoves.col, true);
  28200. }
  28201. event.preventDefault();
  28202. (0, _event.stopPropagation)(event);
  28203. break;
  28204. case _unicode.KEY_CODES.BACKSPACE:
  28205. case _unicode.KEY_CODES.DELETE:
  28206. instance.emptySelectedCells();
  28207. _this.prepareEditor();
  28208. event.preventDefault();
  28209. break;
  28210. case _unicode.KEY_CODES.F2:
  28211. /* F2 */
  28212. _this.openEditor(null, event);
  28213. if (activeEditor) {
  28214. activeEditor.enableFullEditMode();
  28215. }
  28216. event.preventDefault(); // prevent Opera from opening 'Go to Page dialog'
  28217. break;
  28218. case _unicode.KEY_CODES.ENTER:
  28219. /* return/enter */
  28220. if (_this.isEditorOpened()) {
  28221. if (activeEditor && activeEditor.state !== _baseEditor.EditorState.WAITING) {
  28222. _this.closeEditorAndSaveChanges(ctrlDown);
  28223. }
  28224. moveSelectionAfterEnter(event.shiftKey);
  28225. } else if (instance.getSettings().enterBeginsEditing) {
  28226. _this.openEditor(null, event);
  28227. if (activeEditor) {
  28228. activeEditor.enableFullEditMode();
  28229. }
  28230. } else {
  28231. moveSelectionAfterEnter(event.shiftKey);
  28232. }
  28233. event.preventDefault(); // don't add newline to field
  28234. (0, _event.stopImmediatePropagation)(event); // required by HandsontableEditor
  28235. break;
  28236. case _unicode.KEY_CODES.ESCAPE:
  28237. if (_this.isEditorOpened()) {
  28238. _this.closeEditorAndRestoreOriginalValue(ctrlDown);
  28239. }
  28240. event.preventDefault();
  28241. break;
  28242. case _unicode.KEY_CODES.HOME:
  28243. if (event.ctrlKey || event.metaKey) {
  28244. rangeModifier.call(selection, new _src.CellCoords(0, selection.selectedRange.current().from.col));
  28245. } else {
  28246. rangeModifier.call(selection, new _src.CellCoords(selection.selectedRange.current().from.row, 0));
  28247. }
  28248. event.preventDefault(); // don't scroll the window
  28249. (0, _event.stopPropagation)(event);
  28250. break;
  28251. case _unicode.KEY_CODES.END:
  28252. if (event.ctrlKey || event.metaKey) {
  28253. rangeModifier.call(selection, new _src.CellCoords(instance.countRows() - 1, selection.selectedRange.current().from.col));
  28254. } else {
  28255. rangeModifier.call(selection, new _src.CellCoords(selection.selectedRange.current().from.row, instance.countCols() - 1));
  28256. }
  28257. event.preventDefault(); // don't scroll the window
  28258. (0, _event.stopPropagation)(event);
  28259. break;
  28260. case _unicode.KEY_CODES.PAGE_UP:
  28261. selection.transformStart(-instance.countVisibleRows(), 0);
  28262. event.preventDefault(); // don't page up the window
  28263. (0, _event.stopPropagation)(event);
  28264. break;
  28265. case _unicode.KEY_CODES.PAGE_DOWN:
  28266. selection.transformStart(instance.countVisibleRows(), 0);
  28267. event.preventDefault(); // don't page down the window
  28268. (0, _event.stopPropagation)(event);
  28269. break;
  28270. default:
  28271. break;
  28272. }
  28273. }
  28274. function init() {
  28275. instance.addHook('afterDocumentKeyDown', onKeyDown);
  28276. eventManager.addEventListener(document.documentElement, 'keydown', function (event) {
  28277. if (!destroyed) {
  28278. instance.runHooks('afterDocumentKeyDown', event);
  28279. }
  28280. });
  28281. function onDblClick(event, coords, elem) {
  28282. // may be TD or TH
  28283. if (elem.nodeName === 'TD') {
  28284. _this.openEditor(null, event);
  28285. if (activeEditor) {
  28286. activeEditor.enableFullEditMode();
  28287. }
  28288. }
  28289. }
  28290. instance.view.wt.update('onCellDblClick', onDblClick);
  28291. }
  28292. /**
  28293. * Lock the editor from being prepared and closed. Locking the editor prevents its closing and
  28294. * reinitialized after selecting the new cell. This feature is necessary for a mobile editor.
  28295. *
  28296. * @function lockEditor
  28297. * @memberof! Handsontable.EditorManager#
  28298. */
  28299. this.lockEditor = function () {
  28300. lock = true;
  28301. };
  28302. /**
  28303. * Unlock the editor from being prepared and closed. This method restores the original behavior of
  28304. * the editors where for every new selection its instances are closed.
  28305. *
  28306. * @function unlockEditor
  28307. * @memberof! Handsontable.EditorManager#
  28308. */
  28309. this.unlockEditor = function () {
  28310. lock = false;
  28311. };
  28312. /**
  28313. * Destroy current editor, if exists.
  28314. *
  28315. * @function destroyEditor
  28316. * @memberof! Handsontable.EditorManager#
  28317. * @param {Boolean} revertOriginal
  28318. */
  28319. this.destroyEditor = function (revertOriginal) {
  28320. if (!lock) {
  28321. this.closeEditor(revertOriginal);
  28322. }
  28323. };
  28324. /**
  28325. * Get active editor.
  28326. *
  28327. * @function getActiveEditor
  28328. * @memberof! Handsontable.EditorManager#
  28329. * @returns {*}
  28330. */
  28331. this.getActiveEditor = function () {
  28332. return activeEditor;
  28333. };
  28334. /**
  28335. * Prepare text input to be displayed at given grid cell.
  28336. *
  28337. * @function prepareEditor
  28338. * @memberof! Handsontable.EditorManager#
  28339. */
  28340. this.prepareEditor = function () {
  28341. if (lock) {
  28342. return;
  28343. }
  28344. var row, col, prop, td, originalValue, cellProperties, editorClass;
  28345. if (activeEditor && activeEditor.isWaiting()) {
  28346. this.closeEditor(false, false, function (dataSaved) {
  28347. if (dataSaved) {
  28348. _this.prepareEditor();
  28349. }
  28350. });
  28351. return;
  28352. }
  28353. row = instance.selection.selectedRange.current().highlight.row;
  28354. col = instance.selection.selectedRange.current().highlight.col;
  28355. prop = instance.colToProp(col);
  28356. td = instance.getCell(row, col);
  28357. originalValue = instance.getSourceDataAtCell(instance.runHooks('modifyRow', row), col);
  28358. cellProperties = instance.getCellMeta(row, col);
  28359. editorClass = instance.getCellEditor(cellProperties);
  28360. if (editorClass) {
  28361. activeEditor = (0, _editors.getEditorInstance)(editorClass, instance);
  28362. activeEditor.prepare(row, col, prop, td, originalValue, cellProperties);
  28363. } else {
  28364. activeEditor = void 0;
  28365. }
  28366. };
  28367. /**
  28368. * Check is editor is opened/showed.
  28369. *
  28370. * @function isEditorOpened
  28371. * @memberof! Handsontable.EditorManager#
  28372. * @returns {Boolean}
  28373. */
  28374. this.isEditorOpened = function () {
  28375. return activeEditor && activeEditor.isOpened();
  28376. };
  28377. /**
  28378. * Open editor with initial value.
  28379. *
  28380. * @function openEditor
  28381. * @memberof! Handsontable.EditorManager#
  28382. * @param {null|String} newInitialValue new value from which editor will start if handled property it's not the `null`.
  28383. * @param {DOMEvent} event
  28384. */
  28385. this.openEditor = function (newInitialValue, event) {
  28386. if (activeEditor && !activeEditor.cellProperties.readOnly) {
  28387. activeEditor.beginEditing(newInitialValue, event);
  28388. } else if (activeEditor && activeEditor.cellProperties.readOnly) {
  28389. // move the selection after opening the editor with ENTER key
  28390. if (event && event.keyCode === _unicode.KEY_CODES.ENTER) {
  28391. moveSelectionAfterEnter();
  28392. }
  28393. }
  28394. };
  28395. /**
  28396. * Close editor, finish editing cell.
  28397. *
  28398. * @function closeEditor
  28399. * @memberof! Handsontable.EditorManager#
  28400. * @param {Boolean} restoreOriginalValue
  28401. * @param {Boolean} [ctrlDown]
  28402. * @param {Function} [callback]
  28403. */
  28404. this.closeEditor = function (restoreOriginalValue, ctrlDown, callback) {
  28405. if (activeEditor) {
  28406. activeEditor.finishEditing(restoreOriginalValue, ctrlDown, callback);
  28407. } else if (callback) {
  28408. callback(false);
  28409. }
  28410. };
  28411. /**
  28412. * Close editor and save changes.
  28413. *
  28414. * @function closeEditorAndSaveChanges
  28415. * @memberof! Handsontable.EditorManager#
  28416. * @param {Boolean} ctrlDown
  28417. */
  28418. this.closeEditorAndSaveChanges = function (ctrlDown) {
  28419. return this.closeEditor(false, ctrlDown);
  28420. };
  28421. /**
  28422. * Close editor and restore original value.
  28423. *
  28424. * @function closeEditorAndRestoreOriginalValue
  28425. * @memberof! Handsontable.EditorManager#
  28426. * @param {Boolean} ctrlDown
  28427. */
  28428. this.closeEditorAndRestoreOriginalValue = function (ctrlDown) {
  28429. return this.closeEditor(true, ctrlDown);
  28430. };
  28431. /**
  28432. * Destroy the instance.
  28433. */
  28434. this.destroy = function () {
  28435. destroyed = true;
  28436. };
  28437. init();
  28438. }
  28439. var instances = new WeakMap();
  28440. EditorManager.getInstance = function (hotInstance, hotSettings, selection, datamap) {
  28441. var editorManager = instances.get(hotInstance);
  28442. if (!editorManager) {
  28443. editorManager = new EditorManager(hotInstance, hotSettings, selection, datamap);
  28444. instances.set(hotInstance, editorManager);
  28445. }
  28446. return editorManager;
  28447. };
  28448. exports.default = EditorManager;
  28449. /***/ }),
  28450. /* 267 */
  28451. /***/ (function(module, exports, __webpack_require__) {
  28452. "use strict";
  28453. exports.__esModule = true;
  28454. 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"); } }; }();
  28455. var _element = __webpack_require__(0);
  28456. var _browser = __webpack_require__(27);
  28457. var _eventManager = __webpack_require__(6);
  28458. var _eventManager2 = _interopRequireDefault(_eventManager);
  28459. var _event = __webpack_require__(12);
  28460. var _src = __webpack_require__(4);
  28461. var _src2 = _interopRequireDefault(_src);
  28462. var _mouseEventHandler = __webpack_require__(192);
  28463. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28464. /**
  28465. * Handsontable TableView constructor
  28466. * @param {Object} instance
  28467. */
  28468. function TableView(instance) {
  28469. var _this = this;
  28470. var that = this;
  28471. this.eventManager = new _eventManager2.default(instance);
  28472. this.instance = instance;
  28473. this.settings = instance.getSettings();
  28474. this.selectionMouseDown = false;
  28475. var originalStyle = instance.rootElement.getAttribute('style');
  28476. if (originalStyle) {
  28477. instance.rootElement.setAttribute('data-originalstyle', originalStyle); // needed to retrieve original style in jsFiddle link generator in HT examples. may be removed in future versions
  28478. }
  28479. (0, _element.addClass)(instance.rootElement, 'handsontable');
  28480. var table = document.createElement('TABLE');
  28481. (0, _element.addClass)(table, 'htCore');
  28482. if (instance.getSettings().tableClassName) {
  28483. (0, _element.addClass)(table, instance.getSettings().tableClassName);
  28484. }
  28485. this.THEAD = document.createElement('THEAD');
  28486. table.appendChild(this.THEAD);
  28487. this.TBODY = document.createElement('TBODY');
  28488. table.appendChild(this.TBODY);
  28489. instance.table = table;
  28490. instance.container.insertBefore(table, instance.container.firstChild);
  28491. this.eventManager.addEventListener(instance.rootElement, 'mousedown', function (event) {
  28492. this.selectionMouseDown = true;
  28493. if (!that.isTextSelectionAllowed(event.target)) {
  28494. clearTextSelection();
  28495. event.preventDefault();
  28496. window.focus(); // make sure that window that contains HOT is active. Important when HOT is in iframe.
  28497. }
  28498. });
  28499. this.eventManager.addEventListener(instance.rootElement, 'mouseup', function (event) {
  28500. this.selectionMouseDown = false;
  28501. });
  28502. this.eventManager.addEventListener(instance.rootElement, 'mousemove', function (event) {
  28503. if (this.selectionMouseDown && !that.isTextSelectionAllowed(event.target)) {
  28504. clearTextSelection();
  28505. event.preventDefault();
  28506. }
  28507. });
  28508. this.eventManager.addEventListener(document.documentElement, 'keyup', function (event) {
  28509. if (instance.selection.isInProgress() && !event.shiftKey) {
  28510. instance.selection.finish();
  28511. }
  28512. });
  28513. var isMouseDown;
  28514. this.isMouseDown = function () {
  28515. return isMouseDown;
  28516. };
  28517. this.eventManager.addEventListener(document.documentElement, 'mouseup', function (event) {
  28518. if (instance.selection.isInProgress() && (0, _event.isLeftClick)(event)) {
  28519. // is left mouse button
  28520. instance.selection.finish();
  28521. }
  28522. isMouseDown = false;
  28523. if ((0, _element.isOutsideInput)(document.activeElement) || !instance.selection.isSelected() && !(0, _event.isRightClick)(event)) {
  28524. instance.unlisten();
  28525. }
  28526. });
  28527. this.eventManager.addEventListener(document.documentElement, 'mousedown', function (event) {
  28528. var originalTarget = event.target;
  28529. var next = event.target;
  28530. var eventX = event.x || event.clientX;
  28531. var eventY = event.y || event.clientY;
  28532. if (isMouseDown || !instance.rootElement) {
  28533. return; // it must have been started in a cell
  28534. }
  28535. // immediate click on "holder" means click on the right side of vertical scrollbar
  28536. if (next === instance.view.wt.wtTable.holder) {
  28537. var scrollbarWidth = (0, _element.getScrollbarWidth)();
  28538. if (document.elementFromPoint(eventX + scrollbarWidth, eventY) !== instance.view.wt.wtTable.holder || document.elementFromPoint(eventX, eventY + scrollbarWidth) !== instance.view.wt.wtTable.holder) {
  28539. return;
  28540. }
  28541. } else {
  28542. while (next !== document.documentElement) {
  28543. if (next === null) {
  28544. if (event.isTargetWebComponent) {
  28545. break;
  28546. }
  28547. // click on something that was a row but now is detached (possibly because your click triggered a rerender)
  28548. return;
  28549. }
  28550. if (next === instance.rootElement) {
  28551. // click inside container
  28552. return;
  28553. }
  28554. next = next.parentNode;
  28555. }
  28556. }
  28557. // function did not return until here, we have an outside click!
  28558. var outsideClickDeselects = typeof that.settings.outsideClickDeselects === 'function' ? that.settings.outsideClickDeselects(originalTarget) : that.settings.outsideClickDeselects;
  28559. if (outsideClickDeselects) {
  28560. instance.deselectCell();
  28561. } else {
  28562. instance.destroyEditor();
  28563. }
  28564. });
  28565. this.eventManager.addEventListener(table, 'selectstart', function (event) {
  28566. if (that.settings.fragmentSelection || (0, _element.isInput)(event.target)) {
  28567. return;
  28568. }
  28569. // https://github.com/handsontable/handsontable/issues/160
  28570. // Prevent text from being selected when performing drag down.
  28571. event.preventDefault();
  28572. });
  28573. var clearTextSelection = function clearTextSelection() {
  28574. // http://stackoverflow.com/questions/3169786/clear-text-selection-with-javascript
  28575. if (window.getSelection) {
  28576. if (window.getSelection().empty) {
  28577. // Chrome
  28578. window.getSelection().empty();
  28579. } else if (window.getSelection().removeAllRanges) {
  28580. // Firefox
  28581. window.getSelection().removeAllRanges();
  28582. }
  28583. } else if (document.selection) {
  28584. // IE?
  28585. document.selection.empty();
  28586. }
  28587. };
  28588. var walkontableConfig = {
  28589. debug: function debug() {
  28590. return that.settings.debug;
  28591. },
  28592. externalRowCalculator: this.instance.getPlugin('autoRowSize') && this.instance.getPlugin('autoRowSize').isEnabled(),
  28593. table: table,
  28594. preventOverflow: function preventOverflow() {
  28595. return _this.settings.preventOverflow;
  28596. },
  28597. stretchH: function stretchH() {
  28598. return that.settings.stretchH;
  28599. },
  28600. data: instance.getDataAtCell,
  28601. totalRows: function totalRows() {
  28602. return instance.countRows();
  28603. },
  28604. totalColumns: function totalColumns() {
  28605. return instance.countCols();
  28606. },
  28607. fixedColumnsLeft: function fixedColumnsLeft() {
  28608. return that.settings.fixedColumnsLeft;
  28609. },
  28610. fixedRowsTop: function fixedRowsTop() {
  28611. return that.settings.fixedRowsTop;
  28612. },
  28613. fixedRowsBottom: function fixedRowsBottom() {
  28614. return that.settings.fixedRowsBottom;
  28615. },
  28616. minSpareRows: function minSpareRows() {
  28617. return that.settings.minSpareRows;
  28618. },
  28619. renderAllRows: that.settings.renderAllRows,
  28620. rowHeaders: function rowHeaders() {
  28621. var headerRenderers = [];
  28622. if (instance.hasRowHeaders()) {
  28623. headerRenderers.push(function (row, TH) {
  28624. that.appendRowHeader(row, TH);
  28625. });
  28626. }
  28627. instance.runHooks('afterGetRowHeaderRenderers', headerRenderers);
  28628. return headerRenderers;
  28629. },
  28630. columnHeaders: function columnHeaders() {
  28631. var headerRenderers = [];
  28632. if (instance.hasColHeaders()) {
  28633. headerRenderers.push(function (column, TH) {
  28634. that.appendColHeader(column, TH);
  28635. });
  28636. }
  28637. instance.runHooks('afterGetColumnHeaderRenderers', headerRenderers);
  28638. return headerRenderers;
  28639. },
  28640. columnWidth: instance.getColWidth,
  28641. rowHeight: instance.getRowHeight,
  28642. cellRenderer: function cellRenderer(row, col, TD) {
  28643. var cellProperties = that.instance.getCellMeta(row, col);
  28644. var prop = that.instance.colToProp(col);
  28645. var value = that.instance.getDataAtRowProp(row, prop);
  28646. if (that.instance.hasHook('beforeValueRender')) {
  28647. value = that.instance.runHooks('beforeValueRender', value, cellProperties);
  28648. }
  28649. that.instance.runHooks('beforeRenderer', TD, row, col, prop, value, cellProperties);
  28650. that.instance.getCellRenderer(cellProperties)(that.instance, TD, row, col, prop, value, cellProperties);
  28651. that.instance.runHooks('afterRenderer', TD, row, col, prop, value, cellProperties);
  28652. },
  28653. selections: that.instance.selection.highlight,
  28654. hideBorderOnMouseDownOver: function hideBorderOnMouseDownOver() {
  28655. return that.settings.fragmentSelection;
  28656. },
  28657. onCellMouseDown: function onCellMouseDown(event, coords, TD, wt) {
  28658. var blockCalculations = {
  28659. row: false,
  28660. column: false,
  28661. cell: false
  28662. };
  28663. instance.listen();
  28664. that.activeWt = wt;
  28665. isMouseDown = true;
  28666. instance.runHooks('beforeOnCellMouseDown', event, coords, TD, blockCalculations);
  28667. if ((0, _event.isImmediatePropagationStopped)(event)) {
  28668. return;
  28669. }
  28670. (0, _mouseEventHandler.handleMouseEvent)(event, {
  28671. coords: coords,
  28672. selection: instance.selection,
  28673. controller: blockCalculations
  28674. });
  28675. instance.runHooks('afterOnCellMouseDown', event, coords, TD);
  28676. that.activeWt = that.wt;
  28677. },
  28678. onCellMouseOut: function onCellMouseOut(event, coords, TD, wt) {
  28679. that.activeWt = wt;
  28680. instance.runHooks('beforeOnCellMouseOut', event, coords, TD);
  28681. if ((0, _event.isImmediatePropagationStopped)(event)) {
  28682. return;
  28683. }
  28684. instance.runHooks('afterOnCellMouseOut', event, coords, TD);
  28685. that.activeWt = that.wt;
  28686. },
  28687. onCellMouseOver: function onCellMouseOver(event, coords, TD, wt) {
  28688. var blockCalculations = {
  28689. row: false,
  28690. column: false,
  28691. cell: false
  28692. };
  28693. that.activeWt = wt;
  28694. instance.runHooks('beforeOnCellMouseOver', event, coords, TD, blockCalculations);
  28695. if ((0, _event.isImmediatePropagationStopped)(event)) {
  28696. return;
  28697. }
  28698. if (isMouseDown) {
  28699. (0, _mouseEventHandler.handleMouseEvent)(event, {
  28700. coords: coords,
  28701. selection: instance.selection,
  28702. controller: blockCalculations
  28703. });
  28704. }
  28705. instance.runHooks('afterOnCellMouseOver', event, coords, TD);
  28706. that.activeWt = that.wt;
  28707. },
  28708. onCellMouseUp: function onCellMouseUp(event, coords, TD, wt) {
  28709. that.activeWt = wt;
  28710. instance.runHooks('beforeOnCellMouseUp', event, coords, TD);
  28711. instance.runHooks('afterOnCellMouseUp', event, coords, TD);
  28712. that.activeWt = that.wt;
  28713. },
  28714. onCellCornerMouseDown: function onCellCornerMouseDown(event) {
  28715. event.preventDefault();
  28716. instance.runHooks('afterOnCellCornerMouseDown', event);
  28717. },
  28718. onCellCornerDblClick: function onCellCornerDblClick(event) {
  28719. event.preventDefault();
  28720. instance.runHooks('afterOnCellCornerDblClick', event);
  28721. },
  28722. beforeDraw: function beforeDraw(force, skipRender) {
  28723. that.beforeRender(force, skipRender);
  28724. },
  28725. onDraw: function onDraw(force) {
  28726. that.onDraw(force);
  28727. },
  28728. onScrollVertically: function onScrollVertically() {
  28729. instance.runHooks('afterScrollVertically');
  28730. },
  28731. onScrollHorizontally: function onScrollHorizontally() {
  28732. instance.runHooks('afterScrollHorizontally');
  28733. },
  28734. onBeforeRemoveCellClassNames: function onBeforeRemoveCellClassNames() {
  28735. return instance.runHooks('beforeRemoveCellClassNames');
  28736. },
  28737. onAfterDrawSelection: function onAfterDrawSelection(currentRow, currentColumn, cornersOfSelection, layerLevel) {
  28738. return instance.runHooks('afterDrawSelection', currentRow, currentColumn, cornersOfSelection, layerLevel);
  28739. },
  28740. onBeforeDrawBorders: function onBeforeDrawBorders(corners, borderClassName) {
  28741. instance.runHooks('beforeDrawBorders', corners, borderClassName);
  28742. },
  28743. onBeforeTouchScroll: function onBeforeTouchScroll() {
  28744. instance.runHooks('beforeTouchScroll');
  28745. },
  28746. onAfterMomentumScroll: function onAfterMomentumScroll() {
  28747. instance.runHooks('afterMomentumScroll');
  28748. },
  28749. onBeforeStretchingColumnWidth: function onBeforeStretchingColumnWidth(stretchedWidth, column) {
  28750. return instance.runHooks('beforeStretchingColumnWidth', stretchedWidth, column);
  28751. },
  28752. onModifyRowHeaderWidth: function onModifyRowHeaderWidth(rowHeaderWidth) {
  28753. return instance.runHooks('modifyRowHeaderWidth', rowHeaderWidth);
  28754. },
  28755. onModifyGetCellCoords: function onModifyGetCellCoords(row, column, topmost) {
  28756. return instance.runHooks('modifyGetCellCoords', row, column, topmost);
  28757. },
  28758. viewportRowCalculatorOverride: function viewportRowCalculatorOverride(calc) {
  28759. var rows = instance.countRows();
  28760. var viewportOffset = that.settings.viewportRowRenderingOffset;
  28761. if (viewportOffset === 'auto' && that.settings.fixedRowsTop) {
  28762. viewportOffset = 10;
  28763. }
  28764. if (typeof viewportOffset === 'number') {
  28765. calc.startRow = Math.max(calc.startRow - viewportOffset, 0);
  28766. calc.endRow = Math.min(calc.endRow + viewportOffset, rows - 1);
  28767. }
  28768. if (viewportOffset === 'auto') {
  28769. var center = calc.startRow + calc.endRow - calc.startRow;
  28770. var offset = Math.ceil(center / rows * 12);
  28771. calc.startRow = Math.max(calc.startRow - offset, 0);
  28772. calc.endRow = Math.min(calc.endRow + offset, rows - 1);
  28773. }
  28774. instance.runHooks('afterViewportRowCalculatorOverride', calc);
  28775. },
  28776. viewportColumnCalculatorOverride: function viewportColumnCalculatorOverride(calc) {
  28777. var cols = instance.countCols();
  28778. var viewportOffset = that.settings.viewportColumnRenderingOffset;
  28779. if (viewportOffset === 'auto' && that.settings.fixedColumnsLeft) {
  28780. viewportOffset = 10;
  28781. }
  28782. if (typeof viewportOffset === 'number') {
  28783. calc.startColumn = Math.max(calc.startColumn - viewportOffset, 0);
  28784. calc.endColumn = Math.min(calc.endColumn + viewportOffset, cols - 1);
  28785. }
  28786. if (viewportOffset === 'auto') {
  28787. var center = calc.startColumn + calc.endColumn - calc.startColumn;
  28788. var offset = Math.ceil(center / cols * 12);
  28789. calc.startRow = Math.max(calc.startColumn - offset, 0);
  28790. calc.endColumn = Math.min(calc.endColumn + offset, cols - 1);
  28791. }
  28792. instance.runHooks('afterViewportColumnCalculatorOverride', calc);
  28793. },
  28794. rowHeaderWidth: function rowHeaderWidth() {
  28795. return that.settings.rowHeaderWidth;
  28796. },
  28797. columnHeaderHeight: function columnHeaderHeight() {
  28798. var columnHeaderHeight = instance.runHooks('modifyColumnHeaderHeight');
  28799. return that.settings.columnHeaderHeight || columnHeaderHeight;
  28800. }
  28801. };
  28802. instance.runHooks('beforeInitWalkontable', walkontableConfig);
  28803. this.wt = new _src2.default(walkontableConfig);
  28804. this.activeWt = this.wt;
  28805. this.eventManager.addEventListener(that.wt.wtTable.spreader, 'mousedown', function (event) {
  28806. // right mouse button exactly on spreader means right click on the right hand side of vertical scrollbar
  28807. if (event.target === that.wt.wtTable.spreader && event.which === 3) {
  28808. (0, _event.stopPropagation)(event);
  28809. }
  28810. });
  28811. this.eventManager.addEventListener(that.wt.wtTable.spreader, 'contextmenu', function (event) {
  28812. // right mouse button exactly on spreader means right click on the right hand side of vertical scrollbar
  28813. if (event.target === that.wt.wtTable.spreader && event.which === 3) {
  28814. (0, _event.stopPropagation)(event);
  28815. }
  28816. });
  28817. this.eventManager.addEventListener(document.documentElement, 'click', function () {
  28818. if (that.settings.observeDOMVisibility) {
  28819. if (that.wt.drawInterrupted) {
  28820. that.instance.forceFullRender = true;
  28821. that.render();
  28822. }
  28823. }
  28824. });
  28825. }
  28826. TableView.prototype.isTextSelectionAllowed = function (el) {
  28827. if ((0, _element.isInput)(el)) {
  28828. return true;
  28829. }
  28830. var isChildOfTableBody = (0, _element.isChildOf)(el, this.instance.view.wt.wtTable.spreader);
  28831. if (this.settings.fragmentSelection === true && isChildOfTableBody) {
  28832. return true;
  28833. }
  28834. if (this.settings.fragmentSelection === 'cell' && this.isSelectedOnlyCell() && isChildOfTableBody) {
  28835. return true;
  28836. }
  28837. if (!this.settings.fragmentSelection && this.isCellEdited() && this.isSelectedOnlyCell()) {
  28838. return true;
  28839. }
  28840. return false;
  28841. };
  28842. /**
  28843. * Check if selected only one cell.
  28844. *
  28845. * @returns {Boolean}
  28846. */
  28847. TableView.prototype.isSelectedOnlyCell = function () {
  28848. var _ref = this.instance.getSelectedLast() || [],
  28849. _ref2 = _slicedToArray(_ref, 4),
  28850. row = _ref2[0],
  28851. col = _ref2[1],
  28852. rowEnd = _ref2[2],
  28853. colEnd = _ref2[3];
  28854. return row !== void 0 && row === rowEnd && col === colEnd;
  28855. };
  28856. TableView.prototype.isCellEdited = function () {
  28857. var activeEditor = this.instance.getActiveEditor();
  28858. return activeEditor && activeEditor.isOpened();
  28859. };
  28860. TableView.prototype.beforeRender = function (force, skipRender) {
  28861. if (force) {
  28862. // this.instance.forceFullRender = did Handsontable request full render?
  28863. this.instance.runHooks('beforeRender', this.instance.forceFullRender, skipRender);
  28864. }
  28865. };
  28866. TableView.prototype.onDraw = function (force) {
  28867. if (force) {
  28868. // this.instance.forceFullRender = did Handsontable request full render?
  28869. this.instance.runHooks('afterRender', this.instance.forceFullRender);
  28870. }
  28871. };
  28872. TableView.prototype.render = function () {
  28873. this.wt.draw(!this.instance.forceFullRender);
  28874. this.instance.forceFullRender = false;
  28875. this.instance.renderCall = false;
  28876. };
  28877. /**
  28878. * Returns td object given coordinates
  28879. *
  28880. * @param {CellCoords} coords
  28881. * @param {Boolean} topmost
  28882. */
  28883. TableView.prototype.getCellAtCoords = function (coords, topmost) {
  28884. var td = this.wt.getCell(coords, topmost);
  28885. if (td < 0) {
  28886. // there was an exit code (cell is out of bounds)
  28887. return null;
  28888. }
  28889. return td;
  28890. };
  28891. /**
  28892. * Scroll viewport to selection.
  28893. *
  28894. * @param {CellCoords} coords
  28895. */
  28896. TableView.prototype.scrollViewport = function (coords) {
  28897. this.wt.scrollViewport(coords);
  28898. };
  28899. /**
  28900. * Append row header to a TH element
  28901. * @param row
  28902. * @param TH
  28903. */
  28904. TableView.prototype.appendRowHeader = function (row, TH) {
  28905. if (TH.firstChild) {
  28906. var container = TH.firstChild;
  28907. if (!(0, _element.hasClass)(container, 'relative')) {
  28908. (0, _element.empty)(TH);
  28909. this.appendRowHeader(row, TH);
  28910. return;
  28911. }
  28912. this.updateCellHeader(container.querySelector('.rowHeader'), row, this.instance.getRowHeader);
  28913. } else {
  28914. var div = document.createElement('div');
  28915. var span = document.createElement('span');
  28916. div.className = 'relative';
  28917. span.className = 'rowHeader';
  28918. this.updateCellHeader(span, row, this.instance.getRowHeader);
  28919. div.appendChild(span);
  28920. TH.appendChild(div);
  28921. }
  28922. this.instance.runHooks('afterGetRowHeader', row, TH);
  28923. };
  28924. /**
  28925. * Append column header to a TH element
  28926. * @param col
  28927. * @param TH
  28928. */
  28929. TableView.prototype.appendColHeader = function (col, TH) {
  28930. if (TH.firstChild) {
  28931. var container = TH.firstChild;
  28932. if ((0, _element.hasClass)(container, 'relative')) {
  28933. this.updateCellHeader(container.querySelector('.colHeader'), col, this.instance.getColHeader);
  28934. } else {
  28935. (0, _element.empty)(TH);
  28936. this.appendColHeader(col, TH);
  28937. }
  28938. } else {
  28939. var div = document.createElement('div');
  28940. var span = document.createElement('span');
  28941. div.className = 'relative';
  28942. span.className = 'colHeader';
  28943. this.updateCellHeader(span, col, this.instance.getColHeader);
  28944. div.appendChild(span);
  28945. TH.appendChild(div);
  28946. }
  28947. this.instance.runHooks('afterGetColHeader', col, TH);
  28948. };
  28949. /**
  28950. * Update header cell content
  28951. *
  28952. * @since 0.15.0-beta4
  28953. * @param {HTMLElement} element Element to update
  28954. * @param {Number} index Row index or column index
  28955. * @param {Function} content Function which should be returns content for this cell
  28956. */
  28957. TableView.prototype.updateCellHeader = function (element, index, content) {
  28958. var renderedIndex = index;
  28959. var parentOverlay = this.wt.wtOverlays.getParentOverlay(element) || this.wt;
  28960. // prevent wrong calculations from SampleGenerator
  28961. if (element.parentNode) {
  28962. if ((0, _element.hasClass)(element, 'colHeader')) {
  28963. renderedIndex = parentOverlay.wtTable.columnFilter.sourceToRendered(index);
  28964. } else if ((0, _element.hasClass)(element, 'rowHeader')) {
  28965. renderedIndex = parentOverlay.wtTable.rowFilter.sourceToRendered(index);
  28966. }
  28967. }
  28968. if (renderedIndex > -1) {
  28969. (0, _element.fastInnerHTML)(element, content(index));
  28970. } else {
  28971. // workaround for https://github.com/handsontable/handsontable/issues/1946
  28972. (0, _element.fastInnerText)(element, String.fromCharCode(160));
  28973. (0, _element.addClass)(element, 'cornerHeader');
  28974. }
  28975. };
  28976. /**
  28977. * Given a element's left position relative to the viewport, returns maximum element width until the right
  28978. * edge of the viewport (before scrollbar)
  28979. *
  28980. * @param {Number} leftOffset
  28981. * @return {Number}
  28982. */
  28983. TableView.prototype.maximumVisibleElementWidth = function (leftOffset) {
  28984. var workspaceWidth = this.wt.wtViewport.getWorkspaceWidth();
  28985. var maxWidth = workspaceWidth - leftOffset;
  28986. return maxWidth > 0 ? maxWidth : 0;
  28987. };
  28988. /**
  28989. * Given a element's top position relative to the viewport, returns maximum element height until the bottom
  28990. * edge of the viewport (before scrollbar)
  28991. *
  28992. * @param {Number} topOffset
  28993. * @return {Number}
  28994. */
  28995. TableView.prototype.maximumVisibleElementHeight = function (topOffset) {
  28996. var workspaceHeight = this.wt.wtViewport.getWorkspaceHeight();
  28997. var maxHeight = workspaceHeight - topOffset;
  28998. return maxHeight > 0 ? maxHeight : 0;
  28999. };
  29000. TableView.prototype.mainViewIsActive = function () {
  29001. return this.wt === this.activeWt;
  29002. };
  29003. TableView.prototype.destroy = function () {
  29004. this.wt.destroy();
  29005. this.eventManager.destroy();
  29006. };
  29007. exports.default = TableView;
  29008. /***/ }),
  29009. /* 268 */
  29010. /***/ (function(module, exports, __webpack_require__) {
  29011. "use strict";
  29012. exports.__esModule = true;
  29013. 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; }; }();
  29014. var _object = __webpack_require__(2);
  29015. var _array = __webpack_require__(1);
  29016. var _number = __webpack_require__(5);
  29017. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  29018. /**
  29019. * @class DataSource
  29020. * @private
  29021. */
  29022. var DataSource = function () {
  29023. function DataSource(hotInstance) {
  29024. var dataSource = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  29025. _classCallCheck(this, DataSource);
  29026. /**
  29027. * Instance of Handsontable.
  29028. *
  29029. * @type {Handsontable}
  29030. */
  29031. this.hot = hotInstance;
  29032. /**
  29033. * Data source
  29034. *
  29035. * @type {Array}
  29036. */
  29037. this.data = dataSource;
  29038. /**
  29039. * Type of data source.
  29040. *
  29041. * @type {String}
  29042. * @default 'array'
  29043. */
  29044. this.dataType = 'array';
  29045. this.colToProp = function () {};
  29046. this.propToCol = function () {};
  29047. }
  29048. /**
  29049. * Get all data.
  29050. *
  29051. * @param {Boolean} [toArray=false] If `true` return source data as an array of arrays even when source data was provided
  29052. * in another format.
  29053. * @returns {Array}
  29054. */
  29055. _createClass(DataSource, [{
  29056. key: 'getData',
  29057. value: function getData() {
  29058. var toArray = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  29059. var result = this.data;
  29060. if (toArray) {
  29061. result = this.getByRange({ row: 0, col: 0 }, { row: Math.max(this.countRows() - 1, 0), col: Math.max(this.countColumns() - 1, 0) }, true);
  29062. }
  29063. return result;
  29064. }
  29065. /**
  29066. * Set new data source.
  29067. *
  29068. * @param data {Array}
  29069. */
  29070. }, {
  29071. key: 'setData',
  29072. value: function setData(data) {
  29073. this.data = data;
  29074. }
  29075. /**
  29076. * Returns array of column values from the data source. `column` is the index of the row in the data source.
  29077. *
  29078. * @param {Number} column Visual column index.
  29079. * @returns {Array}
  29080. */
  29081. }, {
  29082. key: 'getAtColumn',
  29083. value: function getAtColumn(column) {
  29084. var _this = this;
  29085. var result = [];
  29086. (0, _array.arrayEach)(this.data, function (row) {
  29087. var property = _this.colToProp(column);
  29088. if (typeof property === 'string') {
  29089. row = (0, _object.getProperty)(row, property);
  29090. } else {
  29091. row = row[property];
  29092. }
  29093. result.push(row);
  29094. });
  29095. return result;
  29096. }
  29097. /**
  29098. * 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.
  29099. *
  29100. * @param {Number} row Physical row index.
  29101. * @returns {Array|Object}
  29102. */
  29103. }, {
  29104. key: 'getAtRow',
  29105. value: function getAtRow(row) {
  29106. return this.data[row];
  29107. }
  29108. /**
  29109. * Returns a single value from the data.
  29110. *
  29111. * @param {Number} row Physical row index.
  29112. * @param {Number} column Visual column index.
  29113. * @returns {*}
  29114. */
  29115. }, {
  29116. key: 'getAtCell',
  29117. value: function getAtCell(row, column) {
  29118. var result = null;
  29119. var modifyRowData = this.hot.runHooks('modifyRowData', row);
  29120. var dataRow = isNaN(modifyRowData) ? modifyRowData : this.data[row];
  29121. if (dataRow) {
  29122. var prop = this.colToProp(column);
  29123. if (typeof prop === 'string') {
  29124. result = (0, _object.getProperty)(dataRow, prop);
  29125. } else if (typeof prop === 'function') {
  29126. result = prop(this.data.slice(row, row + 1)[0]);
  29127. } else {
  29128. result = dataRow[prop];
  29129. }
  29130. }
  29131. return result;
  29132. }
  29133. /**
  29134. * Returns source data by passed range.
  29135. *
  29136. * @param {Object} start Object with physical `row` and `col` keys (or visual column index, if data type is an array of objects).
  29137. * @param {Object} end Object with physical `row` and `col` keys (or visual column index, if data type is an array of objects).
  29138. * @param {Boolean} [toArray=false] If `true` return source data as an array of arrays even when source data was provided
  29139. * in another format.
  29140. * @returns {Array}
  29141. */
  29142. }, {
  29143. key: 'getByRange',
  29144. value: function getByRange(start, end) {
  29145. var _this2 = this;
  29146. var toArray = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  29147. var startRow = Math.min(start.row, end.row);
  29148. var startCol = Math.min(start.col, end.col);
  29149. var endRow = Math.max(start.row, end.row);
  29150. var endCol = Math.max(start.col, end.col);
  29151. var result = [];
  29152. (0, _number.rangeEach)(startRow, endRow, function (currentRow) {
  29153. var row = _this2.getAtRow(currentRow);
  29154. var newRow = void 0;
  29155. if (_this2.dataType === 'array') {
  29156. newRow = row.slice(startCol, endCol + 1);
  29157. } else if (_this2.dataType === 'object') {
  29158. newRow = toArray ? [] : {};
  29159. (0, _number.rangeEach)(startCol, endCol, function (column) {
  29160. var prop = _this2.colToProp(column);
  29161. if (toArray) {
  29162. newRow.push(row[prop]);
  29163. } else {
  29164. newRow[prop] = row[prop];
  29165. }
  29166. });
  29167. }
  29168. result.push(newRow);
  29169. });
  29170. return result;
  29171. }
  29172. /**
  29173. * Count number of rows.
  29174. *
  29175. * @returns {Number}
  29176. */
  29177. }, {
  29178. key: 'countRows',
  29179. value: function countRows() {
  29180. return Array.isArray(this.data) ? this.data.length : 0;
  29181. }
  29182. /**
  29183. * Count number of columns.
  29184. *
  29185. * @returns {Number}
  29186. */
  29187. }, {
  29188. key: 'countColumns',
  29189. value: function countColumns() {
  29190. var result = 0;
  29191. if (Array.isArray(this.data)) {
  29192. if (this.dataType === 'array') {
  29193. result = this.data[0].length;
  29194. } else if (this.dataType === 'object') {
  29195. result = Object.keys(this.data[0]).length;
  29196. }
  29197. }
  29198. return result;
  29199. }
  29200. /**
  29201. * Destroy instance.
  29202. */
  29203. }, {
  29204. key: 'destroy',
  29205. value: function destroy() {
  29206. this.data = null;
  29207. this.hot = null;
  29208. }
  29209. }]);
  29210. return DataSource;
  29211. }();
  29212. exports.default = DataSource;
  29213. /***/ }),
  29214. /* 269 */
  29215. /***/ (function(module, exports, __webpack_require__) {
  29216. "use strict";
  29217. exports.__esModule = true;
  29218. var _dictionary;
  29219. var _constants = __webpack_require__(7);
  29220. var C = _interopRequireWildcard(_constants);
  29221. 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; } }
  29222. 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; } /**
  29223. * @preserve
  29224. * Authors: Handsoncode
  29225. * Last updated: Nov 15, 2017
  29226. *
  29227. * Description: Definition file for English - United States language-country.
  29228. */
  29229. var dictionary = (_dictionary = {
  29230. languageCode: 'en-US'
  29231. }, _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);
  29232. exports.default = dictionary;
  29233. /***/ }),
  29234. /* 270 */
  29235. /***/ (function(module, exports, __webpack_require__) {
  29236. "use strict";
  29237. exports.__esModule = true;
  29238. exports.getPhraseFormatters = exports.registerPhraseFormatter = undefined;
  29239. exports.register = register;
  29240. exports.getAll = getAll;
  29241. var _staticRegister2 = __webpack_require__(39);
  29242. var _staticRegister3 = _interopRequireDefault(_staticRegister2);
  29243. var _pluralize = __webpack_require__(271);
  29244. var _pluralize2 = _interopRequireDefault(_pluralize);
  29245. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  29246. var _staticRegister = (0, _staticRegister3.default)('phraseFormatters'),
  29247. registerGloballyPhraseFormatter = _staticRegister.register,
  29248. getGlobalPhraseFormatters = _staticRegister.getValues;
  29249. /**
  29250. * Register phrase formatter.
  29251. *
  29252. * @param {String} name Name of formatter.
  29253. * @param {Function} formatterFn Function which will be applied on phrase propositions. It will transform them if it's possible.
  29254. */
  29255. function register(name, formatterFn) {
  29256. registerGloballyPhraseFormatter(name, formatterFn);
  29257. }
  29258. /**
  29259. * Get all registered previously formatters.
  29260. *
  29261. * @returns {Array}
  29262. */
  29263. function getAll() {
  29264. return getGlobalPhraseFormatters();
  29265. }
  29266. exports.registerPhraseFormatter = register;
  29267. exports.getPhraseFormatters = getAll;
  29268. register('pluralize', _pluralize2.default);
  29269. /***/ }),
  29270. /* 271 */
  29271. /***/ (function(module, exports, __webpack_require__) {
  29272. "use strict";
  29273. exports.__esModule = true;
  29274. exports.default = pluralize;
  29275. /**
  29276. * Try to choose plural form from available phrase propositions.
  29277. *
  29278. * @param {Array} phrasePropositions List of phrases propositions.
  29279. * @param {number} pluralForm Number determining which phrase form should be used.
  29280. *
  29281. * @returns {String|Array} One particular phrase if it's possible, list of unchanged phrase propositions otherwise.
  29282. */
  29283. function pluralize(phrasePropositions, pluralForm) {
  29284. var isPluralizable = Array.isArray(phrasePropositions) && Number.isInteger(pluralForm);
  29285. if (isPluralizable) {
  29286. return phrasePropositions[pluralForm];
  29287. }
  29288. return phrasePropositions;
  29289. };
  29290. /***/ }),
  29291. /* 272 */
  29292. /***/ (function(module, exports, __webpack_require__) {
  29293. "use strict";
  29294. exports.__esModule = true;
  29295. exports.Selection = exports.Highlight = exports.handleMouseEvent = undefined;
  29296. var _highlight = __webpack_require__(199);
  29297. var _highlight2 = _interopRequireDefault(_highlight);
  29298. var _selection = __webpack_require__(279);
  29299. var _selection2 = _interopRequireDefault(_selection);
  29300. var _mouseEventHandler = __webpack_require__(192);
  29301. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  29302. exports.handleMouseEvent = _mouseEventHandler.handleMouseEvent;
  29303. exports.Highlight = _highlight2.default;
  29304. exports.Selection = _selection2.default;
  29305. /***/ }),
  29306. /* 273 */
  29307. /***/ (function(module, exports, __webpack_require__) {
  29308. "use strict";
  29309. exports.__esModule = true;
  29310. exports.createHighlight = undefined;
  29311. var _staticRegister2 = __webpack_require__(39);
  29312. var _staticRegister3 = _interopRequireDefault(_staticRegister2);
  29313. var _activeHeader = __webpack_require__(274);
  29314. var _activeHeader2 = _interopRequireDefault(_activeHeader);
  29315. var _area = __webpack_require__(275);
  29316. var _area2 = _interopRequireDefault(_area);
  29317. var _cell = __webpack_require__(276);
  29318. var _cell2 = _interopRequireDefault(_cell);
  29319. var _fill = __webpack_require__(277);
  29320. var _fill2 = _interopRequireDefault(_fill);
  29321. var _header = __webpack_require__(278);
  29322. var _header2 = _interopRequireDefault(_header);
  29323. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  29324. /* eslint-disable import/prefer-default-export */
  29325. var _staticRegister = (0, _staticRegister3.default)('highlight/types'),
  29326. register = _staticRegister.register,
  29327. getItem = _staticRegister.getItem;
  29328. register('active-header', _activeHeader2.default);
  29329. register('area', _area2.default);
  29330. register('cell', _cell2.default);
  29331. register('fill', _fill2.default);
  29332. register('header', _header2.default);
  29333. function createHighlight(highlightType, options) {
  29334. return getItem(highlightType)(options);
  29335. }
  29336. exports.createHighlight = createHighlight;
  29337. /***/ }),
  29338. /* 274 */
  29339. /***/ (function(module, exports, __webpack_require__) {
  29340. "use strict";
  29341. exports.__esModule = true;
  29342. var _src = __webpack_require__(4);
  29343. /**
  29344. * @return {Selection}
  29345. */
  29346. function createHighlight(_ref) {
  29347. var activeHeaderClassName = _ref.activeHeaderClassName;
  29348. var s = new _src.Selection({
  29349. highlightHeaderClassName: activeHeaderClassName
  29350. });
  29351. return s;
  29352. }
  29353. exports.default = createHighlight;
  29354. /***/ }),
  29355. /* 275 */
  29356. /***/ (function(module, exports, __webpack_require__) {
  29357. "use strict";
  29358. exports.__esModule = true;
  29359. var _src = __webpack_require__(4);
  29360. /**
  29361. * Creates the new instance of Selection responsible for highlighting area of the selected multiple cells.
  29362. *
  29363. * @return {Selection}
  29364. */
  29365. function createHighlight(_ref) {
  29366. var layerLevel = _ref.layerLevel,
  29367. areaCornerVisible = _ref.areaCornerVisible;
  29368. var s = new _src.Selection({
  29369. className: 'area',
  29370. markIntersections: true,
  29371. layerLevel: Math.min(layerLevel, 7),
  29372. border: {
  29373. width: 1,
  29374. color: '#4b89ff',
  29375. cornerVisible: areaCornerVisible
  29376. }
  29377. });
  29378. return s;
  29379. }
  29380. exports.default = createHighlight;
  29381. /***/ }),
  29382. /* 276 */
  29383. /***/ (function(module, exports, __webpack_require__) {
  29384. "use strict";
  29385. exports.__esModule = true;
  29386. var _src = __webpack_require__(4);
  29387. /**
  29388. * Creates the new instance of Selection responsible for highlighting currently selected cell. This type of selection
  29389. * can present on the table only one at the time.
  29390. *
  29391. * @return {Selection}
  29392. */
  29393. function createHighlight(_ref) {
  29394. var cellCornerVisible = _ref.cellCornerVisible;
  29395. var s = new _src.Selection({
  29396. className: 'current',
  29397. border: {
  29398. width: 2,
  29399. color: '#4b89ff',
  29400. cornerVisible: cellCornerVisible
  29401. }
  29402. });
  29403. return s;
  29404. }
  29405. exports.default = createHighlight;
  29406. /***/ }),
  29407. /* 277 */
  29408. /***/ (function(module, exports, __webpack_require__) {
  29409. "use strict";
  29410. exports.__esModule = true;
  29411. var _src = __webpack_require__(4);
  29412. /**
  29413. * Creates the new instance of Selection, responsible for highlighting cells which are covered by fill handle
  29414. * functionality. This type of selection can present on the table only one at the time.
  29415. *
  29416. * @return {Selection}
  29417. */
  29418. function createHighlight() {
  29419. var s = new _src.Selection({
  29420. className: 'fill',
  29421. border: {
  29422. width: 1,
  29423. color: '#ff0000'
  29424. }
  29425. });
  29426. return s;
  29427. }
  29428. exports.default = createHighlight;
  29429. /***/ }),
  29430. /* 278 */
  29431. /***/ (function(module, exports, __webpack_require__) {
  29432. "use strict";
  29433. exports.__esModule = true;
  29434. var _src = __webpack_require__(4);
  29435. /**
  29436. * Creates the new instance of Selection, responsible for highlighting row and column headers. This type of selection
  29437. * can occur multiple times.
  29438. *
  29439. * @return {Selection}
  29440. */
  29441. function createHighlight(_ref) {
  29442. var headerClassName = _ref.headerClassName,
  29443. rowClassName = _ref.rowClassName,
  29444. columnClassName = _ref.columnClassName;
  29445. var s = new _src.Selection({
  29446. className: 'highlight',
  29447. highlightHeaderClassName: headerClassName,
  29448. highlightRowClassName: rowClassName,
  29449. highlightColumnClassName: columnClassName
  29450. });
  29451. return s;
  29452. }
  29453. exports.default = createHighlight;
  29454. /***/ }),
  29455. /* 279 */
  29456. /***/ (function(module, exports, __webpack_require__) {
  29457. "use strict";
  29458. exports.__esModule = true;
  29459. 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"); } }; }();
  29460. 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; }; }();
  29461. 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.']);
  29462. var _highlight = __webpack_require__(199);
  29463. var _highlight2 = _interopRequireDefault(_highlight);
  29464. var _range = __webpack_require__(280);
  29465. var _range2 = _interopRequireDefault(_range);
  29466. var _src = __webpack_require__(4);
  29467. var _keyStateObserver = __webpack_require__(198);
  29468. var _object = __webpack_require__(2);
  29469. var _mixed = __webpack_require__(16);
  29470. var _array = __webpack_require__(1);
  29471. var _localHooks = __webpack_require__(58);
  29472. var _localHooks2 = _interopRequireDefault(_localHooks);
  29473. var _transformation = __webpack_require__(281);
  29474. var _transformation2 = _interopRequireDefault(_transformation);
  29475. var _utils = __webpack_require__(91);
  29476. var _templateLiteralTag = __webpack_require__(41);
  29477. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  29478. function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
  29479. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  29480. /**
  29481. * @class Selection
  29482. * @util
  29483. */
  29484. var Selection = function () {
  29485. function Selection(settings, tableProps) {
  29486. var _this = this;
  29487. _classCallCheck(this, Selection);
  29488. /**
  29489. * Handsontable settings instance.
  29490. *
  29491. * @type {GridSettings}
  29492. */
  29493. this.settings = settings;
  29494. /**
  29495. * An additional object with dynamically defined properties which describes table state.
  29496. *
  29497. * @type {Object}
  29498. */
  29499. this.tableProps = tableProps;
  29500. /**
  29501. * The flag which determines if the selection is in progress.
  29502. *
  29503. * @type {Boolean}
  29504. */
  29505. this.inProgress = false;
  29506. /**
  29507. * The flag indicates that selection was performed by clicking the corner overlay.
  29508. *
  29509. * @type {Boolean}
  29510. */
  29511. this.selectedByCorner = false;
  29512. /**
  29513. * The collection of the selection layer levels where the whole row was selected using the row header.
  29514. *
  29515. * @type {Set.<Number>}
  29516. */
  29517. this.selectedByRowHeader = new Set();
  29518. /**
  29519. * The collection of the selection layer levels where the whole column was selected using the column header.
  29520. *
  29521. * @type {Set.<Number>}
  29522. */
  29523. this.selectedByColumnHeader = new Set();
  29524. /**
  29525. * Selection data layer.
  29526. *
  29527. * @type {SelectionRange}
  29528. */
  29529. this.selectedRange = new _range2.default();
  29530. /**
  29531. * Visualization layer.
  29532. *
  29533. * @type {Highlight}
  29534. */
  29535. this.highlight = new _highlight2.default({
  29536. headerClassName: settings.currentHeaderClassName,
  29537. activeHeaderClassName: settings.activeHeaderClassName,
  29538. rowClassName: settings.currentRowClassName,
  29539. columnClassName: settings.currentColClassName,
  29540. disableHighlight: this.settings.disableVisualSelection,
  29541. cellCornerVisible: function cellCornerVisible() {
  29542. return _this.isCellCornerVisible.apply(_this, arguments);
  29543. },
  29544. areaCornerVisible: function areaCornerVisible() {
  29545. return _this.isAreaCornerVisible.apply(_this, arguments);
  29546. }
  29547. });
  29548. /**
  29549. * The module for modifying coordinates.
  29550. *
  29551. * @type {Transformation}
  29552. */
  29553. this.transformation = new _transformation2.default(this.selectedRange, {
  29554. countRows: function countRows() {
  29555. return _this.tableProps.countRows();
  29556. },
  29557. countCols: function countCols() {
  29558. return _this.tableProps.countCols();
  29559. },
  29560. fixedRowsBottom: function fixedRowsBottom() {
  29561. return settings.fixedRowsBottom;
  29562. },
  29563. minSpareRows: function minSpareRows() {
  29564. return settings.minSpareRows;
  29565. },
  29566. minSpareCols: function minSpareCols() {
  29567. return settings.minSpareCols;
  29568. },
  29569. autoWrapRow: function autoWrapRow() {
  29570. return settings.autoWrapRow;
  29571. },
  29572. autoWrapCol: function autoWrapCol() {
  29573. return settings.autoWrapCol;
  29574. }
  29575. });
  29576. this.transformation.addLocalHook('beforeTransformStart', function () {
  29577. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  29578. args[_key] = arguments[_key];
  29579. }
  29580. return _this.runLocalHooks.apply(_this, ['beforeModifyTransformStart'].concat(args));
  29581. });
  29582. this.transformation.addLocalHook('afterTransformStart', function () {
  29583. for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  29584. args[_key2] = arguments[_key2];
  29585. }
  29586. return _this.runLocalHooks.apply(_this, ['afterModifyTransformStart'].concat(args));
  29587. });
  29588. this.transformation.addLocalHook('beforeTransformEnd', function () {
  29589. for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  29590. args[_key3] = arguments[_key3];
  29591. }
  29592. return _this.runLocalHooks.apply(_this, ['beforeModifyTransformEnd'].concat(args));
  29593. });
  29594. this.transformation.addLocalHook('afterTransformEnd', function () {
  29595. for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
  29596. args[_key4] = arguments[_key4];
  29597. }
  29598. return _this.runLocalHooks.apply(_this, ['afterModifyTransformEnd'].concat(args));
  29599. });
  29600. this.transformation.addLocalHook('insertRowRequire', function () {
  29601. for (var _len5 = arguments.length, args = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
  29602. args[_key5] = arguments[_key5];
  29603. }
  29604. return _this.runLocalHooks.apply(_this, ['insertRowRequire'].concat(args));
  29605. });
  29606. this.transformation.addLocalHook('insertColRequire', function () {
  29607. for (var _len6 = arguments.length, args = Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
  29608. args[_key6] = arguments[_key6];
  29609. }
  29610. return _this.runLocalHooks.apply(_this, ['insertColRequire'].concat(args));
  29611. });
  29612. }
  29613. /**
  29614. * Get data layer for current selection.
  29615. *
  29616. * @return {SelectionRange}
  29617. */
  29618. _createClass(Selection, [{
  29619. key: 'getSelectedRange',
  29620. value: function getSelectedRange() {
  29621. return this.selectedRange;
  29622. }
  29623. /**
  29624. * Indicate that selection process began. It sets internaly `.inProgress` property to `true`.
  29625. */
  29626. }, {
  29627. key: 'begin',
  29628. value: function begin() {
  29629. this.inProgress = true;
  29630. }
  29631. /**
  29632. * Indicate that selection process finished. It sets internaly `.inProgress` property to `false`.
  29633. */
  29634. }, {
  29635. key: 'finish',
  29636. value: function finish() {
  29637. this.runLocalHooks('afterSelectionFinished', Array.from(this.selectedRange));
  29638. this.inProgress = false;
  29639. }
  29640. /**
  29641. * Check if the process of selecting the cell/cells is in progress.
  29642. *
  29643. * @returns {Boolean}
  29644. */
  29645. }, {
  29646. key: 'isInProgress',
  29647. value: function isInProgress() {
  29648. return this.inProgress;
  29649. }
  29650. /**
  29651. * Starts selection range on given coordinate object.
  29652. *
  29653. * @param {CellCoords} coords Visual coords.
  29654. * @param {Boolean} [multipleSelection] If `true`, selection will be worked in 'multiple' mode. This option works
  29655. * only when 'selectionMode' is set as 'multiple'. If the argument is not defined
  29656. * the default trigger will be used (isPressedCtrlKey() helper).
  29657. * @param {Boolean} [fragment=false] If `true`, the selection will be treated as a partial selection where the
  29658. * `setRangeEnd` method won't be called on every `setRangeStart` call.
  29659. */
  29660. }, {
  29661. key: 'setRangeStart',
  29662. value: function setRangeStart(coords, multipleSelection) {
  29663. var fragment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  29664. var isMultipleMode = this.settings.selectionMode === 'multiple';
  29665. var isMultipleSelection = (0, _mixed.isUndefined)(multipleSelection) ? (0, _keyStateObserver.isPressedCtrlKey)() : multipleSelection;
  29666. var isRowNegative = coords.row < 0;
  29667. var isColumnNegative = coords.col < 0;
  29668. var selectedByCorner = isRowNegative && isColumnNegative;
  29669. if (isRowNegative) {
  29670. coords.row = 0;
  29671. }
  29672. if (isColumnNegative) {
  29673. coords.col = 0;
  29674. }
  29675. this.selectedByCorner = selectedByCorner;
  29676. this.runLocalHooks('beforeSetRangeStart' + (fragment ? 'Only' : ''), coords);
  29677. if (!isMultipleMode || isMultipleMode && !isMultipleSelection && (0, _mixed.isUndefined)(multipleSelection)) {
  29678. this.selectedRange.clear();
  29679. }
  29680. this.selectedRange.add(coords);
  29681. if (this.getLayerLevel() === 0) {
  29682. this.selectedByRowHeader.clear();
  29683. this.selectedByColumnHeader.clear();
  29684. }
  29685. if (!selectedByCorner && isColumnNegative) {
  29686. this.selectedByRowHeader.add(this.getLayerLevel());
  29687. }
  29688. if (!selectedByCorner && isRowNegative) {
  29689. this.selectedByColumnHeader.add(this.getLayerLevel());
  29690. }
  29691. if (!fragment) {
  29692. this.setRangeEnd(coords);
  29693. }
  29694. }
  29695. /**
  29696. * Starts selection range on given coordinate object.
  29697. *
  29698. * @param {CellCoords} coords Visual coords.
  29699. * @param {Boolean} [multipleSelection] If `true`, selection will be worked in 'multiple' mode. This option works
  29700. * only when 'selectionMode' is set as 'multiple'. If the argument is not defined
  29701. * the default trigger will be used (isPressedCtrlKey() helper).
  29702. */
  29703. }, {
  29704. key: 'setRangeStartOnly',
  29705. value: function setRangeStartOnly(coords, multipleSelection) {
  29706. this.setRangeStart(coords, multipleSelection, true);
  29707. }
  29708. /**
  29709. * Ends selection range on given coordinate object.
  29710. *
  29711. * @param {CellCoords} coords Visual coords.
  29712. */
  29713. }, {
  29714. key: 'setRangeEnd',
  29715. value: function setRangeEnd(coords) {
  29716. if (this.selectedRange.isEmpty()) {
  29717. return;
  29718. }
  29719. this.runLocalHooks('beforeSetRangeEnd', coords);
  29720. this.begin();
  29721. var cellRange = this.selectedRange.current();
  29722. if (this.settings.selectionMode !== 'single') {
  29723. cellRange.setTo(new _src.CellCoords(coords.row, coords.col));
  29724. }
  29725. // Set up current selection.
  29726. this.highlight.getCell().clear();
  29727. if (this.highlight.isEnabledFor(_highlight.CELL_TYPE)) {
  29728. this.highlight.getCell().add(this.selectedRange.current().highlight);
  29729. }
  29730. var layerLevel = this.getLayerLevel();
  29731. // If the next layer level is lower than previous then clear all area and header highlights. This is the
  29732. // indication that the new selection is performing.
  29733. if (layerLevel < this.highlight.layerLevel) {
  29734. (0, _array.arrayEach)(this.highlight.getAreas(), function (highlight) {
  29735. return void highlight.clear();
  29736. });
  29737. (0, _array.arrayEach)(this.highlight.getHeaders(), function (highlight) {
  29738. return void highlight.clear();
  29739. });
  29740. (0, _array.arrayEach)(this.highlight.getActiveHeaders(), function (highlight) {
  29741. return void highlight.clear();
  29742. });
  29743. }
  29744. this.highlight.useLayerLevel(layerLevel);
  29745. var areaHighlight = this.highlight.createOrGetArea();
  29746. var headerHighlight = this.highlight.createOrGetHeader();
  29747. var activeHeaderHighlight = this.highlight.createOrGetActiveHeader();
  29748. areaHighlight.clear();
  29749. headerHighlight.clear();
  29750. activeHeaderHighlight.clear();
  29751. if (this.highlight.isEnabledFor(_highlight.AREA_TYPE) && (this.isMultiple() || layerLevel >= 1)) {
  29752. areaHighlight.add(cellRange.from).add(cellRange.to);
  29753. if (layerLevel === 1) {
  29754. // For single cell selection in the same layer, we do not create area selection to prevent blue background.
  29755. // When non-consecutive selection is performed we have to add that missing area selection to the previous layer
  29756. // based on previous coordinates. It only occurs when the previous selection wasn't select multiple cells.
  29757. this.highlight.useLayerLevel(layerLevel - 1).createOrGetArea().add(this.selectedRange.previous().from);
  29758. this.highlight.useLayerLevel(layerLevel);
  29759. }
  29760. }
  29761. if (this.highlight.isEnabledFor(_highlight.HEADER_TYPE)) {
  29762. if (this.settings.selectionMode === 'single') {
  29763. headerHighlight.add(cellRange.highlight);
  29764. } else {
  29765. headerHighlight.add(cellRange.from).add(cellRange.to);
  29766. }
  29767. }
  29768. if (this.isSelectedByRowHeader()) {
  29769. var isRowSelected = this.tableProps.countCols() === cellRange.getWidth();
  29770. // Make sure that the whole row is selected (in case where selectionMode is set to 'single')
  29771. if (isRowSelected) {
  29772. activeHeaderHighlight.add(new _src.CellCoords(cellRange.from.row, -1)).add(new _src.CellCoords(cellRange.to.row, -1));
  29773. }
  29774. }
  29775. if (this.isSelectedByColumnHeader()) {
  29776. var isColumnSelected = this.tableProps.countRows() === cellRange.getHeight();
  29777. // Make sure that the whole column is selected (in case where selectionMode is set to 'single')
  29778. if (isColumnSelected) {
  29779. activeHeaderHighlight.add(new _src.CellCoords(-1, cellRange.from.col)).add(new _src.CellCoords(-1, cellRange.to.col));
  29780. }
  29781. }
  29782. this.runLocalHooks('afterSetRangeEnd', coords);
  29783. }
  29784. /**
  29785. * Returns information if we have a multiselection. This method check multiselection only on the latest layer of
  29786. * the selection.
  29787. *
  29788. * @returns {Boolean}
  29789. */
  29790. }, {
  29791. key: 'isMultiple',
  29792. value: function isMultiple() {
  29793. var isMultipleListener = (0, _object.createObjectPropListener)(!this.selectedRange.current().isSingle());
  29794. this.runLocalHooks('afterIsMultipleSelection', isMultipleListener);
  29795. return isMultipleListener.value;
  29796. }
  29797. /**
  29798. * Selects cell relative to the current cell (if possible).
  29799. *
  29800. * @param {Number} rowDelta Rows number to move, value can be passed as negative number.
  29801. * @param {Number} colDelta Columns number to move, value can be passed as negative number.
  29802. * @param {Boolean} force If `true` the new rows/columns will be created if necessary. Otherwise, row/column will
  29803. * be created according to `minSpareRows/minSpareCols` settings of Handsontable.
  29804. */
  29805. }, {
  29806. key: 'transformStart',
  29807. value: function transformStart(rowDelta, colDelta, force) {
  29808. this.setRangeStart(this.transformation.transformStart(rowDelta, colDelta, force));
  29809. }
  29810. /**
  29811. * Sets selection end cell relative to the current selection end cell (if possible).
  29812. *
  29813. * @param {Number} rowDelta Rows number to move, value can be passed as negative number.
  29814. * @param {Number} colDelta Columns number to move, value can be passed as negative number.
  29815. */
  29816. }, {
  29817. key: 'transformEnd',
  29818. value: function transformEnd(rowDelta, colDelta) {
  29819. this.setRangeEnd(this.transformation.transformEnd(rowDelta, colDelta));
  29820. }
  29821. /**
  29822. * Returns currently used layer level.
  29823. *
  29824. * @return {Number} Returns layer level starting from 0. If no selection was added to the table -1 is returned.
  29825. */
  29826. }, {
  29827. key: 'getLayerLevel',
  29828. value: function getLayerLevel() {
  29829. return this.selectedRange.size() - 1;
  29830. }
  29831. /**
  29832. * Returns `true` if currently there is a selection on the screen, `false` otherwise.
  29833. *
  29834. * @returns {Boolean}
  29835. */
  29836. }, {
  29837. key: 'isSelected',
  29838. value: function isSelected() {
  29839. return !this.selectedRange.isEmpty();
  29840. }
  29841. /**
  29842. * Returns `true` if the selection was applied by clicking to the row header. If the `layerLevel`
  29843. * argument is passed then only that layer will be checked. Otherwise, it checks if any row header
  29844. * was clicked on any selection layer level.
  29845. *
  29846. * @param {Number} [layerLevel=this.getLayerLevel()] Selection layer level to check.
  29847. * @return {Boolean}
  29848. */
  29849. }, {
  29850. key: 'isSelectedByRowHeader',
  29851. value: function isSelectedByRowHeader() {
  29852. var layerLevel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getLayerLevel();
  29853. return layerLevel === -1 ? this.selectedByRowHeader.size > 0 : this.selectedByRowHeader.has(layerLevel);
  29854. }
  29855. /**
  29856. * Returns `true` if the selection was applied by clicking to the column header. If the `layerLevel`
  29857. * argument is passed then only that layer will be checked. Otherwise, it checks if any column header
  29858. * was clicked on any selection layer level.
  29859. *
  29860. * @param {Number} [layerLevel=this.getLayerLevel()] Selection layer level to check.
  29861. * @return {Boolean}
  29862. */
  29863. }, {
  29864. key: 'isSelectedByColumnHeader',
  29865. value: function isSelectedByColumnHeader() {
  29866. var layerLevel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getLayerLevel();
  29867. return layerLevel === -1 ? this.selectedByColumnHeader.size > 0 : this.selectedByColumnHeader.has(layerLevel);
  29868. }
  29869. /**
  29870. * Returns `true` if the selection was applied by clicking on the row or column header on any layer level.
  29871. *
  29872. * @return {Boolean}
  29873. */
  29874. }, {
  29875. key: 'isSelectedByAnyHeader',
  29876. value: function isSelectedByAnyHeader() {
  29877. return this.isSelectedByRowHeader(-1) || this.isSelectedByColumnHeader(-1);
  29878. }
  29879. /**
  29880. * Returns `true` if the selection was applied by clicking on the left-top corner overlay.
  29881. *
  29882. * @return {Boolean}
  29883. */
  29884. }, {
  29885. key: 'isSelectedByCorner',
  29886. value: function isSelectedByCorner() {
  29887. return this.selectedByCorner;
  29888. }
  29889. /**
  29890. * Returns `true` if coords is within selection coords. This method iterates through all selection layers to check if
  29891. * the coords object is within selection range.
  29892. *
  29893. * @param {CellCoords} coords The CellCoords instance with defined visual coordinates.
  29894. * @returns {Boolean}
  29895. */
  29896. }, {
  29897. key: 'inInSelection',
  29898. value: function inInSelection(coords) {
  29899. return this.selectedRange.includes(coords);
  29900. }
  29901. /**
  29902. * Returns `true` if the cell corner should be visible.
  29903. *
  29904. * @private
  29905. * @return {Boolean} `true` if the corner element has to be visible, `false` otherwise.
  29906. */
  29907. }, {
  29908. key: 'isCellCornerVisible',
  29909. value: function isCellCornerVisible() {
  29910. return this.settings.fillHandle && !this.tableProps.isEditorOpened() && !this.isMultiple();
  29911. }
  29912. /**
  29913. * Returns `true` if the area corner should be visible.
  29914. *
  29915. * @param {Number} layerLevel The layer level.
  29916. * @return {Boolean} `true` if the corner element has to be visible, `false` otherwise.
  29917. */
  29918. }, {
  29919. key: 'isAreaCornerVisible',
  29920. value: function isAreaCornerVisible(layerLevel) {
  29921. if (Number.isInteger(layerLevel) && layerLevel !== this.getLayerLevel()) {
  29922. return false;
  29923. }
  29924. return this.settings.fillHandle && !this.tableProps.isEditorOpened() && this.isMultiple();
  29925. }
  29926. /**
  29927. * Clear the selection by resetting the collected ranges and highlights.
  29928. */
  29929. }, {
  29930. key: 'clear',
  29931. value: function clear() {
  29932. this.selectedRange.clear();
  29933. this.highlight.clear();
  29934. }
  29935. /**
  29936. * Deselects all selected cells.
  29937. */
  29938. }, {
  29939. key: 'deselect',
  29940. value: function deselect() {
  29941. if (!this.isSelected()) {
  29942. return;
  29943. }
  29944. this.inProgress = false;
  29945. this.clear();
  29946. this.runLocalHooks('afterDeselect');
  29947. }
  29948. /**
  29949. * Select all cells.
  29950. */
  29951. }, {
  29952. key: 'selectAll',
  29953. value: function selectAll() {
  29954. this.clear();
  29955. this.setRangeStart(new _src.CellCoords(-1, -1));
  29956. this.selectedByRowHeader.add(this.getLayerLevel());
  29957. this.selectedByColumnHeader.add(this.getLayerLevel());
  29958. this.setRangeEnd(new _src.CellCoords(this.tableProps.countRows() - 1, this.tableProps.countCols() - 1));
  29959. }
  29960. /**
  29961. * Make multiple, non-contiguous selection specified by `row` and `column` values or a range of cells
  29962. * finishing at `endRow`, `endColumn`. The method supports two input formats, first as an array of arrays such
  29963. * as `[[rowStart, columnStart, rowEnd, columnEnd]]` and second format as an array of CellRange objects.
  29964. * If the passed ranges have another format the exception will be thrown.
  29965. *
  29966. * @param {Array[]|CellRange[]} selectionRanges The coordinates which define what the cells should be selected.
  29967. * @return {Boolean} Returns `true` if selection was successful, `false` otherwise.
  29968. */
  29969. }, {
  29970. key: 'selectCells',
  29971. value: function selectCells(selectionRanges) {
  29972. var _this2 = this;
  29973. var selectionType = (0, _utils.detectSelectionType)(selectionRanges);
  29974. if (selectionType === _utils.SELECTION_TYPE_EMPTY) {
  29975. return false;
  29976. } else if (selectionType === _utils.SELECTION_TYPE_UNRECOGNIZED) {
  29977. throw new Error((0, _templateLiteralTag.toSingleLine)(_templateObject));
  29978. }
  29979. var selectionSchemaNormalizer = (0, _utils.normalizeSelectionFactory)(selectionType, {
  29980. propToCol: function propToCol(prop) {
  29981. return _this2.tableProps.propToCol(prop);
  29982. },
  29983. keepDirection: true
  29984. });
  29985. var countRows = this.tableProps.countRows();
  29986. var countCols = this.tableProps.countCols();
  29987. // Check if every layer of the coordinates are valid.
  29988. var isValid = !selectionRanges.some(function (selection) {
  29989. var _selectionSchemaNorma = selectionSchemaNormalizer(selection),
  29990. _selectionSchemaNorma2 = _slicedToArray(_selectionSchemaNorma, 4),
  29991. rowStart = _selectionSchemaNorma2[0],
  29992. columnStart = _selectionSchemaNorma2[1],
  29993. rowEnd = _selectionSchemaNorma2[2],
  29994. columnEnd = _selectionSchemaNorma2[3];
  29995. var _isValid = (0, _utils.isValidCoord)(rowStart, countRows) && (0, _utils.isValidCoord)(columnStart, countCols) && (0, _utils.isValidCoord)(rowEnd, countRows) && (0, _utils.isValidCoord)(columnEnd, countCols);
  29996. return !_isValid;
  29997. });
  29998. if (isValid) {
  29999. this.clear();
  30000. (0, _array.arrayEach)(selectionRanges, function (selection) {
  30001. var _selectionSchemaNorma3 = selectionSchemaNormalizer(selection),
  30002. _selectionSchemaNorma4 = _slicedToArray(_selectionSchemaNorma3, 4),
  30003. rowStart = _selectionSchemaNorma4[0],
  30004. columnStart = _selectionSchemaNorma4[1],
  30005. rowEnd = _selectionSchemaNorma4[2],
  30006. columnEnd = _selectionSchemaNorma4[3];
  30007. _this2.setRangeStartOnly(new _src.CellCoords(rowStart, columnStart), false);
  30008. _this2.setRangeEnd(new _src.CellCoords(rowEnd, columnEnd));
  30009. _this2.finish();
  30010. });
  30011. }
  30012. return isValid;
  30013. }
  30014. /**
  30015. * Select column specified by `startColumn` visual index or column property or a range of columns finishing at `endColumn`.
  30016. *
  30017. * @param {Number|String} startColumn Visual column index or column property from which the selection starts.
  30018. * @param {Number|String} [endColumn] Visual column index or column property from to the selection finishes.
  30019. * @returns {Boolean} Returns `true` if selection was successful, `false` otherwise.
  30020. */
  30021. }, {
  30022. key: 'selectColumns',
  30023. value: function selectColumns(startColumn) {
  30024. var endColumn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startColumn;
  30025. startColumn = typeof startColumn === 'string' ? this.tableProps.propToCol(startColumn) : startColumn;
  30026. endColumn = typeof endColumn === 'string' ? this.tableProps.propToCol(endColumn) : endColumn;
  30027. var countCols = this.tableProps.countCols();
  30028. var isValid = (0, _utils.isValidCoord)(startColumn, countCols) && (0, _utils.isValidCoord)(endColumn, countCols);
  30029. if (isValid) {
  30030. this.setRangeStartOnly(new _src.CellCoords(-1, startColumn));
  30031. this.setRangeEnd(new _src.CellCoords(this.tableProps.countRows() - 1, endColumn));
  30032. this.finish();
  30033. }
  30034. return isValid;
  30035. }
  30036. /**
  30037. * Select row specified by `startRow` visual index or a range of rows finishing at `endRow`.
  30038. *
  30039. * @param {Number} startRow Visual row index from which the selection starts.
  30040. * @param {Number} [endRow] Visual row index from to the selection finishes.
  30041. * @returns {Boolean} Returns `true` if selection was successful, `false` otherwise.
  30042. */
  30043. }, {
  30044. key: 'selectRows',
  30045. value: function selectRows(startRow) {
  30046. var endRow = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startRow;
  30047. var countRows = this.tableProps.countRows();
  30048. var isValid = (0, _utils.isValidCoord)(startRow, countRows) && (0, _utils.isValidCoord)(endRow, countRows);
  30049. if (isValid) {
  30050. this.setRangeStartOnly(new _src.CellCoords(startRow, -1));
  30051. this.setRangeEnd(new _src.CellCoords(endRow, this.tableProps.countCols() - 1));
  30052. this.finish();
  30053. }
  30054. return isValid;
  30055. }
  30056. }]);
  30057. return Selection;
  30058. }();
  30059. (0, _object.mixin)(Selection, _localHooks2.default);
  30060. exports.default = Selection;
  30061. /***/ }),
  30062. /* 280 */
  30063. /***/ (function(module, exports, __webpack_require__) {
  30064. "use strict";
  30065. exports.__esModule = true;
  30066. 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; }; }();
  30067. var _src = __webpack_require__(4);
  30068. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  30069. /**
  30070. * The SelectionRange class is a simple CellRanges collection designed for easy manipulation of the multiple
  30071. * consecutive and non-consecutive selections.
  30072. *
  30073. * @class SelectionRange
  30074. * @util
  30075. */
  30076. var SelectionRange = function () {
  30077. function SelectionRange() {
  30078. _classCallCheck(this, SelectionRange);
  30079. /**
  30080. * List of all CellRanges added to the class instance.
  30081. *
  30082. * @type {CellRange[]}
  30083. */
  30084. this.ranges = [];
  30085. }
  30086. /**
  30087. * Check if selected range is empty.
  30088. *
  30089. * @return {Boolean}
  30090. */
  30091. _createClass(SelectionRange, [{
  30092. key: 'isEmpty',
  30093. value: function isEmpty() {
  30094. return this.size() === 0;
  30095. }
  30096. /**
  30097. * Set coordinates to the class instance. It clears all previously added coordinates and push `coords`
  30098. * to the collection.
  30099. *
  30100. * @param {CellCoords} coords The CellCoords instance with defined visual coordinates.
  30101. * @returns {SelectionRange}
  30102. */
  30103. }, {
  30104. key: 'set',
  30105. value: function set(coords) {
  30106. this.clear();
  30107. this.ranges.push(new _src.CellRange(coords));
  30108. return this;
  30109. }
  30110. /**
  30111. * Add coordinates to the class instance. The new coordinates are added to the end of the range collection.
  30112. *
  30113. * @param {CellCoords} coords The CellCoords instance with defined visual coordinates.
  30114. * @returns {SelectionRange}
  30115. */
  30116. }, {
  30117. key: 'add',
  30118. value: function add(coords) {
  30119. this.ranges.push(new _src.CellRange(coords));
  30120. return this;
  30121. }
  30122. /**
  30123. * Get last added coordinates from ranges, it returns a CellRange instance.
  30124. *
  30125. * @return {CellRange|undefined}
  30126. */
  30127. }, {
  30128. key: 'current',
  30129. value: function current() {
  30130. return this.peekByIndex(0);
  30131. }
  30132. /**
  30133. * Get previously added coordinates from ranges, it returns a CellRange instance.
  30134. *
  30135. * @return {CellRange|undefined}
  30136. */
  30137. }, {
  30138. key: 'previous',
  30139. value: function previous() {
  30140. return this.peekByIndex(-1);
  30141. }
  30142. /**
  30143. * Returns `true` if coords is within selection coords. This method iterates through all selection layers to check if
  30144. * the coords object is within selection range.
  30145. *
  30146. * @param {CellCoords} coords The CellCoords instance with defined visual coordinates.
  30147. * @returns {Boolean}
  30148. */
  30149. }, {
  30150. key: 'includes',
  30151. value: function includes(coords) {
  30152. return this.ranges.some(function (cellRange) {
  30153. return cellRange.includes(coords);
  30154. });
  30155. }
  30156. /**
  30157. * Clear collection.
  30158. *
  30159. * @return {SelectionRange}
  30160. */
  30161. }, {
  30162. key: 'clear',
  30163. value: function clear() {
  30164. this.ranges.length = 0;
  30165. return this;
  30166. }
  30167. /**
  30168. * Get count of added all coordinates added to the selection.
  30169. *
  30170. * @return {Number}
  30171. */
  30172. }, {
  30173. key: 'size',
  30174. value: function size() {
  30175. return this.ranges.length;
  30176. }
  30177. /**
  30178. * Peek the coordinates based on the offset where that coordinate resides in the collection.
  30179. *
  30180. * @param {Number} [offset=0] An offset where the coordinate will be retrieved from.
  30181. * @return {CellRange|undefined}
  30182. */
  30183. }, {
  30184. key: 'peekByIndex',
  30185. value: function peekByIndex() {
  30186. var offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  30187. var rangeIndex = this.size() + offset - 1;
  30188. var cellRange = void 0;
  30189. if (rangeIndex >= 0) {
  30190. cellRange = this.ranges[rangeIndex];
  30191. }
  30192. return cellRange;
  30193. }
  30194. }, {
  30195. key: Symbol.iterator,
  30196. value: function value() {
  30197. return this.ranges[Symbol.iterator]();
  30198. }
  30199. }]);
  30200. return SelectionRange;
  30201. }();
  30202. exports.default = SelectionRange;
  30203. /***/ }),
  30204. /* 281 */
  30205. /***/ (function(module, exports, __webpack_require__) {
  30206. "use strict";
  30207. exports.__esModule = true;
  30208. 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; }; }();
  30209. var _src = __webpack_require__(4);
  30210. var _object = __webpack_require__(2);
  30211. var _localHooks = __webpack_require__(58);
  30212. var _localHooks2 = _interopRequireDefault(_localHooks);
  30213. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  30214. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  30215. /**
  30216. * The Transformation class implements algorithms for transforming coordinates based on current settings
  30217. * passed to the Handsontable.
  30218. *
  30219. * Transformation is always applied relative to the current selection.
  30220. *
  30221. * @class Transformation
  30222. * @util
  30223. */
  30224. var Transformation = function () {
  30225. function Transformation(range, options) {
  30226. _classCallCheck(this, Transformation);
  30227. /**
  30228. * Instance of the SelectionRange, holder for coordinates applied to the table.
  30229. *
  30230. * @type {SelectionRange}
  30231. */
  30232. this.range = range;
  30233. /**
  30234. * Additional options which define the state of the settings which can infer transformation.
  30235. *
  30236. * @type {Object}
  30237. */
  30238. this.options = options;
  30239. }
  30240. /**
  30241. * Selects cell relative to current cell (if possible).
  30242. *
  30243. * @param {Number} rowDelta Rows number to move, value can be passed as negative number.
  30244. * @param {Number} colDelta Columns number to move, value can be passed as negative number.
  30245. * @param {Boolean} force If `true` the new rows/columns will be created if necessary. Otherwise, row/column will
  30246. * be created according to `minSpareRows/minSpareCols` settings of Handsontable.
  30247. * @returns {CellCoords}
  30248. */
  30249. _createClass(Transformation, [{
  30250. key: 'transformStart',
  30251. value: function transformStart(rowDelta, colDelta, force) {
  30252. var delta = new _src.CellCoords(rowDelta, colDelta);
  30253. this.runLocalHooks('beforeTransformStart', delta);
  30254. var totalRows = this.options.countRows();
  30255. var totalCols = this.options.countCols();
  30256. var fixedRowsBottom = this.options.fixedRowsBottom();
  30257. var minSpareRows = this.options.minSpareRows();
  30258. var minSpareCols = this.options.minSpareCols();
  30259. var autoWrapRow = this.options.autoWrapRow();
  30260. var autoWrapCol = this.options.autoWrapCol();
  30261. var highlightCoords = this.range.current().highlight;
  30262. if (highlightCoords.row + rowDelta > totalRows - 1) {
  30263. if (force && minSpareRows > 0 && !(fixedRowsBottom && highlightCoords.row >= totalRows - fixedRowsBottom - 1)) {
  30264. this.runLocalHooks('insertRowRequire', totalRows);
  30265. totalRows = this.options.countRows();
  30266. } else if (autoWrapCol) {
  30267. delta.row = 1 - totalRows;
  30268. delta.col = highlightCoords.col + delta.col == totalCols - 1 ? 1 - totalCols : 1;
  30269. }
  30270. } else if (autoWrapCol && highlightCoords.row + delta.row < 0 && highlightCoords.col + delta.col >= 0) {
  30271. delta.row = totalRows - 1;
  30272. delta.col = highlightCoords.col + delta.col == 0 ? totalCols - 1 : -1;
  30273. }
  30274. if (highlightCoords.col + delta.col > totalCols - 1) {
  30275. if (force && minSpareCols > 0) {
  30276. this.runLocalHooks('insertColRequire', totalRows);
  30277. totalCols = this.options.countCols();
  30278. } else if (autoWrapRow) {
  30279. delta.row = highlightCoords.row + delta.row == totalRows - 1 ? 1 - totalRows : 1;
  30280. delta.col = 1 - totalCols;
  30281. }
  30282. } else if (autoWrapRow && highlightCoords.col + delta.col < 0 && highlightCoords.row + delta.row >= 0) {
  30283. delta.row = highlightCoords.row + delta.row == 0 ? totalRows - 1 : -1;
  30284. delta.col = totalCols - 1;
  30285. }
  30286. var coords = new _src.CellCoords(highlightCoords.row + delta.row, highlightCoords.col + delta.col);
  30287. var rowTransformDir = 0;
  30288. var colTransformDir = 0;
  30289. if (coords.row < 0) {
  30290. rowTransformDir = -1;
  30291. coords.row = 0;
  30292. } else if (coords.row > 0 && coords.row >= totalRows) {
  30293. rowTransformDir = 1;
  30294. coords.row = totalRows - 1;
  30295. }
  30296. if (coords.col < 0) {
  30297. colTransformDir = -1;
  30298. coords.col = 0;
  30299. } else if (coords.col > 0 && coords.col >= totalCols) {
  30300. colTransformDir = 1;
  30301. coords.col = totalCols - 1;
  30302. }
  30303. this.runLocalHooks('afterTransformStart', coords, rowTransformDir, colTransformDir);
  30304. return coords;
  30305. }
  30306. /**
  30307. * Sets selection end cell relative to current selection end cell (if possible).
  30308. *
  30309. * @param {Number} rowDelta Rows number to move, value can be passed as negative number.
  30310. * @param {Number} colDelta Columns number to move, value can be passed as negative number.
  30311. * @returns {CellCoords}
  30312. */
  30313. }, {
  30314. key: 'transformEnd',
  30315. value: function transformEnd(rowDelta, colDelta) {
  30316. var delta = new _src.CellCoords(rowDelta, colDelta);
  30317. this.runLocalHooks('beforeTransformEnd', delta);
  30318. var totalRows = this.options.countRows();
  30319. var totalCols = this.options.countCols();
  30320. var cellRange = this.range.current();
  30321. var coords = new _src.CellCoords(cellRange.to.row + delta.row, cellRange.to.col + delta.col);
  30322. var rowTransformDir = 0;
  30323. var colTransformDir = 0;
  30324. if (coords.row < 0) {
  30325. rowTransformDir = -1;
  30326. coords.row = 0;
  30327. } else if (coords.row > 0 && coords.row >= totalRows) {
  30328. rowTransformDir = 1;
  30329. coords.row = totalRows - 1;
  30330. }
  30331. if (coords.col < 0) {
  30332. colTransformDir = -1;
  30333. coords.col = 0;
  30334. } else if (coords.col > 0 && coords.col >= totalCols) {
  30335. colTransformDir = 1;
  30336. coords.col = totalCols - 1;
  30337. }
  30338. this.runLocalHooks('afterTransformEnd', coords, rowTransformDir, colTransformDir);
  30339. return coords;
  30340. }
  30341. }]);
  30342. return Transformation;
  30343. }();
  30344. (0, _object.mixin)(Transformation, _localHooks2.default);
  30345. exports.default = Transformation;
  30346. /***/ }),
  30347. /* 282 */
  30348. /***/ (function(module, exports, __webpack_require__) {
  30349. "use strict";
  30350. exports.__esModule = true;
  30351. exports.default = jQueryWrapper;
  30352. function jQueryWrapper(Handsontable) {
  30353. var jQuery = typeof window === 'undefined' ? false : window.jQuery;
  30354. if (!jQuery) {
  30355. return;
  30356. }
  30357. jQuery.fn.handsontable = function (action) {
  30358. var $this = this.first(); // Use only first element from list
  30359. var instance = $this.data('handsontable');
  30360. // Init case
  30361. if (typeof action !== 'string') {
  30362. var userSettings = action || {};
  30363. if (instance) {
  30364. instance.updateSettings(userSettings);
  30365. } else {
  30366. instance = new Handsontable.Core($this[0], userSettings);
  30367. $this.data('handsontable', instance);
  30368. instance.init();
  30369. }
  30370. return $this;
  30371. }
  30372. // Action case
  30373. var args = [];
  30374. var output = void 0;
  30375. if (arguments.length > 1) {
  30376. for (var i = 1, ilen = arguments.length; i < ilen; i++) {
  30377. args.push(arguments[i]);
  30378. }
  30379. }
  30380. if (instance) {
  30381. if (typeof instance[action] !== 'undefined') {
  30382. output = instance[action].apply(instance, args);
  30383. if (action === 'destroy') {
  30384. $this.removeData();
  30385. }
  30386. } else {
  30387. throw new Error('Handsontable do not provide action: ' + action);
  30388. }
  30389. }
  30390. return output;
  30391. };
  30392. };
  30393. /***/ }),
  30394. /* 283 */
  30395. /***/ (function(module, exports, __webpack_require__) {
  30396. "use strict";
  30397. exports.__esModule = true;
  30398. 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;
  30399. var _persistentState = __webpack_require__(284);
  30400. var _persistentState2 = _interopRequireDefault(_persistentState);
  30401. var _autoColumnSize = __webpack_require__(286);
  30402. var _autoColumnSize2 = _interopRequireDefault(_autoColumnSize);
  30403. var _autofill = __webpack_require__(287);
  30404. var _autofill2 = _interopRequireDefault(_autofill);
  30405. var _autoRowSize = __webpack_require__(289);
  30406. var _autoRowSize2 = _interopRequireDefault(_autoRowSize);
  30407. var _columnSorting = __webpack_require__(290);
  30408. var _columnSorting2 = _interopRequireDefault(_columnSorting);
  30409. var _comments = __webpack_require__(293);
  30410. var _comments2 = _interopRequireDefault(_comments);
  30411. var _contextMenu = __webpack_require__(297);
  30412. var _contextMenu2 = _interopRequireDefault(_contextMenu);
  30413. var _copyPaste = __webpack_require__(314);
  30414. var _copyPaste2 = _interopRequireDefault(_copyPaste);
  30415. var _customBorders = __webpack_require__(321);
  30416. var _customBorders2 = _interopRequireDefault(_customBorders);
  30417. var _dragToScroll = __webpack_require__(327);
  30418. var _dragToScroll2 = _interopRequireDefault(_dragToScroll);
  30419. var _manualColumnFreeze = __webpack_require__(328);
  30420. var _manualColumnFreeze2 = _interopRequireDefault(_manualColumnFreeze);
  30421. var _manualColumnMove = __webpack_require__(332);
  30422. var _manualColumnMove2 = _interopRequireDefault(_manualColumnMove);
  30423. var _manualColumnResize = __webpack_require__(337);
  30424. var _manualColumnResize2 = _interopRequireDefault(_manualColumnResize);
  30425. var _manualRowMove = __webpack_require__(338);
  30426. var _manualRowMove2 = _interopRequireDefault(_manualRowMove);
  30427. var _manualRowResize = __webpack_require__(343);
  30428. var _manualRowResize2 = _interopRequireDefault(_manualRowResize);
  30429. var _mergeCells = __webpack_require__(344);
  30430. var _mergeCells2 = _interopRequireDefault(_mergeCells);
  30431. var _multipleSelectionHandles = __webpack_require__(350);
  30432. var _multipleSelectionHandles2 = _interopRequireDefault(_multipleSelectionHandles);
  30433. var _observeChanges = __webpack_require__(351);
  30434. var _observeChanges2 = _interopRequireDefault(_observeChanges);
  30435. var _search = __webpack_require__(354);
  30436. var _search2 = _interopRequireDefault(_search);
  30437. var _touchScroll = __webpack_require__(355);
  30438. var _touchScroll2 = _interopRequireDefault(_touchScroll);
  30439. var _undoRedo = __webpack_require__(356);
  30440. var _undoRedo2 = _interopRequireDefault(_undoRedo);
  30441. var _base = __webpack_require__(10);
  30442. var _base2 = _interopRequireDefault(_base);
  30443. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  30444. exports.AutoColumnSize = _autoColumnSize2.default;
  30445. exports.AutoFill = _autofill2.default;
  30446. exports.AutoRowSize = _autoRowSize2.default;
  30447. exports.ColumnSorting = _columnSorting2.default;
  30448. exports.Comments = _comments2.default;
  30449. exports.ContextMenu = _contextMenu2.default;
  30450. exports.CopyPaste = _copyPaste2.default;
  30451. exports.CustomBorders = _customBorders2.default;
  30452. exports.DragToScroll = _dragToScroll2.default;
  30453. exports.ManualColumnFreeze = _manualColumnFreeze2.default;
  30454. exports.ManualColumnMove = _manualColumnMove2.default;
  30455. exports.ManualColumnResize = _manualColumnResize2.default;
  30456. exports.ManualRowMove = _manualRowMove2.default;
  30457. exports.ManualRowResize = _manualRowResize2.default;
  30458. exports.MergeCells = _mergeCells2.default;
  30459. exports.MultipleSelectionHandles = _multipleSelectionHandles2.default;
  30460. exports.ObserveChanges = _observeChanges2.default;
  30461. exports.PersistentState = _persistentState2.default;
  30462. exports.Search = _search2.default;
  30463. exports.TouchScroll = _touchScroll2.default;
  30464. exports.UndoRedo = _undoRedo2.default;
  30465. exports.Base = _base2.default;
  30466. /***/ }),
  30467. /* 284 */
  30468. /***/ (function(module, exports, __webpack_require__) {
  30469. "use strict";
  30470. exports.__esModule = true;
  30471. 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; }; }();
  30472. 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); } };
  30473. var _base = __webpack_require__(10);
  30474. var _base2 = _interopRequireDefault(_base);
  30475. var _plugins = __webpack_require__(8);
  30476. var _storage = __webpack_require__(285);
  30477. var _storage2 = _interopRequireDefault(_storage);
  30478. var _pluginHooks = __webpack_require__(15);
  30479. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  30480. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  30481. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  30482. 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; }
  30483. 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; }
  30484. _pluginHooks2.default.getSingleton().register('persistentStateSave');
  30485. _pluginHooks2.default.getSingleton().register('persistentStateLoad');
  30486. _pluginHooks2.default.getSingleton().register('persistentStateReset');
  30487. /**
  30488. * Save the state of column sorting, column positions and column sizes in local storage
  30489. * to preserve table state between page reloads.
  30490. *
  30491. * In order to enable data storage mechanism, persistentState option must be set to true.
  30492. *
  30493. * When persistentState is enabled it exposes 3 hooks:
  30494. *
  30495. * persistentStateSave (key: String, value: Mixed) -
  30496. * Saves value under given key in browser local storage.
  30497. *
  30498. * persistentStateLoad (key: String, saveTo: Object) -
  30499. * Loads value, saved under given key, form browser local storage.
  30500. * The loaded value will be saved in saveTo.value.
  30501. *
  30502. * persistentStateReset (key: String) -
  30503. * Clears the value saved under key.
  30504. * If no key is given, all values associated with table will be cleared.
  30505. *
  30506. * @plugin persistentState
  30507. */
  30508. var PersistentState = function (_BasePlugin) {
  30509. _inherits(PersistentState, _BasePlugin);
  30510. function PersistentState(hotInstance) {
  30511. _classCallCheck(this, PersistentState);
  30512. /**
  30513. * Instance of {@link Storage}.
  30514. *
  30515. * @type {Storage}
  30516. */
  30517. var _this = _possibleConstructorReturn(this, (PersistentState.__proto__ || Object.getPrototypeOf(PersistentState)).call(this, hotInstance));
  30518. _this.storage = void 0;
  30519. return _this;
  30520. }
  30521. /**
  30522. * Check if the plugin is enabled in the Handsontable settings.
  30523. *
  30524. * @returns {Boolean}
  30525. */
  30526. _createClass(PersistentState, [{
  30527. key: 'isEnabled',
  30528. value: function isEnabled() {
  30529. return !!this.hot.getSettings().persistentState;
  30530. }
  30531. /**
  30532. * Enable plugin for this Handsontable instance.
  30533. */
  30534. }, {
  30535. key: 'enablePlugin',
  30536. value: function enablePlugin() {
  30537. var _this2 = this;
  30538. if (this.enabled) {
  30539. return;
  30540. }
  30541. if (!this.storage) {
  30542. this.storage = new _storage2.default(this.hot.rootElement.id);
  30543. }
  30544. this.addHook('persistentStateSave', function (key, value) {
  30545. return _this2.saveValue(key, value);
  30546. });
  30547. this.addHook('persistentStateLoad', function (key, saveTo) {
  30548. return _this2.loadValue(key, saveTo);
  30549. });
  30550. this.addHook('persistentStateReset', function () {
  30551. return _this2.resetValue();
  30552. });
  30553. _get(PersistentState.prototype.__proto__ || Object.getPrototypeOf(PersistentState.prototype), 'enablePlugin', this).call(this);
  30554. }
  30555. /**
  30556. * Disable plugin for this Handsontable instance.
  30557. */
  30558. }, {
  30559. key: 'disablePlugin',
  30560. value: function disablePlugin() {
  30561. this.storage = void 0;
  30562. _get(PersistentState.prototype.__proto__ || Object.getPrototypeOf(PersistentState.prototype), 'disablePlugin', this).call(this);
  30563. }
  30564. /**
  30565. * Updates the plugin to use the latest options you have specified.
  30566. */
  30567. }, {
  30568. key: 'updatePlugin',
  30569. value: function updatePlugin() {
  30570. this.disablePlugin();
  30571. this.enablePlugin();
  30572. _get(PersistentState.prototype.__proto__ || Object.getPrototypeOf(PersistentState.prototype), 'updatePlugin', this).call(this);
  30573. }
  30574. /**
  30575. * Load value from localStorage.
  30576. *
  30577. * @param {String} key Key string.
  30578. * @param {Object} saveTo Saved value from browser local storage.
  30579. */
  30580. }, {
  30581. key: 'loadValue',
  30582. value: function loadValue(key, saveTo) {
  30583. saveTo.value = this.storage.loadValue(key);
  30584. }
  30585. /**
  30586. * Save data to localStorage.
  30587. *
  30588. * @param {String} key Key string.
  30589. * @param {Mixed} value Value to save.
  30590. */
  30591. }, {
  30592. key: 'saveValue',
  30593. value: function saveValue(key, value) {
  30594. this.storage.saveValue(key, value);
  30595. }
  30596. /**
  30597. * Reset given data or all data from localStorage.
  30598. *
  30599. * @param {String} key [optional] Key string.
  30600. */
  30601. }, {
  30602. key: 'resetValue',
  30603. value: function resetValue(key) {
  30604. if (typeof key === 'undefined') {
  30605. this.storage.resetAll();
  30606. } else {
  30607. this.storage.reset(key);
  30608. }
  30609. }
  30610. /**
  30611. * Destroy plugin instance.
  30612. */
  30613. }, {
  30614. key: 'destroy',
  30615. value: function destroy() {
  30616. _get(PersistentState.prototype.__proto__ || Object.getPrototypeOf(PersistentState.prototype), 'destroy', this).call(this);
  30617. }
  30618. }]);
  30619. return PersistentState;
  30620. }(_base2.default);
  30621. (0, _plugins.registerPlugin)('persistentState', PersistentState);
  30622. exports.default = PersistentState;
  30623. /***/ }),
  30624. /* 285 */
  30625. /***/ (function(module, exports, __webpack_require__) {
  30626. "use strict";
  30627. exports.__esModule = true;
  30628. 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; }; }();
  30629. var _array = __webpack_require__(1);
  30630. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  30631. /**
  30632. * @class Storage
  30633. * @plugin PersistentState
  30634. */
  30635. var Storage = function () {
  30636. function Storage(prefix) {
  30637. _classCallCheck(this, Storage);
  30638. /**
  30639. * Prefix for key (id element).
  30640. *
  30641. * @type {String}
  30642. */
  30643. this.prefix = prefix;
  30644. /**
  30645. * Saved keys.
  30646. *
  30647. * @type {Array}
  30648. */
  30649. this.savedKeys = [];
  30650. this.loadSavedKeys();
  30651. }
  30652. /**
  30653. * Save data to localStorage.
  30654. *
  30655. * @param {String} key Key string.
  30656. * @param {Mixed} value Value to save.
  30657. */
  30658. _createClass(Storage, [{
  30659. key: 'saveValue',
  30660. value: function saveValue(key, value) {
  30661. window.localStorage.setItem(this.prefix + '_' + key, JSON.stringify(value));
  30662. if (this.savedKeys.indexOf(key) === -1) {
  30663. this.savedKeys.push(key);
  30664. this.saveSavedKeys();
  30665. }
  30666. }
  30667. /**
  30668. * Load data from localStorage.
  30669. *
  30670. * @param {String} key Key string.
  30671. * @param {Object} defaultValue Object containing the loaded data.
  30672. *
  30673. * @returns {}
  30674. */
  30675. }, {
  30676. key: 'loadValue',
  30677. value: function loadValue(key, defaultValue) {
  30678. key = typeof key === 'undefined' ? defaultValue : key;
  30679. var value = window.localStorage.getItem(this.prefix + '_' + key);
  30680. return value === null ? void 0 : JSON.parse(value);
  30681. }
  30682. /**
  30683. * Reset given data from localStorage.
  30684. *
  30685. * @param {String} key Key string.
  30686. */
  30687. }, {
  30688. key: 'reset',
  30689. value: function reset(key) {
  30690. window.localStorage.removeItem(this.prefix + '_' + key);
  30691. }
  30692. /**
  30693. * Reset all data from localStorage.
  30694. *
  30695. */
  30696. }, {
  30697. key: 'resetAll',
  30698. value: function resetAll() {
  30699. var _this = this;
  30700. (0, _array.arrayEach)(this.savedKeys, function (value, index) {
  30701. window.localStorage.removeItem(_this.prefix + '_' + _this.savedKeys[index]);
  30702. });
  30703. this.clearSavedKeys();
  30704. }
  30705. /**
  30706. * Load and save all keys from localStorage.
  30707. *
  30708. * @private
  30709. */
  30710. }, {
  30711. key: 'loadSavedKeys',
  30712. value: function loadSavedKeys() {
  30713. var keysJSON = window.localStorage.getItem(this.prefix + '__persistentStateKeys');
  30714. var keys = typeof keysJSON === 'string' ? JSON.parse(keysJSON) : void 0;
  30715. this.savedKeys = keys ? keys : [];
  30716. }
  30717. }, {
  30718. key: 'saveSavedKeys',
  30719. /**
  30720. * Save saved key in localStorage.
  30721. *
  30722. * @private
  30723. */
  30724. value: function saveSavedKeys() {
  30725. window.localStorage.setItem(this.prefix + '__persistentStateKeys', JSON.stringify(this.savedKeys));
  30726. }
  30727. }, {
  30728. key: 'clearSavedKeys',
  30729. /**
  30730. * Clear saved key from localStorage.
  30731. *
  30732. * @private
  30733. */
  30734. value: function clearSavedKeys() {
  30735. this.savedKeys.length = 0;
  30736. this.saveSavedKeys();
  30737. }
  30738. }]);
  30739. return Storage;
  30740. }();
  30741. exports.default = Storage;
  30742. /***/ }),
  30743. /* 286 */
  30744. /***/ (function(module, exports, __webpack_require__) {
  30745. "use strict";
  30746. exports.__esModule = true;
  30747. 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"); } }; }();
  30748. 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); } };
  30749. 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; }; }();
  30750. var _base = __webpack_require__(10);
  30751. var _base2 = _interopRequireDefault(_base);
  30752. var _array = __webpack_require__(1);
  30753. var _feature = __webpack_require__(40);
  30754. var _element = __webpack_require__(0);
  30755. var _ghostTable = __webpack_require__(92);
  30756. var _ghostTable2 = _interopRequireDefault(_ghostTable);
  30757. var _object = __webpack_require__(2);
  30758. var _number = __webpack_require__(5);
  30759. var _plugins = __webpack_require__(8);
  30760. var _samplesGenerator = __webpack_require__(200);
  30761. var _samplesGenerator2 = _interopRequireDefault(_samplesGenerator);
  30762. var _string = __webpack_require__(36);
  30763. var _src = __webpack_require__(4);
  30764. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  30765. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  30766. 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; }
  30767. 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; }
  30768. var privatePool = new WeakMap();
  30769. /**
  30770. * @plugin AutoColumnSize
  30771. *
  30772. * @description
  30773. * This plugin allows to set column widths based on their widest cells.
  30774. *
  30775. * By default, the plugin is declared as `undefined`, which makes it enabled (same as if it was declared as `true`).
  30776. * Enabling this plugin may decrease the overall table performance, as it needs to calculate the widths of all cells to
  30777. * resize the columns accordingly.
  30778. * If you experience problems with the performance, try turning this feature off and declaring the column widths manually.
  30779. *
  30780. * Column width calculations are divided into sync and async part. Each of this parts has their own advantages and
  30781. * disadvantages. Synchronous calculations are faster but they block the browser UI, while the slower asynchronous operations don't
  30782. * block the browser UI.
  30783. *
  30784. * To configure the sync/async distribution, you can pass an absolute value (number of columns) or a percentage value to a config object:
  30785. * ```js
  30786. * ...
  30787. * // as a number (300 columns in sync, rest async)
  30788. * autoColumnSize: {syncLimit: 300},
  30789. * ...
  30790. *
  30791. * ...
  30792. * // as a string (percent)
  30793. * autoColumnSize: {syncLimit: '40%'},
  30794. * ...
  30795. * ```
  30796. *
  30797. * To configure this plugin see {@link Options#autoColumnSize}.
  30798. *
  30799. * @example
  30800. * ```js
  30801. * ...
  30802. * var hot = new Handsontable(document.getElementById('example'), {
  30803. * date: getData(),
  30804. * autoColumnSize: true
  30805. * });
  30806. * // Access to plugin instance:
  30807. * var plugin = hot.getPlugin('autoColumnSize');
  30808. *
  30809. * plugin.getColumnWidth(4);
  30810. *
  30811. * if (plugin.isEnabled()) {
  30812. * // code...
  30813. * }
  30814. * ...
  30815. * ```
  30816. */
  30817. var AutoColumnSize = function (_BasePlugin) {
  30818. _inherits(AutoColumnSize, _BasePlugin);
  30819. _createClass(AutoColumnSize, null, [{
  30820. key: 'CALCULATION_STEP',
  30821. get: function get() {
  30822. return 50;
  30823. }
  30824. }, {
  30825. key: 'SYNC_CALCULATION_LIMIT',
  30826. get: function get() {
  30827. return 50;
  30828. }
  30829. }]);
  30830. function AutoColumnSize(hotInstance) {
  30831. _classCallCheck(this, AutoColumnSize);
  30832. var _this = _possibleConstructorReturn(this, (AutoColumnSize.__proto__ || Object.getPrototypeOf(AutoColumnSize)).call(this, hotInstance));
  30833. privatePool.set(_this, {
  30834. /**
  30835. * Cached column header names. It is used to diff current column headers with previous state and detect which
  30836. * columns width should be updated.
  30837. *
  30838. * @private
  30839. * @type {Array}
  30840. */
  30841. cachedColumnHeaders: []
  30842. });
  30843. /**
  30844. * Cached columns widths.
  30845. *
  30846. * @type {Array}
  30847. */
  30848. _this.widths = [];
  30849. /**
  30850. * Instance of {@link GhostTable} for rows and columns size calculations.
  30851. *
  30852. * @type {GhostTable}
  30853. */
  30854. _this.ghostTable = new _ghostTable2.default(_this.hot);
  30855. /**
  30856. * Instance of {@link SamplesGenerator} for generating samples necessary for columns width calculations.
  30857. *
  30858. * @type {SamplesGenerator}
  30859. */
  30860. _this.samplesGenerator = new _samplesGenerator2.default(function (row, col) {
  30861. return _this.hot.getCellMeta(row, col).spanned ? '' : _this.hot.getDataAtCell(row, col);
  30862. });
  30863. /**
  30864. * `true` only if the first calculation was performed
  30865. *
  30866. * @type {Boolean}
  30867. */
  30868. _this.firstCalculation = true;
  30869. /**
  30870. * `true` if the size calculation is in progress.
  30871. *
  30872. * @type {Boolean}
  30873. */
  30874. _this.inProgress = false;
  30875. // moved to constructor to allow auto-sizing the columns when the plugin is disabled
  30876. _this.addHook('beforeColumnResize', function (col, size, isDblClick) {
  30877. return _this.onBeforeColumnResize(col, size, isDblClick);
  30878. });
  30879. return _this;
  30880. }
  30881. /**
  30882. * Check if the plugin is enabled in the handsontable settings.
  30883. *
  30884. * @returns {Boolean}
  30885. */
  30886. _createClass(AutoColumnSize, [{
  30887. key: 'isEnabled',
  30888. value: function isEnabled() {
  30889. return this.hot.getSettings().autoColumnSize !== false && !this.hot.getSettings().colWidths;
  30890. }
  30891. /**
  30892. * Enable plugin for this Handsontable instance.
  30893. */
  30894. }, {
  30895. key: 'enablePlugin',
  30896. value: function enablePlugin() {
  30897. var _this2 = this;
  30898. if (this.enabled) {
  30899. return;
  30900. }
  30901. var setting = this.hot.getSettings().autoColumnSize;
  30902. if (setting && setting.useHeaders != null) {
  30903. this.ghostTable.setSetting('useHeaders', setting.useHeaders);
  30904. }
  30905. this.addHook('afterLoadData', function () {
  30906. return _this2.onAfterLoadData();
  30907. });
  30908. this.addHook('beforeChange', function (changes) {
  30909. return _this2.onBeforeChange(changes);
  30910. });
  30911. this.addHook('beforeRender', function (force) {
  30912. return _this2.onBeforeRender(force);
  30913. });
  30914. this.addHook('modifyColWidth', function (width, col) {
  30915. return _this2.getColumnWidth(col, width);
  30916. });
  30917. this.addHook('afterInit', function () {
  30918. return _this2.onAfterInit();
  30919. });
  30920. _get(AutoColumnSize.prototype.__proto__ || Object.getPrototypeOf(AutoColumnSize.prototype), 'enablePlugin', this).call(this);
  30921. }
  30922. /**
  30923. * Update plugin state.
  30924. */
  30925. }, {
  30926. key: 'updatePlugin',
  30927. value: function updatePlugin() {
  30928. var changedColumns = this.findColumnsWhereHeaderWasChanged();
  30929. if (changedColumns.length) {
  30930. this.clearCache(changedColumns);
  30931. }
  30932. _get(AutoColumnSize.prototype.__proto__ || Object.getPrototypeOf(AutoColumnSize.prototype), 'updatePlugin', this).call(this);
  30933. }
  30934. /**
  30935. * Disable plugin for this Handsontable instance.
  30936. */
  30937. }, {
  30938. key: 'disablePlugin',
  30939. value: function disablePlugin() {
  30940. _get(AutoColumnSize.prototype.__proto__ || Object.getPrototypeOf(AutoColumnSize.prototype), 'disablePlugin', this).call(this);
  30941. }
  30942. /**
  30943. * Calculate a columns width.
  30944. *
  30945. * @param {Number|Object} colRange Column range object.
  30946. * @param {Number|Object} rowRange Row range object.
  30947. * @param {Boolean} [force=false] If `true` force calculate width even when value was cached earlier.
  30948. */
  30949. }, {
  30950. key: 'calculateColumnsWidth',
  30951. value: function calculateColumnsWidth() {
  30952. var colRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { from: 0, to: this.hot.countCols() - 1 };
  30953. var _this3 = this;
  30954. var rowRange = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { from: 0, to: this.hot.countRows() - 1 };
  30955. var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  30956. if (typeof colRange === 'number') {
  30957. colRange = { from: colRange, to: colRange };
  30958. }
  30959. if (typeof rowRange === 'number') {
  30960. rowRange = { from: rowRange, to: rowRange };
  30961. }
  30962. (0, _number.rangeEach)(colRange.from, colRange.to, function (col) {
  30963. if (force || _this3.widths[col] === void 0 && !_this3.hot._getColWidthFromSettings(col)) {
  30964. var samples = _this3.samplesGenerator.generateColumnSamples(col, rowRange);
  30965. samples.forEach(function (sample, col) {
  30966. return _this3.ghostTable.addColumn(col, sample);
  30967. });
  30968. }
  30969. });
  30970. if (this.ghostTable.columns.length) {
  30971. this.ghostTable.getWidths(function (col, width) {
  30972. _this3.widths[col] = width;
  30973. });
  30974. this.ghostTable.clean();
  30975. }
  30976. }
  30977. /**
  30978. * Calculate all columns width.
  30979. *
  30980. * @param {Object|Number} rowRange Row range object.
  30981. */
  30982. }, {
  30983. key: 'calculateAllColumnsWidth',
  30984. value: function calculateAllColumnsWidth() {
  30985. var _this4 = this;
  30986. var rowRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { from: 0, to: this.hot.countRows() - 1 };
  30987. var current = 0;
  30988. var length = this.hot.countCols() - 1;
  30989. var timer = null;
  30990. this.inProgress = true;
  30991. var loop = function loop() {
  30992. // When hot was destroyed after calculating finished cancel frame
  30993. if (!_this4.hot) {
  30994. (0, _feature.cancelAnimationFrame)(timer);
  30995. _this4.inProgress = false;
  30996. return;
  30997. }
  30998. _this4.calculateColumnsWidth({
  30999. from: current,
  31000. to: Math.min(current + AutoColumnSize.CALCULATION_STEP, length)
  31001. }, rowRange);
  31002. current = current + AutoColumnSize.CALCULATION_STEP + 1;
  31003. if (current < length) {
  31004. timer = (0, _feature.requestAnimationFrame)(loop);
  31005. } else {
  31006. (0, _feature.cancelAnimationFrame)(timer);
  31007. _this4.inProgress = false;
  31008. // @TODO Should call once per render cycle, currently fired separately in different plugins
  31009. _this4.hot.view.wt.wtOverlays.adjustElementsSize(true);
  31010. // tmp
  31011. if (_this4.hot.view.wt.wtOverlays.leftOverlay.needFullRender) {
  31012. _this4.hot.view.wt.wtOverlays.leftOverlay.clone.draw();
  31013. }
  31014. }
  31015. };
  31016. // sync
  31017. if (this.firstCalculation && this.getSyncCalculationLimit()) {
  31018. this.calculateColumnsWidth({ from: 0, to: this.getSyncCalculationLimit() }, rowRange);
  31019. this.firstCalculation = false;
  31020. current = this.getSyncCalculationLimit() + 1;
  31021. }
  31022. // async
  31023. if (current < length) {
  31024. loop();
  31025. } else {
  31026. this.inProgress = false;
  31027. }
  31028. }
  31029. /**
  31030. * Set the sampling options.
  31031. *
  31032. * @private
  31033. */
  31034. }, {
  31035. key: 'setSamplingOptions',
  31036. value: function setSamplingOptions() {
  31037. var setting = this.hot.getSettings().autoColumnSize;
  31038. var samplingRatio = setting && (0, _object.hasOwnProperty)(setting, 'samplingRatio') ? this.hot.getSettings().autoColumnSize.samplingRatio : void 0;
  31039. var allowSampleDuplicates = setting && (0, _object.hasOwnProperty)(setting, 'allowSampleDuplicates') ? this.hot.getSettings().autoColumnSize.allowSampleDuplicates : void 0;
  31040. if (samplingRatio && !isNaN(samplingRatio)) {
  31041. this.samplesGenerator.setSampleCount(parseInt(samplingRatio, 10));
  31042. }
  31043. if (allowSampleDuplicates) {
  31044. this.samplesGenerator.setAllowDuplicates(allowSampleDuplicates);
  31045. }
  31046. }
  31047. /**
  31048. * Recalculate all columns width (overwrite cache values).
  31049. */
  31050. }, {
  31051. key: 'recalculateAllColumnsWidth',
  31052. value: function recalculateAllColumnsWidth() {
  31053. if (this.hot.view && (0, _element.isVisible)(this.hot.view.wt.wtTable.TABLE)) {
  31054. this.clearCache();
  31055. this.calculateAllColumnsWidth();
  31056. }
  31057. }
  31058. /**
  31059. * Get value which tells how many columns should be calculated synchronously. Rest of the columns will be calculated asynchronously.
  31060. *
  31061. * @returns {Number}
  31062. */
  31063. }, {
  31064. key: 'getSyncCalculationLimit',
  31065. value: function getSyncCalculationLimit() {
  31066. /* eslint-disable no-bitwise */
  31067. var limit = AutoColumnSize.SYNC_CALCULATION_LIMIT;
  31068. var colsLimit = this.hot.countCols() - 1;
  31069. if ((0, _object.isObject)(this.hot.getSettings().autoColumnSize)) {
  31070. limit = this.hot.getSettings().autoColumnSize.syncLimit;
  31071. if ((0, _string.isPercentValue)(limit)) {
  31072. limit = (0, _number.valueAccordingPercent)(colsLimit, limit);
  31073. } else {
  31074. // Force to Number
  31075. limit >>= 0;
  31076. }
  31077. }
  31078. return Math.min(limit, colsLimit);
  31079. }
  31080. /**
  31081. * Get the calculated column width.
  31082. *
  31083. * @param {Number} col Column index.
  31084. * @param {Number} [defaultWidth] Default column width. It will be picked up if no calculated width found.
  31085. * @param {Boolean} [keepMinimum=true] If `true` then returned value won't be smaller then 50 (default column width).
  31086. * @returns {Number}
  31087. */
  31088. }, {
  31089. key: 'getColumnWidth',
  31090. value: function getColumnWidth(col) {
  31091. var defaultWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : void 0;
  31092. var keepMinimum = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  31093. var width = defaultWidth;
  31094. if (width === void 0) {
  31095. width = this.widths[col];
  31096. if (keepMinimum && typeof width === 'number') {
  31097. width = Math.max(width, _src.ViewportColumnsCalculator.DEFAULT_WIDTH);
  31098. }
  31099. }
  31100. return width;
  31101. }
  31102. /**
  31103. * Get the first visible column.
  31104. *
  31105. * @returns {Number} Returns column index or -1 if table is not rendered.
  31106. */
  31107. }, {
  31108. key: 'getFirstVisibleColumn',
  31109. value: function getFirstVisibleColumn() {
  31110. var wot = this.hot.view.wt;
  31111. if (wot.wtViewport.columnsVisibleCalculator) {
  31112. return wot.wtTable.getFirstVisibleColumn();
  31113. }
  31114. if (wot.wtViewport.columnsRenderCalculator) {
  31115. return wot.wtTable.getFirstRenderedColumn();
  31116. }
  31117. return -1;
  31118. }
  31119. /**
  31120. * Get the last visible column.
  31121. *
  31122. * @returns {Number} Returns column index or -1 if table is not rendered.
  31123. */
  31124. }, {
  31125. key: 'getLastVisibleColumn',
  31126. value: function getLastVisibleColumn() {
  31127. var wot = this.hot.view.wt;
  31128. if (wot.wtViewport.columnsVisibleCalculator) {
  31129. return wot.wtTable.getLastVisibleColumn();
  31130. }
  31131. if (wot.wtViewport.columnsRenderCalculator) {
  31132. return wot.wtTable.getLastRenderedColumn();
  31133. }
  31134. return -1;
  31135. }
  31136. /**
  31137. * Collects all columns which titles has been changed in comparison to the previous state.
  31138. *
  31139. * @returns {Array} It returns an array of physical column indexes.
  31140. */
  31141. }, {
  31142. key: 'findColumnsWhereHeaderWasChanged',
  31143. value: function findColumnsWhereHeaderWasChanged() {
  31144. var columnHeaders = this.hot.getColHeader();
  31145. var _privatePool$get = privatePool.get(this),
  31146. cachedColumnHeaders = _privatePool$get.cachedColumnHeaders;
  31147. var changedColumns = (0, _array.arrayReduce)(columnHeaders, function (acc, columnTitle, physicalColumn) {
  31148. var cachedColumnsLength = cachedColumnHeaders.length;
  31149. if (cachedColumnsLength - 1 < physicalColumn || cachedColumnHeaders[physicalColumn] !== columnTitle) {
  31150. acc.push(physicalColumn);
  31151. }
  31152. if (cachedColumnsLength - 1 < physicalColumn) {
  31153. cachedColumnHeaders.push(columnTitle);
  31154. } else {
  31155. cachedColumnHeaders[physicalColumn] = columnTitle;
  31156. }
  31157. return acc;
  31158. }, []);
  31159. return changedColumns;
  31160. }
  31161. /**
  31162. * Clear cache of calculated column widths. If you want to clear only selected columns pass an array with their indexes.
  31163. * Otherwise whole cache will be cleared.
  31164. *
  31165. * @param {Array} [columns=[]] List of column indexes (physical indexes) to clear.
  31166. */
  31167. }, {
  31168. key: 'clearCache',
  31169. value: function clearCache() {
  31170. var _this5 = this;
  31171. var columns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  31172. if (columns.length) {
  31173. (0, _array.arrayEach)(columns, function (physicalIndex) {
  31174. _this5.widths[physicalIndex] = void 0;
  31175. });
  31176. } else {
  31177. this.widths.length = 0;
  31178. }
  31179. }
  31180. /**
  31181. * Check if all widths were calculated. If not then return `true` (need recalculate).
  31182. *
  31183. * @returns {Boolean}
  31184. */
  31185. }, {
  31186. key: 'isNeedRecalculate',
  31187. value: function isNeedRecalculate() {
  31188. return !!(0, _array.arrayFilter)(this.widths, function (item) {
  31189. return item === void 0;
  31190. }).length;
  31191. }
  31192. /**
  31193. * On before render listener.
  31194. *
  31195. * @private
  31196. */
  31197. }, {
  31198. key: 'onBeforeRender',
  31199. value: function onBeforeRender() {
  31200. var force = this.hot.renderCall;
  31201. var rowsCount = this.hot.countRows();
  31202. // Keep last column widths unchanged for situation when all rows was deleted or trimmed (pro #6)
  31203. if (!rowsCount) {
  31204. return;
  31205. }
  31206. this.calculateColumnsWidth({ from: this.getFirstVisibleColumn(), to: this.getLastVisibleColumn() }, void 0, force);
  31207. if (this.isNeedRecalculate() && !this.inProgress) {
  31208. this.calculateAllColumnsWidth();
  31209. }
  31210. }
  31211. /**
  31212. * On after load data listener.
  31213. *
  31214. * @private
  31215. */
  31216. }, {
  31217. key: 'onAfterLoadData',
  31218. value: function onAfterLoadData() {
  31219. var _this6 = this;
  31220. if (this.hot.view) {
  31221. this.recalculateAllColumnsWidth();
  31222. } else {
  31223. // first load - initialization
  31224. setTimeout(function () {
  31225. if (_this6.hot) {
  31226. _this6.recalculateAllColumnsWidth();
  31227. }
  31228. }, 0);
  31229. }
  31230. }
  31231. /**
  31232. * On before change listener.
  31233. *
  31234. * @private
  31235. * @param {Array} changes
  31236. */
  31237. }, {
  31238. key: 'onBeforeChange',
  31239. value: function onBeforeChange(changes) {
  31240. var _this7 = this;
  31241. var changedColumns = (0, _array.arrayMap)(changes, function (_ref) {
  31242. var _ref2 = _slicedToArray(_ref, 2),
  31243. row = _ref2[0],
  31244. column = _ref2[1];
  31245. return _this7.hot.propToCol(column);
  31246. });
  31247. this.clearCache(changedColumns);
  31248. }
  31249. /**
  31250. * On before column resize listener.
  31251. *
  31252. * @private
  31253. * @param {Number} col
  31254. * @param {Number} size
  31255. * @param {Boolean} isDblClick
  31256. * @returns {Number}
  31257. */
  31258. }, {
  31259. key: 'onBeforeColumnResize',
  31260. value: function onBeforeColumnResize(col, size, isDblClick) {
  31261. if (isDblClick) {
  31262. this.calculateColumnsWidth(col, void 0, true);
  31263. size = this.getColumnWidth(col, void 0, false);
  31264. }
  31265. return size;
  31266. }
  31267. /**
  31268. * On after Handsontable init fill plugin with all necessary values.
  31269. *
  31270. * @private
  31271. */
  31272. }, {
  31273. key: 'onAfterInit',
  31274. value: function onAfterInit() {
  31275. privatePool.get(this).cachedColumnHeaders = this.hot.getColHeader();
  31276. }
  31277. /**
  31278. * Destroy plugin instance.
  31279. */
  31280. }, {
  31281. key: 'destroy',
  31282. value: function destroy() {
  31283. this.ghostTable.clean();
  31284. _get(AutoColumnSize.prototype.__proto__ || Object.getPrototypeOf(AutoColumnSize.prototype), 'destroy', this).call(this);
  31285. }
  31286. }]);
  31287. return AutoColumnSize;
  31288. }(_base2.default);
  31289. (0, _plugins.registerPlugin)('autoColumnSize', AutoColumnSize);
  31290. exports.default = AutoColumnSize;
  31291. /***/ }),
  31292. /* 287 */
  31293. /***/ (function(module, exports, __webpack_require__) {
  31294. "use strict";
  31295. exports.__esModule = true;
  31296. 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; }; }();
  31297. 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); } };
  31298. var _base = __webpack_require__(10);
  31299. var _base2 = _interopRequireDefault(_base);
  31300. var _pluginHooks = __webpack_require__(15);
  31301. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  31302. var _element = __webpack_require__(0);
  31303. var _eventManager = __webpack_require__(6);
  31304. var _eventManager2 = _interopRequireDefault(_eventManager);
  31305. var _plugins = __webpack_require__(8);
  31306. var _src = __webpack_require__(4);
  31307. var _utils = __webpack_require__(288);
  31308. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  31309. 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); } }
  31310. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  31311. 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; }
  31312. 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; }
  31313. _pluginHooks2.default.getSingleton().register('modifyAutofillRange');
  31314. _pluginHooks2.default.getSingleton().register('beforeAutofill');
  31315. var INSERT_ROW_ALTER_ACTION_NAME = 'insert_row';
  31316. var INTERVAL_FOR_ADDING_ROW = 200;
  31317. /**
  31318. * This plugin provides "drag-down" and "copy-down" functionalities, both operated
  31319. * using the small square in the right bottom of the cell selection.
  31320. *
  31321. * "Drag-down" expands the value of the selected cells to the neighbouring
  31322. * cells when you drag the small square in the corner.
  31323. *
  31324. * "Copy-down" copies the value of the selection to all empty cells
  31325. * below when you double click the small square.
  31326. *
  31327. * @class Autofill
  31328. * @plugin Autofill
  31329. */
  31330. var Autofill = function (_BasePlugin) {
  31331. _inherits(Autofill, _BasePlugin);
  31332. function Autofill(hotInstance) {
  31333. _classCallCheck(this, Autofill);
  31334. /**
  31335. * Event manager
  31336. *
  31337. * @type {EventManager}
  31338. */
  31339. var _this = _possibleConstructorReturn(this, (Autofill.__proto__ || Object.getPrototypeOf(Autofill)).call(this, hotInstance));
  31340. _this.eventManager = new _eventManager2.default(_this);
  31341. /**
  31342. * Specifies if adding new row started.
  31343. *
  31344. * @type {Boolean}
  31345. */
  31346. _this.addingStarted = false;
  31347. /**
  31348. * Specifies if there was mouse down on the cell corner.
  31349. *
  31350. * @type {Boolean}
  31351. */
  31352. _this.mouseDownOnCellCorner = false;
  31353. /**
  31354. * Specifies if mouse was dragged outside Handsontable.
  31355. *
  31356. * @type {Boolean}
  31357. */
  31358. _this.mouseDragOutside = false;
  31359. /**
  31360. * Specifies how many cell levels were dragged using the handle.
  31361. *
  31362. * @type {Boolean}
  31363. */
  31364. _this.handleDraggedCells = 0;
  31365. /**
  31366. * Specifies allowed directions of drag.
  31367. *
  31368. * @type {Array}
  31369. */
  31370. _this.directions = [];
  31371. /**
  31372. * Specifies if can insert new rows if needed.
  31373. *
  31374. * @type {Boolean}
  31375. */
  31376. _this.autoInsertRow = false;
  31377. return _this;
  31378. }
  31379. /**
  31380. * Check if the plugin is enabled in the Handsontable settings.
  31381. *
  31382. * @returns {Boolean}
  31383. */
  31384. _createClass(Autofill, [{
  31385. key: 'isEnabled',
  31386. value: function isEnabled() {
  31387. return this.hot.getSettings().fillHandle;
  31388. }
  31389. /**
  31390. * Enable plugin for this Handsontable instance.
  31391. */
  31392. }, {
  31393. key: 'enablePlugin',
  31394. value: function enablePlugin() {
  31395. var _this2 = this;
  31396. if (this.enabled) {
  31397. return;
  31398. }
  31399. this.mapSettings();
  31400. this.registerEvents();
  31401. this.addHook('afterOnCellCornerMouseDown', function (event) {
  31402. return _this2.onAfterCellCornerMouseDown(event);
  31403. });
  31404. this.addHook('afterOnCellCornerDblClick', function (event) {
  31405. return _this2.onCellCornerDblClick(event);
  31406. });
  31407. this.addHook('beforeOnCellMouseOver', function (event, coords, TD) {
  31408. return _this2.onBeforeCellMouseOver(coords);
  31409. });
  31410. _get(Autofill.prototype.__proto__ || Object.getPrototypeOf(Autofill.prototype), 'enablePlugin', this).call(this);
  31411. }
  31412. /**
  31413. * Update plugin for this Handsontable instance.
  31414. */
  31415. }, {
  31416. key: 'updatePlugin',
  31417. value: function updatePlugin() {
  31418. this.disablePlugin();
  31419. this.enablePlugin();
  31420. _get(Autofill.prototype.__proto__ || Object.getPrototypeOf(Autofill.prototype), 'updatePlugin', this).call(this);
  31421. }
  31422. /**
  31423. * Disable plugin for this Handsontable instance.
  31424. */
  31425. }, {
  31426. key: 'disablePlugin',
  31427. value: function disablePlugin() {
  31428. this.clearMappedSettings();
  31429. _get(Autofill.prototype.__proto__ || Object.getPrototypeOf(Autofill.prototype), 'disablePlugin', this).call(this);
  31430. }
  31431. /**
  31432. * Get selection data
  31433. *
  31434. * @private
  31435. * @returns {Array} Array with the data.
  31436. */
  31437. }, {
  31438. key: 'getSelectionData',
  31439. value: function getSelectionData() {
  31440. var selRange = {
  31441. from: this.hot.getSelectedRangeLast().from,
  31442. to: this.hot.getSelectedRangeLast().to
  31443. };
  31444. return this.hot.getData(selRange.from.row, selRange.from.col, selRange.to.row, selRange.to.col);
  31445. }
  31446. /**
  31447. * Try to apply fill values to the area in fill border, omitting the selection border.
  31448. *
  31449. * @private
  31450. * @returns {Boolean} reports if fill was applied.
  31451. */
  31452. }, {
  31453. key: 'fillIn',
  31454. value: function fillIn() {
  31455. if (this.hot.selection.highlight.getFill().isEmpty()) {
  31456. return false;
  31457. }
  31458. var cornersOfSelectionAndDragAreas = this.hot.selection.highlight.getFill().getCorners();
  31459. this.resetSelectionOfDraggedArea();
  31460. var cornersOfSelectedCells = this.getCornersOfSelectedCells();
  31461. cornersOfSelectionAndDragAreas = this.hot.runHooks('modifyAutofillRange', cornersOfSelectionAndDragAreas, cornersOfSelectedCells);
  31462. var _getDragDirectionAndR = (0, _utils.getDragDirectionAndRange)(cornersOfSelectedCells, cornersOfSelectionAndDragAreas),
  31463. directionOfDrag = _getDragDirectionAndR.directionOfDrag,
  31464. startOfDragCoords = _getDragDirectionAndR.startOfDragCoords,
  31465. endOfDragCoords = _getDragDirectionAndR.endOfDragCoords;
  31466. if (startOfDragCoords && startOfDragCoords.row > -1 && startOfDragCoords.col > -1) {
  31467. var selectionData = this.getSelectionData();
  31468. this.hot.runHooks('beforeAutofill', startOfDragCoords, endOfDragCoords, selectionData);
  31469. var deltas = (0, _utils.getDeltas)(startOfDragCoords, endOfDragCoords, selectionData, directionOfDrag);
  31470. var fillData = selectionData;
  31471. if (['up', 'left'].indexOf(directionOfDrag) > -1) {
  31472. fillData = [];
  31473. var dragLength = null;
  31474. var fillOffset = null;
  31475. if (directionOfDrag === 'up') {
  31476. dragLength = endOfDragCoords.row - startOfDragCoords.row + 1;
  31477. fillOffset = dragLength % selectionData.length;
  31478. for (var i = 0; i < dragLength; i++) {
  31479. fillData.push(selectionData[(i + (selectionData.length - fillOffset)) % selectionData.length]);
  31480. }
  31481. } else {
  31482. dragLength = endOfDragCoords.col - startOfDragCoords.col + 1;
  31483. fillOffset = dragLength % selectionData[0].length;
  31484. for (var _i = 0; _i < selectionData.length; _i++) {
  31485. fillData.push([]);
  31486. for (var j = 0; j < dragLength; j++) {
  31487. fillData[_i].push(selectionData[_i][(j + (selectionData[_i].length - fillOffset)) % selectionData[_i].length]);
  31488. }
  31489. }
  31490. }
  31491. }
  31492. this.hot.populateFromArray(startOfDragCoords.row, startOfDragCoords.col, fillData, endOfDragCoords.row, endOfDragCoords.col, this.pluginName + '.fill', null, directionOfDrag, deltas);
  31493. this.setSelection(cornersOfSelectionAndDragAreas);
  31494. } else {
  31495. // reset to avoid some range bug
  31496. this.hot._refreshBorders();
  31497. }
  31498. return true;
  31499. }
  31500. /**
  31501. * Reduce the selection area if the handle was dragged outside of the table or on headers.
  31502. *
  31503. * @private
  31504. * @param {CellCoords} coords indexes of selection corners.
  31505. * @returns {CellCoords}
  31506. */
  31507. }, {
  31508. key: 'reduceSelectionAreaIfNeeded',
  31509. value: function reduceSelectionAreaIfNeeded(coords) {
  31510. if (coords.row < 0) {
  31511. coords.row = 0;
  31512. }
  31513. if (coords.col < 0) {
  31514. coords.col = 0;
  31515. }
  31516. return coords;
  31517. }
  31518. /**
  31519. * Get the coordinates of the drag & drop borders.
  31520. *
  31521. * @private
  31522. * @param {CellCoords} coordsOfSelection `CellCoords` coord object.
  31523. * @returns {Array}
  31524. */
  31525. }, {
  31526. key: 'getCoordsOfDragAndDropBorders',
  31527. value: function getCoordsOfDragAndDropBorders(coordsOfSelection) {
  31528. var topLeftCorner = this.hot.getSelectedRangeLast().getTopLeftCorner();
  31529. var bottomRightCorner = this.hot.getSelectedRangeLast().getBottomRightCorner();
  31530. var coords = void 0;
  31531. if (this.directions.includes(_utils.DIRECTIONS.vertical) && (bottomRightCorner.row < coordsOfSelection.row || topLeftCorner.row > coordsOfSelection.row)) {
  31532. coords = new _src.CellCoords(coordsOfSelection.row, bottomRightCorner.col);
  31533. } else if (this.directions.includes(_utils.DIRECTIONS.horizontal)) {
  31534. coords = new _src.CellCoords(bottomRightCorner.row, coordsOfSelection.col);
  31535. } else {
  31536. // wrong direction
  31537. return;
  31538. }
  31539. return this.reduceSelectionAreaIfNeeded(coords);
  31540. }
  31541. /**
  31542. * Show the fill border.
  31543. *
  31544. * @private
  31545. * @param {CellCoords} coordsOfSelection `CellCoords` coord object.
  31546. */
  31547. }, {
  31548. key: 'showBorder',
  31549. value: function showBorder(coordsOfSelection) {
  31550. var coordsOfDragAndDropBorders = this.getCoordsOfDragAndDropBorders(coordsOfSelection);
  31551. if (coordsOfDragAndDropBorders) {
  31552. this.redrawBorders(coordsOfDragAndDropBorders);
  31553. }
  31554. }
  31555. /**
  31556. * Add new row
  31557. *
  31558. * @private
  31559. */
  31560. }, {
  31561. key: 'addRow',
  31562. value: function addRow() {
  31563. var _this3 = this;
  31564. this.hot._registerTimeout(setTimeout(function () {
  31565. _this3.hot.alter(INSERT_ROW_ALTER_ACTION_NAME, void 0, 1, _this3.pluginName + '.fill');
  31566. _this3.addingStarted = false;
  31567. }, INTERVAL_FOR_ADDING_ROW));
  31568. }
  31569. /**
  31570. * Add new rows if they are needed to continue auto-filling values.
  31571. *
  31572. * @private
  31573. */
  31574. }, {
  31575. key: 'addNewRowIfNeeded',
  31576. value: function addNewRowIfNeeded() {
  31577. if (this.hot.selection.highlight.getFill().cellRange && this.addingStarted === false && this.autoInsertRow) {
  31578. var cornersOfSelectedCells = this.hot.getSelectedLast();
  31579. var cornersOfSelectedDragArea = this.hot.selection.highlight.getFill().getCorners();
  31580. var nrOfTableRows = this.hot.countRows();
  31581. if (cornersOfSelectedCells[2] < nrOfTableRows - 1 && cornersOfSelectedDragArea[2] === nrOfTableRows - 1) {
  31582. this.addingStarted = true;
  31583. this.addRow();
  31584. }
  31585. }
  31586. }
  31587. /**
  31588. * Get corners of selected cells.
  31589. *
  31590. * @private
  31591. * @returns {Array}
  31592. */
  31593. }, {
  31594. key: 'getCornersOfSelectedCells',
  31595. value: function getCornersOfSelectedCells() {
  31596. if (this.hot.selection.isMultiple()) {
  31597. return this.hot.selection.highlight.createOrGetArea().getCorners();
  31598. }
  31599. return this.hot.selection.highlight.getCell().getCorners();
  31600. }
  31601. /**
  31602. * Get index of last adjacent filled in row
  31603. *
  31604. * @private
  31605. * @param {Array} cornersOfSelectedCells indexes of selection corners.
  31606. * @returns {Number} gives number greater than or equal to zero when selection adjacent can be applied.
  31607. * or -1 when selection adjacent can't be applied
  31608. */
  31609. }, {
  31610. key: 'getIndexOfLastAdjacentFilledInRow',
  31611. value: function getIndexOfLastAdjacentFilledInRow(cornersOfSelectedCells) {
  31612. var data = this.hot.getData();
  31613. var nrOfTableRows = this.hot.countRows();
  31614. var lastFilledInRowIndex = void 0;
  31615. for (var rowIndex = cornersOfSelectedCells[2] + 1; rowIndex < nrOfTableRows; rowIndex++) {
  31616. for (var columnIndex = cornersOfSelectedCells[1]; columnIndex <= cornersOfSelectedCells[3]; columnIndex++) {
  31617. var dataInCell = data[rowIndex][columnIndex];
  31618. if (dataInCell) {
  31619. return -1;
  31620. }
  31621. }
  31622. var dataInNextLeftCell = data[rowIndex][cornersOfSelectedCells[1] - 1];
  31623. var dataInNextRightCell = data[rowIndex][cornersOfSelectedCells[3] + 1];
  31624. if (!!dataInNextLeftCell || !!dataInNextRightCell) {
  31625. lastFilledInRowIndex = rowIndex;
  31626. }
  31627. }
  31628. return lastFilledInRowIndex;
  31629. }
  31630. /**
  31631. * Add a selection from the start area to the specific row index.
  31632. *
  31633. * @private
  31634. * @param {Array} selectStartArea selection area from which we start to create more comprehensive selection.
  31635. * @param {Number} rowIndex
  31636. */
  31637. }, {
  31638. key: 'addSelectionFromStartAreaToSpecificRowIndex',
  31639. value: function addSelectionFromStartAreaToSpecificRowIndex(selectStartArea, rowIndex) {
  31640. this.hot.selection.highlight.getFill().clear().add(new _src.CellCoords(selectStartArea[0], selectStartArea[1])).add(new _src.CellCoords(rowIndex, selectStartArea[3]));
  31641. }
  31642. /**
  31643. * Set selection based on passed corners.
  31644. *
  31645. * @private
  31646. * @param {Array} cornersOfArea
  31647. */
  31648. }, {
  31649. key: 'setSelection',
  31650. value: function setSelection(cornersOfArea) {
  31651. var _hot;
  31652. (_hot = this.hot).selectCell.apply(_hot, _toConsumableArray(cornersOfArea).concat([false, false]));
  31653. }
  31654. /**
  31655. * Try to select cells down to the last row in the left column and then returns if selection was applied.
  31656. *
  31657. * @private
  31658. * @returns {Boolean}
  31659. */
  31660. }, {
  31661. key: 'selectAdjacent',
  31662. value: function selectAdjacent() {
  31663. var cornersOfSelectedCells = this.getCornersOfSelectedCells();
  31664. var lastFilledInRowIndex = this.getIndexOfLastAdjacentFilledInRow(cornersOfSelectedCells);
  31665. if (lastFilledInRowIndex === -1) {
  31666. return false;
  31667. }
  31668. this.addSelectionFromStartAreaToSpecificRowIndex(cornersOfSelectedCells, lastFilledInRowIndex);
  31669. return true;
  31670. }
  31671. /**
  31672. * Reset selection of dragged area.
  31673. *
  31674. * @private
  31675. */
  31676. }, {
  31677. key: 'resetSelectionOfDraggedArea',
  31678. value: function resetSelectionOfDraggedArea() {
  31679. this.handleDraggedCells = 0;
  31680. this.hot.selection.highlight.getFill().clear();
  31681. }
  31682. /**
  31683. * Redraw borders.
  31684. *
  31685. * @private
  31686. * @param {CellCoords} coords `CellCoords` coord object.
  31687. */
  31688. }, {
  31689. key: 'redrawBorders',
  31690. value: function redrawBorders(coords) {
  31691. this.hot.selection.highlight.getFill().clear().add(this.hot.getSelectedRangeLast().from).add(this.hot.getSelectedRangeLast().to).add(coords);
  31692. this.hot.view.render();
  31693. }
  31694. /**
  31695. * Get if mouse was dragged outside.
  31696. *
  31697. * @private
  31698. * @param {MouseEvent} event `mousemove` event properties.
  31699. * @returns {Boolean}
  31700. */
  31701. }, {
  31702. key: 'getIfMouseWasDraggedOutside',
  31703. value: function getIfMouseWasDraggedOutside(event) {
  31704. var tableBottom = (0, _element.offset)(this.hot.table).top - (window.pageYOffset || document.documentElement.scrollTop) + (0, _element.outerHeight)(this.hot.table);
  31705. var tableRight = (0, _element.offset)(this.hot.table).left - (window.pageXOffset || document.documentElement.scrollLeft) + (0, _element.outerWidth)(this.hot.table);
  31706. return event.clientY > tableBottom && event.clientX <= tableRight;
  31707. }
  31708. /**
  31709. * Bind the events used by the plugin.
  31710. *
  31711. * @private
  31712. */
  31713. }, {
  31714. key: 'registerEvents',
  31715. value: function registerEvents() {
  31716. var _this4 = this;
  31717. this.eventManager.addEventListener(document.documentElement, 'mouseup', function () {
  31718. return _this4.onMouseUp();
  31719. });
  31720. this.eventManager.addEventListener(document.documentElement, 'mousemove', function (event) {
  31721. return _this4.onMouseMove(event);
  31722. });
  31723. }
  31724. /**
  31725. * On cell corner double click callback.
  31726. *
  31727. * @private
  31728. */
  31729. }, {
  31730. key: 'onCellCornerDblClick',
  31731. value: function onCellCornerDblClick() {
  31732. var selectionApplied = this.selectAdjacent();
  31733. if (selectionApplied) {
  31734. this.fillIn();
  31735. }
  31736. }
  31737. /**
  31738. * On after cell corner mouse down listener.
  31739. *
  31740. * @private
  31741. */
  31742. }, {
  31743. key: 'onAfterCellCornerMouseDown',
  31744. value: function onAfterCellCornerMouseDown() {
  31745. this.handleDraggedCells = 1;
  31746. this.mouseDownOnCellCorner = true;
  31747. }
  31748. /**
  31749. * On before cell mouse over listener.
  31750. *
  31751. * @private
  31752. * @param {CellCoords} coords `CellCoords` coord object.
  31753. */
  31754. }, {
  31755. key: 'onBeforeCellMouseOver',
  31756. value: function onBeforeCellMouseOver(coords) {
  31757. if (this.mouseDownOnCellCorner && !this.hot.view.isMouseDown() && this.handleDraggedCells) {
  31758. this.handleDraggedCells++;
  31759. this.showBorder(coords);
  31760. this.addNewRowIfNeeded();
  31761. }
  31762. }
  31763. /**
  31764. * On mouse up listener.
  31765. *
  31766. * @private
  31767. */
  31768. }, {
  31769. key: 'onMouseUp',
  31770. value: function onMouseUp() {
  31771. if (this.handleDraggedCells) {
  31772. if (this.handleDraggedCells > 1) {
  31773. this.fillIn();
  31774. }
  31775. this.handleDraggedCells = 0;
  31776. this.mouseDownOnCellCorner = false;
  31777. }
  31778. }
  31779. /**
  31780. * On mouse move listener.
  31781. *
  31782. * @private
  31783. * @param {MouseEvent} event `mousemove` event properties.
  31784. */
  31785. }, {
  31786. key: 'onMouseMove',
  31787. value: function onMouseMove(event) {
  31788. var mouseWasDraggedOutside = this.getIfMouseWasDraggedOutside(event);
  31789. if (this.addingStarted === false && this.handleDraggedCells > 0 && mouseWasDraggedOutside) {
  31790. this.mouseDragOutside = true;
  31791. this.addingStarted = true;
  31792. } else {
  31793. this.mouseDragOutside = false;
  31794. }
  31795. if (this.mouseDragOutside && this.autoInsertRow) {
  31796. this.addRow();
  31797. }
  31798. }
  31799. /**
  31800. * Clear mapped settings.
  31801. *
  31802. * @private
  31803. */
  31804. }, {
  31805. key: 'clearMappedSettings',
  31806. value: function clearMappedSettings() {
  31807. this.directions.length = 0;
  31808. this.autoInsertRow = false;
  31809. }
  31810. /**
  31811. * Map settings.
  31812. *
  31813. * @private
  31814. */
  31815. }, {
  31816. key: 'mapSettings',
  31817. value: function mapSettings() {
  31818. var mappedSettings = (0, _utils.getMappedFillHandleSetting)(this.hot.getSettings().fillHandle);
  31819. this.directions = mappedSettings.directions;
  31820. this.autoInsertRow = mappedSettings.autoInsertRow;
  31821. }
  31822. /**
  31823. * Destroy plugin instance.
  31824. */
  31825. }, {
  31826. key: 'destroy',
  31827. value: function destroy() {
  31828. _get(Autofill.prototype.__proto__ || Object.getPrototypeOf(Autofill.prototype), 'destroy', this).call(this);
  31829. }
  31830. }]);
  31831. return Autofill;
  31832. }(_base2.default);
  31833. (0, _plugins.registerPlugin)('autofill', Autofill);
  31834. exports.default = Autofill;
  31835. /***/ }),
  31836. /* 288 */
  31837. /***/ (function(module, exports, __webpack_require__) {
  31838. "use strict";
  31839. exports.__esModule = true;
  31840. exports.DIRECTIONS = undefined;
  31841. exports.getDeltas = getDeltas;
  31842. exports.getDragDirectionAndRange = getDragDirectionAndRange;
  31843. exports.getMappedFillHandleSetting = getMappedFillHandleSetting;
  31844. var _object = __webpack_require__(2);
  31845. var _mixed = __webpack_require__(16);
  31846. var _src = __webpack_require__(4);
  31847. var DIRECTIONS = exports.DIRECTIONS = {
  31848. horizontal: 'horizontal',
  31849. vertical: 'vertical'
  31850. };
  31851. /**
  31852. * Get deltas array.
  31853. *
  31854. * @param {CellCoords} start
  31855. * @param {CellCoords} end
  31856. * @param {Array} data
  31857. * @param {String} direction
  31858. * @returns {Array}
  31859. */
  31860. function getDeltas(start, end, data, direction) {
  31861. var rowsLength = data.length;
  31862. var columnsLength = data ? data[0].length : 0;
  31863. var deltas = [];
  31864. var diffRow = end.row - start.row;
  31865. var diffCol = end.col - start.col;
  31866. if (['down', 'up'].indexOf(direction) !== -1) {
  31867. var arr = [];
  31868. for (var col = 0; col <= diffCol; col++) {
  31869. var startValue = parseInt(data[0][col], 10);
  31870. var endValue = parseInt(data[rowsLength - 1][col], 10);
  31871. var delta = (direction === 'down' ? endValue - startValue : startValue - endValue) / (rowsLength - 1) || 0;
  31872. arr.push(delta);
  31873. }
  31874. deltas.push(arr);
  31875. }
  31876. if (['right', 'left'].indexOf(direction) !== -1) {
  31877. for (var row = 0; row <= diffRow; row++) {
  31878. var _startValue = parseInt(data[row][0], 10);
  31879. var _endValue = parseInt(data[row][columnsLength - 1], 10);
  31880. var _delta = (direction === 'right' ? _endValue - _startValue : _startValue - _endValue) / (columnsLength - 1) || 0;
  31881. deltas.push([_delta]);
  31882. }
  31883. }
  31884. return deltas;
  31885. }
  31886. /**
  31887. * Get direction between positions and cords of selections difference (drag area)
  31888. *
  31889. * @param {Array} startSelection
  31890. * @param {Array} endSelection
  31891. * @returns {{direction: String, start: CellCoords, end: CellCoords}}
  31892. */
  31893. function getDragDirectionAndRange(startSelection, endSelection) {
  31894. var startOfDragCoords = void 0,
  31895. endOfDragCoords = void 0,
  31896. directionOfDrag = void 0;
  31897. if (endSelection[0] === startSelection[0] && endSelection[1] < startSelection[1]) {
  31898. directionOfDrag = 'left';
  31899. startOfDragCoords = new _src.CellCoords(endSelection[0], endSelection[1]);
  31900. endOfDragCoords = new _src.CellCoords(endSelection[2], startSelection[1] - 1);
  31901. } else if (endSelection[2] === startSelection[2] && endSelection[0] === startSelection[0] && endSelection[3] > startSelection[3]) {
  31902. directionOfDrag = 'right';
  31903. startOfDragCoords = new _src.CellCoords(endSelection[0], startSelection[3] + 1);
  31904. endOfDragCoords = new _src.CellCoords(endSelection[2], endSelection[3]);
  31905. } else if (endSelection[0] < startSelection[0] && endSelection[1] === startSelection[1]) {
  31906. directionOfDrag = 'up';
  31907. startOfDragCoords = new _src.CellCoords(endSelection[0], endSelection[1]);
  31908. endOfDragCoords = new _src.CellCoords(startSelection[0] - 1, endSelection[3]);
  31909. } else if (endSelection[2] > startSelection[2] && endSelection[1] === startSelection[1]) {
  31910. directionOfDrag = 'down';
  31911. startOfDragCoords = new _src.CellCoords(startSelection[2] + 1, endSelection[1]);
  31912. endOfDragCoords = new _src.CellCoords(endSelection[2], endSelection[3]);
  31913. }
  31914. return {
  31915. directionOfDrag: directionOfDrag,
  31916. startOfDragCoords: startOfDragCoords,
  31917. endOfDragCoords: endOfDragCoords
  31918. };
  31919. }
  31920. /**
  31921. * Get mapped FillHandle setting containing information about
  31922. * allowed FillHandle directions and if allowed is automatic insertion of rows on drag
  31923. *
  31924. * @param {Boolean|Object} fillHandle property of Handsontable settings
  31925. * @returns {{directions: Array, autoInsertRow: Boolean}} object allowing access to information
  31926. * about FillHandle in more useful way
  31927. */
  31928. function getMappedFillHandleSetting(fillHandle) {
  31929. var mappedSettings = {};
  31930. if (fillHandle === true) {
  31931. mappedSettings.directions = Object.keys(DIRECTIONS);
  31932. mappedSettings.autoInsertRow = true;
  31933. } else if ((0, _object.isObject)(fillHandle)) {
  31934. if ((0, _mixed.isDefined)(fillHandle.autoInsertRow)) {
  31935. // autoInsertRow for horizontal direction will be always false
  31936. if (fillHandle.direction === DIRECTIONS.horizontal) {
  31937. mappedSettings.autoInsertRow = false;
  31938. } else {
  31939. mappedSettings.autoInsertRow = fillHandle.autoInsertRow;
  31940. }
  31941. } else {
  31942. mappedSettings.autoInsertRow = false;
  31943. }
  31944. if ((0, _mixed.isDefined)(fillHandle.direction)) {
  31945. mappedSettings.directions = [fillHandle.direction];
  31946. } else {
  31947. mappedSettings.directions = Object.keys(DIRECTIONS);
  31948. }
  31949. } else if (typeof fillHandle === 'string') {
  31950. mappedSettings.directions = [fillHandle];
  31951. mappedSettings.autoInsertRow = true;
  31952. } else {
  31953. mappedSettings.directions = [];
  31954. mappedSettings.autoInsertRow = false;
  31955. }
  31956. return mappedSettings;
  31957. }
  31958. /***/ }),
  31959. /* 289 */
  31960. /***/ (function(module, exports, __webpack_require__) {
  31961. "use strict";
  31962. exports.__esModule = true;
  31963. 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); } };
  31964. 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; }; }();
  31965. var _base = __webpack_require__(10);
  31966. var _base2 = _interopRequireDefault(_base);
  31967. var _array = __webpack_require__(1);
  31968. var _feature = __webpack_require__(40);
  31969. var _element = __webpack_require__(0);
  31970. var _ghostTable = __webpack_require__(92);
  31971. var _ghostTable2 = _interopRequireDefault(_ghostTable);
  31972. var _object = __webpack_require__(2);
  31973. var _number = __webpack_require__(5);
  31974. var _plugins = __webpack_require__(8);
  31975. var _samplesGenerator = __webpack_require__(200);
  31976. var _samplesGenerator2 = _interopRequireDefault(_samplesGenerator);
  31977. var _string = __webpack_require__(36);
  31978. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  31979. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  31980. 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; }
  31981. 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; }
  31982. /**
  31983. * @plugin AutoRowSize
  31984. *
  31985. * @description
  31986. * This plugin allows to set row heights based on their highest cells.
  31987. *
  31988. * By default, the plugin is declared as `undefined`, which makes it disabled (same as if it was declared as `false`).
  31989. * Enabling this plugin may decrease the overall table performance, as it needs to calculate the heights of all cells to
  31990. * resize the rows accordingly.
  31991. * If you experience problems with the performance, try turning this feature off and declaring the row heights manually.
  31992. *
  31993. * Row height calculations are divided into sync and async part. Each of this parts has their own advantages and
  31994. * disadvantages. Synchronous calculations are faster but they block the browser UI, while the slower asynchronous operations don't
  31995. * block the browser UI.
  31996. *
  31997. * To configure the sync/async distribution, you can pass an absolute value (number of columns) or a percentage value to a config object:
  31998. * ```js
  31999. * ...
  32000. * // as a number (300 columns in sync, rest async)
  32001. * autoRowSize: {syncLimit: 300},
  32002. * ...
  32003. *
  32004. * ...
  32005. * // as a string (percent)
  32006. * autoRowSize: {syncLimit: '40%'},
  32007. * ...
  32008. * ```
  32009. *
  32010. * You can also use the `allowSampleDuplicates` option to allow sampling duplicate values when calculating the row height. Note, that this might have
  32011. * a negative impact on performance.
  32012. *
  32013. * To configure this plugin see {@link Options#autoRowSize}.
  32014. *
  32015. * @example
  32016. *
  32017. * ```js
  32018. * ...
  32019. * var hot = new Handsontable(document.getElementById('example'), {
  32020. * date: getData(),
  32021. * autoRowSize: true
  32022. * });
  32023. * // Access to plugin instance:
  32024. * var plugin = hot.getPlugin('autoRowSize');
  32025. *
  32026. * plugin.getRowHeight(4);
  32027. *
  32028. * if (plugin.isEnabled()) {
  32029. * // code...
  32030. * }
  32031. * ...
  32032. * ```
  32033. */
  32034. var AutoRowSize = function (_BasePlugin) {
  32035. _inherits(AutoRowSize, _BasePlugin);
  32036. _createClass(AutoRowSize, null, [{
  32037. key: 'CALCULATION_STEP',
  32038. get: function get() {
  32039. return 50;
  32040. }
  32041. }, {
  32042. key: 'SYNC_CALCULATION_LIMIT',
  32043. get: function get() {
  32044. return 500;
  32045. }
  32046. }]);
  32047. function AutoRowSize(hotInstance) {
  32048. _classCallCheck(this, AutoRowSize);
  32049. /**
  32050. * Cached rows heights.
  32051. *
  32052. * @type {Array}
  32053. */
  32054. var _this = _possibleConstructorReturn(this, (AutoRowSize.__proto__ || Object.getPrototypeOf(AutoRowSize)).call(this, hotInstance));
  32055. _this.heights = [];
  32056. /**
  32057. * Instance of {@link GhostTable} for rows and columns size calculations.
  32058. *
  32059. * @type {GhostTable}
  32060. */
  32061. _this.ghostTable = new _ghostTable2.default(_this.hot);
  32062. /**
  32063. * Instance of {@link SamplesGenerator} for generating samples necessary for rows height calculations.
  32064. *
  32065. * @type {SamplesGenerator}
  32066. */
  32067. _this.samplesGenerator = new _samplesGenerator2.default(function (row, col) {
  32068. if (row >= 0) {
  32069. return _this.hot.getDataAtCell(row, col);
  32070. } else if (row === -1) {
  32071. return _this.hot.getColHeader(col);
  32072. }
  32073. return null;
  32074. });
  32075. /**
  32076. * `true` if only the first calculation was performed.
  32077. *
  32078. * @type {Boolean}
  32079. */
  32080. _this.firstCalculation = true;
  32081. /**
  32082. * `true` if the size calculation is in progress.
  32083. *
  32084. * @type {Boolean}
  32085. */
  32086. _this.inProgress = false;
  32087. // moved to constructor to allow auto-sizing the rows when the plugin is disabled
  32088. _this.addHook('beforeRowResize', function (row, size, isDblClick) {
  32089. return _this.onBeforeRowResize(row, size, isDblClick);
  32090. });
  32091. return _this;
  32092. }
  32093. /**
  32094. * Check if the plugin is enabled in the Handsontable settings.
  32095. *
  32096. * @returns {Boolean}
  32097. */
  32098. _createClass(AutoRowSize, [{
  32099. key: 'isEnabled',
  32100. value: function isEnabled() {
  32101. return this.hot.getSettings().autoRowSize === true || (0, _object.isObject)(this.hot.getSettings().autoRowSize);
  32102. }
  32103. /**
  32104. * Enable plugin for this Handsontable instance.
  32105. */
  32106. }, {
  32107. key: 'enablePlugin',
  32108. value: function enablePlugin() {
  32109. var _this2 = this;
  32110. if (this.enabled) {
  32111. return;
  32112. }
  32113. this.setSamplingOptions();
  32114. this.addHook('afterLoadData', function () {
  32115. return _this2.onAfterLoadData();
  32116. });
  32117. this.addHook('beforeChange', function (changes) {
  32118. return _this2.onBeforeChange(changes);
  32119. });
  32120. this.addHook('beforeColumnMove', function () {
  32121. return _this2.recalculateAllRowsHeight();
  32122. });
  32123. this.addHook('beforeColumnResize', function () {
  32124. return _this2.recalculateAllRowsHeight();
  32125. });
  32126. this.addHook('beforeColumnSort', function () {
  32127. return _this2.clearCache();
  32128. });
  32129. this.addHook('beforeRender', function (force) {
  32130. return _this2.onBeforeRender(force);
  32131. });
  32132. this.addHook('beforeRowMove', function (rowStart, rowEnd) {
  32133. return _this2.onBeforeRowMove(rowStart, rowEnd);
  32134. });
  32135. this.addHook('modifyRowHeight', function (height, row) {
  32136. return _this2.getRowHeight(row, height);
  32137. });
  32138. this.addHook('modifyColumnHeaderHeight', function () {
  32139. return _this2.getColumnHeaderHeight();
  32140. });
  32141. _get(AutoRowSize.prototype.__proto__ || Object.getPrototypeOf(AutoRowSize.prototype), 'enablePlugin', this).call(this);
  32142. }
  32143. /**
  32144. * Disable plugin for this Handsontable instance.
  32145. */
  32146. }, {
  32147. key: 'disablePlugin',
  32148. value: function disablePlugin() {
  32149. _get(AutoRowSize.prototype.__proto__ || Object.getPrototypeOf(AutoRowSize.prototype), 'disablePlugin', this).call(this);
  32150. }
  32151. /**
  32152. * Calculate a given rows height.
  32153. *
  32154. * @param {Number|Object} rowRange Row range object.
  32155. * @param {Number|Object} colRange Column range object.
  32156. * @param {Boolean} [force=false] If `true` force calculate height even when value was cached earlier.
  32157. */
  32158. }, {
  32159. key: 'calculateRowsHeight',
  32160. value: function calculateRowsHeight() {
  32161. var rowRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { from: 0, to: this.hot.countRows() - 1 };
  32162. var _this3 = this;
  32163. var colRange = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { from: 0, to: this.hot.countCols() - 1 };
  32164. var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  32165. if (typeof rowRange === 'number') {
  32166. rowRange = { from: rowRange, to: rowRange };
  32167. }
  32168. if (typeof colRange === 'number') {
  32169. colRange = { from: colRange, to: colRange };
  32170. }
  32171. if (this.hot.getColHeader(0) !== null) {
  32172. var samples = this.samplesGenerator.generateRowSamples(-1, colRange);
  32173. this.ghostTable.addColumnHeadersRow(samples.get(-1));
  32174. }
  32175. (0, _number.rangeEach)(rowRange.from, rowRange.to, function (row) {
  32176. // For rows we must calculate row height even when user had set height value manually.
  32177. // We can shrink column but cannot shrink rows!
  32178. if (force || _this3.heights[row] === void 0) {
  32179. var _samples = _this3.samplesGenerator.generateRowSamples(row, colRange);
  32180. _samples.forEach(function (sample, row) {
  32181. _this3.ghostTable.addRow(row, sample);
  32182. });
  32183. }
  32184. });
  32185. if (this.ghostTable.rows.length) {
  32186. this.ghostTable.getHeights(function (row, height) {
  32187. _this3.heights[row] = height;
  32188. });
  32189. this.ghostTable.clean();
  32190. }
  32191. }
  32192. /**
  32193. * Calculate the height of all the rows.
  32194. *
  32195. * @param {Object|Number} colRange Column range object.
  32196. */
  32197. }, {
  32198. key: 'calculateAllRowsHeight',
  32199. value: function calculateAllRowsHeight() {
  32200. var _this4 = this;
  32201. var colRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { from: 0, to: this.hot.countCols() - 1 };
  32202. var current = 0;
  32203. var length = this.hot.countRows() - 1;
  32204. var timer = null;
  32205. this.inProgress = true;
  32206. var loop = function loop() {
  32207. // When hot was destroyed after calculating finished cancel frame
  32208. if (!_this4.hot) {
  32209. (0, _feature.cancelAnimationFrame)(timer);
  32210. _this4.inProgress = false;
  32211. return;
  32212. }
  32213. _this4.calculateRowsHeight({ from: current, to: Math.min(current + AutoRowSize.CALCULATION_STEP, length) }, colRange);
  32214. current = current + AutoRowSize.CALCULATION_STEP + 1;
  32215. if (current < length) {
  32216. timer = (0, _feature.requestAnimationFrame)(loop);
  32217. } else {
  32218. (0, _feature.cancelAnimationFrame)(timer);
  32219. _this4.inProgress = false;
  32220. // @TODO Should call once per render cycle, currently fired separately in different plugins
  32221. _this4.hot.view.wt.wtOverlays.adjustElementsSize(true);
  32222. // tmp
  32223. if (_this4.hot.view.wt.wtOverlays.leftOverlay.needFullRender) {
  32224. _this4.hot.view.wt.wtOverlays.leftOverlay.clone.draw();
  32225. }
  32226. }
  32227. };
  32228. // sync
  32229. if (this.firstCalculation && this.getSyncCalculationLimit()) {
  32230. this.calculateRowsHeight({ from: 0, to: this.getSyncCalculationLimit() }, colRange);
  32231. this.firstCalculation = false;
  32232. current = this.getSyncCalculationLimit() + 1;
  32233. }
  32234. // async
  32235. if (current < length) {
  32236. loop();
  32237. } else {
  32238. this.inProgress = false;
  32239. this.hot.view.wt.wtOverlays.adjustElementsSize(false);
  32240. }
  32241. }
  32242. /**
  32243. * Set the sampling options.
  32244. *
  32245. * @private
  32246. */
  32247. }, {
  32248. key: 'setSamplingOptions',
  32249. value: function setSamplingOptions() {
  32250. var setting = this.hot.getSettings().autoRowSize;
  32251. var samplingRatio = setting && (0, _object.hasOwnProperty)(setting, 'samplingRatio') ? this.hot.getSettings().autoRowSize.samplingRatio : void 0;
  32252. var allowSampleDuplicates = setting && (0, _object.hasOwnProperty)(setting, 'allowSampleDuplicates') ? this.hot.getSettings().autoRowSize.allowSampleDuplicates : void 0;
  32253. if (samplingRatio && !isNaN(samplingRatio)) {
  32254. this.samplesGenerator.setSampleCount(parseInt(samplingRatio, 10));
  32255. }
  32256. if (allowSampleDuplicates) {
  32257. this.samplesGenerator.setAllowDuplicates(allowSampleDuplicates);
  32258. }
  32259. }
  32260. /**
  32261. * Recalculate all rows height (overwrite cache values).
  32262. */
  32263. }, {
  32264. key: 'recalculateAllRowsHeight',
  32265. value: function recalculateAllRowsHeight() {
  32266. if ((0, _element.isVisible)(this.hot.view.wt.wtTable.TABLE)) {
  32267. this.clearCache();
  32268. this.calculateAllRowsHeight();
  32269. }
  32270. }
  32271. /**
  32272. * Get value which tells how much rows will be calculated synchronously. Rest rows will be calculated asynchronously.
  32273. *
  32274. * @returns {Number}
  32275. */
  32276. }, {
  32277. key: 'getSyncCalculationLimit',
  32278. value: function getSyncCalculationLimit() {
  32279. /* eslint-disable no-bitwise */
  32280. var limit = AutoRowSize.SYNC_CALCULATION_LIMIT;
  32281. var rowsLimit = this.hot.countRows() - 1;
  32282. if ((0, _object.isObject)(this.hot.getSettings().autoRowSize)) {
  32283. limit = this.hot.getSettings().autoRowSize.syncLimit;
  32284. if ((0, _string.isPercentValue)(limit)) {
  32285. limit = (0, _number.valueAccordingPercent)(rowsLimit, limit);
  32286. } else {
  32287. // Force to Number
  32288. limit >>= 0;
  32289. }
  32290. }
  32291. return Math.min(limit, rowsLimit);
  32292. }
  32293. /**
  32294. * Get the calculated row height.
  32295. *
  32296. * @param {Number} row Visual row index.
  32297. * @param {Number} [defaultHeight] Default row height. It will be pick up if no calculated height found.
  32298. * @returns {Number}
  32299. */
  32300. }, {
  32301. key: 'getRowHeight',
  32302. value: function getRowHeight(row) {
  32303. var defaultHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : void 0;
  32304. var height = defaultHeight;
  32305. if (this.heights[row] !== void 0 && this.heights[row] > (defaultHeight || 0)) {
  32306. height = this.heights[row];
  32307. }
  32308. return height;
  32309. }
  32310. /**
  32311. * Get the calculated column header height.
  32312. *
  32313. * @returns {Number|undefined}
  32314. */
  32315. }, {
  32316. key: 'getColumnHeaderHeight',
  32317. value: function getColumnHeaderHeight() {
  32318. return this.heights[-1];
  32319. }
  32320. /**
  32321. * Get the first visible row.
  32322. *
  32323. * @returns {Number} Returns row index or -1 if table is not rendered.
  32324. */
  32325. }, {
  32326. key: 'getFirstVisibleRow',
  32327. value: function getFirstVisibleRow() {
  32328. var wot = this.hot.view.wt;
  32329. if (wot.wtViewport.rowsVisibleCalculator) {
  32330. return wot.wtTable.getFirstVisibleRow();
  32331. }
  32332. if (wot.wtViewport.rowsRenderCalculator) {
  32333. return wot.wtTable.getFirstRenderedRow();
  32334. }
  32335. return -1;
  32336. }
  32337. /**
  32338. * Get the last visible row.
  32339. *
  32340. * @returns {Number} Returns row index or -1 if table is not rendered.
  32341. */
  32342. }, {
  32343. key: 'getLastVisibleRow',
  32344. value: function getLastVisibleRow() {
  32345. var wot = this.hot.view.wt;
  32346. if (wot.wtViewport.rowsVisibleCalculator) {
  32347. return wot.wtTable.getLastVisibleRow();
  32348. }
  32349. if (wot.wtViewport.rowsRenderCalculator) {
  32350. return wot.wtTable.getLastRenderedRow();
  32351. }
  32352. return -1;
  32353. }
  32354. /**
  32355. * Clear cached heights.
  32356. */
  32357. }, {
  32358. key: 'clearCache',
  32359. value: function clearCache() {
  32360. this.heights.length = 0;
  32361. this.heights[-1] = void 0;
  32362. }
  32363. /**
  32364. * Clear cache by range.
  32365. *
  32366. * @param {Object|Number} range Row range object.
  32367. */
  32368. }, {
  32369. key: 'clearCacheByRange',
  32370. value: function clearCacheByRange(range) {
  32371. var _this5 = this;
  32372. if (typeof range === 'number') {
  32373. range = { from: range, to: range };
  32374. }
  32375. (0, _number.rangeEach)(Math.min(range.from, range.to), Math.max(range.from, range.to), function (row) {
  32376. _this5.heights[row] = void 0;
  32377. });
  32378. }
  32379. /**
  32380. * @returns {Boolean}
  32381. */
  32382. }, {
  32383. key: 'isNeedRecalculate',
  32384. value: function isNeedRecalculate() {
  32385. return !!(0, _array.arrayFilter)(this.heights, function (item) {
  32386. return item === void 0;
  32387. }).length;
  32388. }
  32389. /**
  32390. * On before render listener.
  32391. *
  32392. * @private
  32393. */
  32394. }, {
  32395. key: 'onBeforeRender',
  32396. value: function onBeforeRender() {
  32397. var force = this.hot.renderCall;
  32398. this.calculateRowsHeight({ from: this.getFirstVisibleRow(), to: this.getLastVisibleRow() }, void 0, force);
  32399. var fixedRowsBottom = this.hot.getSettings().fixedRowsBottom;
  32400. // Calculate rows height synchronously for bottom overlay
  32401. if (fixedRowsBottom) {
  32402. var totalRows = this.hot.countRows() - 1;
  32403. this.calculateRowsHeight({ from: totalRows - fixedRowsBottom, to: totalRows });
  32404. }
  32405. if (this.isNeedRecalculate() && !this.inProgress) {
  32406. this.calculateAllRowsHeight();
  32407. }
  32408. }
  32409. /**
  32410. * On before row move listener.
  32411. *
  32412. * @private
  32413. * @param {Number} from Row index where was grabbed.
  32414. * @param {Number} to Destination row index.
  32415. */
  32416. }, {
  32417. key: 'onBeforeRowMove',
  32418. value: function onBeforeRowMove(from, to) {
  32419. this.clearCacheByRange({ from: from, to: to });
  32420. this.calculateAllRowsHeight();
  32421. }
  32422. /**
  32423. * On before row resize listener.
  32424. *
  32425. * @private
  32426. * @param {Number} row
  32427. * @param {Number} size
  32428. * @param {Boolean} isDblClick
  32429. * @returns {Number}
  32430. */
  32431. }, {
  32432. key: 'onBeforeRowResize',
  32433. value: function onBeforeRowResize(row, size, isDblClick) {
  32434. if (isDblClick) {
  32435. this.calculateRowsHeight(row, void 0, true);
  32436. size = this.getRowHeight(row);
  32437. }
  32438. return size;
  32439. }
  32440. /**
  32441. * On after load data listener.
  32442. *
  32443. * @private
  32444. */
  32445. }, {
  32446. key: 'onAfterLoadData',
  32447. value: function onAfterLoadData() {
  32448. var _this6 = this;
  32449. if (this.hot.view) {
  32450. this.recalculateAllRowsHeight();
  32451. } else {
  32452. // first load - initialization
  32453. setTimeout(function () {
  32454. if (_this6.hot) {
  32455. _this6.recalculateAllRowsHeight();
  32456. }
  32457. }, 0);
  32458. }
  32459. }
  32460. /**
  32461. * On before change listener.
  32462. *
  32463. * @private
  32464. * @param {Array} changes
  32465. */
  32466. }, {
  32467. key: 'onBeforeChange',
  32468. value: function onBeforeChange(changes) {
  32469. var range = null;
  32470. if (changes.length === 1) {
  32471. range = changes[0][0];
  32472. } else if (changes.length > 1) {
  32473. range = {
  32474. from: changes[0][0],
  32475. to: changes[changes.length - 1][0]
  32476. };
  32477. }
  32478. if (range !== null) {
  32479. this.clearCacheByRange(range);
  32480. }
  32481. }
  32482. /**
  32483. * Destroy plugin instance.
  32484. */
  32485. }, {
  32486. key: 'destroy',
  32487. value: function destroy() {
  32488. this.ghostTable.clean();
  32489. _get(AutoRowSize.prototype.__proto__ || Object.getPrototypeOf(AutoRowSize.prototype), 'destroy', this).call(this);
  32490. }
  32491. }]);
  32492. return AutoRowSize;
  32493. }(_base2.default);
  32494. (0, _plugins.registerPlugin)('autoRowSize', AutoRowSize);
  32495. exports.default = AutoRowSize;
  32496. /***/ }),
  32497. /* 290 */
  32498. /***/ (function(module, exports, __webpack_require__) {
  32499. "use strict";
  32500. exports.__esModule = true;
  32501. 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; };
  32502. 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; }; }();
  32503. 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); } };
  32504. var _moment = __webpack_require__(55);
  32505. var _moment2 = _interopRequireDefault(_moment);
  32506. var _element = __webpack_require__(0);
  32507. var _array = __webpack_require__(1);
  32508. var _mixed = __webpack_require__(16);
  32509. var _object = __webpack_require__(2);
  32510. var _base = __webpack_require__(10);
  32511. var _base2 = _interopRequireDefault(_base);
  32512. var _plugins = __webpack_require__(8);
  32513. var _mergeSort = __webpack_require__(291);
  32514. var _mergeSort2 = _interopRequireDefault(_mergeSort);
  32515. var _pluginHooks = __webpack_require__(15);
  32516. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  32517. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  32518. 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); } }
  32519. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  32520. 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; }
  32521. 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; }
  32522. _pluginHooks2.default.getSingleton().register('beforeColumnSort');
  32523. _pluginHooks2.default.getSingleton().register('afterColumnSort');
  32524. // TODO: Implement mixin arrayMapper to ColumnSorting plugin.
  32525. /**
  32526. * @plugin ColumnSorting
  32527. *
  32528. * @description
  32529. * This plugin sorts the view by a column (but does not sort the data source!).
  32530. * To enable the plugin, set the `columnSorting` property to either:
  32531. * * a boolean value (`true`/`false`),
  32532. * * an object defining the initial sorting order (see the example below).
  32533. *
  32534. * @example
  32535. * ```js
  32536. * ...
  32537. * // as boolean
  32538. * columnSorting: true
  32539. * ...
  32540. * // as a object with initial order (sort ascending column at index 2)
  32541. * columnSorting: {
  32542. * column: 2,
  32543. * sortOrder: true, // true = ascending, false = descending, undefined = original order
  32544. * sortEmptyCells: true // true = the table sorts empty cells, false = the table moves all empty cells to the end of the table
  32545. * }
  32546. * ...
  32547. * ```
  32548. * @dependencies ObserveChanges
  32549. */
  32550. var ColumnSorting = function (_BasePlugin) {
  32551. _inherits(ColumnSorting, _BasePlugin);
  32552. function ColumnSorting(hotInstance) {
  32553. _classCallCheck(this, ColumnSorting);
  32554. var _this2 = _possibleConstructorReturn(this, (ColumnSorting.__proto__ || Object.getPrototypeOf(ColumnSorting)).call(this, hotInstance));
  32555. _this2.sortIndicators = [];
  32556. _this2.lastSortedColumn = null;
  32557. _this2.sortEmptyCells = false;
  32558. return _this2;
  32559. }
  32560. /**
  32561. * Check if the plugin is enabled in the handsontable settings.
  32562. *
  32563. * @returns {Boolean}
  32564. */
  32565. _createClass(ColumnSorting, [{
  32566. key: 'isEnabled',
  32567. value: function isEnabled() {
  32568. return !!this.hot.getSettings().columnSorting;
  32569. }
  32570. /**
  32571. * Enable plugin for this Handsontable instance.
  32572. */
  32573. }, {
  32574. key: 'enablePlugin',
  32575. value: function enablePlugin() {
  32576. var _this3 = this;
  32577. if (this.enabled) {
  32578. return;
  32579. }
  32580. this.setPluginOptions();
  32581. var _this = this;
  32582. this.hot.sortIndex = [];
  32583. this.hot.sort = function () {
  32584. var args = Array.prototype.slice.call(arguments);
  32585. return _this.sortByColumn.apply(_this, _toConsumableArray(args));
  32586. };
  32587. if (typeof this.hot.getSettings().observeChanges === 'undefined') {
  32588. this.enableObserveChangesPlugin();
  32589. }
  32590. this.addHook('afterTrimRow', function (row) {
  32591. return _this3.sort();
  32592. });
  32593. this.addHook('afterUntrimRow', function (row) {
  32594. return _this3.sort();
  32595. });
  32596. this.addHook('modifyRow', function (row) {
  32597. return _this3.translateRow(row);
  32598. });
  32599. this.addHook('unmodifyRow', function (row) {
  32600. return _this3.untranslateRow(row);
  32601. });
  32602. this.addHook('afterUpdateSettings', function () {
  32603. return _this3.onAfterUpdateSettings();
  32604. });
  32605. this.addHook('afterGetColHeader', function (col, TH) {
  32606. return _this3.getColHeader(col, TH);
  32607. });
  32608. this.addHook('afterOnCellMouseDown', function (event, target) {
  32609. return _this3.onAfterOnCellMouseDown(event, target);
  32610. });
  32611. this.addHook('afterCreateRow', function () {
  32612. _this.afterCreateRow.apply(_this, arguments);
  32613. });
  32614. this.addHook('afterRemoveRow', function () {
  32615. _this.afterRemoveRow.apply(_this, arguments);
  32616. });
  32617. this.addHook('afterInit', function () {
  32618. return _this3.sortBySettings();
  32619. });
  32620. this.addHook('afterLoadData', function () {
  32621. _this3.hot.sortIndex = [];
  32622. if (_this3.hot.view) {
  32623. _this3.sortBySettings();
  32624. }
  32625. });
  32626. if (this.hot.view) {
  32627. this.sortBySettings();
  32628. }
  32629. _get(ColumnSorting.prototype.__proto__ || Object.getPrototypeOf(ColumnSorting.prototype), 'enablePlugin', this).call(this);
  32630. }
  32631. /**
  32632. * Disable plugin for this Handsontable instance.
  32633. */
  32634. }, {
  32635. key: 'disablePlugin',
  32636. value: function disablePlugin() {
  32637. this.hot.sort = void 0;
  32638. _get(ColumnSorting.prototype.__proto__ || Object.getPrototypeOf(ColumnSorting.prototype), 'disablePlugin', this).call(this);
  32639. }
  32640. /**
  32641. * afterUpdateSettings callback.
  32642. *
  32643. * @private
  32644. */
  32645. }, {
  32646. key: 'onAfterUpdateSettings',
  32647. value: function onAfterUpdateSettings() {
  32648. this.sortBySettings();
  32649. }
  32650. }, {
  32651. key: 'sortBySettings',
  32652. value: function sortBySettings() {
  32653. var sortingSettings = this.hot.getSettings().columnSorting;
  32654. var loadedSortingState = this.loadSortingState();
  32655. var sortingColumn = void 0;
  32656. var sortingOrder = void 0;
  32657. if (typeof loadedSortingState === 'undefined') {
  32658. sortingColumn = sortingSettings.column;
  32659. sortingOrder = sortingSettings.sortOrder;
  32660. } else {
  32661. sortingColumn = loadedSortingState.sortColumn;
  32662. sortingOrder = loadedSortingState.sortOrder;
  32663. }
  32664. if (typeof sortingColumn === 'number') {
  32665. this.lastSortedColumn = sortingColumn;
  32666. this.sortByColumn(sortingColumn, sortingOrder);
  32667. }
  32668. }
  32669. /**
  32670. * Set sorted column and order info
  32671. *
  32672. * @param {number} col Sorted visual column index.
  32673. * @param {boolean|undefined} order Sorting order (`true` for ascending, `false` for descending).
  32674. */
  32675. }, {
  32676. key: 'setSortingColumn',
  32677. value: function setSortingColumn(col, order) {
  32678. if (typeof col == 'undefined') {
  32679. this.hot.sortColumn = void 0;
  32680. this.hot.sortOrder = void 0;
  32681. return;
  32682. } else if (this.hot.sortColumn === col && typeof order == 'undefined') {
  32683. if (this.hot.sortOrder === false) {
  32684. this.hot.sortOrder = void 0;
  32685. } else {
  32686. this.hot.sortOrder = !this.hot.sortOrder;
  32687. }
  32688. } else {
  32689. this.hot.sortOrder = typeof order === 'undefined' ? true : order;
  32690. }
  32691. this.hot.sortColumn = col;
  32692. }
  32693. }, {
  32694. key: 'sortByColumn',
  32695. value: function sortByColumn(col, order) {
  32696. this.setSortingColumn(col, order);
  32697. if (typeof this.hot.sortColumn == 'undefined') {
  32698. return;
  32699. }
  32700. var allowSorting = this.hot.runHooks('beforeColumnSort', this.hot.sortColumn, this.hot.sortOrder);
  32701. if (allowSorting !== false) {
  32702. this.sort();
  32703. }
  32704. this.updateOrderClass();
  32705. this.updateSortIndicator();
  32706. this.hot.runHooks('afterColumnSort', this.hot.sortColumn, this.hot.sortOrder);
  32707. this.hot.render();
  32708. this.saveSortingState();
  32709. }
  32710. /**
  32711. * Save the sorting state
  32712. */
  32713. }, {
  32714. key: 'saveSortingState',
  32715. value: function saveSortingState() {
  32716. var sortingState = {};
  32717. if (typeof this.hot.sortColumn != 'undefined') {
  32718. sortingState.sortColumn = this.hot.sortColumn;
  32719. }
  32720. if (typeof this.hot.sortOrder != 'undefined') {
  32721. sortingState.sortOrder = this.hot.sortOrder;
  32722. }
  32723. if ((0, _object.hasOwnProperty)(sortingState, 'sortColumn') || (0, _object.hasOwnProperty)(sortingState, 'sortOrder')) {
  32724. this.hot.runHooks('persistentStateSave', 'columnSorting', sortingState);
  32725. }
  32726. }
  32727. /**
  32728. * Load the sorting state.
  32729. *
  32730. * @returns {*} Previously saved sorting state.
  32731. */
  32732. }, {
  32733. key: 'loadSortingState',
  32734. value: function loadSortingState() {
  32735. var storedState = {};
  32736. this.hot.runHooks('persistentStateLoad', 'columnSorting', storedState);
  32737. return storedState.value;
  32738. }
  32739. /**
  32740. * Update sorting class name state.
  32741. */
  32742. }, {
  32743. key: 'updateOrderClass',
  32744. value: function updateOrderClass() {
  32745. var orderClass = void 0;
  32746. if (this.hot.sortOrder === true) {
  32747. orderClass = 'ascending';
  32748. } else if (this.hot.sortOrder === false) {
  32749. orderClass = 'descending';
  32750. }
  32751. this.sortOrderClass = orderClass;
  32752. }
  32753. }, {
  32754. key: 'enableObserveChangesPlugin',
  32755. value: function enableObserveChangesPlugin() {
  32756. var _this = this;
  32757. this.hot._registerTimeout(setTimeout(function () {
  32758. _this.hot.updateSettings({
  32759. observeChanges: true
  32760. });
  32761. }, 0));
  32762. }
  32763. /**
  32764. * Default sorting algorithm.
  32765. *
  32766. * @param {Boolean} sortOrder Sorting order - `true` for ascending, `false` for descending.
  32767. * @param {Object} columnMeta Column meta object.
  32768. * @returns {Function} The comparing function.
  32769. */
  32770. }, {
  32771. key: 'defaultSort',
  32772. value: function defaultSort(sortOrder, columnMeta) {
  32773. return function (a, b) {
  32774. if (typeof a[1] == 'string') {
  32775. a[1] = a[1].toLowerCase();
  32776. }
  32777. if (typeof b[1] == 'string') {
  32778. b[1] = b[1].toLowerCase();
  32779. }
  32780. if (a[1] === b[1]) {
  32781. return 0;
  32782. }
  32783. if ((0, _mixed.isEmpty)(a[1])) {
  32784. if ((0, _mixed.isEmpty)(b[1])) {
  32785. return 0;
  32786. }
  32787. if (columnMeta.columnSorting.sortEmptyCells) {
  32788. return sortOrder ? -1 : 1;
  32789. }
  32790. return 1;
  32791. }
  32792. if ((0, _mixed.isEmpty)(b[1])) {
  32793. if ((0, _mixed.isEmpty)(a[1])) {
  32794. return 0;
  32795. }
  32796. if (columnMeta.columnSorting.sortEmptyCells) {
  32797. return sortOrder ? 1 : -1;
  32798. }
  32799. return -1;
  32800. }
  32801. if (isNaN(a[1]) && !isNaN(b[1])) {
  32802. return sortOrder ? 1 : -1;
  32803. } else if (!isNaN(a[1]) && isNaN(b[1])) {
  32804. return sortOrder ? -1 : 1;
  32805. } else if (!(isNaN(a[1]) || isNaN(b[1]))) {
  32806. a[1] = parseFloat(a[1]);
  32807. b[1] = parseFloat(b[1]);
  32808. }
  32809. if (a[1] < b[1]) {
  32810. return sortOrder ? -1 : 1;
  32811. }
  32812. if (a[1] > b[1]) {
  32813. return sortOrder ? 1 : -1;
  32814. }
  32815. return 0;
  32816. };
  32817. }
  32818. /**
  32819. * Date sorting algorithm
  32820. * @param {Boolean} sortOrder Sorting order (`true` for ascending, `false` for descending).
  32821. * @param {Object} columnMeta Column meta object.
  32822. * @returns {Function} The compare function.
  32823. */
  32824. }, {
  32825. key: 'dateSort',
  32826. value: function dateSort(sortOrder, columnMeta) {
  32827. return function (a, b) {
  32828. if (a[1] === b[1]) {
  32829. return 0;
  32830. }
  32831. if ((0, _mixed.isEmpty)(a[1])) {
  32832. if ((0, _mixed.isEmpty)(b[1])) {
  32833. return 0;
  32834. }
  32835. if (columnMeta.columnSorting.sortEmptyCells) {
  32836. return sortOrder ? -1 : 1;
  32837. }
  32838. return 1;
  32839. }
  32840. if ((0, _mixed.isEmpty)(b[1])) {
  32841. if ((0, _mixed.isEmpty)(a[1])) {
  32842. return 0;
  32843. }
  32844. if (columnMeta.columnSorting.sortEmptyCells) {
  32845. return sortOrder ? 1 : -1;
  32846. }
  32847. return -1;
  32848. }
  32849. var aDate = (0, _moment2.default)(a[1], columnMeta.dateFormat);
  32850. var bDate = (0, _moment2.default)(b[1], columnMeta.dateFormat);
  32851. if (!aDate.isValid()) {
  32852. return 1;
  32853. }
  32854. if (!bDate.isValid()) {
  32855. return -1;
  32856. }
  32857. if (bDate.isAfter(aDate)) {
  32858. return sortOrder ? -1 : 1;
  32859. }
  32860. if (bDate.isBefore(aDate)) {
  32861. return sortOrder ? 1 : -1;
  32862. }
  32863. return 0;
  32864. };
  32865. }
  32866. /**
  32867. * Numeric sorting algorithm.
  32868. *
  32869. * @param {Boolean} sortOrder Sorting order (`true` for ascending, `false` for descending).
  32870. * @param {Object} columnMeta Column meta object.
  32871. * @returns {Function} The compare function.
  32872. */
  32873. }, {
  32874. key: 'numericSort',
  32875. value: function numericSort(sortOrder, columnMeta) {
  32876. return function (a, b) {
  32877. var parsedA = parseFloat(a[1]);
  32878. var parsedB = parseFloat(b[1]);
  32879. // Watch out when changing this part of code!
  32880. // Check below returns 0 (as expected) when comparing empty string, null, undefined
  32881. if (parsedA === parsedB || isNaN(parsedA) && isNaN(parsedB)) {
  32882. return 0;
  32883. }
  32884. if (columnMeta.columnSorting.sortEmptyCells) {
  32885. if ((0, _mixed.isEmpty)(a[1])) {
  32886. return sortOrder ? -1 : 1;
  32887. }
  32888. if ((0, _mixed.isEmpty)(b[1])) {
  32889. return sortOrder ? 1 : -1;
  32890. }
  32891. }
  32892. if (isNaN(parsedA)) {
  32893. return 1;
  32894. }
  32895. if (isNaN(parsedB)) {
  32896. return -1;
  32897. }
  32898. if (parsedA < parsedB) {
  32899. return sortOrder ? -1 : 1;
  32900. } else if (parsedA > parsedB) {
  32901. return sortOrder ? 1 : -1;
  32902. }
  32903. return 0;
  32904. };
  32905. }
  32906. /**
  32907. * Perform the sorting.
  32908. */
  32909. }, {
  32910. key: 'sort',
  32911. value: function sort() {
  32912. if (typeof this.hot.sortOrder == 'undefined') {
  32913. this.hot.sortIndex.length = 0;
  32914. return;
  32915. }
  32916. var colMeta = this.hot.getCellMeta(0, this.hot.sortColumn);
  32917. var emptyRows = this.hot.countEmptyRows();
  32918. var sortFunction = void 0;
  32919. var nrOfRows = void 0;
  32920. this.hot.sortingEnabled = false; // this is required by translateRow plugin hook
  32921. this.hot.sortIndex.length = 0;
  32922. if (typeof colMeta.columnSorting.sortEmptyCells === 'undefined') {
  32923. colMeta.columnSorting = { sortEmptyCells: this.sortEmptyCells };
  32924. }
  32925. if (this.hot.getSettings().maxRows === Number.POSITIVE_INFINITY) {
  32926. nrOfRows = this.hot.countRows() - this.hot.getSettings().minSpareRows;
  32927. } else {
  32928. nrOfRows = this.hot.countRows() - emptyRows;
  32929. }
  32930. for (var i = 0, ilen = nrOfRows; i < ilen; i++) {
  32931. this.hot.sortIndex.push([i, this.hot.getDataAtCell(i, this.hot.sortColumn)]);
  32932. }
  32933. if (colMeta.sortFunction) {
  32934. sortFunction = colMeta.sortFunction;
  32935. } else {
  32936. switch (colMeta.type) {
  32937. case 'date':
  32938. sortFunction = this.dateSort;
  32939. break;
  32940. case 'numeric':
  32941. sortFunction = this.numericSort;
  32942. break;
  32943. default:
  32944. sortFunction = this.defaultSort;
  32945. }
  32946. }
  32947. (0, _mergeSort2.default)(this.hot.sortIndex, sortFunction(this.hot.sortOrder, colMeta));
  32948. // Append spareRows
  32949. for (var _i = this.hot.sortIndex.length; _i < this.hot.countRows(); _i++) {
  32950. this.hot.sortIndex.push([_i, this.hot.getDataAtCell(_i, this.hot.sortColumn)]);
  32951. }
  32952. this.hot.sortingEnabled = true; // this is required by translateRow plugin hook
  32953. }
  32954. /**
  32955. * Update indicator states.
  32956. */
  32957. }, {
  32958. key: 'updateSortIndicator',
  32959. value: function updateSortIndicator() {
  32960. if (typeof this.hot.sortOrder == 'undefined') {
  32961. return;
  32962. }
  32963. var colMeta = this.hot.getCellMeta(0, this.hot.sortColumn);
  32964. this.sortIndicators[this.hot.sortColumn] = colMeta.sortIndicator;
  32965. }
  32966. /**
  32967. * `modifyRow` hook callback. Translates physical row index to the sorted row index.
  32968. *
  32969. * @param {Number} row Row index.
  32970. * @returns {Number} Sorted row index.
  32971. */
  32972. }, {
  32973. key: 'translateRow',
  32974. value: function translateRow(row) {
  32975. if (this.hot.sortingEnabled && typeof this.hot.sortOrder !== 'undefined' && this.hot.sortIndex && this.hot.sortIndex.length && this.hot.sortIndex[row]) {
  32976. return this.hot.sortIndex[row][0];
  32977. }
  32978. return row;
  32979. }
  32980. /**
  32981. * Translates sorted row index to physical row index.
  32982. *
  32983. * @param {Number} row Sorted (visual) row index.
  32984. * @returns {number} Physical row index.
  32985. */
  32986. }, {
  32987. key: 'untranslateRow',
  32988. value: function untranslateRow(row) {
  32989. if (this.hot.sortingEnabled && this.hot.sortIndex && this.hot.sortIndex.length) {
  32990. for (var i = 0; i < this.hot.sortIndex.length; i++) {
  32991. if (this.hot.sortIndex[i][0] == row) {
  32992. return i;
  32993. }
  32994. }
  32995. }
  32996. }
  32997. /**
  32998. * `afterGetColHeader` callback. Adds column sorting css classes to clickable headers.
  32999. *
  33000. * @private
  33001. * @param {Number} col Visual column index.
  33002. * @param {Element} TH TH HTML element.
  33003. */
  33004. }, {
  33005. key: 'getColHeader',
  33006. value: function getColHeader(col, TH) {
  33007. if (col < 0 || !TH.parentNode) {
  33008. return false;
  33009. }
  33010. var headerLink = TH.querySelector('.colHeader');
  33011. var colspan = TH.getAttribute('colspan');
  33012. var TRs = TH.parentNode.parentNode.childNodes;
  33013. var headerLevel = Array.prototype.indexOf.call(TRs, TH.parentNode);
  33014. headerLevel -= TRs.length;
  33015. if (!headerLink) {
  33016. return;
  33017. }
  33018. if (this.hot.getSettings().columnSorting && col >= 0 && headerLevel === -1) {
  33019. (0, _element.addClass)(headerLink, 'columnSorting');
  33020. }
  33021. (0, _element.removeClass)(headerLink, 'descending');
  33022. (0, _element.removeClass)(headerLink, 'ascending');
  33023. if (this.sortIndicators[col]) {
  33024. if (col === this.hot.sortColumn) {
  33025. if (this.sortOrderClass === 'ascending') {
  33026. (0, _element.addClass)(headerLink, 'ascending');
  33027. } else if (this.sortOrderClass === 'descending') {
  33028. (0, _element.addClass)(headerLink, 'descending');
  33029. }
  33030. }
  33031. }
  33032. }
  33033. /**
  33034. * Check if any column is in a sorted state.
  33035. *
  33036. * @returns {Boolean}
  33037. */
  33038. }, {
  33039. key: 'isSorted',
  33040. value: function isSorted() {
  33041. return typeof this.hot.sortColumn != 'undefined';
  33042. }
  33043. /**
  33044. * `afterCreateRow` callback. Updates the sorting state after a row have been created.
  33045. *
  33046. * @private
  33047. * @param {Number} index Visual row index.
  33048. * @param {Number} amount
  33049. */
  33050. }, {
  33051. key: 'afterCreateRow',
  33052. value: function afterCreateRow(index, amount) {
  33053. if (!this.isSorted()) {
  33054. return;
  33055. }
  33056. for (var i = 0; i < this.hot.sortIndex.length; i++) {
  33057. if (this.hot.sortIndex[i][0] >= index) {
  33058. this.hot.sortIndex[i][0] += amount;
  33059. }
  33060. }
  33061. for (var _i2 = 0; _i2 < amount; _i2++) {
  33062. this.hot.sortIndex.splice(index + _i2, 0, [index + _i2, this.hot.getSourceData()[index + _i2][this.hot.sortColumn + this.hot.colOffset()]]);
  33063. }
  33064. this.saveSortingState();
  33065. }
  33066. /**
  33067. * `afterRemoveRow` hook callback.
  33068. *
  33069. * @private
  33070. * @param {Number} index Visual row index.
  33071. * @param {Number} amount
  33072. */
  33073. }, {
  33074. key: 'afterRemoveRow',
  33075. value: function afterRemoveRow(index, amount) {
  33076. if (!this.isSorted()) {
  33077. return;
  33078. }
  33079. var removedRows = this.hot.sortIndex.splice(index, amount);
  33080. removedRows = (0, _array.arrayMap)(removedRows, function (row) {
  33081. return row[0];
  33082. });
  33083. function countRowShift(logicalRow) {
  33084. // Todo: compare perf between reduce vs sort->each->brake
  33085. return (0, _array.arrayReduce)(removedRows, function (count, removedLogicalRow) {
  33086. if (logicalRow > removedLogicalRow) {
  33087. count++;
  33088. }
  33089. return count;
  33090. }, 0);
  33091. }
  33092. this.hot.sortIndex = (0, _array.arrayMap)(this.hot.sortIndex, function (logicalRow, physicalRow) {
  33093. var rowShift = countRowShift(logicalRow[0]);
  33094. if (rowShift) {
  33095. logicalRow[0] -= rowShift;
  33096. }
  33097. return logicalRow;
  33098. });
  33099. this.saveSortingState();
  33100. }
  33101. /**
  33102. * Set options by passed settings
  33103. *
  33104. * @private
  33105. */
  33106. }, {
  33107. key: 'setPluginOptions',
  33108. value: function setPluginOptions() {
  33109. var columnSorting = this.hot.getSettings().columnSorting;
  33110. if ((typeof columnSorting === 'undefined' ? 'undefined' : _typeof(columnSorting)) === 'object') {
  33111. this.sortEmptyCells = columnSorting.sortEmptyCells || false;
  33112. } else {
  33113. this.sortEmptyCells = false;
  33114. }
  33115. }
  33116. /**
  33117. * `onAfterOnCellMouseDown` hook callback.
  33118. *
  33119. * @private
  33120. * @param {Event} event Event which are provided by hook.
  33121. * @param {CellCoords} coords Visual coords of the selected cell.
  33122. */
  33123. }, {
  33124. key: 'onAfterOnCellMouseDown',
  33125. value: function onAfterOnCellMouseDown(event, coords) {
  33126. if (coords.row > -1) {
  33127. return;
  33128. }
  33129. if ((0, _element.hasClass)(event.realTarget, 'columnSorting')) {
  33130. // reset order state on every new column header click
  33131. if (coords.col !== this.lastSortedColumn) {
  33132. this.hot.sortOrder = true;
  33133. }
  33134. this.lastSortedColumn = coords.col;
  33135. this.sortByColumn(coords.col);
  33136. }
  33137. }
  33138. }]);
  33139. return ColumnSorting;
  33140. }(_base2.default);
  33141. (0, _plugins.registerPlugin)('columnSorting', ColumnSorting);
  33142. exports.default = ColumnSorting;
  33143. /***/ }),
  33144. /* 291 */
  33145. /***/ (function(module, exports, __webpack_require__) {
  33146. "use strict";
  33147. exports.__esModule = true;
  33148. exports.default = mergeSort;
  33149. exports.merge = merge;
  33150. var _linkedList = __webpack_require__(292);
  33151. var _linkedList2 = _interopRequireDefault(_linkedList);
  33152. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  33153. /**
  33154. * Refactored implementation of mergeSort (part of javascript-algorithms project) by Github users:
  33155. * mgechev, AndriiHeonia and lekkas (part of javascript-algorithms project - all project contributors
  33156. * at repository website)
  33157. *
  33158. * Link to repository: https://github.com/mgechev/javascript-algorithms
  33159. */
  33160. /**
  33161. * Specifies a function that defines the sort order. The array is sorted according to each
  33162. * character's Unicode code point value, according to the string conversion of each element.
  33163. *
  33164. * @param a {*} first compared element.
  33165. * @param b {*} second compared element.
  33166. * @returns {Number}
  33167. */
  33168. var defaultCompareFunction = function defaultCompareFunction(a, b) {
  33169. // sort lexically
  33170. var firstValue = a.toString();
  33171. var secondValue = b.toString();
  33172. if (firstValue === secondValue) {
  33173. return 0;
  33174. } else if (firstValue < secondValue) {
  33175. return -1;
  33176. }
  33177. return 1;
  33178. };
  33179. /**
  33180. * Mergesort method which is recursively called for sorting the input array.
  33181. *
  33182. * @param {Array} array The array which should be sorted.
  33183. * @param {Function} compareFunction Compares two items in an array. If compareFunction is not supplied,
  33184. * elements are sorted by converting them to strings and comparing strings in Unicode code point order.
  33185. * @param {Number} startIndex Left side of the subarray.
  33186. * @param {Number} endIndex Right side of the subarray.
  33187. * @returns {Array} Array with sorted subarray.
  33188. */
  33189. function mergeSort(array) {
  33190. var compareFunction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultCompareFunction;
  33191. var startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  33192. var endIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : array.length;
  33193. if (Math.abs(endIndex - startIndex) <= 1) {
  33194. return [];
  33195. }
  33196. var middleIndex = Math.ceil((startIndex + endIndex) / 2);
  33197. mergeSort(array, compareFunction, startIndex, middleIndex);
  33198. mergeSort(array, compareFunction, middleIndex, endIndex);
  33199. return merge(array, compareFunction, startIndex, middleIndex, endIndex);
  33200. }
  33201. /**
  33202. * Devides and sort merges two subarrays of given array
  33203. *
  33204. * @param {Array} array The array which subarrays should be sorted.
  33205. * @param {Number} startIndex The start of the first subarray.
  33206. * This subarray is with end middle - 1.
  33207. * @param {Number} middleIndex The start of the second array.
  33208. * @param {Number} endIndex end - 1 is the end of the second array.
  33209. * @returns {Array} The array with sorted subarray.
  33210. */
  33211. function merge(array, compareFunction, startIndex, middleIndex, endIndex) {
  33212. var leftElements = new _linkedList2.default();
  33213. var rightElements = new _linkedList2.default();
  33214. var leftSize = middleIndex - startIndex;
  33215. var rightSize = endIndex - middleIndex;
  33216. var maxSize = Math.max(leftSize, rightSize);
  33217. var size = endIndex - startIndex;
  33218. for (var _i = 0; _i < maxSize; _i += 1) {
  33219. if (_i < leftSize) {
  33220. leftElements.push(array[startIndex + _i]);
  33221. }
  33222. if (_i < rightSize) {
  33223. rightElements.push(array[middleIndex + _i]);
  33224. }
  33225. }
  33226. var i = 0;
  33227. while (i < size) {
  33228. if (leftElements.first && rightElements.first) {
  33229. if (compareFunction(leftElements.first.data, rightElements.first.data) > 0) {
  33230. array[startIndex + i] = rightElements.shift().data;
  33231. } else {
  33232. array[startIndex + i] = leftElements.shift().data;
  33233. }
  33234. } else if (leftElements.first) {
  33235. array[startIndex + i] = leftElements.shift().data;
  33236. } else {
  33237. array[startIndex + i] = rightElements.shift().data;
  33238. }
  33239. i += 1;
  33240. }
  33241. return array;
  33242. };
  33243. /***/ }),
  33244. /* 292 */
  33245. /***/ (function(module, exports, __webpack_require__) {
  33246. "use strict";
  33247. exports.__esModule = true;
  33248. 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; }; }();
  33249. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  33250. /**
  33251. * Refactored implementation of LinkedList (part of javascript-algorithms project) by Github users:
  33252. * mgechev, AndriiHeonia, Microfed and Jakeh (part of javascript-algorithms project - all project contributors
  33253. * at repository website)
  33254. *
  33255. * Link to repository: https://github.com/mgechev/javascript-algorithms
  33256. */
  33257. /**
  33258. * Linked list node.
  33259. *
  33260. * @class NodeStructure
  33261. * @util
  33262. */
  33263. var NodeStructure = function NodeStructure(data) {
  33264. _classCallCheck(this, NodeStructure);
  33265. /**
  33266. * Data of the node.
  33267. * @member {Object}
  33268. */
  33269. this.data = data;
  33270. /**
  33271. * Next node.
  33272. * @member {NodeStructure}
  33273. */
  33274. this.next = null;
  33275. /**
  33276. * Previous node.
  33277. * @member {NodeStructure}
  33278. */
  33279. this.prev = null;
  33280. };
  33281. /**
  33282. * Linked list.
  33283. *
  33284. * @class LinkedList
  33285. * @util
  33286. */
  33287. var LinkedList = function () {
  33288. function LinkedList() {
  33289. _classCallCheck(this, LinkedList);
  33290. this.first = null;
  33291. this.last = null;
  33292. }
  33293. /**
  33294. * Add data to the end of linked list.
  33295. *
  33296. * @param {Object} data Data which should be added.
  33297. */
  33298. _createClass(LinkedList, [{
  33299. key: "push",
  33300. value: function push(data) {
  33301. var node = new NodeStructure(data);
  33302. if (this.first === null) {
  33303. this.first = node;
  33304. this.last = node;
  33305. } else {
  33306. var temp = this.last;
  33307. this.last = node;
  33308. node.prev = temp;
  33309. temp.next = node;
  33310. }
  33311. }
  33312. /**
  33313. * Add data to the beginning of linked list.
  33314. *
  33315. * @param {Object} data Data which should be added.
  33316. */
  33317. }, {
  33318. key: "unshift",
  33319. value: function unshift(data) {
  33320. var node = new NodeStructure(data);
  33321. if (this.first === null) {
  33322. this.first = node;
  33323. this.last = node;
  33324. } else {
  33325. var temp = this.first;
  33326. this.first = node;
  33327. node.next = temp;
  33328. temp.prev = node;
  33329. }
  33330. }
  33331. /**
  33332. * In order traversal of the linked list.
  33333. *
  33334. * @param {Function} callback Callback which should be executed on each node.
  33335. */
  33336. }, {
  33337. key: "inorder",
  33338. value: function inorder(callback) {
  33339. var temp = this.first;
  33340. while (temp) {
  33341. callback(temp);
  33342. temp = temp.next;
  33343. }
  33344. }
  33345. /**
  33346. * Remove data from the linked list.
  33347. *
  33348. * @param {Object} data Data which should be removed.
  33349. * @returns {Boolean} Returns true if data has been removed.
  33350. */
  33351. }, {
  33352. key: "remove",
  33353. value: function remove(data) {
  33354. if (this.first === null) {
  33355. return false;
  33356. }
  33357. var temp = this.first;
  33358. var next = void 0;
  33359. var prev = void 0;
  33360. while (temp) {
  33361. if (temp.data === data) {
  33362. next = temp.next;
  33363. prev = temp.prev;
  33364. if (next) {
  33365. next.prev = prev;
  33366. }
  33367. if (prev) {
  33368. prev.next = next;
  33369. }
  33370. if (temp === this.first) {
  33371. this.first = next;
  33372. }
  33373. if (temp === this.last) {
  33374. this.last = prev;
  33375. }
  33376. return true;
  33377. }
  33378. temp = temp.next;
  33379. }
  33380. return false;
  33381. }
  33382. /**
  33383. * Check if linked list contains cycle.
  33384. *
  33385. * @returns {Boolean} Returns true if linked list contains cycle.
  33386. */
  33387. }, {
  33388. key: "hasCycle",
  33389. value: function hasCycle() {
  33390. var fast = this.first;
  33391. var slow = this.first;
  33392. while (true) {
  33393. if (fast === null) {
  33394. return false;
  33395. }
  33396. fast = fast.next;
  33397. if (fast === null) {
  33398. return false;
  33399. }
  33400. fast = fast.next;
  33401. slow = slow.next;
  33402. if (fast === slow) {
  33403. return true;
  33404. }
  33405. }
  33406. }
  33407. }, {
  33408. key: "pop",
  33409. /**
  33410. * Return last node from the linked list.
  33411. *
  33412. * @returns {NodeStructure} Last node.
  33413. */
  33414. value: function pop() {
  33415. if (this.last === null) {
  33416. return null;
  33417. }
  33418. var temp = this.last;
  33419. this.last = this.last.prev;
  33420. return temp;
  33421. }
  33422. }, {
  33423. key: "shift",
  33424. /**
  33425. * Return first node from the linked list.
  33426. *
  33427. * @returns {NodeStructure} First node.
  33428. */
  33429. value: function shift() {
  33430. if (this.first === null) {
  33431. return null;
  33432. }
  33433. var temp = this.first;
  33434. this.first = this.first.next;
  33435. return temp;
  33436. }
  33437. }, {
  33438. key: "recursiveReverse",
  33439. /**
  33440. * Reverses the linked list recursively
  33441. */
  33442. value: function recursiveReverse() {
  33443. function inverse(current, next) {
  33444. if (!next) {
  33445. return;
  33446. }
  33447. inverse(next, next.next);
  33448. next.next = current;
  33449. }
  33450. if (!this.first) {
  33451. return;
  33452. }
  33453. inverse(this.first, this.first.next);
  33454. this.first.next = null;
  33455. var temp = this.first;
  33456. this.first = this.last;
  33457. this.last = temp;
  33458. }
  33459. }, {
  33460. key: "reverse",
  33461. /**
  33462. * Reverses the linked list iteratively
  33463. */
  33464. value: function reverse() {
  33465. if (!this.first || !this.first.next) {
  33466. return;
  33467. }
  33468. var current = this.first.next;
  33469. var prev = this.first;
  33470. var temp = void 0;
  33471. while (current) {
  33472. temp = current.next;
  33473. current.next = prev;
  33474. prev.prev = current;
  33475. prev = current;
  33476. current = temp;
  33477. }
  33478. this.first.next = null;
  33479. this.last.prev = null;
  33480. temp = this.first;
  33481. this.first = prev;
  33482. this.last = temp;
  33483. }
  33484. }]);
  33485. return LinkedList;
  33486. }();
  33487. ;
  33488. exports.NodeStructure = NodeStructure;
  33489. exports.default = LinkedList;
  33490. /***/ }),
  33491. /* 293 */
  33492. /***/ (function(module, exports, __webpack_require__) {
  33493. "use strict";
  33494. exports.__esModule = true;
  33495. 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; }; }();
  33496. 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); } };
  33497. var _element = __webpack_require__(0);
  33498. var _object = __webpack_require__(2);
  33499. var _eventManager = __webpack_require__(6);
  33500. var _eventManager2 = _interopRequireDefault(_eventManager);
  33501. var _src = __webpack_require__(4);
  33502. var _plugins = __webpack_require__(8);
  33503. var _base = __webpack_require__(10);
  33504. var _base2 = _interopRequireDefault(_base);
  33505. var _commentEditor = __webpack_require__(294);
  33506. var _commentEditor2 = _interopRequireDefault(_commentEditor);
  33507. var _utils = __webpack_require__(19);
  33508. var _displaySwitch = __webpack_require__(295);
  33509. var _displaySwitch2 = _interopRequireDefault(_displaySwitch);
  33510. var _constants = __webpack_require__(7);
  33511. var C = _interopRequireWildcard(_constants);
  33512. __webpack_require__(296);
  33513. 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; } }
  33514. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  33515. 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; }
  33516. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  33517. 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; }
  33518. 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; }
  33519. var privatePool = new WeakMap();
  33520. var META_COMMENT = 'comment';
  33521. var META_COMMENT_VALUE = 'value';
  33522. var META_STYLE = 'style';
  33523. var META_READONLY = 'readOnly';
  33524. /**
  33525. * @plugin Comments
  33526. *
  33527. * @description
  33528. * This plugin allows setting and managing cell comments by either an option in the context menu or with the use of the API.
  33529. *
  33530. * To enable the plugin, you'll need to set the comments property of the config object to `true`:
  33531. * ```js
  33532. * ...
  33533. * comments: true
  33534. * ...
  33535. * ```
  33536. *
  33537. * or object with extra predefined plugin config:
  33538. *
  33539. * ```js
  33540. * ...
  33541. * comments: {
  33542. * displayDelay: 1000
  33543. * }
  33544. * ...
  33545. * ```
  33546. *
  33547. * To add comments at the table initialization, define the `comment` property in the `cell` config array as in an example below.
  33548. *
  33549. * @example
  33550. *
  33551. * ```js
  33552. * ...
  33553. * var hot = new Handsontable(document.getElementById('example'), {
  33554. * date: getData(),
  33555. * comments: true,
  33556. * cell: [
  33557. * {row: 1, col: 1, comment: {value: 'Foo'}},
  33558. * {row: 2, col: 2, comment: {value: 'Bar'}}
  33559. * ]
  33560. * });
  33561. *
  33562. * // Access to the Comments plugin instance:
  33563. * var commentsPlugin = hot.getPlugin('comments');
  33564. *
  33565. * // Manage comments programmatically:
  33566. * commentsPlugin.setCommentAtCell(1, 6, 'Comment contents');
  33567. * commentsPlugin.showAtCell(1, 6);
  33568. * commentsPlugin.removeCommentAtCell(1, 6);
  33569. *
  33570. * // You can also set range once and use proper methods:
  33571. * commentsPlugin.setRange({row: 1, col: 6});
  33572. * commentsPlugin.setComment('Comment contents');
  33573. * commentsPlugin.show();
  33574. * commentsPlugin.removeComment();
  33575. * ...
  33576. * ```
  33577. */
  33578. var Comments = function (_BasePlugin) {
  33579. _inherits(Comments, _BasePlugin);
  33580. function Comments(hotInstance) {
  33581. _classCallCheck(this, Comments);
  33582. /**
  33583. * Instance of {@link CommentEditor}.
  33584. *
  33585. * @type {CommentEditor}
  33586. */
  33587. var _this = _possibleConstructorReturn(this, (Comments.__proto__ || Object.getPrototypeOf(Comments)).call(this, hotInstance));
  33588. _this.editor = null;
  33589. /**
  33590. * Instance of {@link DisplaySwitch}.
  33591. *
  33592. * @type {DisplaySwitch}
  33593. */
  33594. _this.displaySwitch = null;
  33595. /**
  33596. * Instance of {@link EventManager}.
  33597. *
  33598. * @private
  33599. * @type {EventManager}
  33600. */
  33601. _this.eventManager = null;
  33602. /**
  33603. * Current cell range.
  33604. *
  33605. * @type {Object}
  33606. */
  33607. _this.range = {};
  33608. /**
  33609. * @private
  33610. * @type {Boolean}
  33611. */
  33612. _this.mouseDown = false;
  33613. /**
  33614. * @private
  33615. * @type {Boolean}
  33616. */
  33617. _this.contextMenuEvent = false;
  33618. /**
  33619. * @private
  33620. * @type {*}
  33621. */
  33622. _this.timer = null;
  33623. privatePool.set(_this, {
  33624. tempEditorDimensions: {},
  33625. cellBelowCursor: null
  33626. });
  33627. return _this;
  33628. }
  33629. /**
  33630. * Check if the plugin is enabled in the Handsontable settings.
  33631. *
  33632. * @returns {Boolean}
  33633. */
  33634. _createClass(Comments, [{
  33635. key: 'isEnabled',
  33636. value: function isEnabled() {
  33637. return !!this.hot.getSettings().comments;
  33638. }
  33639. /**
  33640. * Enable plugin for this Handsontable instance.
  33641. */
  33642. }, {
  33643. key: 'enablePlugin',
  33644. value: function enablePlugin() {
  33645. var _this2 = this;
  33646. if (this.enabled) {
  33647. return;
  33648. }
  33649. if (!this.editor) {
  33650. this.editor = new _commentEditor2.default();
  33651. }
  33652. if (!this.eventManager) {
  33653. this.eventManager = new _eventManager2.default(this);
  33654. }
  33655. if (!this.displaySwitch) {
  33656. this.displaySwitch = new _displaySwitch2.default(this.getDisplayDelaySetting());
  33657. }
  33658. this.addHook('afterContextMenuDefaultOptions', function (options) {
  33659. return _this2.addToContextMenu(options);
  33660. });
  33661. this.addHook('afterRenderer', function (TD, row, col, prop, value, cellProperties) {
  33662. return _this2.onAfterRenderer(TD, cellProperties);
  33663. });
  33664. this.addHook('afterScrollHorizontally', function () {
  33665. return _this2.hide();
  33666. });
  33667. this.addHook('afterScrollVertically', function () {
  33668. return _this2.hide();
  33669. });
  33670. this.addHook('afterBeginEditing', function (args) {
  33671. return _this2.onAfterBeginEditing(args);
  33672. });
  33673. this.displaySwitch.addLocalHook('hide', function () {
  33674. return _this2.hide();
  33675. });
  33676. this.displaySwitch.addLocalHook('show', function (row, col) {
  33677. return _this2.showAtCell(row, col);
  33678. });
  33679. this.registerListeners();
  33680. _get(Comments.prototype.__proto__ || Object.getPrototypeOf(Comments.prototype), 'enablePlugin', this).call(this);
  33681. }
  33682. /**
  33683. * Update plugin for this Handsontable instance.
  33684. */
  33685. }, {
  33686. key: 'updatePlugin',
  33687. value: function updatePlugin() {
  33688. this.disablePlugin();
  33689. this.enablePlugin();
  33690. _get(Comments.prototype.__proto__ || Object.getPrototypeOf(Comments.prototype), 'updatePlugin', this).call(this);
  33691. this.displaySwitch.updateDelay(this.getDisplayDelaySetting());
  33692. }
  33693. /**
  33694. * Disable plugin for this Handsontable instance.
  33695. */
  33696. }, {
  33697. key: 'disablePlugin',
  33698. value: function disablePlugin() {
  33699. _get(Comments.prototype.__proto__ || Object.getPrototypeOf(Comments.prototype), 'disablePlugin', this).call(this);
  33700. }
  33701. /**
  33702. * Register all necessary DOM listeners.
  33703. *
  33704. * @private
  33705. */
  33706. }, {
  33707. key: 'registerListeners',
  33708. value: function registerListeners() {
  33709. var _this3 = this;
  33710. this.eventManager.addEventListener(document, 'mouseover', function (event) {
  33711. return _this3.onMouseOver(event);
  33712. });
  33713. this.eventManager.addEventListener(document, 'mousedown', function (event) {
  33714. return _this3.onMouseDown(event);
  33715. });
  33716. this.eventManager.addEventListener(document, 'mouseup', function (event) {
  33717. return _this3.onMouseUp(event);
  33718. });
  33719. this.eventManager.addEventListener(this.editor.getInputElement(), 'blur', function (event) {
  33720. return _this3.onEditorBlur(event);
  33721. });
  33722. this.eventManager.addEventListener(this.editor.getInputElement(), 'mousedown', function (event) {
  33723. return _this3.onEditorMouseDown(event);
  33724. });
  33725. this.eventManager.addEventListener(this.editor.getInputElement(), 'mouseup', function (event) {
  33726. return _this3.onEditorMouseUp(event);
  33727. });
  33728. }
  33729. /**
  33730. * Set current cell range to be able to use general methods like {@link Comments#setComment},
  33731. * {@link Comments#removeComment}, {@link Comments#show}.
  33732. *
  33733. * @param {Object} range Object with `from` and `to` properties, each with `row` and `col` properties.
  33734. */
  33735. }, {
  33736. key: 'setRange',
  33737. value: function setRange(range) {
  33738. this.range = range;
  33739. }
  33740. /**
  33741. * Clear the currently selected cell.
  33742. */
  33743. }, {
  33744. key: 'clearRange',
  33745. value: function clearRange() {
  33746. this.range = {};
  33747. }
  33748. /**
  33749. * Check if the event target is a cell containing a comment.
  33750. *
  33751. * @param {Event} event DOM event
  33752. * @returns {Boolean}
  33753. */
  33754. }, {
  33755. key: 'targetIsCellWithComment',
  33756. value: function targetIsCellWithComment(event) {
  33757. var closestCell = (0, _element.closest)(event.target, 'TD', 'TBODY');
  33758. return !!(closestCell && (0, _element.hasClass)(closestCell, 'htCommentCell') && (0, _element.closest)(closestCell, [this.hot.rootElement]));
  33759. }
  33760. /**
  33761. * Check if the event target is a comment textarea.
  33762. *
  33763. * @param {Event} event DOM event.
  33764. * @returns {Boolean}
  33765. */
  33766. }, {
  33767. key: 'targetIsCommentTextArea',
  33768. value: function targetIsCommentTextArea(event) {
  33769. return this.editor.getInputElement() === event.target;
  33770. }
  33771. /**
  33772. * Set a comment for a cell according to the previously set range (see {@link Comments#setRange}).
  33773. *
  33774. * @param {String} value Comment contents.
  33775. */
  33776. }, {
  33777. key: 'setComment',
  33778. value: function setComment(value) {
  33779. if (!this.range.from) {
  33780. throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
  33781. }
  33782. var editorValue = this.editor.getValue();
  33783. var comment = '';
  33784. if (value != null) {
  33785. comment = value;
  33786. } else if (editorValue != null) {
  33787. comment = editorValue;
  33788. }
  33789. var row = this.range.from.row;
  33790. var col = this.range.from.col;
  33791. this.updateCommentMeta(row, col, _defineProperty({}, META_COMMENT_VALUE, comment));
  33792. this.hot.render();
  33793. }
  33794. /**
  33795. * Set a comment for a cell.
  33796. *
  33797. * @param {Number} row Visual row index.
  33798. * @param {Number} col Visual column index.
  33799. * @param {String} value Comment contents.
  33800. */
  33801. }, {
  33802. key: 'setCommentAtCell',
  33803. value: function setCommentAtCell(row, col, value) {
  33804. this.setRange({
  33805. from: new _src.CellCoords(row, col)
  33806. });
  33807. this.setComment(value);
  33808. }
  33809. /**
  33810. * Remove a comment from a cell according to previously set range (see {@link Comments#setRange}).
  33811. *
  33812. * @param {Boolean} [forceRender = true] If set to `true`, the table will be re-rendered at the end of the operation.
  33813. */
  33814. }, {
  33815. key: 'removeComment',
  33816. value: function removeComment() {
  33817. var forceRender = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  33818. if (!this.range.from) {
  33819. throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
  33820. }
  33821. this.hot.setCellMeta(this.range.from.row, this.range.from.col, META_COMMENT, void 0);
  33822. if (forceRender) {
  33823. this.hot.render();
  33824. }
  33825. this.hide();
  33826. }
  33827. /**
  33828. * Remove comment from a cell.
  33829. *
  33830. * @param {Number} row Visual row index.
  33831. * @param {Number} col Visual column index.
  33832. * @param {Boolean} [forceRender = true] If `true`, the table will be re-rendered at the end of the operation.
  33833. */
  33834. }, {
  33835. key: 'removeCommentAtCell',
  33836. value: function removeCommentAtCell(row, col) {
  33837. var forceRender = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  33838. this.setRange({
  33839. from: new _src.CellCoords(row, col)
  33840. });
  33841. this.removeComment(forceRender);
  33842. }
  33843. /**
  33844. * Get comment from a cell at the predefined range.
  33845. */
  33846. }, {
  33847. key: 'getComment',
  33848. value: function getComment() {
  33849. var row = this.range.from.row;
  33850. var column = this.range.from.col;
  33851. return this.getCommentMeta(row, column, META_COMMENT_VALUE);
  33852. }
  33853. /**
  33854. * Get comment from a cell at the provided coordinates.
  33855. *
  33856. * @param {Number} row Visual row index.
  33857. * @param {Number} column Visual column index.
  33858. */
  33859. }, {
  33860. key: 'getCommentAtCell',
  33861. value: function getCommentAtCell(row, column) {
  33862. return this.getCommentMeta(row, column, META_COMMENT_VALUE);
  33863. }
  33864. /**
  33865. * Show the comment editor accordingly to the previously set range (see {@link Comments#setRange}).
  33866. *
  33867. * @returns {Boolean} Returns `true` if comment editor was shown.
  33868. */
  33869. }, {
  33870. key: 'show',
  33871. value: function show() {
  33872. if (!this.range.from) {
  33873. throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
  33874. }
  33875. var meta = this.hot.getCellMeta(this.range.from.row, this.range.from.col);
  33876. this.refreshEditor(true);
  33877. this.editor.setValue(meta[META_COMMENT] ? meta[META_COMMENT][META_COMMENT_VALUE] : null || '');
  33878. if (this.editor.hidden) {
  33879. this.editor.show();
  33880. }
  33881. return true;
  33882. }
  33883. /**
  33884. * Show comment editor according to cell coordinates.
  33885. *
  33886. * @param {Number} row Visual row index.
  33887. * @param {Number} col Visual column index.
  33888. * @returns {Boolean} Returns `true` if comment editor was shown.
  33889. */
  33890. }, {
  33891. key: 'showAtCell',
  33892. value: function showAtCell(row, col) {
  33893. this.setRange({
  33894. from: new _src.CellCoords(row, col)
  33895. });
  33896. return this.show();
  33897. }
  33898. /**
  33899. * Hide the comment editor.
  33900. */
  33901. }, {
  33902. key: 'hide',
  33903. value: function hide() {
  33904. if (!this.editor.hidden) {
  33905. this.editor.hide();
  33906. }
  33907. }
  33908. /**
  33909. * Refresh comment editor position and styling.
  33910. *
  33911. * @param {Boolean} [force=false] If `true` then recalculation will be forced.
  33912. */
  33913. }, {
  33914. key: 'refreshEditor',
  33915. value: function refreshEditor() {
  33916. var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  33917. if (!force && (!this.range.from || !this.editor.isVisible())) {
  33918. return;
  33919. }
  33920. var scrollableElement = (0, _element.getScrollableElement)(this.hot.view.wt.wtTable.TABLE);
  33921. var TD = this.hot.view.wt.wtTable.getCell(this.range.from);
  33922. var row = this.range.from.row;
  33923. var column = this.range.from.col;
  33924. var cellOffset = (0, _element.offset)(TD);
  33925. var lastColWidth = this.hot.view.wt.wtTable.getStretchedColumnWidth(column);
  33926. var cellTopOffset = cellOffset.top < 0 ? 0 : cellOffset.top;
  33927. var cellLeftOffset = cellOffset.left;
  33928. if (this.hot.view.wt.wtViewport.hasVerticalScroll() && scrollableElement !== window) {
  33929. cellTopOffset -= this.hot.view.wt.wtOverlays.topOverlay.getScrollPosition();
  33930. }
  33931. if (this.hot.view.wt.wtViewport.hasHorizontalScroll() && scrollableElement !== window) {
  33932. cellLeftOffset -= this.hot.view.wt.wtOverlays.leftOverlay.getScrollPosition();
  33933. }
  33934. var x = cellLeftOffset + lastColWidth;
  33935. var y = cellTopOffset;
  33936. var commentStyle = this.getCommentMeta(row, column, META_STYLE);
  33937. var readOnly = this.getCommentMeta(row, column, META_READONLY);
  33938. if (commentStyle) {
  33939. this.editor.setSize(commentStyle.width, commentStyle.height);
  33940. } else {
  33941. this.editor.resetSize();
  33942. }
  33943. this.editor.setReadOnlyState(readOnly);
  33944. this.editor.setPosition(x, y);
  33945. }
  33946. /**
  33947. * Check if there is a comment for selected range.
  33948. *
  33949. * @private
  33950. * @returns {Boolean}
  33951. */
  33952. }, {
  33953. key: 'checkSelectionCommentsConsistency',
  33954. value: function checkSelectionCommentsConsistency() {
  33955. var selected = this.hot.getSelectedRangeLast();
  33956. if (!selected) {
  33957. return false;
  33958. }
  33959. var hasComment = false;
  33960. var cell = selected.from; // IN EXCEL THERE IS COMMENT ONLY FOR TOP LEFT CELL IN SELECTION
  33961. if (this.getCommentMeta(cell.row, cell.col, META_COMMENT_VALUE)) {
  33962. hasComment = true;
  33963. }
  33964. return hasComment;
  33965. }
  33966. /**
  33967. * Set or update the comment-related cell meta.
  33968. *
  33969. * @param {Number} row Visual row index.
  33970. * @param {Number} column Visual column index.
  33971. * @param {Object} metaObject Object defining all the comment-related meta information.
  33972. */
  33973. }, {
  33974. key: 'updateCommentMeta',
  33975. value: function updateCommentMeta(row, column, metaObject) {
  33976. var oldComment = this.hot.getCellMeta(row, column)[META_COMMENT];
  33977. var newComment = void 0;
  33978. if (oldComment) {
  33979. newComment = (0, _object.deepClone)(oldComment);
  33980. (0, _object.deepExtend)(newComment, metaObject);
  33981. } else {
  33982. newComment = metaObject;
  33983. }
  33984. this.hot.setCellMeta(row, column, META_COMMENT, newComment);
  33985. }
  33986. /**
  33987. * Get the comment related meta information.
  33988. *
  33989. * @param {Number} row Visual row index.
  33990. * @param {Number} column Visual column index.
  33991. * @param {String} property Cell meta property.
  33992. * @returns {Mixed}
  33993. */
  33994. }, {
  33995. key: 'getCommentMeta',
  33996. value: function getCommentMeta(row, column, property) {
  33997. var cellMeta = this.hot.getCellMeta(row, column);
  33998. if (!cellMeta[META_COMMENT]) {
  33999. return void 0;
  34000. }
  34001. return cellMeta[META_COMMENT][property];
  34002. }
  34003. /**
  34004. * `mousedown` event callback.
  34005. *
  34006. * @private
  34007. * @param {MouseEvent} event The `mousedown` event.
  34008. */
  34009. }, {
  34010. key: 'onMouseDown',
  34011. value: function onMouseDown(event) {
  34012. this.mouseDown = true;
  34013. if (!this.hot.view || !this.hot.view.wt) {
  34014. return;
  34015. }
  34016. if (!this.contextMenuEvent && !this.targetIsCommentTextArea(event)) {
  34017. var eventCell = (0, _element.closest)(event.target, 'TD', 'TBODY');
  34018. var coordinates = null;
  34019. if (eventCell) {
  34020. coordinates = this.hot.view.wt.wtTable.getCoords(eventCell);
  34021. }
  34022. if (!eventCell || this.range.from && coordinates && (this.range.from.row !== coordinates.row || this.range.from.col !== coordinates.col)) {
  34023. this.hide();
  34024. }
  34025. }
  34026. this.contextMenuEvent = false;
  34027. }
  34028. /**
  34029. * `mouseover` event callback.
  34030. *
  34031. * @private
  34032. * @param {MouseEvent} event The `mouseover` event.
  34033. */
  34034. }, {
  34035. key: 'onMouseOver',
  34036. value: function onMouseOver(event) {
  34037. var priv = privatePool.get(this);
  34038. priv.cellBelowCursor = document.elementFromPoint(event.clientX, event.clientY);
  34039. if (this.mouseDown || this.editor.isFocused() || (0, _element.hasClass)(event.target, 'wtBorder') || priv.cellBelowCursor !== event.target || !this.editor) {
  34040. return;
  34041. }
  34042. if (this.targetIsCellWithComment(event)) {
  34043. var coordinates = this.hot.view.wt.wtTable.getCoords(event.target);
  34044. var range = {
  34045. from: new _src.CellCoords(coordinates.row, coordinates.col)
  34046. };
  34047. this.displaySwitch.show(range);
  34048. } else if ((0, _element.isChildOf)(event.target, document) && !this.targetIsCommentTextArea(event)) {
  34049. this.displaySwitch.hide();
  34050. }
  34051. }
  34052. /**
  34053. * `mouseup` event callback.
  34054. *
  34055. * @private
  34056. * @param {MouseEvent} event The `mouseup` event.
  34057. */
  34058. }, {
  34059. key: 'onMouseUp',
  34060. value: function onMouseUp(event) {
  34061. this.mouseDown = false;
  34062. }
  34063. /** *
  34064. * The `afterRenderer` hook callback..
  34065. *
  34066. * @private
  34067. * @param {HTMLTableCellElement} TD The rendered `TD` element.
  34068. * @param {Object} cellProperties The rendered cell's property object.
  34069. */
  34070. }, {
  34071. key: 'onAfterRenderer',
  34072. value: function onAfterRenderer(TD, cellProperties) {
  34073. if (cellProperties[META_COMMENT] && cellProperties[META_COMMENT][META_COMMENT_VALUE]) {
  34074. (0, _element.addClass)(TD, cellProperties.commentedCellClassName);
  34075. }
  34076. }
  34077. /**
  34078. * `blur` event callback for the comment editor.
  34079. *
  34080. * @private
  34081. * @param {Event} event The `blur` event.
  34082. */
  34083. }, {
  34084. key: 'onEditorBlur',
  34085. value: function onEditorBlur(event) {
  34086. this.setComment();
  34087. }
  34088. /**
  34089. * `mousedown` hook. Along with `onEditorMouseUp` used to simulate the textarea resizing event.
  34090. *
  34091. * @private
  34092. * @param {MouseEvent} event The `mousedown` event.
  34093. */
  34094. }, {
  34095. key: 'onEditorMouseDown',
  34096. value: function onEditorMouseDown(event) {
  34097. var priv = privatePool.get(this);
  34098. priv.tempEditorDimensions = {
  34099. width: (0, _element.outerWidth)(event.target),
  34100. height: (0, _element.outerHeight)(event.target)
  34101. };
  34102. }
  34103. /**
  34104. * `mouseup` hook. Along with `onEditorMouseDown` used to simulate the textarea resizing event.
  34105. *
  34106. * @private
  34107. * @param {MouseEvent} event The `mouseup` event.
  34108. */
  34109. }, {
  34110. key: 'onEditorMouseUp',
  34111. value: function onEditorMouseUp(event) {
  34112. var priv = privatePool.get(this);
  34113. var currentWidth = (0, _element.outerWidth)(event.target);
  34114. var currentHeight = (0, _element.outerHeight)(event.target);
  34115. if (currentWidth !== priv.tempEditorDimensions.width + 1 || currentHeight !== priv.tempEditorDimensions.height + 2) {
  34116. this.updateCommentMeta(this.range.from.row, this.range.from.col, _defineProperty({}, META_STYLE, {
  34117. width: currentWidth,
  34118. height: currentHeight
  34119. }));
  34120. }
  34121. }
  34122. /**
  34123. * Context Menu's "Add comment" callback. Results in showing the comment editor.
  34124. *
  34125. * @private
  34126. */
  34127. }, {
  34128. key: 'onContextMenuAddComment',
  34129. value: function onContextMenuAddComment() {
  34130. var _this4 = this;
  34131. this.displaySwitch.cancelHiding();
  34132. var coords = this.hot.getSelectedRangeLast();
  34133. this.contextMenuEvent = true;
  34134. this.setRange({
  34135. from: coords.from
  34136. });
  34137. this.show();
  34138. setTimeout(function () {
  34139. if (_this4.hot) {
  34140. _this4.hot.deselectCell();
  34141. _this4.editor.focus();
  34142. }
  34143. }, 10);
  34144. }
  34145. /**
  34146. * Context Menu's "remove comment" callback.
  34147. *
  34148. * @private
  34149. */
  34150. }, {
  34151. key: 'onContextMenuRemoveComment',
  34152. value: function onContextMenuRemoveComment() {
  34153. this.contextMenuEvent = true;
  34154. var _hot$getSelectedRange = this.hot.getSelectedRangeLast(),
  34155. from = _hot$getSelectedRange.from,
  34156. to = _hot$getSelectedRange.to;
  34157. for (var i = from.row; i <= to.row; i++) {
  34158. for (var j = from.col; j <= to.col; j++) {
  34159. this.removeCommentAtCell(i, j, false);
  34160. }
  34161. }
  34162. this.hot.render();
  34163. }
  34164. /**
  34165. * Context Menu's "make comment read-only" callback.
  34166. *
  34167. * @private
  34168. */
  34169. }, {
  34170. key: 'onContextMenuMakeReadOnly',
  34171. value: function onContextMenuMakeReadOnly() {
  34172. this.contextMenuEvent = true;
  34173. var _hot$getSelectedRange2 = this.hot.getSelectedRangeLast(),
  34174. from = _hot$getSelectedRange2.from,
  34175. to = _hot$getSelectedRange2.to;
  34176. for (var i = from.row; i <= to.row; i++) {
  34177. for (var j = from.col; j <= to.col; j++) {
  34178. var currentState = !!this.getCommentMeta(i, j, META_READONLY);
  34179. this.updateCommentMeta(i, j, _defineProperty({}, META_READONLY, !currentState));
  34180. }
  34181. }
  34182. }
  34183. /**
  34184. * Add Comments plugin options to the Context Menu.
  34185. *
  34186. * @private
  34187. * @param {Object} defaultOptions
  34188. */
  34189. }, {
  34190. key: 'addToContextMenu',
  34191. value: function addToContextMenu(defaultOptions) {
  34192. var _this5 = this;
  34193. defaultOptions.items.push({
  34194. name: '---------'
  34195. }, {
  34196. key: 'commentsAddEdit',
  34197. name: function name() {
  34198. if (_this5.checkSelectionCommentsConsistency()) {
  34199. return _this5.hot.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_EDIT_COMMENT);
  34200. }
  34201. return _this5.hot.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ADD_COMMENT);
  34202. },
  34203. callback: function callback() {
  34204. return _this5.onContextMenuAddComment();
  34205. },
  34206. disabled: function disabled() {
  34207. return !(this.getSelectedLast() && !this.selection.isSelectedByCorner());
  34208. }
  34209. }, {
  34210. key: 'commentsRemove',
  34211. name: function name() {
  34212. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_REMOVE_COMMENT);
  34213. },
  34214. callback: function callback() {
  34215. return _this5.onContextMenuRemoveComment();
  34216. },
  34217. disabled: function disabled() {
  34218. return _this5.hot.selection.isSelectedByCorner();
  34219. }
  34220. }, {
  34221. key: 'commentsReadOnly',
  34222. name: function name() {
  34223. var _this6 = this;
  34224. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_READ_ONLY_COMMENT);
  34225. var hasProperty = (0, _utils.checkSelectionConsistency)(this.getSelectedRangeLast(), function (row, col) {
  34226. var readOnlyProperty = _this6.getCellMeta(row, col)[META_COMMENT];
  34227. if (readOnlyProperty) {
  34228. readOnlyProperty = readOnlyProperty[META_READONLY];
  34229. }
  34230. if (readOnlyProperty) {
  34231. return true;
  34232. }
  34233. });
  34234. if (hasProperty) {
  34235. label = (0, _utils.markLabelAsSelected)(label);
  34236. }
  34237. return label;
  34238. },
  34239. callback: function callback() {
  34240. return _this5.onContextMenuMakeReadOnly();
  34241. },
  34242. disabled: function disabled() {
  34243. return _this5.hot.selection.isSelectedByCorner() || !_this5.checkSelectionCommentsConsistency();
  34244. }
  34245. });
  34246. }
  34247. /**
  34248. * Get `displayDelay` setting of comment plugin.
  34249. *
  34250. * @returns {Number|undefined}
  34251. */
  34252. }, {
  34253. key: 'getDisplayDelaySetting',
  34254. value: function getDisplayDelaySetting() {
  34255. var commentSetting = this.hot.getSettings().comments;
  34256. if ((0, _object.isObject)(commentSetting)) {
  34257. return commentSetting.displayDelay;
  34258. }
  34259. return void 0;
  34260. }
  34261. /**
  34262. * `afterBeginEditing` hook callback.
  34263. *
  34264. * @private
  34265. * @param {Number} row Visual row index of the currently edited cell.
  34266. * @param {Number} column Visual column index of the currently edited cell.
  34267. */
  34268. }, {
  34269. key: 'onAfterBeginEditing',
  34270. value: function onAfterBeginEditing(row, column) {
  34271. this.hide();
  34272. }
  34273. /**
  34274. * Destroy plugin instance.
  34275. */
  34276. }, {
  34277. key: 'destroy',
  34278. value: function destroy() {
  34279. if (this.editor) {
  34280. this.editor.destroy();
  34281. }
  34282. if (this.displaySwitch) {
  34283. this.displaySwitch.destroy();
  34284. }
  34285. _get(Comments.prototype.__proto__ || Object.getPrototypeOf(Comments.prototype), 'destroy', this).call(this);
  34286. }
  34287. }]);
  34288. return Comments;
  34289. }(_base2.default);
  34290. (0, _plugins.registerPlugin)('comments', Comments);
  34291. exports.default = Comments;
  34292. /***/ }),
  34293. /* 294 */
  34294. /***/ (function(module, exports, __webpack_require__) {
  34295. "use strict";
  34296. exports.__esModule = true;
  34297. 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; }; }();
  34298. var _element = __webpack_require__(0);
  34299. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  34300. /**
  34301. * Comment editor for the Comments plugin.
  34302. *
  34303. * @class CommentEditor
  34304. * @plugin Comments
  34305. */
  34306. var CommentEditor = function () {
  34307. _createClass(CommentEditor, null, [{
  34308. key: 'CLASS_EDITOR_CONTAINER',
  34309. get: function get() {
  34310. return 'htCommentsContainer';
  34311. }
  34312. }, {
  34313. key: 'CLASS_EDITOR',
  34314. get: function get() {
  34315. return 'htComments';
  34316. }
  34317. }, {
  34318. key: 'CLASS_INPUT',
  34319. get: function get() {
  34320. return 'htCommentTextArea';
  34321. }
  34322. }, {
  34323. key: 'CLASS_CELL',
  34324. get: function get() {
  34325. return 'htCommentCell';
  34326. }
  34327. }]);
  34328. function CommentEditor() {
  34329. _classCallCheck(this, CommentEditor);
  34330. this.editor = this.createEditor();
  34331. this.editorStyle = this.editor.style;
  34332. this.hidden = true;
  34333. this.hide();
  34334. }
  34335. /**
  34336. * Set position of the comments editor according to the provided x and y coordinates.
  34337. *
  34338. * @param {Number} x X position (in pixels).
  34339. * @param {Number} y Y position (in pixels).
  34340. */
  34341. _createClass(CommentEditor, [{
  34342. key: 'setPosition',
  34343. value: function setPosition(x, y) {
  34344. this.editorStyle.left = x + 'px';
  34345. this.editorStyle.top = y + 'px';
  34346. }
  34347. /**
  34348. * Set the editor size according to the provided arguments.
  34349. *
  34350. * @param {Number} width Width in pixels.
  34351. * @param {Number} height Height in pixels.
  34352. */
  34353. }, {
  34354. key: 'setSize',
  34355. value: function setSize(width, height) {
  34356. if (width && height) {
  34357. var input = this.getInputElement();
  34358. input.style.width = width + 'px';
  34359. input.style.height = height + 'px';
  34360. }
  34361. }
  34362. /**
  34363. * Reset the editor size to its initial state.
  34364. */
  34365. }, {
  34366. key: 'resetSize',
  34367. value: function resetSize() {
  34368. var input = this.getInputElement();
  34369. input.style.width = '';
  34370. input.style.height = '';
  34371. }
  34372. /**
  34373. * Set the read-only state for the comments editor.
  34374. *
  34375. * @param {Boolean} state The new read only state.
  34376. */
  34377. }, {
  34378. key: 'setReadOnlyState',
  34379. value: function setReadOnlyState(state) {
  34380. var input = this.getInputElement();
  34381. input.readOnly = state;
  34382. }
  34383. /**
  34384. * Show the comments editor.
  34385. */
  34386. }, {
  34387. key: 'show',
  34388. value: function show() {
  34389. this.editorStyle.display = 'block';
  34390. this.hidden = false;
  34391. }
  34392. /**
  34393. * Hide the comments editor.
  34394. */
  34395. }, {
  34396. key: 'hide',
  34397. value: function hide() {
  34398. this.editorStyle.display = 'none';
  34399. this.hidden = true;
  34400. }
  34401. /**
  34402. * Checks if the editor is visible.
  34403. *
  34404. * @returns {Boolean}
  34405. */
  34406. }, {
  34407. key: 'isVisible',
  34408. value: function isVisible() {
  34409. return this.editorStyle.display === 'block';
  34410. }
  34411. /**
  34412. * Set the comment value.
  34413. *
  34414. * @param {String} [value] The value to use.
  34415. */
  34416. }, {
  34417. key: 'setValue',
  34418. value: function setValue() {
  34419. var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  34420. value = value || '';
  34421. this.getInputElement().value = value;
  34422. }
  34423. /**
  34424. * Get the comment value.
  34425. *
  34426. * @returns {String}
  34427. */
  34428. }, {
  34429. key: 'getValue',
  34430. value: function getValue() {
  34431. return this.getInputElement().value;
  34432. }
  34433. /**
  34434. * Checks if the comment input element is focused.
  34435. *
  34436. * @returns {Boolean}
  34437. */
  34438. }, {
  34439. key: 'isFocused',
  34440. value: function isFocused() {
  34441. return document.activeElement === this.getInputElement();
  34442. }
  34443. /**
  34444. * Focus the comments input element.
  34445. */
  34446. }, {
  34447. key: 'focus',
  34448. value: function focus() {
  34449. this.getInputElement().focus();
  34450. }
  34451. /**
  34452. * Create the `textarea` to be used as a comments editor.
  34453. *
  34454. * @returns {HTMLElement}
  34455. */
  34456. }, {
  34457. key: 'createEditor',
  34458. value: function createEditor() {
  34459. var container = document.querySelector('.' + CommentEditor.CLASS_EDITOR_CONTAINER);
  34460. var editor = void 0;
  34461. var textArea = void 0;
  34462. if (!container) {
  34463. container = document.createElement('div');
  34464. (0, _element.addClass)(container, CommentEditor.CLASS_EDITOR_CONTAINER);
  34465. document.body.appendChild(container);
  34466. }
  34467. editor = document.createElement('div');
  34468. (0, _element.addClass)(editor, CommentEditor.CLASS_EDITOR);
  34469. textArea = document.createElement('textarea');
  34470. (0, _element.addClass)(textArea, CommentEditor.CLASS_INPUT);
  34471. editor.appendChild(textArea);
  34472. container.appendChild(editor);
  34473. return editor;
  34474. }
  34475. /**
  34476. * Get the input element.
  34477. *
  34478. * @returns {HTMLElement}
  34479. */
  34480. }, {
  34481. key: 'getInputElement',
  34482. value: function getInputElement() {
  34483. return this.editor.querySelector('.' + CommentEditor.CLASS_INPUT);
  34484. }
  34485. /**
  34486. * Destroy the comments editor.
  34487. */
  34488. }, {
  34489. key: 'destroy',
  34490. value: function destroy() {
  34491. this.editor.parentNode.removeChild(this.editor);
  34492. this.editor = null;
  34493. this.editorStyle = null;
  34494. }
  34495. }]);
  34496. return CommentEditor;
  34497. }();
  34498. exports.default = CommentEditor;
  34499. /***/ }),
  34500. /* 295 */
  34501. /***/ (function(module, exports, __webpack_require__) {
  34502. "use strict";
  34503. exports.__esModule = true;
  34504. 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; }; }();
  34505. var _function = __webpack_require__(42);
  34506. var _object = __webpack_require__(2);
  34507. var _localHooks = __webpack_require__(58);
  34508. var _localHooks2 = _interopRequireDefault(_localHooks);
  34509. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  34510. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  34511. var DEFAULT_DISPLAY_DELAY = 250;
  34512. var DEFAULT_HIDE_DELAY = 250;
  34513. /**
  34514. * Display switch for the Comments plugin. Manages the time of delayed displaying / hiding comments.
  34515. *
  34516. * @class DisplaySwitch
  34517. * @plugin Comments
  34518. */
  34519. var DisplaySwitch = function () {
  34520. function DisplaySwitch(displayDelay) {
  34521. _classCallCheck(this, DisplaySwitch);
  34522. /**
  34523. * Flag to determine if comment can be showed or hidden. State `true` mean that last performed action
  34524. * was an attempt to show comment element. State `false` mean that it was attempt to hide comment element.
  34525. *
  34526. * @type {Boolean}
  34527. */
  34528. this.wasLastActionShow = true;
  34529. /**
  34530. * Show comment after predefined delay. It keeps reference to immutable `debounce` function.
  34531. *
  34532. * @type {Function}
  34533. */
  34534. this.showDebounced = null;
  34535. /**
  34536. * Reference to timer, run by `setTimeout`, which is hiding comment
  34537. *
  34538. * @type {Number}
  34539. */
  34540. this.hidingTimer = null;
  34541. this.updateDelay(displayDelay);
  34542. }
  34543. /**
  34544. * Responsible for hiding comment after proper delay.
  34545. */
  34546. _createClass(DisplaySwitch, [{
  34547. key: 'hide',
  34548. value: function hide() {
  34549. var _this = this;
  34550. this.wasLastActionShow = false;
  34551. this.hidingTimer = setTimeout(function () {
  34552. if (_this.wasLastActionShow === false) {
  34553. _this.runLocalHooks('hide');
  34554. }
  34555. }, DEFAULT_HIDE_DELAY);
  34556. }
  34557. /**
  34558. * Responsible for showing comment after proper delay.
  34559. *
  34560. * @param {Object} range Coordinates of selected cell.
  34561. */
  34562. }, {
  34563. key: 'show',
  34564. value: function show(range) {
  34565. this.wasLastActionShow = true;
  34566. this.showDebounced(range);
  34567. }
  34568. }, {
  34569. key: 'cancelHiding',
  34570. /**
  34571. * Cancel hiding comment.
  34572. */
  34573. value: function cancelHiding() {
  34574. this.wasLastActionShow = true;
  34575. clearTimeout(this.hidingTimer);
  34576. this.hidingTimer = null;
  34577. }
  34578. /**
  34579. * Update the switch settings.
  34580. *
  34581. * @param {Number} displayDelay Delay of showing the comments (in milliseconds).
  34582. */
  34583. }, {
  34584. key: 'updateDelay',
  34585. value: function updateDelay() {
  34586. var _this2 = this;
  34587. var displayDelay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_DISPLAY_DELAY;
  34588. this.showDebounced = (0, _function.debounce)(function (range) {
  34589. if (_this2.wasLastActionShow) {
  34590. _this2.runLocalHooks('show', range.from.row, range.from.col);
  34591. }
  34592. }, displayDelay);
  34593. }
  34594. /**
  34595. * Destroy the switcher.
  34596. */
  34597. }, {
  34598. key: 'destroy',
  34599. value: function destroy() {
  34600. this.clearLocalHooks();
  34601. }
  34602. }]);
  34603. return DisplaySwitch;
  34604. }();
  34605. (0, _object.mixin)(DisplaySwitch, _localHooks2.default);
  34606. exports.default = DisplaySwitch;
  34607. /***/ }),
  34608. /* 296 */
  34609. /***/ (function(module, exports) {
  34610. // removed by extract-text-webpack-plugin
  34611. /***/ }),
  34612. /* 297 */
  34613. /***/ (function(module, exports, __webpack_require__) {
  34614. "use strict";
  34615. exports.__esModule = true;
  34616. 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); } };
  34617. 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; }; }();
  34618. var _base = __webpack_require__(10);
  34619. var _base2 = _interopRequireDefault(_base);
  34620. var _pluginHooks = __webpack_require__(15);
  34621. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  34622. var _array = __webpack_require__(1);
  34623. var _commandExecutor = __webpack_require__(298);
  34624. var _commandExecutor2 = _interopRequireDefault(_commandExecutor);
  34625. var _eventManager = __webpack_require__(6);
  34626. var _eventManager2 = _interopRequireDefault(_eventManager);
  34627. var _itemsFactory = __webpack_require__(299);
  34628. var _itemsFactory2 = _interopRequireDefault(_itemsFactory);
  34629. var _menu = __webpack_require__(311);
  34630. var _menu2 = _interopRequireDefault(_menu);
  34631. var _plugins = __webpack_require__(8);
  34632. var _event = __webpack_require__(12);
  34633. var _element = __webpack_require__(0);
  34634. var _predefinedItems = __webpack_require__(94);
  34635. __webpack_require__(313);
  34636. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  34637. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  34638. 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; }
  34639. 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; }
  34640. _pluginHooks2.default.getSingleton().register('afterContextMenuDefaultOptions');
  34641. _pluginHooks2.default.getSingleton().register('beforeContextMenuShow');
  34642. _pluginHooks2.default.getSingleton().register('afterContextMenuShow');
  34643. _pluginHooks2.default.getSingleton().register('afterContextMenuHide');
  34644. _pluginHooks2.default.getSingleton().register('afterContextMenuExecute');
  34645. /**
  34646. * @description
  34647. * This plugin creates the Handsontable Context Menu. It allows to create a new row or
  34648. * column at any place in the grid among [other features](http://docs.handsontable.com/demo-context-menu.html).
  34649. * Possible values:
  34650. * * `true` (to enable default options),
  34651. * * `false` (to disable completely)
  34652. *
  34653. * or array of any available strings:
  34654. * * `["row_above", "row_below", "col_left", "col_right",
  34655. * "remove_row", "remove_col", "---------", "undo", "redo"]`.
  34656. *
  34657. * See [the context menu demo](http://docs.handsontable.com/demo-context-menu.html) for examples.
  34658. *
  34659. * @example
  34660. * ```js
  34661. * ...
  34662. * // as a boolean
  34663. * contextMenu: true
  34664. * ...
  34665. * // as a array
  34666. * contextMenu: ['row_above', 'row_below', '---------', 'undo', 'redo']
  34667. * ...
  34668. * ```
  34669. *
  34670. * @plugin ContextMenu
  34671. */
  34672. var ContextMenu = function (_BasePlugin) {
  34673. _inherits(ContextMenu, _BasePlugin);
  34674. _createClass(ContextMenu, null, [{
  34675. key: 'DEFAULT_ITEMS',
  34676. /**
  34677. * Default menu items order when `contextMenu` is enabled by `true`.
  34678. *
  34679. * @returns {Array}
  34680. */
  34681. get: function get() {
  34682. 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];
  34683. }
  34684. }]);
  34685. function ContextMenu(hotInstance) {
  34686. _classCallCheck(this, ContextMenu);
  34687. /**
  34688. * Instance of {@link EventManager}.
  34689. *
  34690. * @type {EventManager}
  34691. */
  34692. var _this = _possibleConstructorReturn(this, (ContextMenu.__proto__ || Object.getPrototypeOf(ContextMenu)).call(this, hotInstance));
  34693. _this.eventManager = new _eventManager2.default(_this);
  34694. /**
  34695. * Instance of {@link CommandExecutor}.
  34696. *
  34697. * @type {CommandExecutor}
  34698. */
  34699. _this.commandExecutor = new _commandExecutor2.default(_this.hot);
  34700. /**
  34701. * Instance of {@link ItemsFactory}.
  34702. *
  34703. * @type {ItemsFactory}
  34704. */
  34705. _this.itemsFactory = null;
  34706. /**
  34707. * Instance of {@link Menu}.
  34708. *
  34709. * @type {Menu}
  34710. */
  34711. _this.menu = null;
  34712. return _this;
  34713. }
  34714. /**
  34715. * Check if the plugin is enabled in the Handsontable settings.
  34716. *
  34717. * @returns {Boolean}
  34718. */
  34719. _createClass(ContextMenu, [{
  34720. key: 'isEnabled',
  34721. value: function isEnabled() {
  34722. return this.hot.getSettings().contextMenu;
  34723. }
  34724. /**
  34725. * Enable plugin for this Handsontable instance.
  34726. */
  34727. }, {
  34728. key: 'enablePlugin',
  34729. value: function enablePlugin() {
  34730. var _this2 = this;
  34731. if (this.enabled) {
  34732. return;
  34733. }
  34734. this.itemsFactory = new _itemsFactory2.default(this.hot, ContextMenu.DEFAULT_ITEMS);
  34735. var settings = this.hot.getSettings().contextMenu;
  34736. var predefinedItems = {
  34737. items: this.itemsFactory.getItems(settings)
  34738. };
  34739. this.registerEvents();
  34740. if (typeof settings.callback === 'function') {
  34741. this.commandExecutor.setCommonCallback(settings.callback);
  34742. }
  34743. _get(ContextMenu.prototype.__proto__ || Object.getPrototypeOf(ContextMenu.prototype), 'enablePlugin', this).call(this);
  34744. var delayedInitialization = function delayedInitialization() {
  34745. if (!_this2.hot) {
  34746. return;
  34747. }
  34748. _this2.hot.runHooks('afterContextMenuDefaultOptions', predefinedItems);
  34749. _this2.itemsFactory.setPredefinedItems(predefinedItems.items);
  34750. var menuItems = _this2.itemsFactory.getItems(settings);
  34751. _this2.menu = new _menu2.default(_this2.hot, {
  34752. className: 'htContextMenu',
  34753. keepInViewport: true
  34754. });
  34755. _this2.hot.runHooks('beforeContextMenuSetItems', menuItems);
  34756. _this2.menu.setMenuItems(menuItems);
  34757. _this2.menu.addLocalHook('beforeOpen', function () {
  34758. return _this2.onMenuBeforeOpen();
  34759. });
  34760. _this2.menu.addLocalHook('afterOpen', function () {
  34761. return _this2.onMenuAfterOpen();
  34762. });
  34763. _this2.menu.addLocalHook('afterClose', function () {
  34764. return _this2.onMenuAfterClose();
  34765. });
  34766. _this2.menu.addLocalHook('executeCommand', function () {
  34767. for (var _len = arguments.length, params = Array(_len), _key = 0; _key < _len; _key++) {
  34768. params[_key] = arguments[_key];
  34769. }
  34770. return _this2.executeCommand.apply(_this2, params);
  34771. });
  34772. // Register all commands. Predefined and added by user or by plugins
  34773. (0, _array.arrayEach)(menuItems, function (command) {
  34774. return _this2.commandExecutor.registerCommand(command.key, command);
  34775. });
  34776. };
  34777. this.callOnPluginsReady(function () {
  34778. if (_this2.isPluginsReady) {
  34779. setTimeout(delayedInitialization, 0);
  34780. } else {
  34781. delayedInitialization();
  34782. }
  34783. });
  34784. }
  34785. /**
  34786. * Updates the plugin to use the latest options you have specified.
  34787. */
  34788. }, {
  34789. key: 'updatePlugin',
  34790. value: function updatePlugin() {
  34791. this.disablePlugin();
  34792. this.enablePlugin();
  34793. _get(ContextMenu.prototype.__proto__ || Object.getPrototypeOf(ContextMenu.prototype), 'updatePlugin', this).call(this);
  34794. }
  34795. /**
  34796. * Disable plugin for this Handsontable instance.
  34797. */
  34798. }, {
  34799. key: 'disablePlugin',
  34800. value: function disablePlugin() {
  34801. this.close();
  34802. if (this.menu) {
  34803. this.menu.destroy();
  34804. this.menu = null;
  34805. }
  34806. _get(ContextMenu.prototype.__proto__ || Object.getPrototypeOf(ContextMenu.prototype), 'disablePlugin', this).call(this);
  34807. }
  34808. /**
  34809. * Register dom listeners.
  34810. *
  34811. * @private
  34812. */
  34813. }, {
  34814. key: 'registerEvents',
  34815. value: function registerEvents() {
  34816. var _this3 = this;
  34817. this.eventManager.addEventListener(this.hot.rootElement, 'contextmenu', function (event) {
  34818. return _this3.onContextMenu(event);
  34819. });
  34820. }
  34821. /**
  34822. * Open menu and re-position it based on dom event object.
  34823. *
  34824. * @param {Event} event The event object.
  34825. */
  34826. }, {
  34827. key: 'open',
  34828. value: function open(event) {
  34829. if (!this.menu) {
  34830. return;
  34831. }
  34832. this.menu.open();
  34833. this.menu.setPosition({
  34834. top: parseInt((0, _event.pageY)(event), 10) - (0, _element.getWindowScrollTop)(),
  34835. left: parseInt((0, _event.pageX)(event), 10) - (0, _element.getWindowScrollLeft)()
  34836. });
  34837. // ContextMenu is not detected HotTableEnv correctly because is injected outside hot-table
  34838. this.menu.hotMenu.isHotTableEnv = this.hot.isHotTableEnv;
  34839. // Handsontable.eventManager.isHotTableEnv = this.hot.isHotTableEnv;
  34840. }
  34841. /**
  34842. * Close menu.
  34843. */
  34844. }, {
  34845. key: 'close',
  34846. value: function close() {
  34847. if (!this.menu) {
  34848. return;
  34849. }
  34850. this.menu.close();
  34851. }
  34852. /**
  34853. * Execute context menu command.
  34854. *
  34855. * You can execute all predefined commands:
  34856. * * `'row_above'` - Insert row above
  34857. * * `'row_below'` - Insert row below
  34858. * * `'col_left'` - Insert column left
  34859. * * `'col_right'` - Insert column right
  34860. * * `'clear_column'` - Clear selected column
  34861. * * `'remove_row'` - Remove row
  34862. * * `'remove_col'` - Remove column
  34863. * * `'undo'` - Undo last action
  34864. * * `'redo'` - Redo last action
  34865. * * `'make_read_only'` - Make cell read only
  34866. * * `'alignment:left'` - Alignment to the left
  34867. * * `'alignment:top'` - Alignment to the top
  34868. * * `'alignment:right'` - Alignment to the right
  34869. * * `'alignment:bottom'` - Alignment to the bottom
  34870. * * `'alignment:middle'` - Alignment to the middle
  34871. * * `'alignment:center'` - Alignment to the center (justify)
  34872. *
  34873. * Or you can execute command registered in settings where `key` is your command name.
  34874. *
  34875. * @param {String} commandName
  34876. * @param {*} params
  34877. */
  34878. }, {
  34879. key: 'executeCommand',
  34880. value: function executeCommand() {
  34881. for (var _len2 = arguments.length, params = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  34882. params[_key2] = arguments[_key2];
  34883. }
  34884. this.commandExecutor.execute.apply(this.commandExecutor, params);
  34885. }
  34886. /**
  34887. * On context menu listener.
  34888. *
  34889. * @private
  34890. * @param {Event} event
  34891. */
  34892. }, {
  34893. key: 'onContextMenu',
  34894. value: function onContextMenu(event) {
  34895. var settings = this.hot.getSettings();
  34896. var showRowHeaders = settings.rowHeaders;
  34897. var showColHeaders = settings.colHeaders;
  34898. function isValidElement(element) {
  34899. return element.nodeName === 'TD' || element.parentNode.nodeName === 'TD';
  34900. }
  34901. // if event is from hot-table we must get web component element not element inside him
  34902. var element = event.realTarget;
  34903. this.close();
  34904. if ((0, _element.hasClass)(element, 'handsontableInput')) {
  34905. return;
  34906. }
  34907. event.preventDefault();
  34908. (0, _event.stopPropagation)(event);
  34909. if (!(showRowHeaders || showColHeaders)) {
  34910. if (!isValidElement(element) && !((0, _element.hasClass)(element, 'current') && (0, _element.hasClass)(element, 'wtBorder'))) {
  34911. return;
  34912. }
  34913. }
  34914. this.open(event);
  34915. }
  34916. /**
  34917. * On menu before open listener.
  34918. *
  34919. * @private
  34920. */
  34921. }, {
  34922. key: 'onMenuBeforeOpen',
  34923. value: function onMenuBeforeOpen() {
  34924. this.hot.runHooks('beforeContextMenuShow', this);
  34925. }
  34926. /**
  34927. * On menu after open listener.
  34928. *
  34929. * @private
  34930. */
  34931. }, {
  34932. key: 'onMenuAfterOpen',
  34933. value: function onMenuAfterOpen() {
  34934. this.hot.runHooks('afterContextMenuShow', this);
  34935. }
  34936. /**
  34937. * On menu after close listener.
  34938. *
  34939. * @private
  34940. */
  34941. }, {
  34942. key: 'onMenuAfterClose',
  34943. value: function onMenuAfterClose() {
  34944. this.hot.listen();
  34945. this.hot.runHooks('afterContextMenuHide', this);
  34946. }
  34947. /**
  34948. * Destroy instance.
  34949. */
  34950. }, {
  34951. key: 'destroy',
  34952. value: function destroy() {
  34953. this.close();
  34954. if (this.menu) {
  34955. this.menu.destroy();
  34956. }
  34957. _get(ContextMenu.prototype.__proto__ || Object.getPrototypeOf(ContextMenu.prototype), 'destroy', this).call(this);
  34958. }
  34959. }]);
  34960. return ContextMenu;
  34961. }(_base2.default);
  34962. ContextMenu.SEPARATOR = {
  34963. name: _predefinedItems.SEPARATOR
  34964. };
  34965. (0, _plugins.registerPlugin)('contextMenu', ContextMenu);
  34966. exports.default = ContextMenu;
  34967. /***/ }),
  34968. /* 298 */
  34969. /***/ (function(module, exports, __webpack_require__) {
  34970. "use strict";
  34971. exports.__esModule = true;
  34972. 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; }; }();
  34973. var _array = __webpack_require__(1);
  34974. var _object = __webpack_require__(2);
  34975. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  34976. /**
  34977. * Command executor for ContextMenu.
  34978. *
  34979. * @class CommandExecutor
  34980. * @plugin ContextMenu
  34981. */
  34982. var CommandExecutor = function () {
  34983. function CommandExecutor(hotInstance) {
  34984. _classCallCheck(this, CommandExecutor);
  34985. this.hot = hotInstance;
  34986. this.commands = {};
  34987. this.commonCallback = null;
  34988. }
  34989. /**
  34990. * Register command.
  34991. *
  34992. * @param {String} name Command name.
  34993. * @param {Object} commandDescriptor Command descriptor object with properties like `key` (command id),
  34994. * `callback` (task to execute), `name` (command name), `disabled` (command availability).
  34995. */
  34996. _createClass(CommandExecutor, [{
  34997. key: 'registerCommand',
  34998. value: function registerCommand(name, commandDescriptor) {
  34999. this.commands[name] = commandDescriptor;
  35000. }
  35001. /**
  35002. * Set common callback which will be trigger on every executed command.
  35003. *
  35004. * @param {Function} callback Function which will be fired on every command execute.
  35005. */
  35006. }, {
  35007. key: 'setCommonCallback',
  35008. value: function setCommonCallback(callback) {
  35009. this.commonCallback = callback;
  35010. }
  35011. /**
  35012. * Execute command by its name.
  35013. *
  35014. * @param {String} commandName Command id.
  35015. * @param {*} params Arguments passed to command task.
  35016. */
  35017. }, {
  35018. key: 'execute',
  35019. value: function execute(commandName) {
  35020. var _this = this;
  35021. for (var _len = arguments.length, params = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  35022. params[_key - 1] = arguments[_key];
  35023. }
  35024. var commandSplit = commandName.split(':');
  35025. commandName = commandSplit[0];
  35026. var subCommandName = commandSplit.length === 2 ? commandSplit[1] : null;
  35027. var command = this.commands[commandName];
  35028. if (!command) {
  35029. throw new Error('Menu command \'' + commandName + '\' not exists.');
  35030. }
  35031. if (subCommandName && command.submenu) {
  35032. command = findSubCommand(subCommandName, command.submenu.items);
  35033. }
  35034. if (command.disabled === true) {
  35035. return;
  35036. }
  35037. if (typeof command.disabled == 'function' && command.disabled.call(this.hot) === true) {
  35038. return;
  35039. }
  35040. if ((0, _object.hasOwnProperty)(command, 'submenu')) {
  35041. return;
  35042. }
  35043. var callbacks = [];
  35044. if (typeof command.callback === 'function') {
  35045. callbacks.push(command.callback);
  35046. }
  35047. if (typeof this.commonCallback === 'function') {
  35048. callbacks.push(this.commonCallback);
  35049. }
  35050. params.unshift(commandSplit.join(':'));
  35051. (0, _array.arrayEach)(callbacks, function (callback) {
  35052. return callback.apply(_this.hot, params);
  35053. });
  35054. }
  35055. }]);
  35056. return CommandExecutor;
  35057. }();
  35058. function findSubCommand(subCommandName, subCommands) {
  35059. var command = void 0;
  35060. (0, _array.arrayEach)(subCommands, function (cmd) {
  35061. var cmds = cmd.key ? cmd.key.split(':') : null;
  35062. if (Array.isArray(cmds) && cmds[1] === subCommandName) {
  35063. command = cmd;
  35064. return false;
  35065. }
  35066. });
  35067. return command;
  35068. }
  35069. exports.default = CommandExecutor;
  35070. /***/ }),
  35071. /* 299 */
  35072. /***/ (function(module, exports, __webpack_require__) {
  35073. "use strict";
  35074. exports.__esModule = true;
  35075. 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; }; }();
  35076. var _object = __webpack_require__(2);
  35077. var _array = __webpack_require__(1);
  35078. var _predefinedItems = __webpack_require__(94);
  35079. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  35080. /**
  35081. * Predefined items class factory for menu items.
  35082. *
  35083. * @class ItemsFactory
  35084. * @plugin ContextMenu
  35085. */
  35086. var ItemsFactory = function () {
  35087. function ItemsFactory(hotInstance) {
  35088. var orderPattern = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  35089. _classCallCheck(this, ItemsFactory);
  35090. this.hot = hotInstance;
  35091. this.predefinedItems = (0, _predefinedItems.predefinedItems)();
  35092. this.defaultOrderPattern = orderPattern;
  35093. }
  35094. /**
  35095. * Set predefined items.
  35096. *
  35097. * @param {Array} predefinedItems Array of predefined items.
  35098. */
  35099. _createClass(ItemsFactory, [{
  35100. key: 'setPredefinedItems',
  35101. value: function setPredefinedItems(predefinedItems) {
  35102. var _this = this;
  35103. var items = {};
  35104. this.defaultOrderPattern.length = 0;
  35105. (0, _object.objectEach)(predefinedItems, function (value, key) {
  35106. var menuItemKey = '';
  35107. if (value.name === _predefinedItems.SEPARATOR) {
  35108. items[_predefinedItems.SEPARATOR] = value;
  35109. menuItemKey = _predefinedItems.SEPARATOR;
  35110. // Menu item added as a property to array
  35111. } else if (isNaN(parseInt(key, 10))) {
  35112. value.key = value.key === void 0 ? key : value.key;
  35113. items[key] = value;
  35114. menuItemKey = value.key;
  35115. } else {
  35116. items[value.key] = value;
  35117. menuItemKey = value.key;
  35118. }
  35119. _this.defaultOrderPattern.push(menuItemKey);
  35120. });
  35121. this.predefinedItems = items;
  35122. }
  35123. /**
  35124. * Get all menu items based on pattern.
  35125. *
  35126. * @param {Array|Object|Boolean} pattern Pattern which you can define by displaying menu items order. If `true` default
  35127. * pattern will be used.
  35128. * @returns {Array}
  35129. */
  35130. }, {
  35131. key: 'getItems',
  35132. value: function getItems() {
  35133. var pattern = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  35134. return _getItems(pattern, this.defaultOrderPattern, this.predefinedItems);
  35135. }
  35136. }]);
  35137. return ItemsFactory;
  35138. }();
  35139. function _getItems() {
  35140. var pattern = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  35141. var defaultPattern = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  35142. var items = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  35143. var result = [];
  35144. if (pattern && pattern.items) {
  35145. pattern = pattern.items;
  35146. } else if (!Array.isArray(pattern)) {
  35147. pattern = defaultPattern;
  35148. }
  35149. if ((0, _object.isObject)(pattern)) {
  35150. (0, _object.objectEach)(pattern, function (value, key) {
  35151. var item = items[typeof value === 'string' ? value : key];
  35152. if (!item) {
  35153. item = value;
  35154. }
  35155. if ((0, _object.isObject)(value)) {
  35156. (0, _object.extend)(item, value);
  35157. } else if (typeof item === 'string') {
  35158. item = { name: item };
  35159. }
  35160. if (item.key === void 0) {
  35161. item.key = key;
  35162. }
  35163. result.push(item);
  35164. });
  35165. } else {
  35166. (0, _array.arrayEach)(pattern, function (name, key) {
  35167. var item = items[name];
  35168. // Item deleted from settings `allowInsertRow: false` etc.
  35169. if (!item && _predefinedItems.ITEMS.indexOf(name) >= 0) {
  35170. return;
  35171. }
  35172. if (!item) {
  35173. item = { name: name, key: '' + key };
  35174. }
  35175. if ((0, _object.isObject)(name)) {
  35176. (0, _object.extend)(item, name);
  35177. }
  35178. if (item.key === void 0) {
  35179. item.key = key;
  35180. }
  35181. result.push(item);
  35182. });
  35183. }
  35184. return result;
  35185. }
  35186. exports.default = ItemsFactory;
  35187. /***/ }),
  35188. /* 300 */
  35189. /***/ (function(module, exports, __webpack_require__) {
  35190. "use strict";
  35191. exports.__esModule = true;
  35192. exports.KEY = undefined;
  35193. exports.default = alignmentItem;
  35194. var _utils = __webpack_require__(19);
  35195. var _separator = __webpack_require__(93);
  35196. var _constants = __webpack_require__(7);
  35197. var C = _interopRequireWildcard(_constants);
  35198. 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; } }
  35199. var KEY = exports.KEY = 'alignment';
  35200. function alignmentItem() {
  35201. return {
  35202. key: KEY,
  35203. name: function name() {
  35204. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ALIGNMENT);
  35205. },
  35206. disabled: function disabled() {
  35207. return !(this.getSelectedRange() && !this.selection.isSelectedByCorner());
  35208. },
  35209. submenu: {
  35210. items: [{
  35211. key: KEY + ':left',
  35212. name: function name() {
  35213. var _this = this;
  35214. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ALIGNMENT_LEFT);
  35215. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  35216. var className = _this.getCellMeta(row, col).className;
  35217. if (className && className.indexOf('htLeft') !== -1) {
  35218. return true;
  35219. }
  35220. });
  35221. if (hasClass) {
  35222. label = (0, _utils.markLabelAsSelected)(label);
  35223. }
  35224. return label;
  35225. },
  35226. callback: function callback() {
  35227. var _this2 = this;
  35228. var selectedRange = this.getSelectedRange();
  35229. var stateBefore = (0, _utils.getAlignmentClasses)(selectedRange, function (row, col) {
  35230. return _this2.getCellMeta(row, col).className;
  35231. });
  35232. var type = 'horizontal';
  35233. var alignment = 'htLeft';
  35234. this.runHooks('beforeCellAlignment', stateBefore, selectedRange, type, alignment);
  35235. (0, _utils.align)(selectedRange, type, alignment, function (row, col) {
  35236. return _this2.getCellMeta(row, col);
  35237. }, function (row, col, key, value) {
  35238. return _this2.setCellMeta(row, col, key, value);
  35239. });
  35240. this.render();
  35241. },
  35242. disabled: false
  35243. }, {
  35244. key: KEY + ':center',
  35245. name: function name() {
  35246. var _this3 = this;
  35247. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ALIGNMENT_CENTER);
  35248. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  35249. var className = _this3.getCellMeta(row, col).className;
  35250. if (className && className.indexOf('htCenter') !== -1) {
  35251. return true;
  35252. }
  35253. });
  35254. if (hasClass) {
  35255. label = (0, _utils.markLabelAsSelected)(label);
  35256. }
  35257. return label;
  35258. },
  35259. callback: function callback(key, selection) {
  35260. var _this4 = this;
  35261. var selectedRange = this.getSelectedRange();
  35262. var stateBefore = (0, _utils.getAlignmentClasses)(selectedRange, function (row, col) {
  35263. return _this4.getCellMeta(row, col).className;
  35264. });
  35265. var type = 'horizontal';
  35266. var alignment = 'htCenter';
  35267. this.runHooks('beforeCellAlignment', stateBefore, selectedRange, type, alignment);
  35268. (0, _utils.align)(selectedRange, type, alignment, function (row, col) {
  35269. return _this4.getCellMeta(row, col);
  35270. }, function (row, col, key, value) {
  35271. return _this4.setCellMeta(row, col, key, value);
  35272. });
  35273. this.render();
  35274. },
  35275. disabled: false
  35276. }, {
  35277. key: KEY + ':right',
  35278. name: function name() {
  35279. var _this5 = this;
  35280. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ALIGNMENT_RIGHT);
  35281. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  35282. var className = _this5.getCellMeta(row, col).className;
  35283. if (className && className.indexOf('htRight') !== -1) {
  35284. return true;
  35285. }
  35286. });
  35287. if (hasClass) {
  35288. label = (0, _utils.markLabelAsSelected)(label);
  35289. }
  35290. return label;
  35291. },
  35292. callback: function callback() {
  35293. var _this6 = this;
  35294. var selectedRange = this.getSelectedRange();
  35295. var stateBefore = (0, _utils.getAlignmentClasses)(selectedRange, function (row, col) {
  35296. return _this6.getCellMeta(row, col).className;
  35297. });
  35298. var type = 'horizontal';
  35299. var alignment = 'htRight';
  35300. this.runHooks('beforeCellAlignment', stateBefore, selectedRange, type, alignment);
  35301. (0, _utils.align)(selectedRange, type, alignment, function (row, col) {
  35302. return _this6.getCellMeta(row, col);
  35303. }, function (row, col, key, value) {
  35304. return _this6.setCellMeta(row, col, key, value);
  35305. });
  35306. this.render();
  35307. },
  35308. disabled: false
  35309. }, {
  35310. key: KEY + ':justify',
  35311. name: function name() {
  35312. var _this7 = this;
  35313. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ALIGNMENT_JUSTIFY);
  35314. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  35315. var className = _this7.getCellMeta(row, col).className;
  35316. if (className && className.indexOf('htJustify') !== -1) {
  35317. return true;
  35318. }
  35319. });
  35320. if (hasClass) {
  35321. label = (0, _utils.markLabelAsSelected)(label);
  35322. }
  35323. return label;
  35324. },
  35325. callback: function callback() {
  35326. var _this8 = this;
  35327. var selectedRange = this.getSelectedRange();
  35328. var stateBefore = (0, _utils.getAlignmentClasses)(selectedRange, function (row, col) {
  35329. return _this8.getCellMeta(row, col).className;
  35330. });
  35331. var type = 'horizontal';
  35332. var alignment = 'htJustify';
  35333. this.runHooks('beforeCellAlignment', stateBefore, selectedRange, type, alignment);
  35334. (0, _utils.align)(selectedRange, type, alignment, function (row, col) {
  35335. return _this8.getCellMeta(row, col);
  35336. }, function (row, col, key, value) {
  35337. return _this8.setCellMeta(row, col, key, value);
  35338. });
  35339. this.render();
  35340. },
  35341. disabled: false
  35342. }, {
  35343. name: _separator.KEY
  35344. }, {
  35345. key: KEY + ':top',
  35346. name: function name() {
  35347. var _this9 = this;
  35348. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ALIGNMENT_TOP);
  35349. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  35350. var className = _this9.getCellMeta(row, col).className;
  35351. if (className && className.indexOf('htTop') !== -1) {
  35352. return true;
  35353. }
  35354. });
  35355. if (hasClass) {
  35356. label = (0, _utils.markLabelAsSelected)(label);
  35357. }
  35358. return label;
  35359. },
  35360. callback: function callback() {
  35361. var _this10 = this;
  35362. var selectedRange = this.getSelectedRange();
  35363. var stateBefore = (0, _utils.getAlignmentClasses)(selectedRange, function (row, col) {
  35364. return _this10.getCellMeta(row, col).className;
  35365. });
  35366. var type = 'vertical';
  35367. var alignment = 'htTop';
  35368. this.runHooks('beforeCellAlignment', stateBefore, selectedRange, type, alignment);
  35369. (0, _utils.align)(selectedRange, type, alignment, function (row, col) {
  35370. return _this10.getCellMeta(row, col);
  35371. }, function (row, col, key, value) {
  35372. return _this10.setCellMeta(row, col, key, value);
  35373. });
  35374. this.render();
  35375. },
  35376. disabled: false
  35377. }, {
  35378. key: KEY + ':middle',
  35379. name: function name() {
  35380. var _this11 = this;
  35381. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ALIGNMENT_MIDDLE);
  35382. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  35383. var className = _this11.getCellMeta(row, col).className;
  35384. if (className && className.indexOf('htMiddle') !== -1) {
  35385. return true;
  35386. }
  35387. });
  35388. if (hasClass) {
  35389. label = (0, _utils.markLabelAsSelected)(label);
  35390. }
  35391. return label;
  35392. },
  35393. callback: function callback() {
  35394. var _this12 = this;
  35395. var selectedRange = this.getSelectedRange();
  35396. var stateBefore = (0, _utils.getAlignmentClasses)(selectedRange, function (row, col) {
  35397. return _this12.getCellMeta(row, col).className;
  35398. });
  35399. var type = 'vertical';
  35400. var alignment = 'htMiddle';
  35401. this.runHooks('beforeCellAlignment', stateBefore, selectedRange, type, alignment);
  35402. (0, _utils.align)(selectedRange, type, alignment, function (row, col) {
  35403. return _this12.getCellMeta(row, col);
  35404. }, function (row, col, key, value) {
  35405. return _this12.setCellMeta(row, col, key, value);
  35406. });
  35407. this.render();
  35408. },
  35409. disabled: false
  35410. }, {
  35411. key: KEY + ':bottom',
  35412. name: function name() {
  35413. var _this13 = this;
  35414. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ALIGNMENT_BOTTOM);
  35415. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  35416. var className = _this13.getCellMeta(row, col).className;
  35417. if (className && className.indexOf('htBottom') !== -1) {
  35418. return true;
  35419. }
  35420. });
  35421. if (hasClass) {
  35422. label = (0, _utils.markLabelAsSelected)(label);
  35423. }
  35424. return label;
  35425. },
  35426. callback: function callback() {
  35427. var _this14 = this;
  35428. var selectedRange = this.getSelectedRange();
  35429. var stateBefore = (0, _utils.getAlignmentClasses)(selectedRange, function (row, col) {
  35430. return _this14.getCellMeta(row, col).className;
  35431. });
  35432. var type = 'vertical';
  35433. var alignment = 'htBottom';
  35434. this.runHooks('beforeCellAlignment', stateBefore, selectedRange, type, alignment);
  35435. (0, _utils.align)(selectedRange, type, alignment, function (row, col) {
  35436. return _this14.getCellMeta(row, col);
  35437. }, function (row, col, key, value) {
  35438. return _this14.setCellMeta(row, col, key, value);
  35439. });
  35440. this.render();
  35441. },
  35442. disabled: false
  35443. }]
  35444. }
  35445. };
  35446. }
  35447. /***/ }),
  35448. /* 301 */
  35449. /***/ (function(module, exports, __webpack_require__) {
  35450. "use strict";
  35451. exports.__esModule = true;
  35452. exports.KEY = undefined;
  35453. 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"); } }; }();
  35454. exports.default = clearColumnItem;
  35455. var _utils = __webpack_require__(19);
  35456. var _constants = __webpack_require__(7);
  35457. var C = _interopRequireWildcard(_constants);
  35458. 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; } }
  35459. var KEY = exports.KEY = 'clear_column';
  35460. function clearColumnItem() {
  35461. return {
  35462. key: KEY,
  35463. name: function name() {
  35464. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_CLEAR_COLUMN);
  35465. },
  35466. callback: function callback(key, selection) {
  35467. var column = selection[0].start.col;
  35468. if (this.countRows()) {
  35469. this.populateFromArray(0, column, [[null]], Math.max(selection[0].start.row, selection[0].end.row), column, 'ContextMenu.clearColumn');
  35470. }
  35471. },
  35472. disabled: function disabled() {
  35473. var selected = (0, _utils.getValidSelection)(this);
  35474. if (!selected) {
  35475. return true;
  35476. }
  35477. var _selected$ = _slicedToArray(selected[0], 4),
  35478. startRow = _selected$[0],
  35479. startColumn = _selected$[1],
  35480. endRow = _selected$[2],
  35481. endColumn = _selected$[3];
  35482. var entireRowSelection = [startRow, 0, endRow, this.countCols() - 1];
  35483. var rowSelected = entireRowSelection.join(',') === selected.join(',');
  35484. return startColumn < 0 || this.countCols() >= this.getSettings().maxCols || rowSelected;
  35485. }
  35486. };
  35487. }
  35488. /***/ }),
  35489. /* 302 */
  35490. /***/ (function(module, exports, __webpack_require__) {
  35491. "use strict";
  35492. exports.__esModule = true;
  35493. exports.KEY = undefined;
  35494. 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"); } }; }();
  35495. exports.default = columnLeftItem;
  35496. var _utils = __webpack_require__(19);
  35497. var _constants = __webpack_require__(7);
  35498. var C = _interopRequireWildcard(_constants);
  35499. 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; } }
  35500. var KEY = exports.KEY = 'col_left';
  35501. function columnLeftItem() {
  35502. return {
  35503. key: KEY,
  35504. name: function name() {
  35505. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_INSERT_LEFT);
  35506. },
  35507. callback: function callback(key, normalizedSelection) {
  35508. var latestSelection = normalizedSelection[Math.max(normalizedSelection.length - 1, 0)];
  35509. this.alter('insert_col', latestSelection.start.col, 1, 'ContextMenu.columnLeft');
  35510. },
  35511. disabled: function disabled() {
  35512. var selected = (0, _utils.getValidSelection)(this);
  35513. if (!selected) {
  35514. return true;
  35515. }
  35516. if (!this.isColumnModificationAllowed()) {
  35517. return true;
  35518. }
  35519. var _selected$ = _slicedToArray(selected[0], 4),
  35520. startRow = _selected$[0],
  35521. startColumn = _selected$[1],
  35522. endRow = _selected$[2],
  35523. endColumn = _selected$[3];
  35524. var entireRowSelection = [startRow, 0, endRow, this.countCols() - 1];
  35525. var rowSelected = entireRowSelection.join(',') === selected.join(',');
  35526. var onlyOneColumn = this.countCols() === 1;
  35527. return startColumn < 0 || this.countCols() >= this.getSettings().maxCols || !onlyOneColumn && rowSelected;
  35528. },
  35529. hidden: function hidden() {
  35530. return !this.getSettings().allowInsertColumn;
  35531. }
  35532. };
  35533. }
  35534. /***/ }),
  35535. /* 303 */
  35536. /***/ (function(module, exports, __webpack_require__) {
  35537. "use strict";
  35538. exports.__esModule = true;
  35539. exports.KEY = undefined;
  35540. 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"); } }; }();
  35541. exports.default = columnRightItem;
  35542. var _utils = __webpack_require__(19);
  35543. var _constants = __webpack_require__(7);
  35544. var C = _interopRequireWildcard(_constants);
  35545. 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; } }
  35546. var KEY = exports.KEY = 'col_right';
  35547. function columnRightItem() {
  35548. return {
  35549. key: KEY,
  35550. name: function name() {
  35551. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_INSERT_RIGHT);
  35552. },
  35553. callback: function callback(key, normalizedSelection) {
  35554. var latestSelection = normalizedSelection[Math.max(normalizedSelection.length - 1, 0)];
  35555. this.alter('insert_col', latestSelection.end.col + 1, 1, 'ContextMenu.columnRight');
  35556. },
  35557. disabled: function disabled() {
  35558. var selected = (0, _utils.getValidSelection)(this);
  35559. if (!selected) {
  35560. return true;
  35561. }
  35562. if (!this.isColumnModificationAllowed()) {
  35563. return true;
  35564. }
  35565. var _selected$ = _slicedToArray(selected[0], 4),
  35566. startRow = _selected$[0],
  35567. startColumn = _selected$[1],
  35568. endRow = _selected$[2],
  35569. endColumn = _selected$[3];
  35570. var entireRowSelection = [startRow, 0, endRow, this.countCols() - 1];
  35571. var rowSelected = entireRowSelection.join(',') === selected.join(',');
  35572. var onlyOneColumn = this.countCols() === 1;
  35573. return startColumn < 0 || this.countCols() >= this.getSettings().maxCols || !onlyOneColumn && rowSelected;
  35574. },
  35575. hidden: function hidden() {
  35576. return !this.getSettings().allowInsertColumn;
  35577. }
  35578. };
  35579. }
  35580. /***/ }),
  35581. /* 304 */
  35582. /***/ (function(module, exports, __webpack_require__) {
  35583. "use strict";
  35584. exports.__esModule = true;
  35585. exports.KEY = undefined;
  35586. exports.default = readOnlyItem;
  35587. var _utils = __webpack_require__(19);
  35588. var _array = __webpack_require__(1);
  35589. var _constants = __webpack_require__(7);
  35590. var C = _interopRequireWildcard(_constants);
  35591. 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; } }
  35592. var KEY = exports.KEY = 'make_read_only';
  35593. function readOnlyItem() {
  35594. return {
  35595. key: KEY,
  35596. name: function name() {
  35597. var _this = this;
  35598. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_READ_ONLY);
  35599. var atLeastOneReadOnly = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  35600. return _this.getCellMeta(row, col).readOnly;
  35601. });
  35602. if (atLeastOneReadOnly) {
  35603. label = (0, _utils.markLabelAsSelected)(label);
  35604. }
  35605. return label;
  35606. },
  35607. callback: function callback() {
  35608. var _this2 = this;
  35609. var ranges = this.getSelectedRange();
  35610. var atLeastOneReadOnly = (0, _utils.checkSelectionConsistency)(ranges, function (row, col) {
  35611. return _this2.getCellMeta(row, col).readOnly;
  35612. });
  35613. (0, _array.arrayEach)(ranges, function (range) {
  35614. range.forAll(function (row, col) {
  35615. _this2.setCellMeta(row, col, 'readOnly', !atLeastOneReadOnly);
  35616. });
  35617. });
  35618. this.render();
  35619. },
  35620. disabled: function disabled() {
  35621. return !(this.getSelectedRange() && !this.selection.isSelectedByCorner());
  35622. }
  35623. };
  35624. }
  35625. /***/ }),
  35626. /* 305 */
  35627. /***/ (function(module, exports, __webpack_require__) {
  35628. "use strict";
  35629. exports.__esModule = true;
  35630. exports.KEY = undefined;
  35631. exports.default = redoItem;
  35632. var _constants = __webpack_require__(7);
  35633. var C = _interopRequireWildcard(_constants);
  35634. 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; } }
  35635. var KEY = exports.KEY = 'redo';
  35636. function redoItem() {
  35637. return {
  35638. key: KEY,
  35639. name: function name() {
  35640. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_REDO);
  35641. },
  35642. callback: function callback() {
  35643. this.redo();
  35644. },
  35645. disabled: function disabled() {
  35646. return this.undoRedo && !this.undoRedo.isRedoAvailable();
  35647. }
  35648. };
  35649. }
  35650. /***/ }),
  35651. /* 306 */
  35652. /***/ (function(module, exports, __webpack_require__) {
  35653. "use strict";
  35654. exports.__esModule = true;
  35655. exports.KEY = undefined;
  35656. 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"); } }; }();
  35657. exports.default = removeColumnItem;
  35658. var _utils = __webpack_require__(19);
  35659. var _array = __webpack_require__(1);
  35660. var _utils2 = __webpack_require__(91);
  35661. var _constants = __webpack_require__(7);
  35662. var C = _interopRequireWildcard(_constants);
  35663. 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; } }
  35664. var KEY = exports.KEY = 'remove_col';
  35665. function removeColumnItem() {
  35666. return {
  35667. key: KEY,
  35668. name: function name() {
  35669. var selection = this.getSelected();
  35670. var pluralForm = 0;
  35671. if (selection) {
  35672. if (selection.length > 1) {
  35673. pluralForm = 1;
  35674. } else {
  35675. var _selection$ = _slicedToArray(selection[0], 4),
  35676. fromColumn = _selection$[1],
  35677. toColumn = _selection$[3];
  35678. if (fromColumn - toColumn !== 0) {
  35679. pluralForm = 1;
  35680. }
  35681. }
  35682. }
  35683. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_REMOVE_COLUMN, pluralForm);
  35684. },
  35685. callback: function callback() {
  35686. this.alter('remove_col', (0, _utils2.transformSelectionToColumnDistance)(this.getSelected()), null, 'ContextMenu.removeColumn');
  35687. },
  35688. disabled: function disabled() {
  35689. var selected = (0, _utils.getValidSelection)(this);
  35690. var totalColumns = this.countCols();
  35691. if (!selected) {
  35692. return true;
  35693. }
  35694. return this.selection.isSelectedByRowHeader() || this.selection.isSelectedByCorner() || !this.isColumnModificationAllowed() || !totalColumns;
  35695. },
  35696. hidden: function hidden() {
  35697. return !this.getSettings().allowRemoveColumn;
  35698. }
  35699. };
  35700. }
  35701. /***/ }),
  35702. /* 307 */
  35703. /***/ (function(module, exports, __webpack_require__) {
  35704. "use strict";
  35705. exports.__esModule = true;
  35706. exports.KEY = undefined;
  35707. 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"); } }; }();
  35708. exports.default = removeRowItem;
  35709. var _utils = __webpack_require__(19);
  35710. var _array = __webpack_require__(1);
  35711. var _utils2 = __webpack_require__(91);
  35712. var _constants = __webpack_require__(7);
  35713. var C = _interopRequireWildcard(_constants);
  35714. 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; } }
  35715. var KEY = exports.KEY = 'remove_row';
  35716. function removeRowItem() {
  35717. return {
  35718. key: KEY,
  35719. name: function name() {
  35720. var selection = this.getSelected();
  35721. var pluralForm = 0;
  35722. if (selection) {
  35723. if (selection.length > 1) {
  35724. pluralForm = 1;
  35725. } else {
  35726. var _selection$ = _slicedToArray(selection[0], 3),
  35727. fromRow = _selection$[0],
  35728. toRow = _selection$[2];
  35729. if (fromRow - toRow !== 0) {
  35730. pluralForm = 1;
  35731. }
  35732. }
  35733. }
  35734. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_REMOVE_ROW, pluralForm);
  35735. },
  35736. callback: function callback() {
  35737. this.alter('remove_row', (0, _utils2.transformSelectionToRowDistance)(this.getSelected()), null, 'ContextMenu.removeRow');
  35738. },
  35739. disabled: function disabled() {
  35740. var selected = (0, _utils.getValidSelection)(this);
  35741. var totalRows = this.countRows();
  35742. if (!selected) {
  35743. return true;
  35744. }
  35745. return this.selection.isSelectedByColumnHeader() || this.selection.isSelectedByCorner() || !totalRows;
  35746. },
  35747. hidden: function hidden() {
  35748. return !this.getSettings().allowRemoveRow;
  35749. }
  35750. };
  35751. }
  35752. /***/ }),
  35753. /* 308 */
  35754. /***/ (function(module, exports, __webpack_require__) {
  35755. "use strict";
  35756. exports.__esModule = true;
  35757. exports.KEY = undefined;
  35758. exports.default = rowAboveItem;
  35759. var _utils = __webpack_require__(19);
  35760. var _constants = __webpack_require__(7);
  35761. var C = _interopRequireWildcard(_constants);
  35762. 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; } }
  35763. var KEY = exports.KEY = 'row_above';
  35764. function rowAboveItem() {
  35765. return {
  35766. key: KEY,
  35767. name: function name() {
  35768. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ROW_ABOVE);
  35769. },
  35770. callback: function callback(key, normalizedSelection) {
  35771. var latestSelection = normalizedSelection[Math.max(normalizedSelection.length - 1, 0)];
  35772. this.alter('insert_row', latestSelection.start.row, 1, 'ContextMenu.rowAbove');
  35773. },
  35774. disabled: function disabled() {
  35775. var selected = (0, _utils.getValidSelection)(this);
  35776. if (!selected) {
  35777. return true;
  35778. }
  35779. return this.selection.isSelectedByColumnHeader() || this.countRows() >= this.getSettings().maxRows;
  35780. },
  35781. hidden: function hidden() {
  35782. return !this.getSettings().allowInsertRow;
  35783. }
  35784. };
  35785. }
  35786. /***/ }),
  35787. /* 309 */
  35788. /***/ (function(module, exports, __webpack_require__) {
  35789. "use strict";
  35790. exports.__esModule = true;
  35791. exports.KEY = undefined;
  35792. exports.default = rowBelowItem;
  35793. var _utils = __webpack_require__(19);
  35794. var _constants = __webpack_require__(7);
  35795. var C = _interopRequireWildcard(_constants);
  35796. 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; } }
  35797. var KEY = exports.KEY = 'row_below';
  35798. function rowBelowItem() {
  35799. return {
  35800. key: KEY,
  35801. name: function name() {
  35802. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ROW_BELOW);
  35803. },
  35804. callback: function callback(key, normalizedSelection) {
  35805. var latestSelection = normalizedSelection[Math.max(normalizedSelection.length - 1, 0)];
  35806. this.alter('insert_row', latestSelection.end.row + 1, 1, 'ContextMenu.rowBelow');
  35807. },
  35808. disabled: function disabled() {
  35809. var selected = (0, _utils.getValidSelection)(this);
  35810. if (!selected) {
  35811. return true;
  35812. }
  35813. return this.selection.isSelectedByColumnHeader() || this.countRows() >= this.getSettings().maxRows;
  35814. },
  35815. hidden: function hidden() {
  35816. return !this.getSettings().allowInsertRow;
  35817. }
  35818. };
  35819. }
  35820. /***/ }),
  35821. /* 310 */
  35822. /***/ (function(module, exports, __webpack_require__) {
  35823. "use strict";
  35824. exports.__esModule = true;
  35825. exports.KEY = undefined;
  35826. exports.default = undoItem;
  35827. var _constants = __webpack_require__(7);
  35828. var C = _interopRequireWildcard(_constants);
  35829. 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; } }
  35830. var KEY = exports.KEY = 'undo';
  35831. function undoItem() {
  35832. return {
  35833. key: KEY,
  35834. name: function name() {
  35835. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_UNDO);
  35836. },
  35837. callback: function callback() {
  35838. this.undo();
  35839. },
  35840. disabled: function disabled() {
  35841. return this.undoRedo && !this.undoRedo.isUndoAvailable();
  35842. }
  35843. };
  35844. }
  35845. /***/ }),
  35846. /* 311 */
  35847. /***/ (function(module, exports, __webpack_require__) {
  35848. "use strict";
  35849. exports.__esModule = true;
  35850. 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; }; }();
  35851. var _core = __webpack_require__(88);
  35852. var _core2 = _interopRequireDefault(_core);
  35853. var _element = __webpack_require__(0);
  35854. var _array = __webpack_require__(1);
  35855. var _cursor = __webpack_require__(312);
  35856. var _cursor2 = _interopRequireDefault(_cursor);
  35857. var _eventManager = __webpack_require__(6);
  35858. var _eventManager2 = _interopRequireDefault(_eventManager);
  35859. var _object = __webpack_require__(2);
  35860. var _mixed = __webpack_require__(16);
  35861. var _function = __webpack_require__(42);
  35862. var _utils = __webpack_require__(19);
  35863. var _unicode = __webpack_require__(21);
  35864. var _localHooks = __webpack_require__(58);
  35865. var _localHooks2 = _interopRequireDefault(_localHooks);
  35866. var _predefinedItems = __webpack_require__(94);
  35867. var _event = __webpack_require__(12);
  35868. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  35869. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  35870. var MIN_WIDTH = 215;
  35871. /**
  35872. * @class Menu
  35873. * @plugin ContextMenu
  35874. */
  35875. var Menu = function () {
  35876. function Menu(hotInstance, options) {
  35877. _classCallCheck(this, Menu);
  35878. this.hot = hotInstance;
  35879. this.options = options || {
  35880. parent: null,
  35881. name: null,
  35882. className: '',
  35883. keepInViewport: true,
  35884. standalone: false,
  35885. minWidth: MIN_WIDTH
  35886. };
  35887. this.eventManager = new _eventManager2.default(this);
  35888. this.container = this.createContainer(this.options.name);
  35889. this.hotMenu = null;
  35890. this.hotSubMenus = {};
  35891. this.parentMenu = this.options.parent || null;
  35892. this.menuItems = null;
  35893. this.origOutsideClickDeselects = null;
  35894. this.keyEvent = false;
  35895. this.offset = {
  35896. above: 0,
  35897. below: 0,
  35898. left: 0,
  35899. right: 0
  35900. };
  35901. this._afterScrollCallback = null;
  35902. this.registerEvents();
  35903. }
  35904. /**
  35905. * Register event listeners.
  35906. *
  35907. * @private
  35908. */
  35909. _createClass(Menu, [{
  35910. key: 'registerEvents',
  35911. value: function registerEvents() {
  35912. var _this = this;
  35913. this.eventManager.addEventListener(document.documentElement, 'mousedown', function (event) {
  35914. return _this.onDocumentMouseDown(event);
  35915. });
  35916. }
  35917. /**
  35918. * Set array of objects which defines menu items.
  35919. *
  35920. * @param {Array} menuItems Menu items to display.
  35921. */
  35922. }, {
  35923. key: 'setMenuItems',
  35924. value: function setMenuItems(menuItems) {
  35925. this.menuItems = menuItems;
  35926. }
  35927. /**
  35928. * Set offset menu position for specified area (`above`, `below`, `left` or `right`).
  35929. *
  35930. * @param {String} area Specified area name (`above`, `below`, `left` or `right`).
  35931. * @param {Number} offset Offset value.
  35932. */
  35933. }, {
  35934. key: 'setOffset',
  35935. value: function setOffset(area) {
  35936. var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  35937. this.offset[area] = offset;
  35938. }
  35939. /**
  35940. * Check if menu is using as sub-menu.
  35941. *
  35942. * @returns {Boolean}
  35943. */
  35944. }, {
  35945. key: 'isSubMenu',
  35946. value: function isSubMenu() {
  35947. return this.parentMenu !== null;
  35948. }
  35949. /**
  35950. * Open menu.
  35951. *
  35952. * @fires Hooks#beforeContextMenuShow
  35953. * @fires Hooks#afterContextMenuShow
  35954. */
  35955. }, {
  35956. key: 'open',
  35957. value: function open() {
  35958. var _this2 = this;
  35959. this.runLocalHooks('beforeOpen');
  35960. this.container.removeAttribute('style');
  35961. this.container.style.display = 'block';
  35962. var delayedOpenSubMenu = (0, _function.debounce)(function (row) {
  35963. return _this2.openSubMenu(row);
  35964. }, 300);
  35965. var minWidthOfMenu = this.options.minWidth || MIN_WIDTH;
  35966. var filteredItems = (0, _array.arrayFilter)(this.menuItems, function (item) {
  35967. return (0, _utils.isItemHidden)(item, _this2.hot);
  35968. });
  35969. filteredItems = (0, _utils.filterSeparators)(filteredItems, _predefinedItems.SEPARATOR);
  35970. var settings = {
  35971. data: filteredItems,
  35972. colHeaders: false,
  35973. autoColumnSize: true,
  35974. modifyColWidth: function modifyColWidth(width) {
  35975. if ((0, _mixed.isDefined)(width) && width < minWidthOfMenu) {
  35976. return minWidthOfMenu;
  35977. }
  35978. return width;
  35979. },
  35980. autoRowSize: false,
  35981. readOnly: true,
  35982. copyPaste: false,
  35983. columns: [{
  35984. data: 'name',
  35985. renderer: function renderer(hot, TD, row, col, prop, value) {
  35986. return _this2.menuItemRenderer(hot, TD, row, col, prop, value);
  35987. }
  35988. }],
  35989. renderAllRows: true,
  35990. fragmentSelection: 'cell',
  35991. disableVisualSelection: 'area',
  35992. beforeKeyDown: function beforeKeyDown(event) {
  35993. return _this2.onBeforeKeyDown(event);
  35994. },
  35995. afterOnCellMouseOver: function afterOnCellMouseOver(event, coords, TD) {
  35996. if (_this2.isAllSubMenusClosed()) {
  35997. delayedOpenSubMenu(coords.row);
  35998. } else {
  35999. _this2.openSubMenu(coords.row);
  36000. }
  36001. },
  36002. rowHeights: function rowHeights(row) {
  36003. return filteredItems[row].name === _predefinedItems.SEPARATOR ? 1 : 23;
  36004. }
  36005. };
  36006. this.origOutsideClickDeselects = this.hot.getSettings().outsideClickDeselects;
  36007. this.hot.getSettings().outsideClickDeselects = false;
  36008. this.hotMenu = new _core2.default(this.container, settings);
  36009. this.hotMenu.addHook('afterInit', function () {
  36010. return _this2.onAfterInit();
  36011. });
  36012. this.hotMenu.addHook('afterSelection', function () {
  36013. return _this2.onAfterSelection.apply(_this2, arguments);
  36014. });
  36015. this.hotMenu.init();
  36016. this.hotMenu.listen();
  36017. this.blockMainTableCallbacks();
  36018. this.runLocalHooks('afterOpen');
  36019. }
  36020. /**
  36021. * Close menu.
  36022. *
  36023. * @param {Boolean} [closeParent=false] if `true` try to close parent menu if exists.
  36024. */
  36025. }, {
  36026. key: 'close',
  36027. value: function close() {
  36028. var closeParent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  36029. if (!this.isOpened()) {
  36030. return;
  36031. }
  36032. if (closeParent && this.parentMenu) {
  36033. this.parentMenu.close();
  36034. } else {
  36035. this.closeAllSubMenus();
  36036. this.container.style.display = 'none';
  36037. this.releaseMainTableCallbacks();
  36038. this.hotMenu.destroy();
  36039. this.hotMenu = null;
  36040. this.hot.getSettings().outsideClickDeselects = this.origOutsideClickDeselects;
  36041. this.runLocalHooks('afterClose');
  36042. if (this.parentMenu) {
  36043. this.parentMenu.hotMenu.listen();
  36044. }
  36045. }
  36046. }
  36047. /**
  36048. * Open sub menu at the provided row index.
  36049. *
  36050. * @param {Number} row Row index.
  36051. * @returns {Menu|Boolean} Returns created menu or `false` if no one menu was created.
  36052. */
  36053. }, {
  36054. key: 'openSubMenu',
  36055. value: function openSubMenu(row) {
  36056. if (!this.hotMenu) {
  36057. return false;
  36058. }
  36059. var cell = this.hotMenu.getCell(row, 0);
  36060. this.closeAllSubMenus();
  36061. if (!cell || !(0, _utils.hasSubMenu)(cell)) {
  36062. return false;
  36063. }
  36064. var dataItem = this.hotMenu.getSourceDataAtRow(row);
  36065. var subMenu = new Menu(this.hot, {
  36066. parent: this,
  36067. name: dataItem.name,
  36068. className: this.options.className,
  36069. keepInViewport: true
  36070. });
  36071. subMenu.setMenuItems(dataItem.submenu.items);
  36072. subMenu.open();
  36073. subMenu.setPosition(cell.getBoundingClientRect());
  36074. this.hotSubMenus[dataItem.key] = subMenu;
  36075. return subMenu;
  36076. }
  36077. /**
  36078. * Close sub menu at row index.
  36079. *
  36080. * @param {Number} row Row index.
  36081. */
  36082. }, {
  36083. key: 'closeSubMenu',
  36084. value: function closeSubMenu(row) {
  36085. var dataItem = this.hotMenu.getSourceDataAtRow(row);
  36086. var menus = this.hotSubMenus[dataItem.key];
  36087. if (menus) {
  36088. menus.destroy();
  36089. delete this.hotSubMenus[dataItem.key];
  36090. }
  36091. }
  36092. /**
  36093. * Close all opened sub menus.
  36094. */
  36095. }, {
  36096. key: 'closeAllSubMenus',
  36097. value: function closeAllSubMenus() {
  36098. var _this3 = this;
  36099. (0, _array.arrayEach)(this.hotMenu.getData(), function (value, row) {
  36100. return _this3.closeSubMenu(row);
  36101. });
  36102. }
  36103. /**
  36104. * Checks if all created and opened sub menus are closed.
  36105. *
  36106. * @returns {Boolean}
  36107. */
  36108. }, {
  36109. key: 'isAllSubMenusClosed',
  36110. value: function isAllSubMenusClosed() {
  36111. return Object.keys(this.hotSubMenus).length === 0;
  36112. }
  36113. /**
  36114. * Destroy instance.
  36115. */
  36116. }, {
  36117. key: 'destroy',
  36118. value: function destroy() {
  36119. this.clearLocalHooks();
  36120. this.close();
  36121. this.parentMenu = null;
  36122. this.eventManager.destroy();
  36123. }
  36124. /**
  36125. * Checks if menu was opened.
  36126. *
  36127. * @returns {Boolean} Returns `true` if menu was opened.
  36128. */
  36129. }, {
  36130. key: 'isOpened',
  36131. value: function isOpened() {
  36132. return this.hotMenu !== null;
  36133. }
  36134. /**
  36135. * Execute menu command.
  36136. *
  36137. * @param {Event} [event]
  36138. */
  36139. }, {
  36140. key: 'executeCommand',
  36141. value: function executeCommand(event) {
  36142. if (!this.isOpened() || !this.hotMenu.getSelectedLast()) {
  36143. return;
  36144. }
  36145. var selectedItem = this.hotMenu.getSourceDataAtRow(this.hotMenu.getSelectedLast()[0]);
  36146. this.runLocalHooks('select', selectedItem, event);
  36147. if (selectedItem.isCommand === false || selectedItem.name === _predefinedItems.SEPARATOR) {
  36148. return;
  36149. }
  36150. var selRanges = this.hot.getSelectedRange();
  36151. var normalizedSelection = selRanges ? (0, _utils.normalizeSelection)(selRanges) : [];
  36152. var autoClose = true;
  36153. // Don't close context menu if item is disabled or it has submenu
  36154. if (selectedItem.disabled === true || typeof selectedItem.disabled === 'function' && selectedItem.disabled.call(this.hot) === true || selectedItem.submenu) {
  36155. autoClose = false;
  36156. }
  36157. this.runLocalHooks('executeCommand', selectedItem.key, normalizedSelection, event);
  36158. if (this.isSubMenu()) {
  36159. this.parentMenu.runLocalHooks('executeCommand', selectedItem.key, normalizedSelection, event);
  36160. }
  36161. if (autoClose) {
  36162. this.close(true);
  36163. }
  36164. }
  36165. /**
  36166. * Set menu position based on dom event or based on literal object.
  36167. *
  36168. * @param {Event|Object} coords Event or literal Object with coordinates.
  36169. */
  36170. }, {
  36171. key: 'setPosition',
  36172. value: function setPosition(coords) {
  36173. var cursor = new _cursor2.default(coords);
  36174. if (this.options.keepInViewport) {
  36175. if (cursor.fitsBelow(this.container)) {
  36176. this.setPositionBelowCursor(cursor);
  36177. } else if (cursor.fitsAbove(this.container)) {
  36178. this.setPositionAboveCursor(cursor);
  36179. } else {
  36180. this.setPositionBelowCursor(cursor);
  36181. }
  36182. if (cursor.fitsOnRight(this.container)) {
  36183. this.setPositionOnRightOfCursor(cursor);
  36184. } else {
  36185. this.setPositionOnLeftOfCursor(cursor);
  36186. }
  36187. } else {
  36188. this.setPositionBelowCursor(cursor);
  36189. this.setPositionOnRightOfCursor(cursor);
  36190. }
  36191. }
  36192. /**
  36193. * Set menu position above cursor object.
  36194. *
  36195. * @param {Cursor} cursor `Cursor` object.
  36196. */
  36197. }, {
  36198. key: 'setPositionAboveCursor',
  36199. value: function setPositionAboveCursor(cursor) {
  36200. var top = this.offset.above + cursor.top - this.container.offsetHeight;
  36201. if (this.isSubMenu()) {
  36202. top = cursor.top + cursor.cellHeight - this.container.offsetHeight + 3;
  36203. }
  36204. this.container.style.top = top + 'px';
  36205. }
  36206. /**
  36207. * Set menu position below cursor object.
  36208. *
  36209. * @param {Cursor} cursor `Cursor` object.
  36210. */
  36211. }, {
  36212. key: 'setPositionBelowCursor',
  36213. value: function setPositionBelowCursor(cursor) {
  36214. var top = this.offset.below + cursor.top;
  36215. if (this.isSubMenu()) {
  36216. top = cursor.top - 1;
  36217. }
  36218. this.container.style.top = top + 'px';
  36219. }
  36220. /**
  36221. * Set menu position on the right of cursor object.
  36222. *
  36223. * @param {Cursor} cursor `Cursor` object.
  36224. */
  36225. }, {
  36226. key: 'setPositionOnRightOfCursor',
  36227. value: function setPositionOnRightOfCursor(cursor) {
  36228. var left = void 0;
  36229. if (this.isSubMenu()) {
  36230. left = 1 + cursor.left + cursor.cellWidth;
  36231. } else {
  36232. left = this.offset.right + 1 + cursor.left;
  36233. }
  36234. this.container.style.left = left + 'px';
  36235. }
  36236. /**
  36237. * Set menu position on the left of cursor object.
  36238. *
  36239. * @param {Cursor} cursor `Cursor` object.
  36240. */
  36241. }, {
  36242. key: 'setPositionOnLeftOfCursor',
  36243. value: function setPositionOnLeftOfCursor(cursor) {
  36244. var left = this.offset.left + cursor.left - this.container.offsetWidth + (0, _element.getScrollbarWidth)() + 4;
  36245. this.container.style.left = left + 'px';
  36246. }
  36247. /**
  36248. * Select first cell in opened menu.
  36249. */
  36250. }, {
  36251. key: 'selectFirstCell',
  36252. value: function selectFirstCell() {
  36253. var cell = this.hotMenu.getCell(0, 0);
  36254. if ((0, _utils.isSeparator)(cell) || (0, _utils.isDisabled)(cell) || (0, _utils.isSelectionDisabled)(cell)) {
  36255. this.selectNextCell(0, 0);
  36256. } else {
  36257. this.hotMenu.selectCell(0, 0);
  36258. }
  36259. }
  36260. /**
  36261. * Select last cell in opened menu.
  36262. */
  36263. }, {
  36264. key: 'selectLastCell',
  36265. value: function selectLastCell() {
  36266. var lastRow = this.hotMenu.countRows() - 1;
  36267. var cell = this.hotMenu.getCell(lastRow, 0);
  36268. if ((0, _utils.isSeparator)(cell) || (0, _utils.isDisabled)(cell) || (0, _utils.isSelectionDisabled)(cell)) {
  36269. this.selectPrevCell(lastRow, 0);
  36270. } else {
  36271. this.hotMenu.selectCell(lastRow, 0);
  36272. }
  36273. }
  36274. /**
  36275. * Select next cell in opened menu.
  36276. *
  36277. * @param {Number} row Row index.
  36278. * @param {Number} col Column index.
  36279. */
  36280. }, {
  36281. key: 'selectNextCell',
  36282. value: function selectNextCell(row, col) {
  36283. var nextRow = row + 1;
  36284. var cell = nextRow < this.hotMenu.countRows() ? this.hotMenu.getCell(nextRow, col) : null;
  36285. if (!cell) {
  36286. return;
  36287. }
  36288. if ((0, _utils.isSeparator)(cell) || (0, _utils.isDisabled)(cell) || (0, _utils.isSelectionDisabled)(cell)) {
  36289. this.selectNextCell(nextRow, col);
  36290. } else {
  36291. this.hotMenu.selectCell(nextRow, col);
  36292. }
  36293. }
  36294. /**
  36295. * Select previous cell in opened menu.
  36296. *
  36297. * @param {Number} row Row index.
  36298. * @param {Number} col Column index.
  36299. */
  36300. }, {
  36301. key: 'selectPrevCell',
  36302. value: function selectPrevCell(row, col) {
  36303. var prevRow = row - 1;
  36304. var cell = prevRow >= 0 ? this.hotMenu.getCell(prevRow, col) : null;
  36305. if (!cell) {
  36306. return;
  36307. }
  36308. if ((0, _utils.isSeparator)(cell) || (0, _utils.isDisabled)(cell) || (0, _utils.isSelectionDisabled)(cell)) {
  36309. this.selectPrevCell(prevRow, col);
  36310. } else {
  36311. this.hotMenu.selectCell(prevRow, col);
  36312. }
  36313. }
  36314. /**
  36315. * Menu item renderer.
  36316. *
  36317. * @private
  36318. */
  36319. }, {
  36320. key: 'menuItemRenderer',
  36321. value: function menuItemRenderer(hot, TD, row, col, prop, value) {
  36322. var _this4 = this;
  36323. var item = hot.getSourceDataAtRow(row);
  36324. var wrapper = document.createElement('div');
  36325. var isSubMenu = function isSubMenu(item) {
  36326. return (0, _object.hasOwnProperty)(item, 'submenu');
  36327. };
  36328. var itemIsSeparator = function itemIsSeparator(item) {
  36329. return new RegExp(_predefinedItems.SEPARATOR, 'i').test(item.name);
  36330. };
  36331. var itemIsDisabled = function itemIsDisabled(item) {
  36332. return item.disabled === true || typeof item.disabled == 'function' && item.disabled.call(_this4.hot) === true;
  36333. };
  36334. var itemIsSelectionDisabled = function itemIsSelectionDisabled(item) {
  36335. return item.disableSelection;
  36336. };
  36337. if (typeof value === 'function') {
  36338. value = value.call(this.hot);
  36339. }
  36340. (0, _element.empty)(TD);
  36341. (0, _element.addClass)(wrapper, 'htItemWrapper');
  36342. TD.appendChild(wrapper);
  36343. if (itemIsSeparator(item)) {
  36344. (0, _element.addClass)(TD, 'htSeparator');
  36345. } else if (typeof item.renderer === 'function') {
  36346. (0, _element.addClass)(TD, 'htCustomMenuRenderer');
  36347. TD.appendChild(item.renderer(hot, wrapper, row, col, prop, value));
  36348. } else {
  36349. (0, _element.fastInnerHTML)(wrapper, value);
  36350. }
  36351. if (itemIsDisabled(item)) {
  36352. (0, _element.addClass)(TD, 'htDisabled');
  36353. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  36354. return hot.deselectCell();
  36355. });
  36356. } else if (itemIsSelectionDisabled(item)) {
  36357. (0, _element.addClass)(TD, 'htSelectionDisabled');
  36358. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  36359. return hot.deselectCell();
  36360. });
  36361. } else if (isSubMenu(item)) {
  36362. (0, _element.addClass)(TD, 'htSubmenu');
  36363. if (itemIsSelectionDisabled(item)) {
  36364. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  36365. return hot.deselectCell();
  36366. });
  36367. } else {
  36368. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  36369. return hot.selectCell(row, col, void 0, void 0, false, false);
  36370. });
  36371. }
  36372. } else {
  36373. (0, _element.removeClass)(TD, 'htSubmenu');
  36374. (0, _element.removeClass)(TD, 'htDisabled');
  36375. if (itemIsSelectionDisabled(item)) {
  36376. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  36377. return hot.deselectCell();
  36378. });
  36379. } else {
  36380. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  36381. return hot.selectCell(row, col, void 0, void 0, false, false);
  36382. });
  36383. }
  36384. }
  36385. }
  36386. /**
  36387. * Create container/wrapper for handsontable.
  36388. *
  36389. * @private
  36390. * @param {String} [name] Class name.
  36391. * @returns {HTMLElement}
  36392. */
  36393. }, {
  36394. key: 'createContainer',
  36395. value: function createContainer() {
  36396. var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  36397. var container = void 0;
  36398. if (name) {
  36399. if ((0, _function.isFunction)(name)) {
  36400. name = name.call(this.hot);
  36401. if (name === null || (0, _mixed.isUndefined)(name)) {
  36402. name = '';
  36403. } else {
  36404. name = name.toString();
  36405. }
  36406. }
  36407. name = name.replace(/[^A-z0-9]/g, '_');
  36408. name = this.options.className + 'Sub_' + name;
  36409. container = document.querySelector('.' + this.options.className + '.' + name);
  36410. } else {
  36411. container = document.querySelector('.' + this.options.className);
  36412. }
  36413. if (!container) {
  36414. container = document.createElement('div');
  36415. (0, _element.addClass)(container, 'htMenu ' + this.options.className);
  36416. if (name) {
  36417. (0, _element.addClass)(container, name);
  36418. }
  36419. document.getElementsByTagName('body')[0].appendChild(container);
  36420. }
  36421. return container;
  36422. }
  36423. /**
  36424. * @private
  36425. */
  36426. }, {
  36427. key: 'blockMainTableCallbacks',
  36428. value: function blockMainTableCallbacks() {
  36429. this._afterScrollCallback = function () {};
  36430. this.hot.addHook('afterScrollVertically', this._afterScrollCallback);
  36431. this.hot.addHook('afterScrollHorizontally', this._afterScrollCallback);
  36432. }
  36433. /**
  36434. * @private
  36435. */
  36436. }, {
  36437. key: 'releaseMainTableCallbacks',
  36438. value: function releaseMainTableCallbacks() {
  36439. if (this._afterScrollCallback) {
  36440. this.hot.removeHook('afterScrollVertically', this._afterScrollCallback);
  36441. this.hot.removeHook('afterScrollHorizontally', this._afterScrollCallback);
  36442. this._afterScrollCallback = null;
  36443. }
  36444. }
  36445. /**
  36446. * On before key down listener.
  36447. *
  36448. * @private
  36449. * @param {Event} event
  36450. */
  36451. }, {
  36452. key: 'onBeforeKeyDown',
  36453. value: function onBeforeKeyDown(event) {
  36454. var selection = this.hotMenu.getSelectedLast();
  36455. var stopEvent = false;
  36456. this.keyEvent = true;
  36457. switch (event.keyCode) {
  36458. case _unicode.KEY_CODES.ESCAPE:
  36459. this.close();
  36460. stopEvent = true;
  36461. break;
  36462. case _unicode.KEY_CODES.ENTER:
  36463. if (selection) {
  36464. if (this.hotMenu.getSourceDataAtRow(selection[0]).submenu) {
  36465. stopEvent = true;
  36466. } else {
  36467. this.executeCommand(event);
  36468. this.close(true);
  36469. }
  36470. }
  36471. break;
  36472. case _unicode.KEY_CODES.ARROW_DOWN:
  36473. if (selection) {
  36474. this.selectNextCell(selection[0], selection[1]);
  36475. } else {
  36476. this.selectFirstCell();
  36477. }
  36478. stopEvent = true;
  36479. break;
  36480. case _unicode.KEY_CODES.ARROW_UP:
  36481. if (selection) {
  36482. this.selectPrevCell(selection[0], selection[1]);
  36483. } else {
  36484. this.selectLastCell();
  36485. }
  36486. stopEvent = true;
  36487. break;
  36488. case _unicode.KEY_CODES.ARROW_RIGHT:
  36489. if (selection) {
  36490. var menu = this.openSubMenu(selection[0]);
  36491. if (menu) {
  36492. menu.selectFirstCell();
  36493. }
  36494. }
  36495. stopEvent = true;
  36496. break;
  36497. case _unicode.KEY_CODES.ARROW_LEFT:
  36498. if (selection && this.isSubMenu()) {
  36499. this.close();
  36500. if (this.parentMenu) {
  36501. this.parentMenu.hotMenu.listen();
  36502. }
  36503. stopEvent = true;
  36504. }
  36505. break;
  36506. default:
  36507. break;
  36508. }
  36509. if (stopEvent) {
  36510. event.preventDefault();
  36511. (0, _event.stopImmediatePropagation)(event);
  36512. }
  36513. this.keyEvent = false;
  36514. }
  36515. /**
  36516. * On after init listener.
  36517. *
  36518. * @private
  36519. */
  36520. }, {
  36521. key: 'onAfterInit',
  36522. value: function onAfterInit() {
  36523. var data = this.hotMenu.getSettings().data;
  36524. var hiderStyle = this.hotMenu.view.wt.wtTable.hider.style;
  36525. var holderStyle = this.hotMenu.view.wt.wtTable.holder.style;
  36526. var currentHiderWidth = parseInt(hiderStyle.width, 10);
  36527. var realHeight = (0, _array.arrayReduce)(data, function (accumulator, value) {
  36528. return accumulator + (value.name === _predefinedItems.SEPARATOR ? 1 : 26);
  36529. }, 0);
  36530. holderStyle.width = currentHiderWidth + 22 + 'px';
  36531. holderStyle.height = realHeight + 4 + 'px';
  36532. hiderStyle.height = holderStyle.height;
  36533. }
  36534. /**
  36535. * On after selection listener.
  36536. *
  36537. * @param {Number} r Selection start row index.
  36538. * @param {Number} c Selection start column index.
  36539. * @param {Number} r2 Selection end row index.
  36540. * @param {Number} c2 Selection end column index.
  36541. * @param {Object} preventScrolling Object with `value` property where its value change will be observed.
  36542. * @param {Number} selectionLayerLevel The number which indicates what selection layer is currently modified.
  36543. */
  36544. }, {
  36545. key: 'onAfterSelection',
  36546. value: function onAfterSelection(r, c, r2, c2, preventScrolling) {
  36547. if (this.keyEvent === false) {
  36548. preventScrolling.value = true;
  36549. }
  36550. }
  36551. /**
  36552. * Document mouse down listener.
  36553. *
  36554. * @private
  36555. * @param {Event} event
  36556. */
  36557. }, {
  36558. key: 'onDocumentMouseDown',
  36559. value: function onDocumentMouseDown(event) {
  36560. if (!this.isOpened()) {
  36561. return;
  36562. }
  36563. if (this.container && (0, _element.isChildOf)(event.target, this.container)) {
  36564. this.executeCommand(event);
  36565. }
  36566. // Close menu when clicked element is not belongs to menu itself
  36567. if (this.options.standalone && this.hotMenu && !(0, _element.isChildOf)(event.target, this.hotMenu.rootElement)) {
  36568. this.close(true);
  36569. // Automatically close menu when clicked element is not belongs to menu or submenu (not necessarily to itself)
  36570. } else if ((this.isAllSubMenusClosed() || this.isSubMenu()) && !(0, _element.isChildOf)(event.target, '.htMenu') && (0, _element.isChildOf)(event.target, document)) {
  36571. this.close(true);
  36572. }
  36573. }
  36574. }]);
  36575. return Menu;
  36576. }();
  36577. (0, _object.mixin)(Menu, _localHooks2.default);
  36578. exports.default = Menu;
  36579. /***/ }),
  36580. /* 312 */
  36581. /***/ (function(module, exports, __webpack_require__) {
  36582. "use strict";
  36583. exports.__esModule = true;
  36584. 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; }; }();
  36585. var _element = __webpack_require__(0);
  36586. var _event = __webpack_require__(12);
  36587. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  36588. /**
  36589. * Helper class for checking if element will fit at the desired side of cursor.
  36590. *
  36591. * @class Cursor
  36592. * @plugin ContextMenu
  36593. */
  36594. var Cursor = function () {
  36595. function Cursor(object) {
  36596. _classCallCheck(this, Cursor);
  36597. var windowScrollTop = (0, _element.getWindowScrollTop)();
  36598. var windowScrollLeft = (0, _element.getWindowScrollLeft)();
  36599. var top = void 0,
  36600. topRelative = void 0;
  36601. var left = void 0,
  36602. leftRelative = void 0;
  36603. var cellHeight = void 0,
  36604. cellWidth = void 0;
  36605. this.type = this.getSourceType(object);
  36606. if (this.type === 'literal') {
  36607. top = parseInt(object.top, 10);
  36608. left = parseInt(object.left, 10);
  36609. cellHeight = object.height || 0;
  36610. cellWidth = object.width || 0;
  36611. topRelative = top;
  36612. leftRelative = left;
  36613. top += windowScrollTop;
  36614. left += windowScrollLeft;
  36615. } else if (this.type === 'event') {
  36616. top = parseInt((0, _event.pageY)(object), 10);
  36617. left = parseInt((0, _event.pageX)(object), 10);
  36618. cellHeight = object.target.clientHeight;
  36619. cellWidth = object.target.clientWidth;
  36620. topRelative = top - windowScrollTop;
  36621. leftRelative = left - windowScrollLeft;
  36622. }
  36623. this.top = top;
  36624. this.topRelative = topRelative;
  36625. this.left = left;
  36626. this.leftRelative = leftRelative;
  36627. this.scrollTop = windowScrollTop;
  36628. this.scrollLeft = windowScrollLeft;
  36629. this.cellHeight = cellHeight;
  36630. this.cellWidth = cellWidth;
  36631. }
  36632. /**
  36633. * Get source type name.
  36634. *
  36635. * @param {*} object Event or Object with coordinates.
  36636. * @returns {String} Returns one of this values: `'literal'`, `'event'`.
  36637. */
  36638. _createClass(Cursor, [{
  36639. key: 'getSourceType',
  36640. value: function getSourceType(object) {
  36641. var type = 'literal';
  36642. if (object instanceof Event) {
  36643. type = 'event';
  36644. }
  36645. return type;
  36646. }
  36647. /**
  36648. * Checks if element can be placed above the cursor.
  36649. *
  36650. * @param {HTMLElement} element Element to check if it's size will fit above the cursor.
  36651. * @returns {Boolean}
  36652. */
  36653. }, {
  36654. key: 'fitsAbove',
  36655. value: function fitsAbove(element) {
  36656. return this.topRelative >= element.offsetHeight;
  36657. }
  36658. /**
  36659. * Checks if element can be placed below the cursor.
  36660. *
  36661. * @param {HTMLElement} element Element to check if it's size will fit below the cursor.
  36662. * @param {Number} [viewportHeight] The viewport height.
  36663. * @returns {Boolean}
  36664. */
  36665. }, {
  36666. key: 'fitsBelow',
  36667. value: function fitsBelow(element) {
  36668. var viewportHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.innerHeight;
  36669. return this.topRelative + element.offsetHeight <= viewportHeight;
  36670. }
  36671. /**
  36672. * Checks if element can be placed on the right of the cursor.
  36673. *
  36674. * @param {HTMLElement} element Element to check if it's size will fit on the right of the cursor.
  36675. * @param {Number} [viewportWidth] The viewport width.
  36676. * @returns {Boolean}
  36677. */
  36678. }, {
  36679. key: 'fitsOnRight',
  36680. value: function fitsOnRight(element) {
  36681. var viewportWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.innerWidth;
  36682. return this.leftRelative + this.cellWidth + element.offsetWidth <= viewportWidth;
  36683. }
  36684. /**
  36685. * Checks if element can be placed on the left on the cursor.
  36686. *
  36687. * @param {HTMLElement} element Element to check if it's size will fit on the left of the cursor.
  36688. * @returns {Boolean}
  36689. */
  36690. }, {
  36691. key: 'fitsOnLeft',
  36692. value: function fitsOnLeft(element) {
  36693. return this.leftRelative >= element.offsetWidth;
  36694. }
  36695. }]);
  36696. return Cursor;
  36697. }();
  36698. exports.default = Cursor;
  36699. /***/ }),
  36700. /* 313 */
  36701. /***/ (function(module, exports) {
  36702. // removed by extract-text-webpack-plugin
  36703. /***/ }),
  36704. /* 314 */
  36705. /***/ (function(module, exports, __webpack_require__) {
  36706. "use strict";
  36707. exports.__esModule = true;
  36708. 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; };
  36709. 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; }; }();
  36710. 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); } };
  36711. var _base = __webpack_require__(10);
  36712. var _base2 = _interopRequireDefault(_base);
  36713. var _pluginHooks = __webpack_require__(15);
  36714. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  36715. var _SheetClip = __webpack_require__(191);
  36716. var _SheetClip2 = _interopRequireDefault(_SheetClip);
  36717. var _src = __webpack_require__(4);
  36718. var _element = __webpack_require__(0);
  36719. var _array = __webpack_require__(1);
  36720. var _number = __webpack_require__(5);
  36721. var _plugins = __webpack_require__(8);
  36722. var _textarea = __webpack_require__(315);
  36723. var _textarea2 = _interopRequireDefault(_textarea);
  36724. var _copy = __webpack_require__(316);
  36725. var _copy2 = _interopRequireDefault(_copy);
  36726. var _cut = __webpack_require__(317);
  36727. var _cut2 = _interopRequireDefault(_cut);
  36728. var _eventManager = __webpack_require__(6);
  36729. var _eventManager2 = _interopRequireDefault(_eventManager);
  36730. var _pasteEvent = __webpack_require__(318);
  36731. var _pasteEvent2 = _interopRequireDefault(_pasteEvent);
  36732. __webpack_require__(320);
  36733. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  36734. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  36735. 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; }
  36736. 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; }
  36737. _pluginHooks2.default.getSingleton().register('afterCopyLimit');
  36738. _pluginHooks2.default.getSingleton().register('modifyCopyableRange');
  36739. _pluginHooks2.default.getSingleton().register('beforeCut');
  36740. _pluginHooks2.default.getSingleton().register('afterCut');
  36741. _pluginHooks2.default.getSingleton().register('beforePaste');
  36742. _pluginHooks2.default.getSingleton().register('afterPaste');
  36743. _pluginHooks2.default.getSingleton().register('beforeCopy');
  36744. _pluginHooks2.default.getSingleton().register('afterCopy');
  36745. var ROWS_LIMIT = 1000;
  36746. var COLUMNS_LIMIT = 1000;
  36747. var privatePool = new WeakMap();
  36748. /**
  36749. * @description
  36750. * This plugin enables the copy/paste functionality in the Handsontable.
  36751. *
  36752. * @example
  36753. * ```js
  36754. * ...
  36755. * copyPaste: true,
  36756. * ...
  36757. * ```
  36758. * @class CopyPaste
  36759. * @plugin CopyPaste
  36760. */
  36761. var CopyPaste = function (_BasePlugin) {
  36762. _inherits(CopyPaste, _BasePlugin);
  36763. function CopyPaste(hotInstance) {
  36764. _classCallCheck(this, CopyPaste);
  36765. /**
  36766. * Event manager
  36767. *
  36768. * @type {EventManager}
  36769. */
  36770. var _this = _possibleConstructorReturn(this, (CopyPaste.__proto__ || Object.getPrototypeOf(CopyPaste)).call(this, hotInstance));
  36771. _this.eventManager = new _eventManager2.default(_this);
  36772. /**
  36773. * Maximum number of columns than can be copied to clipboard using <kbd>CTRL</kbd> + <kbd>C</kbd>.
  36774. *
  36775. * @private
  36776. * @type {Number}
  36777. * @default 1000
  36778. */
  36779. _this.columnsLimit = COLUMNS_LIMIT;
  36780. /**
  36781. * Ranges of the cells coordinates, which should be used to copy/cut/paste actions.
  36782. *
  36783. * @private
  36784. * @type {Array}
  36785. */
  36786. _this.copyableRanges = [];
  36787. /**
  36788. * Defines paste (<kbd>CTRL</kbd> + <kbd>V</kbd>) behavior.
  36789. * * Default value `"overwrite"` will paste clipboard value over current selection.
  36790. * * When set to `"shift_down"`, clipboard data will be pasted in place of current selection, while all selected cells are moved down.
  36791. * * When set to `"shift_right"`, clipboard data will be pasted in place of current selection, while all selected cells are moved right.
  36792. *
  36793. * @private
  36794. * @type {String}
  36795. * @default 'overwrite'
  36796. */
  36797. _this.pasteMode = 'overwrite';
  36798. /**
  36799. * Maximum number of rows than can be copied to clipboard using <kbd>CTRL</kbd> + <kbd>C</kbd>.
  36800. *
  36801. * @private
  36802. * @type {Number}
  36803. * @default 1000
  36804. */
  36805. _this.rowsLimit = ROWS_LIMIT;
  36806. /**
  36807. * The `textarea` element which is necessary to process copying, cutting off and pasting.
  36808. *
  36809. * @private
  36810. * @type {HTMLElement}
  36811. * @default undefined
  36812. */
  36813. _this.textarea = void 0;
  36814. privatePool.set(_this, {
  36815. isTriggeredByCopy: false,
  36816. isTriggeredByCut: false,
  36817. isBeginEditing: false,
  36818. isFragmentSelectionEnabled: false
  36819. });
  36820. return _this;
  36821. }
  36822. /**
  36823. * Check if plugin is enabled.
  36824. *
  36825. * @returns {Boolean}
  36826. */
  36827. _createClass(CopyPaste, [{
  36828. key: 'isEnabled',
  36829. value: function isEnabled() {
  36830. return !!this.hot.getSettings().copyPaste;
  36831. }
  36832. /**
  36833. * Enable the plugin.
  36834. */
  36835. }, {
  36836. key: 'enablePlugin',
  36837. value: function enablePlugin() {
  36838. var _this2 = this;
  36839. if (this.enabled) {
  36840. return;
  36841. }
  36842. var settings = this.hot.getSettings();
  36843. var priv = privatePool.get(this);
  36844. this.textarea = _textarea2.default.getSingleton();
  36845. priv.isFragmentSelectionEnabled = settings.fragmentSelection;
  36846. if (_typeof(settings.copyPaste) === 'object') {
  36847. this.pasteMode = settings.copyPaste.pasteMode || this.pasteMode;
  36848. this.rowsLimit = settings.copyPaste.rowsLimit || this.rowsLimit;
  36849. this.columnsLimit = settings.copyPaste.columnsLimit || this.columnsLimit;
  36850. }
  36851. this.addHook('afterContextMenuDefaultOptions', function (options) {
  36852. return _this2.onAfterContextMenuDefaultOptions(options);
  36853. });
  36854. this.addHook('afterSelectionEnd', function () {
  36855. return _this2.onAfterSelectionEnd();
  36856. });
  36857. this.registerEvents();
  36858. _get(CopyPaste.prototype.__proto__ || Object.getPrototypeOf(CopyPaste.prototype), 'enablePlugin', this).call(this);
  36859. }
  36860. /**
  36861. * Updates the plugin to use the latest options you have specified.
  36862. */
  36863. }, {
  36864. key: 'updatePlugin',
  36865. value: function updatePlugin() {
  36866. this.disablePlugin();
  36867. this.enablePlugin();
  36868. _get(CopyPaste.prototype.__proto__ || Object.getPrototypeOf(CopyPaste.prototype), 'updatePlugin', this).call(this);
  36869. }
  36870. /**
  36871. * Disable plugin for this Handsontable instance.
  36872. */
  36873. }, {
  36874. key: 'disablePlugin',
  36875. value: function disablePlugin() {
  36876. if (this.textarea) {
  36877. this.textarea.destroy();
  36878. }
  36879. _get(CopyPaste.prototype.__proto__ || Object.getPrototypeOf(CopyPaste.prototype), 'disablePlugin', this).call(this);
  36880. }
  36881. /**
  36882. * Prepares copyable text from the cells selection in the invisible textarea.
  36883. *
  36884. * @function setCopyable
  36885. * @memberof CopyPaste#
  36886. */
  36887. }, {
  36888. key: 'setCopyableText',
  36889. value: function setCopyableText() {
  36890. var selRange = this.hot.getSelectedRangeLast();
  36891. if (!selRange) {
  36892. return;
  36893. }
  36894. var topLeft = selRange.getTopLeftCorner();
  36895. var bottomRight = selRange.getBottomRightCorner();
  36896. var startRow = topLeft.row;
  36897. var startCol = topLeft.col;
  36898. var endRow = bottomRight.row;
  36899. var endCol = bottomRight.col;
  36900. var finalEndRow = Math.min(endRow, startRow + this.rowsLimit - 1);
  36901. var finalEndCol = Math.min(endCol, startCol + this.columnsLimit - 1);
  36902. this.copyableRanges.length = 0;
  36903. this.copyableRanges.push({
  36904. startRow: startRow,
  36905. startCol: startCol,
  36906. endRow: finalEndRow,
  36907. endCol: finalEndCol
  36908. });
  36909. this.copyableRanges = this.hot.runHooks('modifyCopyableRange', this.copyableRanges);
  36910. if (endRow !== finalEndRow || endCol !== finalEndCol) {
  36911. this.hot.runHooks('afterCopyLimit', endRow - startRow + 1, endCol - startCol + 1, this.rowsLimit, this.columnsLimit);
  36912. }
  36913. }
  36914. /**
  36915. * Create copyable text releated to range objects.
  36916. *
  36917. * @since 0.19.0
  36918. * @param {Array} ranges Array of Objects with properties `startRow`, `endRow`, `startCol` and `endCol`.
  36919. * @returns {String} Returns string which will be copied into clipboard.
  36920. */
  36921. }, {
  36922. key: 'getRangedCopyableData',
  36923. value: function getRangedCopyableData(ranges) {
  36924. var _this3 = this;
  36925. var dataSet = [];
  36926. var copyableRows = [];
  36927. var copyableColumns = [];
  36928. // Count all copyable rows and columns
  36929. (0, _array.arrayEach)(ranges, function (range) {
  36930. (0, _number.rangeEach)(range.startRow, range.endRow, function (row) {
  36931. if (copyableRows.indexOf(row) === -1) {
  36932. copyableRows.push(row);
  36933. }
  36934. });
  36935. (0, _number.rangeEach)(range.startCol, range.endCol, function (column) {
  36936. if (copyableColumns.indexOf(column) === -1) {
  36937. copyableColumns.push(column);
  36938. }
  36939. });
  36940. });
  36941. // Concat all rows and columns data defined in ranges into one copyable string
  36942. (0, _array.arrayEach)(copyableRows, function (row) {
  36943. var rowSet = [];
  36944. (0, _array.arrayEach)(copyableColumns, function (column) {
  36945. rowSet.push(_this3.hot.getCopyableData(row, column));
  36946. });
  36947. dataSet.push(rowSet);
  36948. });
  36949. return _SheetClip2.default.stringify(dataSet);
  36950. }
  36951. /**
  36952. * Create copyable text releated to range objects.
  36953. *
  36954. * @since 0.31.1
  36955. * @param {Array} ranges Array of Objects with properties `startRow`, `startCol`, `endRow` and `endCol`.
  36956. * @returns {Array} Returns array of arrays which will be copied into clipboard.
  36957. */
  36958. }, {
  36959. key: 'getRangedData',
  36960. value: function getRangedData(ranges) {
  36961. var _this4 = this;
  36962. var dataSet = [];
  36963. var copyableRows = [];
  36964. var copyableColumns = [];
  36965. // Count all copyable rows and columns
  36966. (0, _array.arrayEach)(ranges, function (range) {
  36967. (0, _number.rangeEach)(range.startRow, range.endRow, function (row) {
  36968. if (copyableRows.indexOf(row) === -1) {
  36969. copyableRows.push(row);
  36970. }
  36971. });
  36972. (0, _number.rangeEach)(range.startCol, range.endCol, function (column) {
  36973. if (copyableColumns.indexOf(column) === -1) {
  36974. copyableColumns.push(column);
  36975. }
  36976. });
  36977. });
  36978. // Concat all rows and columns data defined in ranges into one copyable string
  36979. (0, _array.arrayEach)(copyableRows, function (row) {
  36980. var rowSet = [];
  36981. (0, _array.arrayEach)(copyableColumns, function (column) {
  36982. rowSet.push(_this4.hot.getCopyableData(row, column));
  36983. });
  36984. dataSet.push(rowSet);
  36985. });
  36986. return dataSet;
  36987. }
  36988. /**
  36989. * Copy action.
  36990. */
  36991. }, {
  36992. key: 'copy',
  36993. value: function copy() {
  36994. var priv = privatePool.get(this);
  36995. priv.isTriggeredByCopy = true;
  36996. this.textarea.select();
  36997. document.execCommand('copy');
  36998. }
  36999. /**
  37000. * Cut action.
  37001. */
  37002. }, {
  37003. key: 'cut',
  37004. value: function cut() {
  37005. var priv = privatePool.get(this);
  37006. priv.isTriggeredByCut = true;
  37007. this.textarea.select();
  37008. document.execCommand('cut');
  37009. }
  37010. /**
  37011. * Simulated paste action.
  37012. *
  37013. * @param {String} [value=''] New value, which should be `pasted`.
  37014. */
  37015. }, {
  37016. key: 'paste',
  37017. value: function paste() {
  37018. var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  37019. var pasteData = new _pasteEvent2.default();
  37020. pasteData.clipboardData.setData('text/plain', value);
  37021. this.onPaste(pasteData);
  37022. }
  37023. /**
  37024. * Register event listeners.
  37025. *
  37026. * @private
  37027. */
  37028. }, {
  37029. key: 'registerEvents',
  37030. value: function registerEvents() {
  37031. var _this5 = this;
  37032. this.eventManager.addEventListener(this.textarea.element, 'paste', function (event) {
  37033. return _this5.onPaste(event);
  37034. });
  37035. this.eventManager.addEventListener(this.textarea.element, 'cut', function (event) {
  37036. return _this5.onCut(event);
  37037. });
  37038. this.eventManager.addEventListener(this.textarea.element, 'copy', function (event) {
  37039. return _this5.onCopy(event);
  37040. });
  37041. }
  37042. /**
  37043. * `copy` event callback on textarea element.
  37044. *
  37045. * @param {Event} event ClipboardEvent.
  37046. * @private
  37047. */
  37048. }, {
  37049. key: 'onCopy',
  37050. value: function onCopy(event) {
  37051. var priv = privatePool.get(this);
  37052. if (!this.hot.isListening() && !priv.isTriggeredByCopy) {
  37053. return;
  37054. }
  37055. this.setCopyableText();
  37056. priv.isTriggeredByCopy = false;
  37057. var rangedData = this.getRangedData(this.copyableRanges);
  37058. var allowCopying = !!this.hot.runHooks('beforeCopy', rangedData, this.copyableRanges);
  37059. var value = '';
  37060. if (allowCopying) {
  37061. value = _SheetClip2.default.stringify(rangedData);
  37062. if (event && event.clipboardData) {
  37063. event.clipboardData.setData('text/plain', value);
  37064. } else if (typeof ClipboardEvent === 'undefined') {
  37065. window.clipboardData.setData('Text', value);
  37066. }
  37067. this.hot.runHooks('afterCopy', rangedData, this.copyableRanges);
  37068. }
  37069. event.preventDefault();
  37070. }
  37071. /**
  37072. * `cut` event callback on textarea element.
  37073. *
  37074. * @param {Event} event ClipboardEvent.
  37075. * @private
  37076. */
  37077. }, {
  37078. key: 'onCut',
  37079. value: function onCut(event) {
  37080. var priv = privatePool.get(this);
  37081. if (!this.hot.isListening() && !priv.isTriggeredByCut) {
  37082. return;
  37083. }
  37084. this.setCopyableText();
  37085. priv.isTriggeredByCut = false;
  37086. var rangedData = this.getRangedData(this.copyableRanges);
  37087. var allowCuttingOut = !!this.hot.runHooks('beforeCut', rangedData, this.copyableRanges);
  37088. var value = void 0;
  37089. if (allowCuttingOut) {
  37090. value = _SheetClip2.default.stringify(rangedData);
  37091. if (event && event.clipboardData) {
  37092. event.clipboardData.setData('text/plain', value);
  37093. } else if (typeof ClipboardEvent === 'undefined') {
  37094. window.clipboardData.setData('Text', value);
  37095. }
  37096. this.hot.emptySelectedCells();
  37097. this.hot.runHooks('afterCut', rangedData, this.copyableRanges);
  37098. }
  37099. event.preventDefault();
  37100. }
  37101. /**
  37102. * `paste` event callback on textarea element.
  37103. *
  37104. * @param {Event} event ClipboardEvent or pseudo ClipboardEvent, if paste was called manually.
  37105. * @private
  37106. */
  37107. }, {
  37108. key: 'onPaste',
  37109. value: function onPaste(event) {
  37110. var _this6 = this;
  37111. if (!this.hot.isListening()) {
  37112. return;
  37113. }
  37114. if (event && event.preventDefault) {
  37115. event.preventDefault();
  37116. }
  37117. var inputArray = void 0;
  37118. if (event && typeof event.clipboardData !== 'undefined') {
  37119. this.textarea.setValue(event.clipboardData.getData('text/plain'));
  37120. } else if (typeof ClipboardEvent === 'undefined' && typeof window.clipboardData !== 'undefined') {
  37121. this.textarea.setValue(window.clipboardData.getData('Text'));
  37122. }
  37123. inputArray = _SheetClip2.default.parse(this.textarea.getValue());
  37124. this.textarea.setValue(' ');
  37125. if (inputArray.length === 0) {
  37126. return;
  37127. }
  37128. var allowPasting = !!this.hot.runHooks('beforePaste', inputArray, this.copyableRanges);
  37129. if (!allowPasting) {
  37130. return;
  37131. }
  37132. var selected = this.hot.getSelectedLast();
  37133. var coordsFrom = new _src.CellCoords(selected[0], selected[1]);
  37134. var coordsTo = new _src.CellCoords(selected[2], selected[3]);
  37135. var cellRange = new _src.CellRange(coordsFrom, coordsFrom, coordsTo);
  37136. var topLeftCorner = cellRange.getTopLeftCorner();
  37137. var bottomRightCorner = cellRange.getBottomRightCorner();
  37138. var areaStart = topLeftCorner;
  37139. var areaEnd = new _src.CellCoords(Math.max(bottomRightCorner.row, inputArray.length - 1 + topLeftCorner.row), Math.max(bottomRightCorner.col, inputArray[0].length - 1 + topLeftCorner.col));
  37140. var isSelRowAreaCoverInputValue = coordsTo.row - coordsFrom.row >= inputArray.length - 1;
  37141. var isSelColAreaCoverInputValue = coordsTo.col - coordsFrom.col >= inputArray[0].length - 1;
  37142. this.hot.addHookOnce('afterChange', function (changes) {
  37143. var changesLength = changes ? changes.length : 0;
  37144. if (changesLength) {
  37145. var offset = { row: 0, col: 0 };
  37146. var highestColumnIndex = -1;
  37147. (0, _array.arrayEach)(changes, function (change, index) {
  37148. var nextChange = changesLength > index + 1 ? changes[index + 1] : null;
  37149. if (nextChange) {
  37150. if (!isSelRowAreaCoverInputValue) {
  37151. offset.row += Math.max(nextChange[0] - change[0] - 1, 0);
  37152. }
  37153. if (!isSelColAreaCoverInputValue && change[1] > highestColumnIndex) {
  37154. highestColumnIndex = change[1];
  37155. offset.col += Math.max(nextChange[1] - change[1] - 1, 0);
  37156. }
  37157. }
  37158. });
  37159. _this6.hot.selectCell(areaStart.row, areaStart.col, areaEnd.row + offset.row, areaEnd.col + offset.col);
  37160. }
  37161. });
  37162. this.hot.populateFromArray(areaStart.row, areaStart.col, inputArray, areaEnd.row, areaEnd.col, 'CopyPaste.paste', this.pasteMode);
  37163. this.hot.runHooks('afterPaste', inputArray, this.copyableRanges);
  37164. }
  37165. /**
  37166. * Add copy, cut and paste options to the Context Menu.
  37167. *
  37168. * @private
  37169. * @param {Object} options Contains default added options of the Context Menu.
  37170. */
  37171. }, {
  37172. key: 'onAfterContextMenuDefaultOptions',
  37173. value: function onAfterContextMenuDefaultOptions(options) {
  37174. options.items.push({
  37175. name: '---------'
  37176. }, (0, _copy2.default)(this), (0, _cut2.default)(this));
  37177. }
  37178. /**
  37179. * We have to keep focus on textarea element, to make possible use of the browser tools (copy, cut, paste).
  37180. *
  37181. * @private
  37182. */
  37183. }, {
  37184. key: 'onAfterSelectionEnd',
  37185. value: function onAfterSelectionEnd() {
  37186. var priv = privatePool.get(this);
  37187. var editor = this.hot.getActiveEditor();
  37188. if (editor && typeof editor.isOpened !== 'undefined' && editor.isOpened()) {
  37189. return;
  37190. }
  37191. if (priv.isFragmentSelectionEnabled && !this.textarea.isActive() && (0, _element.getSelectionText)()) {
  37192. return;
  37193. }
  37194. this.setCopyableText();
  37195. this.textarea.select();
  37196. }
  37197. /**
  37198. * Destroy plugin instance.
  37199. */
  37200. }, {
  37201. key: 'destroy',
  37202. value: function destroy() {
  37203. if (this.textarea) {
  37204. this.textarea.destroy();
  37205. }
  37206. _get(CopyPaste.prototype.__proto__ || Object.getPrototypeOf(CopyPaste.prototype), 'destroy', this).call(this);
  37207. }
  37208. }]);
  37209. return CopyPaste;
  37210. }(_base2.default);
  37211. (0, _plugins.registerPlugin)('CopyPaste', CopyPaste);
  37212. exports.default = CopyPaste;
  37213. /***/ }),
  37214. /* 315 */
  37215. /***/ (function(module, exports, __webpack_require__) {
  37216. "use strict";
  37217. exports.__esModule = true;
  37218. 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; }; }();
  37219. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  37220. /**
  37221. * @class Textarea
  37222. *
  37223. * @plugin CopyPaste
  37224. */
  37225. var Textarea = function () {
  37226. _createClass(Textarea, null, [{
  37227. key: 'getSingleton',
  37228. value: function getSingleton() {
  37229. globalSingleton.append();
  37230. return globalSingleton;
  37231. }
  37232. }]);
  37233. function Textarea() {
  37234. _classCallCheck(this, Textarea);
  37235. /**
  37236. * Main textarea element.
  37237. *
  37238. * @type {HTMLElement}
  37239. */
  37240. this.element = void 0;
  37241. /**
  37242. * Store information about append to the document.body.
  37243. *
  37244. * @type {Boolean}
  37245. */
  37246. this.isAppended = false;
  37247. /**
  37248. * Reference counter.
  37249. *
  37250. * @type {Number}
  37251. */
  37252. this.refCounter = 0;
  37253. }
  37254. /**
  37255. * Apends textarea element to the `body`
  37256. */
  37257. _createClass(Textarea, [{
  37258. key: 'append',
  37259. value: function append() {
  37260. if (this.hasBeenDestroyed()) {
  37261. this.create();
  37262. }
  37263. this.refCounter++;
  37264. if (!this.isAppended && document.body) {
  37265. if (document.body) {
  37266. this.isAppended = true;
  37267. document.body.appendChild(this.element);
  37268. }
  37269. }
  37270. }
  37271. /**
  37272. * Prepares textarea element with proper attributes.
  37273. */
  37274. }, {
  37275. key: 'create',
  37276. value: function create() {
  37277. this.element = document.createElement('textarea');
  37278. this.element.id = 'HandsontableCopyPaste';
  37279. this.element.className = 'copyPaste';
  37280. this.element.tabIndex = -1;
  37281. this.element.autocomplete = 'off';
  37282. this.element.wrap = 'hard';
  37283. this.element.value = ' ';
  37284. }
  37285. /**
  37286. * Deselects textarea element if is active.
  37287. */
  37288. }, {
  37289. key: 'deselect',
  37290. value: function deselect() {
  37291. if (this.element === document.activeElement) {
  37292. document.activeElement.blur();
  37293. }
  37294. }
  37295. /**
  37296. * Destroy instance
  37297. */
  37298. }, {
  37299. key: 'destroy',
  37300. value: function destroy() {
  37301. this.refCounter--;
  37302. this.refCounter = this.refCounter < 0 ? 0 : this.refCounter;
  37303. if (this.hasBeenDestroyed() && this.element && this.element.parentNode) {
  37304. this.element.parentNode.removeChild(this.element);
  37305. this.element = null;
  37306. this.isAppended = false;
  37307. }
  37308. }
  37309. /**
  37310. * Getter for the element.
  37311. *
  37312. * @returns {String}
  37313. */
  37314. }, {
  37315. key: 'getValue',
  37316. value: function getValue() {
  37317. return this.element.value;
  37318. }
  37319. /**
  37320. * Check if instance has been destroyed
  37321. *
  37322. * @returns {Boolean}
  37323. */
  37324. }, {
  37325. key: 'hasBeenDestroyed',
  37326. value: function hasBeenDestroyed() {
  37327. return this.refCounter < 1;
  37328. }
  37329. /**
  37330. * Check if the element is an active element in frame.
  37331. *
  37332. * @returns {Boolean}
  37333. */
  37334. }, {
  37335. key: 'isActive',
  37336. value: function isActive() {
  37337. return this.element === document.activeElement;
  37338. }
  37339. /**
  37340. * Sets focus on the element and select content.
  37341. */
  37342. }, {
  37343. key: 'select',
  37344. value: function select() {
  37345. this.element.focus();
  37346. this.element.select();
  37347. }
  37348. /**
  37349. * Setter for the element.
  37350. *
  37351. * @param {String} data Value which should be insert into the element.
  37352. */
  37353. }, {
  37354. key: 'setValue',
  37355. value: function setValue(data) {
  37356. this.element.value = data;
  37357. }
  37358. }]);
  37359. return Textarea;
  37360. }();
  37361. var globalSingleton = new Textarea();
  37362. exports.default = Textarea;
  37363. /***/ }),
  37364. /* 316 */
  37365. /***/ (function(module, exports, __webpack_require__) {
  37366. "use strict";
  37367. exports.__esModule = true;
  37368. exports.default = copyItem;
  37369. var _constants = __webpack_require__(7);
  37370. var C = _interopRequireWildcard(_constants);
  37371. 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; } }
  37372. function copyItem(copyPastePlugin) {
  37373. return {
  37374. key: 'copy',
  37375. name: function name() {
  37376. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_COPY);
  37377. },
  37378. callback: function callback() {
  37379. copyPastePlugin.copy();
  37380. },
  37381. disabled: function disabled() {
  37382. var selected = this.getSelected();
  37383. if (!selected || selected.length > 1) {
  37384. return true;
  37385. }
  37386. return false;
  37387. },
  37388. hidden: false
  37389. };
  37390. }
  37391. /***/ }),
  37392. /* 317 */
  37393. /***/ (function(module, exports, __webpack_require__) {
  37394. "use strict";
  37395. exports.__esModule = true;
  37396. exports.default = cutItem;
  37397. var _constants = __webpack_require__(7);
  37398. var C = _interopRequireWildcard(_constants);
  37399. 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; } }
  37400. function cutItem(copyPastePlugin) {
  37401. return {
  37402. key: 'cut',
  37403. name: function name() {
  37404. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_CUT);
  37405. },
  37406. callback: function callback() {
  37407. copyPastePlugin.cut();
  37408. },
  37409. disabled: function disabled() {
  37410. var selected = this.getSelected();
  37411. if (!selected || selected.length > 1) {
  37412. return true;
  37413. }
  37414. return false;
  37415. },
  37416. hidden: false
  37417. };
  37418. }
  37419. /***/ }),
  37420. /* 318 */
  37421. /***/ (function(module, exports, __webpack_require__) {
  37422. "use strict";
  37423. exports.__esModule = true;
  37424. var _clipboardData = __webpack_require__(319);
  37425. var _clipboardData2 = _interopRequireDefault(_clipboardData);
  37426. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  37427. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  37428. var PasteEvent = function PasteEvent() {
  37429. _classCallCheck(this, PasteEvent);
  37430. this.clipboardData = new _clipboardData2.default();
  37431. };
  37432. exports.default = PasteEvent;
  37433. /***/ }),
  37434. /* 319 */
  37435. /***/ (function(module, exports, __webpack_require__) {
  37436. "use strict";
  37437. exports.__esModule = true;
  37438. 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; }; }();
  37439. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  37440. var ClipboardData = function () {
  37441. function ClipboardData() {
  37442. _classCallCheck(this, ClipboardData);
  37443. this.data = {};
  37444. }
  37445. _createClass(ClipboardData, [{
  37446. key: "setData",
  37447. value: function setData(type, value) {
  37448. this.data[type] = value;
  37449. }
  37450. }, {
  37451. key: "getData",
  37452. value: function getData(type) {
  37453. return this.data[type] || void 0;
  37454. }
  37455. }]);
  37456. return ClipboardData;
  37457. }();
  37458. exports.default = ClipboardData;
  37459. /***/ }),
  37460. /* 320 */
  37461. /***/ (function(module, exports) {
  37462. // removed by extract-text-webpack-plugin
  37463. /***/ }),
  37464. /* 321 */
  37465. /***/ (function(module, exports, __webpack_require__) {
  37466. "use strict";
  37467. exports.__esModule = true;
  37468. 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; }; }();
  37469. 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); } };
  37470. var _base = __webpack_require__(10);
  37471. var _base2 = _interopRequireDefault(_base);
  37472. var _plugins = __webpack_require__(8);
  37473. var _object = __webpack_require__(2);
  37474. var _number = __webpack_require__(5);
  37475. var _src = __webpack_require__(4);
  37476. var _pluginHooks = __webpack_require__(15);
  37477. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  37478. var _array = __webpack_require__(1);
  37479. var _constants = __webpack_require__(7);
  37480. var C = _interopRequireWildcard(_constants);
  37481. var _bottom = __webpack_require__(322);
  37482. var _bottom2 = _interopRequireDefault(_bottom);
  37483. var _left = __webpack_require__(323);
  37484. var _left2 = _interopRequireDefault(_left);
  37485. var _noBorders = __webpack_require__(324);
  37486. var _noBorders2 = _interopRequireDefault(_noBorders);
  37487. var _right = __webpack_require__(325);
  37488. var _right2 = _interopRequireDefault(_right);
  37489. var _top = __webpack_require__(326);
  37490. var _top2 = _interopRequireDefault(_top);
  37491. var _utils = __webpack_require__(47);
  37492. 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; } }
  37493. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  37494. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  37495. 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; }
  37496. 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; }
  37497. /**
  37498. * @plugin CustomBorders
  37499. *
  37500. * @description
  37501. * This plugin enables an option to apply custom borders through the context menu (configurable with context menu key `borders`).
  37502. *
  37503. * To initialize Handsontable with predefined custom borders, provide cell coordinates and border styles in a form of an array.
  37504. *
  37505. * See [Custom Borders](http://docs.handsontable.com/demo-custom-borders.html) demo for more examples.
  37506. *
  37507. * @example
  37508. * ```js
  37509. * ...
  37510. * customBorders: [
  37511. * {
  37512. * range: {
  37513. * from: {
  37514. * row: 1,
  37515. * col: 1
  37516. * },
  37517. * to: {
  37518. * row: 3,
  37519. * col: 4
  37520. * },
  37521. * },
  37522. * left: {},
  37523. * right: {},
  37524. * top: {},
  37525. * bottom: {},
  37526. * },
  37527. * ],
  37528. * ...
  37529. *
  37530. * // or
  37531. * ...
  37532. * customBorders: [
  37533. * { row: 2,
  37534. * col: 2,
  37535. * left: {
  37536. * width: 2,
  37537. * color: 'red',
  37538. * },
  37539. * right: {
  37540. * width: 1,
  37541. * color: 'green',
  37542. * },
  37543. * top: '',
  37544. * bottom: '',
  37545. * }.
  37546. * ],
  37547. * ...
  37548. * ```
  37549. * @private
  37550. * @class CustomBorders
  37551. */
  37552. var CustomBorders = function (_BasePlugin) {
  37553. _inherits(CustomBorders, _BasePlugin);
  37554. function CustomBorders(hotInstance) {
  37555. _classCallCheck(this, CustomBorders);
  37556. /**
  37557. * Saved borders settings.
  37558. *
  37559. * @type {Array}
  37560. */
  37561. var _this = _possibleConstructorReturn(this, (CustomBorders.__proto__ || Object.getPrototypeOf(CustomBorders)).call(this, hotInstance));
  37562. _this.savedBorderSettings = void 0;
  37563. return _this;
  37564. }
  37565. /**
  37566. * Check if the plugin is enabled in the handsontable settings.
  37567. *
  37568. * @returns {Boolean}
  37569. */
  37570. _createClass(CustomBorders, [{
  37571. key: 'isEnabled',
  37572. value: function isEnabled() {
  37573. return !!this.hot.getSettings().customBorders;
  37574. }
  37575. /**
  37576. * Enable plugin for this Handsontable instance.
  37577. */
  37578. }, {
  37579. key: 'enablePlugin',
  37580. value: function enablePlugin() {
  37581. var _this2 = this;
  37582. if (this.enabled) {
  37583. return;
  37584. }
  37585. this.addHook('afterContextMenuDefaultOptions', function (options) {
  37586. return _this2.onAfterContextMenuDefaultOptions(options);
  37587. });
  37588. this.addHook('afterInit', function () {
  37589. return _this2.onAfterInit();
  37590. });
  37591. _get(CustomBorders.prototype.__proto__ || Object.getPrototypeOf(CustomBorders.prototype), 'enablePlugin', this).call(this);
  37592. }
  37593. /**
  37594. * Disable plugin for this Handsontable instance.
  37595. */
  37596. }, {
  37597. key: 'disablePlugin',
  37598. value: function disablePlugin() {
  37599. this.clearBorders();
  37600. _get(CustomBorders.prototype.__proto__ || Object.getPrototypeOf(CustomBorders.prototype), 'disablePlugin', this).call(this);
  37601. }
  37602. /**
  37603. * Updates the plugin to use the latest options you have specified.
  37604. */
  37605. }, {
  37606. key: 'updatePlugin',
  37607. value: function updatePlugin() {
  37608. this.disablePlugin();
  37609. this.enablePlugin();
  37610. this.changeBorderSettings();
  37611. _get(CustomBorders.prototype.__proto__ || Object.getPrototypeOf(CustomBorders.prototype), 'updatePlugin', this).call(this);
  37612. }
  37613. /**
  37614. * Get index of border from the settings.
  37615. *
  37616. * @param {String} className Class name as string.
  37617. * @returns {Number}
  37618. */
  37619. }, {
  37620. key: 'getSettingIndex',
  37621. value: function getSettingIndex(className) {
  37622. var index = -1;
  37623. (0, _array.arrayEach)(this.hot.selection.highlight.borders, function (selection, i) {
  37624. if (selection.settings.className === className) {
  37625. index = i;
  37626. return false;
  37627. }
  37628. });
  37629. return index;
  37630. }
  37631. /**
  37632. * Insert WalkontableSelection instance into Walkontable settings.
  37633. *
  37634. * @param {Object} border Object with `row` and `col`, `left`, `right`, `top` and `bottom`, `className` and `border` ({Object} with `color`, `width` and `cornerVisible` property) properties.
  37635. */
  37636. }, {
  37637. key: 'insertBorderIntoSettings',
  37638. value: function insertBorderIntoSettings(border) {
  37639. var coordinates = {
  37640. row: border.row,
  37641. col: border.col
  37642. };
  37643. var selection = new _src.Selection(border, new _src.CellRange(coordinates, coordinates, coordinates));
  37644. var index = this.getSettingIndex(border.className);
  37645. if (index >= 0) {
  37646. this.hot.selection.highlight.borders[index] = selection;
  37647. } else {
  37648. this.hot.selection.highlight.borders.push(selection);
  37649. }
  37650. }
  37651. /**
  37652. * Prepare borders from setting (single cell).
  37653. *
  37654. * @param {Number} row Visual row index.
  37655. * @param {Number} col Visual column index.
  37656. * @param {Object} borderObj Object with `row` and `col`, `left`, `right`, `top` and `bottom` properties.
  37657. */
  37658. }, {
  37659. key: 'prepareBorderFromCustomAdded',
  37660. value: function prepareBorderFromCustomAdded(row, col, borderObj) {
  37661. var border = (0, _utils.createEmptyBorders)(row, col);
  37662. border = (0, _utils.extendDefaultBorder)(border, borderObj);
  37663. this.hot.setCellMeta(row, col, 'borders', border);
  37664. this.insertBorderIntoSettings(border);
  37665. }
  37666. /** *
  37667. * Prepare borders from setting (object).
  37668. *
  37669. * @param {Object} rowObj Object with `range`, `left`, `right`, `top` and `bottom` properties.
  37670. */
  37671. }, {
  37672. key: 'prepareBorderFromCustomAddedRange',
  37673. value: function prepareBorderFromCustomAddedRange(rowObj) {
  37674. var _this3 = this;
  37675. var range = rowObj.range;
  37676. (0, _number.rangeEach)(range.from.row, range.to.row, function (rowIndex) {
  37677. (0, _number.rangeEach)(range.from.col, range.to.col, function (colIndex) {
  37678. var border = (0, _utils.createEmptyBorders)(rowIndex, colIndex);
  37679. var add = 0;
  37680. if (rowIndex === range.from.row) {
  37681. add += 1;
  37682. if ((0, _object.hasOwnProperty)(rowObj, 'top')) {
  37683. border.top = rowObj.top;
  37684. }
  37685. }
  37686. if (rowIndex === range.to.row) {
  37687. add += 1;
  37688. if ((0, _object.hasOwnProperty)(rowObj, 'bottom')) {
  37689. border.bottom = rowObj.bottom;
  37690. }
  37691. }
  37692. if (colIndex === range.from.col) {
  37693. add += 1;
  37694. if ((0, _object.hasOwnProperty)(rowObj, 'left')) {
  37695. border.left = rowObj.left;
  37696. }
  37697. }
  37698. if (colIndex === range.to.col) {
  37699. add += 1;
  37700. if ((0, _object.hasOwnProperty)(rowObj, 'right')) {
  37701. border.right = rowObj.right;
  37702. }
  37703. }
  37704. if (add > 0) {
  37705. _this3.hot.setCellMeta(rowIndex, colIndex, 'borders', border);
  37706. _this3.insertBorderIntoSettings(border);
  37707. }
  37708. });
  37709. });
  37710. }
  37711. /**
  37712. * Remove borders divs from DOM.
  37713. *
  37714. * @param {String} borderClassName Border class name as string.
  37715. */
  37716. }, {
  37717. key: 'removeBordersFromDom',
  37718. value: function removeBordersFromDom(borderClassName) {
  37719. var borders = this.hot.rootElement.querySelectorAll('.' + borderClassName + ':not(td)');
  37720. (0, _number.rangeEach)(0, borders.length - 1, function (index) {
  37721. var parent = borders[index].parentNode;
  37722. if (parent.parentNode) {
  37723. parent.parentNode.removeChild(parent);
  37724. }
  37725. });
  37726. }
  37727. /**
  37728. * Remove border (triggered from context menu).
  37729. *
  37730. * @param {Number} row Visual row index.
  37731. * @param {Number} col Visual column index.
  37732. */
  37733. }, {
  37734. key: 'removeAllBorders',
  37735. value: function removeAllBorders(row, col) {
  37736. var borderClassName = (0, _utils.createClassName)(row, col);
  37737. this.removeBordersFromDom(borderClassName);
  37738. this.hot.removeCellMeta(row, col, 'borders');
  37739. }
  37740. /**
  37741. * Set borders for each cell re. to border position.
  37742. *
  37743. * @param {Number} row Visual row index.
  37744. * @param {Number} col Visual column index.
  37745. * @param {String} place Coordinate where add/remove border - `top`, `bottom`, `left`, `right` and `noBorders`.
  37746. * @param {Boolean} remove True when remove borders, and false when add borders.
  37747. */
  37748. }, {
  37749. key: 'setBorder',
  37750. value: function setBorder(row, col, place, remove) {
  37751. var bordersMeta = this.hot.getCellMeta(row, col).borders;
  37752. if (!bordersMeta || bordersMeta.border === void 0) {
  37753. bordersMeta = (0, _utils.createEmptyBorders)(row, col);
  37754. }
  37755. if (remove) {
  37756. bordersMeta[place] = (0, _utils.createSingleEmptyBorder)();
  37757. } else {
  37758. bordersMeta[place] = (0, _utils.createDefaultCustomBorder)();
  37759. }
  37760. this.hot.setCellMeta(row, col, 'borders', bordersMeta);
  37761. var borderClassName = (0, _utils.createClassName)(row, col);
  37762. this.removeBordersFromDom(borderClassName);
  37763. this.insertBorderIntoSettings(bordersMeta);
  37764. this.hot.render();
  37765. }
  37766. /**
  37767. * Prepare borders based on cell and border position.
  37768. *
  37769. * @param {Object} selected
  37770. * @param {String} place Coordinate where add/remove border - `top`, `bottom`, `left`, `right` and `noBorders`.
  37771. * @param {Boolean} remove True when remove borders, and false when add borders.
  37772. */
  37773. }, {
  37774. key: 'prepareBorder',
  37775. value: function prepareBorder(selected, place, remove) {
  37776. var _this4 = this;
  37777. (0, _array.arrayEach)(selected, function (_ref) {
  37778. var start = _ref.start,
  37779. end = _ref.end;
  37780. if (start.row === end.row && start.col === end.col) {
  37781. if (place === 'noBorders') {
  37782. _this4.removeAllBorders(start.row, start.col);
  37783. } else {
  37784. _this4.setBorder(start.row, start.col, place, remove);
  37785. }
  37786. } else {
  37787. switch (place) {
  37788. case 'noBorders':
  37789. (0, _number.rangeEach)(start.col, end.col, function (colIndex) {
  37790. (0, _number.rangeEach)(start.row, end.row, function (rowIndex) {
  37791. _this4.removeAllBorders(rowIndex, colIndex);
  37792. });
  37793. });
  37794. break;
  37795. case 'top':
  37796. (0, _number.rangeEach)(start.col, end.col, function (topCol) {
  37797. _this4.setBorder(start.row, topCol, place, remove);
  37798. });
  37799. break;
  37800. case 'right':
  37801. (0, _number.rangeEach)(start.row, end.row, function (rowRight) {
  37802. _this4.setBorder(rowRight, end.col, place, remove);
  37803. });
  37804. break;
  37805. case 'bottom':
  37806. (0, _number.rangeEach)(start.col, end.col, function (bottomCol) {
  37807. _this4.setBorder(end.row, bottomCol, place, remove);
  37808. });
  37809. break;
  37810. case 'left':
  37811. (0, _number.rangeEach)(start.row, end.row, function (rowLeft) {
  37812. _this4.setBorder(rowLeft, start.col, place, remove);
  37813. });
  37814. break;
  37815. default:
  37816. break;
  37817. }
  37818. }
  37819. });
  37820. }
  37821. /**
  37822. * Create borders from settings.
  37823. *
  37824. * @private
  37825. * @param {Array} customBorders Object with `row` and `col`, `left`, `right`, `top` and `bottom` properties.
  37826. */
  37827. }, {
  37828. key: 'createCustomBorders',
  37829. value: function createCustomBorders(customBorders) {
  37830. var _this5 = this;
  37831. (0, _number.rangeEach)(0, customBorders.length - 1, function (index) {
  37832. if (customBorders[index].range) {
  37833. _this5.prepareBorderFromCustomAddedRange(customBorders[index]);
  37834. } else {
  37835. _this5.prepareBorderFromCustomAdded(customBorders[index].row, customBorders[index].col, customBorders[index]);
  37836. }
  37837. });
  37838. this.hot.render();
  37839. this.hot.view.wt.draw(true);
  37840. }
  37841. /**
  37842. * Add border options to context menu.
  37843. *
  37844. * @private
  37845. * @param {Object} defaultOptions Context menu items.
  37846. */
  37847. }, {
  37848. key: 'onAfterContextMenuDefaultOptions',
  37849. value: function onAfterContextMenuDefaultOptions(defaultOptions) {
  37850. if (!this.hot.getSettings().customBorders) {
  37851. return;
  37852. }
  37853. defaultOptions.items.push({
  37854. name: '---------'
  37855. }, {
  37856. key: 'borders',
  37857. name: function name() {
  37858. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_BORDERS);
  37859. },
  37860. disabled: function disabled() {
  37861. return this.selection.isSelectedByCorner();
  37862. },
  37863. submenu: {
  37864. items: [(0, _top2.default)(this), (0, _right2.default)(this), (0, _bottom2.default)(this), (0, _left2.default)(this), (0, _noBorders2.default)(this)]
  37865. }
  37866. });
  37867. }
  37868. /**
  37869. * Clear borders.
  37870. *
  37871. * @private
  37872. */
  37873. }, {
  37874. key: 'clearBorders',
  37875. value: function clearBorders() {
  37876. var _this6 = this;
  37877. var bordersFromTable = this.hot.rootElement.querySelectorAll('td[class^="border"]');
  37878. (0, _number.rangeEach)(0, bordersFromTable.length - 1, function (index) {
  37879. _this6.removeBordersFromDom(bordersFromTable[index].className);
  37880. });
  37881. }
  37882. /**
  37883. * Change borders from settings.
  37884. *
  37885. * @private
  37886. */
  37887. }, {
  37888. key: 'changeBorderSettings',
  37889. value: function changeBorderSettings() {
  37890. var customBorders = this.hot.getSettings().customBorders;
  37891. if (customBorders) {
  37892. if (Array.isArray(customBorders)) {
  37893. this.savedBorderSettings = customBorders;
  37894. this.createCustomBorders(customBorders);
  37895. } else if (customBorders !== void 0) {
  37896. var borders = this.savedBorderSettings ? this.savedBorderSettings : customBorders;
  37897. this.createCustomBorders(borders);
  37898. }
  37899. }
  37900. }
  37901. /**
  37902. * `afterInit` hook callback.
  37903. *
  37904. * @private
  37905. */
  37906. }, {
  37907. key: 'onAfterInit',
  37908. value: function onAfterInit() {
  37909. this.changeBorderSettings();
  37910. }
  37911. /**
  37912. * Destroy plugin instance.
  37913. */
  37914. }, {
  37915. key: 'destroy',
  37916. value: function destroy() {
  37917. _get(CustomBorders.prototype.__proto__ || Object.getPrototypeOf(CustomBorders.prototype), 'destroy', this).call(this);
  37918. }
  37919. }]);
  37920. return CustomBorders;
  37921. }(_base2.default);
  37922. (0, _plugins.registerPlugin)('customBorders', CustomBorders);
  37923. exports.default = CustomBorders;
  37924. /***/ }),
  37925. /* 322 */
  37926. /***/ (function(module, exports, __webpack_require__) {
  37927. "use strict";
  37928. exports.__esModule = true;
  37929. exports.default = bottom;
  37930. var _constants = __webpack_require__(7);
  37931. var C = _interopRequireWildcard(_constants);
  37932. var _utils = __webpack_require__(47);
  37933. 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; } }
  37934. function bottom(customBordersPlugin) {
  37935. return {
  37936. key: 'borders:bottom',
  37937. name: function name() {
  37938. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_BORDERS_BOTTOM);
  37939. var hasBorder = (0, _utils.checkSelectionBorders)(this, 'bottom');
  37940. if (hasBorder) {
  37941. label = (0, _utils.markSelected)(label);
  37942. }
  37943. return label;
  37944. },
  37945. callback: function callback(key, selected) {
  37946. var hasBorder = (0, _utils.checkSelectionBorders)(this, 'bottom');
  37947. customBordersPlugin.prepareBorder(selected, 'bottom', hasBorder);
  37948. }
  37949. };
  37950. }
  37951. /***/ }),
  37952. /* 323 */
  37953. /***/ (function(module, exports, __webpack_require__) {
  37954. "use strict";
  37955. exports.__esModule = true;
  37956. exports.default = left;
  37957. var _constants = __webpack_require__(7);
  37958. var C = _interopRequireWildcard(_constants);
  37959. var _utils = __webpack_require__(47);
  37960. 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; } }
  37961. function left(customBordersPlugin) {
  37962. return {
  37963. key: 'borders:left',
  37964. name: function name() {
  37965. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_BORDERS_LEFT);
  37966. var hasBorder = (0, _utils.checkSelectionBorders)(this, 'left');
  37967. if (hasBorder) {
  37968. label = (0, _utils.markSelected)(label);
  37969. }
  37970. return label;
  37971. },
  37972. callback: function callback(key, selected) {
  37973. var hasBorder = (0, _utils.checkSelectionBorders)(this, 'left');
  37974. customBordersPlugin.prepareBorder(selected, 'left', hasBorder);
  37975. }
  37976. };
  37977. }
  37978. /***/ }),
  37979. /* 324 */
  37980. /***/ (function(module, exports, __webpack_require__) {
  37981. "use strict";
  37982. exports.__esModule = true;
  37983. exports.default = noBorders;
  37984. var _constants = __webpack_require__(7);
  37985. var C = _interopRequireWildcard(_constants);
  37986. var _utils = __webpack_require__(47);
  37987. 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; } }
  37988. function noBorders(customBordersPlugin) {
  37989. return {
  37990. key: 'borders:no_borders',
  37991. name: function name() {
  37992. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_REMOVE_BORDERS);
  37993. },
  37994. callback: function callback(key, selected) {
  37995. customBordersPlugin.prepareBorder(selected, 'noBorders');
  37996. },
  37997. disabled: function disabled() {
  37998. return !(0, _utils.checkSelectionBorders)(this);
  37999. }
  38000. };
  38001. }
  38002. /***/ }),
  38003. /* 325 */
  38004. /***/ (function(module, exports, __webpack_require__) {
  38005. "use strict";
  38006. exports.__esModule = true;
  38007. exports.default = right;
  38008. var _constants = __webpack_require__(7);
  38009. var C = _interopRequireWildcard(_constants);
  38010. var _utils = __webpack_require__(47);
  38011. 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; } }
  38012. function right(customBordersPlugin) {
  38013. return {
  38014. key: 'borders:right',
  38015. name: function name() {
  38016. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_BORDERS_RIGHT);
  38017. var hasBorder = (0, _utils.checkSelectionBorders)(this, 'right');
  38018. if (hasBorder) {
  38019. label = (0, _utils.markSelected)(label);
  38020. }
  38021. return label;
  38022. },
  38023. callback: function callback(key, selected) {
  38024. var hasBorder = (0, _utils.checkSelectionBorders)(this, 'right');
  38025. customBordersPlugin.prepareBorder(selected, 'right', hasBorder);
  38026. }
  38027. };
  38028. }
  38029. /***/ }),
  38030. /* 326 */
  38031. /***/ (function(module, exports, __webpack_require__) {
  38032. "use strict";
  38033. exports.__esModule = true;
  38034. exports.default = top;
  38035. var _constants = __webpack_require__(7);
  38036. var C = _interopRequireWildcard(_constants);
  38037. var _utils = __webpack_require__(47);
  38038. 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; } }
  38039. function top(customBordersPlugin) {
  38040. return {
  38041. key: 'borders:top',
  38042. name: function name() {
  38043. var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_BORDERS_TOP);
  38044. var hasBorder = (0, _utils.checkSelectionBorders)(this, 'top');
  38045. if (hasBorder) {
  38046. label = (0, _utils.markSelected)(label);
  38047. }
  38048. return label;
  38049. },
  38050. callback: function callback(key, selected) {
  38051. var hasBorder = (0, _utils.checkSelectionBorders)(this, 'top');
  38052. customBordersPlugin.prepareBorder(selected, 'top', hasBorder);
  38053. }
  38054. };
  38055. }
  38056. /***/ }),
  38057. /* 327 */
  38058. /***/ (function(module, exports, __webpack_require__) {
  38059. "use strict";
  38060. exports.__esModule = true;
  38061. 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; }; }();
  38062. 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); } };
  38063. var _base = __webpack_require__(10);
  38064. var _base2 = _interopRequireDefault(_base);
  38065. var _eventManager = __webpack_require__(6);
  38066. var _eventManager2 = _interopRequireDefault(_eventManager);
  38067. var _plugins = __webpack_require__(8);
  38068. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  38069. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  38070. 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; }
  38071. 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; }
  38072. /**
  38073. * @description
  38074. * Plugin used to scroll Handsontable by selecting a cell and dragging outside of the visible viewport.
  38075. *
  38076. *
  38077. * @class DragToScroll
  38078. * @plugin DragToScroll
  38079. */
  38080. var DragToScroll = function (_BasePlugin) {
  38081. _inherits(DragToScroll, _BasePlugin);
  38082. function DragToScroll(hotInstance) {
  38083. _classCallCheck(this, DragToScroll);
  38084. /**
  38085. * Instance of {@link EventManager}.
  38086. *
  38087. * @type {EventManager}
  38088. */
  38089. var _this = _possibleConstructorReturn(this, (DragToScroll.__proto__ || Object.getPrototypeOf(DragToScroll)).call(this, hotInstance));
  38090. _this.eventManager = new _eventManager2.default(_this);
  38091. /**
  38092. * DOMRect - size of an element and its position relative to the viewport,
  38093. * e.g. {bottom: 449, height: 441, left: 8, right: 814, top: 8, width: 806, x: 8, y:8}.
  38094. *
  38095. * @type {Object}
  38096. */
  38097. _this.boundaries = null;
  38098. /**
  38099. * Callback function.
  38100. *
  38101. * @type {Function}
  38102. */
  38103. _this.callback = null;
  38104. /**
  38105. * Flag indicates mouseDown/mouseUp.
  38106. *
  38107. * @type {Boolean}
  38108. */
  38109. _this.listening = false;
  38110. return _this;
  38111. }
  38112. /**
  38113. * Check if the plugin is enabled in the Handsontable settings.
  38114. *
  38115. * @returns {Boolean}
  38116. */
  38117. _createClass(DragToScroll, [{
  38118. key: 'isEnabled',
  38119. value: function isEnabled() {
  38120. return !!this.hot.getSettings().dragToScroll;
  38121. }
  38122. /**
  38123. * Enable plugin for this Handsontable instance.
  38124. */
  38125. }, {
  38126. key: 'enablePlugin',
  38127. value: function enablePlugin() {
  38128. var _this2 = this;
  38129. if (this.enabled) {
  38130. return;
  38131. }
  38132. this.addHook('afterOnCellMouseDown', function () {
  38133. return _this2.setupListening();
  38134. });
  38135. this.addHook('afterOnCellCornerMouseDown', function () {
  38136. return _this2.setupListening();
  38137. });
  38138. this.registerEvents();
  38139. _get(DragToScroll.prototype.__proto__ || Object.getPrototypeOf(DragToScroll.prototype), 'enablePlugin', this).call(this);
  38140. }
  38141. /**
  38142. * Updates the plugin to use the latest options you have specified.
  38143. */
  38144. }, {
  38145. key: 'updatePlugin',
  38146. value: function updatePlugin() {
  38147. this.disablePlugin();
  38148. this.enablePlugin();
  38149. _get(DragToScroll.prototype.__proto__ || Object.getPrototypeOf(DragToScroll.prototype), 'updatePlugin', this).call(this);
  38150. }
  38151. /**
  38152. * Disable plugin for this Handsontable instance.
  38153. */
  38154. }, {
  38155. key: 'disablePlugin',
  38156. value: function disablePlugin() {
  38157. this.unregisterEvents();
  38158. _get(DragToScroll.prototype.__proto__ || Object.getPrototypeOf(DragToScroll.prototype), 'disablePlugin', this).call(this);
  38159. }
  38160. /**
  38161. * Sets the value of the visible element.
  38162. *
  38163. * @param boundaries {Object} compatible with getBoundingClientRect
  38164. */
  38165. }, {
  38166. key: 'setBoundaries',
  38167. value: function setBoundaries(boundaries) {
  38168. this.boundaries = boundaries;
  38169. }
  38170. /**
  38171. * Change callback function.
  38172. *
  38173. * @param callback {Function}
  38174. */
  38175. }, {
  38176. key: 'setCallback',
  38177. value: function setCallback(callback) {
  38178. this.callback = callback;
  38179. }
  38180. /**
  38181. * Check if mouse position (x, y) is outside of the viewport.
  38182. *
  38183. * @param {Number} x
  38184. * @param {Number} y
  38185. */
  38186. }, {
  38187. key: 'check',
  38188. value: function check(x, y) {
  38189. var diffX = 0;
  38190. var diffY = 0;
  38191. if (y < this.boundaries.top) {
  38192. // y is less than top
  38193. diffY = y - this.boundaries.top;
  38194. } else if (y > this.boundaries.bottom) {
  38195. // y is more than bottom
  38196. diffY = y - this.boundaries.bottom;
  38197. }
  38198. if (x < this.boundaries.left) {
  38199. // x is less than left
  38200. diffX = x - this.boundaries.left;
  38201. } else if (x > this.boundaries.right) {
  38202. // x is more than right
  38203. diffX = x - this.boundaries.right;
  38204. }
  38205. this.callback(diffX, diffY);
  38206. }
  38207. /**
  38208. * Register dom listeners.
  38209. *
  38210. * @private
  38211. */
  38212. }, {
  38213. key: 'registerEvents',
  38214. value: function registerEvents() {
  38215. var _this3 = this;
  38216. this.eventManager.addEventListener(document, 'mouseup', function () {
  38217. return _this3.onMouseUp();
  38218. });
  38219. this.eventManager.addEventListener(document, 'mousemove', function (event) {
  38220. return _this3.onMouseMove(event);
  38221. });
  38222. }
  38223. /**
  38224. * Unbind the events used by the plugin.
  38225. *
  38226. * @private
  38227. */
  38228. }, {
  38229. key: 'unregisterEvents',
  38230. value: function unregisterEvents() {
  38231. this.eventManager.clear();
  38232. }
  38233. /**
  38234. * On after on cell/cellCorner mouse down listener.
  38235. *
  38236. * @private
  38237. */
  38238. }, {
  38239. key: 'setupListening',
  38240. value: function setupListening() {
  38241. var scrollHandler = this.hot.view.wt.wtTable.holder; // native scroll
  38242. if (scrollHandler === window) {
  38243. // not much we can do currently
  38244. return;
  38245. }
  38246. this.setBoundaries(scrollHandler.getBoundingClientRect());
  38247. this.setCallback(function (scrollX, scrollY) {
  38248. if (scrollX < 0) {
  38249. scrollHandler.scrollLeft -= 50;
  38250. } else if (scrollX > 0) {
  38251. scrollHandler.scrollLeft += 50;
  38252. }
  38253. if (scrollY < 0) {
  38254. scrollHandler.scrollTop -= 20;
  38255. } else if (scrollY > 0) {
  38256. scrollHandler.scrollTop += 20;
  38257. }
  38258. });
  38259. this.listening = true;
  38260. }
  38261. /**
  38262. * 'mouseMove' event callback.
  38263. *
  38264. * @private
  38265. * @param {MouseEvent} event `mousemove` event properties.
  38266. */
  38267. }, {
  38268. key: 'onMouseMove',
  38269. value: function onMouseMove(event) {
  38270. if (this.listening) {
  38271. this.check(event.clientX, event.clientY);
  38272. }
  38273. }
  38274. /**
  38275. * `onMouseUp` hook callback.
  38276. *
  38277. * @private
  38278. */
  38279. }, {
  38280. key: 'onMouseUp',
  38281. value: function onMouseUp() {
  38282. this.listening = false;
  38283. }
  38284. /**
  38285. * Destroy instance.
  38286. */
  38287. }, {
  38288. key: 'destroy',
  38289. value: function destroy() {
  38290. _get(DragToScroll.prototype.__proto__ || Object.getPrototypeOf(DragToScroll.prototype), 'destroy', this).call(this);
  38291. }
  38292. }]);
  38293. return DragToScroll;
  38294. }(_base2.default);
  38295. (0, _plugins.registerPlugin)('dragToScroll', DragToScroll);
  38296. exports.default = DragToScroll;
  38297. /***/ }),
  38298. /* 328 */
  38299. /***/ (function(module, exports, __webpack_require__) {
  38300. "use strict";
  38301. exports.__esModule = true;
  38302. 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; }; }();
  38303. 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); } };
  38304. var _base = __webpack_require__(10);
  38305. var _base2 = _interopRequireDefault(_base);
  38306. var _plugins = __webpack_require__(8);
  38307. var _array = __webpack_require__(1);
  38308. var _freezeColumn = __webpack_require__(329);
  38309. var _freezeColumn2 = _interopRequireDefault(_freezeColumn);
  38310. var _unfreezeColumn = __webpack_require__(330);
  38311. var _unfreezeColumn2 = _interopRequireDefault(_unfreezeColumn);
  38312. __webpack_require__(331);
  38313. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  38314. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  38315. 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; }
  38316. 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; }
  38317. var privatePool = new WeakMap();
  38318. /**
  38319. * This plugin allows to manually "freeze" and "unfreeze" a column using an entry in the Context Menu.
  38320. * You can turn it on by setting a `manualColumnFreeze` property to `true`.
  38321. *
  38322. * @plugin ManualColumnFreeze
  38323. * @dependencies ManualColumnMove
  38324. */
  38325. var ManualColumnFreeze = function (_BasePlugin) {
  38326. _inherits(ManualColumnFreeze, _BasePlugin);
  38327. function ManualColumnFreeze(hotInstance) {
  38328. _classCallCheck(this, ManualColumnFreeze);
  38329. var _this = _possibleConstructorReturn(this, (ManualColumnFreeze.__proto__ || Object.getPrototypeOf(ManualColumnFreeze)).call(this, hotInstance));
  38330. privatePool.set(_this, {
  38331. moveByFreeze: false,
  38332. afterFirstUse: false
  38333. });
  38334. /**
  38335. * Original column positions
  38336. *
  38337. * @type {Array}
  38338. */
  38339. _this.frozenColumnsBasePositions = [];
  38340. /**
  38341. * Reference to the `ManualColumnMove` plugin.
  38342. */
  38343. _this.manualColumnMovePlugin = void 0;
  38344. return _this;
  38345. }
  38346. /**
  38347. * Check if the plugin is enabled in the Handsontable settings.
  38348. *
  38349. * @returns {Boolean}
  38350. */
  38351. _createClass(ManualColumnFreeze, [{
  38352. key: 'isEnabled',
  38353. value: function isEnabled() {
  38354. return !!this.hot.getSettings().manualColumnFreeze;
  38355. }
  38356. /**
  38357. * Enable plugin for this Handsontable instance.
  38358. */
  38359. }, {
  38360. key: 'enablePlugin',
  38361. value: function enablePlugin() {
  38362. var _this2 = this;
  38363. if (this.enabled) {
  38364. return;
  38365. }
  38366. this.addHook('afterContextMenuDefaultOptions', function (options) {
  38367. return _this2.addContextMenuEntry(options);
  38368. });
  38369. this.addHook('afterInit', function () {
  38370. return _this2.onAfterInit();
  38371. });
  38372. this.addHook('beforeColumnMove', function (rows, target) {
  38373. return _this2.onBeforeColumnMove(rows, target);
  38374. });
  38375. _get(ManualColumnFreeze.prototype.__proto__ || Object.getPrototypeOf(ManualColumnFreeze.prototype), 'enablePlugin', this).call(this);
  38376. }
  38377. /**
  38378. * Disable plugin for this Handsontable instance.
  38379. */
  38380. }, {
  38381. key: 'disablePlugin',
  38382. value: function disablePlugin() {
  38383. var priv = privatePool.get(this);
  38384. priv.afterFirstUse = false;
  38385. priv.moveByFreeze = false;
  38386. _get(ManualColumnFreeze.prototype.__proto__ || Object.getPrototypeOf(ManualColumnFreeze.prototype), 'disablePlugin', this).call(this);
  38387. }
  38388. /**
  38389. * Updates the plugin to use the latest options you have specified.
  38390. */
  38391. }, {
  38392. key: 'updatePlugin',
  38393. value: function updatePlugin() {
  38394. this.disablePlugin();
  38395. this.enablePlugin();
  38396. _get(ManualColumnFreeze.prototype.__proto__ || Object.getPrototypeOf(ManualColumnFreeze.prototype), 'updatePlugin', this).call(this);
  38397. }
  38398. /**
  38399. * Freeze the given column (add it to fixed columns).
  38400. *
  38401. * @param {Number} column Visual column index.
  38402. */
  38403. }, {
  38404. key: 'freezeColumn',
  38405. value: function freezeColumn(column) {
  38406. var priv = privatePool.get(this);
  38407. var settings = this.hot.getSettings();
  38408. if (!priv.afterFirstUse) {
  38409. priv.afterFirstUse = true;
  38410. }
  38411. if (settings.fixedColumnsLeft === this.hot.countCols() || column <= settings.fixedColumnsLeft - 1) {
  38412. return; // already fixed
  38413. }
  38414. priv.moveByFreeze = true;
  38415. if (column !== this.getMovePlugin().columnsMapper.getValueByIndex(column)) {
  38416. this.frozenColumnsBasePositions[settings.fixedColumnsLeft] = column;
  38417. }
  38418. this.getMovePlugin().moveColumn(column, settings.fixedColumnsLeft++);
  38419. }
  38420. /**
  38421. * Unfreeze the given column (remove it from fixed columns and bring to it's previous position).
  38422. *
  38423. * @param {Number} column Visual column index.
  38424. */
  38425. }, {
  38426. key: 'unfreezeColumn',
  38427. value: function unfreezeColumn(column) {
  38428. var priv = privatePool.get(this);
  38429. var settings = this.hot.getSettings();
  38430. if (!priv.afterFirstUse) {
  38431. priv.afterFirstUse = true;
  38432. }
  38433. if (settings.fixedColumnsLeft <= 0 || column > settings.fixedColumnsLeft - 1) {
  38434. return; // not fixed
  38435. }
  38436. var returnCol = this.getBestColumnReturnPosition(column);
  38437. priv.moveByFreeze = true;
  38438. settings.fixedColumnsLeft--;
  38439. this.getMovePlugin().moveColumn(column, returnCol + 1);
  38440. }
  38441. /**
  38442. * Get the reference to the ManualColumnMove plugin.
  38443. *
  38444. * @private
  38445. * @returns {Object}
  38446. */
  38447. }, {
  38448. key: 'getMovePlugin',
  38449. value: function getMovePlugin() {
  38450. if (!this.manualColumnMovePlugin) {
  38451. this.manualColumnMovePlugin = this.hot.getPlugin('manualColumnMove');
  38452. }
  38453. return this.manualColumnMovePlugin;
  38454. }
  38455. /**
  38456. * Estimates the most fitting return position for unfrozen column.
  38457. *
  38458. * @private
  38459. * @param {Number} column Visual column index.
  38460. */
  38461. }, {
  38462. key: 'getBestColumnReturnPosition',
  38463. value: function getBestColumnReturnPosition(column) {
  38464. var movePlugin = this.getMovePlugin();
  38465. var settings = this.hot.getSettings();
  38466. var i = settings.fixedColumnsLeft;
  38467. var j = movePlugin.columnsMapper.getValueByIndex(i);
  38468. var initialCol = void 0;
  38469. if (this.frozenColumnsBasePositions[column] === null || this.frozenColumnsBasePositions[column] === void 0) {
  38470. initialCol = movePlugin.columnsMapper.getValueByIndex(column);
  38471. while (j !== null && j <= initialCol) {
  38472. i++;
  38473. j = movePlugin.columnsMapper.getValueByIndex(i);
  38474. }
  38475. } else {
  38476. initialCol = this.frozenColumnsBasePositions[column];
  38477. this.frozenColumnsBasePositions[column] = void 0;
  38478. while (j !== null && j <= initialCol) {
  38479. i++;
  38480. j = movePlugin.columnsMapper.getValueByIndex(i);
  38481. }
  38482. i = j;
  38483. }
  38484. return i - 1;
  38485. }
  38486. /**
  38487. * Add the manualColumnFreeze context menu entries.
  38488. *
  38489. * @private
  38490. * @param {Object} options Context menu options.
  38491. */
  38492. }, {
  38493. key: 'addContextMenuEntry',
  38494. value: function addContextMenuEntry(options) {
  38495. options.items.push({ name: '---------' }, (0, _freezeColumn2.default)(this), (0, _unfreezeColumn2.default)(this));
  38496. }
  38497. /**
  38498. * Enabling `manualColumnMove` plugin on `afterInit` hook.
  38499. *
  38500. * @private
  38501. */
  38502. }, {
  38503. key: 'onAfterInit',
  38504. value: function onAfterInit() {
  38505. if (!this.getMovePlugin().isEnabled()) {
  38506. this.getMovePlugin().enablePlugin();
  38507. }
  38508. }
  38509. /**
  38510. * Prevent moving the rows from/to fixed area.
  38511. *
  38512. * @private
  38513. * @param {Array} rows
  38514. * @param {Number} target
  38515. */
  38516. }, {
  38517. key: 'onBeforeColumnMove',
  38518. value: function onBeforeColumnMove(rows, target) {
  38519. var priv = privatePool.get(this);
  38520. if (priv.afterFirstUse && !priv.moveByFreeze) {
  38521. var frozenLen = this.hot.getSettings().fixedColumnsLeft;
  38522. var disallowMoving = target < frozenLen;
  38523. if (!disallowMoving) {
  38524. (0, _array.arrayEach)(rows, function (value, index, array) {
  38525. if (value < frozenLen) {
  38526. disallowMoving = true;
  38527. return false;
  38528. }
  38529. });
  38530. }
  38531. if (disallowMoving) {
  38532. return false;
  38533. }
  38534. }
  38535. if (priv.moveByFreeze) {
  38536. priv.moveByFreeze = false;
  38537. }
  38538. }
  38539. /**
  38540. * Destroy plugin instance.
  38541. */
  38542. }, {
  38543. key: 'destroy',
  38544. value: function destroy() {
  38545. _get(ManualColumnFreeze.prototype.__proto__ || Object.getPrototypeOf(ManualColumnFreeze.prototype), 'destroy', this).call(this);
  38546. }
  38547. }]);
  38548. return ManualColumnFreeze;
  38549. }(_base2.default);
  38550. (0, _plugins.registerPlugin)('manualColumnFreeze', ManualColumnFreeze);
  38551. exports.default = ManualColumnFreeze;
  38552. /***/ }),
  38553. /* 329 */
  38554. /***/ (function(module, exports, __webpack_require__) {
  38555. "use strict";
  38556. exports.__esModule = true;
  38557. 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"); } }; }();
  38558. exports.default = freezeColumnItem;
  38559. var _constants = __webpack_require__(7);
  38560. var C = _interopRequireWildcard(_constants);
  38561. 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; } }
  38562. function freezeColumnItem(manualColumnFreezePlugin) {
  38563. return {
  38564. key: 'freeze_column',
  38565. name: function name() {
  38566. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_FREEZE_COLUMN);
  38567. },
  38568. callback: function callback(key, selected) {
  38569. var _selected = _slicedToArray(selected, 1),
  38570. selectedColumn = _selected[0].start.col;
  38571. manualColumnFreezePlugin.freezeColumn(selectedColumn);
  38572. this.render();
  38573. this.view.wt.wtOverlays.adjustElementsSize(true);
  38574. },
  38575. hidden: function hidden() {
  38576. var selection = this.getSelectedRange();
  38577. var hide = false;
  38578. if (selection === void 0) {
  38579. hide = true;
  38580. } else if (selection.length > 1) {
  38581. hide = true;
  38582. } else if (selection[0].from.col !== selection[0].to.col || selection[0].from.col <= this.getSettings().fixedColumnsLeft - 1) {
  38583. hide = true;
  38584. }
  38585. return hide;
  38586. }
  38587. };
  38588. }
  38589. /***/ }),
  38590. /* 330 */
  38591. /***/ (function(module, exports, __webpack_require__) {
  38592. "use strict";
  38593. exports.__esModule = true;
  38594. 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"); } }; }();
  38595. exports.default = unfreezeColumnItem;
  38596. var _constants = __webpack_require__(7);
  38597. var C = _interopRequireWildcard(_constants);
  38598. 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; } }
  38599. function unfreezeColumnItem(manualColumnFreezePlugin) {
  38600. return {
  38601. key: 'unfreeze_column',
  38602. name: function name() {
  38603. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_UNFREEZE_COLUMN);
  38604. },
  38605. callback: function callback(key, selected) {
  38606. var _selected = _slicedToArray(selected, 1),
  38607. selectedColumn = _selected[0].start.col;
  38608. manualColumnFreezePlugin.unfreezeColumn(selectedColumn);
  38609. this.render();
  38610. this.view.wt.wtOverlays.adjustElementsSize(true);
  38611. },
  38612. hidden: function hidden() {
  38613. var selection = this.getSelectedRange();
  38614. var hide = false;
  38615. if (selection === void 0) {
  38616. hide = true;
  38617. } else if (selection.length > 1) {
  38618. hide = true;
  38619. } else if (selection[0].from.col !== selection[0].to.col || selection[0].from.col >= this.getSettings().fixedColumnsLeft) {
  38620. hide = true;
  38621. }
  38622. return hide;
  38623. }
  38624. };
  38625. }
  38626. /***/ }),
  38627. /* 331 */
  38628. /***/ (function(module, exports) {
  38629. // removed by extract-text-webpack-plugin
  38630. /***/ }),
  38631. /* 332 */
  38632. /***/ (function(module, exports, __webpack_require__) {
  38633. "use strict";
  38634. exports.__esModule = true;
  38635. 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; }; }();
  38636. 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); } };
  38637. var _base = __webpack_require__(10);
  38638. var _base2 = _interopRequireDefault(_base);
  38639. var _pluginHooks = __webpack_require__(15);
  38640. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  38641. var _array = __webpack_require__(1);
  38642. var _element = __webpack_require__(0);
  38643. var _number = __webpack_require__(5);
  38644. var _eventManager = __webpack_require__(6);
  38645. var _eventManager2 = _interopRequireDefault(_eventManager);
  38646. var _plugins = __webpack_require__(8);
  38647. var _columnsMapper = __webpack_require__(333);
  38648. var _columnsMapper2 = _interopRequireDefault(_columnsMapper);
  38649. var _backlight = __webpack_require__(334);
  38650. var _backlight2 = _interopRequireDefault(_backlight);
  38651. var _guideline = __webpack_require__(335);
  38652. var _guideline2 = _interopRequireDefault(_guideline);
  38653. var _src = __webpack_require__(4);
  38654. __webpack_require__(336);
  38655. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  38656. 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); } }
  38657. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  38658. 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; }
  38659. 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; }
  38660. _pluginHooks2.default.getSingleton().register('beforeColumnMove');
  38661. _pluginHooks2.default.getSingleton().register('afterColumnMove');
  38662. _pluginHooks2.default.getSingleton().register('unmodifyCol');
  38663. var privatePool = new WeakMap();
  38664. var CSS_PLUGIN = 'ht__manualColumnMove';
  38665. var CSS_SHOW_UI = 'show-ui';
  38666. var CSS_ON_MOVING = 'on-moving--columns';
  38667. var CSS_AFTER_SELECTION = 'after-selection--columns';
  38668. /**
  38669. * @plugin ManualColumnMove
  38670. *
  38671. * @description
  38672. * This plugin allows to change columns order.
  38673. *
  38674. * API:
  38675. * - moveColumn - move single column to the new position.
  38676. * - moveColumns - move many columns (as an array of indexes) to the new position.
  38677. *
  38678. * If you want apply visual changes, you have to call manually the render() method on the instance of Handsontable.
  38679. *
  38680. * UI components:
  38681. * - backlight - highlight of selected columns.
  38682. * - guideline - line which shows where rows has been moved.
  38683. *
  38684. * @class ManualColumnMove
  38685. * @plugin ManualColumnMove
  38686. */
  38687. var ManualColumnMove = function (_BasePlugin) {
  38688. _inherits(ManualColumnMove, _BasePlugin);
  38689. function ManualColumnMove(hotInstance) {
  38690. _classCallCheck(this, ManualColumnMove);
  38691. /**
  38692. * Set up WeakMap of plugin to sharing private parameters;
  38693. */
  38694. var _this = _possibleConstructorReturn(this, (ManualColumnMove.__proto__ || Object.getPrototypeOf(ManualColumnMove)).call(this, hotInstance));
  38695. privatePool.set(_this, {
  38696. columnsToMove: [],
  38697. countCols: 0,
  38698. fixedColumns: 0,
  38699. pressed: void 0,
  38700. disallowMoving: void 0,
  38701. target: {
  38702. eventPageX: void 0,
  38703. coords: void 0,
  38704. TD: void 0,
  38705. col: void 0
  38706. }
  38707. });
  38708. /**
  38709. * List of last removed row indexes.
  38710. *
  38711. * @type {Array}
  38712. */
  38713. _this.removedColumns = [];
  38714. /**
  38715. * Object containing visual row indexes mapped to data source indexes.
  38716. *
  38717. * @type {RowsMapper}
  38718. */
  38719. _this.columnsMapper = new _columnsMapper2.default(_this);
  38720. /**
  38721. * Event Manager object.
  38722. *
  38723. * @type {Object}
  38724. */
  38725. _this.eventManager = new _eventManager2.default(_this);
  38726. /**
  38727. * Backlight UI object.
  38728. *
  38729. * @type {Object}
  38730. */
  38731. _this.backlight = new _backlight2.default(hotInstance);
  38732. /**
  38733. * Guideline UI object.
  38734. *
  38735. * @type {Object}
  38736. */
  38737. _this.guideline = new _guideline2.default(hotInstance);
  38738. return _this;
  38739. }
  38740. /**
  38741. * Check if plugin is enabled.
  38742. *
  38743. * @returns {Boolean}
  38744. */
  38745. _createClass(ManualColumnMove, [{
  38746. key: 'isEnabled',
  38747. value: function isEnabled() {
  38748. return !!this.hot.getSettings().manualColumnMove;
  38749. }
  38750. /**
  38751. * Enable the plugin.
  38752. */
  38753. }, {
  38754. key: 'enablePlugin',
  38755. value: function enablePlugin() {
  38756. var _this2 = this;
  38757. if (this.enabled) {
  38758. return;
  38759. }
  38760. this.addHook('beforeOnCellMouseDown', function (event, coords, TD, blockCalculations) {
  38761. return _this2.onBeforeOnCellMouseDown(event, coords, TD, blockCalculations);
  38762. });
  38763. this.addHook('beforeOnCellMouseOver', function (event, coords, TD, blockCalculations) {
  38764. return _this2.onBeforeOnCellMouseOver(event, coords, TD, blockCalculations);
  38765. });
  38766. this.addHook('afterScrollVertically', function () {
  38767. return _this2.onAfterScrollVertically();
  38768. });
  38769. this.addHook('modifyCol', function (row, source) {
  38770. return _this2.onModifyCol(row, source);
  38771. });
  38772. this.addHook('beforeRemoveCol', function (index, amount) {
  38773. return _this2.onBeforeRemoveCol(index, amount);
  38774. });
  38775. this.addHook('afterRemoveCol', function () {
  38776. return _this2.onAfterRemoveCol();
  38777. });
  38778. this.addHook('afterCreateCol', function (index, amount) {
  38779. return _this2.onAfterCreateCol(index, amount);
  38780. });
  38781. this.addHook('afterLoadData', function () {
  38782. return _this2.onAfterLoadData();
  38783. });
  38784. this.addHook('unmodifyCol', function (column) {
  38785. return _this2.onUnmodifyCol(column);
  38786. });
  38787. this.registerEvents();
  38788. // TODO: move adding plugin classname to BasePlugin.
  38789. (0, _element.addClass)(this.hot.rootElement, CSS_PLUGIN);
  38790. _get(ManualColumnMove.prototype.__proto__ || Object.getPrototypeOf(ManualColumnMove.prototype), 'enablePlugin', this).call(this);
  38791. }
  38792. /**
  38793. * Updates the plugin to use the latest options you have specified.
  38794. */
  38795. }, {
  38796. key: 'updatePlugin',
  38797. value: function updatePlugin() {
  38798. this.disablePlugin();
  38799. this.enablePlugin();
  38800. this.onAfterPluginsInitialized();
  38801. _get(ManualColumnMove.prototype.__proto__ || Object.getPrototypeOf(ManualColumnMove.prototype), 'updatePlugin', this).call(this);
  38802. }
  38803. /**
  38804. * Disable plugin for this Handsontable instance.
  38805. */
  38806. }, {
  38807. key: 'disablePlugin',
  38808. value: function disablePlugin() {
  38809. var pluginSettings = this.hot.getSettings().manualColumnMove;
  38810. if (Array.isArray(pluginSettings)) {
  38811. this.columnsMapper.clearMap();
  38812. }
  38813. (0, _element.removeClass)(this.hot.rootElement, CSS_PLUGIN);
  38814. this.unregisterEvents();
  38815. this.backlight.destroy();
  38816. this.guideline.destroy();
  38817. _get(ManualColumnMove.prototype.__proto__ || Object.getPrototypeOf(ManualColumnMove.prototype), 'disablePlugin', this).call(this);
  38818. }
  38819. /**
  38820. * Move a single column.
  38821. *
  38822. * @param {Number} column Visual column index to be moved.
  38823. * @param {Number} target Visual column index being a target for the moved column.
  38824. */
  38825. }, {
  38826. key: 'moveColumn',
  38827. value: function moveColumn(column, target) {
  38828. this.moveColumns([column], target);
  38829. }
  38830. /**
  38831. * Move multiple columns.
  38832. *
  38833. * @param {Array} columns Array of visual column indexes to be moved.
  38834. * @param {Number} target Visual column index being a target for the moved columns.
  38835. */
  38836. }, {
  38837. key: 'moveColumns',
  38838. value: function moveColumns(columns, target) {
  38839. var _this3 = this;
  38840. var visualColumns = [].concat(_toConsumableArray(columns));
  38841. var priv = privatePool.get(this);
  38842. var beforeColumnHook = this.hot.runHooks('beforeColumnMove', visualColumns, target);
  38843. priv.disallowMoving = !beforeColumnHook;
  38844. if (beforeColumnHook !== false) {
  38845. // first we need to rewrite an visual indexes to physical for save reference after move
  38846. (0, _array.arrayEach)(columns, function (column, index, array) {
  38847. array[index] = _this3.columnsMapper.getValueByIndex(column);
  38848. });
  38849. // next, when we have got an physical indexes, we can move columns
  38850. (0, _array.arrayEach)(columns, function (column, index) {
  38851. var actualPosition = _this3.columnsMapper.getIndexByValue(column);
  38852. if (actualPosition !== target) {
  38853. _this3.columnsMapper.moveColumn(actualPosition, target + index);
  38854. }
  38855. });
  38856. // after moving we have to clear columnsMapper from null entries
  38857. this.columnsMapper.clearNull();
  38858. }
  38859. this.hot.runHooks('afterColumnMove', visualColumns, target);
  38860. }
  38861. /**
  38862. * Correct the cell selection after the move action. Fired only when action was made with a mouse.
  38863. * That means that changing the column order using the API won't correct the selection.
  38864. *
  38865. * @private
  38866. * @param {Number} startColumn Visual column index for the start of the selection.
  38867. * @param {Number} endColumn Visual column index for the end of the selection.
  38868. */
  38869. }, {
  38870. key: 'changeSelection',
  38871. value: function changeSelection(startColumn, endColumn) {
  38872. this.hot.selectColumns(startColumn, endColumn);
  38873. }
  38874. /**
  38875. * Get the sum of the widths of columns in the provided range.
  38876. *
  38877. * @private
  38878. * @param {Number} from Visual column index.
  38879. * @param {Number} to Visual column index.
  38880. * @returns {Number}
  38881. */
  38882. }, {
  38883. key: 'getColumnsWidth',
  38884. value: function getColumnsWidth(from, to) {
  38885. var width = 0;
  38886. for (var i = from; i < to; i++) {
  38887. var columnWidth = 0;
  38888. if (i < 0) {
  38889. columnWidth = this.hot.view.wt.wtViewport.getRowHeaderWidth() || 0;
  38890. } else {
  38891. columnWidth = this.hot.view.wt.wtTable.getStretchedColumnWidth(i) || 0;
  38892. }
  38893. width += columnWidth;
  38894. }
  38895. return width;
  38896. }
  38897. /**
  38898. * Load initial settings when persistent state is saved or when plugin was initialized as an array.
  38899. *
  38900. * @private
  38901. */
  38902. }, {
  38903. key: 'initialSettings',
  38904. value: function initialSettings() {
  38905. var pluginSettings = this.hot.getSettings().manualColumnMove;
  38906. if (Array.isArray(pluginSettings)) {
  38907. this.moveColumns(pluginSettings, 0);
  38908. } else if (pluginSettings !== void 0) {
  38909. this.persistentStateLoad();
  38910. }
  38911. }
  38912. /**
  38913. * Check if the provided column is in the fixedColumnsLeft section.
  38914. *
  38915. * @private
  38916. * @param {Number} column Visual column index to check.
  38917. * @returns {Boolean}
  38918. */
  38919. }, {
  38920. key: 'isFixedColumnsLeft',
  38921. value: function isFixedColumnsLeft(column) {
  38922. return column < this.hot.getSettings().fixedColumnsLeft;
  38923. }
  38924. /**
  38925. * Save the manual column positions to the persistent state.
  38926. *
  38927. * @private
  38928. */
  38929. }, {
  38930. key: 'persistentStateSave',
  38931. value: function persistentStateSave() {
  38932. this.hot.runHooks('persistentStateSave', 'manualColumnMove', this.columnsMapper._arrayMap);
  38933. }
  38934. /**
  38935. * Load the manual column positions from the persistent state.
  38936. *
  38937. * @private
  38938. */
  38939. }, {
  38940. key: 'persistentStateLoad',
  38941. value: function persistentStateLoad() {
  38942. var storedState = {};
  38943. this.hot.runHooks('persistentStateLoad', 'manualColumnMove', storedState);
  38944. if (storedState.value) {
  38945. this.columnsMapper._arrayMap = storedState.value;
  38946. }
  38947. }
  38948. /**
  38949. * Prepare array of indexes based on actual selection.
  38950. *
  38951. * @private
  38952. * @returns {Array}
  38953. */
  38954. }, {
  38955. key: 'prepareColumnsToMoving',
  38956. value: function prepareColumnsToMoving(start, end) {
  38957. var selectedColumns = [];
  38958. (0, _number.rangeEach)(start, end, function (i) {
  38959. selectedColumns.push(i);
  38960. });
  38961. return selectedColumns;
  38962. }
  38963. /**
  38964. * Update the UI visual position.
  38965. *
  38966. * @private
  38967. */
  38968. }, {
  38969. key: 'refreshPositions',
  38970. value: function refreshPositions() {
  38971. var priv = privatePool.get(this);
  38972. var firstVisible = this.hot.view.wt.wtTable.getFirstVisibleColumn();
  38973. var lastVisible = this.hot.view.wt.wtTable.getLastVisibleColumn();
  38974. var wtTable = this.hot.view.wt.wtTable;
  38975. var scrollableElement = this.hot.view.wt.wtOverlays.scrollableElement;
  38976. var scrollLeft = typeof scrollableElement.scrollX === 'number' ? scrollableElement.scrollX : scrollableElement.scrollLeft;
  38977. var tdOffsetLeft = this.hot.view.THEAD.offsetLeft + this.getColumnsWidth(0, priv.coordsColumn);
  38978. var mouseOffsetLeft = priv.target.eventPageX - (priv.rootElementOffset - (scrollableElement.scrollX === void 0 ? scrollLeft : 0));
  38979. var hiderWidth = wtTable.hider.offsetWidth;
  38980. var tbodyOffsetLeft = wtTable.TBODY.offsetLeft;
  38981. var backlightElemMarginLeft = this.backlight.getOffset().left;
  38982. var backlightElemWidth = this.backlight.getSize().width;
  38983. var rowHeaderWidth = 0;
  38984. if (priv.rootElementOffset + wtTable.holder.offsetWidth + scrollLeft < priv.target.eventPageX) {
  38985. if (priv.coordsColumn < priv.countCols) {
  38986. priv.coordsColumn++;
  38987. }
  38988. }
  38989. if (priv.hasRowHeaders) {
  38990. rowHeaderWidth = this.hot.view.wt.wtOverlays.leftOverlay.clone.wtTable.getColumnHeader(-1).offsetWidth;
  38991. }
  38992. if (this.isFixedColumnsLeft(priv.coordsColumn)) {
  38993. tdOffsetLeft += scrollLeft;
  38994. }
  38995. tdOffsetLeft += rowHeaderWidth;
  38996. if (priv.coordsColumn < 0) {
  38997. // if hover on rowHeader
  38998. if (priv.fixedColumns > 0) {
  38999. priv.target.col = 0;
  39000. } else {
  39001. priv.target.col = firstVisible > 0 ? firstVisible - 1 : firstVisible;
  39002. }
  39003. } else if (priv.target.TD.offsetWidth / 2 + tdOffsetLeft <= mouseOffsetLeft) {
  39004. var newCoordsCol = priv.coordsColumn >= priv.countCols ? priv.countCols - 1 : priv.coordsColumn;
  39005. // if hover on right part of TD
  39006. priv.target.col = newCoordsCol + 1;
  39007. // unfortunately first column is bigger than rest
  39008. tdOffsetLeft += priv.target.TD.offsetWidth;
  39009. if (priv.target.col > lastVisible) {
  39010. this.hot.scrollViewportTo(void 0, lastVisible + 1, void 0, true);
  39011. }
  39012. } else {
  39013. // elsewhere on table
  39014. priv.target.col = priv.coordsColumn;
  39015. if (priv.target.col <= firstVisible && priv.target.col >= priv.fixedColumns) {
  39016. this.hot.scrollViewportTo(void 0, firstVisible - 1);
  39017. }
  39018. }
  39019. if (priv.target.col <= firstVisible && priv.target.col >= priv.fixedColumns) {
  39020. this.hot.scrollViewportTo(void 0, firstVisible - 1);
  39021. }
  39022. var backlightLeft = mouseOffsetLeft;
  39023. var guidelineLeft = tdOffsetLeft;
  39024. if (mouseOffsetLeft + backlightElemWidth + backlightElemMarginLeft >= hiderWidth) {
  39025. // prevent display backlight on the right side of the table
  39026. backlightLeft = hiderWidth - backlightElemWidth - backlightElemMarginLeft;
  39027. } else if (mouseOffsetLeft + backlightElemMarginLeft < tbodyOffsetLeft + rowHeaderWidth) {
  39028. // prevent display backlight on the left side of the table
  39029. backlightLeft = tbodyOffsetLeft + rowHeaderWidth + Math.abs(backlightElemMarginLeft);
  39030. }
  39031. if (tdOffsetLeft >= hiderWidth - 1) {
  39032. // prevent display guideline outside the table
  39033. guidelineLeft = hiderWidth - 1;
  39034. } else if (guidelineLeft === 0) {
  39035. // guideline has got `margin-left: -1px` as default
  39036. guidelineLeft = 1;
  39037. } else if (scrollableElement.scrollX !== void 0 && priv.coordsColumn < priv.fixedColumns) {
  39038. guidelineLeft -= priv.rootElementOffset <= scrollableElement.scrollX ? priv.rootElementOffset : 0;
  39039. }
  39040. this.backlight.setPosition(null, backlightLeft);
  39041. this.guideline.setPosition(null, guidelineLeft);
  39042. }
  39043. /**
  39044. * This method checks arrayMap from columnsMapper and updates the columnsMapper if it's necessary.
  39045. *
  39046. * @private
  39047. */
  39048. }, {
  39049. key: 'updateColumnsMapper',
  39050. value: function updateColumnsMapper() {
  39051. var countCols = this.hot.countSourceCols();
  39052. var columnsMapperLen = this.columnsMapper._arrayMap.length;
  39053. if (columnsMapperLen === 0) {
  39054. this.columnsMapper.createMap(countCols || this.hot.getSettings().startCols);
  39055. } else if (columnsMapperLen < countCols) {
  39056. var diff = countCols - columnsMapperLen;
  39057. this.columnsMapper.insertItems(columnsMapperLen, diff);
  39058. } else if (columnsMapperLen > countCols) {
  39059. var maxIndex = countCols - 1;
  39060. var columnsToRemove = [];
  39061. (0, _array.arrayEach)(this.columnsMapper._arrayMap, function (value, index) {
  39062. if (value > maxIndex) {
  39063. columnsToRemove.push(index);
  39064. }
  39065. });
  39066. this.columnsMapper.removeItems(columnsToRemove);
  39067. }
  39068. }
  39069. /**
  39070. * Bind the events used by the plugin.
  39071. *
  39072. * @private
  39073. */
  39074. }, {
  39075. key: 'registerEvents',
  39076. value: function registerEvents() {
  39077. var _this4 = this;
  39078. this.eventManager.addEventListener(document.documentElement, 'mousemove', function (event) {
  39079. return _this4.onMouseMove(event);
  39080. });
  39081. this.eventManager.addEventListener(document.documentElement, 'mouseup', function () {
  39082. return _this4.onMouseUp();
  39083. });
  39084. }
  39085. /**
  39086. * Unbind the events used by the plugin.
  39087. *
  39088. * @private
  39089. */
  39090. }, {
  39091. key: 'unregisterEvents',
  39092. value: function unregisterEvents() {
  39093. this.eventManager.clear();
  39094. }
  39095. /**
  39096. * Change the behavior of selection / dragging.
  39097. *
  39098. * @private
  39099. * @param {MouseEvent} event `mousedown` event properties.
  39100. * @param {CellCoords} coords Visual cell coordinates where was fired event.
  39101. * @param {HTMLElement} TD Cell represented as HTMLElement.
  39102. * @param {Object} blockCalculations Object which contains information about blockCalculation for row, column or cells.
  39103. */
  39104. }, {
  39105. key: 'onBeforeOnCellMouseDown',
  39106. value: function onBeforeOnCellMouseDown(event, coords, TD, blockCalculations) {
  39107. var wtTable = this.hot.view.wt.wtTable;
  39108. var isHeaderSelection = this.hot.selection.isSelectedByColumnHeader();
  39109. var selection = this.hot.getSelectedRangeLast();
  39110. var priv = privatePool.get(this);
  39111. var isSortingElement = event.realTarget.className.indexOf('columnSorting') > -1;
  39112. if (!selection || !isHeaderSelection || priv.pressed || event.button !== 0 || isSortingElement) {
  39113. priv.pressed = false;
  39114. priv.columnsToMove.length = 0;
  39115. (0, _element.removeClass)(this.hot.rootElement, [CSS_ON_MOVING, CSS_SHOW_UI]);
  39116. return;
  39117. }
  39118. var guidelineIsNotReady = this.guideline.isBuilt() && !this.guideline.isAppended();
  39119. var backlightIsNotReady = this.backlight.isBuilt() && !this.backlight.isAppended();
  39120. if (guidelineIsNotReady && backlightIsNotReady) {
  39121. this.guideline.appendTo(wtTable.hider);
  39122. this.backlight.appendTo(wtTable.hider);
  39123. }
  39124. var from = selection.from,
  39125. to = selection.to;
  39126. var start = Math.min(from.col, to.col);
  39127. var end = Math.max(from.col, to.col);
  39128. if (coords.row < 0 && coords.col >= start && coords.col <= end) {
  39129. blockCalculations.column = true;
  39130. priv.pressed = true;
  39131. priv.target.eventPageX = event.pageX;
  39132. priv.coordsColumn = coords.col;
  39133. priv.target.TD = TD;
  39134. priv.target.col = coords.col;
  39135. priv.columnsToMove = this.prepareColumnsToMoving(start, end);
  39136. priv.hasRowHeaders = !!this.hot.getSettings().rowHeaders;
  39137. priv.countCols = this.hot.countCols();
  39138. priv.fixedColumns = this.hot.getSettings().fixedColumnsLeft;
  39139. priv.rootElementOffset = (0, _element.offset)(this.hot.rootElement).left;
  39140. var countColumnsFrom = priv.hasRowHeaders ? -1 : 0;
  39141. var topPos = wtTable.holder.scrollTop + wtTable.getColumnHeaderHeight(0) + 1;
  39142. var fixedColumns = coords.col < priv.fixedColumns;
  39143. var scrollableElement = this.hot.view.wt.wtOverlays.scrollableElement;
  39144. var wrapperIsWindow = scrollableElement.scrollX ? scrollableElement.scrollX - priv.rootElementOffset : 0;
  39145. var mouseOffset = event.layerX - (fixedColumns ? wrapperIsWindow : 0);
  39146. var leftOffset = Math.abs(this.getColumnsWidth(start, coords.col) + mouseOffset);
  39147. this.backlight.setPosition(topPos, this.getColumnsWidth(countColumnsFrom, start) + leftOffset);
  39148. this.backlight.setSize(this.getColumnsWidth(start, end + 1), wtTable.hider.offsetHeight - topPos);
  39149. this.backlight.setOffset(null, leftOffset * -1);
  39150. (0, _element.addClass)(this.hot.rootElement, CSS_ON_MOVING);
  39151. } else {
  39152. (0, _element.removeClass)(this.hot.rootElement, CSS_AFTER_SELECTION);
  39153. priv.pressed = false;
  39154. priv.columnsToMove.length = 0;
  39155. }
  39156. }
  39157. /**
  39158. * 'mouseMove' event callback. Fired when pointer move on document.documentElement.
  39159. *
  39160. * @private
  39161. * @param {MouseEvent} event `mousemove` event properties.
  39162. */
  39163. }, {
  39164. key: 'onMouseMove',
  39165. value: function onMouseMove(event) {
  39166. var priv = privatePool.get(this);
  39167. if (!priv.pressed) {
  39168. return;
  39169. }
  39170. // callback for browser which doesn't supports CSS pointer-event: none
  39171. if (event.realTarget === this.backlight.element) {
  39172. var width = this.backlight.getSize().width;
  39173. this.backlight.setSize(0);
  39174. setTimeout(function () {
  39175. this.backlight.setPosition(width);
  39176. });
  39177. }
  39178. priv.target.eventPageX = event.pageX;
  39179. this.refreshPositions();
  39180. }
  39181. /**
  39182. * 'beforeOnCellMouseOver' hook callback. Fired when pointer was over cell.
  39183. *
  39184. * @private
  39185. * @param {MouseEvent} event `mouseover` event properties.
  39186. * @param {CellCoords} coords Visual cell coordinates where was fired event.
  39187. * @param {HTMLElement} TD Cell represented as HTMLElement.
  39188. * @param {Object} blockCalculations Object which contains information about blockCalculation for row, column or cells.
  39189. */
  39190. }, {
  39191. key: 'onBeforeOnCellMouseOver',
  39192. value: function onBeforeOnCellMouseOver(event, coords, TD, blockCalculations) {
  39193. var selectedRange = this.hot.getSelectedRangeLast();
  39194. var priv = privatePool.get(this);
  39195. if (!selectedRange || !priv.pressed) {
  39196. return;
  39197. }
  39198. if (priv.columnsToMove.indexOf(coords.col) > -1) {
  39199. (0, _element.removeClass)(this.hot.rootElement, CSS_SHOW_UI);
  39200. } else {
  39201. (0, _element.addClass)(this.hot.rootElement, CSS_SHOW_UI);
  39202. }
  39203. blockCalculations.row = true;
  39204. blockCalculations.column = true;
  39205. blockCalculations.cell = true;
  39206. priv.coordsColumn = coords.col;
  39207. priv.target.TD = TD;
  39208. }
  39209. /**
  39210. * `onMouseUp` hook callback.
  39211. *
  39212. * @private
  39213. */
  39214. }, {
  39215. key: 'onMouseUp',
  39216. value: function onMouseUp() {
  39217. var priv = privatePool.get(this);
  39218. priv.coordsColumn = void 0;
  39219. priv.pressed = false;
  39220. priv.backlightWidth = 0;
  39221. (0, _element.removeClass)(this.hot.rootElement, [CSS_ON_MOVING, CSS_SHOW_UI, CSS_AFTER_SELECTION]);
  39222. if (this.hot.selection.isSelectedByColumnHeader()) {
  39223. (0, _element.addClass)(this.hot.rootElement, CSS_AFTER_SELECTION);
  39224. }
  39225. if (priv.columnsToMove.length < 1 || priv.target.col === void 0 || priv.columnsToMove.indexOf(priv.target.col) > -1) {
  39226. return;
  39227. }
  39228. this.moveColumns(priv.columnsToMove, priv.target.col);
  39229. this.persistentStateSave();
  39230. this.hot.render();
  39231. this.hot.view.wt.wtOverlays.adjustElementsSize(true);
  39232. if (!priv.disallowMoving) {
  39233. var selectionStart = this.columnsMapper.getIndexByValue(priv.columnsToMove[0]);
  39234. var selectionEnd = this.columnsMapper.getIndexByValue(priv.columnsToMove[priv.columnsToMove.length - 1]);
  39235. this.changeSelection(selectionStart, selectionEnd);
  39236. }
  39237. priv.columnsToMove.length = 0;
  39238. }
  39239. /**
  39240. * `afterScrollHorizontally` hook callback. Fired the table was scrolled horizontally.
  39241. *
  39242. * @private
  39243. */
  39244. }, {
  39245. key: 'onAfterScrollVertically',
  39246. value: function onAfterScrollVertically() {
  39247. var wtTable = this.hot.view.wt.wtTable;
  39248. var headerHeight = wtTable.getColumnHeaderHeight(0) + 1;
  39249. var scrollTop = wtTable.holder.scrollTop;
  39250. var posTop = headerHeight + scrollTop;
  39251. this.backlight.setPosition(posTop);
  39252. this.backlight.setSize(null, wtTable.hider.offsetHeight - posTop);
  39253. }
  39254. /**
  39255. * `afterCreateCol` hook callback.
  39256. *
  39257. * @private
  39258. * @param {Number} index Visual index of the created column.
  39259. * @param {Number} amount Amount of created columns.
  39260. */
  39261. }, {
  39262. key: 'onAfterCreateCol',
  39263. value: function onAfterCreateCol(index, amount) {
  39264. this.columnsMapper.shiftItems(index, amount);
  39265. }
  39266. /**
  39267. * On before remove column listener.
  39268. *
  39269. * @private
  39270. * @param {Number} index Visual column index.
  39271. * @param {Number} amount Defines how many columns removed.
  39272. */
  39273. }, {
  39274. key: 'onBeforeRemoveCol',
  39275. value: function onBeforeRemoveCol(index, amount) {
  39276. var _this5 = this;
  39277. this.removedColumns.length = 0;
  39278. if (index !== false) {
  39279. // Collect physical row index.
  39280. (0, _number.rangeEach)(index, index + amount - 1, function (removedIndex) {
  39281. _this5.removedColumns.push(_this5.hot.runHooks('modifyCol', removedIndex, _this5.pluginName));
  39282. });
  39283. }
  39284. }
  39285. /**
  39286. * `afterRemoveCol` hook callback.
  39287. *
  39288. * @private
  39289. */
  39290. }, {
  39291. key: 'onAfterRemoveCol',
  39292. value: function onAfterRemoveCol() {
  39293. this.columnsMapper.unshiftItems(this.removedColumns);
  39294. }
  39295. /**
  39296. * `afterLoadData` hook callback.
  39297. *
  39298. * @private
  39299. */
  39300. }, {
  39301. key: 'onAfterLoadData',
  39302. value: function onAfterLoadData() {
  39303. this.updateColumnsMapper();
  39304. }
  39305. /**
  39306. * 'modifyRow' hook callback.
  39307. *
  39308. * @private
  39309. * @param {Number} column Visual column index.
  39310. * @returns {Number} Physical column index.
  39311. */
  39312. }, {
  39313. key: 'onModifyCol',
  39314. value: function onModifyCol(column, source) {
  39315. if (source !== this.pluginName) {
  39316. // ugly fix for try to insert new, needed columns after pasting data
  39317. var columnInMapper = this.columnsMapper.getValueByIndex(column);
  39318. column = columnInMapper === null ? column : columnInMapper;
  39319. }
  39320. return column;
  39321. }
  39322. /**
  39323. * 'unmodifyCol' hook callback.
  39324. *
  39325. * @private
  39326. * @param {Number} column Physical column index.
  39327. * @returns {Number} Visual column index.
  39328. */
  39329. }, {
  39330. key: 'onUnmodifyCol',
  39331. value: function onUnmodifyCol(column) {
  39332. var indexInMapper = this.columnsMapper.getIndexByValue(column);
  39333. return indexInMapper === null ? column : indexInMapper;
  39334. }
  39335. /**
  39336. * `afterPluginsInitialized` hook callback.
  39337. *
  39338. * @private
  39339. */
  39340. }, {
  39341. key: 'onAfterPluginsInitialized',
  39342. value: function onAfterPluginsInitialized() {
  39343. this.updateColumnsMapper();
  39344. this.initialSettings();
  39345. this.backlight.build();
  39346. this.guideline.build();
  39347. }
  39348. /**
  39349. * Destroy plugin instance.
  39350. */
  39351. }, {
  39352. key: 'destroy',
  39353. value: function destroy() {
  39354. this.backlight.destroy();
  39355. this.guideline.destroy();
  39356. _get(ManualColumnMove.prototype.__proto__ || Object.getPrototypeOf(ManualColumnMove.prototype), 'destroy', this).call(this);
  39357. }
  39358. }]);
  39359. return ManualColumnMove;
  39360. }(_base2.default);
  39361. (0, _plugins.registerPlugin)('ManualColumnMove', ManualColumnMove);
  39362. exports.default = ManualColumnMove;
  39363. /***/ }),
  39364. /* 333 */
  39365. /***/ (function(module, exports, __webpack_require__) {
  39366. "use strict";
  39367. exports.__esModule = true;
  39368. 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; }; }();
  39369. var _arrayMapper = __webpack_require__(201);
  39370. var _arrayMapper2 = _interopRequireDefault(_arrayMapper);
  39371. var _array = __webpack_require__(1);
  39372. var _object = __webpack_require__(2);
  39373. var _number = __webpack_require__(5);
  39374. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  39375. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  39376. /**
  39377. * @class ColumnsMapper
  39378. * @plugin ManualColumnMove
  39379. */
  39380. var ColumnsMapper = function () {
  39381. function ColumnsMapper(manualColumnMove) {
  39382. _classCallCheck(this, ColumnsMapper);
  39383. /**
  39384. * Instance of ManualColumnMove plugin.
  39385. *
  39386. * @type {ManualColumnMove}
  39387. */
  39388. this.manualColumnMove = manualColumnMove;
  39389. }
  39390. /**
  39391. * Reset current map array and create new one.
  39392. *
  39393. * @param {Number} [length] Custom generated map length.
  39394. */
  39395. _createClass(ColumnsMapper, [{
  39396. key: 'createMap',
  39397. value: function createMap(length) {
  39398. var _this = this;
  39399. var originLength = length === void 0 ? this._arrayMap.length : length;
  39400. this._arrayMap.length = 0;
  39401. (0, _number.rangeEach)(originLength - 1, function (itemIndex) {
  39402. _this._arrayMap[itemIndex] = itemIndex;
  39403. });
  39404. }
  39405. /**
  39406. * Destroy class.
  39407. */
  39408. }, {
  39409. key: 'destroy',
  39410. value: function destroy() {
  39411. this._arrayMap = null;
  39412. }
  39413. /**
  39414. * Moving elements in columnsMapper.
  39415. *
  39416. * @param {Number} from Column index to move.
  39417. * @param {Number} to Target index.
  39418. */
  39419. }, {
  39420. key: 'moveColumn',
  39421. value: function moveColumn(from, to) {
  39422. var indexToMove = this._arrayMap[from];
  39423. this._arrayMap[from] = null;
  39424. this._arrayMap.splice(to, 0, indexToMove);
  39425. }
  39426. /**
  39427. * Clearing arrayMap from `null` entries.
  39428. */
  39429. }, {
  39430. key: 'clearNull',
  39431. value: function clearNull() {
  39432. this._arrayMap = (0, _array.arrayFilter)(this._arrayMap, function (i) {
  39433. return i !== null;
  39434. });
  39435. }
  39436. }]);
  39437. return ColumnsMapper;
  39438. }();
  39439. (0, _object.mixin)(ColumnsMapper, _arrayMapper2.default);
  39440. exports.default = ColumnsMapper;
  39441. /***/ }),
  39442. /* 334 */
  39443. /***/ (function(module, exports, __webpack_require__) {
  39444. "use strict";
  39445. exports.__esModule = true;
  39446. 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; }; }();
  39447. 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); } };
  39448. var _base = __webpack_require__(202);
  39449. var _base2 = _interopRequireDefault(_base);
  39450. var _element = __webpack_require__(0);
  39451. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  39452. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  39453. 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; }
  39454. 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; }
  39455. var CSS_CLASSNAME = 'ht__manualColumnMove--backlight';
  39456. /**
  39457. * @class BacklightUI
  39458. * @util
  39459. */
  39460. var BacklightUI = function (_BaseUI) {
  39461. _inherits(BacklightUI, _BaseUI);
  39462. function BacklightUI() {
  39463. _classCallCheck(this, BacklightUI);
  39464. return _possibleConstructorReturn(this, (BacklightUI.__proto__ || Object.getPrototypeOf(BacklightUI)).apply(this, arguments));
  39465. }
  39466. _createClass(BacklightUI, [{
  39467. key: 'build',
  39468. /**
  39469. * Custom className on build process.
  39470. */
  39471. value: function build() {
  39472. _get(BacklightUI.prototype.__proto__ || Object.getPrototypeOf(BacklightUI.prototype), 'build', this).call(this);
  39473. (0, _element.addClass)(this._element, CSS_CLASSNAME);
  39474. }
  39475. }]);
  39476. return BacklightUI;
  39477. }(_base2.default);
  39478. exports.default = BacklightUI;
  39479. /***/ }),
  39480. /* 335 */
  39481. /***/ (function(module, exports, __webpack_require__) {
  39482. "use strict";
  39483. exports.__esModule = true;
  39484. 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; }; }();
  39485. 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); } };
  39486. var _base = __webpack_require__(202);
  39487. var _base2 = _interopRequireDefault(_base);
  39488. var _element = __webpack_require__(0);
  39489. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  39490. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  39491. 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; }
  39492. 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; }
  39493. var CSS_CLASSNAME = 'ht__manualColumnMove--guideline';
  39494. /**
  39495. * @class GuidelineUI
  39496. * @util
  39497. */
  39498. var GuidelineUI = function (_BaseUI) {
  39499. _inherits(GuidelineUI, _BaseUI);
  39500. function GuidelineUI() {
  39501. _classCallCheck(this, GuidelineUI);
  39502. return _possibleConstructorReturn(this, (GuidelineUI.__proto__ || Object.getPrototypeOf(GuidelineUI)).apply(this, arguments));
  39503. }
  39504. _createClass(GuidelineUI, [{
  39505. key: 'build',
  39506. /**
  39507. * Custom className on build process.
  39508. */
  39509. value: function build() {
  39510. _get(GuidelineUI.prototype.__proto__ || Object.getPrototypeOf(GuidelineUI.prototype), 'build', this).call(this);
  39511. (0, _element.addClass)(this._element, CSS_CLASSNAME);
  39512. }
  39513. }]);
  39514. return GuidelineUI;
  39515. }(_base2.default);
  39516. exports.default = GuidelineUI;
  39517. /***/ }),
  39518. /* 336 */
  39519. /***/ (function(module, exports) {
  39520. // removed by extract-text-webpack-plugin
  39521. /***/ }),
  39522. /* 337 */
  39523. /***/ (function(module, exports, __webpack_require__) {
  39524. "use strict";
  39525. exports.__esModule = true;
  39526. 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; }; }();
  39527. 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); } };
  39528. var _base = __webpack_require__(10);
  39529. var _base2 = _interopRequireDefault(_base);
  39530. var _element = __webpack_require__(0);
  39531. var _eventManager = __webpack_require__(6);
  39532. var _eventManager2 = _interopRequireDefault(_eventManager);
  39533. var _event = __webpack_require__(12);
  39534. var _array = __webpack_require__(1);
  39535. var _number = __webpack_require__(5);
  39536. var _plugins = __webpack_require__(8);
  39537. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  39538. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  39539. 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; }
  39540. 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; }
  39541. // Developer note! Whenever you make a change in this file, make an analogous change in manualRowResize.js
  39542. /**
  39543. * @description
  39544. * ManualColumnResize Plugin.
  39545. *
  39546. * Has 2 UI components:
  39547. * - handle - the draggable element that sets the desired width of the column.
  39548. * - guide - the helper guide that shows the desired width as a vertical guide.
  39549. *
  39550. * @plugin ManualColumnResize
  39551. */
  39552. var ManualColumnResize = function (_BasePlugin) {
  39553. _inherits(ManualColumnResize, _BasePlugin);
  39554. function ManualColumnResize(hotInstance) {
  39555. _classCallCheck(this, ManualColumnResize);
  39556. var _this = _possibleConstructorReturn(this, (ManualColumnResize.__proto__ || Object.getPrototypeOf(ManualColumnResize)).call(this, hotInstance));
  39557. _this.currentTH = null;
  39558. _this.currentCol = null;
  39559. _this.selectedCols = [];
  39560. _this.currentWidth = null;
  39561. _this.newSize = null;
  39562. _this.startY = null;
  39563. _this.startWidth = null;
  39564. _this.startOffset = null;
  39565. _this.handle = document.createElement('DIV');
  39566. _this.guide = document.createElement('DIV');
  39567. _this.eventManager = new _eventManager2.default(_this);
  39568. _this.pressed = null;
  39569. _this.dblclick = 0;
  39570. _this.autoresizeTimeout = null;
  39571. _this.manualColumnWidths = [];
  39572. (0, _element.addClass)(_this.handle, 'manualColumnResizer');
  39573. (0, _element.addClass)(_this.guide, 'manualColumnResizerGuide');
  39574. return _this;
  39575. }
  39576. /**
  39577. * Check if the plugin is enabled in the handsontable settings.
  39578. *
  39579. * @returns {Boolean}
  39580. */
  39581. _createClass(ManualColumnResize, [{
  39582. key: 'isEnabled',
  39583. value: function isEnabled() {
  39584. return this.hot.getSettings().manualColumnResize;
  39585. }
  39586. /**
  39587. * Enable plugin for this Handsontable instance.
  39588. */
  39589. }, {
  39590. key: 'enablePlugin',
  39591. value: function enablePlugin() {
  39592. var _this2 = this;
  39593. if (this.enabled) {
  39594. return;
  39595. }
  39596. this.manualColumnWidths = [];
  39597. var initialColumnWidth = this.hot.getSettings().manualColumnResize;
  39598. var loadedManualColumnWidths = this.loadManualColumnWidths();
  39599. this.addHook('modifyColWidth', function (width, col) {
  39600. return _this2.onModifyColWidth(width, col);
  39601. });
  39602. this.addHook('beforeStretchingColumnWidth', function (stretchedWidth, column) {
  39603. return _this2.onBeforeStretchingColumnWidth(stretchedWidth, column);
  39604. });
  39605. this.addHook('beforeColumnResize', function (currentColumn, newSize, isDoubleClick) {
  39606. return _this2.onBeforeColumnResize(currentColumn, newSize, isDoubleClick);
  39607. });
  39608. if (typeof loadedManualColumnWidths != 'undefined') {
  39609. this.manualColumnWidths = loadedManualColumnWidths;
  39610. } else if (Array.isArray(initialColumnWidth)) {
  39611. this.manualColumnWidths = initialColumnWidth;
  39612. } else {
  39613. this.manualColumnWidths = [];
  39614. }
  39615. // Handsontable.hooks.register('beforeColumnResize');
  39616. // Handsontable.hooks.register('afterColumnResize');
  39617. this.bindEvents();
  39618. _get(ManualColumnResize.prototype.__proto__ || Object.getPrototypeOf(ManualColumnResize.prototype), 'enablePlugin', this).call(this);
  39619. }
  39620. /**
  39621. * Updates the plugin to use the latest options you have specified.
  39622. */
  39623. }, {
  39624. key: 'updatePlugin',
  39625. value: function updatePlugin() {
  39626. var initialColumnWidth = this.hot.getSettings().manualColumnResize;
  39627. if (Array.isArray(initialColumnWidth)) {
  39628. this.manualColumnWidths = initialColumnWidth;
  39629. } else if (!initialColumnWidth) {
  39630. this.manualColumnWidths = [];
  39631. }
  39632. }
  39633. /**
  39634. * Disable plugin for this Handsontable instance.
  39635. */
  39636. }, {
  39637. key: 'disablePlugin',
  39638. value: function disablePlugin() {
  39639. _get(ManualColumnResize.prototype.__proto__ || Object.getPrototypeOf(ManualColumnResize.prototype), 'disablePlugin', this).call(this);
  39640. }
  39641. /**
  39642. * Save the current sizes using the persistentState plugin.
  39643. */
  39644. }, {
  39645. key: 'saveManualColumnWidths',
  39646. value: function saveManualColumnWidths() {
  39647. this.hot.runHooks('persistentStateSave', 'manualColumnWidths', this.manualColumnWidths);
  39648. }
  39649. /**
  39650. * Load the previously saved sizes using the persistentState plugin.
  39651. *
  39652. * @returns {Array}
  39653. */
  39654. }, {
  39655. key: 'loadManualColumnWidths',
  39656. value: function loadManualColumnWidths() {
  39657. var storedState = {};
  39658. this.hot.runHooks('persistentStateLoad', 'manualColumnWidths', storedState);
  39659. return storedState.value;
  39660. }
  39661. /**
  39662. * Set the resize handle position.
  39663. *
  39664. * @param {HTMLCellElement} TH TH HTML element.
  39665. */
  39666. }, {
  39667. key: 'setupHandlePosition',
  39668. value: function setupHandlePosition(TH) {
  39669. var _this3 = this;
  39670. if (!TH.parentNode) {
  39671. return false;
  39672. }
  39673. this.currentTH = TH;
  39674. var col = this.hot.view.wt.wtTable.getCoords(TH).col; // getCoords returns CellCoords
  39675. var headerHeight = (0, _element.outerHeight)(this.currentTH);
  39676. if (col >= 0) {
  39677. // if not col header
  39678. var box = this.currentTH.getBoundingClientRect();
  39679. this.currentCol = col;
  39680. this.selectedCols = [];
  39681. if (this.hot.selection.isSelected() && this.hot.selection.isSelectedByColumnHeader()) {
  39682. var _hot$getSelectedRange = this.hot.getSelectedRangeLast(),
  39683. from = _hot$getSelectedRange.from,
  39684. to = _hot$getSelectedRange.to;
  39685. var start = from.col;
  39686. var end = to.col;
  39687. if (start >= end) {
  39688. start = to.col;
  39689. end = from.col;
  39690. }
  39691. if (this.currentCol >= start && this.currentCol <= end) {
  39692. (0, _number.rangeEach)(start, end, function (i) {
  39693. return _this3.selectedCols.push(i);
  39694. });
  39695. } else {
  39696. this.selectedCols.push(this.currentCol);
  39697. }
  39698. } else {
  39699. this.selectedCols.push(this.currentCol);
  39700. }
  39701. this.startOffset = box.left - 6;
  39702. this.startWidth = parseInt(box.width, 10);
  39703. this.handle.style.top = box.top + 'px';
  39704. this.handle.style.left = this.startOffset + this.startWidth + 'px';
  39705. this.handle.style.height = headerHeight + 'px';
  39706. this.hot.rootElement.appendChild(this.handle);
  39707. }
  39708. }
  39709. /**
  39710. * Refresh the resize handle position.
  39711. */
  39712. }, {
  39713. key: 'refreshHandlePosition',
  39714. value: function refreshHandlePosition() {
  39715. this.handle.style.left = this.startOffset + this.currentWidth + 'px';
  39716. }
  39717. /**
  39718. * Set the resize guide position.
  39719. */
  39720. }, {
  39721. key: 'setupGuidePosition',
  39722. value: function setupGuidePosition() {
  39723. var handleHeight = parseInt((0, _element.outerHeight)(this.handle), 10);
  39724. var handleBottomPosition = parseInt(this.handle.style.top, 10) + handleHeight;
  39725. var maximumVisibleElementHeight = parseInt(this.hot.view.maximumVisibleElementHeight(0), 10);
  39726. (0, _element.addClass)(this.handle, 'active');
  39727. (0, _element.addClass)(this.guide, 'active');
  39728. this.guide.style.top = handleBottomPosition + 'px';
  39729. this.guide.style.left = this.handle.style.left;
  39730. this.guide.style.height = maximumVisibleElementHeight - handleHeight + 'px';
  39731. this.hot.rootElement.appendChild(this.guide);
  39732. }
  39733. /**
  39734. * Refresh the resize guide position.
  39735. */
  39736. }, {
  39737. key: 'refreshGuidePosition',
  39738. value: function refreshGuidePosition() {
  39739. this.guide.style.left = this.handle.style.left;
  39740. }
  39741. /**
  39742. * Hide both the resize handle and resize guide.
  39743. */
  39744. }, {
  39745. key: 'hideHandleAndGuide',
  39746. value: function hideHandleAndGuide() {
  39747. (0, _element.removeClass)(this.handle, 'active');
  39748. (0, _element.removeClass)(this.guide, 'active');
  39749. }
  39750. /**
  39751. * Check if provided element is considered a column header.
  39752. *
  39753. * @param {HTMLElement} element HTML element.
  39754. * @returns {Boolean}
  39755. */
  39756. }, {
  39757. key: 'checkIfColumnHeader',
  39758. value: function checkIfColumnHeader(element) {
  39759. if (element != this.hot.rootElement) {
  39760. var parent = element.parentNode;
  39761. if (parent.tagName === 'THEAD') {
  39762. return true;
  39763. }
  39764. return this.checkIfColumnHeader(parent);
  39765. }
  39766. return false;
  39767. }
  39768. /**
  39769. * Get the TH element from the provided element.
  39770. *
  39771. * @param {HTMLElement} element HTML element.
  39772. * @returns {HTMLElement}
  39773. */
  39774. }, {
  39775. key: 'getTHFromTargetElement',
  39776. value: function getTHFromTargetElement(element) {
  39777. if (element.tagName != 'TABLE') {
  39778. if (element.tagName == 'TH') {
  39779. return element;
  39780. }
  39781. return this.getTHFromTargetElement(element.parentNode);
  39782. }
  39783. return null;
  39784. }
  39785. /**
  39786. * 'mouseover' event callback - set the handle position.
  39787. *
  39788. * @private
  39789. * @param {MouseEvent} event
  39790. */
  39791. }, {
  39792. key: 'onMouseOver',
  39793. value: function onMouseOver(event) {
  39794. if (this.checkIfColumnHeader(event.target)) {
  39795. var th = this.getTHFromTargetElement(event.target);
  39796. if (!th) {
  39797. return;
  39798. }
  39799. var colspan = th.getAttribute('colspan');
  39800. if (th && (colspan === null || colspan === 1)) {
  39801. if (!this.pressed) {
  39802. this.setupHandlePosition(th);
  39803. }
  39804. }
  39805. }
  39806. }
  39807. /**
  39808. * Auto-size row after doubleclick - callback.
  39809. *
  39810. * @private
  39811. */
  39812. }, {
  39813. key: 'afterMouseDownTimeout',
  39814. value: function afterMouseDownTimeout() {
  39815. var _this4 = this;
  39816. var render = function render() {
  39817. _this4.hot.forceFullRender = true;
  39818. _this4.hot.view.render(); // updates all
  39819. _this4.hot.view.wt.wtOverlays.adjustElementsSize(true);
  39820. };
  39821. var resize = function resize(selectedCol, forceRender) {
  39822. var hookNewSize = _this4.hot.runHooks('beforeColumnResize', selectedCol, _this4.newSize, true);
  39823. if (hookNewSize !== void 0) {
  39824. _this4.newSize = hookNewSize;
  39825. }
  39826. if (_this4.hot.getSettings().stretchH === 'all') {
  39827. _this4.clearManualSize(selectedCol);
  39828. } else {
  39829. _this4.setManualSize(selectedCol, _this4.newSize); // double click sets by auto row size plugin
  39830. }
  39831. if (forceRender) {
  39832. render();
  39833. }
  39834. _this4.saveManualColumnWidths();
  39835. _this4.hot.runHooks('afterColumnResize', selectedCol, _this4.newSize, true);
  39836. };
  39837. if (this.dblclick >= 2) {
  39838. var selectedColsLength = this.selectedCols.length;
  39839. if (selectedColsLength > 1) {
  39840. (0, _array.arrayEach)(this.selectedCols, function (selectedCol) {
  39841. resize(selectedCol);
  39842. });
  39843. render();
  39844. } else {
  39845. (0, _array.arrayEach)(this.selectedCols, function (selectedCol) {
  39846. resize(selectedCol, true);
  39847. });
  39848. }
  39849. }
  39850. this.dblclick = 0;
  39851. this.autoresizeTimeout = null;
  39852. }
  39853. /**
  39854. * 'mousedown' event callback.
  39855. *
  39856. * @private
  39857. * @param {MouseEvent} e
  39858. */
  39859. }, {
  39860. key: 'onMouseDown',
  39861. value: function onMouseDown(event) {
  39862. var _this5 = this;
  39863. if ((0, _element.hasClass)(event.target, 'manualColumnResizer')) {
  39864. this.setupGuidePosition();
  39865. this.pressed = this.hot;
  39866. if (this.autoresizeTimeout === null) {
  39867. this.autoresizeTimeout = setTimeout(function () {
  39868. return _this5.afterMouseDownTimeout();
  39869. }, 500);
  39870. this.hot._registerTimeout(this.autoresizeTimeout);
  39871. }
  39872. this.dblclick++;
  39873. this.startX = (0, _event.pageX)(event);
  39874. this.newSize = this.startWidth;
  39875. }
  39876. }
  39877. /**
  39878. * 'mousemove' event callback - refresh the handle and guide positions, cache the new column width.
  39879. *
  39880. * @private
  39881. * @param {MouseEvent} e
  39882. */
  39883. }, {
  39884. key: 'onMouseMove',
  39885. value: function onMouseMove(event) {
  39886. var _this6 = this;
  39887. if (this.pressed) {
  39888. this.currentWidth = this.startWidth + ((0, _event.pageX)(event) - this.startX);
  39889. (0, _array.arrayEach)(this.selectedCols, function (selectedCol) {
  39890. _this6.newSize = _this6.setManualSize(selectedCol, _this6.currentWidth);
  39891. });
  39892. this.refreshHandlePosition();
  39893. this.refreshGuidePosition();
  39894. }
  39895. }
  39896. /**
  39897. * 'mouseup' event callback - apply the column resizing.
  39898. *
  39899. * @private
  39900. * @param {MouseEvent} e
  39901. */
  39902. }, {
  39903. key: 'onMouseUp',
  39904. value: function onMouseUp(event) {
  39905. var _this7 = this;
  39906. var render = function render() {
  39907. _this7.hot.forceFullRender = true;
  39908. _this7.hot.view.render(); // updates all
  39909. _this7.hot.view.wt.wtOverlays.adjustElementsSize(true);
  39910. };
  39911. var resize = function resize(selectedCol, forceRender) {
  39912. _this7.hot.runHooks('beforeColumnResize', selectedCol, _this7.newSize);
  39913. if (forceRender) {
  39914. render();
  39915. }
  39916. _this7.saveManualColumnWidths();
  39917. _this7.hot.runHooks('afterColumnResize', selectedCol, _this7.newSize);
  39918. };
  39919. if (this.pressed) {
  39920. this.hideHandleAndGuide();
  39921. this.pressed = false;
  39922. if (this.newSize != this.startWidth) {
  39923. var selectedColsLength = this.selectedCols.length;
  39924. if (selectedColsLength > 1) {
  39925. (0, _array.arrayEach)(this.selectedCols, function (selectedCol) {
  39926. resize(selectedCol);
  39927. });
  39928. render();
  39929. } else {
  39930. (0, _array.arrayEach)(this.selectedCols, function (selectedCol) {
  39931. resize(selectedCol, true);
  39932. });
  39933. }
  39934. }
  39935. this.setupHandlePosition(this.currentTH);
  39936. }
  39937. }
  39938. /**
  39939. * Bind the mouse events.
  39940. *
  39941. * @private
  39942. */
  39943. }, {
  39944. key: 'bindEvents',
  39945. value: function bindEvents() {
  39946. var _this8 = this;
  39947. this.eventManager.addEventListener(this.hot.rootElement, 'mouseover', function (e) {
  39948. return _this8.onMouseOver(e);
  39949. });
  39950. this.eventManager.addEventListener(this.hot.rootElement, 'mousedown', function (e) {
  39951. return _this8.onMouseDown(e);
  39952. });
  39953. this.eventManager.addEventListener(window, 'mousemove', function (e) {
  39954. return _this8.onMouseMove(e);
  39955. });
  39956. this.eventManager.addEventListener(window, 'mouseup', function (e) {
  39957. return _this8.onMouseUp(e);
  39958. });
  39959. }
  39960. /**
  39961. * Cache the current column width.
  39962. *
  39963. * @param {Number} column Visual column index.
  39964. * @param {Number} width Column width.
  39965. * @returns {Number}
  39966. */
  39967. }, {
  39968. key: 'setManualSize',
  39969. value: function setManualSize(column, width) {
  39970. width = Math.max(width, 20);
  39971. /**
  39972. * We need to run col through modifyCol hook, in case the order of displayed columns is different than the order
  39973. * in data source. For instance, this order can be modified by manualColumnMove plugin.
  39974. */
  39975. column = this.hot.runHooks('modifyCol', column);
  39976. this.manualColumnWidths[column] = width;
  39977. return width;
  39978. }
  39979. /**
  39980. * Clear cache for the current column index.
  39981. *
  39982. * @param {Number} column Visual column index.
  39983. */
  39984. }, {
  39985. key: 'clearManualSize',
  39986. value: function clearManualSize(column) {
  39987. column = this.hot.runHooks('modifyCol', column);
  39988. this.manualColumnWidths[column] = void 0;
  39989. }
  39990. /**
  39991. * Modify the provided column width, based on the plugin settings
  39992. *
  39993. * @private
  39994. * @param {Number} width Column width.
  39995. * @param {Number} column Visual column index.
  39996. * @returns {Number}
  39997. */
  39998. }, {
  39999. key: 'onModifyColWidth',
  40000. value: function onModifyColWidth(width, column) {
  40001. if (this.enabled) {
  40002. column = this.hot.runHooks('modifyCol', column);
  40003. if (this.hot.getSettings().manualColumnResize && this.manualColumnWidths[column]) {
  40004. return this.manualColumnWidths[column];
  40005. }
  40006. }
  40007. return width;
  40008. }
  40009. /**
  40010. * Modify the provided column stretched width. This hook decides if specified column should be stretched or not.
  40011. *
  40012. * @private
  40013. * @param {Number} stretchedWidth Stretched width.
  40014. * @param {Number} column Physical column index.
  40015. * @returns {Number}
  40016. */
  40017. }, {
  40018. key: 'onBeforeStretchingColumnWidth',
  40019. value: function onBeforeStretchingColumnWidth(stretchedWidth, column) {
  40020. var width = this.manualColumnWidths[column];
  40021. if (width === void 0) {
  40022. width = stretchedWidth;
  40023. }
  40024. return width;
  40025. }
  40026. /**
  40027. * `beforeColumnResize` hook callback.
  40028. *
  40029. * @private
  40030. * @param {Number} currentColumn Index of the resized column.
  40031. * @param {Number} newSize Calculated new column width.
  40032. * @param {Boolean} isDoubleClick Flag that determines whether there was a double-click.
  40033. */
  40034. }, {
  40035. key: 'onBeforeColumnResize',
  40036. value: function onBeforeColumnResize() {
  40037. // clear the header height cache information
  40038. this.hot.view.wt.wtViewport.hasOversizedColumnHeadersMarked = {};
  40039. }
  40040. }]);
  40041. return ManualColumnResize;
  40042. }(_base2.default);
  40043. (0, _plugins.registerPlugin)('manualColumnResize', ManualColumnResize);
  40044. exports.default = ManualColumnResize;
  40045. /***/ }),
  40046. /* 338 */
  40047. /***/ (function(module, exports, __webpack_require__) {
  40048. "use strict";
  40049. exports.__esModule = true;
  40050. 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; }; }();
  40051. 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); } };
  40052. var _base = __webpack_require__(10);
  40053. var _base2 = _interopRequireDefault(_base);
  40054. var _pluginHooks = __webpack_require__(15);
  40055. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  40056. var _array = __webpack_require__(1);
  40057. var _element = __webpack_require__(0);
  40058. var _number = __webpack_require__(5);
  40059. var _eventManager = __webpack_require__(6);
  40060. var _eventManager2 = _interopRequireDefault(_eventManager);
  40061. var _plugins = __webpack_require__(8);
  40062. var _rowsMapper = __webpack_require__(339);
  40063. var _rowsMapper2 = _interopRequireDefault(_rowsMapper);
  40064. var _backlight = __webpack_require__(340);
  40065. var _backlight2 = _interopRequireDefault(_backlight);
  40066. var _guideline = __webpack_require__(341);
  40067. var _guideline2 = _interopRequireDefault(_guideline);
  40068. var _src = __webpack_require__(4);
  40069. __webpack_require__(342);
  40070. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  40071. 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); } }
  40072. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  40073. 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; }
  40074. 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; }
  40075. _pluginHooks2.default.getSingleton().register('beforeRowMove');
  40076. _pluginHooks2.default.getSingleton().register('afterRowMove');
  40077. _pluginHooks2.default.getSingleton().register('unmodifyRow');
  40078. var privatePool = new WeakMap();
  40079. var CSS_PLUGIN = 'ht__manualRowMove';
  40080. var CSS_SHOW_UI = 'show-ui';
  40081. var CSS_ON_MOVING = 'on-moving--rows';
  40082. var CSS_AFTER_SELECTION = 'after-selection--rows';
  40083. /**
  40084. * @plugin ManualRowMove
  40085. *
  40086. * @description
  40087. * This plugin allows to change rows order.
  40088. *
  40089. * API:
  40090. * - moveRow - move single row to the new position.
  40091. * - moveRows - move many rows (as an array of indexes) to the new position.
  40092. *
  40093. * If you want apply visual changes, you have to call manually the render() method on the instance of handsontable.
  40094. *
  40095. * UI components:
  40096. * - backlight - highlight of selected rows.
  40097. * - guideline - line which shows where rows has been moved.
  40098. *
  40099. * @class ManualRowMove
  40100. * @plugin ManualRowMove
  40101. */
  40102. var ManualRowMove = function (_BasePlugin) {
  40103. _inherits(ManualRowMove, _BasePlugin);
  40104. function ManualRowMove(hotInstance) {
  40105. _classCallCheck(this, ManualRowMove);
  40106. /**
  40107. * Set up WeakMap of plugin to sharing private parameters;
  40108. */
  40109. var _this = _possibleConstructorReturn(this, (ManualRowMove.__proto__ || Object.getPrototypeOf(ManualRowMove)).call(this, hotInstance));
  40110. privatePool.set(_this, {
  40111. rowsToMove: [],
  40112. pressed: void 0,
  40113. disallowMoving: void 0,
  40114. target: {
  40115. eventPageY: void 0,
  40116. coords: void 0,
  40117. TD: void 0,
  40118. row: void 0
  40119. }
  40120. });
  40121. /**
  40122. * List of last removed row indexes.
  40123. *
  40124. * @type {Array}
  40125. */
  40126. _this.removedRows = [];
  40127. /**
  40128. * Object containing visual row indexes mapped to data source indexes.
  40129. *
  40130. * @type {RowsMapper}
  40131. */
  40132. _this.rowsMapper = new _rowsMapper2.default(_this);
  40133. /**
  40134. * Event Manager object.
  40135. *
  40136. * @type {Object}
  40137. */
  40138. _this.eventManager = new _eventManager2.default(_this);
  40139. /**
  40140. * Backlight UI object.
  40141. *
  40142. * @type {Object}
  40143. */
  40144. _this.backlight = new _backlight2.default(hotInstance);
  40145. /**
  40146. * Guideline UI object.
  40147. *
  40148. * @type {Object}
  40149. */
  40150. _this.guideline = new _guideline2.default(hotInstance);
  40151. return _this;
  40152. }
  40153. /**
  40154. * Check if plugin is enabled.
  40155. *
  40156. * @returns {Boolean}
  40157. */
  40158. _createClass(ManualRowMove, [{
  40159. key: 'isEnabled',
  40160. value: function isEnabled() {
  40161. return !!this.hot.getSettings().manualRowMove;
  40162. }
  40163. /**
  40164. * Enable the plugin.
  40165. */
  40166. }, {
  40167. key: 'enablePlugin',
  40168. value: function enablePlugin() {
  40169. var _this2 = this;
  40170. if (this.enabled) {
  40171. return;
  40172. }
  40173. this.addHook('beforeOnCellMouseDown', function (event, coords, TD, blockCalculations) {
  40174. return _this2.onBeforeOnCellMouseDown(event, coords, TD, blockCalculations);
  40175. });
  40176. this.addHook('beforeOnCellMouseOver', function (event, coords, TD, blockCalculations) {
  40177. return _this2.onBeforeOnCellMouseOver(event, coords, TD, blockCalculations);
  40178. });
  40179. this.addHook('afterScrollHorizontally', function () {
  40180. return _this2.onAfterScrollHorizontally();
  40181. });
  40182. this.addHook('modifyRow', function (row, source) {
  40183. return _this2.onModifyRow(row, source);
  40184. });
  40185. this.addHook('beforeRemoveRow', function (index, amount) {
  40186. return _this2.onBeforeRemoveRow(index, amount);
  40187. });
  40188. this.addHook('afterRemoveRow', function () {
  40189. return _this2.onAfterRemoveRow();
  40190. });
  40191. this.addHook('afterCreateRow', function (index, amount) {
  40192. return _this2.onAfterCreateRow(index, amount);
  40193. });
  40194. this.addHook('afterLoadData', function () {
  40195. return _this2.onAfterLoadData();
  40196. });
  40197. this.addHook('beforeColumnSort', function (column, order) {
  40198. return _this2.onBeforeColumnSort(column, order);
  40199. });
  40200. this.addHook('unmodifyRow', function (row) {
  40201. return _this2.onUnmodifyRow(row);
  40202. });
  40203. this.registerEvents();
  40204. // TODO: move adding plugin classname to BasePlugin.
  40205. (0, _element.addClass)(this.hot.rootElement, CSS_PLUGIN);
  40206. _get(ManualRowMove.prototype.__proto__ || Object.getPrototypeOf(ManualRowMove.prototype), 'enablePlugin', this).call(this);
  40207. }
  40208. /**
  40209. * Updates the plugin to use the latest options you have specified.
  40210. */
  40211. }, {
  40212. key: 'updatePlugin',
  40213. value: function updatePlugin() {
  40214. this.disablePlugin();
  40215. this.enablePlugin();
  40216. this.onAfterPluginsInitialized();
  40217. _get(ManualRowMove.prototype.__proto__ || Object.getPrototypeOf(ManualRowMove.prototype), 'updatePlugin', this).call(this);
  40218. }
  40219. /**
  40220. * Disable plugin for this Handsontable instance.
  40221. */
  40222. }, {
  40223. key: 'disablePlugin',
  40224. value: function disablePlugin() {
  40225. var pluginSettings = this.hot.getSettings().manualRowMove;
  40226. if (Array.isArray(pluginSettings)) {
  40227. this.rowsMapper.clearMap();
  40228. }
  40229. (0, _element.removeClass)(this.hot.rootElement, CSS_PLUGIN);
  40230. this.unregisterEvents();
  40231. this.backlight.destroy();
  40232. this.guideline.destroy();
  40233. _get(ManualRowMove.prototype.__proto__ || Object.getPrototypeOf(ManualRowMove.prototype), 'disablePlugin', this).call(this);
  40234. }
  40235. /**
  40236. * Move a single row.
  40237. *
  40238. * @param {Number} row Visual row index to be moved.
  40239. * @param {Number} target Visual row index being a target for the moved row.
  40240. */
  40241. }, {
  40242. key: 'moveRow',
  40243. value: function moveRow(row, target) {
  40244. this.moveRows([row], target);
  40245. }
  40246. /**
  40247. * Move multiple rows.
  40248. *
  40249. * @param {Array} rows Array of visual row indexes to be moved.
  40250. * @param {Number} target Visual row index being a target for the moved rows.
  40251. */
  40252. }, {
  40253. key: 'moveRows',
  40254. value: function moveRows(rows, target) {
  40255. var _this3 = this;
  40256. var visualRows = [].concat(_toConsumableArray(rows));
  40257. var priv = privatePool.get(this);
  40258. var beforeMoveHook = this.hot.runHooks('beforeRowMove', visualRows, target);
  40259. priv.disallowMoving = beforeMoveHook === false;
  40260. if (!priv.disallowMoving) {
  40261. // first we need to rewrite an visual indexes to physical for save reference after move
  40262. (0, _array.arrayEach)(rows, function (row, index, array) {
  40263. array[index] = _this3.rowsMapper.getValueByIndex(row);
  40264. });
  40265. // next, when we have got an physical indexes, we can move rows
  40266. (0, _array.arrayEach)(rows, function (row, index) {
  40267. var actualPosition = _this3.rowsMapper.getIndexByValue(row);
  40268. if (actualPosition !== target) {
  40269. _this3.rowsMapper.moveRow(actualPosition, target + index);
  40270. }
  40271. });
  40272. // after moving we have to clear rowsMapper from null entries
  40273. this.rowsMapper.clearNull();
  40274. }
  40275. this.hot.runHooks('afterRowMove', visualRows, target);
  40276. }
  40277. /**
  40278. * Correct the cell selection after the move action. Fired only when action was made with a mouse.
  40279. * That means that changing the row order using the API won't correct the selection.
  40280. *
  40281. * @private
  40282. * @param {Number} startRow Visual row index for the start of the selection.
  40283. * @param {Number} endRow Visual row index for the end of the selection.
  40284. */
  40285. }, {
  40286. key: 'changeSelection',
  40287. value: function changeSelection(startRow, endRow) {
  40288. this.hot.selectRows(startRow, endRow);
  40289. }
  40290. /**
  40291. * Get the sum of the heights of rows in the provided range.
  40292. *
  40293. * @private
  40294. * @param {Number} from Visual row index.
  40295. * @param {Number} to Visual row index.
  40296. * @returns {Number}
  40297. */
  40298. }, {
  40299. key: 'getRowsHeight',
  40300. value: function getRowsHeight(from, to) {
  40301. var height = 0;
  40302. for (var i = from; i < to; i++) {
  40303. var rowHeight = this.hot.view.wt.wtTable.getRowHeight(i) || 23;
  40304. height += rowHeight;
  40305. }
  40306. return height;
  40307. }
  40308. /**
  40309. * Load initial settings when persistent state is saved or when plugin was initialized as an array.
  40310. *
  40311. * @private
  40312. */
  40313. }, {
  40314. key: 'initialSettings',
  40315. value: function initialSettings() {
  40316. var pluginSettings = this.hot.getSettings().manualRowMove;
  40317. if (Array.isArray(pluginSettings)) {
  40318. this.moveRows(pluginSettings, 0);
  40319. } else if (pluginSettings !== void 0) {
  40320. var persistentState = this.persistentStateLoad();
  40321. if (persistentState.length) {
  40322. this.moveRows(persistentState, 0);
  40323. }
  40324. }
  40325. }
  40326. /**
  40327. * Check if the provided row is in the fixedRowsTop section.
  40328. *
  40329. * @private
  40330. * @param {Number} row Visual row index to check.
  40331. * @returns {Boolean}
  40332. */
  40333. }, {
  40334. key: 'isFixedRowTop',
  40335. value: function isFixedRowTop(row) {
  40336. return row < this.hot.getSettings().fixedRowsTop;
  40337. }
  40338. /**
  40339. * Check if the provided row is in the fixedRowsBottom section.
  40340. *
  40341. * @private
  40342. * @param {Number} row Visual row index to check.
  40343. * @returns {Boolean}
  40344. */
  40345. }, {
  40346. key: 'isFixedRowBottom',
  40347. value: function isFixedRowBottom(row) {
  40348. return row > this.hot.getSettings().fixedRowsBottom;
  40349. }
  40350. /**
  40351. * Save the manual row positions to the persistent state.
  40352. *
  40353. * @private
  40354. */
  40355. }, {
  40356. key: 'persistentStateSave',
  40357. value: function persistentStateSave() {
  40358. this.hot.runHooks('persistentStateSave', 'manualRowMove', this.rowsMapper._arrayMap);
  40359. }
  40360. /**
  40361. * Load the manual row positions from the persistent state.
  40362. *
  40363. * @private
  40364. * @returns {Array} Stored state.
  40365. */
  40366. }, {
  40367. key: 'persistentStateLoad',
  40368. value: function persistentStateLoad() {
  40369. var storedState = {};
  40370. this.hot.runHooks('persistentStateLoad', 'manualRowMove', storedState);
  40371. return storedState.value ? storedState.value : [];
  40372. }
  40373. /**
  40374. * Prepare array of indexes based on actual selection.
  40375. *
  40376. * @private
  40377. * @returns {Array}
  40378. */
  40379. }, {
  40380. key: 'prepareRowsToMoving',
  40381. value: function prepareRowsToMoving() {
  40382. var selection = this.hot.getSelectedRangeLast();
  40383. var selectedRows = [];
  40384. if (!selection) {
  40385. return selectedRows;
  40386. }
  40387. var from = selection.from,
  40388. to = selection.to;
  40389. var start = Math.min(from.row, to.row);
  40390. var end = Math.max(from.row, to.row);
  40391. (0, _number.rangeEach)(start, end, function (i) {
  40392. selectedRows.push(i);
  40393. });
  40394. return selectedRows;
  40395. }
  40396. /**
  40397. * Update the UI visual position.
  40398. *
  40399. * @private
  40400. */
  40401. }, {
  40402. key: 'refreshPositions',
  40403. value: function refreshPositions() {
  40404. var priv = privatePool.get(this);
  40405. var coords = priv.target.coords;
  40406. var firstVisible = this.hot.view.wt.wtTable.getFirstVisibleRow();
  40407. var lastVisible = this.hot.view.wt.wtTable.getLastVisibleRow();
  40408. var fixedRows = this.hot.getSettings().fixedRowsTop;
  40409. var countRows = this.hot.countRows();
  40410. if (coords.row < fixedRows && firstVisible > 0) {
  40411. this.hot.scrollViewportTo(firstVisible - 1);
  40412. }
  40413. if (coords.row >= lastVisible && lastVisible < countRows) {
  40414. this.hot.scrollViewportTo(lastVisible + 1, undefined, true);
  40415. }
  40416. var wtTable = this.hot.view.wt.wtTable;
  40417. var TD = priv.target.TD;
  40418. var rootElementOffset = (0, _element.offset)(this.hot.rootElement);
  40419. var tdOffsetTop = this.hot.view.THEAD.offsetHeight + this.getRowsHeight(0, coords.row);
  40420. var mouseOffsetTop = priv.target.eventPageY - rootElementOffset.top + wtTable.holder.scrollTop;
  40421. var hiderHeight = wtTable.hider.offsetHeight;
  40422. var tbodyOffsetTop = wtTable.TBODY.offsetTop;
  40423. var backlightElemMarginTop = this.backlight.getOffset().top;
  40424. var backlightElemHeight = this.backlight.getSize().height;
  40425. if (this.isFixedRowTop(coords.row)) {
  40426. tdOffsetTop += wtTable.holder.scrollTop;
  40427. }
  40428. // todo: fixedRowsBottom
  40429. // if (this.isFixedRowBottom(coords.row)) {
  40430. //
  40431. // }
  40432. if (coords.row < 0) {
  40433. // if hover on colHeader
  40434. priv.target.row = firstVisible > 0 ? firstVisible - 1 : firstVisible;
  40435. } else if (TD.offsetHeight / 2 + tdOffsetTop <= mouseOffsetTop) {
  40436. // if hover on lower part of TD
  40437. priv.target.row = coords.row + 1;
  40438. // unfortunately first row is bigger than rest
  40439. tdOffsetTop += coords.row === 0 ? TD.offsetHeight - 1 : TD.offsetHeight;
  40440. } else {
  40441. // elsewhere on table
  40442. priv.target.row = coords.row;
  40443. }
  40444. var backlightTop = mouseOffsetTop;
  40445. var guidelineTop = tdOffsetTop;
  40446. if (mouseOffsetTop + backlightElemHeight + backlightElemMarginTop >= hiderHeight) {
  40447. // prevent display backlight below table
  40448. backlightTop = hiderHeight - backlightElemHeight - backlightElemMarginTop;
  40449. } else if (mouseOffsetTop + backlightElemMarginTop < tbodyOffsetTop) {
  40450. // prevent display above below table
  40451. backlightTop = tbodyOffsetTop + Math.abs(backlightElemMarginTop);
  40452. }
  40453. if (tdOffsetTop >= hiderHeight - 1) {
  40454. // prevent display guideline below table
  40455. guidelineTop = hiderHeight - 1;
  40456. }
  40457. var topOverlayHeight = 0;
  40458. if (this.hot.view.wt.wtOverlays.topOverlay) {
  40459. topOverlayHeight = this.hot.view.wt.wtOverlays.topOverlay.clone.wtTable.TABLE.offsetHeight;
  40460. }
  40461. if (coords.row >= fixedRows && guidelineTop - wtTable.holder.scrollTop < topOverlayHeight) {
  40462. this.hot.scrollViewportTo(coords.row);
  40463. }
  40464. this.backlight.setPosition(backlightTop);
  40465. this.guideline.setPosition(guidelineTop);
  40466. }
  40467. /**
  40468. * This method checks arrayMap from rowsMapper and updates the rowsMapper if it's necessary.
  40469. *
  40470. * @private
  40471. */
  40472. }, {
  40473. key: 'updateRowsMapper',
  40474. value: function updateRowsMapper() {
  40475. var countRows = this.hot.countSourceRows();
  40476. var rowsMapperLen = this.rowsMapper._arrayMap.length;
  40477. if (rowsMapperLen === 0) {
  40478. this.rowsMapper.createMap(countRows || this.hot.getSettings().startRows);
  40479. } else if (rowsMapperLen < countRows) {
  40480. var diff = countRows - rowsMapperLen;
  40481. this.rowsMapper.insertItems(rowsMapperLen, diff);
  40482. } else if (rowsMapperLen > countRows) {
  40483. var maxIndex = countRows - 1;
  40484. var rowsToRemove = [];
  40485. (0, _array.arrayEach)(this.rowsMapper._arrayMap, function (value, index) {
  40486. if (value > maxIndex) {
  40487. rowsToRemove.push(index);
  40488. }
  40489. });
  40490. this.rowsMapper.removeItems(rowsToRemove);
  40491. }
  40492. }
  40493. /**
  40494. * Bind the events used by the plugin.
  40495. *
  40496. * @private
  40497. */
  40498. }, {
  40499. key: 'registerEvents',
  40500. value: function registerEvents() {
  40501. var _this4 = this;
  40502. this.eventManager.addEventListener(document.documentElement, 'mousemove', function (event) {
  40503. return _this4.onMouseMove(event);
  40504. });
  40505. this.eventManager.addEventListener(document.documentElement, 'mouseup', function () {
  40506. return _this4.onMouseUp();
  40507. });
  40508. }
  40509. /**
  40510. * Unbind the events used by the plugin.
  40511. *
  40512. * @private
  40513. */
  40514. }, {
  40515. key: 'unregisterEvents',
  40516. value: function unregisterEvents() {
  40517. this.eventManager.clear();
  40518. }
  40519. /**
  40520. * `beforeColumnSort` hook callback. If user uses the sorting, manual row moving is disabled.
  40521. *
  40522. * @private
  40523. * @param {Number} column Column index where soring is present
  40524. * @param {*} order State of sorting. ASC/DESC/None
  40525. */
  40526. }, {
  40527. key: 'onBeforeColumnSort',
  40528. value: function onBeforeColumnSort(column, order) {
  40529. var priv = privatePool.get(this);
  40530. priv.disallowMoving = order !== void 0;
  40531. }
  40532. /**
  40533. * Change the behavior of selection / dragging.
  40534. *
  40535. * @private
  40536. * @param {MouseEvent} event
  40537. * @param {CellCoords} coords Visual coordinates.
  40538. * @param {HTMLElement} TD
  40539. * @param {Object} blockCalculations
  40540. */
  40541. }, {
  40542. key: 'onBeforeOnCellMouseDown',
  40543. value: function onBeforeOnCellMouseDown(event, coords, TD, blockCalculations) {
  40544. var wtTable = this.hot.view.wt.wtTable;
  40545. var isHeaderSelection = this.hot.selection.isSelectedByRowHeader();
  40546. var selection = this.hot.getSelectedRangeLast();
  40547. var priv = privatePool.get(this);
  40548. if (!selection || !isHeaderSelection || priv.pressed || event.button !== 0) {
  40549. priv.pressed = false;
  40550. priv.rowsToMove.length = 0;
  40551. (0, _element.removeClass)(this.hot.rootElement, [CSS_ON_MOVING, CSS_SHOW_UI]);
  40552. return;
  40553. }
  40554. var guidelineIsNotReady = this.guideline.isBuilt() && !this.guideline.isAppended();
  40555. var backlightIsNotReady = this.backlight.isBuilt() && !this.backlight.isAppended();
  40556. if (guidelineIsNotReady && backlightIsNotReady) {
  40557. this.guideline.appendTo(wtTable.hider);
  40558. this.backlight.appendTo(wtTable.hider);
  40559. }
  40560. var from = selection.from,
  40561. to = selection.to;
  40562. var start = Math.min(from.row, to.row);
  40563. var end = Math.max(from.row, to.row);
  40564. if (coords.col < 0 && coords.row >= start && coords.row <= end) {
  40565. blockCalculations.row = true;
  40566. priv.pressed = true;
  40567. priv.target.eventPageY = event.pageY;
  40568. priv.target.coords = coords;
  40569. priv.target.TD = TD;
  40570. priv.rowsToMove = this.prepareRowsToMoving();
  40571. var leftPos = wtTable.holder.scrollLeft + this.hot.view.wt.wtViewport.getRowHeaderWidth();
  40572. this.backlight.setPosition(null, leftPos);
  40573. this.backlight.setSize(wtTable.hider.offsetWidth - leftPos, this.getRowsHeight(start, end + 1));
  40574. this.backlight.setOffset((this.getRowsHeight(start, coords.row) + event.layerY) * -1, null);
  40575. (0, _element.addClass)(this.hot.rootElement, CSS_ON_MOVING);
  40576. this.refreshPositions();
  40577. } else {
  40578. (0, _element.removeClass)(this.hot.rootElement, CSS_AFTER_SELECTION);
  40579. priv.pressed = false;
  40580. priv.rowsToMove.length = 0;
  40581. }
  40582. }
  40583. /**
  40584. * 'mouseMove' event callback. Fired when pointer move on document.documentElement.
  40585. *
  40586. * @private
  40587. * @param {MouseEvent} event `mousemove` event properties.
  40588. */
  40589. }, {
  40590. key: 'onMouseMove',
  40591. value: function onMouseMove(event) {
  40592. var priv = privatePool.get(this);
  40593. if (!priv.pressed) {
  40594. return;
  40595. }
  40596. // callback for browser which doesn't supports CSS pointer-event: none
  40597. if (event.realTarget === this.backlight.element) {
  40598. var height = this.backlight.getSize().height;
  40599. this.backlight.setSize(null, 0);
  40600. setTimeout(function () {
  40601. this.backlight.setPosition(null, height);
  40602. });
  40603. }
  40604. priv.target.eventPageY = event.pageY;
  40605. this.refreshPositions();
  40606. }
  40607. /**
  40608. * 'beforeOnCellMouseOver' hook callback. Fired when pointer was over cell.
  40609. *
  40610. * @private
  40611. * @param {MouseEvent} event `mouseover` event properties.
  40612. * @param {CellCoords} coords Visual cell coordinates where was fired event.
  40613. * @param {HTMLElement} TD Cell represented as HTMLElement.
  40614. * @param {Object} blockCalculations Object which contains information about blockCalculation for row, column or cells.
  40615. */
  40616. }, {
  40617. key: 'onBeforeOnCellMouseOver',
  40618. value: function onBeforeOnCellMouseOver(event, coords, TD, blockCalculations) {
  40619. var selectedRange = this.hot.getSelectedRangeLast();
  40620. var priv = privatePool.get(this);
  40621. if (!selectedRange || !priv.pressed) {
  40622. return;
  40623. }
  40624. if (priv.rowsToMove.indexOf(coords.row) > -1) {
  40625. (0, _element.removeClass)(this.hot.rootElement, CSS_SHOW_UI);
  40626. } else {
  40627. (0, _element.addClass)(this.hot.rootElement, CSS_SHOW_UI);
  40628. }
  40629. blockCalculations.row = true;
  40630. blockCalculations.column = true;
  40631. blockCalculations.cell = true;
  40632. priv.target.coords = coords;
  40633. priv.target.TD = TD;
  40634. }
  40635. /**
  40636. * `onMouseUp` hook callback.
  40637. *
  40638. * @private
  40639. */
  40640. }, {
  40641. key: 'onMouseUp',
  40642. value: function onMouseUp() {
  40643. var priv = privatePool.get(this);
  40644. var target = priv.target.row;
  40645. var rowsLen = priv.rowsToMove.length;
  40646. priv.pressed = false;
  40647. priv.backlightHeight = 0;
  40648. (0, _element.removeClass)(this.hot.rootElement, [CSS_ON_MOVING, CSS_SHOW_UI, CSS_AFTER_SELECTION]);
  40649. if (this.hot.selection.isSelectedByRowHeader()) {
  40650. (0, _element.addClass)(this.hot.rootElement, CSS_AFTER_SELECTION);
  40651. }
  40652. if (rowsLen < 1 || target === void 0 || priv.rowsToMove.indexOf(target) > -1 || priv.rowsToMove[rowsLen - 1] === target - 1) {
  40653. return;
  40654. }
  40655. this.moveRows(priv.rowsToMove, target);
  40656. this.persistentStateSave();
  40657. this.hot.render();
  40658. if (!priv.disallowMoving) {
  40659. var selectionStart = this.rowsMapper.getIndexByValue(priv.rowsToMove[0]);
  40660. var selectionEnd = this.rowsMapper.getIndexByValue(priv.rowsToMove[rowsLen - 1]);
  40661. this.changeSelection(selectionStart, selectionEnd);
  40662. }
  40663. priv.rowsToMove.length = 0;
  40664. }
  40665. /**
  40666. * `afterScrollHorizontally` hook callback. Fired the table was scrolled horizontally.
  40667. *
  40668. * @private
  40669. */
  40670. }, {
  40671. key: 'onAfterScrollHorizontally',
  40672. value: function onAfterScrollHorizontally() {
  40673. var wtTable = this.hot.view.wt.wtTable;
  40674. var headerWidth = this.hot.view.wt.wtViewport.getRowHeaderWidth();
  40675. var scrollLeft = wtTable.holder.scrollLeft;
  40676. var posLeft = headerWidth + scrollLeft;
  40677. this.backlight.setPosition(null, posLeft);
  40678. this.backlight.setSize(wtTable.hider.offsetWidth - posLeft);
  40679. }
  40680. /**
  40681. * `afterCreateRow` hook callback.
  40682. *
  40683. * @private
  40684. * @param {Number} index Visual index of the created row.
  40685. * @param {Number} amount Amount of created rows.
  40686. */
  40687. }, {
  40688. key: 'onAfterCreateRow',
  40689. value: function onAfterCreateRow(index, amount) {
  40690. this.rowsMapper.shiftItems(index, amount);
  40691. }
  40692. /**
  40693. * On before remove row listener.
  40694. *
  40695. * @private
  40696. * @param {Number} index Visual row index.
  40697. * @param {Number} amount Defines how many rows removed.
  40698. */
  40699. }, {
  40700. key: 'onBeforeRemoveRow',
  40701. value: function onBeforeRemoveRow(index, amount) {
  40702. var _this5 = this;
  40703. this.removedRows.length = 0;
  40704. if (index !== false) {
  40705. // Collect physical row index.
  40706. (0, _number.rangeEach)(index, index + amount - 1, function (removedIndex) {
  40707. _this5.removedRows.push(_this5.hot.runHooks('modifyRow', removedIndex, _this5.pluginName));
  40708. });
  40709. }
  40710. }
  40711. /**
  40712. * `afterRemoveRow` hook callback.
  40713. *
  40714. * @private
  40715. */
  40716. }, {
  40717. key: 'onAfterRemoveRow',
  40718. value: function onAfterRemoveRow() {
  40719. this.rowsMapper.unshiftItems(this.removedRows);
  40720. }
  40721. /**
  40722. * `afterLoadData` hook callback.
  40723. *
  40724. * @private
  40725. */
  40726. }, {
  40727. key: 'onAfterLoadData',
  40728. value: function onAfterLoadData() {
  40729. this.updateRowsMapper();
  40730. }
  40731. /**
  40732. * 'modifyRow' hook callback.
  40733. *
  40734. * @private
  40735. * @param {Number} row Visual Row index.
  40736. * @returns {Number} Physical row index.
  40737. */
  40738. }, {
  40739. key: 'onModifyRow',
  40740. value: function onModifyRow(row, source) {
  40741. if (source !== this.pluginName) {
  40742. var rowInMapper = this.rowsMapper.getValueByIndex(row);
  40743. row = rowInMapper === null ? row : rowInMapper;
  40744. }
  40745. return row;
  40746. }
  40747. /**
  40748. * 'unmodifyRow' hook callback.
  40749. *
  40750. * @private
  40751. * @param {Number} row Physical row index.
  40752. * @returns {Number} Visual row index.
  40753. */
  40754. }, {
  40755. key: 'onUnmodifyRow',
  40756. value: function onUnmodifyRow(row) {
  40757. var indexInMapper = this.rowsMapper.getIndexByValue(row);
  40758. return indexInMapper === null ? row : indexInMapper;
  40759. }
  40760. /**
  40761. * `afterPluginsInitialized` hook callback.
  40762. *
  40763. * @private
  40764. */
  40765. }, {
  40766. key: 'onAfterPluginsInitialized',
  40767. value: function onAfterPluginsInitialized() {
  40768. this.updateRowsMapper();
  40769. this.initialSettings();
  40770. this.backlight.build();
  40771. this.guideline.build();
  40772. }
  40773. /**
  40774. * Destroy plugin instance.
  40775. */
  40776. }, {
  40777. key: 'destroy',
  40778. value: function destroy() {
  40779. this.backlight.destroy();
  40780. this.guideline.destroy();
  40781. _get(ManualRowMove.prototype.__proto__ || Object.getPrototypeOf(ManualRowMove.prototype), 'destroy', this).call(this);
  40782. }
  40783. }]);
  40784. return ManualRowMove;
  40785. }(_base2.default);
  40786. (0, _plugins.registerPlugin)('ManualRowMove', ManualRowMove);
  40787. exports.default = ManualRowMove;
  40788. /***/ }),
  40789. /* 339 */
  40790. /***/ (function(module, exports, __webpack_require__) {
  40791. "use strict";
  40792. exports.__esModule = true;
  40793. 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; }; }();
  40794. var _arrayMapper = __webpack_require__(201);
  40795. var _arrayMapper2 = _interopRequireDefault(_arrayMapper);
  40796. var _array = __webpack_require__(1);
  40797. var _object = __webpack_require__(2);
  40798. var _number = __webpack_require__(5);
  40799. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  40800. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  40801. /**
  40802. * @class RowsMapper
  40803. * @plugin ManualRowMove
  40804. */
  40805. var RowsMapper = function () {
  40806. function RowsMapper(manualRowMove) {
  40807. _classCallCheck(this, RowsMapper);
  40808. /**
  40809. * Instance of ManualRowMove plugin.
  40810. *
  40811. * @type {ManualRowMove}
  40812. */
  40813. this.manualRowMove = manualRowMove;
  40814. }
  40815. /**
  40816. * Reset current map array and create new one.
  40817. *
  40818. * @param {Number} [length] Custom generated map length.
  40819. */
  40820. _createClass(RowsMapper, [{
  40821. key: 'createMap',
  40822. value: function createMap(length) {
  40823. var _this = this;
  40824. var originLength = length === void 0 ? this._arrayMap.length : length;
  40825. this._arrayMap.length = 0;
  40826. (0, _number.rangeEach)(originLength - 1, function (itemIndex) {
  40827. _this._arrayMap[itemIndex] = itemIndex;
  40828. });
  40829. }
  40830. /**
  40831. * Destroy class.
  40832. */
  40833. }, {
  40834. key: 'destroy',
  40835. value: function destroy() {
  40836. this._arrayMap = null;
  40837. }
  40838. /**
  40839. *
  40840. * Moving elements in rowsMapper.
  40841. * @param {Number} from Row index to move.
  40842. * @param {Number} to Target index.
  40843. */
  40844. }, {
  40845. key: 'moveRow',
  40846. value: function moveRow(from, to) {
  40847. var indexToMove = this._arrayMap[from];
  40848. this._arrayMap[from] = null;
  40849. this._arrayMap.splice(to, 0, indexToMove);
  40850. }
  40851. /**
  40852. * Clearing arrayMap from `null` entries.
  40853. */
  40854. }, {
  40855. key: 'clearNull',
  40856. value: function clearNull() {
  40857. this._arrayMap = (0, _array.arrayFilter)(this._arrayMap, function (i) {
  40858. return i !== null;
  40859. });
  40860. }
  40861. }]);
  40862. return RowsMapper;
  40863. }();
  40864. (0, _object.mixin)(RowsMapper, _arrayMapper2.default);
  40865. exports.default = RowsMapper;
  40866. /***/ }),
  40867. /* 340 */
  40868. /***/ (function(module, exports, __webpack_require__) {
  40869. "use strict";
  40870. exports.__esModule = true;
  40871. 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; }; }();
  40872. 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); } };
  40873. var _base = __webpack_require__(203);
  40874. var _base2 = _interopRequireDefault(_base);
  40875. var _element = __webpack_require__(0);
  40876. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  40877. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  40878. 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; }
  40879. 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; }
  40880. var CSS_CLASSNAME = 'ht__manualRowMove--backlight';
  40881. /**
  40882. * @class BacklightUI
  40883. * @util
  40884. */
  40885. var BacklightUI = function (_BaseUI) {
  40886. _inherits(BacklightUI, _BaseUI);
  40887. function BacklightUI() {
  40888. _classCallCheck(this, BacklightUI);
  40889. return _possibleConstructorReturn(this, (BacklightUI.__proto__ || Object.getPrototypeOf(BacklightUI)).apply(this, arguments));
  40890. }
  40891. _createClass(BacklightUI, [{
  40892. key: 'build',
  40893. /**
  40894. * Custom className on build process.
  40895. */
  40896. value: function build() {
  40897. _get(BacklightUI.prototype.__proto__ || Object.getPrototypeOf(BacklightUI.prototype), 'build', this).call(this);
  40898. (0, _element.addClass)(this._element, CSS_CLASSNAME);
  40899. }
  40900. }]);
  40901. return BacklightUI;
  40902. }(_base2.default);
  40903. exports.default = BacklightUI;
  40904. /***/ }),
  40905. /* 341 */
  40906. /***/ (function(module, exports, __webpack_require__) {
  40907. "use strict";
  40908. exports.__esModule = true;
  40909. 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; }; }();
  40910. 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); } };
  40911. var _base = __webpack_require__(203);
  40912. var _base2 = _interopRequireDefault(_base);
  40913. var _element = __webpack_require__(0);
  40914. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  40915. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  40916. 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; }
  40917. 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; }
  40918. var CSS_CLASSNAME = 'ht__manualRowMove--guideline';
  40919. /**
  40920. * @class GuidelineUI
  40921. * @util
  40922. */
  40923. var GuidelineUI = function (_BaseUI) {
  40924. _inherits(GuidelineUI, _BaseUI);
  40925. function GuidelineUI() {
  40926. _classCallCheck(this, GuidelineUI);
  40927. return _possibleConstructorReturn(this, (GuidelineUI.__proto__ || Object.getPrototypeOf(GuidelineUI)).apply(this, arguments));
  40928. }
  40929. _createClass(GuidelineUI, [{
  40930. key: 'build',
  40931. /**
  40932. * Custom className on build process.
  40933. */
  40934. value: function build() {
  40935. _get(GuidelineUI.prototype.__proto__ || Object.getPrototypeOf(GuidelineUI.prototype), 'build', this).call(this);
  40936. (0, _element.addClass)(this._element, CSS_CLASSNAME);
  40937. }
  40938. }]);
  40939. return GuidelineUI;
  40940. }(_base2.default);
  40941. exports.default = GuidelineUI;
  40942. /***/ }),
  40943. /* 342 */
  40944. /***/ (function(module, exports) {
  40945. // removed by extract-text-webpack-plugin
  40946. /***/ }),
  40947. /* 343 */
  40948. /***/ (function(module, exports, __webpack_require__) {
  40949. "use strict";
  40950. exports.__esModule = true;
  40951. 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; }; }();
  40952. 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); } };
  40953. var _base = __webpack_require__(10);
  40954. var _base2 = _interopRequireDefault(_base);
  40955. var _element = __webpack_require__(0);
  40956. var _eventManager = __webpack_require__(6);
  40957. var _eventManager2 = _interopRequireDefault(_eventManager);
  40958. var _event = __webpack_require__(12);
  40959. var _array = __webpack_require__(1);
  40960. var _number = __webpack_require__(5);
  40961. var _plugins = __webpack_require__(8);
  40962. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  40963. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  40964. 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; }
  40965. 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; }
  40966. // Developer note! Whenever you make a change in this file, make an analogous change in manualRowResize.js
  40967. /**
  40968. * @description
  40969. * ManualRowResize Plugin.
  40970. *
  40971. * Has 2 UI components:
  40972. * - handle - the draggable element that sets the desired height of the row.
  40973. * - guide - the helper guide that shows the desired height as a horizontal guide.
  40974. *
  40975. * @plugin ManualRowResize
  40976. */
  40977. var ManualRowResize = function (_BasePlugin) {
  40978. _inherits(ManualRowResize, _BasePlugin);
  40979. function ManualRowResize(hotInstance) {
  40980. _classCallCheck(this, ManualRowResize);
  40981. var _this = _possibleConstructorReturn(this, (ManualRowResize.__proto__ || Object.getPrototypeOf(ManualRowResize)).call(this, hotInstance));
  40982. _this.currentTH = null;
  40983. _this.currentRow = null;
  40984. _this.selectedRows = [];
  40985. _this.currentHeight = null;
  40986. _this.newSize = null;
  40987. _this.startY = null;
  40988. _this.startHeight = null;
  40989. _this.startOffset = null;
  40990. _this.handle = document.createElement('DIV');
  40991. _this.guide = document.createElement('DIV');
  40992. _this.eventManager = new _eventManager2.default(_this);
  40993. _this.pressed = null;
  40994. _this.dblclick = 0;
  40995. _this.autoresizeTimeout = null;
  40996. _this.manualRowHeights = [];
  40997. (0, _element.addClass)(_this.handle, 'manualRowResizer');
  40998. (0, _element.addClass)(_this.guide, 'manualRowResizerGuide');
  40999. return _this;
  41000. }
  41001. /**
  41002. * Check if the plugin is enabled in the handsontable settings.
  41003. *
  41004. * @returns {Boolean}
  41005. */
  41006. _createClass(ManualRowResize, [{
  41007. key: 'isEnabled',
  41008. value: function isEnabled() {
  41009. return this.hot.getSettings().manualRowResize;
  41010. }
  41011. /**
  41012. * Enable plugin for this Handsontable instance.
  41013. */
  41014. }, {
  41015. key: 'enablePlugin',
  41016. value: function enablePlugin() {
  41017. var _this2 = this;
  41018. if (this.enabled) {
  41019. return;
  41020. }
  41021. this.manualRowHeights = [];
  41022. var initialRowHeights = this.hot.getSettings().manualRowResize;
  41023. var loadedManualRowHeights = this.loadManualRowHeights();
  41024. if (typeof loadedManualRowHeights != 'undefined') {
  41025. this.manualRowHeights = loadedManualRowHeights;
  41026. } else if (Array.isArray(initialRowHeights)) {
  41027. this.manualRowHeights = initialRowHeights;
  41028. } else {
  41029. this.manualRowHeights = [];
  41030. }
  41031. this.addHook('modifyRowHeight', function (height, row) {
  41032. return _this2.onModifyRowHeight(height, row);
  41033. });
  41034. // Handsontable.hooks.register('beforeRowResize');
  41035. // Handsontable.hooks.register('afterRowResize');
  41036. this.bindEvents();
  41037. _get(ManualRowResize.prototype.__proto__ || Object.getPrototypeOf(ManualRowResize.prototype), 'enablePlugin', this).call(this);
  41038. }
  41039. /**
  41040. * Updates the plugin to use the latest options you have specified.
  41041. */
  41042. }, {
  41043. key: 'updatePlugin',
  41044. value: function updatePlugin() {
  41045. var initialRowHeights = this.hot.getSettings().manualRowResize;
  41046. if (Array.isArray(initialRowHeights)) {
  41047. this.manualRowHeights = initialRowHeights;
  41048. } else if (!initialRowHeights) {
  41049. this.manualRowHeights = [];
  41050. }
  41051. }
  41052. /**
  41053. * Disable plugin for this Handsontable instance.
  41054. */
  41055. }, {
  41056. key: 'disablePlugin',
  41057. value: function disablePlugin() {
  41058. _get(ManualRowResize.prototype.__proto__ || Object.getPrototypeOf(ManualRowResize.prototype), 'disablePlugin', this).call(this);
  41059. }
  41060. /**
  41061. * Save the current sizes using the persistentState plugin.
  41062. */
  41063. }, {
  41064. key: 'saveManualRowHeights',
  41065. value: function saveManualRowHeights() {
  41066. this.hot.runHooks('persistentStateSave', 'manualRowHeights', this.manualRowHeights);
  41067. }
  41068. /**
  41069. * Load the previously saved sizes using the persistentState plugin.
  41070. *
  41071. * @returns {Array}
  41072. */
  41073. }, {
  41074. key: 'loadManualRowHeights',
  41075. value: function loadManualRowHeights() {
  41076. var storedState = {};
  41077. this.hot.runHooks('persistentStateLoad', 'manualRowHeights', storedState);
  41078. return storedState.value;
  41079. }
  41080. /**
  41081. * Set the resize handle position.
  41082. *
  41083. * @param {HTMLCellElement} TH TH HTML element.
  41084. */
  41085. }, {
  41086. key: 'setupHandlePosition',
  41087. value: function setupHandlePosition(TH) {
  41088. var _this3 = this;
  41089. this.currentTH = TH;
  41090. var row = this.hot.view.wt.wtTable.getCoords(TH).row; // getCoords returns CellCoords
  41091. var headerWidth = (0, _element.outerWidth)(this.currentTH);
  41092. if (row >= 0) {
  41093. // if not col header
  41094. var box = this.currentTH.getBoundingClientRect();
  41095. this.currentRow = row;
  41096. this.selectedRows = [];
  41097. if (this.hot.selection.isSelected() && this.hot.selection.isSelectedByRowHeader()) {
  41098. var _hot$getSelectedRange = this.hot.getSelectedRangeLast(),
  41099. from = _hot$getSelectedRange.from,
  41100. to = _hot$getSelectedRange.to;
  41101. var start = from.row;
  41102. var end = to.row;
  41103. if (start >= end) {
  41104. start = to.row;
  41105. end = from.row;
  41106. }
  41107. if (this.currentRow >= start && this.currentRow <= end) {
  41108. (0, _number.rangeEach)(start, end, function (i) {
  41109. return _this3.selectedRows.push(i);
  41110. });
  41111. } else {
  41112. this.selectedRows.push(this.currentRow);
  41113. }
  41114. } else {
  41115. this.selectedRows.push(this.currentRow);
  41116. }
  41117. this.startOffset = box.top - 6;
  41118. this.startHeight = parseInt(box.height, 10);
  41119. this.handle.style.left = box.left + 'px';
  41120. this.handle.style.top = this.startOffset + this.startHeight + 'px';
  41121. this.handle.style.width = headerWidth + 'px';
  41122. this.hot.rootElement.appendChild(this.handle);
  41123. }
  41124. }
  41125. /**
  41126. * Refresh the resize handle position.
  41127. */
  41128. }, {
  41129. key: 'refreshHandlePosition',
  41130. value: function refreshHandlePosition() {
  41131. this.handle.style.top = this.startOffset + this.currentHeight + 'px';
  41132. }
  41133. /**
  41134. * Set the resize guide position.
  41135. */
  41136. }, {
  41137. key: 'setupGuidePosition',
  41138. value: function setupGuidePosition() {
  41139. var handleWidth = parseInt((0, _element.outerWidth)(this.handle), 10);
  41140. var handleRightPosition = parseInt(this.handle.style.left, 10) + handleWidth;
  41141. var maximumVisibleElementWidth = parseInt(this.hot.view.maximumVisibleElementWidth(0), 10);
  41142. (0, _element.addClass)(this.handle, 'active');
  41143. (0, _element.addClass)(this.guide, 'active');
  41144. this.guide.style.top = this.handle.style.top;
  41145. this.guide.style.left = handleRightPosition + 'px';
  41146. this.guide.style.width = maximumVisibleElementWidth - handleWidth + 'px';
  41147. this.hot.rootElement.appendChild(this.guide);
  41148. }
  41149. /**
  41150. * Refresh the resize guide position.
  41151. */
  41152. }, {
  41153. key: 'refreshGuidePosition',
  41154. value: function refreshGuidePosition() {
  41155. this.guide.style.top = this.handle.style.top;
  41156. }
  41157. /**
  41158. * Hide both the resize handle and resize guide.
  41159. */
  41160. }, {
  41161. key: 'hideHandleAndGuide',
  41162. value: function hideHandleAndGuide() {
  41163. (0, _element.removeClass)(this.handle, 'active');
  41164. (0, _element.removeClass)(this.guide, 'active');
  41165. }
  41166. /**
  41167. * Check if provided element is considered as a row header.
  41168. *
  41169. * @param {HTMLElement} element HTML element.
  41170. * @returns {Boolean}
  41171. */
  41172. }, {
  41173. key: 'checkIfRowHeader',
  41174. value: function checkIfRowHeader(element) {
  41175. if (element != this.hot.rootElement) {
  41176. var parent = element.parentNode;
  41177. if (parent.tagName === 'TBODY') {
  41178. return true;
  41179. }
  41180. return this.checkIfRowHeader(parent);
  41181. }
  41182. return false;
  41183. }
  41184. /**
  41185. * Get the TH element from the provided element.
  41186. *
  41187. * @param {HTMLElement} element HTML element.
  41188. * @returns {HTMLElement}
  41189. */
  41190. }, {
  41191. key: 'getTHFromTargetElement',
  41192. value: function getTHFromTargetElement(element) {
  41193. if (element.tagName != 'TABLE') {
  41194. if (element.tagName == 'TH') {
  41195. return element;
  41196. }
  41197. return this.getTHFromTargetElement(element.parentNode);
  41198. }
  41199. return null;
  41200. }
  41201. /**
  41202. * 'mouseover' event callback - set the handle position.
  41203. *
  41204. * @private
  41205. * @param {MouseEvent} event
  41206. */
  41207. }, {
  41208. key: 'onMouseOver',
  41209. value: function onMouseOver(event) {
  41210. if (this.checkIfRowHeader(event.target)) {
  41211. var th = this.getTHFromTargetElement(event.target);
  41212. if (th) {
  41213. if (!this.pressed) {
  41214. this.setupHandlePosition(th);
  41215. }
  41216. }
  41217. }
  41218. }
  41219. /**
  41220. * Auto-size row after doubleclick - callback.
  41221. *
  41222. * @private
  41223. */
  41224. }, {
  41225. key: 'afterMouseDownTimeout',
  41226. value: function afterMouseDownTimeout() {
  41227. var _this4 = this;
  41228. var render = function render() {
  41229. _this4.hot.forceFullRender = true;
  41230. _this4.hot.view.render(); // updates all
  41231. _this4.hot.view.wt.wtOverlays.adjustElementsSize(true);
  41232. };
  41233. var resize = function resize(selectedRow, forceRender) {
  41234. var hookNewSize = _this4.hot.runHooks('beforeRowResize', selectedRow, _this4.newSize, true);
  41235. if (hookNewSize !== void 0) {
  41236. _this4.newSize = hookNewSize;
  41237. }
  41238. _this4.setManualSize(selectedRow, _this4.newSize); // double click sets auto row size
  41239. if (forceRender) {
  41240. render();
  41241. }
  41242. _this4.hot.runHooks('afterRowResize', selectedRow, _this4.newSize, true);
  41243. };
  41244. if (this.dblclick >= 2) {
  41245. var selectedRowsLength = this.selectedRows.length;
  41246. if (selectedRowsLength > 1) {
  41247. (0, _array.arrayEach)(this.selectedRows, function (selectedRow) {
  41248. resize(selectedRow);
  41249. });
  41250. render();
  41251. } else {
  41252. (0, _array.arrayEach)(this.selectedRows, function (selectedRow) {
  41253. resize(selectedRow, true);
  41254. });
  41255. }
  41256. }
  41257. this.dblclick = 0;
  41258. this.autoresizeTimeout = null;
  41259. }
  41260. /**
  41261. * 'mousedown' event callback.
  41262. *
  41263. * @private
  41264. * @param {MouseEvent} event
  41265. */
  41266. }, {
  41267. key: 'onMouseDown',
  41268. value: function onMouseDown(event) {
  41269. var _this5 = this;
  41270. if ((0, _element.hasClass)(event.target, 'manualRowResizer')) {
  41271. this.setupGuidePosition();
  41272. this.pressed = this.hot;
  41273. if (this.autoresizeTimeout == null) {
  41274. this.autoresizeTimeout = setTimeout(function () {
  41275. return _this5.afterMouseDownTimeout();
  41276. }, 500);
  41277. this.hot._registerTimeout(this.autoresizeTimeout);
  41278. }
  41279. this.dblclick++;
  41280. this.startY = (0, _event.pageY)(event);
  41281. this.newSize = this.startHeight;
  41282. }
  41283. }
  41284. /**
  41285. * 'mousemove' event callback - refresh the handle and guide positions, cache the new row height.
  41286. *
  41287. * @private
  41288. * @param {MouseEvent} event
  41289. */
  41290. }, {
  41291. key: 'onMouseMove',
  41292. value: function onMouseMove(event) {
  41293. var _this6 = this;
  41294. if (this.pressed) {
  41295. this.currentHeight = this.startHeight + ((0, _event.pageY)(event) - this.startY);
  41296. (0, _array.arrayEach)(this.selectedRows, function (selectedRow) {
  41297. _this6.newSize = _this6.setManualSize(selectedRow, _this6.currentHeight);
  41298. });
  41299. this.refreshHandlePosition();
  41300. this.refreshGuidePosition();
  41301. }
  41302. }
  41303. /**
  41304. * 'mouseup' event callback - apply the row resizing.
  41305. *
  41306. * @private
  41307. * @param {MouseEvent} event
  41308. */
  41309. }, {
  41310. key: 'onMouseUp',
  41311. value: function onMouseUp(event) {
  41312. var _this7 = this;
  41313. var render = function render() {
  41314. _this7.hot.forceFullRender = true;
  41315. _this7.hot.view.render(); // updates all
  41316. _this7.hot.view.wt.wtOverlays.adjustElementsSize(true);
  41317. };
  41318. var runHooks = function runHooks(selectedRow, forceRender) {
  41319. _this7.hot.runHooks('beforeRowResize', selectedRow, _this7.newSize);
  41320. if (forceRender) {
  41321. render();
  41322. }
  41323. _this7.saveManualRowHeights();
  41324. _this7.hot.runHooks('afterRowResize', selectedRow, _this7.newSize);
  41325. };
  41326. if (this.pressed) {
  41327. this.hideHandleAndGuide();
  41328. this.pressed = false;
  41329. if (this.newSize != this.startHeight) {
  41330. var selectedRowsLength = this.selectedRows.length;
  41331. if (selectedRowsLength > 1) {
  41332. (0, _array.arrayEach)(this.selectedRows, function (selectedRow) {
  41333. runHooks(selectedRow);
  41334. });
  41335. render();
  41336. } else {
  41337. (0, _array.arrayEach)(this.selectedRows, function (selectedRow) {
  41338. runHooks(selectedRow, true);
  41339. });
  41340. }
  41341. }
  41342. this.setupHandlePosition(this.currentTH);
  41343. }
  41344. }
  41345. /**
  41346. * Bind the mouse events.
  41347. *
  41348. * @private
  41349. */
  41350. }, {
  41351. key: 'bindEvents',
  41352. value: function bindEvents() {
  41353. var _this8 = this;
  41354. this.eventManager.addEventListener(this.hot.rootElement, 'mouseover', function (e) {
  41355. return _this8.onMouseOver(e);
  41356. });
  41357. this.eventManager.addEventListener(this.hot.rootElement, 'mousedown', function (e) {
  41358. return _this8.onMouseDown(e);
  41359. });
  41360. this.eventManager.addEventListener(window, 'mousemove', function (e) {
  41361. return _this8.onMouseMove(e);
  41362. });
  41363. this.eventManager.addEventListener(window, 'mouseup', function (e) {
  41364. return _this8.onMouseUp(e);
  41365. });
  41366. }
  41367. /**
  41368. * Cache the current row height.
  41369. *
  41370. * @param {Number} row Visual row index.
  41371. * @param {Number} height Row height.
  41372. * @returns {Number}
  41373. */
  41374. }, {
  41375. key: 'setManualSize',
  41376. value: function setManualSize(row, height) {
  41377. row = this.hot.runHooks('modifyRow', row);
  41378. this.manualRowHeights[row] = height;
  41379. return height;
  41380. }
  41381. /**
  41382. * Modify the provided row height, based on the plugin settings.
  41383. *
  41384. * @private
  41385. * @param {Number} height Row height.
  41386. * @param {Number} row Visual row index.
  41387. * @returns {Number}
  41388. */
  41389. }, {
  41390. key: 'onModifyRowHeight',
  41391. value: function onModifyRowHeight(height, row) {
  41392. if (this.enabled) {
  41393. var autoRowSizePlugin = this.hot.getPlugin('autoRowSize');
  41394. var autoRowHeightResult = autoRowSizePlugin ? autoRowSizePlugin.heights[row] : null;
  41395. row = this.hot.runHooks('modifyRow', row);
  41396. var manualRowHeight = this.manualRowHeights[row];
  41397. if (manualRowHeight !== void 0 && (manualRowHeight === autoRowHeightResult || manualRowHeight > (height || 0))) {
  41398. return manualRowHeight;
  41399. }
  41400. }
  41401. return height;
  41402. }
  41403. }]);
  41404. return ManualRowResize;
  41405. }(_base2.default);
  41406. (0, _plugins.registerPlugin)('manualRowResize', ManualRowResize);
  41407. exports.default = ManualRowResize;
  41408. /***/ }),
  41409. /* 344 */
  41410. /***/ (function(module, exports, __webpack_require__) {
  41411. "use strict";
  41412. exports.__esModule = true;
  41413. 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"); } }; }();
  41414. 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; }; }();
  41415. 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); } };
  41416. var _base = __webpack_require__(10);
  41417. var _base2 = _interopRequireDefault(_base);
  41418. var _pluginHooks = __webpack_require__(15);
  41419. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  41420. var _plugins = __webpack_require__(8);
  41421. var _event = __webpack_require__(12);
  41422. var _src = __webpack_require__(4);
  41423. var _cellsCollection = __webpack_require__(345);
  41424. var _cellsCollection2 = _interopRequireDefault(_cellsCollection);
  41425. var _cellCoords = __webpack_require__(95);
  41426. var _cellCoords2 = _interopRequireDefault(_cellCoords);
  41427. var _autofill = __webpack_require__(346);
  41428. var _autofill2 = _interopRequireDefault(_autofill);
  41429. var _selection = __webpack_require__(347);
  41430. var _selection2 = _interopRequireDefault(_selection);
  41431. var _toggleMerge = __webpack_require__(348);
  41432. var _toggleMerge2 = _interopRequireDefault(_toggleMerge);
  41433. var _array = __webpack_require__(1);
  41434. var _object = __webpack_require__(2);
  41435. var _console = __webpack_require__(56);
  41436. var _number = __webpack_require__(5);
  41437. var _utils = __webpack_require__(204);
  41438. __webpack_require__(349);
  41439. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  41440. 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); } }
  41441. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  41442. 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; }
  41443. 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; }
  41444. _pluginHooks2.default.getSingleton().register('beforeMergeCells');
  41445. _pluginHooks2.default.getSingleton().register('afterMergeCells');
  41446. _pluginHooks2.default.getSingleton().register('beforeUnmergeCells');
  41447. _pluginHooks2.default.getSingleton().register('afterUnmergeCells');
  41448. var privatePool = new WeakMap();
  41449. /**
  41450. * @plugin MergeCells
  41451. *
  41452. * @description Plugin, which allows merging cells in the table (using the initial configuration, API or context menu).
  41453. *
  41454. * @example
  41455. *
  41456. * ```js
  41457. * ...
  41458. * let hot = new Handsontable(document.getElementById('example'), {
  41459. * data: getData(),
  41460. * mergeCells: [
  41461. * {row: 0, col: 3, rowspan: 3, colspan: 3},
  41462. * {row: 2, col: 6, rowspan: 2, colspan: 2},
  41463. * {row: 4, col: 8, rowspan: 3, colspan: 3}
  41464. * ],
  41465. * ...
  41466. * ```
  41467. */
  41468. var MergeCells = function (_BasePlugin) {
  41469. _inherits(MergeCells, _BasePlugin);
  41470. function MergeCells(hotInstance) {
  41471. _classCallCheck(this, MergeCells);
  41472. var _this = _possibleConstructorReturn(this, (MergeCells.__proto__ || Object.getPrototypeOf(MergeCells)).call(this, hotInstance));
  41473. privatePool.set(_this, {
  41474. lastDesiredCoords: null
  41475. });
  41476. /**
  41477. * A container for all the merged cells.
  41478. *
  41479. * @type {MergedCellsCollection}
  41480. */
  41481. _this.mergedCellsCollection = null;
  41482. /**
  41483. * Instance of the class responsible for all the autofill-related calculations.
  41484. *
  41485. * @private
  41486. * @type {AutofillCalculations}
  41487. */
  41488. _this.autofillCalculations = null;
  41489. /**
  41490. * Instance of the class responsible for the selection-related calculations.
  41491. *
  41492. * @private
  41493. * @type {SelectionCalculations}
  41494. */
  41495. _this.selectionCalculations = null;
  41496. return _this;
  41497. }
  41498. /**
  41499. * Check if the plugin is enabled in the Handsontable settings.
  41500. *
  41501. * @returns {Boolean}
  41502. */
  41503. _createClass(MergeCells, [{
  41504. key: 'isEnabled',
  41505. value: function isEnabled() {
  41506. return !!this.hot.getSettings().mergeCells;
  41507. }
  41508. /**
  41509. * Enable the plugin.
  41510. */
  41511. }, {
  41512. key: 'enablePlugin',
  41513. value: function enablePlugin() {
  41514. var _this2 = this;
  41515. if (this.enabled) {
  41516. return;
  41517. }
  41518. this.mergedCellsCollection = new _cellsCollection2.default(this);
  41519. this.autofillCalculations = new _autofill2.default(this);
  41520. this.selectionCalculations = new _selection2.default(this);
  41521. this.addHook('afterInit', function () {
  41522. return _this2.onAfterInit.apply(_this2, arguments);
  41523. });
  41524. this.addHook('beforeKeyDown', function () {
  41525. return _this2.onBeforeKeyDown.apply(_this2, arguments);
  41526. });
  41527. this.addHook('modifyTransformStart', function () {
  41528. return _this2.onModifyTransformStart.apply(_this2, arguments);
  41529. });
  41530. this.addHook('afterModifyTransformStart', function () {
  41531. return _this2.onAfterModifyTransformStart.apply(_this2, arguments);
  41532. });
  41533. this.addHook('modifyTransformEnd', function () {
  41534. return _this2.onModifyTransformEnd.apply(_this2, arguments);
  41535. });
  41536. this.addHook('modifyGetCellCoords', function () {
  41537. return _this2.onModifyGetCellCoords.apply(_this2, arguments);
  41538. });
  41539. this.addHook('beforeSetRangeEnd', function () {
  41540. return _this2.onBeforeSetRangeEnd.apply(_this2, arguments);
  41541. });
  41542. this.addHook('afterIsMultipleSelection', function () {
  41543. return _this2.onAfterIsMultipleSelection.apply(_this2, arguments);
  41544. });
  41545. this.addHook('afterRenderer', function () {
  41546. return _this2.onAfterRenderer.apply(_this2, arguments);
  41547. });
  41548. this.addHook('afterContextMenuDefaultOptions', function () {
  41549. return _this2.addMergeActionsToContextMenu.apply(_this2, arguments);
  41550. });
  41551. this.addHook('afterGetCellMeta', function () {
  41552. return _this2.onAfterGetCellMeta.apply(_this2, arguments);
  41553. });
  41554. this.addHook('afterViewportRowCalculatorOverride', function () {
  41555. return _this2.onAfterViewportRowCalculatorOverride.apply(_this2, arguments);
  41556. });
  41557. this.addHook('afterViewportColumnCalculatorOverride', function () {
  41558. return _this2.onAfterViewportColumnCalculatorOverride.apply(_this2, arguments);
  41559. });
  41560. this.addHook('modifyAutofillRange', function () {
  41561. return _this2.onModifyAutofillRange.apply(_this2, arguments);
  41562. });
  41563. this.addHook('afterCreateCol', function () {
  41564. return _this2.onAfterCreateCol.apply(_this2, arguments);
  41565. });
  41566. this.addHook('afterRemoveCol', function () {
  41567. return _this2.onAfterRemoveCol.apply(_this2, arguments);
  41568. });
  41569. this.addHook('afterCreateRow', function () {
  41570. return _this2.onAfterCreateRow.apply(_this2, arguments);
  41571. });
  41572. this.addHook('afterRemoveRow', function () {
  41573. return _this2.onAfterRemoveRow.apply(_this2, arguments);
  41574. });
  41575. this.addHook('afterChange', function () {
  41576. return _this2.onAfterChange.apply(_this2, arguments);
  41577. });
  41578. this.addHook('beforeDrawBorders', function () {
  41579. return _this2.onBeforeDrawAreaBorders.apply(_this2, arguments);
  41580. });
  41581. this.addHook('afterDrawSelection', function () {
  41582. return _this2.onAfterDrawSelection.apply(_this2, arguments);
  41583. });
  41584. this.addHook('beforeRemoveCellClassNames', function () {
  41585. return _this2.onBeforeRemoveCellClassNames.apply(_this2, arguments);
  41586. });
  41587. _get(MergeCells.prototype.__proto__ || Object.getPrototypeOf(MergeCells.prototype), 'enablePlugin', this).call(this);
  41588. }
  41589. /**
  41590. * Disable the plugin.
  41591. */
  41592. }, {
  41593. key: 'disablePlugin',
  41594. value: function disablePlugin() {
  41595. this.clearCollections();
  41596. this.hot.render();
  41597. _get(MergeCells.prototype.__proto__ || Object.getPrototypeOf(MergeCells.prototype), 'disablePlugin', this).call(this);
  41598. }
  41599. /**
  41600. * Update the plugin (after using the `updateSettings` method)
  41601. */
  41602. }, {
  41603. key: 'updatePlugin',
  41604. value: function updatePlugin() {
  41605. var settings = this.hot.getSettings().mergeCells;
  41606. this.clearCollections();
  41607. this.disablePlugin();
  41608. this.enablePlugin();
  41609. this.generateFromSettings(settings);
  41610. _get(MergeCells.prototype.__proto__ || Object.getPrototypeOf(MergeCells.prototype), 'updatePlugin', this).call(this);
  41611. }
  41612. /**
  41613. * Validate a single setting object, represented by a single merged cell information object.
  41614. *
  41615. * @private
  41616. * @param {Object} setting An object with `row`, `col`, `rowspan` and `colspan` properties.
  41617. * @return {Boolean}
  41618. */
  41619. }, {
  41620. key: 'validateSetting',
  41621. value: function validateSetting(setting) {
  41622. var valid = true;
  41623. if (!setting) {
  41624. return false;
  41625. }
  41626. if (_cellCoords2.default.containsNegativeValues(setting)) {
  41627. (0, _console.warn)(_cellCoords2.default.NEGATIVE_VALUES_WARNING(setting));
  41628. valid = false;
  41629. } else if (_cellCoords2.default.isOutOfBounds(setting, this.hot.countRows(), this.hot.countCols())) {
  41630. (0, _console.warn)(_cellCoords2.default.IS_OUT_OF_BOUNDS_WARNING(setting));
  41631. valid = false;
  41632. } else if (_cellCoords2.default.isSingleCell(setting)) {
  41633. (0, _console.warn)(_cellCoords2.default.IS_SINGLE_CELL(setting));
  41634. valid = false;
  41635. } else if (_cellCoords2.default.containsZeroSpan(setting)) {
  41636. (0, _console.warn)(_cellCoords2.default.ZERO_SPAN_WARNING(setting));
  41637. valid = false;
  41638. }
  41639. return valid;
  41640. }
  41641. /**
  41642. * Generate the merged cells from the settings provided to the plugin.
  41643. *
  41644. * @private
  41645. * @param {Array|Boolean} settings The settings provided to the plugin.
  41646. */
  41647. }, {
  41648. key: 'generateFromSettings',
  41649. value: function generateFromSettings(settings) {
  41650. var _this3 = this;
  41651. if (Array.isArray(settings)) {
  41652. var _hot;
  41653. var populationArgumentsList = [];
  41654. (0, _array.arrayEach)(settings, function (setting) {
  41655. if (!_this3.validateSetting(setting)) {
  41656. return;
  41657. }
  41658. var highlight = new _src.CellCoords(setting.row, setting.col);
  41659. var rangeEnd = new _src.CellCoords(setting.row + setting.rowspan - 1, setting.col + setting.colspan - 1);
  41660. var mergeRange = new _src.CellRange(highlight, highlight, rangeEnd);
  41661. populationArgumentsList.push(_this3.mergeRange(mergeRange, true, true));
  41662. });
  41663. // remove 'empty' setting objects, caused by improper merge range declarations
  41664. populationArgumentsList = populationArgumentsList.filter(function (value) {
  41665. return value !== true;
  41666. });
  41667. var bulkPopulationData = this.getBulkCollectionData(populationArgumentsList);
  41668. (_hot = this.hot).populateFromArray.apply(_hot, _toConsumableArray(bulkPopulationData));
  41669. }
  41670. }
  41671. /**
  41672. * Generates a bulk set of all the data to be populated to fill the data "under" the added merged cells.
  41673. *
  41674. * @private
  41675. * @param {Array} populationArgumentsList Array in a form of `[row, column, dataUnderCollection]`.
  41676. * @return {Array} Array in a form of `[row, column, dataOfAllCollections]`.
  41677. */
  41678. }, {
  41679. key: 'getBulkCollectionData',
  41680. value: function getBulkCollectionData(populationArgumentsList) {
  41681. var _hot2;
  41682. var populationDataRange = this.getBulkCollectionDataRange(populationArgumentsList);
  41683. var dataAtRange = (_hot2 = this.hot).getData.apply(_hot2, _toConsumableArray(populationDataRange));
  41684. var newDataAtRange = dataAtRange.splice(0);
  41685. (0, _array.arrayEach)(populationArgumentsList, function (mergedCellArguments) {
  41686. var _mergedCellArguments = _slicedToArray(mergedCellArguments, 3),
  41687. mergedCellRowIndex = _mergedCellArguments[0],
  41688. mergedCellColumnIndex = _mergedCellArguments[1],
  41689. mergedCellData = _mergedCellArguments[2];
  41690. (0, _array.arrayEach)(mergedCellData, function (mergedCellRow, rowIndex) {
  41691. (0, _array.arrayEach)(mergedCellRow, function (mergedCellElement, columnIndex) {
  41692. newDataAtRange[mergedCellRowIndex - populationDataRange[0] + rowIndex][mergedCellColumnIndex - populationDataRange[1] + columnIndex] = mergedCellElement;
  41693. });
  41694. });
  41695. });
  41696. return [populationDataRange[0], populationDataRange[1], newDataAtRange];
  41697. }
  41698. /**
  41699. * Get the range of combined data ranges provided in a form of an array of arrays ([row, column, dataUnderCollection])
  41700. *
  41701. * @private
  41702. * @param {Array} populationArgumentsList Array containing argument lists for the `populateFromArray` method - row, column and data for population.
  41703. * @return {Array[]} Start and end coordinates of the merged cell range. (in a form of [rowIndex, columnIndex])
  41704. */
  41705. }, {
  41706. key: 'getBulkCollectionDataRange',
  41707. value: function getBulkCollectionDataRange(populationArgumentsList) {
  41708. var start = [0, 0];
  41709. var end = [0, 0];
  41710. var mergedCellRow = null;
  41711. var mergedCellColumn = null;
  41712. var mergedCellData = null;
  41713. (0, _array.arrayEach)(populationArgumentsList, function (mergedCellArguments) {
  41714. mergedCellRow = mergedCellArguments[0];
  41715. mergedCellColumn = mergedCellArguments[1];
  41716. mergedCellData = mergedCellArguments[2];
  41717. start[0] = Math.min(mergedCellRow, start[0]);
  41718. start[1] = Math.min(mergedCellColumn, start[1]);
  41719. end[0] = Math.max(mergedCellRow + mergedCellData.length - 1, end[0]);
  41720. end[1] = Math.max(mergedCellColumn + mergedCellData[0].length - 1, end[1]);
  41721. });
  41722. return [].concat(start, end);
  41723. }
  41724. /**
  41725. * Clear the merged cells from the merged cell container.
  41726. */
  41727. }, {
  41728. key: 'clearCollections',
  41729. value: function clearCollections() {
  41730. this.mergedCellsCollection.clear();
  41731. }
  41732. /**
  41733. * Returns `true` if a range is mergeable.
  41734. *
  41735. * @private
  41736. * @param {Object} newMergedCellInfo Merged cell information object to test.
  41737. * @param {Boolean} [auto=false] `true` if triggered at initialization.
  41738. * @returns {Boolean}
  41739. */
  41740. }, {
  41741. key: 'canMergeRange',
  41742. value: function canMergeRange(newMergedCellInfo) {
  41743. var auto = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  41744. return auto ? true : this.validateSetting(newMergedCellInfo);
  41745. }
  41746. /**
  41747. * Merge or unmerge, based on last selected range.
  41748. *
  41749. * @private
  41750. */
  41751. }, {
  41752. key: 'toggleMergeOnSelection',
  41753. value: function toggleMergeOnSelection() {
  41754. var currentRange = this.hot.getSelectedRangeLast();
  41755. if (!currentRange) {
  41756. return;
  41757. }
  41758. currentRange.setDirection('NW-SE');
  41759. var from = currentRange.from,
  41760. to = currentRange.to;
  41761. this.toggleMerge(currentRange);
  41762. this.hot.selectCell(from.row, from.col, to.row, to.col, false);
  41763. }
  41764. /**
  41765. * Merge the selection provided as a cell range.
  41766. *
  41767. * @param {CellRange} [cellRange] Selection cell range.
  41768. */
  41769. }, {
  41770. key: 'mergeSelection',
  41771. value: function mergeSelection() {
  41772. var cellRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.hot.getSelectedRangeLast();
  41773. if (!cellRange) {
  41774. return;
  41775. }
  41776. cellRange.setDirection('NW-SE');
  41777. var from = cellRange.from,
  41778. to = cellRange.to;
  41779. this.unmergeRange(cellRange, true);
  41780. this.mergeRange(cellRange);
  41781. this.hot.selectCell(from.row, from.col, to.row, to.col, false);
  41782. }
  41783. /**
  41784. * Unmerge the selection provided as a cell range.
  41785. *
  41786. * @param {CellRange} [cellRange] Selection cell range.
  41787. */
  41788. }, {
  41789. key: 'unmergeSelection',
  41790. value: function unmergeSelection() {
  41791. var cellRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.hot.getSelectedRangeLast();
  41792. if (!cellRange) {
  41793. return;
  41794. }
  41795. var from = cellRange.from,
  41796. to = cellRange.to;
  41797. this.unmergeRange(cellRange, true);
  41798. this.hot.selectCell(from.row, from.col, to.row, to.col, false);
  41799. }
  41800. /**
  41801. * Merge cells in the provided cell range.
  41802. *
  41803. * @private
  41804. * @param {CellRange} cellRange Cell range to merge.
  41805. * @param {Boolean} [auto=false] `true` if is called automatically, e.g. at initialization.
  41806. * @param {Boolean} [preventPopulation=false] `true`, if the method should not run `populateFromArray` at the end, but rather return its arguments.
  41807. * @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`.
  41808. * @fires Hooks#beforeMergeCells
  41809. * @fires Hooks#afterMergeCells
  41810. */
  41811. }, {
  41812. key: 'mergeRange',
  41813. value: function mergeRange(cellRange) {
  41814. var _this4 = this;
  41815. var auto = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  41816. var preventPopulation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  41817. var topLeft = cellRange.getTopLeftCorner();
  41818. var bottomRight = cellRange.getBottomRightCorner();
  41819. var mergeParent = {
  41820. row: topLeft.row,
  41821. col: topLeft.col,
  41822. rowspan: bottomRight.row - topLeft.row + 1,
  41823. colspan: bottomRight.col - topLeft.col + 1
  41824. };
  41825. var clearedData = [];
  41826. var populationInfo = null;
  41827. if (!this.canMergeRange(mergeParent, auto)) {
  41828. return false;
  41829. }
  41830. this.hot.runHooks('beforeMergeCells', cellRange, auto);
  41831. (0, _number.rangeEach)(0, mergeParent.rowspan - 1, function (i) {
  41832. (0, _number.rangeEach)(0, mergeParent.colspan - 1, function (j) {
  41833. var clearedValue = null;
  41834. if (!clearedData[i]) {
  41835. clearedData[i] = [];
  41836. }
  41837. if (i === 0 && j === 0) {
  41838. clearedValue = _this4.hot.getDataAtCell(mergeParent.row, mergeParent.col);
  41839. } else {
  41840. _this4.hot.setCellMeta(mergeParent.row + i, mergeParent.col + j, 'hidden', true);
  41841. }
  41842. clearedData[i][j] = clearedValue;
  41843. });
  41844. });
  41845. this.hot.setCellMeta(mergeParent.row, mergeParent.col, 'spanned', true);
  41846. var mergedCellAdded = this.mergedCellsCollection.add(mergeParent);
  41847. if (mergedCellAdded) {
  41848. if (preventPopulation) {
  41849. populationInfo = [mergeParent.row, mergeParent.col, clearedData];
  41850. } else {
  41851. this.hot.populateFromArray(mergeParent.row, mergeParent.col, clearedData, void 0, void 0, this.pluginName);
  41852. }
  41853. this.hot.runHooks('afterMergeCells', cellRange, mergeParent, auto);
  41854. return populationInfo;
  41855. }
  41856. return true;
  41857. }
  41858. /**
  41859. * Unmerge the selection provided as a cell range. If no cell range is provided, it uses the current selection.
  41860. *
  41861. * @private
  41862. * @param {CellRange} cellRange Selection cell range.
  41863. * @param {Boolean} [auto=false] `true` if called automatically by the plugin.
  41864. */
  41865. }, {
  41866. key: 'unmergeRange',
  41867. value: function unmergeRange(cellRange) {
  41868. var _this5 = this;
  41869. var auto = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  41870. var mergedCells = this.mergedCellsCollection.getWithinRange(cellRange);
  41871. if (!mergedCells) {
  41872. return;
  41873. }
  41874. this.hot.runHooks('beforeUnmergeCells', cellRange, auto);
  41875. (0, _array.arrayEach)(mergedCells, function (currentCollection) {
  41876. _this5.mergedCellsCollection.remove(currentCollection.row, currentCollection.col);
  41877. (0, _number.rangeEach)(0, currentCollection.rowspan - 1, function (i) {
  41878. (0, _number.rangeEach)(0, currentCollection.colspan - 1, function (j) {
  41879. _this5.hot.removeCellMeta(currentCollection.row + i, currentCollection.col + j, 'hidden');
  41880. });
  41881. });
  41882. _this5.hot.removeCellMeta(currentCollection.row, currentCollection.col, 'spanned');
  41883. });
  41884. this.hot.render();
  41885. this.hot.runHooks('afterUnmergeCells', cellRange, auto);
  41886. }
  41887. /**
  41888. * Merge or unmerge, based on the cell range provided as `cellRange`.
  41889. *
  41890. * @private
  41891. * @param {CellRange} cellRange The cell range to merge or unmerged.
  41892. */
  41893. }, {
  41894. key: 'toggleMerge',
  41895. value: function toggleMerge(cellRange) {
  41896. var mergedCell = this.mergedCellsCollection.get(cellRange.from.row, cellRange.from.col);
  41897. 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;
  41898. if (mergedCellCoversWholeRange) {
  41899. this.unmergeRange(cellRange);
  41900. } else {
  41901. this.mergeSelection(cellRange);
  41902. }
  41903. }
  41904. /**
  41905. * Merge the specified range.
  41906. *
  41907. * @param {Number} startRow Start row of the merged cell.
  41908. * @param {Number} startColumn Start column of the merged cell.
  41909. * @param {Number} endRow End row of the merged cell.
  41910. * @param {Number} endColumn End column of the merged cell.
  41911. */
  41912. }, {
  41913. key: 'merge',
  41914. value: function merge(startRow, startColumn, endRow, endColumn) {
  41915. var start = new _src.CellCoords(startRow, startColumn);
  41916. var end = new _src.CellCoords(endRow, endColumn);
  41917. this.mergeRange(new _src.CellRange(start, start, end));
  41918. }
  41919. /**
  41920. * Unmerge the merged cell in the provided range.
  41921. *
  41922. * @param {Number} startRow Start row of the merged cell.
  41923. * @param {Number} startColumn Start column of the merged cell.
  41924. * @param {Number} endRow End row of the merged cell.
  41925. * @param {Number} endColumn End column of the merged cell.
  41926. */
  41927. }, {
  41928. key: 'unmerge',
  41929. value: function unmerge(startRow, startColumn, endRow, endColumn) {
  41930. var start = new _src.CellCoords(startRow, startColumn);
  41931. var end = new _src.CellCoords(endRow, endColumn);
  41932. this.unmergeRange(new _src.CellRange(start, start, end));
  41933. }
  41934. /**
  41935. * `afterInit` hook callback.
  41936. *
  41937. * @private
  41938. */
  41939. }, {
  41940. key: 'onAfterInit',
  41941. value: function onAfterInit() {
  41942. this.generateFromSettings(this.hot.getSettings().mergeCells);
  41943. this.hot.render();
  41944. }
  41945. /**
  41946. * `beforeKeyDown` hook callback.
  41947. *
  41948. * @private
  41949. * @param {KeyboardEvent} event The `keydown` event object.
  41950. */
  41951. }, {
  41952. key: 'onBeforeKeyDown',
  41953. value: function onBeforeKeyDown(event) {
  41954. var ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  41955. if (ctrlDown && event.keyCode === 77) {
  41956. // CTRL + M
  41957. this.toggleMerge(this.hot.getSelectedRangeLast());
  41958. this.hot.render();
  41959. (0, _event.stopImmediatePropagation)(event);
  41960. }
  41961. }
  41962. /**
  41963. * Modify the information on whether the current selection contains multiple cells. The `afterIsMultipleSelection` hook callback.
  41964. *
  41965. * @private
  41966. * @param {Boolean} isMultiple
  41967. * @returns {Boolean}
  41968. */
  41969. }, {
  41970. key: 'onAfterIsMultipleSelection',
  41971. value: function onAfterIsMultipleSelection(isMultiple) {
  41972. if (isMultiple) {
  41973. var mergedCells = this.mergedCellsCollection.mergedCells;
  41974. var selectionRange = this.hot.getSelectedRangeLast();
  41975. for (var group = 0; group < mergedCells.length; group += 1) {
  41976. 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) {
  41977. return false;
  41978. }
  41979. }
  41980. }
  41981. return isMultiple;
  41982. }
  41983. /**
  41984. * `modifyTransformStart` hook callback.
  41985. *
  41986. * @private
  41987. * @param {Object} delta The transformation delta.
  41988. */
  41989. }, {
  41990. key: 'onModifyTransformStart',
  41991. value: function onModifyTransformStart(delta) {
  41992. var priv = privatePool.get(this);
  41993. var currentlySelectedRange = this.hot.getSelectedRangeLast();
  41994. var newDelta = {
  41995. row: delta.row,
  41996. col: delta.col
  41997. };
  41998. var nextPosition = null;
  41999. var currentPosition = new _src.CellCoords(currentlySelectedRange.highlight.row, currentlySelectedRange.highlight.col);
  42000. var mergedParent = this.mergedCellsCollection.get(currentPosition.row, currentPosition.col);
  42001. if (!priv.lastDesiredCoords) {
  42002. priv.lastDesiredCoords = new _src.CellCoords(null, null);
  42003. }
  42004. if (mergedParent) {
  42005. // only merge selected
  42006. var mergeTopLeft = new _src.CellCoords(mergedParent.row, mergedParent.col);
  42007. var mergeBottomRight = new _src.CellCoords(mergedParent.row + mergedParent.rowspan - 1, mergedParent.col + mergedParent.colspan - 1);
  42008. var mergeRange = new _src.CellRange(mergeTopLeft, mergeTopLeft, mergeBottomRight);
  42009. if (!mergeRange.includes(priv.lastDesiredCoords)) {
  42010. priv.lastDesiredCoords = new _src.CellCoords(null, null); // reset outdated version of lastDesiredCoords
  42011. }
  42012. newDelta.row = priv.lastDesiredCoords.row ? priv.lastDesiredCoords.row - currentPosition.row : newDelta.row;
  42013. newDelta.col = priv.lastDesiredCoords.col ? priv.lastDesiredCoords.col - currentPosition.col : newDelta.col;
  42014. if (delta.row > 0) {
  42015. // moving down
  42016. newDelta.row = mergedParent.row + mergedParent.rowspan - 1 - currentPosition.row + delta.row;
  42017. } else if (delta.row < 0) {
  42018. // moving up
  42019. newDelta.row = currentPosition.row - mergedParent.row + delta.row;
  42020. }
  42021. if (delta.col > 0) {
  42022. // moving right
  42023. newDelta.col = mergedParent.col + mergedParent.colspan - 1 - currentPosition.col + delta.col;
  42024. } else if (delta.col < 0) {
  42025. // moving left
  42026. newDelta.col = currentPosition.col - mergedParent.col + delta.col;
  42027. }
  42028. }
  42029. nextPosition = new _src.CellCoords(currentlySelectedRange.highlight.row + newDelta.row, currentlySelectedRange.highlight.col + newDelta.col);
  42030. var nextParentIsMerged = this.mergedCellsCollection.get(nextPosition.row, nextPosition.col);
  42031. if (nextParentIsMerged) {
  42032. // skipping the invisible cells in the merge range
  42033. priv.lastDesiredCoords = nextPosition;
  42034. newDelta = {
  42035. row: nextParentIsMerged.row - currentPosition.row,
  42036. col: nextParentIsMerged.col - currentPosition.col
  42037. };
  42038. }
  42039. if (newDelta.row !== 0) {
  42040. delta.row = newDelta.row;
  42041. }
  42042. if (newDelta.col !== 0) {
  42043. delta.col = newDelta.col;
  42044. }
  42045. }
  42046. /**
  42047. * `modifyTransformEnd` hook callback. Needed to handle "jumping over" merged merged cells, while selecting.
  42048. *
  42049. * @private
  42050. * @param {Object} delta The transformation delta.
  42051. */
  42052. }, {
  42053. key: 'onModifyTransformEnd',
  42054. value: function onModifyTransformEnd(delta) {
  42055. var _this6 = this;
  42056. var currentSelectionRange = this.hot.getSelectedRangeLast();
  42057. var newDelta = (0, _object.clone)(delta);
  42058. var newSelectionRange = this.selectionCalculations.getUpdatedSelectionRange(currentSelectionRange, delta);
  42059. var tempDelta = (0, _object.clone)(newDelta);
  42060. var mergedCellsWithinRange = this.mergedCellsCollection.getWithinRange(newSelectionRange, true);
  42061. do {
  42062. tempDelta = (0, _object.clone)(newDelta);
  42063. this.selectionCalculations.getUpdatedSelectionRange(currentSelectionRange, newDelta);
  42064. (0, _array.arrayEach)(mergedCellsWithinRange, function (mergedCell) {
  42065. _this6.selectionCalculations.snapDelta(newDelta, currentSelectionRange, mergedCell);
  42066. });
  42067. } while (newDelta.row !== tempDelta.row || newDelta.col !== tempDelta.col);
  42068. delta.row = newDelta.row;
  42069. delta.col = newDelta.col;
  42070. }
  42071. /**
  42072. * `modifyGetCellCoords` hook callback. Swaps the `getCell` coords with the merged parent coords.
  42073. *
  42074. * @private
  42075. * @param {Number} row Row index.
  42076. * @param {Number} column Column index.
  42077. * @returns {Array}
  42078. */
  42079. }, {
  42080. key: 'onModifyGetCellCoords',
  42081. value: function onModifyGetCellCoords(row, column) {
  42082. var mergeParent = this.mergedCellsCollection.get(row, column);
  42083. return mergeParent ? [mergeParent.row, mergeParent.col, mergeParent.row + mergeParent.rowspan - 1, mergeParent.col + mergeParent.colspan - 1] : void 0;
  42084. }
  42085. /**
  42086. * `afterContextMenuDefaultOptions` hook callback.
  42087. *
  42088. * @private
  42089. * @param {Object} defaultOptions The default context menu options.
  42090. */
  42091. }, {
  42092. key: 'addMergeActionsToContextMenu',
  42093. value: function addMergeActionsToContextMenu(defaultOptions) {
  42094. defaultOptions.items.push({
  42095. name: '---------'
  42096. }, (0, _toggleMerge2.default)(this));
  42097. }
  42098. /**
  42099. * `afterRenderer` hook callback.
  42100. *
  42101. * @private
  42102. * @param {HTMLElement} TD The cell to be modified.
  42103. * @param {Number} row Row index.
  42104. * @param {Number} col Column index.
  42105. */
  42106. }, {
  42107. key: 'onAfterRenderer',
  42108. value: function onAfterRenderer(TD, row, col) {
  42109. var mergedCell = this.mergedCellsCollection.get(row, col);
  42110. (0, _utils.applySpanProperties)(TD, mergedCell, row, col);
  42111. }
  42112. /**
  42113. * `beforeSetRangeEnd` hook callback.
  42114. * While selecting cells with keyboard or mouse, make sure that rectangular area is expanded to the extent of the merged cell
  42115. *
  42116. * @private
  42117. * @param {Object} coords Cell coords.
  42118. */
  42119. }, {
  42120. key: 'onBeforeSetRangeEnd',
  42121. value: function onBeforeSetRangeEnd(coords) {
  42122. var selRange = this.hot.getSelectedRangeLast();
  42123. selRange.highlight = new _src.CellCoords(selRange.highlight.row, selRange.highlight.col); // clone in case we will modify its reference
  42124. selRange.to = coords;
  42125. var rangeExpanded = false;
  42126. if (selRange.from.row === 0 && selRange.to.row === this.hot.countRows() - 1 || selRange.from.col === 0 && selRange.to.col === this.hot.countCols() - 1) {
  42127. return;
  42128. }
  42129. do {
  42130. rangeExpanded = false;
  42131. for (var i = 0; i < this.mergedCellsCollection.mergedCells.length; i += 1) {
  42132. var cellInfo = this.mergedCellsCollection.mergedCells[i];
  42133. var mergedCellRange = cellInfo.getRange();
  42134. if (selRange.expandByRange(mergedCellRange)) {
  42135. coords.row = selRange.to.row;
  42136. coords.col = selRange.to.col;
  42137. rangeExpanded = true;
  42138. }
  42139. }
  42140. } while (rangeExpanded);
  42141. }
  42142. /**
  42143. * The `afterGetCellMeta` hook callback.
  42144. *
  42145. * @private
  42146. * @param {Number} row Row index.
  42147. * @param {Number} col Column index.
  42148. * @param {Object} cellProperties The cell properties object.
  42149. */
  42150. }, {
  42151. key: 'onAfterGetCellMeta',
  42152. value: function onAfterGetCellMeta(row, col, cellProperties) {
  42153. var mergeParent = this.mergedCellsCollection.get(row, col);
  42154. if (mergeParent && (mergeParent.row !== row || mergeParent.col !== col)) {
  42155. cellProperties.copyable = false;
  42156. }
  42157. }
  42158. /**
  42159. * `afterViewportRowCalculatorOverride` hook callback.
  42160. *
  42161. * @private
  42162. * @param {Object} calc The row calculator object.
  42163. */
  42164. }, {
  42165. key: 'onAfterViewportRowCalculatorOverride',
  42166. value: function onAfterViewportRowCalculatorOverride(calc) {
  42167. var _this7 = this;
  42168. var colCount = this.hot.countCols();
  42169. var mergeParent = void 0;
  42170. (0, _number.rangeEach)(0, colCount - 1, function (c) {
  42171. mergeParent = _this7.mergedCellsCollection.get(calc.startRow, c);
  42172. if (mergeParent) {
  42173. if (mergeParent.row < calc.startRow) {
  42174. calc.startRow = mergeParent.row;
  42175. return _this7.onAfterViewportRowCalculatorOverride.call(_this7, calc); // recursively search upwards
  42176. }
  42177. }
  42178. mergeParent = _this7.mergedCellsCollection.get(calc.endRow, c);
  42179. if (mergeParent) {
  42180. var mergeEnd = mergeParent.row + mergeParent.rowspan - 1;
  42181. if (mergeEnd > calc.endRow) {
  42182. calc.endRow = mergeEnd;
  42183. return _this7.onAfterViewportRowCalculatorOverride.call(_this7, calc); // recursively search upwards
  42184. }
  42185. }
  42186. return true;
  42187. });
  42188. }
  42189. /**
  42190. * `afterViewportColumnCalculatorOverride` hook callback.
  42191. *
  42192. * @private
  42193. * @param {Object} calc The column calculator object.
  42194. */
  42195. }, {
  42196. key: 'onAfterViewportColumnCalculatorOverride',
  42197. value: function onAfterViewportColumnCalculatorOverride(calc) {
  42198. var _this8 = this;
  42199. var rowCount = this.hot.countRows();
  42200. var mergeParent = void 0;
  42201. (0, _number.rangeEach)(0, rowCount - 1, function (r) {
  42202. mergeParent = _this8.mergedCellsCollection.get(r, calc.startColumn);
  42203. if (mergeParent && mergeParent.col < calc.startColumn) {
  42204. calc.startColumn = mergeParent.col;
  42205. return _this8.onAfterViewportColumnCalculatorOverride.call(_this8, calc); // recursively search upwards
  42206. }
  42207. mergeParent = _this8.mergedCellsCollection.get(r, calc.endColumn);
  42208. if (mergeParent) {
  42209. var mergeEnd = mergeParent.col + mergeParent.colspan - 1;
  42210. if (mergeEnd > calc.endColumn) {
  42211. calc.endColumn = mergeEnd;
  42212. return _this8.onAfterViewportColumnCalculatorOverride.call(_this8, calc); // recursively search upwards
  42213. }
  42214. }
  42215. return true;
  42216. });
  42217. }
  42218. /**
  42219. * The `modifyAutofillRange` hook callback.
  42220. *
  42221. * @private
  42222. * @param {Array} drag The drag area coordinates.
  42223. * @param {Array} select The selection information.
  42224. * @return {Array} The new drag area.
  42225. */
  42226. }, {
  42227. key: 'onModifyAutofillRange',
  42228. value: function onModifyAutofillRange(drag, select) {
  42229. this.autofillCalculations.correctSelectionAreaSize(select);
  42230. var dragDirection = this.autofillCalculations.getDirection(select, drag);
  42231. if (this.autofillCalculations.dragAreaOverlapsCollections(select, drag, dragDirection)) {
  42232. drag = select;
  42233. return drag;
  42234. }
  42235. var mergedCellsWithinSelectionArea = this.mergedCellsCollection.getWithinRange({
  42236. from: { row: select[0], col: select[1] },
  42237. to: { row: select[2], col: select[3] }
  42238. });
  42239. if (!mergedCellsWithinSelectionArea) {
  42240. return drag;
  42241. }
  42242. drag = this.autofillCalculations.snapDragArea(select, drag, dragDirection, mergedCellsWithinSelectionArea);
  42243. return drag;
  42244. }
  42245. /**
  42246. * `afterCreateCol` hook callback.
  42247. *
  42248. * @private
  42249. * @param {Number} column Column index.
  42250. * @param {Number} count Number of created columns.
  42251. */
  42252. }, {
  42253. key: 'onAfterCreateCol',
  42254. value: function onAfterCreateCol(column, count) {
  42255. this.mergedCellsCollection.shiftCollections('right', column, count);
  42256. }
  42257. /**
  42258. * `afterRemoveCol` hook callback.
  42259. *
  42260. * @private
  42261. * @param {Number} column Column index.
  42262. * @param {Number} count Number of removed columns.
  42263. */
  42264. }, {
  42265. key: 'onAfterRemoveCol',
  42266. value: function onAfterRemoveCol(column, count) {
  42267. this.mergedCellsCollection.shiftCollections('left', column, count);
  42268. }
  42269. /**
  42270. * `afterCreateRow` hook callback.
  42271. *
  42272. * @private
  42273. * @param {Number} row Row index.
  42274. * @param {Number} count Number of created rows.
  42275. * @param {String} source Source of change.
  42276. */
  42277. }, {
  42278. key: 'onAfterCreateRow',
  42279. value: function onAfterCreateRow(row, count, source) {
  42280. if (source === 'auto') {
  42281. return;
  42282. }
  42283. this.mergedCellsCollection.shiftCollections('down', row, count);
  42284. }
  42285. /**
  42286. * `afterRemoveRow` hook callback.
  42287. *
  42288. * @private
  42289. * @param {Number} row Row index.
  42290. * @param {Number} count Number of removed rows.
  42291. */
  42292. }, {
  42293. key: 'onAfterRemoveRow',
  42294. value: function onAfterRemoveRow(row, count) {
  42295. this.mergedCellsCollection.shiftCollections('up', row, count);
  42296. }
  42297. /**
  42298. * `afterChange` hook callback. Used to propagate merged cells after using Autofill.
  42299. *
  42300. * @private
  42301. * @param {Array} changes The changes array.
  42302. * @param {String} source Determines the source of the change.
  42303. */
  42304. }, {
  42305. key: 'onAfterChange',
  42306. value: function onAfterChange(changes, source) {
  42307. if (source !== 'Autofill.fill') {
  42308. return;
  42309. }
  42310. this.autofillCalculations.recreateAfterDataPopulation(changes);
  42311. }
  42312. /**
  42313. * `beforeDrawAreaBorders` hook callback.
  42314. *
  42315. * @private
  42316. * @param {Array} corners Coordinates of the area corners.
  42317. * @param {String} className Class name for the area.
  42318. */
  42319. }, {
  42320. key: 'onBeforeDrawAreaBorders',
  42321. value: function onBeforeDrawAreaBorders(corners, className) {
  42322. if (className && className === 'area') {
  42323. var selectedRange = this.hot.getSelectedRangeLast();
  42324. var mergedCellsWithinRange = this.mergedCellsCollection.getWithinRange(selectedRange);
  42325. (0, _array.arrayEach)(mergedCellsWithinRange, function (mergedCell) {
  42326. if (selectedRange.getBottomRightCorner().row === mergedCell.getLastRow() && selectedRange.getBottomRightCorner().col === mergedCell.getLastColumn()) {
  42327. corners[2] = mergedCell.row;
  42328. corners[3] = mergedCell.col;
  42329. }
  42330. });
  42331. }
  42332. }
  42333. /**
  42334. * `afterModifyTransformStart` hook callback. Fixes a problem with navigating through merged cells at the edges of the table
  42335. * with the ENTER/SHIFT+ENTER/TAB/SHIFT+TAB keys.
  42336. *
  42337. * @private
  42338. * @param {CellCoords} coords Coordinates of the to-be-selected cell.
  42339. * @param {Number} rowTransformDir Row transformation direction (negative value = up, 0 = none, positive value = down)
  42340. * @param {Number} colTransformDir Column transformation direction (negative value = up, 0 = none, positive value = down)
  42341. */
  42342. }, {
  42343. key: 'onAfterModifyTransformStart',
  42344. value: function onAfterModifyTransformStart(coords, rowTransformDir, colTransformDir) {
  42345. if (!this.enabled) {
  42346. return;
  42347. }
  42348. var mergedCellAtCoords = this.mergedCellsCollection.get(coords.row, coords.col);
  42349. if (!mergedCellAtCoords) {
  42350. return;
  42351. }
  42352. var goingDown = rowTransformDir > 0;
  42353. var goingUp = rowTransformDir < 0;
  42354. var goingLeft = colTransformDir < 0;
  42355. var goingRight = colTransformDir > 0;
  42356. var mergedCellOnBottomEdge = mergedCellAtCoords.row + mergedCellAtCoords.rowspan - 1 === this.hot.countRows() - 1;
  42357. var mergedCellOnTopEdge = mergedCellAtCoords.row === 0;
  42358. var mergedCellOnRightEdge = mergedCellAtCoords.col + mergedCellAtCoords.colspan - 1 === this.hot.countCols() - 1;
  42359. var mergedCellOnLeftEdge = mergedCellAtCoords.col === 0;
  42360. if (goingDown && mergedCellOnBottomEdge || goingUp && mergedCellOnTopEdge || goingRight && mergedCellOnRightEdge || goingLeft && mergedCellOnLeftEdge) {
  42361. coords.row = mergedCellAtCoords.row;
  42362. coords.col = mergedCellAtCoords.col;
  42363. }
  42364. }
  42365. /**
  42366. * `afterDrawSelection` hook callback. Used to add the additional class name for the entirely-selected merged cells.
  42367. *
  42368. * @private
  42369. * @param {Number} currentRow Row index of the currently processed cell.
  42370. * @param {Number} currentColumn Column index of the currently cell.
  42371. * @param {Array} cornersOfSelection Array of the current selection in a form of `[startRow, startColumn, endRow, endColumn]`.
  42372. * @param {Number|undefined} layerLevel Number indicating which layer of selection is currently processed.
  42373. * @returns {String|undefined} A `String`, which will act as an additional `className` to be added to the currently processed cell.
  42374. */
  42375. }, {
  42376. key: 'onAfterDrawSelection',
  42377. value: function onAfterDrawSelection(currentRow, currentColumn, cornersOfSelection, layerLevel) {
  42378. return this.selectionCalculations.getSelectedMergedCellClassName(currentRow, currentColumn, cornersOfSelection, layerLevel);
  42379. }
  42380. /**
  42381. * `beforeRemoveCellClassNames` hook callback. Used to remove additional class name from all cells in the table.
  42382. *
  42383. * @private
  42384. * @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.
  42385. */
  42386. }, {
  42387. key: 'onBeforeRemoveCellClassNames',
  42388. value: function onBeforeRemoveCellClassNames() {
  42389. return this.selectionCalculations.getSelectedMergedCellClassNameToRemove();
  42390. }
  42391. }]);
  42392. return MergeCells;
  42393. }(_base2.default);
  42394. (0, _plugins.registerPlugin)('mergeCells', MergeCells);
  42395. exports.default = MergeCells;
  42396. /***/ }),
  42397. /* 345 */
  42398. /***/ (function(module, exports, __webpack_require__) {
  42399. "use strict";
  42400. exports.__esModule = true;
  42401. 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; }; }();
  42402. 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.']);
  42403. var _cellCoords = __webpack_require__(95);
  42404. var _cellCoords2 = _interopRequireDefault(_cellCoords);
  42405. var _index = __webpack_require__(4);
  42406. var _number = __webpack_require__(5);
  42407. var _console = __webpack_require__(56);
  42408. var _array = __webpack_require__(1);
  42409. var _utils = __webpack_require__(204);
  42410. var _templateLiteralTag = __webpack_require__(41);
  42411. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  42412. function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
  42413. 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); } }
  42414. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  42415. /**
  42416. * Defines a container object for the merged cells.
  42417. *
  42418. * @class MergedCellsCollection
  42419. * @plugin MergeCells
  42420. */
  42421. var MergedCellsCollection = function () {
  42422. function MergedCellsCollection(plugin) {
  42423. _classCallCheck(this, MergedCellsCollection);
  42424. /**
  42425. * Reference to the Merge Cells plugin.
  42426. *
  42427. * @type {MergeCells}
  42428. */
  42429. this.plugin = plugin;
  42430. /**
  42431. * Array of merged cells.
  42432. *
  42433. * @type {Array}
  42434. */
  42435. this.mergedCells = [];
  42436. /**
  42437. * The Handsontable instance.
  42438. *
  42439. * @type {Handsontable}
  42440. */
  42441. this.hot = plugin.hot;
  42442. }
  42443. /**
  42444. * Get a warning message for when the declared merged cell data overlaps already existing merged cells.
  42445. *
  42446. * @param {Object} newMergedCell Object containg information about the merged cells that was about to be added.
  42447. * @return {String}
  42448. */
  42449. _createClass(MergedCellsCollection, [{
  42450. key: 'get',
  42451. /**
  42452. * Get a merged cell from the container, based on the provided arguments. You can provide either the "starting coordinates"
  42453. * of a merged cell, or any coordinates from the body of the merged cell.
  42454. *
  42455. * @param {Number} row Row index.
  42456. * @param {Number} column Column index.
  42457. * @returns {MergedCellCoords|Boolean} Returns a wanted merged cell on success and `false` on failure.
  42458. */
  42459. value: function get(row, column) {
  42460. var mergedCells = this.mergedCells;
  42461. var result = false;
  42462. (0, _array.arrayEach)(mergedCells, function (mergedCell) {
  42463. if (mergedCell.row <= row && mergedCell.row + mergedCell.rowspan - 1 >= row && mergedCell.col <= column && mergedCell.col + mergedCell.colspan - 1 >= column) {
  42464. result = mergedCell;
  42465. return false;
  42466. }
  42467. return true;
  42468. });
  42469. return result;
  42470. }
  42471. /**
  42472. * Get a merged cell containing the provided range.
  42473. *
  42474. * @param {CellRange|Object} range The range to search merged cells for.
  42475. * @return {MergedCellCoords|Boolean}
  42476. */
  42477. }, {
  42478. key: 'getByRange',
  42479. value: function getByRange(range) {
  42480. var mergedCells = this.mergedCells;
  42481. var result = false;
  42482. (0, _array.arrayEach)(mergedCells, function (mergedCell) {
  42483. 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) {
  42484. result = mergedCell;
  42485. return result;
  42486. }
  42487. return true;
  42488. });
  42489. return result;
  42490. }
  42491. /**
  42492. * Get a merged cell contained in the provided range.
  42493. *
  42494. * @param {CellRange|Object} range The range to search merged cells in.
  42495. * @param [countPartials=false] If set to `true`, all the merged cells overlapping the range will be taken into calculation.
  42496. * @return {Array|Boolean} Array of found merged cells of `false` if none were found.
  42497. */
  42498. }, {
  42499. key: 'getWithinRange',
  42500. value: function getWithinRange(range) {
  42501. var countPartials = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  42502. var mergedCells = this.mergedCells;
  42503. var foundMergedCells = [];
  42504. if (!range.includesRange) {
  42505. var from = new _index.CellCoords(range.from.row, range.from.col);
  42506. var to = new _index.CellCoords(range.to.row, range.to.col);
  42507. range = new _index.CellRange(from, from, to);
  42508. }
  42509. (0, _array.arrayEach)(mergedCells, function (mergedCell) {
  42510. var mergedCellTopLeft = new _index.CellCoords(mergedCell.row, mergedCell.col);
  42511. var mergedCellBottomRight = new _index.CellCoords(mergedCell.row + mergedCell.rowspan - 1, mergedCell.col + mergedCell.colspan - 1);
  42512. var mergedCellRange = new _index.CellRange(mergedCellTopLeft, mergedCellTopLeft, mergedCellBottomRight);
  42513. if (countPartials) {
  42514. if (range.overlaps(mergedCellRange)) {
  42515. foundMergedCells.push(mergedCell);
  42516. }
  42517. } else if (range.includesRange(mergedCellRange)) {
  42518. foundMergedCells.push(mergedCell);
  42519. }
  42520. });
  42521. return foundMergedCells.length ? foundMergedCells : false;
  42522. }
  42523. /**
  42524. * Add a merged cell to the container.
  42525. *
  42526. * @param {Object} mergedCellInfo The merged cell information object. Has to contain `row`, `col`, `colspan` and `rowspan` properties.
  42527. * @return {MergedCellCoords|Boolean} Returns the new merged cell on success and `false` on failure.
  42528. */
  42529. }, {
  42530. key: 'add',
  42531. value: function add(mergedCellInfo) {
  42532. var mergedCells = this.mergedCells;
  42533. var row = mergedCellInfo.row;
  42534. var column = mergedCellInfo.col;
  42535. var rowspan = mergedCellInfo.rowspan;
  42536. var colspan = mergedCellInfo.colspan;
  42537. var newMergedCell = new _cellCoords2.default(row, column, rowspan, colspan);
  42538. var alreadyExists = this.get(row, column);
  42539. var isOverlapping = this.isOverlapping(newMergedCell);
  42540. if (!alreadyExists && !isOverlapping) {
  42541. if (this.hot) {
  42542. newMergedCell.normalize(this.hot);
  42543. }
  42544. mergedCells.push(newMergedCell);
  42545. return newMergedCell;
  42546. }
  42547. (0, _console.warn)(MergedCellsCollection.IS_OVERLAPPING_WARNING(newMergedCell));
  42548. return false;
  42549. }
  42550. /**
  42551. * Remove a merged cell from the container. You can provide either the "starting coordinates"
  42552. * of a merged cell, or any coordinates from the body of the merged cell.
  42553. *
  42554. * @param {Number} row Row index.
  42555. * @param {Number} column Column index.
  42556. * @return {MergedCellCoords|Boolean} Returns the removed merged cell on success and `false` on failure.
  42557. */
  42558. }, {
  42559. key: 'remove',
  42560. value: function remove(row, column) {
  42561. var mergedCells = this.mergedCells;
  42562. var wantedCollection = this.get(row, column);
  42563. var wantedCollectionIndex = wantedCollection ? this.mergedCells.indexOf(wantedCollection) : null;
  42564. if (wantedCollection && wantedCollectionIndex !== false) {
  42565. mergedCells.splice(wantedCollectionIndex, 1);
  42566. return wantedCollection;
  42567. }
  42568. return false;
  42569. }
  42570. /**
  42571. * Clear all the merged cells.
  42572. */
  42573. }, {
  42574. key: 'clear',
  42575. value: function clear() {
  42576. var _this = this;
  42577. var mergedCells = this.mergedCells;
  42578. var mergedCellParentsToClear = [];
  42579. var hiddenCollectionElements = [];
  42580. (0, _array.arrayEach)(mergedCells, function (mergedCell) {
  42581. mergedCellParentsToClear.push([_this.hot.getCell(mergedCell.row, mergedCell.col), _this.get(mergedCell.row, mergedCell.col), mergedCell.row, mergedCell.col]);
  42582. });
  42583. this.mergedCells.length = 0;
  42584. (0, _array.arrayEach)(mergedCellParentsToClear, function (mergedCell, i) {
  42585. (0, _number.rangeEach)(0, mergedCell.rowspan - 1, function (j) {
  42586. (0, _number.rangeEach)(0, mergedCell.colspan - 1, function (k) {
  42587. if (k !== 0 || j !== 0) {
  42588. hiddenCollectionElements.push([_this.hot.getCell(mergedCell.row + j, mergedCell.col + k), null, null, null]);
  42589. }
  42590. });
  42591. });
  42592. mergedCellParentsToClear[i][1] = null;
  42593. });
  42594. (0, _array.arrayEach)(mergedCellParentsToClear, function (mergedCellParents) {
  42595. _utils.applySpanProperties.apply(undefined, _toConsumableArray(mergedCellParents));
  42596. });
  42597. (0, _array.arrayEach)(hiddenCollectionElements, function (hiddenCollectionElement) {
  42598. _utils.applySpanProperties.apply(undefined, _toConsumableArray(hiddenCollectionElement));
  42599. });
  42600. }
  42601. /**
  42602. * Check if the provided merged cell overlaps with the others in the container.
  42603. *
  42604. * @param {MergedCellCoords} mergedCell The merged cell to check against all others in the container.
  42605. * @return {Boolean} `true` if the provided merged cell overlaps with the others, `false` otherwise.
  42606. */
  42607. }, {
  42608. key: 'isOverlapping',
  42609. value: function isOverlapping(mergedCell) {
  42610. 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));
  42611. var result = false;
  42612. (0, _array.arrayEach)(this.mergedCells, function (col) {
  42613. 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));
  42614. if (currentRange.overlaps(mergedCellRange)) {
  42615. result = true;
  42616. return false;
  42617. }
  42618. return true;
  42619. });
  42620. return result;
  42621. }
  42622. /**
  42623. * Check whether the provided row/col coordinates direct to a merged parent.
  42624. *
  42625. * @param {Number} row Row index.
  42626. * @param {Number} column Column index.
  42627. * @return {Boolean}
  42628. */
  42629. }, {
  42630. key: 'isMergedParent',
  42631. value: function isMergedParent(row, column) {
  42632. var mergedCells = this.mergedCells;
  42633. var result = false;
  42634. (0, _array.arrayEach)(mergedCells, function (mergedCell) {
  42635. if (mergedCell.row === row && mergedCell.col === column) {
  42636. result = true;
  42637. return false;
  42638. }
  42639. return true;
  42640. });
  42641. return result;
  42642. }
  42643. /**
  42644. * Shift the merged cell in the direction and by an offset defined in the arguments.
  42645. *
  42646. * @param {String} direction `right`, `left`, `up` or `down`.
  42647. * @param {Number} index Index where the change, which caused the shifting took place.
  42648. * @param {Number} count Number of rows/columns added/removed in the preceding action.
  42649. */
  42650. }, {
  42651. key: 'shiftCollections',
  42652. value: function shiftCollections(direction, index, count) {
  42653. var _this2 = this;
  42654. var shiftVector = [0, 0];
  42655. switch (direction) {
  42656. case 'right':
  42657. shiftVector[0] += count;
  42658. break;
  42659. case 'left':
  42660. shiftVector[0] -= count;
  42661. break;
  42662. case 'down':
  42663. shiftVector[1] += count;
  42664. break;
  42665. case 'up':
  42666. shiftVector[1] -= count;
  42667. break;
  42668. default:
  42669. }
  42670. (0, _array.arrayEach)(this.mergedCells, function (currentMerge) {
  42671. currentMerge.shift(shiftVector, index);
  42672. });
  42673. (0, _number.rangeEachReverse)(this.mergedCells.length - 1, 0, function (i) {
  42674. var currentMerge = _this2.mergedCells[i];
  42675. if (currentMerge && currentMerge.removed) {
  42676. _this2.mergedCells.splice(_this2.mergedCells.indexOf(currentMerge), 1);
  42677. }
  42678. });
  42679. }
  42680. }], [{
  42681. key: 'IS_OVERLAPPING_WARNING',
  42682. value: function IS_OVERLAPPING_WARNING(newMergedCell) {
  42683. return (0, _templateLiteralTag.toSingleLine)(_templateObject, newMergedCell.row, newMergedCell.col);
  42684. }
  42685. }]);
  42686. return MergedCellsCollection;
  42687. }();
  42688. exports.default = MergedCellsCollection;
  42689. /***/ }),
  42690. /* 346 */
  42691. /***/ (function(module, exports, __webpack_require__) {
  42692. "use strict";
  42693. exports.__esModule = true;
  42694. 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"); } }; }();
  42695. 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; }; }();
  42696. var _object = __webpack_require__(2);
  42697. var _src = __webpack_require__(4);
  42698. var _array = __webpack_require__(1);
  42699. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  42700. /**
  42701. * Class responsible for all of the Autofill-related operations on merged cells.
  42702. *
  42703. * @class AutofillCalculations
  42704. * @plugin MergeCells
  42705. * @util
  42706. */
  42707. var AutofillCalculations = function () {
  42708. function AutofillCalculations(plugin) {
  42709. _classCallCheck(this, AutofillCalculations);
  42710. /**
  42711. * Reference to the Merge Cells plugin.
  42712. *
  42713. * @type {MergeCells}
  42714. */
  42715. this.plugin = plugin;
  42716. /**
  42717. * Reference to the MergedCellsCollection class instance.
  42718. *
  42719. * @type {MergedCellsCollection}
  42720. */
  42721. this.mergedCellsCollection = this.plugin.mergedCellsCollection;
  42722. /**
  42723. * Cache of the currently processed autofill data.
  42724. *
  42725. * @private
  42726. * @type {Object}
  42727. */
  42728. this.currentFillData = null;
  42729. }
  42730. /**
  42731. * Correct the provided selection area, so it's not selecting only a part of a merged cell.
  42732. *
  42733. * @param {Array} selectionArea
  42734. */
  42735. _createClass(AutofillCalculations, [{
  42736. key: 'correctSelectionAreaSize',
  42737. value: function correctSelectionAreaSize(selectionArea) {
  42738. if (selectionArea[0] === selectionArea[2] && selectionArea[1] === selectionArea[3]) {
  42739. var mergedCell = this.mergedCellsCollection.get(selectionArea[0], selectionArea[1]);
  42740. if (mergedCell) {
  42741. selectionArea[2] = selectionArea[0] + mergedCell.rowspan - 1;
  42742. selectionArea[3] = selectionArea[1] + mergedCell.colspan - 1;
  42743. }
  42744. }
  42745. }
  42746. /**
  42747. * Get the direction of the autofill process.
  42748. *
  42749. * @param {Array} selectionArea The selection area.
  42750. * @param {Array} finalArea The final area (base + drag).
  42751. * @return {String} `up`, `down`, `left` or `right`.
  42752. */
  42753. }, {
  42754. key: 'getDirection',
  42755. value: function getDirection(selectionArea, finalArea) {
  42756. var direction = null;
  42757. if (finalArea[0] === selectionArea[0] && finalArea[1] === selectionArea[1] && finalArea[3] === selectionArea[3]) {
  42758. direction = 'down';
  42759. } else if (finalArea[2] === selectionArea[2] && finalArea[1] === selectionArea[1] && finalArea[3] === selectionArea[3]) {
  42760. direction = 'up';
  42761. } else if (finalArea[1] === selectionArea[1] && finalArea[2] === selectionArea[2]) {
  42762. direction = 'right';
  42763. } else {
  42764. direction = 'left';
  42765. }
  42766. return direction;
  42767. }
  42768. /**
  42769. * Snap the drag area to the farthest merged cell, so it won't clip any of the merged cells.
  42770. *
  42771. * @param {Array} baseArea The base selected area.
  42772. * @param {Array} dragArea The drag area.
  42773. * @param {String} dragDirection The autofill drag direction.
  42774. * @param {Array} foundMergedCells MergeCellCoords found in the base selection area.
  42775. * @return {Array} The new drag area
  42776. */
  42777. }, {
  42778. key: 'snapDragArea',
  42779. value: function snapDragArea(baseArea, dragArea, dragDirection, foundMergedCells) {
  42780. var newDragArea = dragArea.slice(0);
  42781. var fillSize = this.getAutofillSize(baseArea, dragArea, dragDirection);
  42782. var _baseArea = _slicedToArray(baseArea, 4),
  42783. baseAreaStartRow = _baseArea[0],
  42784. baseAreaStartColumn = _baseArea[1],
  42785. baseAreaEndRow = _baseArea[2],
  42786. baseAreaEndColumn = _baseArea[3];
  42787. var verticalDirection = ['up', 'down'].indexOf(dragDirection) > -1;
  42788. var fullCycle = verticalDirection ? baseAreaEndRow - baseAreaStartRow + 1 : baseAreaEndColumn - baseAreaStartColumn + 1;
  42789. var fulls = Math.floor(fillSize / fullCycle) * fullCycle;
  42790. var partials = fillSize - fulls;
  42791. var farthestCollection = this.getFarthestCollection(baseArea, dragArea, dragDirection, foundMergedCells);
  42792. if (farthestCollection) {
  42793. if (dragDirection === 'down') {
  42794. var fill = farthestCollection.row + farthestCollection.rowspan - baseAreaStartRow - partials;
  42795. var newLimit = newDragArea[2] + fill;
  42796. if (newLimit >= this.plugin.hot.countRows()) {
  42797. newDragArea[2] -= partials;
  42798. } else {
  42799. newDragArea[2] += partials ? fill : 0;
  42800. }
  42801. } else if (dragDirection === 'right') {
  42802. var _fill = farthestCollection.col + farthestCollection.colspan - baseAreaStartColumn - partials;
  42803. var _newLimit = newDragArea[3] + _fill;
  42804. if (_newLimit >= this.plugin.hot.countCols()) {
  42805. newDragArea[3] -= partials;
  42806. } else {
  42807. newDragArea[3] += partials ? _fill : 0;
  42808. }
  42809. } else if (dragDirection === 'up') {
  42810. var _fill2 = baseAreaEndRow - partials - farthestCollection.row + 1;
  42811. var _newLimit2 = newDragArea[0] + _fill2;
  42812. if (_newLimit2 < 0) {
  42813. newDragArea[0] += partials;
  42814. } else {
  42815. newDragArea[0] -= partials ? _fill2 : 0;
  42816. }
  42817. } else if (dragDirection === 'left') {
  42818. var _fill3 = baseAreaEndColumn - partials - farthestCollection.col + 1;
  42819. var _newLimit3 = newDragArea[1] + _fill3;
  42820. if (_newLimit3 < 0) {
  42821. newDragArea[1] += partials;
  42822. } else {
  42823. newDragArea[1] -= partials ? _fill3 : 0;
  42824. }
  42825. }
  42826. }
  42827. this.updateCurrentFillCache({
  42828. baseArea: baseArea,
  42829. dragDirection: dragDirection,
  42830. foundMergedCells: foundMergedCells,
  42831. fillSize: fillSize,
  42832. dragArea: newDragArea,
  42833. cycleLength: fullCycle
  42834. });
  42835. return newDragArea;
  42836. }
  42837. /**
  42838. * Update the current fill cache with the provided object.
  42839. *
  42840. * @private
  42841. * @param {Object} updateObject
  42842. */
  42843. }, {
  42844. key: 'updateCurrentFillCache',
  42845. value: function updateCurrentFillCache(updateObject) {
  42846. if (!this.currentFillData) {
  42847. this.currentFillData = {};
  42848. }
  42849. (0, _object.extend)(this.currentFillData, updateObject);
  42850. }
  42851. /**
  42852. * Get the "length" of the drag area.
  42853. *
  42854. * @private
  42855. * @param {Array} baseArea The base selection area.
  42856. * @param {Array} dragArea The drag area (containing the base area).
  42857. * @param {String} direction The drag direction.
  42858. * @return {Number|null} The "length" (height or width, depending on the direction) of the drag.
  42859. */
  42860. }, {
  42861. key: 'getAutofillSize',
  42862. value: function getAutofillSize(baseArea, dragArea, direction) {
  42863. var _baseArea2 = _slicedToArray(baseArea, 4),
  42864. baseAreaStartRow = _baseArea2[0],
  42865. baseAreaStartColumn = _baseArea2[1],
  42866. baseAreaEndRow = _baseArea2[2],
  42867. baseAreaEndColumn = _baseArea2[3];
  42868. var _dragArea = _slicedToArray(dragArea, 4),
  42869. dragAreaStartRow = _dragArea[0],
  42870. dragAreaStartColumn = _dragArea[1],
  42871. dragAreaEndRow = _dragArea[2],
  42872. dragAreaEndColumn = _dragArea[3];
  42873. switch (direction) {
  42874. case 'up':
  42875. return baseAreaStartRow - dragAreaStartRow;
  42876. case 'down':
  42877. return dragAreaEndRow - baseAreaEndRow;
  42878. case 'left':
  42879. return baseAreaStartColumn - dragAreaStartColumn;
  42880. case 'right':
  42881. return dragAreaEndColumn - baseAreaEndColumn;
  42882. default:
  42883. return null;
  42884. }
  42885. }
  42886. /**
  42887. * Trim the default drag area (containing the selection area) to the drag-only area.
  42888. *
  42889. * @private
  42890. * @param {Array} baseArea The base selection area.
  42891. * @param {Array} dragArea The base selection area extended by the drag area.
  42892. * @param {String} direction Drag direction.
  42893. * @return {Array|null} Array representing the drag area coordinates.
  42894. */
  42895. }, {
  42896. key: 'getDragArea',
  42897. value: function getDragArea(baseArea, dragArea, direction) {
  42898. var _baseArea3 = _slicedToArray(baseArea, 4),
  42899. baseAreaStartRow = _baseArea3[0],
  42900. baseAreaStartColumn = _baseArea3[1],
  42901. baseAreaEndRow = _baseArea3[2],
  42902. baseAreaEndColumn = _baseArea3[3];
  42903. var _dragArea2 = _slicedToArray(dragArea, 4),
  42904. dragAreaStartRow = _dragArea2[0],
  42905. dragAreaStartColumn = _dragArea2[1],
  42906. dragAreaEndRow = _dragArea2[2],
  42907. dragAreaEndColumn = _dragArea2[3];
  42908. switch (direction) {
  42909. case 'up':
  42910. return [dragAreaStartRow, dragAreaStartColumn, baseAreaStartRow - 1, baseAreaEndColumn];
  42911. case 'down':
  42912. return [baseAreaEndRow + 1, baseAreaStartColumn, dragAreaEndRow, baseAreaEndColumn];
  42913. case 'left':
  42914. return [dragAreaStartRow, dragAreaStartColumn, baseAreaEndRow, baseAreaStartColumn - 1];
  42915. case 'right':
  42916. return [baseAreaStartRow, baseAreaEndColumn + 1, dragAreaEndRow, dragAreaEndColumn];
  42917. default:
  42918. return null;
  42919. }
  42920. }
  42921. /**
  42922. * Get the to-be-farthest merged cell in the newly filled area.
  42923. *
  42924. * @private
  42925. * @param {Array} baseArea The base selection area.
  42926. * @param {Array} dragArea The drag area (containing the base area).
  42927. * @param {String} direction The drag direction.
  42928. * @param {Array} mergedCellArray Array of the merged cells found in the base area.
  42929. * @return {MergedCellCoords|null}
  42930. */
  42931. }, {
  42932. key: 'getFarthestCollection',
  42933. value: function getFarthestCollection(baseArea, dragArea, direction, mergedCellArray) {
  42934. var _baseArea4 = _slicedToArray(baseArea, 4),
  42935. baseAreaStartRow = _baseArea4[0],
  42936. baseAreaStartColumn = _baseArea4[1],
  42937. baseAreaEndRow = _baseArea4[2],
  42938. baseAreaEndColumn = _baseArea4[3];
  42939. var verticalDirection = ['up', 'down'].indexOf(direction) > -1;
  42940. var baseEnd = verticalDirection ? baseAreaEndRow : baseAreaEndColumn;
  42941. var baseStart = verticalDirection ? baseAreaStartRow : baseAreaStartColumn;
  42942. var fillSize = this.getAutofillSize(baseArea, dragArea, direction);
  42943. var fullCycle = verticalDirection ? baseAreaEndRow - baseAreaStartRow + 1 : baseAreaEndColumn - baseAreaStartColumn + 1;
  42944. var fulls = Math.floor(fillSize / fullCycle) * fullCycle;
  42945. var partials = fillSize - fulls;
  42946. var inclusionFunctionName = null;
  42947. var farthestCollection = null;
  42948. var endOfDragRecreationIndex = null;
  42949. switch (direction) {
  42950. case 'up':
  42951. inclusionFunctionName = 'includesVertically';
  42952. endOfDragRecreationIndex = baseEnd - partials + 1;
  42953. break;
  42954. case 'left':
  42955. inclusionFunctionName = 'includesHorizontally';
  42956. endOfDragRecreationIndex = baseEnd - partials + 1;
  42957. break;
  42958. case 'down':
  42959. inclusionFunctionName = 'includesVertically';
  42960. endOfDragRecreationIndex = baseStart + partials - 1;
  42961. break;
  42962. case 'right':
  42963. inclusionFunctionName = 'includesHorizontally';
  42964. endOfDragRecreationIndex = baseStart + partials - 1;
  42965. break;
  42966. default:
  42967. }
  42968. (0, _array.arrayEach)(mergedCellArray, function (currentCollection) {
  42969. if (currentCollection[inclusionFunctionName](endOfDragRecreationIndex) && currentCollection.isFarther(farthestCollection, direction)) {
  42970. farthestCollection = currentCollection;
  42971. }
  42972. });
  42973. return farthestCollection;
  42974. }
  42975. /**
  42976. * Recreate the merged cells after the autofill process.
  42977. *
  42978. * @param {Array} changes Changes made.
  42979. */
  42980. }, {
  42981. key: 'recreateAfterDataPopulation',
  42982. value: function recreateAfterDataPopulation(changes) {
  42983. if (!this.currentFillData) {
  42984. return;
  42985. }
  42986. var fillRange = this.getRangeFromChanges(changes);
  42987. var foundMergedCells = this.currentFillData.foundMergedCells;
  42988. var dragDirection = this.currentFillData.dragDirection;
  42989. var inBounds = function inBounds(current, offset) {
  42990. switch (dragDirection) {
  42991. case 'up':
  42992. return current.row - offset >= fillRange.from.row;
  42993. case 'down':
  42994. return current.row + current.rowspan - 1 + offset <= fillRange.to.row;
  42995. case 'left':
  42996. return current.col - offset >= fillRange.from.column;
  42997. case 'right':
  42998. return current.col + current.colspan - 1 + offset <= fillRange.to.column;
  42999. default:
  43000. return null;
  43001. }
  43002. };
  43003. var fillOffset = 0;
  43004. var current = null;
  43005. var multiplier = 1;
  43006. do {
  43007. for (var j = 0; j < foundMergedCells.length; j += 1) {
  43008. current = foundMergedCells[j];
  43009. fillOffset = multiplier * this.currentFillData.cycleLength;
  43010. if (inBounds(current, fillOffset)) {
  43011. switch (dragDirection) {
  43012. case 'up':
  43013. this.plugin.mergedCellsCollection.add({
  43014. row: current.row - fillOffset,
  43015. rowspan: current.rowspan,
  43016. col: current.col,
  43017. colspan: current.colspan
  43018. });
  43019. break;
  43020. case 'down':
  43021. this.plugin.mergedCellsCollection.add({
  43022. row: current.row + fillOffset,
  43023. rowspan: current.rowspan,
  43024. col: current.col,
  43025. colspan: current.colspan
  43026. });
  43027. break;
  43028. case 'left':
  43029. this.plugin.mergedCellsCollection.add({
  43030. row: current.row,
  43031. rowspan: current.rowspan,
  43032. col: current.col - fillOffset,
  43033. colspan: current.colspan
  43034. });
  43035. break;
  43036. case 'right':
  43037. this.plugin.mergedCellsCollection.add({
  43038. row: current.row,
  43039. rowspan: current.rowspan,
  43040. col: current.col + fillOffset,
  43041. colspan: current.colspan
  43042. });
  43043. break;
  43044. default:
  43045. }
  43046. }
  43047. if (j === foundMergedCells.length - 1) {
  43048. multiplier += 1;
  43049. }
  43050. }
  43051. } while (inBounds(current, fillOffset));
  43052. this.currentFillData = null;
  43053. this.plugin.hot.render();
  43054. }
  43055. /**
  43056. * Get the drag range from the changes made.
  43057. *
  43058. * @private
  43059. * @param {Array} changes The changes made.
  43060. * @returns {Object} Object with `from` and `to` properties, both containing `row` and `column` keys.
  43061. */
  43062. }, {
  43063. key: 'getRangeFromChanges',
  43064. value: function getRangeFromChanges(changes) {
  43065. var rows = { min: null, max: null };
  43066. var columns = { min: null, max: null };
  43067. (0, _array.arrayEach)(changes, function (change) {
  43068. if (rows.min === null || change[0] < rows.min) {
  43069. rows.min = change[0];
  43070. }
  43071. if (rows.max === null || change[0] > rows.max) {
  43072. rows.max = change[0];
  43073. }
  43074. if (columns.min === null || change[1] < columns.min) {
  43075. columns.min = change[1];
  43076. }
  43077. if (columns.max === null || change[1] > columns.max) {
  43078. columns.max = change[1];
  43079. }
  43080. });
  43081. return {
  43082. from: {
  43083. row: rows.min,
  43084. column: columns.min
  43085. },
  43086. to: {
  43087. row: rows.max,
  43088. column: columns.max
  43089. }
  43090. };
  43091. }
  43092. /**
  43093. * Check if the drag area contains any merged cells.
  43094. *
  43095. * @param {Array} baseArea The base selection area.
  43096. * @param {Array} fullArea The base area extended by the drag area.
  43097. * @param {String} direction Drag direction.
  43098. * @returns {Boolean}
  43099. */
  43100. }, {
  43101. key: 'dragAreaOverlapsCollections',
  43102. value: function dragAreaOverlapsCollections(baseArea, fullArea, direction) {
  43103. var dragArea = this.getDragArea(baseArea, fullArea, direction);
  43104. var _dragArea3 = _slicedToArray(dragArea, 4),
  43105. dragAreaStartRow = _dragArea3[0],
  43106. dragAreaStartColumn = _dragArea3[1],
  43107. dragAreaEndRow = _dragArea3[2],
  43108. dragAreaEndColumn = _dragArea3[3];
  43109. var topLeft = new _src.CellCoords(dragAreaStartRow, dragAreaStartColumn);
  43110. var bottomRight = new _src.CellCoords(dragAreaEndRow, dragAreaEndColumn);
  43111. var dragRange = new _src.CellRange(topLeft, topLeft, bottomRight);
  43112. return !!this.mergedCellsCollection.getWithinRange(dragRange, true);
  43113. }
  43114. }]);
  43115. return AutofillCalculations;
  43116. }();
  43117. exports.default = AutofillCalculations;
  43118. /***/ }),
  43119. /* 347 */
  43120. /***/ (function(module, exports, __webpack_require__) {
  43121. "use strict";
  43122. exports.__esModule = true;
  43123. 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"); } }; }();
  43124. 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; }; }();
  43125. var _src = __webpack_require__(4);
  43126. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  43127. /**
  43128. * Class responsible for all of the Selection-related operations on merged cells.
  43129. *
  43130. * @class SelectionCalculations
  43131. * @plugin MergeCells
  43132. * @util
  43133. */
  43134. var SelectionCalculations = function () {
  43135. function SelectionCalculations(plugin) {
  43136. _classCallCheck(this, SelectionCalculations);
  43137. /**
  43138. * Reference to the Merge Cells plugin.
  43139. *
  43140. * @type {MergeCells}
  43141. */
  43142. this.plugin = plugin;
  43143. /**
  43144. * Class name used for fully selected merged cells.
  43145. *
  43146. * @type {String}
  43147. */
  43148. this.fullySelectedMergedCellClassName = 'fullySelectedMergedCell';
  43149. }
  43150. /**
  43151. * "Snap" the delta value according to defined merged cells. (In other words, compensate the rowspan -
  43152. * e.g. going up with `delta.row = -1` over a merged cell with `rowspan = 3`, `delta.row` should change to `-3`.)
  43153. *
  43154. * @param {Object} delta The delta object containing `row` and `col` properties.
  43155. * @param {CellRange} selectionRange The selection range.
  43156. * @param {Object} mergedCell A merged cell object.
  43157. */
  43158. _createClass(SelectionCalculations, [{
  43159. key: 'snapDelta',
  43160. value: function snapDelta(delta, selectionRange, mergedCell) {
  43161. var cellCoords = selectionRange.to;
  43162. var newRow = cellCoords.row + delta.row;
  43163. var newColumn = cellCoords.col + delta.col;
  43164. if (delta.row) {
  43165. this.jumpOverMergedCell(delta, mergedCell, newRow);
  43166. } else if (delta.col) {
  43167. this.jumpOverMergedCell(delta, mergedCell, newColumn);
  43168. }
  43169. }
  43170. /**
  43171. * "Jump" over the merged cell (compensate for the indexes within the merged cell to get past it)
  43172. *
  43173. * @private
  43174. * @param {Object} delta The delta object.
  43175. * @param {MergedCellCoords} mergedCell The merge cell object.
  43176. * @param {Number} newIndex New row/column index, created with the delta.
  43177. */
  43178. }, {
  43179. key: 'jumpOverMergedCell',
  43180. value: function jumpOverMergedCell(delta, mergedCell, newIndex) {
  43181. var flatDelta = delta.row || delta.col;
  43182. var includesIndex = null;
  43183. var firstIndex = null;
  43184. var lastIndex = null;
  43185. if (delta.row) {
  43186. includesIndex = mergedCell.includesVertically(newIndex);
  43187. firstIndex = mergedCell.row;
  43188. lastIndex = mergedCell.getLastRow();
  43189. } else if (delta.col) {
  43190. includesIndex = mergedCell.includesHorizontally(newIndex);
  43191. firstIndex = mergedCell.col;
  43192. lastIndex = mergedCell.getLastColumn();
  43193. }
  43194. if (flatDelta === 0) {
  43195. return;
  43196. } else if (flatDelta > 0) {
  43197. if (includesIndex && newIndex !== firstIndex) {
  43198. flatDelta += lastIndex - newIndex + 1;
  43199. }
  43200. } else if (includesIndex && newIndex !== lastIndex) {
  43201. flatDelta -= newIndex - firstIndex + 1;
  43202. }
  43203. if (delta.row) {
  43204. delta.row = flatDelta;
  43205. } else if (delta.col) {
  43206. delta.col = flatDelta;
  43207. }
  43208. }
  43209. /**
  43210. * Get a selection range with `to` property incremented by the provided delta.
  43211. *
  43212. * @param {CellRange} oldSelectionRange The base selection range.
  43213. * @param {Object} delta The delta object with `row` and `col` properties.
  43214. * @returns {CellRange} A new `CellRange` object.
  43215. */
  43216. }, {
  43217. key: 'getUpdatedSelectionRange',
  43218. value: function getUpdatedSelectionRange(oldSelectionRange, delta) {
  43219. return new _src.CellRange(oldSelectionRange.highlight, oldSelectionRange.from, new _src.CellCoords(oldSelectionRange.to.row + delta.row, oldSelectionRange.to.col + delta.col));
  43220. }
  43221. /**
  43222. * Generate an additional class name for the entirely-selected merged cells.
  43223. *
  43224. * @param {Number} currentRow Row index of the currently processed cell.
  43225. * @param {Number} currentColumn Column index of the currently cell.
  43226. * @param {Array} cornersOfSelection Array of the current selection in a form of `[startRow, startColumn, endRow, endColumn]`.
  43227. * @param {Number|undefined} layerLevel Number indicating which layer of selection is currently processed.
  43228. * @returns {String|undefined} A `String`, which will act as an additional `className` to be added to the currently processed cell.
  43229. */
  43230. }, {
  43231. key: 'getSelectedMergedCellClassName',
  43232. value: function getSelectedMergedCellClassName(currentRow, currentColumn, cornersOfSelection, layerLevel) {
  43233. var _cornersOfSelection = _slicedToArray(cornersOfSelection, 4),
  43234. startRow = _cornersOfSelection[0],
  43235. startColumn = _cornersOfSelection[1],
  43236. endRow = _cornersOfSelection[2],
  43237. endColumn = _cornersOfSelection[3];
  43238. if (layerLevel === void 0) {
  43239. return;
  43240. }
  43241. if (currentRow >= startRow && currentRow <= endRow && currentColumn >= startColumn && currentColumn <= endColumn) {
  43242. var isMergedCellParent = this.plugin.mergedCellsCollection.isMergedParent(currentRow, currentColumn);
  43243. if (!isMergedCellParent) {
  43244. return;
  43245. }
  43246. var mergedCell = this.plugin.mergedCellsCollection.get(currentRow, currentColumn);
  43247. if (!mergedCell) {
  43248. return;
  43249. }
  43250. if (mergedCell.row + mergedCell.rowspan - 1 <= endRow && mergedCell.col + mergedCell.colspan - 1 <= endColumn) {
  43251. return this.fullySelectedMergedCellClassName + '-' + layerLevel;
  43252. } else if (this.plugin.selectionCalculations.isMergeCellFullySelected(mergedCell, this.plugin.hot.getSelectedRange())) {
  43253. return this.fullySelectedMergedCellClassName + '-multiple';
  43254. }
  43255. }
  43256. }
  43257. /**
  43258. * Check if the provided merged cell is fully selected (by one or many layers of selection)
  43259. *
  43260. * @param {MergedCellCoords} mergedCell The merged cell to be processed.
  43261. * @param {CellRange[]} selectionRangesArray Array of selection ranges.
  43262. * @returns {Boolean}
  43263. */
  43264. }, {
  43265. key: 'isMergeCellFullySelected',
  43266. value: function isMergeCellFullySelected(mergedCell, selectionRangesArray) {
  43267. var mergedCellIndividualCoords = [];
  43268. if (!selectionRangesArray || !mergedCell) {
  43269. return false;
  43270. }
  43271. for (var r = 0; r < mergedCell.rowspan; r += 1) {
  43272. for (var c = 0; c < mergedCell.colspan; c += 1) {
  43273. mergedCellIndividualCoords.push(new _src.CellCoords(mergedCell.row + r, mergedCell.col + c));
  43274. }
  43275. }
  43276. for (var i = 0; i < mergedCellIndividualCoords.length; i += 1) {
  43277. var insideSelections = [];
  43278. for (var s = 0; s < selectionRangesArray.length; s += 1) {
  43279. insideSelections[s] = selectionRangesArray[s].includes(mergedCellIndividualCoords[i]);
  43280. }
  43281. if (!insideSelections.includes(true)) {
  43282. return false;
  43283. }
  43284. }
  43285. return true;
  43286. }
  43287. /**
  43288. * Generate an array of the entirely-selected merged cells' class names.
  43289. *
  43290. * @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.
  43291. */
  43292. }, {
  43293. key: 'getSelectedMergedCellClassNameToRemove',
  43294. value: function getSelectedMergedCellClassNameToRemove() {
  43295. var classNames = [];
  43296. for (var i = 0; i <= 7; i += 1) {
  43297. classNames.push(this.fullySelectedMergedCellClassName + '-' + i);
  43298. }
  43299. classNames.push(this.fullySelectedMergedCellClassName + '-multiple');
  43300. return classNames;
  43301. }
  43302. }]);
  43303. return SelectionCalculations;
  43304. }();
  43305. exports.default = SelectionCalculations;
  43306. /***/ }),
  43307. /* 348 */
  43308. /***/ (function(module, exports, __webpack_require__) {
  43309. "use strict";
  43310. exports.__esModule = true;
  43311. exports.default = toggleMergeItem;
  43312. var _constants = __webpack_require__(7);
  43313. var C = _interopRequireWildcard(_constants);
  43314. var _cellCoords = __webpack_require__(95);
  43315. var _cellCoords2 = _interopRequireDefault(_cellCoords);
  43316. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  43317. 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; } }
  43318. function toggleMergeItem(plugin) {
  43319. return {
  43320. key: 'mergeCells',
  43321. name: function name() {
  43322. var sel = this.getSelectedLast();
  43323. if (sel) {
  43324. var info = plugin.mergedCellsCollection.get(sel[0], sel[1]);
  43325. if (info.row === sel[0] && info.col === sel[1] && info.row + info.rowspan - 1 === sel[2] && info.col + info.colspan - 1 === sel[3]) {
  43326. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_UNMERGE_CELLS);
  43327. }
  43328. }
  43329. return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_MERGE_CELLS);
  43330. },
  43331. callback: function callback() {
  43332. plugin.toggleMergeOnSelection();
  43333. },
  43334. disabled: function disabled() {
  43335. var sel = this.getSelectedLast();
  43336. if (!sel) {
  43337. return true;
  43338. }
  43339. var isSingleCell = _cellCoords2.default.isSingleCell({
  43340. row: sel[0],
  43341. col: sel[1],
  43342. rowspan: sel[2] - sel[0] + 1,
  43343. colspan: sel[3] - sel[1] + 1
  43344. });
  43345. return isSingleCell || this.selection.isSelectedByCorner();
  43346. },
  43347. hidden: false
  43348. };
  43349. }
  43350. /***/ }),
  43351. /* 349 */
  43352. /***/ (function(module, exports) {
  43353. // removed by extract-text-webpack-plugin
  43354. /***/ }),
  43355. /* 350 */
  43356. /***/ (function(module, exports, __webpack_require__) {
  43357. "use strict";
  43358. exports.__esModule = true;
  43359. 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; }; }();
  43360. 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); } };
  43361. var _pluginHooks = __webpack_require__(15);
  43362. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  43363. var _element = __webpack_require__(0);
  43364. var _browser = __webpack_require__(27);
  43365. var _base = __webpack_require__(10);
  43366. var _base2 = _interopRequireDefault(_base);
  43367. var _eventManager = __webpack_require__(6);
  43368. var _eventManager2 = _interopRequireDefault(_eventManager);
  43369. var _plugins = __webpack_require__(8);
  43370. var _src = __webpack_require__(4);
  43371. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  43372. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  43373. 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; }
  43374. 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; }
  43375. /**
  43376. * @private
  43377. * @plugin MultipleSelectionHandles
  43378. */
  43379. var MultipleSelectionHandles = function (_BasePlugin) {
  43380. _inherits(MultipleSelectionHandles, _BasePlugin);
  43381. /**
  43382. * @param {Object} hotInstance
  43383. */
  43384. function MultipleSelectionHandles(hotInstance) {
  43385. _classCallCheck(this, MultipleSelectionHandles);
  43386. /**
  43387. * @type {Array}
  43388. */
  43389. var _this2 = _possibleConstructorReturn(this, (MultipleSelectionHandles.__proto__ || Object.getPrototypeOf(MultipleSelectionHandles)).call(this, hotInstance));
  43390. _this2.dragged = [];
  43391. /**
  43392. * Instance of EventManager.
  43393. *
  43394. * @type {EventManager}
  43395. */
  43396. _this2.eventManager = null;
  43397. /**
  43398. * @type {null}
  43399. */
  43400. _this2.lastSetCell = null;
  43401. return _this2;
  43402. }
  43403. /**
  43404. * Check if the plugin is enabled in the handsontable settings.
  43405. *
  43406. * @returns {Boolean}
  43407. */
  43408. _createClass(MultipleSelectionHandles, [{
  43409. key: 'isEnabled',
  43410. value: function isEnabled() {
  43411. return (0, _browser.isMobileBrowser)();
  43412. }
  43413. /**
  43414. * Enable plugin for this Handsontable instance.
  43415. */
  43416. }, {
  43417. key: 'enablePlugin',
  43418. value: function enablePlugin() {
  43419. if (this.enabled) {
  43420. return;
  43421. }
  43422. if (!this.eventManager) {
  43423. this.eventManager = new _eventManager2.default(this);
  43424. }
  43425. this.registerListeners();
  43426. _get(MultipleSelectionHandles.prototype.__proto__ || Object.getPrototypeOf(MultipleSelectionHandles.prototype), 'enablePlugin', this).call(this);
  43427. }
  43428. /**
  43429. * Bind the touch events
  43430. * @private
  43431. */
  43432. }, {
  43433. key: 'registerListeners',
  43434. value: function registerListeners() {
  43435. var _this = this;
  43436. function removeFromDragged(query) {
  43437. if (_this.dragged.length === 1) {
  43438. // clear array
  43439. _this.dragged.splice(0, _this.dragged.length);
  43440. return true;
  43441. }
  43442. var entryPosition = _this.dragged.indexOf(query);
  43443. if (entryPosition == -1) {
  43444. return false;
  43445. } else if (entryPosition === 0) {
  43446. _this.dragged = _this.dragged.slice(0, 1);
  43447. } else if (entryPosition == 1) {
  43448. _this.dragged = _this.dragged.slice(-1);
  43449. }
  43450. }
  43451. this.eventManager.addEventListener(this.hot.rootElement, 'touchstart', function (event) {
  43452. var selectedRange = void 0;
  43453. if ((0, _element.hasClass)(event.target, 'topLeftSelectionHandle-HitArea')) {
  43454. selectedRange = _this.hot.getSelectedRangeLast();
  43455. _this.dragged.push('topLeft');
  43456. _this.touchStartRange = {
  43457. width: selectedRange.getWidth(),
  43458. height: selectedRange.getHeight(),
  43459. direction: selectedRange.getDirection()
  43460. };
  43461. event.preventDefault();
  43462. return false;
  43463. } else if ((0, _element.hasClass)(event.target, 'bottomRightSelectionHandle-HitArea')) {
  43464. selectedRange = _this.hot.getSelectedRangeLast();
  43465. _this.dragged.push('bottomRight');
  43466. _this.touchStartRange = {
  43467. width: selectedRange.getWidth(),
  43468. height: selectedRange.getHeight(),
  43469. direction: selectedRange.getDirection()
  43470. };
  43471. event.preventDefault();
  43472. return false;
  43473. }
  43474. });
  43475. this.eventManager.addEventListener(this.hot.rootElement, 'touchend', function (event) {
  43476. if ((0, _element.hasClass)(event.target, 'topLeftSelectionHandle-HitArea')) {
  43477. removeFromDragged.call(_this, 'topLeft');
  43478. _this.touchStartRange = void 0;
  43479. event.preventDefault();
  43480. return false;
  43481. } else if ((0, _element.hasClass)(event.target, 'bottomRightSelectionHandle-HitArea')) {
  43482. removeFromDragged.call(_this, 'bottomRight');
  43483. _this.touchStartRange = void 0;
  43484. event.preventDefault();
  43485. return false;
  43486. }
  43487. });
  43488. this.eventManager.addEventListener(this.hot.rootElement, 'touchmove', function (event) {
  43489. var scrollTop = (0, _element.getWindowScrollTop)(),
  43490. scrollLeft = (0, _element.getWindowScrollLeft)(),
  43491. endTarget = void 0,
  43492. targetCoords = void 0,
  43493. selectedRange = void 0,
  43494. rangeWidth = void 0,
  43495. rangeHeight = void 0,
  43496. rangeDirection = void 0,
  43497. newRangeCoords = void 0;
  43498. if (_this.dragged.length === 0) {
  43499. return;
  43500. }
  43501. endTarget = document.elementFromPoint(event.touches[0].screenX - scrollLeft, event.touches[0].screenY - scrollTop);
  43502. if (!endTarget || endTarget === _this.lastSetCell) {
  43503. return;
  43504. }
  43505. if (endTarget.nodeName == 'TD' || endTarget.nodeName == 'TH') {
  43506. targetCoords = _this.hot.getCoords(endTarget);
  43507. if (targetCoords.col == -1) {
  43508. targetCoords.col = 0;
  43509. }
  43510. selectedRange = _this.hot.getSelectedRangeLast();
  43511. rangeWidth = selectedRange.getWidth();
  43512. rangeHeight = selectedRange.getHeight();
  43513. rangeDirection = selectedRange.getDirection();
  43514. if (rangeWidth == 1 && rangeHeight == 1) {
  43515. _this.hot.selection.setRangeEnd(targetCoords);
  43516. }
  43517. newRangeCoords = _this.getCurrentRangeCoords(selectedRange, targetCoords, _this.touchStartRange.direction, rangeDirection, _this.dragged[0]);
  43518. if (newRangeCoords.start !== null) {
  43519. _this.hot.selection.setRangeStart(newRangeCoords.start);
  43520. }
  43521. _this.hot.selection.setRangeEnd(newRangeCoords.end);
  43522. _this.lastSetCell = endTarget;
  43523. }
  43524. event.preventDefault();
  43525. });
  43526. }
  43527. }, {
  43528. key: 'getCurrentRangeCoords',
  43529. value: function getCurrentRangeCoords(selectedRange, currentTouch, touchStartDirection, currentDirection, draggedHandle) {
  43530. var topLeftCorner = selectedRange.getTopLeftCorner(),
  43531. bottomRightCorner = selectedRange.getBottomRightCorner(),
  43532. bottomLeftCorner = selectedRange.getBottomLeftCorner(),
  43533. topRightCorner = selectedRange.getTopRightCorner();
  43534. var newCoords = {
  43535. start: null,
  43536. end: null
  43537. };
  43538. switch (touchStartDirection) {
  43539. case 'NE-SW':
  43540. switch (currentDirection) {
  43541. case 'NE-SW':
  43542. case 'NW-SE':
  43543. if (draggedHandle == 'topLeft') {
  43544. newCoords = {
  43545. start: new _src.CellCoords(currentTouch.row, selectedRange.highlight.col),
  43546. end: new _src.CellCoords(bottomLeftCorner.row, currentTouch.col)
  43547. };
  43548. } else {
  43549. newCoords = {
  43550. start: new _src.CellCoords(selectedRange.highlight.row, currentTouch.col),
  43551. end: new _src.CellCoords(currentTouch.row, topLeftCorner.col)
  43552. };
  43553. }
  43554. break;
  43555. case 'SE-NW':
  43556. if (draggedHandle == 'bottomRight') {
  43557. newCoords = {
  43558. start: new _src.CellCoords(bottomRightCorner.row, currentTouch.col),
  43559. end: new _src.CellCoords(currentTouch.row, topLeftCorner.col)
  43560. };
  43561. }
  43562. break;
  43563. default:
  43564. break;
  43565. }
  43566. break;
  43567. case 'NW-SE':
  43568. switch (currentDirection) {
  43569. case 'NE-SW':
  43570. if (draggedHandle == 'topLeft') {
  43571. newCoords = {
  43572. start: currentTouch,
  43573. end: bottomLeftCorner
  43574. };
  43575. } else {
  43576. newCoords.end = currentTouch;
  43577. }
  43578. break;
  43579. case 'NW-SE':
  43580. if (draggedHandle == 'topLeft') {
  43581. newCoords = {
  43582. start: currentTouch,
  43583. end: bottomRightCorner
  43584. };
  43585. } else {
  43586. newCoords.end = currentTouch;
  43587. }
  43588. break;
  43589. case 'SE-NW':
  43590. if (draggedHandle == 'topLeft') {
  43591. newCoords = {
  43592. start: currentTouch,
  43593. end: topLeftCorner
  43594. };
  43595. } else {
  43596. newCoords.end = currentTouch;
  43597. }
  43598. break;
  43599. case 'SW-NE':
  43600. if (draggedHandle == 'topLeft') {
  43601. newCoords = {
  43602. start: currentTouch,
  43603. end: topRightCorner
  43604. };
  43605. } else {
  43606. newCoords.end = currentTouch;
  43607. }
  43608. break;
  43609. default:
  43610. break;
  43611. }
  43612. break;
  43613. case 'SW-NE':
  43614. switch (currentDirection) {
  43615. case 'NW-SE':
  43616. if (draggedHandle == 'bottomRight') {
  43617. newCoords = {
  43618. start: new _src.CellCoords(currentTouch.row, topLeftCorner.col),
  43619. end: new _src.CellCoords(bottomLeftCorner.row, currentTouch.col)
  43620. };
  43621. } else {
  43622. newCoords = {
  43623. start: new _src.CellCoords(topLeftCorner.row, currentTouch.col),
  43624. end: new _src.CellCoords(currentTouch.row, bottomRightCorner.col)
  43625. };
  43626. }
  43627. break;
  43628. // case 'NE-SW':
  43629. //
  43630. // break;
  43631. case 'SW-NE':
  43632. if (draggedHandle == 'topLeft') {
  43633. newCoords = {
  43634. start: new _src.CellCoords(selectedRange.highlight.row, currentTouch.col),
  43635. end: new _src.CellCoords(currentTouch.row, bottomRightCorner.col)
  43636. };
  43637. } else {
  43638. newCoords = {
  43639. start: new _src.CellCoords(currentTouch.row, topLeftCorner.col),
  43640. end: new _src.CellCoords(topLeftCorner.row, currentTouch.col)
  43641. };
  43642. }
  43643. break;
  43644. case 'SE-NW':
  43645. if (draggedHandle == 'bottomRight') {
  43646. newCoords = {
  43647. start: new _src.CellCoords(currentTouch.row, topRightCorner.col),
  43648. end: new _src.CellCoords(topLeftCorner.row, currentTouch.col)
  43649. };
  43650. } else if (draggedHandle == 'topLeft') {
  43651. newCoords = {
  43652. start: bottomLeftCorner,
  43653. end: currentTouch
  43654. };
  43655. }
  43656. break;
  43657. default:
  43658. break;
  43659. }
  43660. break;
  43661. case 'SE-NW':
  43662. switch (currentDirection) {
  43663. case 'NW-SE':
  43664. case 'NE-SW':
  43665. case 'SW-NE':
  43666. if (draggedHandle == 'topLeft') {
  43667. newCoords.end = currentTouch;
  43668. }
  43669. break;
  43670. case 'SE-NW':
  43671. if (draggedHandle == 'topLeft') {
  43672. newCoords.end = currentTouch;
  43673. } else {
  43674. newCoords = {
  43675. start: currentTouch,
  43676. end: topLeftCorner
  43677. };
  43678. }
  43679. break;
  43680. default:
  43681. break;
  43682. }
  43683. break;
  43684. default:
  43685. break;
  43686. }
  43687. return newCoords;
  43688. }
  43689. /**
  43690. * Check if user is currently dragging the handle.
  43691. *
  43692. * @returns {boolean} Dragging state
  43693. */
  43694. }, {
  43695. key: 'isDragged',
  43696. value: function isDragged() {
  43697. return this.dragged.length > 0;
  43698. }
  43699. }]);
  43700. return MultipleSelectionHandles;
  43701. }(_base2.default);
  43702. (0, _plugins.registerPlugin)('multipleSelectionHandles', MultipleSelectionHandles);
  43703. exports.default = MultipleSelectionHandles;
  43704. /***/ }),
  43705. /* 351 */
  43706. /***/ (function(module, exports, __webpack_require__) {
  43707. "use strict";
  43708. exports.__esModule = true;
  43709. 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; }; }();
  43710. 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); } };
  43711. var _base = __webpack_require__(10);
  43712. var _base2 = _interopRequireDefault(_base);
  43713. var _jsonPatchDuplex = __webpack_require__(205);
  43714. var _jsonPatchDuplex2 = _interopRequireDefault(_jsonPatchDuplex);
  43715. var _dataObserver = __webpack_require__(352);
  43716. var _dataObserver2 = _interopRequireDefault(_dataObserver);
  43717. var _array = __webpack_require__(1);
  43718. var _plugins = __webpack_require__(8);
  43719. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  43720. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  43721. 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; }
  43722. 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; }
  43723. // Handsontable.hooks.register('afterChangesObserved');
  43724. /**
  43725. * @plugin ObserveChanges
  43726. *
  43727. * @description
  43728. * This plugin allows to observe data source changes.
  43729. *
  43730. * By default, the plugin is declared as `undefined`, which makes it disabled.
  43731. * Enabling this plugin switches the table into one-way data binding where changes are applied into the data source (outside from the table)
  43732. * will be automatically reflected in the table.
  43733. *
  43734. * ```js
  43735. * ...
  43736. * // as a boolean
  43737. * observeChanges: true,
  43738. * ...
  43739. * ```
  43740. *
  43741. * To configure this plugin see {@link Options#observeChanges}.
  43742. */
  43743. var ObserveChanges = function (_BasePlugin) {
  43744. _inherits(ObserveChanges, _BasePlugin);
  43745. function ObserveChanges(hotInstance) {
  43746. _classCallCheck(this, ObserveChanges);
  43747. /**
  43748. * Instance of {@link DataObserver}.
  43749. *
  43750. * @type {DataObserver}
  43751. */
  43752. var _this = _possibleConstructorReturn(this, (ObserveChanges.__proto__ || Object.getPrototypeOf(ObserveChanges)).call(this, hotInstance));
  43753. _this.observer = null;
  43754. return _this;
  43755. }
  43756. /**
  43757. * Check if the plugin is enabled in the handsontable settings.
  43758. *
  43759. * @returns {Boolean}
  43760. */
  43761. _createClass(ObserveChanges, [{
  43762. key: 'isEnabled',
  43763. value: function isEnabled() {
  43764. return this.hot.getSettings().observeChanges;
  43765. }
  43766. /**
  43767. * Enable plugin for this Handsontable instance.
  43768. */
  43769. }, {
  43770. key: 'enablePlugin',
  43771. value: function enablePlugin() {
  43772. var _this2 = this;
  43773. if (this.enabled) {
  43774. return;
  43775. }
  43776. if (!this.observer) {
  43777. this.observer = new _dataObserver2.default(this.hot.getSourceData());
  43778. this._exposePublicApi();
  43779. }
  43780. this.observer.addLocalHook('change', function (patches) {
  43781. return _this2.onDataChange(patches);
  43782. });
  43783. this.addHook('afterCreateRow', function () {
  43784. return _this2.onAfterTableAlter();
  43785. });
  43786. this.addHook('afterRemoveRow', function () {
  43787. return _this2.onAfterTableAlter();
  43788. });
  43789. this.addHook('afterCreateCol', function () {
  43790. return _this2.onAfterTableAlter();
  43791. });
  43792. this.addHook('afterRemoveCol', function () {
  43793. return _this2.onAfterTableAlter();
  43794. });
  43795. this.addHook('afterChange', function (changes, source) {
  43796. return _this2.onAfterTableAlter(source);
  43797. });
  43798. this.addHook('afterLoadData', function (firstRun) {
  43799. return _this2.onAfterLoadData(firstRun);
  43800. });
  43801. _get(ObserveChanges.prototype.__proto__ || Object.getPrototypeOf(ObserveChanges.prototype), 'enablePlugin', this).call(this);
  43802. }
  43803. /**
  43804. * Disable plugin for this Handsontable instance.
  43805. */
  43806. }, {
  43807. key: 'disablePlugin',
  43808. value: function disablePlugin() {
  43809. if (this.observer) {
  43810. this.observer.destroy();
  43811. this.observer = null;
  43812. this._deletePublicApi();
  43813. }
  43814. _get(ObserveChanges.prototype.__proto__ || Object.getPrototypeOf(ObserveChanges.prototype), 'disablePlugin', this).call(this);
  43815. }
  43816. /**
  43817. * Data change observer.
  43818. *
  43819. * @private
  43820. * @param {Array} patches An array of objects which every item defines coordinates where data was changed.
  43821. */
  43822. }, {
  43823. key: 'onDataChange',
  43824. value: function onDataChange(patches) {
  43825. var _this3 = this;
  43826. if (!this.observer.isPaused()) {
  43827. var sourceName = this.pluginName + '.change';
  43828. var actions = {
  43829. add: function add(patch) {
  43830. if (isNaN(patch.col)) {
  43831. _this3.hot.runHooks('afterCreateRow', patch.row, 1, sourceName);
  43832. } else {
  43833. _this3.hot.runHooks('afterCreateCol', patch.col, 1, sourceName);
  43834. }
  43835. },
  43836. remove: function remove(patch) {
  43837. if (isNaN(patch.col)) {
  43838. _this3.hot.runHooks('afterRemoveRow', patch.row, 1, sourceName);
  43839. } else {
  43840. _this3.hot.runHooks('afterRemoveCol', patch.col, 1, sourceName);
  43841. }
  43842. },
  43843. replace: function replace(patch) {
  43844. _this3.hot.runHooks('afterChange', [[patch.row, patch.col, null, patch.value]], sourceName);
  43845. }
  43846. };
  43847. (0, _array.arrayEach)(patches, function (patch) {
  43848. if (actions[patch.op]) {
  43849. actions[patch.op](patch);
  43850. }
  43851. });
  43852. this.hot.render();
  43853. }
  43854. this.hot.runHooks('afterChangesObserved');
  43855. }
  43856. /**
  43857. * On after table alter listener. Prevents infinity loop between internal and external data changing.
  43858. *
  43859. * @private
  43860. * @param source
  43861. */
  43862. }, {
  43863. key: 'onAfterTableAlter',
  43864. value: function onAfterTableAlter(source) {
  43865. var _this4 = this;
  43866. if (source !== 'loadData') {
  43867. this.observer.pause();
  43868. this.hot.addHookOnce('afterChangesObserved', function () {
  43869. return _this4.observer.resume();
  43870. });
  43871. }
  43872. }
  43873. /**
  43874. * On after load data listener.
  43875. *
  43876. * @private
  43877. * @param {Boolean} firstRun `true` if event was fired first time.
  43878. */
  43879. }, {
  43880. key: 'onAfterLoadData',
  43881. value: function onAfterLoadData(firstRun) {
  43882. if (!firstRun) {
  43883. this.observer.setObservedData(this.hot.getSourceData());
  43884. }
  43885. }
  43886. /**
  43887. * Destroy plugin instance.
  43888. */
  43889. }, {
  43890. key: 'destroy',
  43891. value: function destroy() {
  43892. if (this.observer) {
  43893. this.observer.destroy();
  43894. this._deletePublicApi();
  43895. }
  43896. _get(ObserveChanges.prototype.__proto__ || Object.getPrototypeOf(ObserveChanges.prototype), 'destroy', this).call(this);
  43897. }
  43898. /**
  43899. * Expose plugins methods to the core.
  43900. *
  43901. * @private
  43902. */
  43903. }, {
  43904. key: '_exposePublicApi',
  43905. value: function _exposePublicApi() {
  43906. var _this5 = this;
  43907. var hot = this.hot;
  43908. hot.pauseObservingChanges = function () {
  43909. return _this5.observer.pause();
  43910. };
  43911. hot.resumeObservingChanges = function () {
  43912. return _this5.observer.resume();
  43913. };
  43914. hot.isPausedObservingChanges = function () {
  43915. return _this5.observer.isPaused();
  43916. };
  43917. }
  43918. /**
  43919. * Delete all previously exposed methods.
  43920. *
  43921. * @private
  43922. */
  43923. }, {
  43924. key: '_deletePublicApi',
  43925. value: function _deletePublicApi() {
  43926. var hot = this.hot;
  43927. delete hot.pauseObservingChanges;
  43928. delete hot.resumeObservingChanges;
  43929. delete hot.isPausedObservingChanges;
  43930. }
  43931. }]);
  43932. return ObserveChanges;
  43933. }(_base2.default);
  43934. exports.default = ObserveChanges;
  43935. (0, _plugins.registerPlugin)('observeChanges', ObserveChanges);
  43936. /***/ }),
  43937. /* 352 */
  43938. /***/ (function(module, exports, __webpack_require__) {
  43939. "use strict";
  43940. exports.__esModule = true;
  43941. 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; }; }();
  43942. var _jsonPatchDuplex = __webpack_require__(205);
  43943. var _jsonPatchDuplex2 = _interopRequireDefault(_jsonPatchDuplex);
  43944. var _localHooks = __webpack_require__(58);
  43945. var _localHooks2 = _interopRequireDefault(_localHooks);
  43946. var _object = __webpack_require__(2);
  43947. var _utils = __webpack_require__(353);
  43948. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  43949. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  43950. /**
  43951. * @class DataObserver
  43952. * @plugin ObserveChanges
  43953. */
  43954. var DataObserver = function () {
  43955. function DataObserver(observedData) {
  43956. _classCallCheck(this, DataObserver);
  43957. /**
  43958. * Observed source data.
  43959. *
  43960. * @type {Array}
  43961. */
  43962. this.observedData = null;
  43963. /**
  43964. * JsonPatch observer.
  43965. *
  43966. * @type {Object}
  43967. */
  43968. this.observer = null;
  43969. /**
  43970. * Flag which determines if observer is paused or not. Paused observer doesn't emit `change` hooks.
  43971. *
  43972. * @type {Boolean}
  43973. * @default false
  43974. */
  43975. this.paused = false;
  43976. this.setObservedData(observedData);
  43977. }
  43978. /**
  43979. * Set data to observe.
  43980. *
  43981. * @param {*} observedData
  43982. */
  43983. _createClass(DataObserver, [{
  43984. key: 'setObservedData',
  43985. value: function setObservedData(observedData) {
  43986. var _this = this;
  43987. if (this.observer) {
  43988. _jsonPatchDuplex2.default.unobserve(this.observedData, this.observer);
  43989. }
  43990. this.observedData = observedData;
  43991. this.observer = _jsonPatchDuplex2.default.observe(this.observedData, function (patches) {
  43992. return _this.onChange(patches);
  43993. });
  43994. }
  43995. /**
  43996. * Check if observer was paused.
  43997. *
  43998. * @returns {Boolean}
  43999. */
  44000. }, {
  44001. key: 'isPaused',
  44002. value: function isPaused() {
  44003. return this.paused;
  44004. }
  44005. /**
  44006. * Pause observer (stop emitting all detected changes).
  44007. */
  44008. }, {
  44009. key: 'pause',
  44010. value: function pause() {
  44011. this.paused = true;
  44012. }
  44013. /**
  44014. * Resume observer (emit all detected changes).
  44015. */
  44016. }, {
  44017. key: 'resume',
  44018. value: function resume() {
  44019. this.paused = false;
  44020. }
  44021. /**
  44022. * JsonPatch on change listener.
  44023. *
  44024. * @private
  44025. * @param {Array} patches An array of object passed from jsonpatch.
  44026. */
  44027. }, {
  44028. key: 'onChange',
  44029. value: function onChange(patches) {
  44030. this.runLocalHooks('change', (0, _utils.cleanPatches)(patches));
  44031. }
  44032. /**
  44033. * Destroy observer instance.
  44034. */
  44035. }, {
  44036. key: 'destroy',
  44037. value: function destroy() {
  44038. _jsonPatchDuplex2.default.unobserve(this.observedData, this.observer);
  44039. this.observedData = null;
  44040. this.observer = null;
  44041. }
  44042. }]);
  44043. return DataObserver;
  44044. }();
  44045. (0, _object.mixin)(DataObserver, _localHooks2.default);
  44046. exports.default = DataObserver;
  44047. /***/ }),
  44048. /* 353 */
  44049. /***/ (function(module, exports, __webpack_require__) {
  44050. "use strict";
  44051. exports.__esModule = true;
  44052. 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"); } }; }();
  44053. exports.cleanPatches = cleanPatches;
  44054. exports.parsePath = parsePath;
  44055. var _array = __webpack_require__(1);
  44056. /**
  44057. * Clean and extend patches from jsonpatch observer.
  44058. *
  44059. * @param {Array} patches
  44060. * @returns {Array}
  44061. */
  44062. function cleanPatches(patches) {
  44063. var newOrRemovedColumns = [];
  44064. /**
  44065. * If observeChanges uses native Object.observe method, then it produces patches for length property. Filter them.
  44066. * If path can't be parsed. Filter it.
  44067. */
  44068. patches = (0, _array.arrayFilter)(patches, function (patch) {
  44069. if (/[/]length/ig.test(patch.path)) {
  44070. return false;
  44071. }
  44072. if (!parsePath(patch.path)) {
  44073. return false;
  44074. }
  44075. return true;
  44076. });
  44077. /**
  44078. * Extend patches with changed cells coords
  44079. */
  44080. patches = (0, _array.arrayMap)(patches, function (patch) {
  44081. var coords = parsePath(patch.path);
  44082. patch.row = coords.row;
  44083. patch.col = coords.col;
  44084. return patch;
  44085. });
  44086. /**
  44087. * Removing or adding column will produce one patch for each table row.
  44088. * Leaves only one patch for each column add/remove operation.
  44089. */
  44090. patches = (0, _array.arrayFilter)(patches, function (patch) {
  44091. if (['add', 'remove'].indexOf(patch.op) !== -1 && !isNaN(patch.col)) {
  44092. if (newOrRemovedColumns.indexOf(patch.col) !== -1) {
  44093. return false;
  44094. }
  44095. newOrRemovedColumns.push(patch.col);
  44096. }
  44097. return true;
  44098. });
  44099. newOrRemovedColumns.length = 0;
  44100. return patches;
  44101. }
  44102. /**
  44103. * Extract coordinates from path where data was changed.
  44104. *
  44105. * @param {String} path Path describing where data was changed.
  44106. * @returns {Object|null} Returns an object with `row` and `col` properties or `null` if path doesn't have necessary information.
  44107. */
  44108. function parsePath(path) {
  44109. var match = path.match(/^\/(\d+)\/?(.*)?$/);
  44110. if (!match) {
  44111. return null;
  44112. }
  44113. var _match = _slicedToArray(match, 3),
  44114. row = _match[1],
  44115. column = _match[2];
  44116. return {
  44117. row: parseInt(row, 10),
  44118. col: /^\d*$/.test(column) ? parseInt(column, 10) : column
  44119. };
  44120. }
  44121. /***/ }),
  44122. /* 354 */
  44123. /***/ (function(module, exports, __webpack_require__) {
  44124. "use strict";
  44125. exports.__esModule = true;
  44126. 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; }; }();
  44127. 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); } };
  44128. var _base = __webpack_require__(10);
  44129. var _base2 = _interopRequireDefault(_base);
  44130. var _plugins = __webpack_require__(8);
  44131. var _object = __webpack_require__(2);
  44132. var _number = __webpack_require__(5);
  44133. var _mixed = __webpack_require__(16);
  44134. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  44135. 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); } }
  44136. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  44137. 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; }
  44138. 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; }
  44139. var DEFAULT_SEARCH_RESULT_CLASS = 'htSearchResult';
  44140. var DEFAULT_CALLBACK = function DEFAULT_CALLBACK(instance, row, col, data, testResult) {
  44141. instance.getCellMeta(row, col).isSearchResult = testResult;
  44142. };
  44143. var DEFAULT_QUERY_METHOD = function DEFAULT_QUERY_METHOD(query, value) {
  44144. if ((0, _mixed.isUndefined)(query) || query === null || !query.toLowerCase || query.length === 0) {
  44145. return false;
  44146. }
  44147. if ((0, _mixed.isUndefined)(value) || value === null) {
  44148. return false;
  44149. }
  44150. return value.toString().toLowerCase().indexOf(query.toLowerCase()) !== -1;
  44151. };
  44152. /**
  44153. * @plugin Search
  44154. *
  44155. * @example
  44156. *
  44157. * ```js
  44158. * ...
  44159. * // as boolean
  44160. * search: true
  44161. *
  44162. * // as a object with one or more options
  44163. * search: {
  44164. * callback: myNewCallbackFunction,
  44165. * queryMethod: myNewQueryMethod,
  44166. * searchResultClass: 'customClass'
  44167. * }
  44168. *
  44169. * // Access to search plugin instance:
  44170. * var searchPlugin = hot.getPlugin('search');
  44171. *
  44172. * // Set callback programmatically:
  44173. * searchPlugin.setCallback(myNewCallbackFunction);
  44174. * // Set query method programmatically:
  44175. * searchPlugin.setQueryMethod(myNewQueryMethod);
  44176. * // Set search result cells class programmatically:
  44177. * searchPlugin.setSearchResultClass(customClass);
  44178. * ...
  44179. * ```
  44180. */
  44181. var Search = function (_BasePlugin) {
  44182. _inherits(Search, _BasePlugin);
  44183. function Search(hotInstance) {
  44184. _classCallCheck(this, Search);
  44185. /**
  44186. * Function called during querying for each cell from the {@link DataMap}.
  44187. *
  44188. * @type {Function}
  44189. */
  44190. var _this = _possibleConstructorReturn(this, (Search.__proto__ || Object.getPrototypeOf(Search)).call(this, hotInstance));
  44191. _this.callback = DEFAULT_CALLBACK;
  44192. /**
  44193. * Query function is responsible for determining whether a query matches the value stored in a cell.
  44194. *
  44195. * @type {Function}
  44196. */
  44197. _this.queryMethod = DEFAULT_QUERY_METHOD;
  44198. /**
  44199. * Class name added to each cell that belongs to the searched query.
  44200. *
  44201. * @type {String}
  44202. */
  44203. _this.searchResultClass = DEFAULT_SEARCH_RESULT_CLASS;
  44204. return _this;
  44205. }
  44206. /**
  44207. * Check if the plugin is enabled in the Handsontable settings.
  44208. *
  44209. * @returns {Boolean}
  44210. */
  44211. _createClass(Search, [{
  44212. key: 'isEnabled',
  44213. value: function isEnabled() {
  44214. return this.hot.getSettings().search;
  44215. }
  44216. /**
  44217. * Enable plugin for this Handsontable instance.
  44218. */
  44219. }, {
  44220. key: 'enablePlugin',
  44221. value: function enablePlugin() {
  44222. var _this2 = this;
  44223. if (this.enabled) {
  44224. return;
  44225. }
  44226. var searchSettings = this.hot.getSettings().search;
  44227. this.updatePluginSettings(searchSettings);
  44228. this.addHook('beforeRenderer', function () {
  44229. return _this2.onBeforeRenderer.apply(_this2, arguments);
  44230. });
  44231. _get(Search.prototype.__proto__ || Object.getPrototypeOf(Search.prototype), 'enablePlugin', this).call(this);
  44232. }
  44233. /**
  44234. * Disable plugin for this Handsontable instance.
  44235. */
  44236. }, {
  44237. key: 'disablePlugin',
  44238. value: function disablePlugin() {
  44239. var _this3 = this;
  44240. var beforeRendererCallback = function beforeRendererCallback() {
  44241. return _this3.onBeforeRenderer.apply(_this3, arguments);
  44242. };
  44243. this.hot.addHook('beforeRenderer', beforeRendererCallback);
  44244. this.hot.addHookOnce('afterRender', function () {
  44245. _this3.hot.removeHook('beforeRenderer', beforeRendererCallback);
  44246. });
  44247. _get(Search.prototype.__proto__ || Object.getPrototypeOf(Search.prototype), 'disablePlugin', this).call(this);
  44248. }
  44249. /**
  44250. * Updates the plugin to use the latest options you have specified.
  44251. */
  44252. }, {
  44253. key: 'updatePlugin',
  44254. value: function updatePlugin() {
  44255. this.disablePlugin();
  44256. this.enablePlugin();
  44257. _get(Search.prototype.__proto__ || Object.getPrototypeOf(Search.prototype), 'updatePlugin', this).call(this);
  44258. }
  44259. /**
  44260. * Query method - used inside search input listener.
  44261. *
  44262. * @param {String} queryStr Searched value.
  44263. * @param {Function} [callback] Callback function performed on cells with values which matches to the searched query.
  44264. * @param {Function} [queryMethod] Query function responsible for determining whether a query matches the value stored in a cell.
  44265. *
  44266. * @returns {Array} Return array of objects with `row`, `col`, `data` properties or empty array.
  44267. */
  44268. }, {
  44269. key: 'query',
  44270. value: function query(queryStr) {
  44271. var _this4 = this;
  44272. var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getCallback();
  44273. var queryMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.getQueryMethod();
  44274. var rowCount = this.hot.countRows();
  44275. var colCount = this.hot.countCols();
  44276. var queryResult = [];
  44277. var instance = this.hot;
  44278. (0, _number.rangeEach)(0, rowCount - 1, function (rowIndex) {
  44279. (0, _number.rangeEach)(0, colCount - 1, function (colIndex) {
  44280. var cellData = _this4.hot.getDataAtCell(rowIndex, colIndex);
  44281. var cellProperties = _this4.hot.getCellMeta(rowIndex, colIndex);
  44282. var cellCallback = cellProperties.search.callback || callback;
  44283. var cellQueryMethod = cellProperties.search.queryMethod || queryMethod;
  44284. var testResult = cellQueryMethod(queryStr, cellData);
  44285. if (testResult) {
  44286. var singleResult = {
  44287. row: rowIndex,
  44288. col: colIndex,
  44289. data: cellData
  44290. };
  44291. queryResult.push(singleResult);
  44292. }
  44293. if (cellCallback) {
  44294. cellCallback(instance, rowIndex, colIndex, cellData, testResult);
  44295. }
  44296. });
  44297. });
  44298. return queryResult;
  44299. }
  44300. }, {
  44301. key: 'getCallback',
  44302. /**
  44303. * Get callback function.
  44304. *
  44305. * @returns {Function} Return the callback function.
  44306. */
  44307. value: function getCallback() {
  44308. return this.callback;
  44309. }
  44310. /**
  44311. * Set callback function.
  44312. *
  44313. * @param {Function} newCallback
  44314. */
  44315. }, {
  44316. key: 'setCallback',
  44317. value: function setCallback(newCallback) {
  44318. this.callback = newCallback;
  44319. }
  44320. /**
  44321. * Get queryMethod function.
  44322. *
  44323. * @returns {Function} Return the query method.
  44324. */
  44325. }, {
  44326. key: 'getQueryMethod',
  44327. value: function getQueryMethod() {
  44328. return this.queryMethod;
  44329. }
  44330. /**
  44331. * Set queryMethod function.
  44332. *
  44333. * @param {Function} newQueryMethod
  44334. */
  44335. }, {
  44336. key: 'setQueryMethod',
  44337. value: function setQueryMethod(newQueryMethod) {
  44338. this.queryMethod = newQueryMethod;
  44339. }
  44340. /**
  44341. * Get search result cells class.
  44342. *
  44343. * @returns {Function} Return the cell class.
  44344. */
  44345. }, {
  44346. key: 'getSearchResultClass',
  44347. value: function getSearchResultClass() {
  44348. return this.searchResultClass;
  44349. }
  44350. /**
  44351. * Set search result cells class.
  44352. *
  44353. * @param {String} newElementClass
  44354. */
  44355. }, {
  44356. key: 'setSearchResultClass',
  44357. value: function setSearchResultClass(newElementClass) {
  44358. this.searchResultClass = newElementClass;
  44359. }
  44360. /**
  44361. * Updates the settings of the plugin.
  44362. *
  44363. * @param {Object} searchSettings The plugin settings, taken from Handsontable configuration.
  44364. * @private
  44365. */
  44366. }, {
  44367. key: 'updatePluginSettings',
  44368. value: function updatePluginSettings(searchSettings) {
  44369. if ((0, _object.isObject)(searchSettings)) {
  44370. if (searchSettings.searchResultClass) {
  44371. this.setSearchResultClass(searchSettings.searchResultClass);
  44372. }
  44373. if (searchSettings.queryMethod) {
  44374. this.setQueryMethod(searchSettings.queryMethod);
  44375. }
  44376. if (searchSettings.callback) {
  44377. this.setCallback(searchSettings.callback);
  44378. }
  44379. }
  44380. }
  44381. /** *
  44382. * The `beforeRenderer` hook callback.
  44383. *
  44384. * @private
  44385. * @param {HTMLTableCellElement} TD The rendered `TD` element.
  44386. * @param {Number} row Visual row index.
  44387. * @param {Number} col Visual column index.
  44388. * @param {String | Number} prop Column property name or a column index, if datasource is an array of arrays.
  44389. * @param {String} value Value of the rendered cell.
  44390. * @param {Object} cellProperties Object containing the cell's properties.
  44391. */
  44392. }, {
  44393. key: 'onBeforeRenderer',
  44394. value: function onBeforeRenderer(TD, row, col, prop, value, cellProperties) {
  44395. // TODO: #4972
  44396. var className = cellProperties.className || [];
  44397. var classArray = [];
  44398. if (typeof className === 'string') {
  44399. classArray = className.split(' ');
  44400. } else {
  44401. var _classArray;
  44402. (_classArray = classArray).push.apply(_classArray, _toConsumableArray(className));
  44403. }
  44404. if (this.isEnabled() && cellProperties.isSearchResult) {
  44405. if (!classArray.includes(this.searchResultClass)) {
  44406. classArray.push('' + this.searchResultClass);
  44407. }
  44408. } else if (classArray.includes(this.searchResultClass)) {
  44409. classArray.splice(classArray.indexOf(this.searchResultClass), 1);
  44410. }
  44411. cellProperties.className = classArray.join(' ');
  44412. }
  44413. /**
  44414. * Destroy plugin instance.
  44415. */
  44416. }, {
  44417. key: 'destroy',
  44418. value: function destroy() {
  44419. _get(Search.prototype.__proto__ || Object.getPrototypeOf(Search.prototype), 'destroy', this).call(this);
  44420. }
  44421. }]);
  44422. return Search;
  44423. }(_base2.default);
  44424. (0, _plugins.registerPlugin)('search', Search);
  44425. exports.default = Search;
  44426. /***/ }),
  44427. /* 355 */
  44428. /***/ (function(module, exports, __webpack_require__) {
  44429. "use strict";
  44430. exports.__esModule = true;
  44431. 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; }; }();
  44432. 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); } };
  44433. var _element = __webpack_require__(0);
  44434. var _array = __webpack_require__(1);
  44435. var _base = __webpack_require__(10);
  44436. var _base2 = _interopRequireDefault(_base);
  44437. var _plugins = __webpack_require__(8);
  44438. var _feature = __webpack_require__(40);
  44439. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  44440. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  44441. 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; }
  44442. 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; }
  44443. /**
  44444. * @private
  44445. * @plugin TouchScroll
  44446. * @class TouchScroll
  44447. */
  44448. var TouchScroll = function (_BasePlugin) {
  44449. _inherits(TouchScroll, _BasePlugin);
  44450. function TouchScroll(hotInstance) {
  44451. _classCallCheck(this, TouchScroll);
  44452. /**
  44453. * Collection of scrollbars to update.
  44454. *
  44455. * @type {Array}
  44456. */
  44457. var _this = _possibleConstructorReturn(this, (TouchScroll.__proto__ || Object.getPrototypeOf(TouchScroll)).call(this, hotInstance));
  44458. _this.scrollbars = [];
  44459. /**
  44460. * Collection of overlays to update.
  44461. *
  44462. * @type {Array}
  44463. */
  44464. _this.clones = [];
  44465. /**
  44466. * Flag which determines if collection of overlays should be refilled on every table render.
  44467. *
  44468. * @type {Boolean}
  44469. * @default false
  44470. */
  44471. _this.lockedCollection = false;
  44472. /**
  44473. * Flag which determines if walkontable should freeze overlays while scrolling.
  44474. *
  44475. * @type {Boolean}
  44476. * @default false
  44477. */
  44478. _this.freezeOverlays = false;
  44479. return _this;
  44480. }
  44481. /**
  44482. * Check if plugin is enabled.
  44483. *
  44484. * @returns {Boolean}
  44485. */
  44486. _createClass(TouchScroll, [{
  44487. key: 'isEnabled',
  44488. value: function isEnabled() {
  44489. return (0, _feature.isTouchSupported)();
  44490. }
  44491. /**
  44492. * Enable the plugin.
  44493. */
  44494. }, {
  44495. key: 'enablePlugin',
  44496. value: function enablePlugin() {
  44497. var _this2 = this;
  44498. if (this.enabled) {
  44499. return;
  44500. }
  44501. this.addHook('afterRender', function () {
  44502. return _this2.onAfterRender();
  44503. });
  44504. this.registerEvents();
  44505. _get(TouchScroll.prototype.__proto__ || Object.getPrototypeOf(TouchScroll.prototype), 'enablePlugin', this).call(this);
  44506. }
  44507. /**
  44508. * Updates the plugin to use the latest options you have specified.
  44509. */
  44510. }, {
  44511. key: 'updatePlugin',
  44512. value: function updatePlugin() {
  44513. this.lockedCollection = false;
  44514. _get(TouchScroll.prototype.__proto__ || Object.getPrototypeOf(TouchScroll.prototype), 'updatePlugin', this).call(this);
  44515. }
  44516. /**
  44517. * Disable plugin for this Handsontable instance.
  44518. */
  44519. }, {
  44520. key: 'disablePlugin',
  44521. value: function disablePlugin() {
  44522. _get(TouchScroll.prototype.__proto__ || Object.getPrototypeOf(TouchScroll.prototype), 'disablePlugin', this).call(this);
  44523. }
  44524. /**
  44525. * Register all necessary events.
  44526. *
  44527. * @private
  44528. */
  44529. }, {
  44530. key: 'registerEvents',
  44531. value: function registerEvents() {
  44532. var _this3 = this;
  44533. this.addHook('beforeTouchScroll', function () {
  44534. return _this3.onBeforeTouchScroll();
  44535. });
  44536. this.addHook('afterMomentumScroll', function () {
  44537. return _this3.onAfterMomentumScroll();
  44538. });
  44539. }
  44540. /**
  44541. * After render listener.
  44542. *
  44543. * @private
  44544. */
  44545. }, {
  44546. key: 'onAfterRender',
  44547. value: function onAfterRender() {
  44548. if (this.lockedCollection) {
  44549. return;
  44550. }
  44551. var _hot$view$wt$wtOverla = this.hot.view.wt.wtOverlays,
  44552. topOverlay = _hot$view$wt$wtOverla.topOverlay,
  44553. bottomOverlay = _hot$view$wt$wtOverla.bottomOverlay,
  44554. leftOverlay = _hot$view$wt$wtOverla.leftOverlay,
  44555. topLeftCornerOverlay = _hot$view$wt$wtOverla.topLeftCornerOverlay,
  44556. bottomLeftCornerOverlay = _hot$view$wt$wtOverla.bottomLeftCornerOverlay;
  44557. this.lockedCollection = true;
  44558. this.scrollbars.length = 0;
  44559. this.scrollbars.push(topOverlay);
  44560. if (bottomOverlay.clone) {
  44561. this.scrollbars.push(bottomOverlay);
  44562. }
  44563. this.scrollbars.push(leftOverlay);
  44564. if (topLeftCornerOverlay) {
  44565. this.scrollbars.push(topLeftCornerOverlay);
  44566. }
  44567. if (bottomLeftCornerOverlay && bottomLeftCornerOverlay.clone) {
  44568. this.scrollbars.push(bottomLeftCornerOverlay);
  44569. }
  44570. this.clones.length = 0;
  44571. if (topOverlay.needFullRender) {
  44572. this.clones.push(topOverlay.clone.wtTable.holder.parentNode);
  44573. }
  44574. if (bottomOverlay.needFullRender) {
  44575. this.clones.push(bottomOverlay.clone.wtTable.holder.parentNode);
  44576. }
  44577. if (leftOverlay.needFullRender) {
  44578. this.clones.push(leftOverlay.clone.wtTable.holder.parentNode);
  44579. }
  44580. if (topLeftCornerOverlay) {
  44581. this.clones.push(topLeftCornerOverlay.clone.wtTable.holder.parentNode);
  44582. }
  44583. if (bottomLeftCornerOverlay && bottomLeftCornerOverlay.clone) {
  44584. this.clones.push(bottomLeftCornerOverlay.clone.wtTable.holder.parentNode);
  44585. }
  44586. }
  44587. /**
  44588. * Touch scroll listener.
  44589. *
  44590. * @private
  44591. */
  44592. }, {
  44593. key: 'onBeforeTouchScroll',
  44594. value: function onBeforeTouchScroll() {
  44595. this.freezeOverlays = true;
  44596. (0, _array.arrayEach)(this.clones, function (clone) {
  44597. (0, _element.addClass)(clone, 'hide-tween');
  44598. });
  44599. }
  44600. /**
  44601. * After momentum scroll listener.
  44602. *
  44603. * @private
  44604. */
  44605. }, {
  44606. key: 'onAfterMomentumScroll',
  44607. value: function onAfterMomentumScroll() {
  44608. var _this4 = this;
  44609. this.freezeOverlays = false;
  44610. (0, _array.arrayEach)(this.clones, function (clone) {
  44611. (0, _element.removeClass)(clone, 'hide-tween');
  44612. (0, _element.addClass)(clone, 'show-tween');
  44613. });
  44614. setTimeout(function () {
  44615. (0, _array.arrayEach)(_this4.clones, function (clone) {
  44616. (0, _element.removeClass)(clone, 'show-tween');
  44617. });
  44618. }, 400);
  44619. (0, _array.arrayEach)(this.scrollbars, function (scrollbar) {
  44620. scrollbar.refresh();
  44621. scrollbar.resetFixedPosition();
  44622. });
  44623. this.hot.view.wt.wtOverlays.syncScrollWithMaster();
  44624. }
  44625. }]);
  44626. return TouchScroll;
  44627. }(_base2.default);
  44628. (0, _plugins.registerPlugin)('touchScroll', TouchScroll);
  44629. exports.default = TouchScroll;
  44630. /***/ }),
  44631. /* 356 */
  44632. /***/ (function(module, exports, __webpack_require__) {
  44633. "use strict";
  44634. exports.__esModule = true;
  44635. 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; }; }();
  44636. var _pluginHooks = __webpack_require__(15);
  44637. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  44638. var _array = __webpack_require__(1);
  44639. var _number = __webpack_require__(5);
  44640. var _object = __webpack_require__(2);
  44641. var _event = __webpack_require__(12);
  44642. var _src = __webpack_require__(4);
  44643. var _utils = __webpack_require__(19);
  44644. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  44645. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  44646. 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; }
  44647. 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; } /**
  44648. * Handsontable UndoRedo class
  44649. */
  44650. /**
  44651. * @description
  44652. * Handsontable UndoRedo plugin. It allows to undo and redo certain actions done in the table.
  44653. * Please note, that not all actions are currently undo-able.
  44654. *
  44655. * @example
  44656. * ```js
  44657. * ...
  44658. * undo: true
  44659. * ...
  44660. * ```
  44661. * @class UndoRedo
  44662. * @plugin UndoRedo
  44663. */
  44664. function UndoRedo(instance) {
  44665. var plugin = this;
  44666. this.instance = instance;
  44667. this.doneActions = [];
  44668. this.undoneActions = [];
  44669. this.ignoreNewActions = false;
  44670. instance.addHook('afterChange', function (changes, source) {
  44671. if (changes && source !== 'UndoRedo.undo' && source !== 'UndoRedo.redo' && source !== 'MergeCells') {
  44672. plugin.done(new UndoRedo.ChangeAction(changes));
  44673. }
  44674. });
  44675. instance.addHook('afterCreateRow', function (index, amount, source) {
  44676. if (source === 'UndoRedo.undo' || source === 'UndoRedo.undo' || source === 'auto') {
  44677. return;
  44678. }
  44679. var action = new UndoRedo.CreateRowAction(index, amount);
  44680. plugin.done(action);
  44681. });
  44682. instance.addHook('beforeRemoveRow', function (index, amount, logicRows, source) {
  44683. if (source === 'UndoRedo.undo' || source === 'UndoRedo.redo' || source === 'auto') {
  44684. return;
  44685. }
  44686. var originalData = plugin.instance.getSourceDataArray();
  44687. index = (originalData.length + index) % originalData.length;
  44688. var removedData = (0, _object.deepClone)(originalData.slice(index, index + amount));
  44689. plugin.done(new UndoRedo.RemoveRowAction(index, removedData));
  44690. });
  44691. instance.addHook('afterCreateCol', function (index, amount, source) {
  44692. if (source === 'UndoRedo.undo' || source === 'UndoRedo.redo' || source === 'auto') {
  44693. return;
  44694. }
  44695. plugin.done(new UndoRedo.CreateColumnAction(index, amount));
  44696. });
  44697. instance.addHook('beforeRemoveCol', function (index, amount, logicColumns, source) {
  44698. if (source === 'UndoRedo.undo' || source === 'UndoRedo.redo' || source === 'auto') {
  44699. return;
  44700. }
  44701. var originalData = plugin.instance.getSourceDataArray();
  44702. index = (plugin.instance.countCols() + index) % plugin.instance.countCols();
  44703. var removedData = [];
  44704. var headers = [];
  44705. var indexes = [];
  44706. (0, _number.rangeEach)(originalData.length - 1, function (i) {
  44707. var column = [];
  44708. var origRow = originalData[i];
  44709. (0, _number.rangeEach)(index, index + (amount - 1), function (j) {
  44710. column.push(origRow[instance.runHooks('modifyCol', j)]);
  44711. });
  44712. removedData.push(column);
  44713. });
  44714. (0, _number.rangeEach)(amount - 1, function (i) {
  44715. indexes.push(instance.runHooks('modifyCol', index + i));
  44716. });
  44717. if (Array.isArray(instance.getSettings().colHeaders)) {
  44718. (0, _number.rangeEach)(amount - 1, function (i) {
  44719. headers.push(instance.getSettings().colHeaders[instance.runHooks('modifyCol', index + i)] || null);
  44720. });
  44721. }
  44722. var manualColumnMovePlugin = plugin.instance.getPlugin('manualColumnMove');
  44723. var columnsMap = manualColumnMovePlugin.isEnabled() ? manualColumnMovePlugin.columnsMapper.__arrayMap : [];
  44724. var action = new UndoRedo.RemoveColumnAction(index, indexes, removedData, headers, columnsMap);
  44725. plugin.done(action);
  44726. });
  44727. instance.addHook('beforeCellAlignment', function (stateBefore, range, type, alignment) {
  44728. var action = new UndoRedo.CellAlignmentAction(stateBefore, range, type, alignment);
  44729. plugin.done(action);
  44730. });
  44731. instance.addHook('beforeFilter', function (conditionsStack) {
  44732. plugin.done(new UndoRedo.FiltersAction(conditionsStack));
  44733. });
  44734. instance.addHook('beforeRowMove', function (movedRows, target) {
  44735. if (movedRows === false) {
  44736. return;
  44737. }
  44738. plugin.done(new UndoRedo.RowMoveAction(movedRows, target));
  44739. });
  44740. instance.addHook('beforeMergeCells', function (cellRange, auto) {
  44741. if (auto) {
  44742. return;
  44743. }
  44744. plugin.done(new UndoRedo.MergeCellsAction(instance, cellRange));
  44745. });
  44746. instance.addHook('afterUnmergeCells', function (cellRange, auto) {
  44747. if (auto) {
  44748. return;
  44749. }
  44750. plugin.done(new UndoRedo.UnmergeCellsAction(instance, cellRange));
  44751. });
  44752. }
  44753. UndoRedo.prototype.done = function (action) {
  44754. if (!this.ignoreNewActions) {
  44755. this.doneActions.push(action);
  44756. this.undoneActions.length = 0;
  44757. }
  44758. };
  44759. /**
  44760. * Undo last edit.
  44761. *
  44762. * @function undo
  44763. * @memberof UndoRedo#
  44764. */
  44765. UndoRedo.prototype.undo = function () {
  44766. if (this.isUndoAvailable()) {
  44767. var action = this.doneActions.pop();
  44768. var actionClone = (0, _object.deepClone)(action);
  44769. var instance = this.instance;
  44770. var continueAction = instance.runHooks('beforeUndo', actionClone);
  44771. if (continueAction === false) {
  44772. return;
  44773. }
  44774. this.ignoreNewActions = true;
  44775. var that = this;
  44776. action.undo(this.instance, function () {
  44777. that.ignoreNewActions = false;
  44778. that.undoneActions.push(action);
  44779. });
  44780. instance.runHooks('afterUndo', actionClone);
  44781. }
  44782. };
  44783. /**
  44784. * Redo edit (used to reverse an undo).
  44785. *
  44786. * @function redo
  44787. * @memberof UndoRedo#
  44788. */
  44789. UndoRedo.prototype.redo = function () {
  44790. if (this.isRedoAvailable()) {
  44791. var action = this.undoneActions.pop();
  44792. var actionClone = (0, _object.deepClone)(action);
  44793. var instance = this.instance;
  44794. var continueAction = instance.runHooks('beforeRedo', actionClone);
  44795. if (continueAction === false) {
  44796. return;
  44797. }
  44798. this.ignoreNewActions = true;
  44799. var that = this;
  44800. action.redo(this.instance, function () {
  44801. that.ignoreNewActions = false;
  44802. that.doneActions.push(action);
  44803. });
  44804. instance.runHooks('afterRedo', actionClone);
  44805. }
  44806. };
  44807. /**
  44808. * Check if undo action is available.
  44809. *
  44810. * @function isUndoAvailable
  44811. * @memberof UndoRedo#
  44812. * @return {Boolean} Return `true` if undo can be performed, `false` otherwise
  44813. */
  44814. UndoRedo.prototype.isUndoAvailable = function () {
  44815. return this.doneActions.length > 0;
  44816. };
  44817. /**
  44818. * Check if redo action is available.
  44819. *
  44820. * @function isRedoAvailable
  44821. * @memberof UndoRedo#
  44822. * @return {Boolean} Return `true` if redo can be performed, `false` otherwise.
  44823. */
  44824. UndoRedo.prototype.isRedoAvailable = function () {
  44825. return this.undoneActions.length > 0;
  44826. };
  44827. /**
  44828. * Clears undo history.
  44829. *
  44830. * @function clear
  44831. * @memberof UndoRedo#
  44832. */
  44833. UndoRedo.prototype.clear = function () {
  44834. this.doneActions.length = 0;
  44835. this.undoneActions.length = 0;
  44836. };
  44837. UndoRedo.Action = function () {};
  44838. UndoRedo.Action.prototype.undo = function () {};
  44839. UndoRedo.Action.prototype.redo = function () {};
  44840. /**
  44841. * Change action.
  44842. */
  44843. UndoRedo.ChangeAction = function (changes) {
  44844. this.changes = changes;
  44845. this.actionType = 'change';
  44846. };
  44847. (0, _object.inherit)(UndoRedo.ChangeAction, UndoRedo.Action);
  44848. UndoRedo.ChangeAction.prototype.undo = function (instance, undoneCallback) {
  44849. var data = (0, _object.deepClone)(this.changes),
  44850. emptyRowsAtTheEnd = instance.countEmptyRows(true),
  44851. emptyColsAtTheEnd = instance.countEmptyCols(true);
  44852. for (var i = 0, len = data.length; i < len; i++) {
  44853. data[i].splice(3, 1);
  44854. }
  44855. instance.addHookOnce('afterChange', undoneCallback);
  44856. instance.setDataAtRowProp(data, null, null, 'UndoRedo.undo');
  44857. for (var _i = 0, _len = data.length; _i < _len; _i++) {
  44858. if (instance.getSettings().minSpareRows && data[_i][0] + 1 + instance.getSettings().minSpareRows === instance.countRows() && emptyRowsAtTheEnd === instance.getSettings().minSpareRows) {
  44859. instance.alter('remove_row', parseInt(data[_i][0] + 1, 10), instance.getSettings().minSpareRows);
  44860. instance.undoRedo.doneActions.pop();
  44861. }
  44862. if (instance.getSettings().minSpareCols && data[_i][1] + 1 + instance.getSettings().minSpareCols === instance.countCols() && emptyColsAtTheEnd === instance.getSettings().minSpareCols) {
  44863. instance.alter('remove_col', parseInt(data[_i][1] + 1, 10), instance.getSettings().minSpareCols);
  44864. instance.undoRedo.doneActions.pop();
  44865. }
  44866. }
  44867. };
  44868. UndoRedo.ChangeAction.prototype.redo = function (instance, onFinishCallback) {
  44869. var data = (0, _object.deepClone)(this.changes);
  44870. for (var i = 0, len = data.length; i < len; i++) {
  44871. data[i].splice(2, 1);
  44872. }
  44873. instance.addHookOnce('afterChange', onFinishCallback);
  44874. instance.setDataAtRowProp(data, null, null, 'UndoRedo.redo');
  44875. };
  44876. /**
  44877. * Create row action.
  44878. */
  44879. UndoRedo.CreateRowAction = function (index, amount) {
  44880. this.index = index;
  44881. this.amount = amount;
  44882. this.actionType = 'insert_row';
  44883. };
  44884. (0, _object.inherit)(UndoRedo.CreateRowAction, UndoRedo.Action);
  44885. UndoRedo.CreateRowAction.prototype.undo = function (instance, undoneCallback) {
  44886. var rowCount = instance.countRows(),
  44887. minSpareRows = instance.getSettings().minSpareRows;
  44888. if (this.index >= rowCount && this.index - minSpareRows < rowCount) {
  44889. this.index -= minSpareRows; // work around the situation where the needed row was removed due to an 'undo' of a made change
  44890. }
  44891. instance.addHookOnce('afterRemoveRow', undoneCallback);
  44892. instance.alter('remove_row', this.index, this.amount, 'UndoRedo.undo');
  44893. };
  44894. UndoRedo.CreateRowAction.prototype.redo = function (instance, redoneCallback) {
  44895. instance.addHookOnce('afterCreateRow', redoneCallback);
  44896. instance.alter('insert_row', this.index, this.amount, 'UndoRedo.redo');
  44897. };
  44898. /**
  44899. * Remove row action.
  44900. */
  44901. UndoRedo.RemoveRowAction = function (index, data) {
  44902. this.index = index;
  44903. this.data = data;
  44904. this.actionType = 'remove_row';
  44905. };
  44906. (0, _object.inherit)(UndoRedo.RemoveRowAction, UndoRedo.Action);
  44907. UndoRedo.RemoveRowAction.prototype.undo = function (instance, undoneCallback) {
  44908. instance.alter('insert_row', this.index, this.data.length, 'UndoRedo.undo');
  44909. instance.addHookOnce('afterRender', undoneCallback);
  44910. instance.populateFromArray(this.index, 0, this.data, void 0, void 0, 'UndoRedo.undo');
  44911. };
  44912. UndoRedo.RemoveRowAction.prototype.redo = function (instance, redoneCallback) {
  44913. instance.addHookOnce('afterRemoveRow', redoneCallback);
  44914. instance.alter('remove_row', this.index, this.data.length, 'UndoRedo.redo');
  44915. };
  44916. /**
  44917. * Create column action.
  44918. */
  44919. UndoRedo.CreateColumnAction = function (index, amount) {
  44920. this.index = index;
  44921. this.amount = amount;
  44922. this.actionType = 'insert_col';
  44923. };
  44924. (0, _object.inherit)(UndoRedo.CreateColumnAction, UndoRedo.Action);
  44925. UndoRedo.CreateColumnAction.prototype.undo = function (instance, undoneCallback) {
  44926. instance.addHookOnce('afterRemoveCol', undoneCallback);
  44927. instance.alter('remove_col', this.index, this.amount, 'UndoRedo.undo');
  44928. };
  44929. UndoRedo.CreateColumnAction.prototype.redo = function (instance, redoneCallback) {
  44930. instance.addHookOnce('afterCreateCol', redoneCallback);
  44931. instance.alter('insert_col', this.index, this.amount, 'UndoRedo.redo');
  44932. };
  44933. /**
  44934. * Remove column action.
  44935. */
  44936. UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPositions) {
  44937. this.index = index;
  44938. this.indexes = indexes;
  44939. this.data = data;
  44940. this.amount = this.data[0].length;
  44941. this.headers = headers;
  44942. this.columnPositions = columnPositions.slice(0);
  44943. this.actionType = 'remove_col';
  44944. };
  44945. (0, _object.inherit)(UndoRedo.RemoveColumnAction, UndoRedo.Action);
  44946. UndoRedo.RemoveColumnAction.prototype.undo = function (instance, undoneCallback) {
  44947. var _this = this;
  44948. var row = void 0;
  44949. var ascendingIndexes = this.indexes.slice(0).sort();
  44950. var sortByIndexes = function sortByIndexes(elem, j, arr) {
  44951. return arr[_this.indexes.indexOf(ascendingIndexes[j])];
  44952. };
  44953. var sortedData = [];
  44954. (0, _number.rangeEach)(this.data.length - 1, function (i) {
  44955. sortedData[i] = (0, _array.arrayMap)(_this.data[i], sortByIndexes);
  44956. });
  44957. var sortedHeaders = [];
  44958. sortedHeaders = (0, _array.arrayMap)(this.headers, sortByIndexes);
  44959. var changes = [];
  44960. // TODO: Temporary hook for undo/redo mess
  44961. instance.runHooks('beforeCreateCol', this.indexes[0], this.indexes.length, 'UndoRedo.undo');
  44962. (0, _number.rangeEach)(this.data.length - 1, function (i) {
  44963. row = instance.getSourceDataAtRow(i);
  44964. (0, _number.rangeEach)(ascendingIndexes.length - 1, function (j) {
  44965. row.splice(ascendingIndexes[j], 0, sortedData[i][j]);
  44966. changes.push([i, ascendingIndexes[j], null, sortedData[i][j]]);
  44967. });
  44968. });
  44969. // TODO: Temporary hook for undo/redo mess
  44970. if (instance.getPlugin('formulas')) {
  44971. instance.getPlugin('formulas').onAfterSetDataAtCell(changes);
  44972. }
  44973. if (typeof this.headers !== 'undefined') {
  44974. (0, _number.rangeEach)(sortedHeaders.length - 1, function (j) {
  44975. instance.getSettings().colHeaders.splice(ascendingIndexes[j], 0, sortedHeaders[j]);
  44976. });
  44977. }
  44978. if (instance.getPlugin('manualColumnMove')) {
  44979. instance.getPlugin('manualColumnMove').columnsMapper.__arrayMap = this.columnPositions;
  44980. }
  44981. instance.addHookOnce('afterRender', undoneCallback);
  44982. // TODO: Temporary hook for undo/redo mess
  44983. instance.runHooks('afterCreateCol', this.indexes[0], this.indexes.length, 'UndoRedo.undo');
  44984. if (instance.getPlugin('formulas')) {
  44985. instance.getPlugin('formulas').recalculateFull();
  44986. }
  44987. instance.render();
  44988. };
  44989. UndoRedo.RemoveColumnAction.prototype.redo = function (instance, redoneCallback) {
  44990. instance.addHookOnce('afterRemoveCol', redoneCallback);
  44991. instance.alter('remove_col', this.index, this.amount, 'UndoRedo.redo');
  44992. };
  44993. /**
  44994. * Cell alignment action.
  44995. */
  44996. UndoRedo.CellAlignmentAction = function (stateBefore, range, type, alignment) {
  44997. this.stateBefore = stateBefore;
  44998. this.range = range;
  44999. this.type = type;
  45000. this.alignment = alignment;
  45001. };
  45002. UndoRedo.CellAlignmentAction.prototype.undo = function (instance, undoneCallback) {
  45003. var _this2 = this;
  45004. (0, _array.arrayEach)(this.range, function (_ref) {
  45005. var from = _ref.from,
  45006. to = _ref.to;
  45007. for (var row = from.row; row <= to.row; row += 1) {
  45008. for (var col = from.col; col <= to.col; col += 1) {
  45009. instance.setCellMeta(row, col, 'className', _this2.stateBefore[row][col] || ' htLeft');
  45010. }
  45011. }
  45012. });
  45013. instance.addHookOnce('afterRender', undoneCallback);
  45014. instance.render();
  45015. };
  45016. UndoRedo.CellAlignmentAction.prototype.redo = function (instance, undoneCallback) {
  45017. (0, _utils.align)(this.range, this.type, this.alignment, function (row, col) {
  45018. return instance.getCellMeta(row, col);
  45019. }, function (row, col, key, value) {
  45020. return instance.setCellMeta(row, col, key, value);
  45021. });
  45022. instance.addHookOnce('afterRender', undoneCallback);
  45023. instance.render();
  45024. };
  45025. /**
  45026. * Filters action.
  45027. */
  45028. UndoRedo.FiltersAction = function (conditionsStack) {
  45029. this.conditionsStack = conditionsStack;
  45030. this.actionType = 'filter';
  45031. };
  45032. (0, _object.inherit)(UndoRedo.FiltersAction, UndoRedo.Action);
  45033. UndoRedo.FiltersAction.prototype.undo = function (instance, undoneCallback) {
  45034. var filters = instance.getPlugin('filters');
  45035. instance.addHookOnce('afterRender', undoneCallback);
  45036. filters.conditionCollection.importAllConditions(this.conditionsStack.slice(0, this.conditionsStack.length - 1));
  45037. filters.filter();
  45038. };
  45039. UndoRedo.FiltersAction.prototype.redo = function (instance, redoneCallback) {
  45040. var filters = instance.getPlugin('filters');
  45041. instance.addHookOnce('afterRender', redoneCallback);
  45042. filters.conditionCollection.importAllConditions(this.conditionsStack);
  45043. filters.filter();
  45044. };
  45045. /**
  45046. * Merge Cells action.
  45047. * @util
  45048. */
  45049. var MergeCellsAction = function (_UndoRedo$Action) {
  45050. _inherits(MergeCellsAction, _UndoRedo$Action);
  45051. function MergeCellsAction(instance, cellRange) {
  45052. _classCallCheck(this, MergeCellsAction);
  45053. var _this3 = _possibleConstructorReturn(this, (MergeCellsAction.__proto__ || Object.getPrototypeOf(MergeCellsAction)).call(this));
  45054. _this3.cellRange = cellRange;
  45055. _this3.rangeData = instance.getData(cellRange.from.row, cellRange.from.col, cellRange.to.row, cellRange.to.col);
  45056. return _this3;
  45057. }
  45058. _createClass(MergeCellsAction, [{
  45059. key: 'undo',
  45060. value: function undo(instance, undoneCallback) {
  45061. var mergeCellsPlugin = instance.getPlugin('mergeCells');
  45062. instance.addHookOnce('afterRender', undoneCallback);
  45063. mergeCellsPlugin.unmergeRange(this.cellRange, true);
  45064. instance.populateFromArray(this.cellRange.from.row, this.cellRange.from.col, this.rangeData, void 0, void 0, 'MergeCells');
  45065. }
  45066. }, {
  45067. key: 'redo',
  45068. value: function redo(instance, redoneCallback) {
  45069. var mergeCellsPlugin = instance.getPlugin('mergeCells');
  45070. instance.addHookOnce('afterRender', redoneCallback);
  45071. mergeCellsPlugin.mergeRange(this.cellRange);
  45072. }
  45073. }]);
  45074. return MergeCellsAction;
  45075. }(UndoRedo.Action);
  45076. UndoRedo.MergeCellsAction = MergeCellsAction;
  45077. /**
  45078. * Unmerge Cells action.
  45079. * @util
  45080. */
  45081. var UnmergeCellsAction = function (_UndoRedo$Action2) {
  45082. _inherits(UnmergeCellsAction, _UndoRedo$Action2);
  45083. function UnmergeCellsAction(instance, cellRange) {
  45084. _classCallCheck(this, UnmergeCellsAction);
  45085. var _this4 = _possibleConstructorReturn(this, (UnmergeCellsAction.__proto__ || Object.getPrototypeOf(UnmergeCellsAction)).call(this));
  45086. _this4.cellRange = cellRange;
  45087. return _this4;
  45088. }
  45089. _createClass(UnmergeCellsAction, [{
  45090. key: 'undo',
  45091. value: function undo(instance, undoneCallback) {
  45092. var mergeCellsPlugin = instance.getPlugin('mergeCells');
  45093. instance.addHookOnce('afterRender', undoneCallback);
  45094. mergeCellsPlugin.mergeRange(this.cellRange, true);
  45095. }
  45096. }, {
  45097. key: 'redo',
  45098. value: function redo(instance, redoneCallback) {
  45099. var mergeCellsPlugin = instance.getPlugin('mergeCells');
  45100. instance.addHookOnce('afterRender', redoneCallback);
  45101. mergeCellsPlugin.unmergeRange(this.cellRange, true);
  45102. instance.render();
  45103. }
  45104. }]);
  45105. return UnmergeCellsAction;
  45106. }(UndoRedo.Action);
  45107. UndoRedo.UnmergeCellsAction = UnmergeCellsAction;
  45108. /**
  45109. * ManualRowMove action.
  45110. * @TODO: removeRow undo should works on logical index
  45111. */
  45112. UndoRedo.RowMoveAction = function (movedRows, target) {
  45113. this.rows = movedRows.slice();
  45114. this.target = target;
  45115. };
  45116. (0, _object.inherit)(UndoRedo.RowMoveAction, UndoRedo.Action);
  45117. UndoRedo.RowMoveAction.prototype.undo = function (instance, undoneCallback) {
  45118. var manualRowMove = instance.getPlugin('manualRowMove');
  45119. instance.addHookOnce('afterRender', undoneCallback);
  45120. var mod = this.rows[0] < this.target ? -1 * this.rows.length : 0;
  45121. var newTarget = this.rows[0] > this.target ? this.rows[0] + this.rows.length : this.rows[0];
  45122. var newRows = [];
  45123. var rowsLen = this.rows.length + mod;
  45124. for (var i = mod; i < rowsLen; i += 1) {
  45125. newRows.push(this.target + i);
  45126. }
  45127. manualRowMove.moveRows(newRows.slice(), newTarget);
  45128. instance.render();
  45129. instance.selectCell(this.rows[0], 0, this.rows[this.rows.length - 1], instance.countCols() - 1, false, false);
  45130. };
  45131. UndoRedo.RowMoveAction.prototype.redo = function (instance, redoneCallback) {
  45132. var manualRowMove = instance.getPlugin('manualRowMove');
  45133. instance.addHookOnce('afterRender', redoneCallback);
  45134. manualRowMove.moveRows(this.rows.slice(), this.target);
  45135. instance.render();
  45136. var startSelection = this.rows[0] < this.target ? this.target - this.rows.length : this.target;
  45137. instance.selectCell(startSelection, 0, startSelection + this.rows.length - 1, instance.countCols() - 1, false, false);
  45138. };
  45139. function init() {
  45140. var instance = this;
  45141. var pluginEnabled = typeof instance.getSettings().undo == 'undefined' || instance.getSettings().undo;
  45142. if (pluginEnabled) {
  45143. if (!instance.undoRedo) {
  45144. /**
  45145. * Instance of Handsontable.UndoRedo Plugin {@link Handsontable.UndoRedo}
  45146. *
  45147. * @alias undoRedo
  45148. * @memberof! Handsontable.Core#
  45149. * @type {UndoRedo}
  45150. */
  45151. instance.undoRedo = new UndoRedo(instance);
  45152. exposeUndoRedoMethods(instance);
  45153. instance.addHook('beforeKeyDown', onBeforeKeyDown);
  45154. instance.addHook('afterChange', onAfterChange);
  45155. }
  45156. } else if (instance.undoRedo) {
  45157. delete instance.undoRedo;
  45158. removeExposedUndoRedoMethods(instance);
  45159. instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  45160. instance.removeHook('afterChange', onAfterChange);
  45161. }
  45162. }
  45163. function onBeforeKeyDown(event) {
  45164. var instance = this;
  45165. var ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  45166. if (ctrlDown) {
  45167. if (event.keyCode === 89 || event.shiftKey && event.keyCode === 90) {
  45168. // CTRL + Y or CTRL + SHIFT + Z
  45169. instance.undoRedo.redo();
  45170. (0, _event.stopImmediatePropagation)(event);
  45171. } else if (event.keyCode === 90) {
  45172. // CTRL + Z
  45173. instance.undoRedo.undo();
  45174. (0, _event.stopImmediatePropagation)(event);
  45175. }
  45176. }
  45177. }
  45178. function onAfterChange(changes, source) {
  45179. var instance = this;
  45180. if (source === 'loadData') {
  45181. return instance.undoRedo.clear();
  45182. }
  45183. }
  45184. function exposeUndoRedoMethods(instance) {
  45185. /**
  45186. * {@link UndoRedo#undo}
  45187. * @alias undo
  45188. * @memberof! Handsontable.Core#
  45189. */
  45190. instance.undo = function () {
  45191. return instance.undoRedo.undo();
  45192. };
  45193. /**
  45194. * {@link UndoRedo#redo}
  45195. * @alias redo
  45196. * @memberof! Handsontable.Core#
  45197. */
  45198. instance.redo = function () {
  45199. return instance.undoRedo.redo();
  45200. };
  45201. /**
  45202. * {@link UndoRedo#isUndoAvailable}
  45203. * @alias isUndoAvailable
  45204. * @memberof! Handsontable.Core#
  45205. */
  45206. instance.isUndoAvailable = function () {
  45207. return instance.undoRedo.isUndoAvailable();
  45208. };
  45209. /**
  45210. * {@link UndoRedo#isRedoAvailable}
  45211. * @alias isRedoAvailable
  45212. * @memberof! Handsontable.Core#
  45213. */
  45214. instance.isRedoAvailable = function () {
  45215. return instance.undoRedo.isRedoAvailable();
  45216. };
  45217. /**
  45218. * {@link UndoRedo#clear}
  45219. * @alias clearUndo
  45220. * @memberof! Handsontable.Core#
  45221. */
  45222. instance.clearUndo = function () {
  45223. return instance.undoRedo.clear();
  45224. };
  45225. }
  45226. function removeExposedUndoRedoMethods(instance) {
  45227. delete instance.undo;
  45228. delete instance.redo;
  45229. delete instance.isUndoAvailable;
  45230. delete instance.isRedoAvailable;
  45231. delete instance.clearUndo;
  45232. }
  45233. var hook = _pluginHooks2.default.getSingleton();
  45234. hook.add('afterInit', init);
  45235. hook.add('afterUpdateSettings', init);
  45236. hook.register('beforeUndo');
  45237. hook.register('afterUndo');
  45238. hook.register('beforeRedo');
  45239. hook.register('afterRedo');
  45240. exports.default = UndoRedo;
  45241. /***/ })
  45242. /******/ ])["default"];
  45243. });
  45244. //# sourceMappingURL=handsontable.js.map