bootstrap-table.js 233 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery')) :
  3. typeof define === 'function' && define.amd ? define(['jquery'], factory) :
  4. (global = global || self, global.BootstrapTable = factory(global.jQuery));
  5. }(this, function ($) { 'use strict';
  6. $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  7. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  8. var global = typeof window == 'object' && window && window.Math == Math ? window
  9. : typeof self == 'object' && self && self.Math == Math ? self
  10. // eslint-disable-next-line no-new-func
  11. : Function('return this')();
  12. var hasOwnProperty = {}.hasOwnProperty;
  13. var has = function (it, key) {
  14. return hasOwnProperty.call(it, key);
  15. };
  16. var fails = function (exec) {
  17. try {
  18. return !!exec();
  19. } catch (e) {
  20. return true;
  21. }
  22. };
  23. // Thank's IE8 for his funny defineProperty
  24. var descriptors = !fails(function () {
  25. return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
  26. });
  27. var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
  28. var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  29. // Nashorn ~ JDK8 bug
  30. var NASHORN_BUG = nativeGetOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);
  31. var f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  32. var descriptor = nativeGetOwnPropertyDescriptor(this, V);
  33. return !!descriptor && descriptor.enumerable;
  34. } : nativePropertyIsEnumerable;
  35. var objectPropertyIsEnumerable = {
  36. f: f
  37. };
  38. var createPropertyDescriptor = function (bitmap, value) {
  39. return {
  40. enumerable: !(bitmap & 1),
  41. configurable: !(bitmap & 2),
  42. writable: !(bitmap & 4),
  43. value: value
  44. };
  45. };
  46. var toString = {}.toString;
  47. var classofRaw = function (it) {
  48. return toString.call(it).slice(8, -1);
  49. };
  50. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  51. var split = ''.split;
  52. var indexedObject = fails(function () {
  53. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  54. // eslint-disable-next-line no-prototype-builtins
  55. return !Object('z').propertyIsEnumerable(0);
  56. }) ? function (it) {
  57. return classofRaw(it) == 'String' ? split.call(it, '') : Object(it);
  58. } : Object;
  59. // `RequireObjectCoercible` abstract operation
  60. // https://tc39.github.io/ecma262/#sec-requireobjectcoercible
  61. var requireObjectCoercible = function (it) {
  62. if (it == undefined) throw TypeError("Can't call method on " + it);
  63. return it;
  64. };
  65. // toObject with fallback for non-array-like ES3 strings
  66. var toIndexedObject = function (it) {
  67. return indexedObject(requireObjectCoercible(it));
  68. };
  69. var isObject = function (it) {
  70. return typeof it === 'object' ? it !== null : typeof it === 'function';
  71. };
  72. // 7.1.1 ToPrimitive(input [, PreferredType])
  73. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  74. // and the second argument - flag - preferred type is a string
  75. var toPrimitive = function (it, S) {
  76. if (!isObject(it)) return it;
  77. var fn, val;
  78. if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  79. if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
  80. if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  81. throw TypeError("Can't convert object to primitive value");
  82. };
  83. var document$1 = global.document;
  84. // typeof document.createElement is 'object' in old IE
  85. var exist = isObject(document$1) && isObject(document$1.createElement);
  86. var documentCreateElement = function (it) {
  87. return exist ? document$1.createElement(it) : {};
  88. };
  89. // Thank's IE8 for his funny defineProperty
  90. var ie8DomDefine = !descriptors && !fails(function () {
  91. return Object.defineProperty(documentCreateElement('div'), 'a', {
  92. get: function () { return 7; }
  93. }).a != 7;
  94. });
  95. var nativeGetOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
  96. var f$1 = descriptors ? nativeGetOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) {
  97. O = toIndexedObject(O);
  98. P = toPrimitive(P, true);
  99. if (ie8DomDefine) try {
  100. return nativeGetOwnPropertyDescriptor$1(O, P);
  101. } catch (e) { /* empty */ }
  102. if (has(O, P)) return createPropertyDescriptor(!objectPropertyIsEnumerable.f.call(O, P), O[P]);
  103. };
  104. var objectGetOwnPropertyDescriptor = {
  105. f: f$1
  106. };
  107. var anObject = function (it) {
  108. if (!isObject(it)) {
  109. throw TypeError(String(it) + ' is not an object');
  110. } return it;
  111. };
  112. var nativeDefineProperty = Object.defineProperty;
  113. var f$2 = descriptors ? nativeDefineProperty : function defineProperty(O, P, Attributes) {
  114. anObject(O);
  115. P = toPrimitive(P, true);
  116. anObject(Attributes);
  117. if (ie8DomDefine) try {
  118. return nativeDefineProperty(O, P, Attributes);
  119. } catch (e) { /* empty */ }
  120. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
  121. if ('value' in Attributes) O[P] = Attributes.value;
  122. return O;
  123. };
  124. var objectDefineProperty = {
  125. f: f$2
  126. };
  127. var hide = descriptors ? function (object, key, value) {
  128. return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value));
  129. } : function (object, key, value) {
  130. object[key] = value;
  131. return object;
  132. };
  133. function createCommonjsModule(fn, module) {
  134. return module = { exports: {} }, fn(module, module.exports), module.exports;
  135. }
  136. var setGlobal = function (key, value) {
  137. try {
  138. hide(global, key, value);
  139. } catch (e) {
  140. global[key] = value;
  141. } return value;
  142. };
  143. var shared = createCommonjsModule(function (module) {
  144. var SHARED = '__core-js_shared__';
  145. var store = global[SHARED] || setGlobal(SHARED, {});
  146. (module.exports = function (key, value) {
  147. return store[key] || (store[key] = value !== undefined ? value : {});
  148. })('versions', []).push({
  149. version: '3.0.0',
  150. mode: 'global',
  151. copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
  152. });
  153. });
  154. var functionToString = shared('native-function-to-string', Function.toString);
  155. var WeakMap = global.WeakMap;
  156. var nativeWeakMap = typeof WeakMap === 'function' && /native code/.test(functionToString.call(WeakMap));
  157. var id = 0;
  158. var postfix = Math.random();
  159. var uid = function (key) {
  160. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + postfix).toString(36));
  161. };
  162. var shared$1 = shared('keys');
  163. var sharedKey = function (key) {
  164. return shared$1[key] || (shared$1[key] = uid(key));
  165. };
  166. var hiddenKeys = {};
  167. var WeakMap$1 = global.WeakMap;
  168. var set, get, has$1;
  169. var enforce = function (it) {
  170. return has$1(it) ? get(it) : set(it, {});
  171. };
  172. var getterFor = function (TYPE) {
  173. return function (it) {
  174. var state;
  175. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  176. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  177. } return state;
  178. };
  179. };
  180. if (nativeWeakMap) {
  181. var store = new WeakMap$1();
  182. var wmget = store.get;
  183. var wmhas = store.has;
  184. var wmset = store.set;
  185. set = function (it, metadata) {
  186. wmset.call(store, it, metadata);
  187. return metadata;
  188. };
  189. get = function (it) {
  190. return wmget.call(store, it) || {};
  191. };
  192. has$1 = function (it) {
  193. return wmhas.call(store, it);
  194. };
  195. } else {
  196. var STATE = sharedKey('state');
  197. hiddenKeys[STATE] = true;
  198. set = function (it, metadata) {
  199. hide(it, STATE, metadata);
  200. return metadata;
  201. };
  202. get = function (it) {
  203. return has(it, STATE) ? it[STATE] : {};
  204. };
  205. has$1 = function (it) {
  206. return has(it, STATE);
  207. };
  208. }
  209. var internalState = {
  210. set: set,
  211. get: get,
  212. has: has$1,
  213. enforce: enforce,
  214. getterFor: getterFor
  215. };
  216. var redefine = createCommonjsModule(function (module) {
  217. var getInternalState = internalState.get;
  218. var enforceInternalState = internalState.enforce;
  219. var TEMPLATE = String(functionToString).split('toString');
  220. shared('inspectSource', function (it) {
  221. return functionToString.call(it);
  222. });
  223. (module.exports = function (O, key, value, options) {
  224. var unsafe = options ? !!options.unsafe : false;
  225. var simple = options ? !!options.enumerable : false;
  226. var noTargetGet = options ? !!options.noTargetGet : false;
  227. if (typeof value == 'function') {
  228. if (typeof key == 'string' && !has(value, 'name')) hide(value, 'name', key);
  229. enforceInternalState(value).source = TEMPLATE.join(typeof key == 'string' ? key : '');
  230. }
  231. if (O === global) {
  232. if (simple) O[key] = value;
  233. else setGlobal(key, value);
  234. return;
  235. } else if (!unsafe) {
  236. delete O[key];
  237. } else if (!noTargetGet && O[key]) {
  238. simple = true;
  239. }
  240. if (simple) O[key] = value;
  241. else hide(O, key, value);
  242. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  243. })(Function.prototype, 'toString', function toString() {
  244. return typeof this == 'function' && getInternalState(this).source || functionToString.call(this);
  245. });
  246. });
  247. var ceil = Math.ceil;
  248. var floor = Math.floor;
  249. // `ToInteger` abstract operation
  250. // https://tc39.github.io/ecma262/#sec-tointeger
  251. var toInteger = function (argument) {
  252. return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);
  253. };
  254. var min = Math.min;
  255. // `ToLength` abstract operation
  256. // https://tc39.github.io/ecma262/#sec-tolength
  257. var toLength = function (argument) {
  258. return argument > 0 ? min(toInteger(argument), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
  259. };
  260. var max = Math.max;
  261. var min$1 = Math.min;
  262. // Helper for a popular repeating case of the spec:
  263. // Let integer be ? ToInteger(index).
  264. // If integer < 0, let result be max((length + integer), 0); else let result be min(length, length).
  265. var toAbsoluteIndex = function (index, length) {
  266. var integer = toInteger(index);
  267. return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
  268. };
  269. // `Array.prototype.{ indexOf, includes }` methods implementation
  270. // false -> Array#indexOf
  271. // https://tc39.github.io/ecma262/#sec-array.prototype.indexof
  272. // true -> Array#includes
  273. // https://tc39.github.io/ecma262/#sec-array.prototype.includes
  274. var arrayIncludes = function (IS_INCLUDES) {
  275. return function ($this, el, fromIndex) {
  276. var O = toIndexedObject($this);
  277. var length = toLength(O.length);
  278. var index = toAbsoluteIndex(fromIndex, length);
  279. var value;
  280. // Array#includes uses SameValueZero equality algorithm
  281. // eslint-disable-next-line no-self-compare
  282. if (IS_INCLUDES && el != el) while (length > index) {
  283. value = O[index++];
  284. // eslint-disable-next-line no-self-compare
  285. if (value != value) return true;
  286. // Array#indexOf ignores holes, Array#includes - not
  287. } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
  288. if (O[index] === el) return IS_INCLUDES || index || 0;
  289. } return !IS_INCLUDES && -1;
  290. };
  291. };
  292. var arrayIndexOf = arrayIncludes(false);
  293. var objectKeysInternal = function (object, names) {
  294. var O = toIndexedObject(object);
  295. var i = 0;
  296. var result = [];
  297. var key;
  298. for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key);
  299. // Don't enum bug & hidden keys
  300. while (names.length > i) if (has(O, key = names[i++])) {
  301. ~arrayIndexOf(result, key) || result.push(key);
  302. }
  303. return result;
  304. };
  305. // IE8- don't enum bug keys
  306. var enumBugKeys = [
  307. 'constructor',
  308. 'hasOwnProperty',
  309. 'isPrototypeOf',
  310. 'propertyIsEnumerable',
  311. 'toLocaleString',
  312. 'toString',
  313. 'valueOf'
  314. ];
  315. // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
  316. var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype');
  317. var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  318. return objectKeysInternal(O, hiddenKeys$1);
  319. };
  320. var objectGetOwnPropertyNames = {
  321. f: f$3
  322. };
  323. var f$4 = Object.getOwnPropertySymbols;
  324. var objectGetOwnPropertySymbols = {
  325. f: f$4
  326. };
  327. var Reflect = global.Reflect;
  328. // all object keys, includes non-enumerable and symbols
  329. var ownKeys = Reflect && Reflect.ownKeys || function ownKeys(it) {
  330. var keys = objectGetOwnPropertyNames.f(anObject(it));
  331. var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
  332. return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
  333. };
  334. var copyConstructorProperties = function (target, source) {
  335. var keys = ownKeys(source);
  336. var defineProperty = objectDefineProperty.f;
  337. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  338. for (var i = 0; i < keys.length; i++) {
  339. var key = keys[i];
  340. if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  341. }
  342. };
  343. var replacement = /#|\.prototype\./;
  344. var isForced = function (feature, detection) {
  345. var value = data[normalize(feature)];
  346. return value == POLYFILL ? true
  347. : value == NATIVE ? false
  348. : typeof detection == 'function' ? fails(detection)
  349. : !!detection;
  350. };
  351. var normalize = isForced.normalize = function (string) {
  352. return String(string).replace(replacement, '.').toLowerCase();
  353. };
  354. var data = isForced.data = {};
  355. var NATIVE = isForced.NATIVE = 'N';
  356. var POLYFILL = isForced.POLYFILL = 'P';
  357. var isForced_1 = isForced;
  358. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  359. /*
  360. options.target - name of the target object
  361. options.global - target is the global object
  362. options.stat - export as static methods of target
  363. options.proto - export as prototype methods of target
  364. options.real - real prototype method for the `pure` version
  365. options.forced - export even if the native feature is available
  366. options.bind - bind methods to the target, required for the `pure` version
  367. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  368. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  369. options.sham - add a flag to not completely full polyfills
  370. options.enumerable - export as enumerable property
  371. options.noTargetGet - prevent calling a getter on target
  372. */
  373. var _export = function (options, source) {
  374. var TARGET = options.target;
  375. var GLOBAL = options.global;
  376. var STATIC = options.stat;
  377. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  378. if (GLOBAL) {
  379. target = global;
  380. } else if (STATIC) {
  381. target = global[TARGET] || setGlobal(TARGET, {});
  382. } else {
  383. target = (global[TARGET] || {}).prototype;
  384. }
  385. if (target) for (key in source) {
  386. sourceProperty = source[key];
  387. if (options.noTargetGet) {
  388. descriptor = getOwnPropertyDescriptor(target, key);
  389. targetProperty = descriptor && descriptor.value;
  390. } else targetProperty = target[key];
  391. FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  392. // contained in target
  393. if (!FORCED && targetProperty !== undefined) {
  394. if (typeof sourceProperty === typeof targetProperty) continue;
  395. copyConstructorProperties(sourceProperty, targetProperty);
  396. }
  397. // add a flag to not completely full polyfills
  398. if (options.sham || (targetProperty && targetProperty.sham)) {
  399. hide(sourceProperty, 'sham', true);
  400. }
  401. // extend global
  402. redefine(target, key, sourceProperty, options);
  403. }
  404. };
  405. // Chrome 38 Symbol has incorrect toString conversion
  406. var nativeSymbol = !fails(function () {
  407. });
  408. var store$1 = shared('wks');
  409. var Symbol$1 = global.Symbol;
  410. var wellKnownSymbol = function (name) {
  411. return store$1[name] || (store$1[name] = nativeSymbol && Symbol$1[name]
  412. || (nativeSymbol ? Symbol$1 : uid)('Symbol.' + name));
  413. };
  414. var defineProperty = objectDefineProperty.f;
  415. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  416. var setToStringTag = function (it, TAG, STATIC) {
  417. if (it && !has(it = STATIC ? it : it.prototype, TO_STRING_TAG)) {
  418. defineProperty(it, TO_STRING_TAG, { configurable: true, value: TAG });
  419. }
  420. };
  421. var f$5 = wellKnownSymbol;
  422. var wrappedWellKnownSymbol = {
  423. f: f$5
  424. };
  425. var path = global;
  426. var defineProperty$1 = objectDefineProperty.f;
  427. var defineWellKnownSymbol = function (NAME) {
  428. var Symbol = path.Symbol || (path.Symbol = {});
  429. if (!has(Symbol, NAME)) defineProperty$1(Symbol, NAME, {
  430. value: wrappedWellKnownSymbol.f(NAME)
  431. });
  432. };
  433. // 19.1.2.14 / 15.2.3.14 Object.keys(O)
  434. var objectKeys = Object.keys || function keys(O) {
  435. return objectKeysInternal(O, enumBugKeys);
  436. };
  437. // all enumerable object keys, includes symbols
  438. var enumKeys = function (it) {
  439. var result = objectKeys(it);
  440. var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
  441. if (getOwnPropertySymbols) {
  442. var symbols = getOwnPropertySymbols(it);
  443. var propertyIsEnumerable = objectPropertyIsEnumerable.f;
  444. var i = 0;
  445. var key;
  446. while (symbols.length > i) if (propertyIsEnumerable.call(it, key = symbols[i++])) result.push(key);
  447. } return result;
  448. };
  449. // `IsArray` abstract operation
  450. // https://tc39.github.io/ecma262/#sec-isarray
  451. var isArray = Array.isArray || function isArray(arg) {
  452. return classofRaw(arg) == 'Array';
  453. };
  454. var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
  455. anObject(O);
  456. var keys = objectKeys(Properties);
  457. var length = keys.length;
  458. var i = 0;
  459. var key;
  460. while (length > i) objectDefineProperty.f(O, key = keys[i++], Properties[key]);
  461. return O;
  462. };
  463. var document$2 = global.document;
  464. var html = document$2 && document$2.documentElement;
  465. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  466. var IE_PROTO = sharedKey('IE_PROTO');
  467. var PROTOTYPE = 'prototype';
  468. var Empty = function () { /* empty */ };
  469. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  470. var createDict = function () {
  471. // Thrash, waste and sodomy: IE GC bug
  472. var iframe = documentCreateElement('iframe');
  473. var length = enumBugKeys.length;
  474. var lt = '<';
  475. var script = 'script';
  476. var gt = '>';
  477. var js = 'java' + script + ':';
  478. var iframeDocument;
  479. iframe.style.display = 'none';
  480. html.appendChild(iframe);
  481. iframe.src = String(js);
  482. iframeDocument = iframe.contentWindow.document;
  483. iframeDocument.open();
  484. iframeDocument.write(lt + script + gt + 'document.F=Object' + lt + '/' + script + gt);
  485. iframeDocument.close();
  486. createDict = iframeDocument.F;
  487. while (length--) delete createDict[PROTOTYPE][enumBugKeys[length]];
  488. return createDict();
  489. };
  490. var objectCreate = Object.create || function create(O, Properties) {
  491. var result;
  492. if (O !== null) {
  493. Empty[PROTOTYPE] = anObject(O);
  494. result = new Empty();
  495. Empty[PROTOTYPE] = null;
  496. // add "__proto__" for Object.getPrototypeOf polyfill
  497. result[IE_PROTO] = O;
  498. } else result = createDict();
  499. return Properties === undefined ? result : objectDefineProperties(result, Properties);
  500. };
  501. hiddenKeys[IE_PROTO] = true;
  502. // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
  503. var nativeGetOwnPropertyNames = objectGetOwnPropertyNames.f;
  504. var toString$1 = {}.toString;
  505. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
  506. ? Object.getOwnPropertyNames(window) : [];
  507. var getWindowNames = function (it) {
  508. try {
  509. return nativeGetOwnPropertyNames(it);
  510. } catch (e) {
  511. return windowNames.slice();
  512. }
  513. };
  514. var f$6 = function getOwnPropertyNames(it) {
  515. return windowNames && toString$1.call(it) == '[object Window]'
  516. ? getWindowNames(it)
  517. : nativeGetOwnPropertyNames(toIndexedObject(it));
  518. };
  519. var objectGetOwnPropertyNamesExternal = {
  520. f: f$6
  521. };
  522. // ECMAScript 6 symbols shim
  523. var HIDDEN = sharedKey('hidden');
  524. var SYMBOL = 'Symbol';
  525. var setInternalState = internalState.set;
  526. var getInternalState = internalState.getterFor(SYMBOL);
  527. var nativeGetOwnPropertyDescriptor$2 = objectGetOwnPropertyDescriptor.f;
  528. var nativeDefineProperty$1 = objectDefineProperty.f;
  529. var nativeGetOwnPropertyNames$1 = objectGetOwnPropertyNamesExternal.f;
  530. var $Symbol = global.Symbol;
  531. var JSON$1 = global.JSON;
  532. var nativeJSONStringify = JSON$1 && JSON$1.stringify;
  533. var PROTOTYPE$1 = 'prototype';
  534. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  535. var nativePropertyIsEnumerable$1 = objectPropertyIsEnumerable.f;
  536. var SymbolRegistry = shared('symbol-registry');
  537. var AllSymbols = shared('symbols');
  538. var ObjectPrototypeSymbols = shared('op-symbols');
  539. var WellKnownSymbolsStore = shared('wks');
  540. var ObjectPrototype = Object[PROTOTYPE$1];
  541. var QObject = global.QObject;
  542. // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
  543. var USE_SETTER = !QObject || !QObject[PROTOTYPE$1] || !QObject[PROTOTYPE$1].findChild;
  544. // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
  545. var setSymbolDescriptor = descriptors && fails(function () {
  546. return objectCreate(nativeDefineProperty$1({}, 'a', {
  547. get: function () { return nativeDefineProperty$1(this, 'a', { value: 7 }).a; }
  548. })).a != 7;
  549. }) ? function (it, key, D) {
  550. var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor$2(ObjectPrototype, key);
  551. if (ObjectPrototypeDescriptor) delete ObjectPrototype[key];
  552. nativeDefineProperty$1(it, key, D);
  553. if (ObjectPrototypeDescriptor && it !== ObjectPrototype) {
  554. nativeDefineProperty$1(ObjectPrototype, key, ObjectPrototypeDescriptor);
  555. }
  556. } : nativeDefineProperty$1;
  557. var wrap = function (tag, description) {
  558. var symbol = AllSymbols[tag] = objectCreate($Symbol[PROTOTYPE$1]);
  559. setInternalState(symbol, {
  560. type: SYMBOL,
  561. tag: tag,
  562. description: description
  563. });
  564. if (!descriptors) symbol.description = description;
  565. return symbol;
  566. };
  567. var isSymbol = nativeSymbol && typeof $Symbol.iterator == 'symbol' ? function (it) {
  568. return typeof it == 'symbol';
  569. } : function (it) {
  570. return Object(it) instanceof $Symbol;
  571. };
  572. var $defineProperty = function defineProperty(it, key, D) {
  573. if (it === ObjectPrototype) $defineProperty(ObjectPrototypeSymbols, key, D);
  574. anObject(it);
  575. key = toPrimitive(key, true);
  576. anObject(D);
  577. if (has(AllSymbols, key)) {
  578. if (!D.enumerable) {
  579. if (!has(it, HIDDEN)) nativeDefineProperty$1(it, HIDDEN, createPropertyDescriptor(1, {}));
  580. it[HIDDEN][key] = true;
  581. } else {
  582. if (has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false;
  583. D = objectCreate(D, { enumerable: createPropertyDescriptor(0, false) });
  584. } return setSymbolDescriptor(it, key, D);
  585. } return nativeDefineProperty$1(it, key, D);
  586. };
  587. var $defineProperties = function defineProperties(it, P) {
  588. anObject(it);
  589. var keys = enumKeys(P = toIndexedObject(P));
  590. var i = 0;
  591. var l = keys.length;
  592. var key;
  593. while (l > i) $defineProperty(it, key = keys[i++], P[key]);
  594. return it;
  595. };
  596. var $create = function create(it, P) {
  597. return P === undefined ? objectCreate(it) : $defineProperties(objectCreate(it), P);
  598. };
  599. var $propertyIsEnumerable = function propertyIsEnumerable(key) {
  600. var E = nativePropertyIsEnumerable$1.call(this, key = toPrimitive(key, true));
  601. if (this === ObjectPrototype && has(AllSymbols, key) && !has(ObjectPrototypeSymbols, key)) return false;
  602. return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
  603. };
  604. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {
  605. it = toIndexedObject(it);
  606. key = toPrimitive(key, true);
  607. if (it === ObjectPrototype && has(AllSymbols, key) && !has(ObjectPrototypeSymbols, key)) return;
  608. var D = nativeGetOwnPropertyDescriptor$2(it, key);
  609. if (D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true;
  610. return D;
  611. };
  612. var $getOwnPropertyNames = function getOwnPropertyNames(it) {
  613. var names = nativeGetOwnPropertyNames$1(toIndexedObject(it));
  614. var result = [];
  615. var i = 0;
  616. var key;
  617. while (names.length > i) {
  618. if (!has(AllSymbols, key = names[i++]) && !has(hiddenKeys, key)) result.push(key);
  619. } return result;
  620. };
  621. var $getOwnPropertySymbols = function getOwnPropertySymbols(it) {
  622. var IS_OP = it === ObjectPrototype;
  623. var names = nativeGetOwnPropertyNames$1(IS_OP ? ObjectPrototypeSymbols : toIndexedObject(it));
  624. var result = [];
  625. var i = 0;
  626. var key;
  627. while (names.length > i) {
  628. if (has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectPrototype, key) : true)) result.push(AllSymbols[key]);
  629. } return result;
  630. };
  631. // `Symbol` constructor
  632. // https://tc39.github.io/ecma262/#sec-symbol-constructor
  633. if (!nativeSymbol) {
  634. $Symbol = function Symbol() {
  635. if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor');
  636. var description = arguments[0] === undefined ? undefined : String(arguments[0]);
  637. var tag = uid(description);
  638. var setter = function (value) {
  639. if (this === ObjectPrototype) setter.call(ObjectPrototypeSymbols, value);
  640. if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
  641. setSymbolDescriptor(this, tag, createPropertyDescriptor(1, value));
  642. };
  643. if (descriptors && USE_SETTER) setSymbolDescriptor(ObjectPrototype, tag, { configurable: true, set: setter });
  644. return wrap(tag, description);
  645. };
  646. redefine($Symbol[PROTOTYPE$1], 'toString', function toString() {
  647. return getInternalState(this).tag;
  648. });
  649. objectPropertyIsEnumerable.f = $propertyIsEnumerable;
  650. objectDefineProperty.f = $defineProperty;
  651. objectGetOwnPropertyDescriptor.f = $getOwnPropertyDescriptor;
  652. objectGetOwnPropertyNames.f = objectGetOwnPropertyNamesExternal.f = $getOwnPropertyNames;
  653. objectGetOwnPropertySymbols.f = $getOwnPropertySymbols;
  654. if (descriptors) {
  655. // https://github.com/tc39/proposal-Symbol-description
  656. nativeDefineProperty$1($Symbol[PROTOTYPE$1], 'description', {
  657. configurable: true,
  658. get: function description() {
  659. return getInternalState(this).description;
  660. }
  661. });
  662. {
  663. redefine(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true });
  664. }
  665. }
  666. wrappedWellKnownSymbol.f = function (name) {
  667. return wrap(wellKnownSymbol(name), name);
  668. };
  669. }
  670. _export({ global: true, wrap: true, forced: !nativeSymbol, sham: !nativeSymbol }, { Symbol: $Symbol });
  671. for (var wellKnownSymbols = objectKeys(WellKnownSymbolsStore), k = 0; wellKnownSymbols.length > k;) {
  672. defineWellKnownSymbol(wellKnownSymbols[k++]);
  673. }
  674. _export({ target: SYMBOL, stat: true, forced: !nativeSymbol }, {
  675. // `Symbol.for` method
  676. // https://tc39.github.io/ecma262/#sec-symbol.for
  677. 'for': function (key) {
  678. return has(SymbolRegistry, key += '')
  679. ? SymbolRegistry[key]
  680. : SymbolRegistry[key] = $Symbol(key);
  681. },
  682. // `Symbol.keyFor` method
  683. // https://tc39.github.io/ecma262/#sec-symbol.keyfor
  684. keyFor: function keyFor(sym) {
  685. if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol');
  686. for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key;
  687. },
  688. useSetter: function () { USE_SETTER = true; },
  689. useSimple: function () { USE_SETTER = false; }
  690. });
  691. _export({ target: 'Object', stat: true, forced: !nativeSymbol, sham: !descriptors }, {
  692. // `Object.create` method
  693. // https://tc39.github.io/ecma262/#sec-object.create
  694. create: $create,
  695. // `Object.defineProperty` method
  696. // https://tc39.github.io/ecma262/#sec-object.defineproperty
  697. defineProperty: $defineProperty,
  698. // `Object.defineProperties` method
  699. // https://tc39.github.io/ecma262/#sec-object.defineproperties
  700. defineProperties: $defineProperties,
  701. // `Object.getOwnPropertyDescriptor` method
  702. // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptors
  703. getOwnPropertyDescriptor: $getOwnPropertyDescriptor
  704. });
  705. _export({ target: 'Object', stat: true, forced: !nativeSymbol }, {
  706. // `Object.getOwnPropertyNames` method
  707. // https://tc39.github.io/ecma262/#sec-object.getownpropertynames
  708. getOwnPropertyNames: $getOwnPropertyNames,
  709. // `Object.getOwnPropertySymbols` method
  710. // https://tc39.github.io/ecma262/#sec-object.getownpropertysymbols
  711. getOwnPropertySymbols: $getOwnPropertySymbols
  712. });
  713. // `JSON.stringify` method behavior with symbols
  714. // https://tc39.github.io/ecma262/#sec-json.stringify
  715. JSON$1 && _export({ target: 'JSON', stat: true, forced: !nativeSymbol || fails(function () {
  716. var symbol = $Symbol();
  717. // MS Edge converts symbol values to JSON as {}
  718. return nativeJSONStringify([symbol]) != '[null]'
  719. // WebKit converts symbol values to JSON as null
  720. || nativeJSONStringify({ a: symbol }) != '{}'
  721. // V8 throws on boxed symbols
  722. || nativeJSONStringify(Object(symbol)) != '{}';
  723. }) }, {
  724. stringify: function stringify(it) {
  725. var args = [it];
  726. var i = 1;
  727. var replacer, $replacer;
  728. while (arguments.length > i) args.push(arguments[i++]);
  729. $replacer = replacer = args[1];
  730. if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
  731. if (!isArray(replacer)) replacer = function (key, value) {
  732. if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
  733. if (!isSymbol(value)) return value;
  734. };
  735. args[1] = replacer;
  736. return nativeJSONStringify.apply(JSON$1, args);
  737. }
  738. });
  739. // `Symbol.prototype[@@toPrimitive]` method
  740. // https://tc39.github.io/ecma262/#sec-symbol.prototype-@@toprimitive
  741. if (!$Symbol[PROTOTYPE$1][TO_PRIMITIVE]) hide($Symbol[PROTOTYPE$1], TO_PRIMITIVE, $Symbol[PROTOTYPE$1].valueOf);
  742. // `Symbol.prototype[@@toStringTag]` property
  743. // https://tc39.github.io/ecma262/#sec-symbol.prototype-@@tostringtag
  744. setToStringTag($Symbol, SYMBOL);
  745. hiddenKeys[HIDDEN] = true;
  746. var defineProperty$2 = objectDefineProperty.f;
  747. var NativeSymbol = global.Symbol;
  748. if (descriptors && typeof NativeSymbol == 'function' && (!('description' in NativeSymbol.prototype) ||
  749. // Safari 12 bug
  750. NativeSymbol().description !== undefined
  751. )) {
  752. var EmptyStringDescriptionStore = {};
  753. // wrap Symbol constructor for correct work with undefined description
  754. var SymbolWrapper = function Symbol() {
  755. var description = arguments.length < 1 || arguments[0] === undefined ? undefined : String(arguments[0]);
  756. var result = this instanceof SymbolWrapper
  757. ? new NativeSymbol(description)
  758. // in Edge 13, String(Symbol(undefined)) === 'Symbol(undefined)'
  759. : description === undefined ? NativeSymbol() : NativeSymbol(description);
  760. if (description === '') EmptyStringDescriptionStore[result] = true;
  761. return result;
  762. };
  763. copyConstructorProperties(SymbolWrapper, NativeSymbol);
  764. var symbolPrototype = SymbolWrapper.prototype = NativeSymbol.prototype;
  765. symbolPrototype.constructor = SymbolWrapper;
  766. var symbolToString = symbolPrototype.toString;
  767. var native = String(NativeSymbol('test')) == 'Symbol(test)';
  768. var regexp = /^Symbol\((.*)\)[^)]+$/;
  769. defineProperty$2(symbolPrototype, 'description', {
  770. configurable: true,
  771. get: function description() {
  772. var symbol = isObject(this) ? this.valueOf() : this;
  773. var string = symbolToString.call(symbol);
  774. if (has(EmptyStringDescriptionStore, symbol)) return '';
  775. var desc = native ? string.slice(7, -1) : string.replace(regexp, '$1');
  776. return desc === '' ? undefined : desc;
  777. }
  778. });
  779. _export({ global: true, forced: true }, { Symbol: SymbolWrapper });
  780. }
  781. // `Symbol.iterator` well-known symbol
  782. // https://tc39.github.io/ecma262/#sec-symbol.iterator
  783. defineWellKnownSymbol('iterator');
  784. // `ToObject` abstract operation
  785. // https://tc39.github.io/ecma262/#sec-toobject
  786. var toObject = function (argument) {
  787. return Object(requireObjectCoercible(argument));
  788. };
  789. var createProperty = function (object, key, value) {
  790. var propertyKey = toPrimitive(key);
  791. if (propertyKey in object) objectDefineProperty.f(object, propertyKey, createPropertyDescriptor(0, value));
  792. else object[propertyKey] = value;
  793. };
  794. var SPECIES = wellKnownSymbol('species');
  795. // `ArraySpeciesCreate` abstract operation
  796. // https://tc39.github.io/ecma262/#sec-arrayspeciescreate
  797. var arraySpeciesCreate = function (originalArray, length) {
  798. var C;
  799. if (isArray(originalArray)) {
  800. C = originalArray.constructor;
  801. // cross-realm fallback
  802. if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
  803. else if (isObject(C)) {
  804. C = C[SPECIES];
  805. if (C === null) C = undefined;
  806. }
  807. } return new (C === undefined ? Array : C)(length === 0 ? 0 : length);
  808. };
  809. var SPECIES$1 = wellKnownSymbol('species');
  810. var arrayMethodHasSpeciesSupport = function (METHOD_NAME) {
  811. return !fails(function () {
  812. var array = [];
  813. var constructor = array.constructor = {};
  814. constructor[SPECIES$1] = function () {
  815. return { foo: 1 };
  816. };
  817. return array[METHOD_NAME](Boolean).foo !== 1;
  818. });
  819. };
  820. var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');
  821. var MAX_SAFE_INTEGER = 0x1fffffffffffff;
  822. var MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded';
  823. var IS_CONCAT_SPREADABLE_SUPPORT = !fails(function () {
  824. var array = [];
  825. array[IS_CONCAT_SPREADABLE] = false;
  826. return array.concat()[0] !== array;
  827. });
  828. var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat');
  829. var isConcatSpreadable = function (O) {
  830. if (!isObject(O)) return false;
  831. var spreadable = O[IS_CONCAT_SPREADABLE];
  832. return spreadable !== undefined ? !!spreadable : isArray(O);
  833. };
  834. var FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT;
  835. // `Array.prototype.concat` method
  836. // https://tc39.github.io/ecma262/#sec-array.prototype.concat
  837. // with adding support of @@isConcatSpreadable and @@species
  838. _export({ target: 'Array', proto: true, forced: FORCED }, {
  839. concat: function concat(arg) { // eslint-disable-line no-unused-vars
  840. var O = toObject(this);
  841. var A = arraySpeciesCreate(O, 0);
  842. var n = 0;
  843. var i, k, length, len, E;
  844. for (i = -1, length = arguments.length; i < length; i++) {
  845. E = i === -1 ? O : arguments[i];
  846. if (isConcatSpreadable(E)) {
  847. len = toLength(E.length);
  848. if (n + len > MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
  849. for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]);
  850. } else {
  851. if (n >= MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
  852. createProperty(A, n++, E);
  853. }
  854. }
  855. A.length = n;
  856. return A;
  857. }
  858. });
  859. var aFunction = function (it) {
  860. if (typeof it != 'function') {
  861. throw TypeError(String(it) + ' is not a function');
  862. } return it;
  863. };
  864. // optional / simple context binding
  865. var bindContext = function (fn, that, length) {
  866. aFunction(fn);
  867. if (that === undefined) return fn;
  868. switch (length) {
  869. case 0: return function () {
  870. return fn.call(that);
  871. };
  872. case 1: return function (a) {
  873. return fn.call(that, a);
  874. };
  875. case 2: return function (a, b) {
  876. return fn.call(that, a, b);
  877. };
  878. case 3: return function (a, b, c) {
  879. return fn.call(that, a, b, c);
  880. };
  881. }
  882. return function (/* ...args */) {
  883. return fn.apply(that, arguments);
  884. };
  885. };
  886. // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex }` methods implementation
  887. // 0 -> Array#forEach
  888. // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
  889. // 1 -> Array#map
  890. // https://tc39.github.io/ecma262/#sec-array.prototype.map
  891. // 2 -> Array#filter
  892. // https://tc39.github.io/ecma262/#sec-array.prototype.filter
  893. // 3 -> Array#some
  894. // https://tc39.github.io/ecma262/#sec-array.prototype.some
  895. // 4 -> Array#every
  896. // https://tc39.github.io/ecma262/#sec-array.prototype.every
  897. // 5 -> Array#find
  898. // https://tc39.github.io/ecma262/#sec-array.prototype.find
  899. // 6 -> Array#findIndex
  900. // https://tc39.github.io/ecma262/#sec-array.prototype.findIndex
  901. var arrayMethods = function (TYPE, specificCreate) {
  902. var IS_MAP = TYPE == 1;
  903. var IS_FILTER = TYPE == 2;
  904. var IS_SOME = TYPE == 3;
  905. var IS_EVERY = TYPE == 4;
  906. var IS_FIND_INDEX = TYPE == 6;
  907. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  908. var create = specificCreate || arraySpeciesCreate;
  909. return function ($this, callbackfn, that) {
  910. var O = toObject($this);
  911. var self = indexedObject(O);
  912. var boundFunction = bindContext(callbackfn, that, 3);
  913. var length = toLength(self.length);
  914. var index = 0;
  915. var target = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  916. var value, result;
  917. for (;length > index; index++) if (NO_HOLES || index in self) {
  918. value = self[index];
  919. result = boundFunction(value, index, O);
  920. if (TYPE) {
  921. if (IS_MAP) target[index] = result; // map
  922. else if (result) switch (TYPE) {
  923. case 3: return true; // some
  924. case 5: return value; // find
  925. case 6: return index; // findIndex
  926. case 2: target.push(value); // filter
  927. } else if (IS_EVERY) return false; // every
  928. }
  929. }
  930. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
  931. };
  932. };
  933. var internalFilter = arrayMethods(2);
  934. var SPECIES_SUPPORT$1 = arrayMethodHasSpeciesSupport('filter');
  935. // `Array.prototype.filter` method
  936. // https://tc39.github.io/ecma262/#sec-array.prototype.filter
  937. // with adding support of @@species
  938. _export({ target: 'Array', proto: true, forced: !SPECIES_SUPPORT$1 }, {
  939. filter: function filter(callbackfn /* , thisArg */) {
  940. return internalFilter(this, callbackfn, arguments[1]);
  941. }
  942. });
  943. var UNSCOPABLES = wellKnownSymbol('unscopables');
  944. var ArrayPrototype = Array.prototype;
  945. // Array.prototype[@@unscopables]
  946. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  947. if (ArrayPrototype[UNSCOPABLES] == undefined) {
  948. hide(ArrayPrototype, UNSCOPABLES, objectCreate(null));
  949. }
  950. // add a key to Array.prototype[@@unscopables]
  951. var addToUnscopables = function (key) {
  952. ArrayPrototype[UNSCOPABLES][key] = true;
  953. };
  954. var internalFind = arrayMethods(5);
  955. var FIND = 'find';
  956. var SKIPS_HOLES = true;
  957. // Shouldn't skip holes
  958. if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
  959. // `Array.prototype.find` method
  960. // https://tc39.github.io/ecma262/#sec-array.prototype.find
  961. _export({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
  962. find: function find(callbackfn /* , that = undefined */) {
  963. return internalFind(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  964. }
  965. });
  966. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  967. addToUnscopables(FIND);
  968. var internalFindIndex = arrayMethods(6);
  969. var FIND_INDEX = 'findIndex';
  970. var SKIPS_HOLES$1 = true;
  971. // Shouldn't skip holes
  972. if (FIND_INDEX in []) Array(1)[FIND_INDEX](function () { SKIPS_HOLES$1 = false; });
  973. // `Array.prototype.findIndex` method
  974. // https://tc39.github.io/ecma262/#sec-array.prototype.findindex
  975. _export({ target: 'Array', proto: true, forced: SKIPS_HOLES$1 }, {
  976. findIndex: function findIndex(callbackfn /* , that = undefined */) {
  977. return internalFindIndex(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  978. }
  979. });
  980. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  981. addToUnscopables(FIND_INDEX);
  982. var internalIncludes = arrayIncludes(true);
  983. // `Array.prototype.includes` method
  984. // https://tc39.github.io/ecma262/#sec-array.prototype.includes
  985. _export({ target: 'Array', proto: true }, {
  986. includes: function includes(el /* , fromIndex = 0 */) {
  987. return internalIncludes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  988. }
  989. });
  990. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  991. addToUnscopables('includes');
  992. var sloppyArrayMethod = function (METHOD_NAME, argument) {
  993. var method = [][METHOD_NAME];
  994. return !method || !fails(function () {
  995. // eslint-disable-next-line no-useless-call
  996. method.call(null, argument || function () { throw Error(); }, 1);
  997. });
  998. };
  999. var internalIndexOf = arrayIncludes(false);
  1000. var nativeIndexOf = [].indexOf;
  1001. var NEGATIVE_ZERO = !!nativeIndexOf && 1 / [1].indexOf(1, -0) < 0;
  1002. var SLOPPY_METHOD = sloppyArrayMethod('indexOf');
  1003. // `Array.prototype.indexOf` method
  1004. // https://tc39.github.io/ecma262/#sec-array.prototype.indexof
  1005. _export({ target: 'Array', proto: true, forced: NEGATIVE_ZERO || SLOPPY_METHOD }, {
  1006. indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {
  1007. return NEGATIVE_ZERO
  1008. // convert -0 to +0
  1009. ? nativeIndexOf.apply(this, arguments) || 0
  1010. : internalIndexOf(this, searchElement, arguments[1]);
  1011. }
  1012. });
  1013. var correctPrototypeGetter = !fails(function () {
  1014. function F() { /* empty */ }
  1015. F.prototype.constructor = null;
  1016. return Object.getPrototypeOf(new F()) !== F.prototype;
  1017. });
  1018. // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
  1019. var IE_PROTO$1 = sharedKey('IE_PROTO');
  1020. var ObjectPrototype$1 = Object.prototype;
  1021. var objectGetPrototypeOf = correctPrototypeGetter ? Object.getPrototypeOf : function (O) {
  1022. O = toObject(O);
  1023. if (has(O, IE_PROTO$1)) return O[IE_PROTO$1];
  1024. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  1025. return O.constructor.prototype;
  1026. } return O instanceof Object ? ObjectPrototype$1 : null;
  1027. };
  1028. var ITERATOR = wellKnownSymbol('iterator');
  1029. var BUGGY_SAFARI_ITERATORS = false;
  1030. var returnThis = function () { return this; };
  1031. // `%IteratorPrototype%` object
  1032. // https://tc39.github.io/ecma262/#sec-%iteratorprototype%-object
  1033. var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
  1034. if ([].keys) {
  1035. arrayIterator = [].keys();
  1036. // Safari 8 has buggy iterators w/o `next`
  1037. if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
  1038. else {
  1039. PrototypeOfArrayIteratorPrototype = objectGetPrototypeOf(objectGetPrototypeOf(arrayIterator));
  1040. if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
  1041. }
  1042. }
  1043. if (IteratorPrototype == undefined) IteratorPrototype = {};
  1044. // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
  1045. if (!has(IteratorPrototype, ITERATOR)) hide(IteratorPrototype, ITERATOR, returnThis);
  1046. var iteratorsCore = {
  1047. IteratorPrototype: IteratorPrototype,
  1048. BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
  1049. };
  1050. var IteratorPrototype$1 = iteratorsCore.IteratorPrototype;
  1051. var createIteratorConstructor = function (IteratorConstructor, NAME, next) {
  1052. var TO_STRING_TAG = NAME + ' Iterator';
  1053. IteratorConstructor.prototype = objectCreate(IteratorPrototype$1, { next: createPropertyDescriptor(1, next) });
  1054. setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);
  1055. return IteratorConstructor;
  1056. };
  1057. var validateSetPrototypeOfArguments = function (O, proto) {
  1058. anObject(O);
  1059. if (!isObject(proto) && proto !== null) {
  1060. throw TypeError("Can't set " + String(proto) + ' as a prototype');
  1061. }
  1062. };
  1063. // Works with __proto__ only. Old v8 can't work with null proto objects.
  1064. /* eslint-disable no-proto */
  1065. var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () { // eslint-disable-line
  1066. var correctSetter = false;
  1067. var test = {};
  1068. var setter;
  1069. try {
  1070. setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;
  1071. setter.call(test, []);
  1072. correctSetter = test instanceof Array;
  1073. } catch (e) { /* empty */ }
  1074. return function setPrototypeOf(O, proto) {
  1075. validateSetPrototypeOfArguments(O, proto);
  1076. if (correctSetter) setter.call(O, proto);
  1077. else O.__proto__ = proto;
  1078. return O;
  1079. };
  1080. }() : undefined);
  1081. var ITERATOR$1 = wellKnownSymbol('iterator');
  1082. var IteratorPrototype$2 = iteratorsCore.IteratorPrototype;
  1083. var BUGGY_SAFARI_ITERATORS$1 = iteratorsCore.BUGGY_SAFARI_ITERATORS;
  1084. var KEYS = 'keys';
  1085. var VALUES = 'values';
  1086. var ENTRIES = 'entries';
  1087. var returnThis$1 = function () { return this; };
  1088. var defineIterator = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
  1089. createIteratorConstructor(IteratorConstructor, NAME, next);
  1090. var getIterationMethod = function (KIND) {
  1091. if (KIND === DEFAULT && defaultIterator) return defaultIterator;
  1092. if (!BUGGY_SAFARI_ITERATORS$1 && KIND in IterablePrototype) return IterablePrototype[KIND];
  1093. switch (KIND) {
  1094. case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };
  1095. case VALUES: return function values() { return new IteratorConstructor(this, KIND); };
  1096. case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };
  1097. } return function () { return new IteratorConstructor(this); };
  1098. };
  1099. var TO_STRING_TAG = NAME + ' Iterator';
  1100. var INCORRECT_VALUES_NAME = false;
  1101. var IterablePrototype = Iterable.prototype;
  1102. var nativeIterator = IterablePrototype[ITERATOR$1]
  1103. || IterablePrototype['@@iterator']
  1104. || DEFAULT && IterablePrototype[DEFAULT];
  1105. var defaultIterator = !BUGGY_SAFARI_ITERATORS$1 && nativeIterator || getIterationMethod(DEFAULT);
  1106. var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
  1107. var CurrentIteratorPrototype, methods, KEY;
  1108. // fix native
  1109. if (anyNativeIterator) {
  1110. CurrentIteratorPrototype = objectGetPrototypeOf(anyNativeIterator.call(new Iterable()));
  1111. if (IteratorPrototype$2 !== Object.prototype && CurrentIteratorPrototype.next) {
  1112. if (objectGetPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype$2) {
  1113. if (objectSetPrototypeOf) {
  1114. objectSetPrototypeOf(CurrentIteratorPrototype, IteratorPrototype$2);
  1115. } else if (typeof CurrentIteratorPrototype[ITERATOR$1] != 'function') {
  1116. hide(CurrentIteratorPrototype, ITERATOR$1, returnThis$1);
  1117. }
  1118. }
  1119. // Set @@toStringTag to native iterators
  1120. setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);
  1121. }
  1122. }
  1123. // fix Array#{values, @@iterator}.name in V8 / FF
  1124. if (DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
  1125. INCORRECT_VALUES_NAME = true;
  1126. defaultIterator = function values() { return nativeIterator.call(this); };
  1127. }
  1128. // define iterator
  1129. if (IterablePrototype[ITERATOR$1] !== defaultIterator) {
  1130. hide(IterablePrototype, ITERATOR$1, defaultIterator);
  1131. }
  1132. // export additional methods
  1133. if (DEFAULT) {
  1134. methods = {
  1135. values: getIterationMethod(VALUES),
  1136. keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
  1137. entries: getIterationMethod(ENTRIES)
  1138. };
  1139. if (FORCED) for (KEY in methods) {
  1140. if (BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
  1141. redefine(IterablePrototype, KEY, methods[KEY]);
  1142. }
  1143. } else _export({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME }, methods);
  1144. }
  1145. return methods;
  1146. };
  1147. var ARRAY_ITERATOR = 'Array Iterator';
  1148. var setInternalState$1 = internalState.set;
  1149. var getInternalState$1 = internalState.getterFor(ARRAY_ITERATOR);
  1150. // `Array.prototype.entries` method
  1151. // https://tc39.github.io/ecma262/#sec-array.prototype.entries
  1152. // `Array.prototype.keys` method
  1153. // https://tc39.github.io/ecma262/#sec-array.prototype.keys
  1154. // `Array.prototype.values` method
  1155. // https://tc39.github.io/ecma262/#sec-array.prototype.values
  1156. // `Array.prototype[@@iterator]` method
  1157. // https://tc39.github.io/ecma262/#sec-array.prototype-@@iterator
  1158. // `CreateArrayIterator` internal method
  1159. // https://tc39.github.io/ecma262/#sec-createarrayiterator
  1160. var es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind) {
  1161. setInternalState$1(this, {
  1162. type: ARRAY_ITERATOR,
  1163. target: toIndexedObject(iterated), // target
  1164. index: 0, // next index
  1165. kind: kind // kind
  1166. });
  1167. // `%ArrayIteratorPrototype%.next` method
  1168. // https://tc39.github.io/ecma262/#sec-%arrayiteratorprototype%.next
  1169. }, function () {
  1170. var state = getInternalState$1(this);
  1171. var target = state.target;
  1172. var kind = state.kind;
  1173. var index = state.index++;
  1174. if (!target || index >= target.length) {
  1175. state.target = undefined;
  1176. return { value: undefined, done: true };
  1177. }
  1178. if (kind == 'keys') return { value: index, done: false };
  1179. if (kind == 'values') return { value: target[index], done: false };
  1180. return { value: [index, target[index]], done: false };
  1181. }, 'values');
  1182. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  1183. addToUnscopables('keys');
  1184. addToUnscopables('values');
  1185. addToUnscopables('entries');
  1186. var nativeJoin = [].join;
  1187. var ES3_STRINGS = indexedObject != Object;
  1188. var SLOPPY_METHOD$1 = sloppyArrayMethod('join', ',');
  1189. // `Array.prototype.join` method
  1190. // https://tc39.github.io/ecma262/#sec-array.prototype.join
  1191. _export({ target: 'Array', proto: true, forced: ES3_STRINGS || SLOPPY_METHOD$1 }, {
  1192. join: function join(separator) {
  1193. return nativeJoin.call(toIndexedObject(this), separator === undefined ? ',' : separator);
  1194. }
  1195. });
  1196. var SPECIES$2 = wellKnownSymbol('species');
  1197. var nativeSlice = [].slice;
  1198. var max$1 = Math.max;
  1199. var SPECIES_SUPPORT$2 = arrayMethodHasSpeciesSupport('slice');
  1200. // `Array.prototype.slice` method
  1201. // https://tc39.github.io/ecma262/#sec-array.prototype.slice
  1202. // fallback for not array-like ES3 strings and DOM objects
  1203. _export({ target: 'Array', proto: true, forced: !SPECIES_SUPPORT$2 }, {
  1204. slice: function slice(start, end) {
  1205. var O = toIndexedObject(this);
  1206. var length = toLength(O.length);
  1207. var k = toAbsoluteIndex(start, length);
  1208. var fin = toAbsoluteIndex(end === undefined ? length : end, length);
  1209. // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible
  1210. var Constructor, result, n;
  1211. if (isArray(O)) {
  1212. Constructor = O.constructor;
  1213. // cross-realm fallback
  1214. if (typeof Constructor == 'function' && (Constructor === Array || isArray(Constructor.prototype))) {
  1215. Constructor = undefined;
  1216. } else if (isObject(Constructor)) {
  1217. Constructor = Constructor[SPECIES$2];
  1218. if (Constructor === null) Constructor = undefined;
  1219. }
  1220. if (Constructor === Array || Constructor === undefined) {
  1221. return nativeSlice.call(O, k, fin);
  1222. }
  1223. }
  1224. result = new (Constructor === undefined ? Array : Constructor)(max$1(fin - k, 0));
  1225. for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);
  1226. result.length = n;
  1227. return result;
  1228. }
  1229. });
  1230. var nativeSort = [].sort;
  1231. var test = [1, 2, 3];
  1232. // IE8-
  1233. var FAILS_ON_UNDEFINED = fails(function () {
  1234. test.sort(undefined);
  1235. });
  1236. // V8 bug
  1237. var FAILS_ON_NULL = fails(function () {
  1238. test.sort(null);
  1239. });
  1240. // Old WebKit
  1241. var SLOPPY_METHOD$2 = sloppyArrayMethod('sort');
  1242. var FORCED$1 = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || SLOPPY_METHOD$2;
  1243. // `Array.prototype.sort` method
  1244. // https://tc39.github.io/ecma262/#sec-array.prototype.sort
  1245. _export({ target: 'Array', proto: true, forced: FORCED$1 }, {
  1246. sort: function sort(comparefn) {
  1247. return comparefn === undefined
  1248. ? nativeSort.call(toObject(this))
  1249. : nativeSort.call(toObject(this), aFunction(comparefn));
  1250. }
  1251. });
  1252. var max$2 = Math.max;
  1253. var min$2 = Math.min;
  1254. var MAX_SAFE_INTEGER$1 = 0x1fffffffffffff;
  1255. var MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded';
  1256. var SPECIES_SUPPORT$3 = arrayMethodHasSpeciesSupport('splice');
  1257. // `Array.prototype.splice` method
  1258. // https://tc39.github.io/ecma262/#sec-array.prototype.splice
  1259. // with adding support of @@species
  1260. _export({ target: 'Array', proto: true, forced: !SPECIES_SUPPORT$3 }, {
  1261. splice: function splice(start, deleteCount /* , ...items */) {
  1262. var O = toObject(this);
  1263. var len = toLength(O.length);
  1264. var actualStart = toAbsoluteIndex(start, len);
  1265. var argumentsLength = arguments.length;
  1266. var insertCount, actualDeleteCount, A, k, from, to;
  1267. if (argumentsLength === 0) {
  1268. insertCount = actualDeleteCount = 0;
  1269. } else if (argumentsLength === 1) {
  1270. insertCount = 0;
  1271. actualDeleteCount = len - actualStart;
  1272. } else {
  1273. insertCount = argumentsLength - 2;
  1274. actualDeleteCount = min$2(max$2(toInteger(deleteCount), 0), len - actualStart);
  1275. }
  1276. if (len + insertCount - actualDeleteCount > MAX_SAFE_INTEGER$1) {
  1277. throw TypeError(MAXIMUM_ALLOWED_LENGTH_EXCEEDED);
  1278. }
  1279. A = arraySpeciesCreate(O, actualDeleteCount);
  1280. for (k = 0; k < actualDeleteCount; k++) {
  1281. from = actualStart + k;
  1282. if (from in O) createProperty(A, k, O[from]);
  1283. }
  1284. A.length = actualDeleteCount;
  1285. if (insertCount < actualDeleteCount) {
  1286. for (k = actualStart; k < len - actualDeleteCount; k++) {
  1287. from = k + actualDeleteCount;
  1288. to = k + insertCount;
  1289. if (from in O) O[to] = O[from];
  1290. else delete O[to];
  1291. }
  1292. for (k = len; k > len - actualDeleteCount + insertCount; k--) delete O[k - 1];
  1293. } else if (insertCount > actualDeleteCount) {
  1294. for (k = len - actualDeleteCount; k > actualStart; k--) {
  1295. from = k + actualDeleteCount - 1;
  1296. to = k + insertCount - 1;
  1297. if (from in O) O[to] = O[from];
  1298. else delete O[to];
  1299. }
  1300. }
  1301. for (k = 0; k < insertCount; k++) {
  1302. O[k + actualStart] = arguments[k + 2];
  1303. }
  1304. O.length = len - actualDeleteCount + insertCount;
  1305. return A;
  1306. }
  1307. });
  1308. var inheritIfRequired = function (that, target, C) {
  1309. var S = target.constructor;
  1310. var P;
  1311. if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && objectSetPrototypeOf) {
  1312. objectSetPrototypeOf(that, P);
  1313. } return that;
  1314. };
  1315. // a string of all valid unicode whitespaces
  1316. // eslint-disable-next-line max-len
  1317. var whitespaces = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
  1318. var whitespace = '[' + whitespaces + ']';
  1319. var ltrim = RegExp('^' + whitespace + whitespace + '*');
  1320. var rtrim = RegExp(whitespace + whitespace + '*$');
  1321. // 1 -> String#trimStart
  1322. // 2 -> String#trimEnd
  1323. // 3 -> String#trim
  1324. var stringTrim = function (string, TYPE) {
  1325. string = String(requireObjectCoercible(string));
  1326. if (TYPE & 1) string = string.replace(ltrim, '');
  1327. if (TYPE & 2) string = string.replace(rtrim, '');
  1328. return string;
  1329. };
  1330. var getOwnPropertyNames = objectGetOwnPropertyNames.f;
  1331. var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
  1332. var defineProperty$3 = objectDefineProperty.f;
  1333. var NUMBER = 'Number';
  1334. var NativeNumber = global[NUMBER];
  1335. var NumberPrototype = NativeNumber.prototype;
  1336. // Opera ~12 has broken Object#toString
  1337. var BROKEN_CLASSOF = classofRaw(objectCreate(NumberPrototype)) == NUMBER;
  1338. var NATIVE_TRIM = 'trim' in String.prototype;
  1339. // `ToNumber` abstract operation
  1340. // https://tc39.github.io/ecma262/#sec-tonumber
  1341. var toNumber = function (argument) {
  1342. var it = toPrimitive(argument, false);
  1343. var first, third, radix, maxCode, digits, length, i, code;
  1344. if (typeof it == 'string' && it.length > 2) {
  1345. it = NATIVE_TRIM ? it.trim() : stringTrim(it, 3);
  1346. first = it.charCodeAt(0);
  1347. if (first === 43 || first === 45) {
  1348. third = it.charCodeAt(2);
  1349. if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix
  1350. } else if (first === 48) {
  1351. switch (it.charCodeAt(1)) {
  1352. case 66: case 98: radix = 2; maxCode = 49; break; // fast equal of /^0b[01]+$/i
  1353. case 79: case 111: radix = 8; maxCode = 55; break; // fast equal of /^0o[0-7]+$/i
  1354. default: return +it;
  1355. }
  1356. digits = it.slice(2);
  1357. length = digits.length;
  1358. for (i = 0; i < length; i++) {
  1359. code = digits.charCodeAt(i);
  1360. // parseInt parses a string to a first unavailable symbol
  1361. // but ToNumber should return NaN if a string contains unavailable symbols
  1362. if (code < 48 || code > maxCode) return NaN;
  1363. } return parseInt(digits, radix);
  1364. }
  1365. } return +it;
  1366. };
  1367. // `Number` constructor
  1368. // https://tc39.github.io/ecma262/#sec-number-constructor
  1369. if (isForced_1(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1'))) {
  1370. var NumberWrapper = function Number(value) {
  1371. var it = arguments.length < 1 ? 0 : value;
  1372. var that = this;
  1373. return that instanceof NumberWrapper
  1374. // check on 1..constructor(foo) case
  1375. && (BROKEN_CLASSOF ? fails(function () { NumberPrototype.valueOf.call(that); }) : classofRaw(that) != NUMBER)
  1376. ? inheritIfRequired(new NativeNumber(toNumber(it)), that, NumberWrapper) : toNumber(it);
  1377. };
  1378. for (var keys = descriptors ? getOwnPropertyNames(NativeNumber) : (
  1379. // ES3:
  1380. 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
  1381. // ES2015 (in case, if modules with ES2015 Number statics required before):
  1382. 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' +
  1383. 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger'
  1384. ).split(','), j = 0, key; keys.length > j; j++) {
  1385. if (has(NativeNumber, key = keys[j]) && !has(NumberWrapper, key)) {
  1386. defineProperty$3(NumberWrapper, key, getOwnPropertyDescriptor$1(NativeNumber, key));
  1387. }
  1388. }
  1389. NumberWrapper.prototype = NumberPrototype;
  1390. NumberPrototype.constructor = NumberWrapper;
  1391. redefine(global, NUMBER, NumberWrapper);
  1392. }
  1393. var nativeParseFloat = global.parseFloat;
  1394. var FORCED$2 = 1 / nativeParseFloat(whitespaces + '-0') !== -Infinity;
  1395. var _parseFloat = FORCED$2 ? function parseFloat(str) {
  1396. var string = stringTrim(String(str), 3);
  1397. var result = nativeParseFloat(string);
  1398. return result === 0 && string.charAt(0) == '-' ? -0 : result;
  1399. } : nativeParseFloat;
  1400. // `Number.parseFloat` method
  1401. // https://tc39.github.io/ecma262/#sec-number.parseFloat
  1402. _export({ target: 'Number', stat: true, forced: Number.parseFloat != _parseFloat }, {
  1403. parseFloat: _parseFloat
  1404. });
  1405. // 19.1.2.1 Object.assign(target, source, ...)
  1406. var nativeAssign = Object.assign;
  1407. // should work with symbols and should have deterministic property order (V8 bug)
  1408. var objectAssign = !nativeAssign || fails(function () {
  1409. var A = {};
  1410. var B = {};
  1411. // eslint-disable-next-line no-undef
  1412. var symbol = Symbol();
  1413. var alphabet = 'abcdefghijklmnopqrst';
  1414. A[symbol] = 7;
  1415. alphabet.split('').forEach(function (chr) { B[chr] = chr; });
  1416. return nativeAssign({}, A)[symbol] != 7 || objectKeys(nativeAssign({}, B)).join('') != alphabet;
  1417. }) ? function assign(target, source) { // eslint-disable-line no-unused-vars
  1418. var T = toObject(target);
  1419. var argumentsLength = arguments.length;
  1420. var index = 1;
  1421. var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
  1422. var propertyIsEnumerable = objectPropertyIsEnumerable.f;
  1423. while (argumentsLength > index) {
  1424. var S = indexedObject(arguments[index++]);
  1425. var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S);
  1426. var length = keys.length;
  1427. var j = 0;
  1428. var key;
  1429. while (length > j) if (propertyIsEnumerable.call(S, key = keys[j++])) T[key] = S[key];
  1430. } return T;
  1431. } : nativeAssign;
  1432. // `Object.assign` method
  1433. // https://tc39.github.io/ecma262/#sec-object.assign
  1434. _export({ target: 'Object', stat: true, forced: Object.assign !== objectAssign }, { assign: objectAssign });
  1435. var propertyIsEnumerable = objectPropertyIsEnumerable.f;
  1436. // TO_ENTRIES: true -> Object.entries
  1437. // TO_ENTRIES: false -> Object.values
  1438. var objectToArray = function (it, TO_ENTRIES) {
  1439. var O = toIndexedObject(it);
  1440. var keys = objectKeys(O);
  1441. var length = keys.length;
  1442. var i = 0;
  1443. var result = [];
  1444. var key;
  1445. while (length > i) if (propertyIsEnumerable.call(O, key = keys[i++])) {
  1446. result.push(TO_ENTRIES ? [key, O[key]] : O[key]);
  1447. } return result;
  1448. };
  1449. // `Object.entries` method
  1450. // https://tc39.github.io/ecma262/#sec-object.entries
  1451. _export({ target: 'Object', stat: true }, {
  1452. entries: function entries(O) {
  1453. return objectToArray(O, true);
  1454. }
  1455. });
  1456. var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag');
  1457. // ES3 wrong here
  1458. var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
  1459. // fallback for IE11 Script Access Denied error
  1460. var tryGet = function (it, key) {
  1461. try {
  1462. return it[key];
  1463. } catch (e) { /* empty */ }
  1464. };
  1465. // getting tag from ES6+ `Object.prototype.toString`
  1466. var classof = function (it) {
  1467. var O, tag, result;
  1468. return it === undefined ? 'Undefined' : it === null ? 'Null'
  1469. // @@toStringTag case
  1470. : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG$1)) == 'string' ? tag
  1471. // builtinTag case
  1472. : CORRECT_ARGUMENTS ? classofRaw(O)
  1473. // ES3 arguments fallback
  1474. : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;
  1475. };
  1476. var TO_STRING_TAG$2 = wellKnownSymbol('toStringTag');
  1477. var test$1 = {};
  1478. test$1[TO_STRING_TAG$2] = 'z';
  1479. // `Object.prototype.toString` method implementation
  1480. // https://tc39.github.io/ecma262/#sec-object.prototype.tostring
  1481. var objectToString = String(test$1) !== '[object z]' ? function toString() {
  1482. return '[object ' + classof(this) + ']';
  1483. } : test$1.toString;
  1484. var ObjectPrototype$2 = Object.prototype;
  1485. // `Object.prototype.toString` method
  1486. // https://tc39.github.io/ecma262/#sec-object.prototype.tostring
  1487. if (objectToString !== ObjectPrototype$2.toString) {
  1488. redefine(ObjectPrototype$2, 'toString', objectToString, { unsafe: true });
  1489. }
  1490. // `parseFloat` method
  1491. // https://tc39.github.io/ecma262/#sec-parsefloat-string
  1492. _export({ global: true, forced: parseFloat != _parseFloat }, {
  1493. parseFloat: _parseFloat
  1494. });
  1495. var nativeParseInt = global.parseInt;
  1496. var hex = /^[-+]?0[xX]/;
  1497. var FORCED$3 = nativeParseInt(whitespaces + '08') !== 8 || nativeParseInt(whitespaces + '0x16') !== 22;
  1498. var _parseInt = FORCED$3 ? function parseInt(str, radix) {
  1499. var string = stringTrim(String(str), 3);
  1500. return nativeParseInt(string, (radix >>> 0) || (hex.test(string) ? 16 : 10));
  1501. } : nativeParseInt;
  1502. // `parseInt` method
  1503. // https://tc39.github.io/ecma262/#sec-parseint-string-radix
  1504. _export({ global: true, forced: parseInt != _parseInt }, {
  1505. parseInt: _parseInt
  1506. });
  1507. // `RegExp.prototype.flags` getter implementation
  1508. // https://tc39.github.io/ecma262/#sec-get-regexp.prototype.flags
  1509. var regexpFlags = function () {
  1510. var that = anObject(this);
  1511. var result = '';
  1512. if (that.global) result += 'g';
  1513. if (that.ignoreCase) result += 'i';
  1514. if (that.multiline) result += 'm';
  1515. if (that.unicode) result += 'u';
  1516. if (that.sticky) result += 'y';
  1517. return result;
  1518. };
  1519. var TO_STRING = 'toString';
  1520. var nativeToString = /./[TO_STRING];
  1521. var NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) != '/a/b'; });
  1522. // FF44- RegExp#toString has a wrong name
  1523. var INCORRECT_NAME = nativeToString.name != TO_STRING;
  1524. // `RegExp.prototype.toString` method
  1525. // https://tc39.github.io/ecma262/#sec-regexp.prototype.tostring
  1526. if (NOT_GENERIC || INCORRECT_NAME) {
  1527. redefine(RegExp.prototype, TO_STRING, function toString() {
  1528. var R = anObject(this);
  1529. return '/'.concat(R.source, '/',
  1530. 'flags' in R ? R.flags : !descriptors && R instanceof RegExp ? regexpFlags.call(R) : undefined);
  1531. }, { unsafe: true });
  1532. }
  1533. var MATCH = wellKnownSymbol('match');
  1534. // `IsRegExp` abstract operation
  1535. // https://tc39.github.io/ecma262/#sec-isregexp
  1536. var isRegexp = function (it) {
  1537. var isRegExp;
  1538. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classofRaw(it) == 'RegExp');
  1539. };
  1540. // helper for String#{startsWith, endsWith, includes}
  1541. var validateStringMethodArguments = function (that, searchString, NAME) {
  1542. if (isRegexp(searchString)) {
  1543. throw TypeError('String.prototype.' + NAME + " doesn't accept regex");
  1544. } return String(requireObjectCoercible(that));
  1545. };
  1546. var MATCH$1 = wellKnownSymbol('match');
  1547. var correctIsRegexpLogic = function (METHOD_NAME) {
  1548. var regexp = /./;
  1549. try {
  1550. '/./'[METHOD_NAME](regexp);
  1551. } catch (e) {
  1552. try {
  1553. regexp[MATCH$1] = false;
  1554. return '/./'[METHOD_NAME](regexp);
  1555. } catch (f) { /* empty */ }
  1556. } return false;
  1557. };
  1558. var INCLUDES = 'includes';
  1559. var CORRECT_IS_REGEXP_LOGIC = correctIsRegexpLogic(INCLUDES);
  1560. // `String.prototype.includes` method
  1561. // https://tc39.github.io/ecma262/#sec-string.prototype.includes
  1562. _export({ target: 'String', proto: true, forced: !CORRECT_IS_REGEXP_LOGIC }, {
  1563. includes: function includes(searchString /* , position = 0 */) {
  1564. return !!~validateStringMethodArguments(this, searchString, INCLUDES)
  1565. .indexOf(searchString, arguments.length > 1 ? arguments[1] : undefined);
  1566. }
  1567. });
  1568. // CONVERT_TO_STRING: true -> String#at
  1569. // CONVERT_TO_STRING: false -> String#codePointAt
  1570. var stringAt = function (that, pos, CONVERT_TO_STRING) {
  1571. var S = String(requireObjectCoercible(that));
  1572. var position = toInteger(pos);
  1573. var size = S.length;
  1574. var first, second;
  1575. if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
  1576. first = S.charCodeAt(position);
  1577. return first < 0xd800 || first > 0xdbff || position + 1 === size
  1578. || (second = S.charCodeAt(position + 1)) < 0xdc00 || second > 0xdfff
  1579. ? CONVERT_TO_STRING ? S.charAt(position) : first
  1580. : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xd800 << 10) + (second - 0xdc00) + 0x10000;
  1581. };
  1582. var STRING_ITERATOR = 'String Iterator';
  1583. var setInternalState$2 = internalState.set;
  1584. var getInternalState$2 = internalState.getterFor(STRING_ITERATOR);
  1585. // `String.prototype[@@iterator]` method
  1586. // https://tc39.github.io/ecma262/#sec-string.prototype-@@iterator
  1587. defineIterator(String, 'String', function (iterated) {
  1588. setInternalState$2(this, {
  1589. type: STRING_ITERATOR,
  1590. string: String(iterated),
  1591. index: 0
  1592. });
  1593. // `%StringIteratorPrototype%.next` method
  1594. // https://tc39.github.io/ecma262/#sec-%stringiteratorprototype%.next
  1595. }, function next() {
  1596. var state = getInternalState$2(this);
  1597. var string = state.string;
  1598. var index = state.index;
  1599. var point;
  1600. if (index >= string.length) return { value: undefined, done: true };
  1601. point = stringAt(string, index, true);
  1602. state.index += point.length;
  1603. return { value: point, done: false };
  1604. });
  1605. // `AdvanceStringIndex` abstract operation
  1606. // https://tc39.github.io/ecma262/#sec-advancestringindex
  1607. var advanceStringIndex = function (S, index, unicode) {
  1608. return index + (unicode ? stringAt(S, index, true).length : 1);
  1609. };
  1610. var nativeExec = RegExp.prototype.exec;
  1611. // This always refers to the native implementation, because the
  1612. // String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js,
  1613. // which loads this file before patching the method.
  1614. var nativeReplace = String.prototype.replace;
  1615. var patchedExec = nativeExec;
  1616. var UPDATES_LAST_INDEX_WRONG = (function () {
  1617. var re1 = /a/;
  1618. var re2 = /b*/g;
  1619. nativeExec.call(re1, 'a');
  1620. nativeExec.call(re2, 'a');
  1621. return re1.lastIndex !== 0 || re2.lastIndex !== 0;
  1622. })();
  1623. // nonparticipating capturing group, copied from es5-shim's String#split patch.
  1624. var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
  1625. var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED;
  1626. if (PATCH) {
  1627. patchedExec = function exec(str) {
  1628. var re = this;
  1629. var lastIndex, reCopy, match, i;
  1630. if (NPCG_INCLUDED) {
  1631. reCopy = new RegExp('^' + re.source + '$(?!\\s)', regexpFlags.call(re));
  1632. }
  1633. if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;
  1634. match = nativeExec.call(re, str);
  1635. if (UPDATES_LAST_INDEX_WRONG && match) {
  1636. re.lastIndex = re.global ? match.index + match[0].length : lastIndex;
  1637. }
  1638. if (NPCG_INCLUDED && match && match.length > 1) {
  1639. // Fix browsers whose `exec` methods don't consistently return `undefined`
  1640. // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
  1641. nativeReplace.call(match[0], reCopy, function () {
  1642. for (i = 1; i < arguments.length - 2; i++) {
  1643. if (arguments[i] === undefined) match[i] = undefined;
  1644. }
  1645. });
  1646. }
  1647. return match;
  1648. };
  1649. }
  1650. var regexpExec = patchedExec;
  1651. // `RegExpExec` abstract operation
  1652. // https://tc39.github.io/ecma262/#sec-regexpexec
  1653. var regexpExecAbstract = function (R, S) {
  1654. var exec = R.exec;
  1655. if (typeof exec === 'function') {
  1656. var result = exec.call(R, S);
  1657. if (typeof result !== 'object') {
  1658. throw TypeError('RegExp exec method returned something other than an Object or null');
  1659. }
  1660. return result;
  1661. }
  1662. if (classofRaw(R) !== 'RegExp') {
  1663. throw TypeError('RegExp#exec called on incompatible receiver');
  1664. }
  1665. return regexpExec.call(R, S);
  1666. };
  1667. var SPECIES$3 = wellKnownSymbol('species');
  1668. var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
  1669. // #replace needs built-in support for named groups.
  1670. // #match works fine because it just return the exec results, even if it has
  1671. // a "grops" property.
  1672. var re = /./;
  1673. re.exec = function () {
  1674. var result = [];
  1675. result.groups = { a: '7' };
  1676. return result;
  1677. };
  1678. return ''.replace(re, '$<a>') !== '7';
  1679. });
  1680. // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
  1681. // Weex JS has frozen built-in prototypes, so use try / catch wrapper
  1682. var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {
  1683. var re = /(?:)/;
  1684. var originalExec = re.exec;
  1685. re.exec = function () { return originalExec.apply(this, arguments); };
  1686. var result = 'ab'.split(re);
  1687. return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
  1688. });
  1689. var fixRegexpWellKnownSymbolLogic = function (KEY, length, exec, sham) {
  1690. var SYMBOL = wellKnownSymbol(KEY);
  1691. var DELEGATES_TO_SYMBOL = !fails(function () {
  1692. // String methods call symbol-named RegEp methods
  1693. var O = {};
  1694. O[SYMBOL] = function () { return 7; };
  1695. return ''[KEY](O) != 7;
  1696. });
  1697. var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () {
  1698. // Symbol-named RegExp methods call .exec
  1699. var execCalled = false;
  1700. var re = /a/;
  1701. re.exec = function () { execCalled = true; return null; };
  1702. if (KEY === 'split') {
  1703. // RegExp[@@split] doesn't call the regex's exec method, but first creates
  1704. // a new one. We need to return the patched regex when creating the new one.
  1705. re.constructor = {};
  1706. re.constructor[SPECIES$3] = function () { return re; };
  1707. }
  1708. re[SYMBOL]('');
  1709. return !execCalled;
  1710. });
  1711. if (
  1712. !DELEGATES_TO_SYMBOL ||
  1713. !DELEGATES_TO_EXEC ||
  1714. (KEY === 'replace' && !REPLACE_SUPPORTS_NAMED_GROUPS) ||
  1715. (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC)
  1716. ) {
  1717. var nativeRegExpMethod = /./[SYMBOL];
  1718. var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
  1719. if (regexp.exec === regexpExec) {
  1720. if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
  1721. // The native String method already delegates to @@method (this
  1722. // polyfilled function), leasing to infinite recursion.
  1723. // We avoid it by directly calling the native @@method method.
  1724. return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };
  1725. }
  1726. return { done: true, value: nativeMethod.call(str, regexp, arg2) };
  1727. }
  1728. return { done: false };
  1729. });
  1730. var stringMethod = methods[0];
  1731. var regexMethod = methods[1];
  1732. redefine(String.prototype, KEY, stringMethod);
  1733. redefine(RegExp.prototype, SYMBOL, length == 2
  1734. // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
  1735. // 21.2.5.11 RegExp.prototype[@@split](string, limit)
  1736. ? function (string, arg) { return regexMethod.call(string, this, arg); }
  1737. // 21.2.5.6 RegExp.prototype[@@match](string)
  1738. // 21.2.5.9 RegExp.prototype[@@search](string)
  1739. : function (string) { return regexMethod.call(string, this); }
  1740. );
  1741. if (sham) hide(RegExp.prototype[SYMBOL], 'sham', true);
  1742. }
  1743. };
  1744. var max$3 = Math.max;
  1745. var min$3 = Math.min;
  1746. var floor$1 = Math.floor;
  1747. var SUBSTITUTION_SYMBOLS = /\$([$&`']|\d\d?|<[^>]*>)/g;
  1748. var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&`']|\d\d?)/g;
  1749. var maybeToString = function (it) {
  1750. return it === undefined ? it : String(it);
  1751. };
  1752. // @@replace logic
  1753. fixRegexpWellKnownSymbolLogic(
  1754. 'replace',
  1755. 2,
  1756. function (REPLACE, nativeReplace, maybeCallNative) {
  1757. return [
  1758. // `String.prototype.replace` method
  1759. // https://tc39.github.io/ecma262/#sec-string.prototype.replace
  1760. function replace(searchValue, replaceValue) {
  1761. var O = requireObjectCoercible(this);
  1762. var replacer = searchValue == undefined ? undefined : searchValue[REPLACE];
  1763. return replacer !== undefined
  1764. ? replacer.call(searchValue, O, replaceValue)
  1765. : nativeReplace.call(String(O), searchValue, replaceValue);
  1766. },
  1767. // `RegExp.prototype[@@replace]` method
  1768. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace
  1769. function (regexp, replaceValue) {
  1770. var res = maybeCallNative(nativeReplace, regexp, this, replaceValue);
  1771. if (res.done) return res.value;
  1772. var rx = anObject(regexp);
  1773. var S = String(this);
  1774. var functionalReplace = typeof replaceValue === 'function';
  1775. if (!functionalReplace) replaceValue = String(replaceValue);
  1776. var global = rx.global;
  1777. if (global) {
  1778. var fullUnicode = rx.unicode;
  1779. rx.lastIndex = 0;
  1780. }
  1781. var results = [];
  1782. while (true) {
  1783. var result = regexpExecAbstract(rx, S);
  1784. if (result === null) break;
  1785. results.push(result);
  1786. if (!global) break;
  1787. var matchStr = String(result[0]);
  1788. if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
  1789. }
  1790. var accumulatedResult = '';
  1791. var nextSourcePosition = 0;
  1792. for (var i = 0; i < results.length; i++) {
  1793. result = results[i];
  1794. var matched = String(result[0]);
  1795. var position = max$3(min$3(toInteger(result.index), S.length), 0);
  1796. var captures = [];
  1797. // NOTE: This is equivalent to
  1798. // captures = result.slice(1).map(maybeToString)
  1799. // but for some reason `nativeSlice.call(result, 1, result.length)` (called in
  1800. // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and
  1801. // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.
  1802. for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j]));
  1803. var namedCaptures = result.groups;
  1804. if (functionalReplace) {
  1805. var replacerArgs = [matched].concat(captures, position, S);
  1806. if (namedCaptures !== undefined) replacerArgs.push(namedCaptures);
  1807. var replacement = String(replaceValue.apply(undefined, replacerArgs));
  1808. } else {
  1809. replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
  1810. }
  1811. if (position >= nextSourcePosition) {
  1812. accumulatedResult += S.slice(nextSourcePosition, position) + replacement;
  1813. nextSourcePosition = position + matched.length;
  1814. }
  1815. }
  1816. return accumulatedResult + S.slice(nextSourcePosition);
  1817. }
  1818. ];
  1819. // https://tc39.github.io/ecma262/#sec-getsubstitution
  1820. function getSubstitution(matched, str, position, captures, namedCaptures, replacement) {
  1821. var tailPos = position + matched.length;
  1822. var m = captures.length;
  1823. var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
  1824. if (namedCaptures !== undefined) {
  1825. namedCaptures = toObject(namedCaptures);
  1826. symbols = SUBSTITUTION_SYMBOLS;
  1827. }
  1828. return nativeReplace.call(replacement, symbols, function (match, ch) {
  1829. var capture;
  1830. switch (ch.charAt(0)) {
  1831. case '$': return '$';
  1832. case '&': return matched;
  1833. case '`': return str.slice(0, position);
  1834. case "'": return str.slice(tailPos);
  1835. case '<':
  1836. capture = namedCaptures[ch.slice(1, -1)];
  1837. break;
  1838. default: // \d\d?
  1839. var n = +ch;
  1840. if (n === 0) return match;
  1841. if (n > m) {
  1842. var f = floor$1(n / 10);
  1843. if (f === 0) return match;
  1844. if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);
  1845. return match;
  1846. }
  1847. capture = captures[n - 1];
  1848. }
  1849. return capture === undefined ? '' : capture;
  1850. });
  1851. }
  1852. }
  1853. );
  1854. // `SameValue` abstract operation
  1855. // https://tc39.github.io/ecma262/#sec-samevalue
  1856. var sameValue = Object.is || function is(x, y) {
  1857. // eslint-disable-next-line no-self-compare
  1858. return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;
  1859. };
  1860. // @@search logic
  1861. fixRegexpWellKnownSymbolLogic(
  1862. 'search',
  1863. 1,
  1864. function (SEARCH, nativeSearch, maybeCallNative) {
  1865. return [
  1866. // `String.prototype.search` method
  1867. // https://tc39.github.io/ecma262/#sec-string.prototype.search
  1868. function search(regexp) {
  1869. var O = requireObjectCoercible(this);
  1870. var searcher = regexp == undefined ? undefined : regexp[SEARCH];
  1871. return searcher !== undefined ? searcher.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O));
  1872. },
  1873. // `RegExp.prototype[@@search]` method
  1874. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@search
  1875. function (regexp) {
  1876. var res = maybeCallNative(nativeSearch, regexp, this);
  1877. if (res.done) return res.value;
  1878. var rx = anObject(regexp);
  1879. var S = String(this);
  1880. var previousLastIndex = rx.lastIndex;
  1881. if (!sameValue(previousLastIndex, 0)) rx.lastIndex = 0;
  1882. var result = regexpExecAbstract(rx, S);
  1883. if (!sameValue(rx.lastIndex, previousLastIndex)) rx.lastIndex = previousLastIndex;
  1884. return result === null ? -1 : result.index;
  1885. }
  1886. ];
  1887. }
  1888. );
  1889. var SPECIES$4 = wellKnownSymbol('species');
  1890. // `SpeciesConstructor` abstract operation
  1891. // https://tc39.github.io/ecma262/#sec-speciesconstructor
  1892. var speciesConstructor = function (O, defaultConstructor) {
  1893. var C = anObject(O).constructor;
  1894. var S;
  1895. return C === undefined || (S = anObject(C)[SPECIES$4]) == undefined ? defaultConstructor : aFunction(S);
  1896. };
  1897. var arrayPush = [].push;
  1898. var min$4 = Math.min;
  1899. var MAX_UINT32 = 0xffffffff;
  1900. // babel-minify transpiles RegExp('x', 'y') -> /x/y and it causes SyntaxError
  1901. var SUPPORTS_Y = !fails(function () { return !RegExp(MAX_UINT32, 'y'); });
  1902. // @@split logic
  1903. fixRegexpWellKnownSymbolLogic(
  1904. 'split',
  1905. 2,
  1906. function (SPLIT, nativeSplit, maybeCallNative) {
  1907. var internalSplit;
  1908. if (
  1909. 'abbc'.split(/(b)*/)[1] == 'c' ||
  1910. 'test'.split(/(?:)/, -1).length != 4 ||
  1911. 'ab'.split(/(?:ab)*/).length != 2 ||
  1912. '.'.split(/(.?)(.?)/).length != 4 ||
  1913. '.'.split(/()()/).length > 1 ||
  1914. ''.split(/.?/).length
  1915. ) {
  1916. // based on es5-shim implementation, need to rework it
  1917. internalSplit = function (separator, limit) {
  1918. var string = String(requireObjectCoercible(this));
  1919. var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
  1920. if (lim === 0) return [];
  1921. if (separator === undefined) return [string];
  1922. // If `separator` is not a regex, use native split
  1923. if (!isRegexp(separator)) {
  1924. return nativeSplit.call(string, separator, lim);
  1925. }
  1926. var output = [];
  1927. var flags = (separator.ignoreCase ? 'i' : '') +
  1928. (separator.multiline ? 'm' : '') +
  1929. (separator.unicode ? 'u' : '') +
  1930. (separator.sticky ? 'y' : '');
  1931. var lastLastIndex = 0;
  1932. // Make `global` and avoid `lastIndex` issues by working with a copy
  1933. var separatorCopy = new RegExp(separator.source, flags + 'g');
  1934. var match, lastIndex, lastLength;
  1935. while (match = regexpExec.call(separatorCopy, string)) {
  1936. lastIndex = separatorCopy.lastIndex;
  1937. if (lastIndex > lastLastIndex) {
  1938. output.push(string.slice(lastLastIndex, match.index));
  1939. if (match.length > 1 && match.index < string.length) arrayPush.apply(output, match.slice(1));
  1940. lastLength = match[0].length;
  1941. lastLastIndex = lastIndex;
  1942. if (output.length >= lim) break;
  1943. }
  1944. if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++; // Avoid an infinite loop
  1945. }
  1946. if (lastLastIndex === string.length) {
  1947. if (lastLength || !separatorCopy.test('')) output.push('');
  1948. } else output.push(string.slice(lastLastIndex));
  1949. return output.length > lim ? output.slice(0, lim) : output;
  1950. };
  1951. // Chakra, V8
  1952. } else if ('0'.split(undefined, 0).length) {
  1953. internalSplit = function (separator, limit) {
  1954. return separator === undefined && limit === 0 ? [] : nativeSplit.call(this, separator, limit);
  1955. };
  1956. } else internalSplit = nativeSplit;
  1957. return [
  1958. // `String.prototype.split` method
  1959. // https://tc39.github.io/ecma262/#sec-string.prototype.split
  1960. function split(separator, limit) {
  1961. var O = requireObjectCoercible(this);
  1962. var splitter = separator == undefined ? undefined : separator[SPLIT];
  1963. return splitter !== undefined
  1964. ? splitter.call(separator, O, limit)
  1965. : internalSplit.call(String(O), separator, limit);
  1966. },
  1967. // `RegExp.prototype[@@split]` method
  1968. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@split
  1969. //
  1970. // NOTE: This cannot be properly polyfilled in engines that don't support
  1971. // the 'y' flag.
  1972. function (regexp, limit) {
  1973. var res = maybeCallNative(internalSplit, regexp, this, limit, internalSplit !== nativeSplit);
  1974. if (res.done) return res.value;
  1975. var rx = anObject(regexp);
  1976. var S = String(this);
  1977. var C = speciesConstructor(rx, RegExp);
  1978. var unicodeMatching = rx.unicode;
  1979. var flags = (rx.ignoreCase ? 'i' : '') +
  1980. (rx.multiline ? 'm' : '') +
  1981. (rx.unicode ? 'u' : '') +
  1982. (SUPPORTS_Y ? 'y' : 'g');
  1983. // ^(? + rx + ) is needed, in combination with some S slicing, to
  1984. // simulate the 'y' flag.
  1985. var splitter = new C(SUPPORTS_Y ? rx : '^(?:' + rx.source + ')', flags);
  1986. var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
  1987. if (lim === 0) return [];
  1988. if (S.length === 0) return regexpExecAbstract(splitter, S) === null ? [S] : [];
  1989. var p = 0;
  1990. var q = 0;
  1991. var A = [];
  1992. while (q < S.length) {
  1993. splitter.lastIndex = SUPPORTS_Y ? q : 0;
  1994. var z = regexpExecAbstract(splitter, SUPPORTS_Y ? S : S.slice(q));
  1995. var e;
  1996. if (
  1997. z === null ||
  1998. (e = min$4(toLength(splitter.lastIndex + (SUPPORTS_Y ? 0 : q)), S.length)) === p
  1999. ) {
  2000. q = advanceStringIndex(S, q, unicodeMatching);
  2001. } else {
  2002. A.push(S.slice(p, q));
  2003. if (A.length === lim) return A;
  2004. for (var i = 1; i <= z.length - 1; i++) {
  2005. A.push(z[i]);
  2006. if (A.length === lim) return A;
  2007. }
  2008. q = p = e;
  2009. }
  2010. }
  2011. A.push(S.slice(p));
  2012. return A;
  2013. }
  2014. ];
  2015. },
  2016. !SUPPORTS_Y
  2017. );
  2018. var non = '\u200b\u0085\u180e';
  2019. // check that a method works with the correct list
  2020. // of whitespaces and has a correct name
  2021. var forcedStringTrimMethod = function (METHOD_NAME) {
  2022. return fails(function () {
  2023. return !!whitespaces[METHOD_NAME]() || non[METHOD_NAME]() != non || whitespaces[METHOD_NAME].name !== METHOD_NAME;
  2024. });
  2025. };
  2026. var FORCED$4 = forcedStringTrimMethod('trim');
  2027. // `String.prototype.trim` method
  2028. // https://tc39.github.io/ecma262/#sec-string.prototype.trim
  2029. _export({ target: 'String', proto: true, forced: FORCED$4 }, {
  2030. trim: function trim() {
  2031. return stringTrim(this, 3);
  2032. }
  2033. });
  2034. // iterable DOM collections
  2035. // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
  2036. var domIterables = {
  2037. CSSRuleList: 0,
  2038. CSSStyleDeclaration: 0,
  2039. CSSValueList: 0,
  2040. ClientRectList: 0,
  2041. DOMRectList: 0,
  2042. DOMStringList: 0,
  2043. DOMTokenList: 1,
  2044. DataTransferItemList: 0,
  2045. FileList: 0,
  2046. HTMLAllCollection: 0,
  2047. HTMLCollection: 0,
  2048. HTMLFormElement: 0,
  2049. HTMLSelectElement: 0,
  2050. MediaList: 0,
  2051. MimeTypeArray: 0,
  2052. NamedNodeMap: 0,
  2053. NodeList: 1,
  2054. PaintRequestList: 0,
  2055. Plugin: 0,
  2056. PluginArray: 0,
  2057. SVGLengthList: 0,
  2058. SVGNumberList: 0,
  2059. SVGPathSegList: 0,
  2060. SVGPointList: 0,
  2061. SVGStringList: 0,
  2062. SVGTransformList: 0,
  2063. SourceBufferList: 0,
  2064. StyleSheetList: 0,
  2065. TextTrackCueList: 0,
  2066. TextTrackList: 0,
  2067. TouchList: 0
  2068. };
  2069. var nativeForEach = [].forEach;
  2070. var internalForEach = arrayMethods(0);
  2071. var SLOPPY_METHOD$3 = sloppyArrayMethod('forEach');
  2072. // `Array.prototype.forEach` method implementation
  2073. // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
  2074. var arrayForEach = SLOPPY_METHOD$3 ? function forEach(callbackfn /* , thisArg */) {
  2075. return internalForEach(this, callbackfn, arguments[1]);
  2076. } : nativeForEach;
  2077. for (var COLLECTION_NAME in domIterables) {
  2078. var Collection = global[COLLECTION_NAME];
  2079. var CollectionPrototype = Collection && Collection.prototype;
  2080. // some Chrome versions have non-configurable methods on DOMTokenList
  2081. if (CollectionPrototype && CollectionPrototype.forEach !== arrayForEach) try {
  2082. hide(CollectionPrototype, 'forEach', arrayForEach);
  2083. } catch (e) {
  2084. CollectionPrototype.forEach = arrayForEach;
  2085. }
  2086. }
  2087. var ITERATOR$2 = wellKnownSymbol('iterator');
  2088. var TO_STRING_TAG$3 = wellKnownSymbol('toStringTag');
  2089. var ArrayValues = es_array_iterator.values;
  2090. for (var COLLECTION_NAME$1 in domIterables) {
  2091. var Collection$1 = global[COLLECTION_NAME$1];
  2092. var CollectionPrototype$1 = Collection$1 && Collection$1.prototype;
  2093. if (CollectionPrototype$1) {
  2094. // some Chrome versions have non-configurable methods on DOMTokenList
  2095. if (CollectionPrototype$1[ITERATOR$2] !== ArrayValues) try {
  2096. hide(CollectionPrototype$1, ITERATOR$2, ArrayValues);
  2097. } catch (e) {
  2098. CollectionPrototype$1[ITERATOR$2] = ArrayValues;
  2099. }
  2100. if (!CollectionPrototype$1[TO_STRING_TAG$3]) hide(CollectionPrototype$1, TO_STRING_TAG$3, COLLECTION_NAME$1);
  2101. if (domIterables[COLLECTION_NAME$1]) for (var METHOD_NAME in es_array_iterator) {
  2102. // some Chrome versions have non-configurable methods on DOMTokenList
  2103. if (CollectionPrototype$1[METHOD_NAME] !== es_array_iterator[METHOD_NAME]) try {
  2104. hide(CollectionPrototype$1, METHOD_NAME, es_array_iterator[METHOD_NAME]);
  2105. } catch (e) {
  2106. CollectionPrototype$1[METHOD_NAME] = es_array_iterator[METHOD_NAME];
  2107. }
  2108. }
  2109. }
  2110. }
  2111. function _typeof(obj) {
  2112. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  2113. _typeof = function (obj) {
  2114. return typeof obj;
  2115. };
  2116. } else {
  2117. _typeof = function (obj) {
  2118. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  2119. };
  2120. }
  2121. return _typeof(obj);
  2122. }
  2123. function _classCallCheck(instance, Constructor) {
  2124. if (!(instance instanceof Constructor)) {
  2125. throw new TypeError("Cannot call a class as a function");
  2126. }
  2127. }
  2128. function _defineProperties(target, props) {
  2129. for (var i = 0; i < props.length; i++) {
  2130. var descriptor = props[i];
  2131. descriptor.enumerable = descriptor.enumerable || false;
  2132. descriptor.configurable = true;
  2133. if ("value" in descriptor) descriptor.writable = true;
  2134. Object.defineProperty(target, descriptor.key, descriptor);
  2135. }
  2136. }
  2137. function _createClass(Constructor, protoProps, staticProps) {
  2138. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  2139. if (staticProps) _defineProperties(Constructor, staticProps);
  2140. return Constructor;
  2141. }
  2142. function _slicedToArray(arr, i) {
  2143. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
  2144. }
  2145. function _toConsumableArray(arr) {
  2146. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
  2147. }
  2148. function _arrayWithoutHoles(arr) {
  2149. if (Array.isArray(arr)) {
  2150. for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
  2151. return arr2;
  2152. }
  2153. }
  2154. function _arrayWithHoles(arr) {
  2155. if (Array.isArray(arr)) return arr;
  2156. }
  2157. function _iterableToArray(iter) {
  2158. if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
  2159. }
  2160. function _iterableToArrayLimit(arr, i) {
  2161. var _arr = [];
  2162. var _n = true;
  2163. var _d = false;
  2164. var _e = undefined;
  2165. try {
  2166. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  2167. _arr.push(_s.value);
  2168. if (i && _arr.length === i) break;
  2169. }
  2170. } catch (err) {
  2171. _d = true;
  2172. _e = err;
  2173. } finally {
  2174. try {
  2175. if (!_n && _i["return"] != null) _i["return"]();
  2176. } finally {
  2177. if (_d) throw _e;
  2178. }
  2179. }
  2180. return _arr;
  2181. }
  2182. function _nonIterableSpread() {
  2183. throw new TypeError("Invalid attempt to spread non-iterable instance");
  2184. }
  2185. function _nonIterableRest() {
  2186. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  2187. }
  2188. var VERSION = '1.15.0';
  2189. var bootstrapVersion = 4;
  2190. try {
  2191. var rawVersion = $.fn.dropdown.Constructor.VERSION; // Only try to parse VERSION if it is defined.
  2192. // It is undefined in older versions of Bootstrap (tested with 3.1.1).
  2193. if (rawVersion !== undefined) {
  2194. bootstrapVersion = parseInt(rawVersion, 10);
  2195. }
  2196. } catch (e) {// ignore
  2197. }
  2198. var CONSTANTS = {
  2199. 3: {
  2200. iconsPrefix: 'glyphicon',
  2201. icons: {
  2202. paginationSwitchDown: 'glyphicon-collapse-down icon-chevron-down',
  2203. paginationSwitchUp: 'glyphicon-collapse-up icon-chevron-up',
  2204. refresh: 'glyphicon-refresh icon-refresh',
  2205. toggleOff: 'glyphicon-list-alt icon-list-alt',
  2206. toggleOn: 'glyphicon-list-alt icon-list-alt',
  2207. columns: 'glyphicon-th icon-th',
  2208. detailOpen: 'glyphicon-plus icon-plus',
  2209. detailClose: 'glyphicon-minus icon-minus',
  2210. fullscreen: 'glyphicon-fullscreen',
  2211. search: 'glyphicon-search',
  2212. clearSearch: 'glyphicon-trash'
  2213. },
  2214. classes: {
  2215. buttonsPrefix: 'btn',
  2216. buttons: 'default',
  2217. buttonsGroup: 'btn-group',
  2218. buttonsDropdown: 'btn-group',
  2219. pull: 'pull',
  2220. inputGroup: 'input-group',
  2221. input: 'form-control',
  2222. paginationDropdown: 'btn-group dropdown',
  2223. dropup: 'dropup',
  2224. dropdownActive: 'active',
  2225. paginationActive: 'active',
  2226. buttonActive: 'active'
  2227. },
  2228. html: {
  2229. toolbarDropdown: ['<ul class="dropdown-menu" role="menu">', '</ul>'],
  2230. toolbarDropdownItem: '<li role="menuitem"><label>%s</label></li>',
  2231. toolbarDropdownSeperator: '<li class="divider"></li>',
  2232. pageDropdown: ['<ul class="dropdown-menu" role="menu">', '</ul>'],
  2233. pageDropdownItem: '<li role="menuitem" class="%s"><a href="#">%s</a></li>',
  2234. dropdownCaret: '<span class="caret"></span>',
  2235. pagination: ['<ul class="pagination%s">', '</ul>'],
  2236. paginationItem: '<li class="page-item%s"><a class="page-link" aria-label="%s" href="javascript:void(0)">%s</a></li>',
  2237. icon: '<i class="%s %s"></i>',
  2238. inputGroup: '<div class="input-group">%s<span class="input-group-btn">%s</span></div>',
  2239. searchInput: '<input class="%s%s" type="text" placeholder="%s">',
  2240. searchButton: '<button class="btn btn-default" type="button" name="search" title="%s">%s %s</button>',
  2241. searchClearButton: '<button class="btn btn-default" type="button" name="clearSearch" title="%s">%s %s</button>'
  2242. }
  2243. },
  2244. 4: {
  2245. iconsPrefix: 'fa',
  2246. icons: {
  2247. paginationSwitchDown: 'fa-caret-square-down',
  2248. paginationSwitchUp: 'fa-caret-square-up',
  2249. refresh: 'fa-sync',
  2250. toggleOff: 'fa-toggle-off',
  2251. toggleOn: 'fa-toggle-on',
  2252. columns: 'fa-th-list',
  2253. detailOpen: 'fa-plus',
  2254. detailClose: 'fa-minus',
  2255. fullscreen: 'fa-arrows-alt',
  2256. search: 'fa-search',
  2257. clearSearch: 'fa-trash'
  2258. },
  2259. classes: {
  2260. buttonsPrefix: 'btn',
  2261. buttons: 'secondary',
  2262. buttonsGroup: 'btn-group',
  2263. buttonsDropdown: 'btn-group',
  2264. pull: 'float',
  2265. inputGroup: 'btn-group',
  2266. input: 'form-control',
  2267. paginationDropdown: 'btn-group dropdown',
  2268. dropup: 'dropup',
  2269. dropdownActive: 'active',
  2270. paginationActive: 'active',
  2271. buttonActive: 'active'
  2272. },
  2273. html: {
  2274. toolbarDropdown: ['<div class="dropdown-menu dropdown-menu-right">', '</div>'],
  2275. toolbarDropdownItem: '<label class="dropdown-item">%s</label>',
  2276. pageDropdown: ['<div class="dropdown-menu">', '</div>'],
  2277. pageDropdownItem: '<a class="dropdown-item %s" href="#">%s</a>',
  2278. toolbarDropdownSeperator: '<div class="dropdown-divider"></div>',
  2279. dropdownCaret: '<span class="caret"></span>',
  2280. pagination: ['<ul class="pagination%s">', '</ul>'],
  2281. paginationItem: '<li class="page-item%s"><a class="page-link" aria-label="%s" href="javascript:void(0)">%s</a></li>',
  2282. icon: '<i class="%s %s"></i>',
  2283. inputGroup: '<div class="input-group">%s<div class="input-group-append">%s</div></div>',
  2284. searchInput: '<input class="%s%s" type="text" placeholder="%s">',
  2285. searchButton: '<button class="btn btn-secondary" type="button" name="search" title="%s">%s %s</button>',
  2286. searchClearButton: '<button class="btn btn-secondary" type="button" name="clearSearch" title="%s">%s %s</button>'
  2287. }
  2288. }
  2289. }[bootstrapVersion];
  2290. var DEFAULTS = {
  2291. height: undefined,
  2292. classes: 'table table-bordered table-hover',
  2293. theadClasses: '',
  2294. rowStyle: function rowStyle(row, index) {
  2295. return {};
  2296. },
  2297. rowAttributes: function rowAttributes(row, index) {
  2298. return {};
  2299. },
  2300. undefinedText: '-',
  2301. locale: undefined,
  2302. sortable: true,
  2303. sortClass: undefined,
  2304. silentSort: true,
  2305. sortName: undefined,
  2306. sortOrder: 'asc',
  2307. sortStable: false,
  2308. rememberOrder: false,
  2309. customSort: undefined,
  2310. columns: [[]],
  2311. data: [],
  2312. url: undefined,
  2313. method: 'get',
  2314. cache: true,
  2315. contentType: 'application/json',
  2316. dataType: 'json',
  2317. ajax: undefined,
  2318. ajaxOptions: {},
  2319. queryParams: function queryParams(params) {
  2320. return params;
  2321. },
  2322. queryParamsType: 'limit',
  2323. // 'limit', undefined
  2324. responseHandler: function responseHandler(res) {
  2325. return res;
  2326. },
  2327. totalField: 'total',
  2328. totalNotFilteredField: 'totalNotFiltered',
  2329. dataField: 'rows',
  2330. pagination: false,
  2331. onlyInfoPagination: false,
  2332. showExtendedPagination: false,
  2333. paginationLoop: true,
  2334. sidePagination: 'client',
  2335. // client or server
  2336. totalRows: 0,
  2337. totalNotFiltered: 0,
  2338. pageNumber: 1,
  2339. pageSize: 10,
  2340. pageList: [10, 25, 50, 100],
  2341. paginationHAlign: 'right',
  2342. // right, left
  2343. paginationVAlign: 'bottom',
  2344. // bottom, top, both
  2345. paginationDetailHAlign: 'left',
  2346. // right, left
  2347. paginationPreText: '&lsaquo;',
  2348. paginationNextText: '&rsaquo;',
  2349. paginationSuccessivelySize: 5,
  2350. // Maximum successively number of pages in a row
  2351. paginationPagesBySide: 1,
  2352. // Number of pages on each side (right, left) of the current page.
  2353. paginationUseIntermediate: false,
  2354. // Calculate intermediate pages for quick access
  2355. search: false,
  2356. searchOnEnterKey: false,
  2357. strictSearch: false,
  2358. visibleSearch: false,
  2359. showButtonIcons: true,
  2360. showButtonText: false,
  2361. showSearchButton: false,
  2362. showSearchClearButton: false,
  2363. trimOnSearch: true,
  2364. searchAlign: 'right',
  2365. searchTimeOut: 500,
  2366. searchText: '',
  2367. customSearch: undefined,
  2368. showHeader: true,
  2369. showFooter: false,
  2370. footerStyle: function footerStyle(row, index) {
  2371. return {};
  2372. },
  2373. showColumns: false,
  2374. showColumnsToggleAll: false,
  2375. minimumCountColumns: 1,
  2376. showPaginationSwitch: false,
  2377. showRefresh: false,
  2378. showToggle: false,
  2379. showFullscreen: false,
  2380. smartDisplay: true,
  2381. escape: false,
  2382. filterOptions: {
  2383. filterAlgorithm: 'and'
  2384. },
  2385. idField: undefined,
  2386. selectItemName: 'btSelectItem',
  2387. clickToSelect: false,
  2388. ignoreClickToSelectOn: function ignoreClickToSelectOn(_ref) {
  2389. var tagName = _ref.tagName;
  2390. return ['A', 'BUTTON'].includes(tagName);
  2391. },
  2392. singleSelect: false,
  2393. checkboxHeader: true,
  2394. maintainMetaData: false,
  2395. multipleSelectRow: false,
  2396. uniqueId: undefined,
  2397. cardView: false,
  2398. detailView: false,
  2399. detailViewIcon: true,
  2400. detailViewByClick: false,
  2401. detailFormatter: function detailFormatter(index, row) {
  2402. return '';
  2403. },
  2404. detailFilter: function detailFilter(index, row) {
  2405. return true;
  2406. },
  2407. toolbar: undefined,
  2408. toolbarAlign: 'left',
  2409. buttonsToolbar: undefined,
  2410. buttonsAlign: 'right',
  2411. buttonsPrefix: CONSTANTS.classes.buttonsPrefix,
  2412. buttonsClass: CONSTANTS.classes.buttons,
  2413. icons: CONSTANTS.icons,
  2414. html: CONSTANTS.html,
  2415. iconSize: undefined,
  2416. iconsPrefix: CONSTANTS.iconsPrefix,
  2417. // glyphicon or fa(font-awesome)
  2418. onAll: function onAll(name, args) {
  2419. return false;
  2420. },
  2421. onClickCell: function onClickCell(field, value, row, $element) {
  2422. return false;
  2423. },
  2424. onDblClickCell: function onDblClickCell(field, value, row, $element) {
  2425. return false;
  2426. },
  2427. onClickRow: function onClickRow(item, $element) {
  2428. return false;
  2429. },
  2430. onDblClickRow: function onDblClickRow(item, $element) {
  2431. return false;
  2432. },
  2433. onSort: function onSort(name, order) {
  2434. return false;
  2435. },
  2436. onCheck: function onCheck(row) {
  2437. return false;
  2438. },
  2439. onUncheck: function onUncheck(row) {
  2440. return false;
  2441. },
  2442. onCheckAll: function onCheckAll(rows) {
  2443. return false;
  2444. },
  2445. onUncheckAll: function onUncheckAll(rows) {
  2446. return false;
  2447. },
  2448. onCheckSome: function onCheckSome(rows) {
  2449. return false;
  2450. },
  2451. onUncheckSome: function onUncheckSome(rows) {
  2452. return false;
  2453. },
  2454. onLoadSuccess: function onLoadSuccess(data) {
  2455. return false;
  2456. },
  2457. onLoadError: function onLoadError(status) {
  2458. return false;
  2459. },
  2460. onColumnSwitch: function onColumnSwitch(field, checked) {
  2461. return false;
  2462. },
  2463. onPageChange: function onPageChange(number, size) {
  2464. return false;
  2465. },
  2466. onSearch: function onSearch(text) {
  2467. return false;
  2468. },
  2469. onToggle: function onToggle(cardView) {
  2470. return false;
  2471. },
  2472. onPreBody: function onPreBody(data) {
  2473. return false;
  2474. },
  2475. onPostBody: function onPostBody() {
  2476. return false;
  2477. },
  2478. onPostHeader: function onPostHeader() {
  2479. return false;
  2480. },
  2481. onPostFooter: function onPostFooter() {
  2482. return false;
  2483. },
  2484. onExpandRow: function onExpandRow(index, row, $detail) {
  2485. return false;
  2486. },
  2487. onCollapseRow: function onCollapseRow(index, row) {
  2488. return false;
  2489. },
  2490. onRefreshOptions: function onRefreshOptions(options) {
  2491. return false;
  2492. },
  2493. onRefresh: function onRefresh(params) {
  2494. return false;
  2495. },
  2496. onResetView: function onResetView() {
  2497. return false;
  2498. },
  2499. onScrollBody: function onScrollBody() {
  2500. return false;
  2501. }
  2502. };
  2503. var EN = {
  2504. formatLoadingMessage: function formatLoadingMessage() {
  2505. return 'Loading, please wait';
  2506. },
  2507. formatRecordsPerPage: function formatRecordsPerPage(pageNumber) {
  2508. return "".concat(pageNumber, " rows per page");
  2509. },
  2510. formatShowingRows: function formatShowingRows(pageFrom, pageTo, totalRows, totalNotFiltered) {
  2511. if (totalNotFiltered !== undefined && totalNotFiltered > 0 && totalNotFiltered > totalRows) {
  2512. return "Showing ".concat(pageFrom, " to ").concat(pageTo, " of ").concat(totalRows, " rows (filtered from ").concat(totalNotFiltered, " total rows)");
  2513. }
  2514. return "Showing ".concat(pageFrom, " to ").concat(pageTo, " of ").concat(totalRows, " rows");
  2515. },
  2516. formatSRPaginationPreText: function formatSRPaginationPreText() {
  2517. return 'previous page';
  2518. },
  2519. formatSRPaginationPageText: function formatSRPaginationPageText(page) {
  2520. return "to page ".concat(page);
  2521. },
  2522. formatSRPaginationNextText: function formatSRPaginationNextText() {
  2523. return 'next page';
  2524. },
  2525. formatDetailPagination: function formatDetailPagination(totalRows) {
  2526. return "Showing ".concat(totalRows, " rows");
  2527. },
  2528. formatSearch: function formatSearch() {
  2529. return 'Search';
  2530. },
  2531. formatClearSearch: function formatClearSearch() {
  2532. return 'Clear Search';
  2533. },
  2534. formatNoMatches: function formatNoMatches() {
  2535. return 'No matching records found';
  2536. },
  2537. formatPaginationSwitch: function formatPaginationSwitch() {
  2538. return 'Hide/Show pagination';
  2539. },
  2540. formatPaginationSwitchDown: function formatPaginationSwitchDown() {
  2541. return 'Show pagination';
  2542. },
  2543. formatPaginationSwitchUp: function formatPaginationSwitchUp() {
  2544. return 'Hide pagination';
  2545. },
  2546. formatRefresh: function formatRefresh() {
  2547. return 'Refresh';
  2548. },
  2549. formatToggle: function formatToggle() {
  2550. return 'Toggle';
  2551. },
  2552. formatToggleOn: function formatToggleOn() {
  2553. return 'Show card view';
  2554. },
  2555. formatToggleOff: function formatToggleOff() {
  2556. return 'Hide card view';
  2557. },
  2558. formatColumns: function formatColumns() {
  2559. return 'Columns';
  2560. },
  2561. formatColumnsToggleAll: function formatColumnsToggleAll() {
  2562. return 'Toggle all';
  2563. },
  2564. formatFullscreen: function formatFullscreen() {
  2565. return 'Fullscreen';
  2566. },
  2567. formatAllRows: function formatAllRows() {
  2568. return 'All';
  2569. }
  2570. };
  2571. var COLUMN_DEFAULTS = {
  2572. field: undefined,
  2573. title: undefined,
  2574. titleTooltip: undefined,
  2575. 'class': undefined,
  2576. width: undefined,
  2577. widthUnit: 'px',
  2578. rowspan: undefined,
  2579. colspan: undefined,
  2580. align: undefined,
  2581. // left, right, center
  2582. halign: undefined,
  2583. // left, right, center
  2584. falign: undefined,
  2585. // left, right, center
  2586. valign: undefined,
  2587. // top, middle, bottom
  2588. cellStyle: undefined,
  2589. radio: false,
  2590. checkbox: false,
  2591. checkboxEnabled: true,
  2592. clickToSelect: true,
  2593. showSelectTitle: false,
  2594. sortable: false,
  2595. sortName: undefined,
  2596. order: 'asc',
  2597. // asc, desc
  2598. sorter: undefined,
  2599. visible: true,
  2600. switchable: true,
  2601. cardVisible: true,
  2602. searchable: true,
  2603. formatter: undefined,
  2604. footerFormatter: undefined,
  2605. detailFormatter: undefined,
  2606. searchFormatter: true,
  2607. escape: false,
  2608. events: undefined
  2609. };
  2610. var METHODS = ['getOptions', 'refreshOptions', 'getData', 'getSelections', 'getAllSelections', 'load', 'append', 'prepend', 'remove', 'removeAll', 'insertRow', 'updateRow', 'getRowByUniqueId', 'updateByUniqueId', 'removeByUniqueId', 'updateCell', 'updateCellByUniqueId', 'showRow', 'hideRow', 'getHiddenRows', 'showColumn', 'hideColumn', 'getVisibleColumns', 'getHiddenColumns', 'showAllColumns', 'hideAllColumns', 'mergeCells', 'checkAll', 'uncheckAll', 'checkInvert', 'check', 'uncheck', 'checkBy', 'uncheckBy', 'refresh', 'destroy', 'resetView', 'resetWidth', 'showLoading', 'hideLoading', 'togglePagination', 'toggleFullscreen', 'toggleView', 'resetSearch', 'filterBy', 'scrollTo', 'getScrollPosition', 'selectPage', 'prevPage', 'nextPage', 'toggleDetailView', 'expandRow', 'collapseRow', 'expandAllRows', 'collapseAllRows', 'updateColumnTitle', 'updateFormatText'];
  2611. var EVENTS = {
  2612. 'all.bs.table': 'onAll',
  2613. 'click-row.bs.table': 'onClickRow',
  2614. 'dbl-click-row.bs.table': 'onDblClickRow',
  2615. 'click-cell.bs.table': 'onClickCell',
  2616. 'dbl-click-cell.bs.table': 'onDblClickCell',
  2617. 'sort.bs.table': 'onSort',
  2618. 'check.bs.table': 'onCheck',
  2619. 'uncheck.bs.table': 'onUncheck',
  2620. 'check-all.bs.table': 'onCheckAll',
  2621. 'uncheck-all.bs.table': 'onUncheckAll',
  2622. 'check-some.bs.table': 'onCheckSome',
  2623. 'uncheck-some.bs.table': 'onUncheckSome',
  2624. 'load-success.bs.table': 'onLoadSuccess',
  2625. 'load-error.bs.table': 'onLoadError',
  2626. 'column-switch.bs.table': 'onColumnSwitch',
  2627. 'page-change.bs.table': 'onPageChange',
  2628. 'search.bs.table': 'onSearch',
  2629. 'toggle.bs.table': 'onToggle',
  2630. 'pre-body.bs.table': 'onPreBody',
  2631. 'post-body.bs.table': 'onPostBody',
  2632. 'post-header.bs.table': 'onPostHeader',
  2633. 'post-footer.bs.table': 'onPostFooter',
  2634. 'expand-row.bs.table': 'onExpandRow',
  2635. 'collapse-row.bs.table': 'onCollapseRow',
  2636. 'refresh-options.bs.table': 'onRefreshOptions',
  2637. 'reset-view.bs.table': 'onResetView',
  2638. 'refresh.bs.table': 'onRefresh',
  2639. 'scroll-body.bs.table': 'onScrollBody'
  2640. };
  2641. Object.assign(DEFAULTS, EN);
  2642. var Constants = {
  2643. VERSION: VERSION,
  2644. THEME: "bootstrap".concat(bootstrapVersion),
  2645. CONSTANTS: CONSTANTS,
  2646. DEFAULTS: DEFAULTS,
  2647. COLUMN_DEFAULTS: COLUMN_DEFAULTS,
  2648. METHODS: METHODS,
  2649. EVENTS: EVENTS,
  2650. LOCALES: {
  2651. en: EN,
  2652. 'en-US': EN
  2653. }
  2654. };
  2655. var FAILS_ON_PRIMITIVES = fails(function () { objectKeys(1); });
  2656. // `Object.keys` method
  2657. // https://tc39.github.io/ecma262/#sec-object.keys
  2658. _export({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {
  2659. keys: function keys(it) {
  2660. return objectKeys(toObject(it));
  2661. }
  2662. });
  2663. var Utils = {
  2664. // it only does '%s', and return '' when arguments are undefined
  2665. sprintf: function sprintf(_str) {
  2666. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  2667. args[_key - 1] = arguments[_key];
  2668. }
  2669. var flag = true;
  2670. var i = 0;
  2671. var str = _str.replace(/%s/g, function () {
  2672. var arg = args[i++];
  2673. if (typeof arg === 'undefined') {
  2674. flag = false;
  2675. return '';
  2676. }
  2677. return arg;
  2678. });
  2679. return flag ? str : '';
  2680. },
  2681. isEmptyObject: function isEmptyObject() {
  2682. var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  2683. return Object.entries(obj).length === 0 && obj.constructor === Object;
  2684. },
  2685. isNumeric: function isNumeric(n) {
  2686. return !isNaN(parseFloat(n)) && isFinite(n);
  2687. },
  2688. getFieldTitle: function getFieldTitle(list, value) {
  2689. var _iteratorNormalCompletion = true;
  2690. var _didIteratorError = false;
  2691. var _iteratorError = undefined;
  2692. try {
  2693. for (var _iterator = list[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  2694. var item = _step.value;
  2695. if (item.field === value) {
  2696. return item.title;
  2697. }
  2698. }
  2699. } catch (err) {
  2700. _didIteratorError = true;
  2701. _iteratorError = err;
  2702. } finally {
  2703. try {
  2704. if (!_iteratorNormalCompletion && _iterator.return != null) {
  2705. _iterator.return();
  2706. }
  2707. } finally {
  2708. if (_didIteratorError) {
  2709. throw _iteratorError;
  2710. }
  2711. }
  2712. }
  2713. return '';
  2714. },
  2715. setFieldIndex: function setFieldIndex(columns) {
  2716. var totalCol = 0;
  2717. var flag = [];
  2718. var _iteratorNormalCompletion2 = true;
  2719. var _didIteratorError2 = false;
  2720. var _iteratorError2 = undefined;
  2721. try {
  2722. for (var _iterator2 = columns[0][Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  2723. var column = _step2.value;
  2724. totalCol += column.colspan || 1;
  2725. }
  2726. } catch (err) {
  2727. _didIteratorError2 = true;
  2728. _iteratorError2 = err;
  2729. } finally {
  2730. try {
  2731. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  2732. _iterator2.return();
  2733. }
  2734. } finally {
  2735. if (_didIteratorError2) {
  2736. throw _iteratorError2;
  2737. }
  2738. }
  2739. }
  2740. for (var i = 0; i < columns.length; i++) {
  2741. flag[i] = [];
  2742. for (var j = 0; j < totalCol; j++) {
  2743. flag[i][j] = false;
  2744. }
  2745. }
  2746. for (var _i = 0; _i < columns.length; _i++) {
  2747. var _iteratorNormalCompletion3 = true;
  2748. var _didIteratorError3 = false;
  2749. var _iteratorError3 = undefined;
  2750. try {
  2751. for (var _iterator3 = columns[_i][Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  2752. var r = _step3.value;
  2753. var rowspan = r.rowspan || 1;
  2754. var colspan = r.colspan || 1;
  2755. var index = flag[_i].indexOf(false);
  2756. if (colspan === 1) {
  2757. r.fieldIndex = index; // when field is undefined, use index instead
  2758. if (typeof r.field === 'undefined') {
  2759. r.field = index;
  2760. }
  2761. }
  2762. for (var k = 0; k < rowspan; k++) {
  2763. flag[_i + k][index] = true;
  2764. }
  2765. for (var _k = 0; _k < colspan; _k++) {
  2766. flag[_i][index + _k] = true;
  2767. }
  2768. }
  2769. } catch (err) {
  2770. _didIteratorError3 = true;
  2771. _iteratorError3 = err;
  2772. } finally {
  2773. try {
  2774. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  2775. _iterator3.return();
  2776. }
  2777. } finally {
  2778. if (_didIteratorError3) {
  2779. throw _iteratorError3;
  2780. }
  2781. }
  2782. }
  2783. }
  2784. },
  2785. getScrollBarWidth: function getScrollBarWidth() {
  2786. if (this.cachedWidth === undefined) {
  2787. var $inner = $('<div/>').addClass('fixed-table-scroll-inner');
  2788. var $outer = $('<div/>').addClass('fixed-table-scroll-outer');
  2789. $outer.append($inner);
  2790. $('body').append($outer);
  2791. var w1 = $inner[0].offsetWidth;
  2792. $outer.css('overflow', 'scroll');
  2793. var w2 = $inner[0].offsetWidth;
  2794. if (w1 === w2) {
  2795. w2 = $outer[0].clientWidth;
  2796. }
  2797. $outer.remove();
  2798. this.cachedWidth = w1 - w2;
  2799. }
  2800. return this.cachedWidth;
  2801. },
  2802. calculateObjectValue: function calculateObjectValue(self, name, args, defaultValue) {
  2803. var func = name;
  2804. if (typeof name === 'string') {
  2805. // support obj.func1.func2
  2806. var names = name.split('.');
  2807. if (names.length > 1) {
  2808. func = window;
  2809. var _iteratorNormalCompletion4 = true;
  2810. var _didIteratorError4 = false;
  2811. var _iteratorError4 = undefined;
  2812. try {
  2813. for (var _iterator4 = names[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  2814. var f = _step4.value;
  2815. func = func[f];
  2816. }
  2817. } catch (err) {
  2818. _didIteratorError4 = true;
  2819. _iteratorError4 = err;
  2820. } finally {
  2821. try {
  2822. if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
  2823. _iterator4.return();
  2824. }
  2825. } finally {
  2826. if (_didIteratorError4) {
  2827. throw _iteratorError4;
  2828. }
  2829. }
  2830. }
  2831. } else {
  2832. func = window[name];
  2833. }
  2834. }
  2835. if (func !== null && _typeof(func) === 'object') {
  2836. return func;
  2837. }
  2838. if (typeof func === 'function') {
  2839. return func.apply(self, args || []);
  2840. }
  2841. if (!func && typeof name === 'string' && this.sprintf.apply(this, [name].concat(_toConsumableArray(args)))) {
  2842. return this.sprintf.apply(this, [name].concat(_toConsumableArray(args)));
  2843. }
  2844. return defaultValue;
  2845. },
  2846. compareObjects: function compareObjects(objectA, objectB, compareLength) {
  2847. var aKeys = Object.keys(objectA);
  2848. var bKeys = Object.keys(objectB);
  2849. if (compareLength && aKeys.length !== bKeys.length) {
  2850. return false;
  2851. }
  2852. for (var _i2 = 0, _aKeys = aKeys; _i2 < _aKeys.length; _i2++) {
  2853. var key = _aKeys[_i2];
  2854. if (bKeys.includes(key) && objectA[key] !== objectB[key]) {
  2855. return false;
  2856. }
  2857. }
  2858. return true;
  2859. },
  2860. escapeHTML: function escapeHTML(text) {
  2861. if (typeof text === 'string') {
  2862. return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#039;').replace(/`/g, '&#x60;');
  2863. }
  2864. return text;
  2865. },
  2866. getRealDataAttr: function getRealDataAttr(dataAttr) {
  2867. for (var _i3 = 0, _Object$entries = Object.entries(dataAttr); _i3 < _Object$entries.length; _i3++) {
  2868. var _Object$entries$_i = _slicedToArray(_Object$entries[_i3], 2),
  2869. attr = _Object$entries$_i[0],
  2870. value = _Object$entries$_i[1];
  2871. var auxAttr = attr.split(/(?=[A-Z])/).join('-').toLowerCase();
  2872. if (auxAttr !== attr) {
  2873. dataAttr[auxAttr] = value;
  2874. delete dataAttr[attr];
  2875. }
  2876. }
  2877. return dataAttr;
  2878. },
  2879. getItemField: function getItemField(item, field, escape) {
  2880. var value = item;
  2881. if (typeof field !== 'string' || item.hasOwnProperty(field)) {
  2882. return escape ? this.escapeHTML(item[field]) : item[field];
  2883. }
  2884. var props = field.split('.');
  2885. var _iteratorNormalCompletion5 = true;
  2886. var _didIteratorError5 = false;
  2887. var _iteratorError5 = undefined;
  2888. try {
  2889. for (var _iterator5 = props[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
  2890. var p = _step5.value;
  2891. value = value && value[p];
  2892. }
  2893. } catch (err) {
  2894. _didIteratorError5 = true;
  2895. _iteratorError5 = err;
  2896. } finally {
  2897. try {
  2898. if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
  2899. _iterator5.return();
  2900. }
  2901. } finally {
  2902. if (_didIteratorError5) {
  2903. throw _iteratorError5;
  2904. }
  2905. }
  2906. }
  2907. return escape ? this.escapeHTML(value) : value;
  2908. },
  2909. isIEBrowser: function isIEBrowser() {
  2910. return navigator.userAgent.includes('MSIE ') || /Trident.*rv:11\./.test(navigator.userAgent);
  2911. },
  2912. findIndex: function findIndex(items, item) {
  2913. var _iteratorNormalCompletion6 = true;
  2914. var _didIteratorError6 = false;
  2915. var _iteratorError6 = undefined;
  2916. try {
  2917. for (var _iterator6 = items[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
  2918. var it = _step6.value;
  2919. if (JSON.stringify(it) === JSON.stringify(item)) {
  2920. return items.indexOf(it);
  2921. }
  2922. }
  2923. } catch (err) {
  2924. _didIteratorError6 = true;
  2925. _iteratorError6 = err;
  2926. } finally {
  2927. try {
  2928. if (!_iteratorNormalCompletion6 && _iterator6.return != null) {
  2929. _iterator6.return();
  2930. }
  2931. } finally {
  2932. if (_didIteratorError6) {
  2933. throw _iteratorError6;
  2934. }
  2935. }
  2936. }
  2937. return -1;
  2938. },
  2939. trToData: function trToData(columns, $els) {
  2940. var _this = this;
  2941. var data = [];
  2942. var m = [];
  2943. $els.each(function (y, el) {
  2944. var row = {}; // save tr's id, class and data-* attributes
  2945. row._id = $(el).attr('id');
  2946. row._class = $(el).attr('class');
  2947. row._data = _this.getRealDataAttr($(el).data());
  2948. $(el).find('>td,>th').each(function (_x, el) {
  2949. var cspan = +$(el).attr('colspan') || 1;
  2950. var rspan = +$(el).attr('rowspan') || 1;
  2951. var x = _x; // skip already occupied cells in current row
  2952. for (; m[y] && m[y][x]; x++) {} // ignore
  2953. // mark matrix elements occupied by current cell with true
  2954. for (var tx = x; tx < x + cspan; tx++) {
  2955. for (var ty = y; ty < y + rspan; ty++) {
  2956. if (!m[ty]) {
  2957. // fill missing rows
  2958. m[ty] = [];
  2959. }
  2960. m[ty][tx] = true;
  2961. }
  2962. }
  2963. var field = columns[x].field;
  2964. row[field] = $(el).html().trim(); // save td's id, class and data-* attributes
  2965. row["_".concat(field, "_id")] = $(el).attr('id');
  2966. row["_".concat(field, "_class")] = $(el).attr('class');
  2967. row["_".concat(field, "_rowspan")] = $(el).attr('rowspan');
  2968. row["_".concat(field, "_colspan")] = $(el).attr('colspan');
  2969. row["_".concat(field, "_title")] = $(el).attr('title');
  2970. row["_".concat(field, "_data")] = _this.getRealDataAttr($(el).data());
  2971. });
  2972. data.push(row);
  2973. });
  2974. return data;
  2975. },
  2976. sort: function sort(a, b, order, sortStable) {
  2977. if (a === undefined || a === null) {
  2978. a = '';
  2979. }
  2980. if (b === undefined || b === null) {
  2981. b = '';
  2982. }
  2983. if (sortStable && a === b) {
  2984. a = a._position;
  2985. b = b._position;
  2986. } // If both values are numeric, do a numeric comparison
  2987. if (this.isNumeric(a) && this.isNumeric(b)) {
  2988. // Convert numerical values form string to float.
  2989. a = parseFloat(a);
  2990. b = parseFloat(b);
  2991. if (a < b) {
  2992. return order * -1;
  2993. }
  2994. if (a > b) {
  2995. return order;
  2996. }
  2997. return 0;
  2998. }
  2999. if (a === b) {
  3000. return 0;
  3001. } // If value is not a string, convert to string
  3002. if (typeof a !== 'string') {
  3003. a = a.toString();
  3004. }
  3005. if (a.localeCompare(b) === -1) {
  3006. return order * -1;
  3007. }
  3008. return order;
  3009. }
  3010. };
  3011. var BLOCK_ROWS = 50;
  3012. var CLUSTER_BLOCKS = 4;
  3013. var VirtualScroll =
  3014. /*#__PURE__*/
  3015. function () {
  3016. function VirtualScroll(options) {
  3017. var _this = this;
  3018. _classCallCheck(this, VirtualScroll);
  3019. this.rows = options.rows;
  3020. this.scrollEl = options.scrollEl;
  3021. this.contentEl = options.contentEl;
  3022. this.callback = options.callback;
  3023. this.cache = {};
  3024. this.scrollTop = this.scrollEl.scrollTop;
  3025. this.initDOM(this.rows);
  3026. this.scrollEl.scrollTop = this.scrollTop;
  3027. this.lastCluster = 0;
  3028. var onScroll = function onScroll() {
  3029. if (_this.lastCluster !== (_this.lastCluster = _this.getNum())) {
  3030. _this.initDOM(_this.rows);
  3031. _this.callback();
  3032. }
  3033. };
  3034. this.scrollEl.addEventListener('scroll', onScroll, false);
  3035. this.destroy = function () {
  3036. _this.contentEl.innerHtml = '';
  3037. _this.scrollEl.removeEventListener('scroll', onScroll, false);
  3038. };
  3039. }
  3040. _createClass(VirtualScroll, [{
  3041. key: "initDOM",
  3042. value: function initDOM(rows) {
  3043. if (typeof this.clusterHeight === 'undefined') {
  3044. this.cache.data = this.contentEl.innerHTML = rows[0] + rows[0] + rows[0];
  3045. this.getRowsHeight(rows);
  3046. }
  3047. var data = this.initData(rows, this.getNum());
  3048. var thisRows = data.rows.join('');
  3049. var dataChanged = this.checkChanges('data', thisRows);
  3050. var topOffsetChanged = this.checkChanges('top', data.topOffset);
  3051. var bottomOffsetChanged = this.checkChanges('bottom', data.bottomOffset);
  3052. var html = [];
  3053. if (dataChanged && topOffsetChanged) {
  3054. if (data.topOffset) {
  3055. html.push(this.getExtra('top', data.topOffset));
  3056. }
  3057. html.push(thisRows);
  3058. if (data.bottomOffset) {
  3059. html.push(this.getExtra('bottom', data.bottomOffset));
  3060. }
  3061. this.contentEl.innerHTML = html.join('');
  3062. } else if (bottomOffsetChanged) {
  3063. this.contentEl.lastChild.style.height = "".concat(data.bottomOffset, "px");
  3064. }
  3065. }
  3066. }, {
  3067. key: "getRowsHeight",
  3068. value: function getRowsHeight() {
  3069. var nodes = this.contentEl.children;
  3070. var node = nodes[Math.floor(nodes.length / 2)];
  3071. this.itemHeight = node.offsetHeight;
  3072. this.blockHeight = this.itemHeight * BLOCK_ROWS;
  3073. this.clusterRows = BLOCK_ROWS * CLUSTER_BLOCKS;
  3074. this.clusterHeight = this.blockHeight * CLUSTER_BLOCKS;
  3075. }
  3076. }, {
  3077. key: "getNum",
  3078. value: function getNum() {
  3079. this.scrollTop = this.scrollEl.scrollTop;
  3080. return Math.floor(this.scrollTop / (this.clusterHeight - this.blockHeight)) || 0;
  3081. }
  3082. }, {
  3083. key: "initData",
  3084. value: function initData(rows, num) {
  3085. if (rows.length < BLOCK_ROWS) {
  3086. return {
  3087. topOffset: 0,
  3088. bottomOffset: 0,
  3089. rowsAbove: 0,
  3090. rows: rows
  3091. };
  3092. }
  3093. var start = Math.max((this.clusterRows - BLOCK_ROWS) * num, 0);
  3094. var end = start + this.clusterRows;
  3095. var topOffset = Math.max(start * this.itemHeight, 0);
  3096. var bottomOffset = Math.max((rows.length - end) * this.itemHeight, 0);
  3097. var thisRows = [];
  3098. var rowsAbove = start;
  3099. if (topOffset < 1) {
  3100. rowsAbove++;
  3101. }
  3102. for (var i = start; i < end; i++) {
  3103. rows[i] && thisRows.push(rows[i]);
  3104. }
  3105. return {
  3106. topOffset: topOffset,
  3107. bottomOffset: bottomOffset,
  3108. rowsAbove: rowsAbove,
  3109. rows: thisRows
  3110. };
  3111. }
  3112. }, {
  3113. key: "checkChanges",
  3114. value: function checkChanges(type, value) {
  3115. var changed = value !== this.cache[type];
  3116. this.cache[type] = value;
  3117. return changed;
  3118. }
  3119. }, {
  3120. key: "getExtra",
  3121. value: function getExtra(className, height) {
  3122. var tag = document.createElement('tr');
  3123. tag.className = "virtual-scroll-".concat(className);
  3124. if (height) {
  3125. tag.style.height = "".concat(height, "px");
  3126. }
  3127. return tag.outerHTML;
  3128. }
  3129. }]);
  3130. return VirtualScroll;
  3131. }();
  3132. var BootstrapTable =
  3133. /*#__PURE__*/
  3134. function () {
  3135. function BootstrapTable(el, options) {
  3136. _classCallCheck(this, BootstrapTable);
  3137. this.options = options;
  3138. this.$el = $(el);
  3139. this.$el_ = this.$el.clone();
  3140. this.timeoutId_ = 0;
  3141. this.timeoutFooter_ = 0;
  3142. this.init();
  3143. }
  3144. _createClass(BootstrapTable, [{
  3145. key: "init",
  3146. value: function init() {
  3147. this.initConstants();
  3148. this.initLocale();
  3149. this.initContainer();
  3150. this.initTable();
  3151. this.initHeader();
  3152. this.initData();
  3153. this.initHiddenRows();
  3154. this.initToolbar();
  3155. this.initPagination();
  3156. this.initBody();
  3157. this.initSearchText();
  3158. this.initServer();
  3159. }
  3160. }, {
  3161. key: "initConstants",
  3162. value: function initConstants() {
  3163. var o = this.options;
  3164. this.constants = Constants.CONSTANTS;
  3165. this.constants.theme = $.fn.bootstrapTable.theme;
  3166. var buttonsPrefix = o.buttonsPrefix ? "".concat(o.buttonsPrefix, "-") : '';
  3167. this.constants.buttonsClass = [o.buttonsPrefix, buttonsPrefix + o.buttonsClass, Utils.sprintf("".concat(buttonsPrefix, "%s"), o.iconSize)].join(' ').trim();
  3168. }
  3169. }, {
  3170. key: "initLocale",
  3171. value: function initLocale() {
  3172. if (this.options.locale) {
  3173. var locales = $.fn.bootstrapTable.locales;
  3174. var parts = this.options.locale.split(/-|_/);
  3175. parts[0] = parts[0].toLowerCase();
  3176. if (parts[1]) {
  3177. parts[1] = parts[1].toUpperCase();
  3178. }
  3179. if (locales[this.options.locale]) {
  3180. $.extend(this.options, locales[this.options.locale]);
  3181. } else if (locales[parts.join('-')]) {
  3182. $.extend(this.options, locales[parts.join('-')]);
  3183. } else if (locales[parts[0]]) {
  3184. $.extend(this.options, locales[parts[0]]);
  3185. }
  3186. }
  3187. }
  3188. }, {
  3189. key: "initContainer",
  3190. value: function initContainer() {
  3191. var topPagination = ['top', 'both'].includes(this.options.paginationVAlign) ? '<div class="fixed-table-pagination clearfix"></div>' : '';
  3192. var bottomPagination = ['bottom', 'both'].includes(this.options.paginationVAlign) ? '<div class="fixed-table-pagination"></div>' : '';
  3193. this.$container = $("\n <div class=\"bootstrap-table ".concat(this.constants.theme, "\">\n <div class=\"fixed-table-toolbar\"></div>\n ").concat(topPagination, "\n <div class=\"fixed-table-container\">\n <div class=\"fixed-table-header\"><table></table></div>\n <div class=\"fixed-table-body\">\n <div class=\"fixed-table-loading\">\n <span class=\"loading-wrap\">\n <span class=\"loading-text\">").concat(this.options.formatLoadingMessage(), "</span>\n <span class=\"animation-wrap\"><span class=\"animation-dot\"></span></span>\n </span>\n </div>\n </div>\n <div class=\"fixed-table-footer\"><table><thead><tr></tr></thead></table></div>\n </div>\n ").concat(bottomPagination, "\n </div>\n "));
  3194. this.$container.insertAfter(this.$el);
  3195. this.$tableContainer = this.$container.find('.fixed-table-container');
  3196. this.$tableHeader = this.$container.find('.fixed-table-header');
  3197. this.$tableBody = this.$container.find('.fixed-table-body');
  3198. this.$tableLoading = this.$container.find('.fixed-table-loading');
  3199. this.$tableFooter = this.$el.find('tfoot'); // checking if custom table-toolbar exists or not
  3200. if (this.options.buttonsToolbar) {
  3201. this.$toolbar = $('body').find(this.options.buttonsToolbar);
  3202. } else {
  3203. this.$toolbar = this.$container.find('.fixed-table-toolbar');
  3204. }
  3205. this.$pagination = this.$container.find('.fixed-table-pagination');
  3206. this.$tableBody.append(this.$el);
  3207. this.$container.after('<div class="clearfix"></div>');
  3208. this.$el.addClass(this.options.classes);
  3209. this.$tableLoading.addClass(this.options.classes);
  3210. if (this.options.height) {
  3211. this.$tableContainer.addClass('fixed-height');
  3212. if (this.options.showFooter) {
  3213. this.$tableContainer.addClass('has-footer');
  3214. }
  3215. if (this.options.classes.split(' ').includes('table-bordered')) {
  3216. this.$tableBody.append('<div class="fixed-table-border"></div>');
  3217. this.$tableBorder = this.$tableBody.find('.fixed-table-border');
  3218. this.$tableLoading.addClass('fixed-table-border');
  3219. }
  3220. this.$tableFooter = this.$container.find('.fixed-table-footer');
  3221. }
  3222. }
  3223. }, {
  3224. key: "initTable",
  3225. value: function initTable() {
  3226. var _this = this;
  3227. var columns = [];
  3228. var data = [];
  3229. this.$header = this.$el.find('>thead');
  3230. if (!this.$header.length) {
  3231. this.$header = $("<thead class=\"".concat(this.options.theadClasses, "\"></thead>")).appendTo(this.$el);
  3232. } else if (this.options.theadClasses) {
  3233. this.$header.addClass(this.options.theadClasses);
  3234. }
  3235. this.$header.find('tr').each(function (i, el) {
  3236. var column = [];
  3237. $(el).find('th').each(function (i, el) {
  3238. // #2014: getFieldIndex and elsewhere assume this is string, causes issues if not
  3239. if (typeof $(el).data('field') !== 'undefined') {
  3240. $(el).data('field', "".concat($(el).data('field')));
  3241. }
  3242. column.push($.extend({}, {
  3243. title: $(el).html(),
  3244. 'class': $(el).attr('class'),
  3245. titleTooltip: $(el).attr('title'),
  3246. rowspan: $(el).attr('rowspan') ? +$(el).attr('rowspan') : undefined,
  3247. colspan: $(el).attr('colspan') ? +$(el).attr('colspan') : undefined
  3248. }, $(el).data()));
  3249. });
  3250. columns.push(column);
  3251. });
  3252. if (!Array.isArray(this.options.columns[0])) {
  3253. this.options.columns = [this.options.columns];
  3254. }
  3255. this.options.columns = $.extend(true, [], columns, this.options.columns);
  3256. this.columns = [];
  3257. this.fieldsColumnsIndex = [];
  3258. Utils.setFieldIndex(this.options.columns);
  3259. this.options.columns.forEach(function (columns, i) {
  3260. columns.forEach(function (_column, j) {
  3261. var column = $.extend({}, BootstrapTable.COLUMN_DEFAULTS, _column);
  3262. if (typeof column.fieldIndex !== 'undefined') {
  3263. _this.columns[column.fieldIndex] = column;
  3264. _this.fieldsColumnsIndex[column.field] = column.fieldIndex;
  3265. }
  3266. _this.options.columns[i][j] = column;
  3267. });
  3268. }); // if options.data is setting, do not process tbody and tfoot data
  3269. if (!this.options.data.length) {
  3270. this.options.data = Utils.trToData(this.columns, this.$el.find('>tbody>tr'));
  3271. if (data.length) {
  3272. this.fromHtml = true;
  3273. }
  3274. }
  3275. this.footerData = Utils.trToData(this.columns, this.$el.find('>tfoot>tr'));
  3276. if (this.footerData) {
  3277. this.$el.find('tfoot').html('<tr></tr>');
  3278. }
  3279. if (!this.options.showFooter || this.options.cardView) {
  3280. this.$tableFooter.hide();
  3281. } else {
  3282. this.$tableFooter.show();
  3283. }
  3284. }
  3285. }, {
  3286. key: "initHeader",
  3287. value: function initHeader() {
  3288. var _this2 = this;
  3289. var visibleColumns = {};
  3290. var html = [];
  3291. this.header = {
  3292. fields: [],
  3293. styles: [],
  3294. classes: [],
  3295. formatters: [],
  3296. detailFormatters: [],
  3297. events: [],
  3298. sorters: [],
  3299. sortNames: [],
  3300. cellStyles: [],
  3301. searchables: []
  3302. };
  3303. this.options.columns.forEach(function (columns, i) {
  3304. html.push('<tr>');
  3305. if (i === 0 && !_this2.options.cardView && _this2.options.detailView && _this2.options.detailViewIcon) {
  3306. html.push("<th class=\"detail\" rowspan=\"".concat(_this2.options.columns.length, "\">\n <div class=\"fht-cell\"></div>\n </th>\n "));
  3307. }
  3308. columns.forEach(function (column, j) {
  3309. var class_ = Utils.sprintf(' class="%s"', column['class']);
  3310. var unitWidth = column.widthUnit;
  3311. var width = Number.parseFloat(column.width);
  3312. var halign = Utils.sprintf('text-align: %s; ', column.halign ? column.halign : column.align);
  3313. var align = Utils.sprintf('text-align: %s; ', column.align);
  3314. var style = Utils.sprintf('vertical-align: %s; ', column.valign);
  3315. style += Utils.sprintf('width: %s; ', (column.checkbox || column.radio) && !width ? !column.showSelectTitle ? '36px' : undefined : width ? width + unitWidth : undefined);
  3316. if (typeof column.fieldIndex !== 'undefined') {
  3317. _this2.header.fields[column.fieldIndex] = column.field;
  3318. _this2.header.styles[column.fieldIndex] = align + style;
  3319. _this2.header.classes[column.fieldIndex] = class_;
  3320. _this2.header.formatters[column.fieldIndex] = column.formatter;
  3321. _this2.header.detailFormatters[column.fieldIndex] = column.detailFormatter;
  3322. _this2.header.events[column.fieldIndex] = column.events;
  3323. _this2.header.sorters[column.fieldIndex] = column.sorter;
  3324. _this2.header.sortNames[column.fieldIndex] = column.sortName;
  3325. _this2.header.cellStyles[column.fieldIndex] = column.cellStyle;
  3326. _this2.header.searchables[column.fieldIndex] = column.searchable;
  3327. if (!column.visible) {
  3328. return;
  3329. }
  3330. if (_this2.options.cardView && !column.cardVisible) {
  3331. return;
  3332. }
  3333. visibleColumns[column.field] = column;
  3334. }
  3335. html.push("<th".concat(Utils.sprintf(' title="%s"', column.titleTooltip)), column.checkbox || column.radio ? Utils.sprintf(' class="bs-checkbox %s"', column['class'] || '') : class_, Utils.sprintf(' style="%s"', halign + style), Utils.sprintf(' rowspan="%s"', column.rowspan), Utils.sprintf(' colspan="%s"', column.colspan), Utils.sprintf(' data-field="%s"', column.field), // If `column` is not the first element of `this.options.columns[0]`, then className 'data-not-first-th' should be added.
  3336. j === 0 && i > 0 ? ' data-not-first-th' : '', '>');
  3337. html.push(Utils.sprintf('<div class="th-inner %s">', _this2.options.sortable && column.sortable ? 'sortable both' : ''));
  3338. var text = _this2.options.escape ? Utils.escapeHTML(column.title) : column.title;
  3339. var title = text;
  3340. if (column.checkbox) {
  3341. text = '';
  3342. if (!_this2.options.singleSelect && _this2.options.checkboxHeader) {
  3343. text = '<label><input name="btSelectAll" type="checkbox" /><span></span></label>';
  3344. }
  3345. _this2.header.stateField = column.field;
  3346. }
  3347. if (column.radio) {
  3348. text = '';
  3349. _this2.header.stateField = column.field;
  3350. _this2.options.singleSelect = true;
  3351. }
  3352. if (!text && column.showSelectTitle) {
  3353. text += title;
  3354. }
  3355. html.push(text);
  3356. html.push('</div>');
  3357. html.push('<div class="fht-cell"></div>');
  3358. html.push('</div>');
  3359. html.push('</th>');
  3360. });
  3361. html.push('</tr>');
  3362. });
  3363. this.$header.html(html.join(''));
  3364. this.$header.find('th[data-field]').each(function (i, el) {
  3365. $(el).data(visibleColumns[$(el).data('field')]);
  3366. });
  3367. this.$container.off('click', '.th-inner').on('click', '.th-inner', function (e) {
  3368. var $this = $(e.currentTarget);
  3369. if (_this2.options.detailView && !$this.parent().hasClass('bs-checkbox')) {
  3370. if ($this.closest('.bootstrap-table')[0] !== _this2.$container[0]) {
  3371. return false;
  3372. }
  3373. }
  3374. if (_this2.options.sortable && $this.parent().data().sortable) {
  3375. _this2.onSort(e);
  3376. }
  3377. });
  3378. this.$header.children().children().off('keypress').on('keypress', function (e) {
  3379. if (_this2.options.sortable && $(e.currentTarget).data().sortable) {
  3380. var code = e.keyCode || e.which;
  3381. if (code === 13) {
  3382. // Enter keycode
  3383. _this2.onSort(e);
  3384. }
  3385. }
  3386. });
  3387. var resizeEvent = "resize.bootstrap-table".concat(this.$el.attr('id') || '');
  3388. $(window).off(resizeEvent);
  3389. if (!this.options.showHeader || this.options.cardView) {
  3390. this.$header.hide();
  3391. this.$tableHeader.hide();
  3392. this.$tableLoading.css('top', 0);
  3393. } else {
  3394. this.$header.show();
  3395. this.$tableHeader.show();
  3396. this.$tableLoading.css('top', this.$header.outerHeight() + 1); // Assign the correct sortable arrow
  3397. this.getCaret();
  3398. $(window).on(resizeEvent, function (e) {
  3399. return _this2.resetWidth(e);
  3400. });
  3401. }
  3402. this.$selectAll = this.$header.find('[name="btSelectAll"]');
  3403. this.$selectAll.off('click').on('click', function (_ref) {
  3404. var currentTarget = _ref.currentTarget;
  3405. var checked = $(currentTarget).prop('checked');
  3406. _this2[checked ? 'checkAll' : 'uncheckAll']();
  3407. _this2.updateSelected();
  3408. });
  3409. }
  3410. }, {
  3411. key: "initData",
  3412. value: function initData(data, type) {
  3413. if (type === 'append') {
  3414. this.options.data = this.options.data.concat(data);
  3415. } else if (type === 'prepend') {
  3416. this.options.data = [].concat(data).concat(this.options.data);
  3417. } else {
  3418. this.options.data = data || this.options.data;
  3419. }
  3420. this.data = this.options.data;
  3421. if (this.options.sidePagination === 'server') {
  3422. return;
  3423. }
  3424. this.initSort();
  3425. }
  3426. }, {
  3427. key: "initSort",
  3428. value: function initSort() {
  3429. var _this3 = this;
  3430. var name = this.options.sortName;
  3431. var order = this.options.sortOrder === 'desc' ? -1 : 1;
  3432. var index = this.header.fields.indexOf(this.options.sortName);
  3433. var timeoutId = 0;
  3434. if (index !== -1) {
  3435. if (this.options.sortStable) {
  3436. this.data.forEach(function (row, i) {
  3437. if (!row.hasOwnProperty('_position')) {
  3438. row._position = i;
  3439. }
  3440. });
  3441. }
  3442. if (this.options.customSort) {
  3443. Utils.calculateObjectValue(this.options, this.options.customSort, [this.options.sortName, this.options.sortOrder, this.data]);
  3444. } else {
  3445. this.data.sort(function (a, b) {
  3446. if (_this3.header.sortNames[index]) {
  3447. name = _this3.header.sortNames[index];
  3448. }
  3449. var aa = Utils.getItemField(a, name, _this3.options.escape);
  3450. var bb = Utils.getItemField(b, name, _this3.options.escape);
  3451. var value = Utils.calculateObjectValue(_this3.header, _this3.header.sorters[index], [aa, bb, a, b]);
  3452. if (value !== undefined) {
  3453. if (_this3.options.sortStable && value === 0) {
  3454. return order * (a._position - b._position);
  3455. }
  3456. return order * value;
  3457. }
  3458. return Utils.sort(aa, bb, order, _this3.options.sortStable);
  3459. });
  3460. }
  3461. if (this.options.sortClass !== undefined) {
  3462. clearTimeout(timeoutId);
  3463. timeoutId = setTimeout(function () {
  3464. _this3.$el.removeClass(_this3.options.sortClass);
  3465. var index = _this3.$header.find("[data-field=\"".concat(_this3.options.sortName, "\"]")).index();
  3466. _this3.$el.find("tr td:nth-child(".concat(index + 1, ")")).addClass(_this3.options.sortClass);
  3467. }, 250);
  3468. }
  3469. }
  3470. }
  3471. }, {
  3472. key: "onSort",
  3473. value: function onSort(_ref2) {
  3474. var type = _ref2.type,
  3475. currentTarget = _ref2.currentTarget;
  3476. var $this = type === 'keypress' ? $(currentTarget) : $(currentTarget).parent();
  3477. var $this_ = this.$header.find('th').eq($this.index());
  3478. this.$header.add(this.$header_).find('span.order').remove();
  3479. if (this.options.sortName === $this.data('field')) {
  3480. this.options.sortOrder = this.options.sortOrder === 'asc' ? 'desc' : 'asc';
  3481. } else {
  3482. this.options.sortName = $this.data('field');
  3483. if (this.options.rememberOrder) {
  3484. this.options.sortOrder = $this.data('order') === 'asc' ? 'desc' : 'asc';
  3485. } else {
  3486. this.options.sortOrder = this.columns[this.fieldsColumnsIndex[$this.data('field')]].sortOrder || this.columns[this.fieldsColumnsIndex[$this.data('field')]].order;
  3487. }
  3488. }
  3489. this.trigger('sort', this.options.sortName, this.options.sortOrder);
  3490. $this.add($this_).data('order', this.options.sortOrder); // Assign the correct sortable arrow
  3491. this.getCaret();
  3492. if (this.options.sidePagination === 'server') {
  3493. this.options.pageNumber = 1;
  3494. this.initServer(this.options.silentSort);
  3495. return;
  3496. }
  3497. this.initSort();
  3498. this.initBody();
  3499. }
  3500. }, {
  3501. key: "initToolbar",
  3502. value: function initToolbar() {
  3503. var _this4 = this;
  3504. var o = this.options;
  3505. var html = [];
  3506. var timeoutId = 0;
  3507. var $keepOpen;
  3508. var $search;
  3509. var switchableCount = 0;
  3510. if (this.$toolbar.find('.bs-bars').children().length) {
  3511. $('body').append($(o.toolbar));
  3512. }
  3513. this.$toolbar.html('');
  3514. if (typeof o.toolbar === 'string' || _typeof(o.toolbar) === 'object') {
  3515. $(Utils.sprintf('<div class="bs-bars %s-%s"></div>', this.constants.classes.pull, o.toolbarAlign)).appendTo(this.$toolbar).append($(o.toolbar));
  3516. } // showColumns, showToggle, showRefresh
  3517. html = ["<div class=\"".concat(['columns', "columns-".concat(o.buttonsAlign), this.constants.classes.buttonsGroup, "".concat(this.constants.classes.pull, "-").concat(o.buttonsAlign)].join(' '), "\">")];
  3518. if (typeof o.icons === 'string') {
  3519. o.icons = Utils.calculateObjectValue(null, o.icons);
  3520. }
  3521. if (o.showPaginationSwitch) {
  3522. html.push("<button class=\"".concat(this.constants.buttonsClass, "\" type=\"button\" name=\"paginationSwitch\"\n aria-label=\"Pagination Switch\" title=\"").concat(o.formatPaginationSwitch(), "\">\n ").concat(o.showButtonIcons ? Utils.sprintf(this.constants.html.icon, o.iconsPrefix, o.icons.paginationSwitchDown) : '', "\n ").concat(o.showButtonText ? o.formatPaginationSwitchUp() : '', "\n </button>"));
  3523. }
  3524. if (o.showRefresh) {
  3525. html.push("<button class=\"".concat(this.constants.buttonsClass, "\" type=\"button\" name=\"refresh\"\n aria-label=\"Refresh\" title=\"").concat(o.formatRefresh(), "\">\n ").concat(o.showButtonIcons ? Utils.sprintf(this.constants.html.icon, o.iconsPrefix, o.icons.refresh) : '', "\n ").concat(o.showButtonText ? o.formatRefresh() : '', "\n </button>"));
  3526. }
  3527. if (o.showToggle) {
  3528. html.push("<button class=\"".concat(this.constants.buttonsClass, "\" type=\"button\" name=\"toggle\"\n aria-label=\"Toggle\" title=\"").concat(o.formatToggle(), "\">\n ").concat(o.showButtonIcons ? Utils.sprintf(this.constants.html.icon, o.iconsPrefix, o.icons.toggleOff) : '', "\n ").concat(o.showButtonText ? o.formatToggleOn() : '', "\n </button>"));
  3529. }
  3530. if (o.showFullscreen) {
  3531. html.push("<button class=\"".concat(this.constants.buttonsClass, "\" type=\"button\" name=\"fullscreen\"\n aria-label=\"Fullscreen\" title=\"").concat(o.formatFullscreen(), "\">\n ").concat(o.showButtonIcons ? Utils.sprintf(this.constants.html.icon, o.iconsPrefix, o.icons.fullscreen) : '', "\n ").concat(o.showButtonText ? o.formatFullscreen() : '', "\n </button>"));
  3532. }
  3533. if (o.showColumns) {
  3534. html.push("<div class=\"keep-open ".concat(this.constants.classes.buttonsDropdown, "\" title=\"").concat(o.formatColumns(), "\">\n <button class=\"").concat(this.constants.buttonsClass, " dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\"\n aria-label=\"Columns\" title=\"").concat(o.formatColumns(), "\">\n ").concat(o.showButtonIcons ? Utils.sprintf(this.constants.html.icon, o.iconsPrefix, o.icons.columns) : '', "\n ").concat(o.showButtonText ? o.formatColumns() : '', "\n ").concat(this.constants.html.dropdownCaret, "\n </button>\n ").concat(this.constants.html.toolbarDropdown[0]));
  3535. if (o.showColumnsToggleAll) {
  3536. var allFieldsVisible = this.getVisibleColumns().length === this.columns.length;
  3537. html.push(Utils.sprintf(this.constants.html.toolbarDropdownItem, Utils.sprintf('<input type="checkbox" class="toggle-all" %s> <span>%s</span>', allFieldsVisible ? 'checked="checked"' : '', o.formatColumnsToggleAll())));
  3538. html.push(this.constants.html.toolbarDropdownSeperator);
  3539. }
  3540. this.columns.forEach(function (column, i) {
  3541. if (column.radio || column.checkbox) {
  3542. return;
  3543. }
  3544. if (o.cardView && !column.cardVisible) {
  3545. return;
  3546. }
  3547. var checked = column.visible ? ' checked="checked"' : '';
  3548. if (column.switchable) {
  3549. html.push(Utils.sprintf(_this4.constants.html.toolbarDropdownItem, Utils.sprintf('<input type="checkbox" data-field="%s" value="%s"%s> <span>%s</span>', column.field, i, checked, column.title)));
  3550. switchableCount++;
  3551. }
  3552. });
  3553. html.push(this.constants.html.toolbarDropdown[1], '</div>');
  3554. }
  3555. html.push('</div>'); // Fix #188: this.showToolbar is for extensions
  3556. if (this.showToolbar || html.length > 2) {
  3557. this.$toolbar.append(html.join(''));
  3558. }
  3559. if (o.showPaginationSwitch) {
  3560. this.$toolbar.find('button[name="paginationSwitch"]').off('click').on('click', function () {
  3561. return _this4.togglePagination();
  3562. });
  3563. }
  3564. if (o.showFullscreen) {
  3565. this.$toolbar.find('button[name="fullscreen"]').off('click').on('click', function () {
  3566. return _this4.toggleFullscreen();
  3567. });
  3568. }
  3569. if (o.showRefresh) {
  3570. this.$toolbar.find('button[name="refresh"]').off('click').on('click', function () {
  3571. return _this4.refresh();
  3572. });
  3573. }
  3574. if (o.showToggle) {
  3575. this.$toolbar.find('button[name="toggle"]').off('click').on('click', function () {
  3576. _this4.toggleView();
  3577. });
  3578. }
  3579. if (o.showColumns) {
  3580. $keepOpen = this.$toolbar.find('.keep-open');
  3581. var $checkboxes = $keepOpen.find('input:not(".toggle-all")');
  3582. var $toggleAll = $keepOpen.find('input.toggle-all');
  3583. if (switchableCount <= o.minimumCountColumns) {
  3584. $keepOpen.find('input').prop('disabled', true);
  3585. }
  3586. $keepOpen.find('li, label').off('click').on('click', function (e) {
  3587. e.stopImmediatePropagation();
  3588. });
  3589. $checkboxes.off('click').on('click', function (_ref3) {
  3590. var currentTarget = _ref3.currentTarget;
  3591. var $this = $(currentTarget);
  3592. _this4._toggleColumn($this.val(), $this.prop('checked'), false);
  3593. _this4.trigger('column-switch', $this.data('field'), $this.prop('checked'));
  3594. $toggleAll.prop('checked', $checkboxes.filter(':checked').length === _this4.columns.length);
  3595. });
  3596. $toggleAll.off('click').on('click', function (_ref4) {
  3597. var currentTarget = _ref4.currentTarget;
  3598. _this4._toggleAllColumns($(currentTarget).prop('checked'));
  3599. });
  3600. }
  3601. if (o.search) {
  3602. html = [];
  3603. var showSearchButton = Utils.sprintf(this.constants.html.searchButton, o.formatSearch(), o.showButtonIcons ? Utils.sprintf(this.constants.html.icon, o.iconsPrefix, o.icons.search) : '', o.showButtonText ? o.formatSearch() : '');
  3604. var showSearchClearButton = Utils.sprintf(this.constants.html.searchClearButton, o.formatClearSearch(), o.showButtonIcons ? Utils.sprintf(this.constants.html.icon, o.iconsPrefix, o.icons.clearSearch) : '', o.showButtonText ? o.formatClearSearch() : '');
  3605. var searchInputHtml = "<input class=\"".concat(this.constants.classes.input).concat(Utils.sprintf(' input-%s', o.iconSize), " search-input\" type=\"text\" placeholder=\"").concat(o.formatSearch(), "\">");
  3606. var searchInputFinalHtml = searchInputHtml;
  3607. if (o.showSearchButton || o.showSearchClearButton) {
  3608. searchInputFinalHtml = Utils.sprintf(this.constants.html.inputGroup, searchInputHtml, (o.showSearchButton ? showSearchButton : '') + (o.showSearchClearButton ? showSearchClearButton : ''));
  3609. }
  3610. html.push(Utils.sprintf("\n <div class=\"".concat(this.constants.classes.pull, "-").concat(o.searchAlign, " search ").concat(this.constants.classes.inputGroup, "\">\n %s\n </div>\n "), searchInputFinalHtml));
  3611. this.$toolbar.append(html.join(''));
  3612. var $searchInput = this.$toolbar.find('.search input');
  3613. $search = o.showSearchButton ? this.$toolbar.find('.search button[name=search]') : $searchInput;
  3614. var eventTriggers = o.showSearchButton ? 'click' : 'keyup drop blur';
  3615. $search.off(eventTriggers).on(eventTriggers, function (event) {
  3616. if (o.searchOnEnterKey && event.keyCode !== 13) {
  3617. return;
  3618. }
  3619. if ([37, 38, 39, 40].includes(event.keyCode)) {
  3620. return;
  3621. }
  3622. clearTimeout(timeoutId); // doesn't matter if it's 0
  3623. timeoutId = setTimeout(function () {
  3624. _this4.onSearch(o.showSearchButton ? {
  3625. currentTarget: $searchInput
  3626. } : event);
  3627. }, o.searchTimeOut);
  3628. });
  3629. if (o.showSearchClearButton) {
  3630. this.$toolbar.find('.search button[name=clearSearch]').click(function () {
  3631. _this4.resetSearch();
  3632. _this4.onSearch({
  3633. currentTarget: _this4.$toolbar.find('.search input')
  3634. });
  3635. });
  3636. }
  3637. if (Utils.isIEBrowser()) {
  3638. $search.off('mouseup').on('mouseup', function (event) {
  3639. clearTimeout(timeoutId); // doesn't matter if it's 0
  3640. timeoutId = setTimeout(function () {
  3641. _this4.onSearch(event);
  3642. }, o.searchTimeOut);
  3643. });
  3644. }
  3645. }
  3646. }
  3647. }, {
  3648. key: "onSearch",
  3649. value: function onSearch() {
  3650. var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  3651. currentTarget = _ref5.currentTarget,
  3652. firedByInitSearchText = _ref5.firedByInitSearchText;
  3653. var overwriteSearchText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  3654. if (currentTarget !== undefined && overwriteSearchText) {
  3655. var text = $(currentTarget).val().trim();
  3656. if (this.options.trimOnSearch && $(currentTarget).val() !== text) {
  3657. $(currentTarget).val(text);
  3658. }
  3659. if (this.searchText === text) {
  3660. return;
  3661. }
  3662. if ($(currentTarget).hasClass('search-input')) {
  3663. this.searchText = text;
  3664. this.options.searchText = text;
  3665. }
  3666. }
  3667. if (!firedByInitSearchText) {
  3668. this.options.pageNumber = 1;
  3669. }
  3670. this.initSearch();
  3671. if (firedByInitSearchText) {
  3672. if (this.options.sidePagination === 'client') {
  3673. this.updatePagination();
  3674. }
  3675. } else {
  3676. this.updatePagination();
  3677. }
  3678. this.trigger('search', this.searchText);
  3679. }
  3680. }, {
  3681. key: "initSearch",
  3682. value: function initSearch() {
  3683. var _this5 = this;
  3684. this.filterOptions = this.filterOptions || this.options.filterOptions;
  3685. if (this.options.sidePagination !== 'server') {
  3686. if (this.options.customSearch) {
  3687. this.data = Utils.calculateObjectValue(this.options, this.options.customSearch, [this.options.data, this.searchText]);
  3688. return;
  3689. }
  3690. var s = this.searchText && (this.options.escape ? Utils.escapeHTML(this.searchText) : this.searchText).toLowerCase();
  3691. var f = Utils.isEmptyObject(this.filterColumns) ? null : this.filterColumns; // Check filter
  3692. if (typeof this.filterOptions.filterAlgorithm === 'function') {
  3693. this.data = this.options.data.filter(function (item, i) {
  3694. return _this5.filterOptions.filterAlgorithm.apply(null, [item, f]);
  3695. });
  3696. } else if (typeof this.filterOptions.filterAlgorithm === 'string') {
  3697. this.data = f ? this.options.data.filter(function (item, i) {
  3698. var filterAlgorithm = _this5.filterOptions.filterAlgorithm;
  3699. if (filterAlgorithm === 'and') {
  3700. for (var key in f) {
  3701. if (Array.isArray(f[key]) && !f[key].includes(item[key]) || !Array.isArray(f[key]) && item[key] !== f[key]) {
  3702. return false;
  3703. }
  3704. }
  3705. } else if (filterAlgorithm === 'or') {
  3706. var match = false;
  3707. for (var _key in f) {
  3708. if (Array.isArray(f[_key]) && f[_key].includes(item[_key]) || !Array.isArray(f[_key]) && item[_key] === f[_key]) {
  3709. match = true;
  3710. }
  3711. }
  3712. return match;
  3713. }
  3714. return true;
  3715. }) : this.options.data;
  3716. }
  3717. var visibleFields = this.getVisibleFields();
  3718. this.data = s ? this.data.filter(function (item, i) {
  3719. for (var j = 0; j < _this5.header.fields.length; j++) {
  3720. if (!_this5.header.searchables[j] || _this5.options.visibleSearch && visibleFields.indexOf(_this5.header.fields[j]) === -1) {
  3721. continue;
  3722. }
  3723. var key = Utils.isNumeric(_this5.header.fields[j]) ? parseInt(_this5.header.fields[j], 10) : _this5.header.fields[j];
  3724. var column = _this5.columns[_this5.fieldsColumnsIndex[key]];
  3725. var value = void 0;
  3726. if (typeof key === 'string') {
  3727. value = item;
  3728. var props = key.split('.');
  3729. for (var _i = 0; _i < props.length; _i++) {
  3730. if (value[props[_i]] !== null) {
  3731. value = value[props[_i]];
  3732. }
  3733. }
  3734. } else {
  3735. value = item[key];
  3736. } // Fix #142: respect searchFormatter boolean
  3737. if (column && column.searchFormatter) {
  3738. value = Utils.calculateObjectValue(column, _this5.header.formatters[j], [value, item, i, column.field], value);
  3739. }
  3740. if (typeof value === 'string' || typeof value === 'number') {
  3741. if (_this5.options.strictSearch) {
  3742. if ("".concat(value).toLowerCase() === s) {
  3743. return true;
  3744. }
  3745. } else {
  3746. var largerSmallerEqualsRegex = /(?:(<=|=>|=<|>=|>|<)(?:\s+)?(\d+)?|(\d+)?(\s+)?(<=|=>|=<|>=|>|<))/gm;
  3747. var matches = largerSmallerEqualsRegex.exec(s);
  3748. var comparisonCheck = false;
  3749. if (matches) {
  3750. var operator = matches[1] || "".concat(matches[5], "l");
  3751. var comparisonValue = matches[2] || matches[3];
  3752. var int = parseInt(value, 10);
  3753. var comparisonInt = parseInt(comparisonValue, 10);
  3754. switch (operator) {
  3755. case '>':
  3756. case '<l':
  3757. comparisonCheck = int > comparisonInt;
  3758. break;
  3759. case '<':
  3760. case '>l':
  3761. comparisonCheck = int < comparisonInt;
  3762. break;
  3763. case '<=':
  3764. case '=<':
  3765. case '>=l':
  3766. case '=>l':
  3767. comparisonCheck = int <= comparisonInt;
  3768. break;
  3769. case '>=':
  3770. case '=>':
  3771. case '<=l':
  3772. case '=<l':
  3773. comparisonCheck = int >= comparisonInt;
  3774. break;
  3775. default:
  3776. break;
  3777. }
  3778. }
  3779. if (comparisonCheck || "".concat(value).toLowerCase().includes(s)) {
  3780. return true;
  3781. }
  3782. }
  3783. }
  3784. }
  3785. return false;
  3786. }) : this.data;
  3787. }
  3788. }
  3789. }, {
  3790. key: "initPagination",
  3791. value: function initPagination() {
  3792. var _this6 = this;
  3793. var o = this.options;
  3794. if (!o.pagination) {
  3795. this.$pagination.hide();
  3796. return;
  3797. }
  3798. this.$pagination.show();
  3799. var html = [];
  3800. var $allSelected = false;
  3801. var i;
  3802. var from;
  3803. var to;
  3804. var $pageList;
  3805. var $pre;
  3806. var $next;
  3807. var $number;
  3808. var data = this.getData({
  3809. includeHiddenRows: false
  3810. });
  3811. var pageList = o.pageList;
  3812. if (o.sidePagination !== 'server') {
  3813. o.totalRows = data.length;
  3814. }
  3815. this.totalPages = 0;
  3816. if (o.totalRows) {
  3817. if (o.pageSize === o.formatAllRows()) {
  3818. o.pageSize = o.totalRows;
  3819. $allSelected = true;
  3820. } else if (o.pageSize === o.totalRows) {
  3821. // Fix #667 Table with pagination,
  3822. // multiple pages and a search this matches to one page throws exception
  3823. var pageLst = typeof o.pageList === 'string' ? o.pageList.replace('[', '').replace(']', '').replace(/ /g, '').toLowerCase().split(',') : o.pageList;
  3824. if (pageLst.includes(o.formatAllRows().toLowerCase())) {
  3825. $allSelected = true;
  3826. }
  3827. }
  3828. this.totalPages = ~~((o.totalRows - 1) / o.pageSize) + 1;
  3829. o.totalPages = this.totalPages;
  3830. }
  3831. if (this.totalPages > 0 && o.pageNumber > this.totalPages) {
  3832. o.pageNumber = this.totalPages;
  3833. }
  3834. this.pageFrom = (o.pageNumber - 1) * o.pageSize + 1;
  3835. this.pageTo = o.pageNumber * o.pageSize;
  3836. if (this.pageTo > o.totalRows) {
  3837. this.pageTo = o.totalRows;
  3838. }
  3839. if (this.options.pagination && this.options.sidePagination !== 'server') {
  3840. this.options.totalNotFiltered = this.options.data.length;
  3841. }
  3842. if (!this.options.showExtendedPagination) {
  3843. this.options.totalNotFiltered = undefined;
  3844. }
  3845. var paginationInfo = o.onlyInfoPagination ? o.formatDetailPagination(o.totalRows) : o.formatShowingRows(this.pageFrom, this.pageTo, o.totalRows, o.totalNotFiltered);
  3846. html.push("<div class=\"".concat(this.constants.classes.pull, "-").concat(o.paginationDetailHAlign, " pagination-detail\">\n <span class=\"pagination-info\">\n ").concat(paginationInfo, "\n </span>"));
  3847. if (!o.onlyInfoPagination) {
  3848. html.push('<span class="page-list">');
  3849. var pageNumber = ["<span class=\"".concat(this.constants.classes.paginationDropdown, "\">\n <button class=\"").concat(this.constants.buttonsClass, " dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\">\n <span class=\"page-size\">\n ").concat($allSelected ? o.formatAllRows() : o.pageSize, "\n </span>\n ").concat(this.constants.html.dropdownCaret, "\n </button>\n ").concat(this.constants.html.pageDropdown[0])];
  3850. if (typeof o.pageList === 'string') {
  3851. var list = o.pageList.replace('[', '').replace(']', '').replace(/ /g, '').split(',');
  3852. pageList = [];
  3853. var _iteratorNormalCompletion = true;
  3854. var _didIteratorError = false;
  3855. var _iteratorError = undefined;
  3856. try {
  3857. for (var _iterator = list[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  3858. var value = _step.value;
  3859. pageList.push(value.toLowerCase() === o.formatAllRows().toLowerCase() || ['all', 'unlimited'].includes(value.toLowerCase()) ? o.formatAllRows() : +value);
  3860. }
  3861. } catch (err) {
  3862. _didIteratorError = true;
  3863. _iteratorError = err;
  3864. } finally {
  3865. try {
  3866. if (!_iteratorNormalCompletion && _iterator.return != null) {
  3867. _iterator.return();
  3868. }
  3869. } finally {
  3870. if (_didIteratorError) {
  3871. throw _iteratorError;
  3872. }
  3873. }
  3874. }
  3875. }
  3876. pageList.forEach(function (page, i) {
  3877. if (!o.smartDisplay || i === 0 || pageList[i - 1] < o.totalRows) {
  3878. var active;
  3879. if ($allSelected) {
  3880. active = page === o.formatAllRows() ? _this6.constants.classes.dropdownActive : '';
  3881. } else {
  3882. active = page === o.pageSize ? _this6.constants.classes.dropdownActive : '';
  3883. }
  3884. pageNumber.push(Utils.sprintf(_this6.constants.html.pageDropdownItem, active, page));
  3885. }
  3886. });
  3887. pageNumber.push("".concat(this.constants.html.pageDropdown[1], "</span>"));
  3888. html.push(o.formatRecordsPerPage(pageNumber.join('')));
  3889. html.push('</span></div>');
  3890. html.push("<div class=\"".concat(this.constants.classes.pull, "-").concat(o.paginationHAlign, " pagination\">"), Utils.sprintf(this.constants.html.pagination[0], Utils.sprintf(' pagination-%s', o.iconSize)), Utils.sprintf(this.constants.html.paginationItem, ' page-pre', o.formatSRPaginationPreText(), o.paginationPreText));
  3891. if (this.totalPages < o.paginationSuccessivelySize) {
  3892. from = 1;
  3893. to = this.totalPages;
  3894. } else {
  3895. from = o.pageNumber - o.paginationPagesBySide;
  3896. to = from + o.paginationPagesBySide * 2;
  3897. }
  3898. if (o.pageNumber < o.paginationSuccessivelySize - 1) {
  3899. to = o.paginationSuccessivelySize;
  3900. }
  3901. if (o.paginationSuccessivelySize > this.totalPages - from) {
  3902. from = from - (o.paginationSuccessivelySize - (this.totalPages - from)) + 1;
  3903. }
  3904. if (from < 1) {
  3905. from = 1;
  3906. }
  3907. if (to > this.totalPages) {
  3908. to = this.totalPages;
  3909. }
  3910. var middleSize = Math.round(o.paginationPagesBySide / 2);
  3911. var pageItem = function pageItem(i) {
  3912. var classes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  3913. return Utils.sprintf(_this6.constants.html.paginationItem, classes + (i === o.pageNumber ? " ".concat(_this6.constants.classes.paginationActive) : ''), o.formatSRPaginationPageText(i), i);
  3914. };
  3915. if (from > 1) {
  3916. var max = o.paginationPagesBySide;
  3917. if (max >= from) max = from - 1;
  3918. for (i = 1; i <= max; i++) {
  3919. html.push(pageItem(i));
  3920. }
  3921. if (from - 1 === max + 1) {
  3922. i = from - 1;
  3923. html.push(pageItem(i));
  3924. } else {
  3925. if (from - 1 > max) {
  3926. if (from - o.paginationPagesBySide * 2 > o.paginationPagesBySide && o.paginationUseIntermediate) {
  3927. i = Math.round((from - middleSize) / 2 + middleSize);
  3928. html.push(pageItem(i, ' page-intermediate'));
  3929. } else {
  3930. html.push(Utils.sprintf(this.constants.html.paginationItem, ' page-first-separator disabled', '', '...'));
  3931. }
  3932. }
  3933. }
  3934. }
  3935. for (i = from; i <= to; i++) {
  3936. html.push(pageItem(i));
  3937. }
  3938. if (this.totalPages > to) {
  3939. var min = this.totalPages - (o.paginationPagesBySide - 1);
  3940. if (to >= min) min = to + 1;
  3941. if (to + 1 === min - 1) {
  3942. i = to + 1;
  3943. html.push(pageItem(i));
  3944. } else {
  3945. if (min > to + 1) {
  3946. if (this.totalPages - to > o.paginationPagesBySide * 2 && o.paginationUseIntermediate) {
  3947. i = Math.round((this.totalPages - middleSize - to) / 2 + to);
  3948. html.push(pageItem(i, ' page-intermediate'));
  3949. } else {
  3950. html.push(Utils.sprintf(this.constants.html.paginationItem, ' page-last-separator disabled', '', '...'));
  3951. }
  3952. }
  3953. }
  3954. for (i = min; i <= this.totalPages; i++) {
  3955. html.push(pageItem(i));
  3956. }
  3957. }
  3958. html.push(Utils.sprintf(this.constants.html.paginationItem, ' page-next', o.formatSRPaginationNextText(), o.paginationNextText));
  3959. html.push(this.constants.html.pagination[1], '</div>');
  3960. }
  3961. this.$pagination.html(html.join(''));
  3962. var dropupClass = ['bottom', 'both'].includes(o.paginationVAlign) ? " ".concat(this.constants.classes.dropup) : '';
  3963. this.$pagination.last().find('.page-list > span').addClass(dropupClass);
  3964. if (!o.onlyInfoPagination) {
  3965. $pageList = this.$pagination.find('.page-list a');
  3966. $pre = this.$pagination.find('.page-pre');
  3967. $next = this.$pagination.find('.page-next');
  3968. $number = this.$pagination.find('.page-item').not('.page-next, .page-pre, .page-last-separator, .page-first-separator');
  3969. if (this.totalPages <= 1) {
  3970. this.$pagination.find('div.pagination').hide();
  3971. }
  3972. if (o.smartDisplay) {
  3973. if (pageList.length < 2 || o.totalRows <= pageList[0]) {
  3974. this.$pagination.find('span.page-list').hide();
  3975. }
  3976. } // when data is empty, hide the pagination
  3977. this.$pagination[this.getData().length ? 'show' : 'hide']();
  3978. if (!o.paginationLoop) {
  3979. if (o.pageNumber === 1) {
  3980. $pre.addClass('disabled');
  3981. }
  3982. if (o.pageNumber === this.totalPages) {
  3983. $next.addClass('disabled');
  3984. }
  3985. }
  3986. if ($allSelected) {
  3987. o.pageSize = o.formatAllRows();
  3988. } // removed the events for last and first, onPageNumber executeds the same logic
  3989. $pageList.off('click').on('click', function (e) {
  3990. return _this6.onPageListChange(e);
  3991. });
  3992. $pre.off('click').on('click', function (e) {
  3993. return _this6.onPagePre(e);
  3994. });
  3995. $next.off('click').on('click', function (e) {
  3996. return _this6.onPageNext(e);
  3997. });
  3998. $number.off('click').on('click', function (e) {
  3999. return _this6.onPageNumber(e);
  4000. });
  4001. }
  4002. }
  4003. }, {
  4004. key: "updatePagination",
  4005. value: function updatePagination(event) {
  4006. // Fix #171: IE disabled button can be clicked bug.
  4007. if (event && $(event.currentTarget).hasClass('disabled')) {
  4008. return;
  4009. }
  4010. if (!this.options.maintainMetaData) {
  4011. this.resetRows();
  4012. }
  4013. this.initPagination();
  4014. if (this.options.sidePagination === 'server') {
  4015. this.initServer();
  4016. } else {
  4017. this.initBody();
  4018. }
  4019. this.trigger('page-change', this.options.pageNumber, this.options.pageSize);
  4020. }
  4021. }, {
  4022. key: "onPageListChange",
  4023. value: function onPageListChange(event) {
  4024. event.preventDefault();
  4025. var $this = $(event.currentTarget);
  4026. $this.parent().addClass(this.constants.classes.dropdownActive).siblings().removeClass(this.constants.classes.dropdownActive);
  4027. this.options.pageSize = $this.text().toUpperCase() === this.options.formatAllRows().toUpperCase() ? this.options.formatAllRows() : +$this.text();
  4028. this.$toolbar.find('.page-size').text(this.options.pageSize);
  4029. this.updatePagination(event);
  4030. return false;
  4031. }
  4032. }, {
  4033. key: "onPagePre",
  4034. value: function onPagePre(event) {
  4035. event.preventDefault();
  4036. if (this.options.pageNumber - 1 === 0) {
  4037. this.options.pageNumber = this.options.totalPages;
  4038. } else {
  4039. this.options.pageNumber--;
  4040. }
  4041. this.updatePagination(event);
  4042. return false;
  4043. }
  4044. }, {
  4045. key: "onPageNext",
  4046. value: function onPageNext(event) {
  4047. event.preventDefault();
  4048. if (this.options.pageNumber + 1 > this.options.totalPages) {
  4049. this.options.pageNumber = 1;
  4050. } else {
  4051. this.options.pageNumber++;
  4052. }
  4053. this.updatePagination(event);
  4054. return false;
  4055. }
  4056. }, {
  4057. key: "onPageNumber",
  4058. value: function onPageNumber(event) {
  4059. event.preventDefault();
  4060. if (this.options.pageNumber === +$(event.currentTarget).text()) {
  4061. return;
  4062. }
  4063. this.options.pageNumber = +$(event.currentTarget).text();
  4064. this.updatePagination(event);
  4065. return false;
  4066. }
  4067. }, {
  4068. key: "initRow",
  4069. value: function initRow(item, i, data, trFragments) {
  4070. var _this7 = this;
  4071. var html = [];
  4072. var style = {};
  4073. var csses = [];
  4074. var data_ = '';
  4075. var attributes = {};
  4076. var htmlAttributes = [];
  4077. if (Utils.findIndex(this.hiddenRows, item) > -1) {
  4078. return;
  4079. }
  4080. style = Utils.calculateObjectValue(this.options, this.options.rowStyle, [item, i], style);
  4081. if (style && style.css) {
  4082. for (var _i2 = 0, _Object$entries = Object.entries(style.css); _i2 < _Object$entries.length; _i2++) {
  4083. var _Object$entries$_i = _slicedToArray(_Object$entries[_i2], 2),
  4084. key = _Object$entries$_i[0],
  4085. value = _Object$entries$_i[1];
  4086. csses.push("".concat(key, ": ").concat(value));
  4087. }
  4088. }
  4089. attributes = Utils.calculateObjectValue(this.options, this.options.rowAttributes, [item, i], attributes);
  4090. if (attributes) {
  4091. for (var _i3 = 0, _Object$entries2 = Object.entries(attributes); _i3 < _Object$entries2.length; _i3++) {
  4092. var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i3], 2),
  4093. key = _Object$entries2$_i[0],
  4094. value = _Object$entries2$_i[1];
  4095. htmlAttributes.push("".concat(key, "=\"").concat(Utils.escapeHTML(value), "\""));
  4096. }
  4097. }
  4098. if (item._data && !Utils.isEmptyObject(item._data)) {
  4099. for (var _i4 = 0, _Object$entries3 = Object.entries(item._data); _i4 < _Object$entries3.length; _i4++) {
  4100. var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i4], 2),
  4101. k = _Object$entries3$_i[0],
  4102. v = _Object$entries3$_i[1];
  4103. // ignore data-index
  4104. if (k === 'index') {
  4105. return;
  4106. }
  4107. data_ += " data-".concat(k, "='").concat(_typeof(v) === 'object' ? JSON.stringify(v) : v, "'");
  4108. }
  4109. }
  4110. html.push('<tr', Utils.sprintf(' %s', htmlAttributes.length ? htmlAttributes.join(' ') : undefined), Utils.sprintf(' id="%s"', Array.isArray(item) ? undefined : item._id), Utils.sprintf(' class="%s"', style.classes || (Array.isArray(item) ? undefined : item._class)), " data-index=\"".concat(i, "\""), Utils.sprintf(' data-uniqueid="%s"', Utils.getItemField(item, this.options.uniqueId, false)), Utils.sprintf(' data-has-detail-view="%s"', !this.options.cardView && this.options.detailView && Utils.calculateObjectValue(null, this.options.detailFilter, [i, item]) ? 'true' : undefined), Utils.sprintf('%s', data_), '>');
  4111. if (this.options.cardView) {
  4112. html.push("<td colspan=\"".concat(this.header.fields.length, "\"><div class=\"card-views\">"));
  4113. }
  4114. if (!this.options.cardView && this.options.detailView && this.options.detailViewIcon) {
  4115. html.push('<td>');
  4116. if (Utils.calculateObjectValue(null, this.options.detailFilter, [i, item])) {
  4117. html.push("\n <a class=\"detail-icon\" href=\"#\">\n ".concat(Utils.sprintf(this.constants.html.icon, this.options.iconsPrefix, this.options.icons.detailOpen), "\n </a>\n "));
  4118. }
  4119. html.push('</td>');
  4120. }
  4121. this.header.fields.forEach(function (field, j) {
  4122. var text = '';
  4123. var value_ = Utils.getItemField(item, field, _this7.options.escape);
  4124. var value = '';
  4125. var type = '';
  4126. var cellStyle = {};
  4127. var id_ = '';
  4128. var class_ = _this7.header.classes[j];
  4129. var style_ = '';
  4130. var data_ = '';
  4131. var rowspan_ = '';
  4132. var colspan_ = '';
  4133. var title_ = '';
  4134. var column = _this7.columns[j];
  4135. if (_this7.fromHtml && typeof value_ === 'undefined') {
  4136. if (!column.checkbox && !column.radio) {
  4137. return;
  4138. }
  4139. }
  4140. if (!column.visible) {
  4141. return;
  4142. }
  4143. if (_this7.options.cardView && !column.cardVisible) {
  4144. return;
  4145. }
  4146. if (column.escape) {
  4147. value_ = Utils.escapeHTML(value_);
  4148. }
  4149. if (csses.concat([_this7.header.styles[j]]).length) {
  4150. style_ = " style=\"".concat(csses.concat([_this7.header.styles[j]]).join('; '), "\"");
  4151. } // handle td's id and class
  4152. if (item["_".concat(field, "_id")]) {
  4153. id_ = Utils.sprintf(' id="%s"', item["_".concat(field, "_id")]);
  4154. }
  4155. if (item["_".concat(field, "_class")]) {
  4156. class_ = Utils.sprintf(' class="%s"', item["_".concat(field, "_class")]);
  4157. }
  4158. if (item["_".concat(field, "_rowspan")]) {
  4159. rowspan_ = Utils.sprintf(' rowspan="%s"', item["_".concat(field, "_rowspan")]);
  4160. }
  4161. if (item["_".concat(field, "_colspan")]) {
  4162. colspan_ = Utils.sprintf(' colspan="%s"', item["_".concat(field, "_colspan")]);
  4163. }
  4164. if (item["_".concat(field, "_title")]) {
  4165. title_ = Utils.sprintf(' title="%s"', item["_".concat(field, "_title")]);
  4166. }
  4167. cellStyle = Utils.calculateObjectValue(_this7.header, _this7.header.cellStyles[j], [value_, item, i, field], cellStyle);
  4168. if (cellStyle.classes) {
  4169. class_ = " class=\"".concat(cellStyle.classes, "\"");
  4170. }
  4171. if (cellStyle.css) {
  4172. var csses_ = [];
  4173. for (var _i5 = 0, _Object$entries4 = Object.entries(cellStyle.css); _i5 < _Object$entries4.length; _i5++) {
  4174. var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i5], 2),
  4175. key = _Object$entries4$_i[0],
  4176. _value = _Object$entries4$_i[1];
  4177. csses_.push("".concat(key, ": ").concat(_value));
  4178. }
  4179. style_ = " style=\"".concat(csses_.concat(_this7.header.styles[j]).join('; '), "\"");
  4180. }
  4181. value = Utils.calculateObjectValue(column, _this7.header.formatters[j], [value_, item, i, field], value_);
  4182. if (item["_".concat(field, "_data")] && !Utils.isEmptyObject(item["_".concat(field, "_data")])) {
  4183. for (var _i6 = 0, _Object$entries5 = Object.entries(item["_".concat(field, "_data")]); _i6 < _Object$entries5.length; _i6++) {
  4184. var _Object$entries5$_i = _slicedToArray(_Object$entries5[_i6], 2),
  4185. k = _Object$entries5$_i[0],
  4186. v = _Object$entries5$_i[1];
  4187. // ignore data-index
  4188. if (k === 'index') {
  4189. return;
  4190. }
  4191. data_ += " data-".concat(k, "=\"").concat(v, "\"");
  4192. }
  4193. }
  4194. if (column.checkbox || column.radio) {
  4195. type = column.checkbox ? 'checkbox' : type;
  4196. type = column.radio ? 'radio' : type;
  4197. var c = column['class'] || '';
  4198. var isChecked = (value === true || value_ || value && value.checked) && value !== false;
  4199. var isDisabled = !column.checkboxEnabled || value && value.disabled;
  4200. text = [_this7.options.cardView ? "<div class=\"card-view ".concat(c, "\">") : "<td class=\"bs-checkbox ".concat(c, "\"").concat(class_).concat(style_, ">"), "<label>\n <input\n data-index=\"".concat(i, "\"\n name=\"").concat(_this7.options.selectItemName, "\"\n type=\"").concat(type, "\"\n ").concat(Utils.sprintf('value="%s"', item[_this7.options.idField]), "\n ").concat(Utils.sprintf('checked="%s"', isChecked ? 'checked' : undefined), "\n ").concat(Utils.sprintf('disabled="%s"', isDisabled ? 'disabled' : undefined), " />\n <span></span>\n </label>"), _this7.header.formatters[j] && typeof value === 'string' ? value : '', _this7.options.cardView ? '</div>' : '</td>'].join('');
  4201. item[_this7.header.stateField] = value === true || !!value_ || value && value.checked;
  4202. } else {
  4203. value = typeof value === 'undefined' || value === null ? _this7.options.undefinedText : value;
  4204. if (_this7.options.cardView) {
  4205. var cardTitle = _this7.options.showHeader ? "<span class=\"card-view-title\"".concat(style_, ">").concat(Utils.getFieldTitle(_this7.columns, field), "</span>") : '';
  4206. text = "<div class=\"card-view\">".concat(cardTitle, "<span class=\"card-view-value\">").concat(value, "</span></div>");
  4207. if (_this7.options.smartDisplay && value === '') {
  4208. text = '<div class="card-view"></div>';
  4209. }
  4210. } else {
  4211. text = "<td".concat(id_).concat(class_).concat(style_).concat(data_).concat(rowspan_).concat(colspan_).concat(title_, ">").concat(value, "</td>");
  4212. }
  4213. }
  4214. html.push(text);
  4215. });
  4216. if (this.options.cardView) {
  4217. html.push('</div></td>');
  4218. }
  4219. html.push('</tr>');
  4220. return html.join('');
  4221. }
  4222. }, {
  4223. key: "initBody",
  4224. value: function initBody(fixedScroll) {
  4225. var _this8 = this;
  4226. var data = this.getData();
  4227. this.trigger('pre-body', data);
  4228. this.$body = this.$el.find('>tbody');
  4229. if (!this.$body.length) {
  4230. this.$body = $('<tbody></tbody>').appendTo(this.$el);
  4231. } // Fix #389 Bootstrap-table-flatJSON is not working
  4232. if (!this.options.pagination || this.options.sidePagination === 'server') {
  4233. this.pageFrom = 1;
  4234. this.pageTo = data.length;
  4235. }
  4236. var rows = [];
  4237. var trFragments = $(document.createDocumentFragment());
  4238. var hasTr = false;
  4239. for (var i = this.pageFrom - 1; i < this.pageTo; i++) {
  4240. var item = data[i];
  4241. var tr = this.initRow(item, i, data, trFragments);
  4242. hasTr = hasTr || !!tr;
  4243. if (tr && typeof tr === 'string') {
  4244. if (this.virtualScrollDisabled) {
  4245. trFragments.append(tr);
  4246. } else {
  4247. rows.push(tr);
  4248. }
  4249. }
  4250. } // show no records
  4251. if (!hasTr) {
  4252. this.$body.html("<tr class=\"no-records-found\">".concat(Utils.sprintf('<td colspan="%s">%s</td>', this.$header.find('th').length, this.options.formatNoMatches()), "</tr>"));
  4253. } else {
  4254. if (this.virtualScrollDisabled) {
  4255. this.$body.html(trFragments);
  4256. } else {
  4257. if (this.virtualScroll) {
  4258. this.virtualScroll.destroy();
  4259. }
  4260. this.virtualScroll = new VirtualScroll({
  4261. rows: rows,
  4262. scrollEl: this.$tableBody[0],
  4263. contentEl: this.$body[0],
  4264. callback: function callback() {
  4265. _this8.fitHeader();
  4266. }
  4267. });
  4268. }
  4269. }
  4270. if (!fixedScroll) {
  4271. this.scrollTo(0);
  4272. } // click to select by column
  4273. this.$body.find('> tr[data-index] > td').off('click dblclick').on('click dblclick', function (e) {
  4274. var $td = $(e.currentTarget);
  4275. var $tr = $td.parent();
  4276. var $cardViewArr = $(e.target).parents('.card-views').children();
  4277. var $cardViewTarget = $(e.target).parents('.card-view');
  4278. var rowIndex = $tr.data('index');
  4279. var item = _this8.data[rowIndex];
  4280. var index = _this8.options.cardView ? $cardViewArr.index($cardViewTarget) : $td[0].cellIndex;
  4281. var fields = _this8.getVisibleFields();
  4282. var field = fields[_this8.options.detailView && !_this8.options.cardView ? index - 1 : index];
  4283. var column = _this8.columns[_this8.fieldsColumnsIndex[field]];
  4284. var value = Utils.getItemField(item, field, _this8.options.escape);
  4285. if ($td.find('.detail-icon').length) {
  4286. return;
  4287. }
  4288. _this8.trigger(e.type === 'click' ? 'click-cell' : 'dbl-click-cell', field, value, item, $td);
  4289. _this8.trigger(e.type === 'click' ? 'click-row' : 'dbl-click-row', item, $tr, field); // if click to select - then trigger the checkbox/radio click
  4290. if (e.type === 'click' && _this8.options.clickToSelect && column.clickToSelect && !Utils.calculateObjectValue(_this8.options, _this8.options.ignoreClickToSelectOn, [e.target])) {
  4291. var $selectItem = $tr.find(Utils.sprintf('[name="%s"]', _this8.options.selectItemName));
  4292. if ($selectItem.length) {
  4293. $selectItem[0].click();
  4294. }
  4295. }
  4296. if (e.type === 'click' && _this8.options.detailViewByClick) {
  4297. _this8.toggleDetailView(rowIndex, _this8.header.detailFormatters[index]);
  4298. }
  4299. }).off('mousedown').on('mousedown', function (e) {
  4300. // https://github.com/jquery/jquery/issues/1741
  4301. _this8.multipleSelectRowCtrlKey = e.ctrlKey || e.metaKey;
  4302. _this8.multipleSelectRowShiftKey = e.shiftKey;
  4303. });
  4304. this.$body.find('> tr[data-index] > td > .detail-icon').off('click').on('click', function (e) {
  4305. e.preventDefault();
  4306. _this8.toggleDetailView($(e.currentTarget).parent().parent().data('index'));
  4307. return false;
  4308. });
  4309. this.$selectItem = this.$body.find(Utils.sprintf('[name="%s"]', this.options.selectItemName));
  4310. this.$selectItem.off('click').on('click', function (e) {
  4311. e.stopImmediatePropagation();
  4312. var $this = $(e.currentTarget);
  4313. _this8._toggleCheck($this.prop('checked'), $this.data('index'));
  4314. });
  4315. this.header.events.forEach(function (_events, i) {
  4316. var events = _events;
  4317. if (!events) {
  4318. return;
  4319. } // fix bug, if events is defined with namespace
  4320. if (typeof events === 'string') {
  4321. events = Utils.calculateObjectValue(null, events);
  4322. }
  4323. var field = _this8.header.fields[i];
  4324. var fieldIndex = _this8.getVisibleFields().indexOf(field);
  4325. if (fieldIndex === -1) {
  4326. return;
  4327. }
  4328. if (_this8.options.detailView && !_this8.options.cardView) {
  4329. fieldIndex += 1;
  4330. }
  4331. var _loop = function _loop() {
  4332. var _Object$entries6$_i = _slicedToArray(_Object$entries6[_i7], 2),
  4333. key = _Object$entries6$_i[0],
  4334. event = _Object$entries6$_i[1];
  4335. _this8.$body.find('>tr:not(.no-records-found)').each(function (i, tr) {
  4336. var $tr = $(tr);
  4337. var $td = $tr.find(_this8.options.cardView ? '.card-view' : 'td').eq(fieldIndex);
  4338. var index = key.indexOf(' ');
  4339. var name = key.substring(0, index);
  4340. var el = key.substring(index + 1);
  4341. $td.find(el).off(name).on(name, function (e) {
  4342. var index = $tr.data('index');
  4343. var row = _this8.data[index];
  4344. var value = row[field];
  4345. event.apply(_this8, [e, value, row, index]);
  4346. });
  4347. });
  4348. };
  4349. for (var _i7 = 0, _Object$entries6 = Object.entries(events); _i7 < _Object$entries6.length; _i7++) {
  4350. _loop();
  4351. }
  4352. });
  4353. this.updateSelected();
  4354. this.initFooter();
  4355. this.resetView();
  4356. if (this.options.sidePagination !== 'server') {
  4357. this.options.totalRows = data.length;
  4358. }
  4359. this.trigger('post-body', data);
  4360. }
  4361. }, {
  4362. key: "initServer",
  4363. value: function initServer(silent, query, url) {
  4364. var _this9 = this;
  4365. var data = {};
  4366. var index = this.header.fields.indexOf(this.options.sortName);
  4367. var params = {
  4368. searchText: this.searchText,
  4369. sortName: this.options.sortName,
  4370. sortOrder: this.options.sortOrder
  4371. };
  4372. if (this.header.sortNames[index]) {
  4373. params.sortName = this.header.sortNames[index];
  4374. }
  4375. if (this.options.pagination && this.options.sidePagination === 'server') {
  4376. params.pageSize = this.options.pageSize === this.options.formatAllRows() ? this.options.totalRows : this.options.pageSize;
  4377. params.pageNumber = this.options.pageNumber;
  4378. }
  4379. if (!(url || this.options.url) && !this.options.ajax) {
  4380. return;
  4381. }
  4382. if (this.options.queryParamsType === 'limit') {
  4383. params = {
  4384. search: params.searchText,
  4385. sort: params.sortName,
  4386. order: params.sortOrder
  4387. };
  4388. if (this.options.pagination && this.options.sidePagination === 'server') {
  4389. params.offset = this.options.pageSize === this.options.formatAllRows() ? 0 : this.options.pageSize * (this.options.pageNumber - 1);
  4390. params.limit = this.options.pageSize === this.options.formatAllRows() ? this.options.totalRows : this.options.pageSize;
  4391. if (params.limit === 0) {
  4392. delete params.limit;
  4393. }
  4394. }
  4395. }
  4396. if (!Utils.isEmptyObject(this.filterColumnsPartial)) {
  4397. params.filter = JSON.stringify(this.filterColumnsPartial, null);
  4398. }
  4399. data = Utils.calculateObjectValue(this.options, this.options.queryParams, [params], data);
  4400. $.extend(data, query || {}); // false to stop request
  4401. if (data === false) {
  4402. return;
  4403. }
  4404. if (!silent) {
  4405. this.showLoading();
  4406. }
  4407. var request = $.extend({}, Utils.calculateObjectValue(null, this.options.ajaxOptions), {
  4408. type: this.options.method,
  4409. url: url || this.options.url,
  4410. data: this.options.contentType === 'application/json' && this.options.method === 'post' ? JSON.stringify(data) : data,
  4411. cache: this.options.cache,
  4412. contentType: this.options.contentType,
  4413. dataType: this.options.dataType,
  4414. success: function success(_res) {
  4415. var res = Utils.calculateObjectValue(_this9.options, _this9.options.responseHandler, [_res], _res);
  4416. _this9.load(res);
  4417. _this9.trigger('load-success', res);
  4418. if (!silent) {
  4419. _this9.hideLoading();
  4420. }
  4421. },
  4422. error: function error(jqXHR) {
  4423. var data = [];
  4424. if (_this9.options.sidePagination === 'server') {
  4425. data = {};
  4426. data[_this9.options.totalField] = 0;
  4427. data[_this9.options.dataField] = [];
  4428. }
  4429. _this9.load(data);
  4430. _this9.trigger('load-error', jqXHR.status, jqXHR);
  4431. if (!silent) _this9.$tableLoading.hide();
  4432. }
  4433. });
  4434. if (this.options.ajax) {
  4435. Utils.calculateObjectValue(this, this.options.ajax, [request], null);
  4436. } else {
  4437. if (this._xhr && this._xhr.readyState !== 4) {
  4438. this._xhr.abort();
  4439. }
  4440. this._xhr = $.ajax(request);
  4441. }
  4442. return data;
  4443. }
  4444. }, {
  4445. key: "initSearchText",
  4446. value: function initSearchText() {
  4447. if (this.options.search) {
  4448. this.searchText = '';
  4449. if (this.options.searchText !== '') {
  4450. var $search = this.$toolbar.find('.search input');
  4451. $search.val(this.options.searchText);
  4452. this.onSearch({
  4453. currentTarget: $search,
  4454. firedByInitSearchText: true
  4455. });
  4456. }
  4457. }
  4458. }
  4459. }, {
  4460. key: "getCaret",
  4461. value: function getCaret() {
  4462. var _this10 = this;
  4463. this.$header.find('th').each(function (i, th) {
  4464. $(th).find('.sortable').removeClass('desc asc').addClass($(th).data('field') === _this10.options.sortName ? _this10.options.sortOrder : 'both');
  4465. });
  4466. }
  4467. }, {
  4468. key: "updateSelected",
  4469. value: function updateSelected() {
  4470. var checkAll = this.$selectItem.filter(':enabled').length && this.$selectItem.filter(':enabled').length === this.$selectItem.filter(':enabled').filter(':checked').length;
  4471. this.$selectAll.add(this.$selectAll_).prop('checked', checkAll);
  4472. this.$selectItem.each(function (i, el) {
  4473. $(el).closest('tr')[$(el).prop('checked') ? 'addClass' : 'removeClass']('selected');
  4474. });
  4475. }
  4476. }, {
  4477. key: "updateRows",
  4478. value: function updateRows() {
  4479. var _this11 = this;
  4480. this.$selectItem.each(function (i, el) {
  4481. _this11.data[$(el).data('index')][_this11.header.stateField] = $(el).prop('checked');
  4482. });
  4483. }
  4484. }, {
  4485. key: "resetRows",
  4486. value: function resetRows() {
  4487. var _iteratorNormalCompletion2 = true;
  4488. var _didIteratorError2 = false;
  4489. var _iteratorError2 = undefined;
  4490. try {
  4491. for (var _iterator2 = this.data[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  4492. var row = _step2.value;
  4493. this.$selectAll.prop('checked', false);
  4494. this.$selectItem.prop('checked', false);
  4495. if (this.header.stateField) {
  4496. row[this.header.stateField] = false;
  4497. }
  4498. }
  4499. } catch (err) {
  4500. _didIteratorError2 = true;
  4501. _iteratorError2 = err;
  4502. } finally {
  4503. try {
  4504. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  4505. _iterator2.return();
  4506. }
  4507. } finally {
  4508. if (_didIteratorError2) {
  4509. throw _iteratorError2;
  4510. }
  4511. }
  4512. }
  4513. this.initHiddenRows();
  4514. }
  4515. }, {
  4516. key: "trigger",
  4517. value: function trigger(_name) {
  4518. var _this$options;
  4519. var name = "".concat(_name, ".bs.table");
  4520. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key2 = 1; _key2 < _len; _key2++) {
  4521. args[_key2 - 1] = arguments[_key2];
  4522. }
  4523. (_this$options = this.options)[BootstrapTable.EVENTS[name]].apply(_this$options, args);
  4524. this.$el.trigger($.Event(name), args);
  4525. this.options.onAll(name, args);
  4526. this.$el.trigger($.Event('all.bs.table'), [name, args]);
  4527. }
  4528. }, {
  4529. key: "resetHeader",
  4530. value: function resetHeader() {
  4531. var _this12 = this;
  4532. // fix #61: the hidden table reset header bug.
  4533. // fix bug: get $el.css('width') error sometime (height = 500)
  4534. clearTimeout(this.timeoutId_);
  4535. this.timeoutId_ = setTimeout(function () {
  4536. return _this12.fitHeader();
  4537. }, this.$el.is(':hidden') ? 100 : 0);
  4538. }
  4539. }, {
  4540. key: "fitHeader",
  4541. value: function fitHeader() {
  4542. var _this13 = this;
  4543. if (this.$el.is(':hidden')) {
  4544. this.timeoutId_ = setTimeout(function () {
  4545. return _this13.fitHeader();
  4546. }, 100);
  4547. return;
  4548. }
  4549. var fixedBody = this.$tableBody.get(0);
  4550. var scrollWidth = fixedBody.scrollWidth > fixedBody.clientWidth && fixedBody.scrollHeight > fixedBody.clientHeight + this.$header.outerHeight() ? Utils.getScrollBarWidth() : 0;
  4551. this.$el.css('margin-top', -this.$header.outerHeight());
  4552. var focused = $(':focus');
  4553. if (focused.length > 0) {
  4554. var $th = focused.parents('th');
  4555. if ($th.length > 0) {
  4556. var dataField = $th.attr('data-field');
  4557. if (dataField !== undefined) {
  4558. var $headerTh = this.$header.find("[data-field='".concat(dataField, "']"));
  4559. if ($headerTh.length > 0) {
  4560. $headerTh.find(':input').addClass('focus-temp');
  4561. }
  4562. }
  4563. }
  4564. }
  4565. this.$header_ = this.$header.clone(true, true);
  4566. this.$selectAll_ = this.$header_.find('[name="btSelectAll"]');
  4567. this.$tableHeader.css('margin-right', scrollWidth).find('table').css('width', this.$el.outerWidth()).html('').attr('class', this.$el.attr('class')).append(this.$header_);
  4568. this.$tableLoading.css('width', this.$el.outerWidth());
  4569. var focusedTemp = $('.focus-temp:visible:eq(0)');
  4570. if (focusedTemp.length > 0) {
  4571. focusedTemp.focus();
  4572. this.$header.find('.focus-temp').removeClass('focus-temp');
  4573. } // fix bug: $.data() is not working as expected after $.append()
  4574. this.$header.find('th[data-field]').each(function (i, el) {
  4575. _this13.$header_.find(Utils.sprintf('th[data-field="%s"]', $(el).data('field'))).data($(el).data());
  4576. });
  4577. var visibleFields = this.getVisibleFields();
  4578. var $ths = this.$header_.find('th');
  4579. var $tr = this.$body.find('>tr:not(.no-records-found,.virtual-scroll-top)').eq(0);
  4580. while ($tr.length && $tr.find('>td[colspan]:not([colspan="1"])').length) {
  4581. $tr = $tr.next();
  4582. }
  4583. $tr.find('> *').each(function (i, el) {
  4584. var $this = $(el);
  4585. var index = i;
  4586. if (_this13.options.detailView && _this13.options.detailViewIcon && !_this13.options.cardView) {
  4587. if (i === 0) {
  4588. var $thDetail = $ths.filter('.detail');
  4589. var _zoomWidth = $thDetail.width() - $thDetail.find('.fht-cell').width();
  4590. $thDetail.find('.fht-cell').width($this.innerWidth() - _zoomWidth);
  4591. }
  4592. index = i - 1;
  4593. }
  4594. if (index === -1) {
  4595. return;
  4596. }
  4597. var $th = _this13.$header_.find(Utils.sprintf('th[data-field="%s"]', visibleFields[index]));
  4598. if ($th.length > 1) {
  4599. $th = $($ths[$this[0].cellIndex]);
  4600. }
  4601. var zoomWidth = $th.width() - $th.find('.fht-cell').width();
  4602. $th.find('.fht-cell').width($this.innerWidth() - zoomWidth);
  4603. });
  4604. this.horizontalScroll();
  4605. this.trigger('post-header');
  4606. }
  4607. }, {
  4608. key: "initFooter",
  4609. value: function initFooter() {
  4610. if (!this.options.showFooter || this.options.cardView) {
  4611. // do nothing
  4612. return;
  4613. }
  4614. var data = this.getData();
  4615. var html = [];
  4616. if (!this.options.cardView && this.options.detailView && this.options.detailViewIcon) {
  4617. html.push('<th class="detail"><div class="th-inner"></div><div class="fht-cell"></div></th>');
  4618. }
  4619. var _iteratorNormalCompletion3 = true;
  4620. var _didIteratorError3 = false;
  4621. var _iteratorError3 = undefined;
  4622. try {
  4623. for (var _iterator3 = this.columns[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  4624. var column = _step3.value;
  4625. var falign = '';
  4626. var valign = '';
  4627. var csses = [];
  4628. var style = {};
  4629. var class_ = Utils.sprintf(' class="%s"', column['class']);
  4630. if (!column.visible) {
  4631. continue;
  4632. }
  4633. if (this.options.cardView && !column.cardVisible) {
  4634. return;
  4635. }
  4636. falign = Utils.sprintf('text-align: %s; ', column.falign ? column.falign : column.align);
  4637. valign = Utils.sprintf('vertical-align: %s; ', column.valign);
  4638. style = Utils.calculateObjectValue(null, this.options.footerStyle, [column]);
  4639. if (style && style.css) {
  4640. for (var _i8 = 0, _Object$entries7 = Object.entries(style.css); _i8 < _Object$entries7.length; _i8++) {
  4641. var _Object$entries7$_i = _slicedToArray(_Object$entries7[_i8], 2),
  4642. key = _Object$entries7$_i[0],
  4643. value = _Object$entries7$_i[1];
  4644. csses.push("".concat(key, ": ").concat(value));
  4645. }
  4646. }
  4647. if (style && style.classes) {
  4648. class_ = Utils.sprintf(' class="%s"', column['class'] ? [column['class'], style.classes].join(' ') : style.classes);
  4649. }
  4650. html.push('<th', class_, Utils.sprintf(' style="%s"', falign + valign + csses.concat().join('; ')), '>');
  4651. html.push('<div class="th-inner">');
  4652. html.push(Utils.calculateObjectValue(column, column.footerFormatter, [data], this.footerData[0] && this.footerData[0][column.field] || ''));
  4653. html.push('</div>');
  4654. html.push('<div class="fht-cell"></div>');
  4655. html.push('</div>');
  4656. html.push('</th>');
  4657. }
  4658. } catch (err) {
  4659. _didIteratorError3 = true;
  4660. _iteratorError3 = err;
  4661. } finally {
  4662. try {
  4663. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  4664. _iterator3.return();
  4665. }
  4666. } finally {
  4667. if (_didIteratorError3) {
  4668. throw _iteratorError3;
  4669. }
  4670. }
  4671. }
  4672. this.$tableFooter.find('tr').html(html.join(''));
  4673. this.trigger('post-footer', this.$tableFooter);
  4674. }
  4675. }, {
  4676. key: "fitFooter",
  4677. value: function fitFooter() {
  4678. var _this14 = this;
  4679. if (this.$el.is(':hidden')) {
  4680. setTimeout(function () {
  4681. return _this14.fitFooter();
  4682. }, 100);
  4683. return;
  4684. }
  4685. var fixedBody = this.$tableBody.get(0);
  4686. var scrollWidth = fixedBody.scrollWidth > fixedBody.clientWidth && fixedBody.scrollHeight > fixedBody.clientHeight + this.$header.outerHeight() ? Utils.getScrollBarWidth() : 0;
  4687. this.$tableFooter.css('margin-right', scrollWidth).find('table').css('width', this.$el.outerWidth()).attr('class', this.$el.attr('class'));
  4688. var visibleFields = this.getVisibleFields();
  4689. var $ths = this.$tableFooter.find('th');
  4690. var $tr = this.$body.find('>tr:first-child:not(.no-records-found)');
  4691. while ($tr.length && $tr.find('>td[colspan]:not([colspan="1"])').length) {
  4692. $tr = $tr.next();
  4693. }
  4694. $tr.find('> *').each(function (i, el) {
  4695. var $this = $(el);
  4696. var index = i;
  4697. if (_this14.options.detailView && !_this14.options.cardView) {
  4698. if (i === 0) {
  4699. var $thDetail = $ths.filter('.detail');
  4700. var _zoomWidth2 = $thDetail.width() - $thDetail.find('.fht-cell').width();
  4701. $thDetail.find('.fht-cell').width($this.innerWidth() - _zoomWidth2);
  4702. }
  4703. index = i - 1;
  4704. }
  4705. if (index === -1) {
  4706. return;
  4707. }
  4708. var $th = $ths.eq(i);
  4709. var zoomWidth = $th.width() - $th.find('.fht-cell').width();
  4710. $th.find('.fht-cell').width($this.innerWidth() - zoomWidth);
  4711. });
  4712. this.horizontalScroll();
  4713. }
  4714. }, {
  4715. key: "horizontalScroll",
  4716. value: function horizontalScroll() {
  4717. var _this15 = this;
  4718. // horizontal scroll event
  4719. // TODO: it's probably better improving the layout than binding to scroll event
  4720. this.trigger('scroll-body');
  4721. this.$tableBody.off('scroll').on('scroll', function (_ref6) {
  4722. var currentTarget = _ref6.currentTarget;
  4723. if (_this15.options.showHeader && _this15.options.height) {
  4724. _this15.$tableHeader.scrollLeft($(currentTarget).scrollLeft());
  4725. }
  4726. if (_this15.options.showFooter && !_this15.options.cardView) {
  4727. _this15.$tableFooter.scrollLeft($(currentTarget).scrollLeft());
  4728. }
  4729. });
  4730. }
  4731. }, {
  4732. key: "getVisibleFields",
  4733. value: function getVisibleFields() {
  4734. var visibleFields = [];
  4735. var _iteratorNormalCompletion4 = true;
  4736. var _didIteratorError4 = false;
  4737. var _iteratorError4 = undefined;
  4738. try {
  4739. for (var _iterator4 = this.header.fields[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  4740. var field = _step4.value;
  4741. var column = this.columns[this.fieldsColumnsIndex[field]];
  4742. if (!column.visible) {
  4743. continue;
  4744. }
  4745. visibleFields.push(field);
  4746. }
  4747. } catch (err) {
  4748. _didIteratorError4 = true;
  4749. _iteratorError4 = err;
  4750. } finally {
  4751. try {
  4752. if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
  4753. _iterator4.return();
  4754. }
  4755. } finally {
  4756. if (_didIteratorError4) {
  4757. throw _iteratorError4;
  4758. }
  4759. }
  4760. }
  4761. return visibleFields;
  4762. }
  4763. }, {
  4764. key: "initHiddenRows",
  4765. value: function initHiddenRows() {
  4766. this.hiddenRows = [];
  4767. } // PUBLIC FUNCTION DEFINITION
  4768. // =======================
  4769. }, {
  4770. key: "getOptions",
  4771. value: function getOptions() {
  4772. // deep copy and remove data
  4773. var options = JSON.parse(JSON.stringify(this.options));
  4774. delete options.data;
  4775. return options;
  4776. }
  4777. }, {
  4778. key: "refreshOptions",
  4779. value: function refreshOptions(options) {
  4780. // If the objects are equivalent then avoid the call of destroy / init methods
  4781. if (Utils.compareObjects(this.options, options, true)) {
  4782. return;
  4783. }
  4784. this.options = $.extend(this.options, options);
  4785. this.trigger('refresh-options', this.options);
  4786. this.destroy();
  4787. this.init();
  4788. }
  4789. }, {
  4790. key: "getData",
  4791. value: function getData(params) {
  4792. var data = this.options.data;
  4793. if (this.searchText || this.options.sortName || !Utils.isEmptyObject(this.filterColumns) || !Utils.isEmptyObject(this.filterColumnsPartial)) {
  4794. data = this.data;
  4795. }
  4796. if (params && params.useCurrentPage) {
  4797. data = data.slice(this.pageFrom - 1, this.pageTo);
  4798. }
  4799. if (params && !params.includeHiddenRows) {
  4800. var hiddenRows = this.getHiddenRows();
  4801. data = data.filter(function (row) {
  4802. return Utils.findIndex(hiddenRows, row) === -1;
  4803. });
  4804. }
  4805. return data;
  4806. }
  4807. }, {
  4808. key: "getSelections",
  4809. value: function getSelections() {
  4810. var _this16 = this;
  4811. // fix #2424: from html with checkbox
  4812. return this.data.filter(function (row) {
  4813. return row[_this16.header.stateField] === true;
  4814. });
  4815. }
  4816. }, {
  4817. key: "getAllSelections",
  4818. value: function getAllSelections() {
  4819. var _this17 = this;
  4820. return this.options.data.filter(function (row) {
  4821. return row[_this17.header.stateField] === true;
  4822. });
  4823. }
  4824. }, {
  4825. key: "load",
  4826. value: function load(_data) {
  4827. var fixedScroll = false;
  4828. var data = _data; // #431: support pagination
  4829. if (this.options.pagination && this.options.sidePagination === 'server') {
  4830. this.options.totalRows = data[this.options.totalField];
  4831. }
  4832. if (this.options.pagination && this.options.sidePagination === 'server') {
  4833. this.options.totalNotFiltered = data[this.options.totalNotFilteredField];
  4834. }
  4835. fixedScroll = data.fixedScroll;
  4836. data = Array.isArray(data) ? data : data[this.options.dataField];
  4837. this.initData(data);
  4838. this.initSearch();
  4839. this.initPagination();
  4840. this.initBody(fixedScroll);
  4841. }
  4842. }, {
  4843. key: "append",
  4844. value: function append(data) {
  4845. this.initData(data, 'append');
  4846. this.initSearch();
  4847. this.initPagination();
  4848. this.initSort();
  4849. this.initBody(true);
  4850. }
  4851. }, {
  4852. key: "prepend",
  4853. value: function prepend(data) {
  4854. this.initData(data, 'prepend');
  4855. this.initSearch();
  4856. this.initPagination();
  4857. this.initSort();
  4858. this.initBody(true);
  4859. }
  4860. }, {
  4861. key: "remove",
  4862. value: function remove(params) {
  4863. var len = this.options.data.length;
  4864. var i;
  4865. var row;
  4866. if (!params.hasOwnProperty('field') || !params.hasOwnProperty('values')) {
  4867. return;
  4868. }
  4869. for (i = len - 1; i >= 0; i--) {
  4870. row = this.options.data[i];
  4871. if (!row.hasOwnProperty(params.field)) {
  4872. continue;
  4873. }
  4874. if (params.values.includes(row[params.field])) {
  4875. this.options.data.splice(i, 1);
  4876. if (this.options.sidePagination === 'server') {
  4877. this.options.totalRows -= 1;
  4878. }
  4879. }
  4880. }
  4881. if (len === this.options.data.length) {
  4882. return;
  4883. }
  4884. this.initSearch();
  4885. this.initPagination();
  4886. this.initSort();
  4887. this.initBody(true);
  4888. }
  4889. }, {
  4890. key: "removeAll",
  4891. value: function removeAll() {
  4892. if (this.options.data.length > 0) {
  4893. this.options.data.splice(0, this.options.data.length);
  4894. this.initSearch();
  4895. this.initPagination();
  4896. this.initBody(true);
  4897. }
  4898. }
  4899. }, {
  4900. key: "insertRow",
  4901. value: function insertRow(params) {
  4902. if (!params.hasOwnProperty('index') || !params.hasOwnProperty('row')) {
  4903. return;
  4904. }
  4905. this.options.data.splice(params.index, 0, params.row);
  4906. this.initSearch();
  4907. this.initPagination();
  4908. this.initSort();
  4909. this.initBody(true);
  4910. }
  4911. }, {
  4912. key: "updateRow",
  4913. value: function updateRow(params) {
  4914. var allParams = Array.isArray(params) ? params : [params];
  4915. var _iteratorNormalCompletion5 = true;
  4916. var _didIteratorError5 = false;
  4917. var _iteratorError5 = undefined;
  4918. try {
  4919. for (var _iterator5 = allParams[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
  4920. var _params = _step5.value;
  4921. if (!_params.hasOwnProperty('index') || !_params.hasOwnProperty('row')) {
  4922. continue;
  4923. }
  4924. $.extend(this.options.data[_params.index], _params.row);
  4925. if (_params.hasOwnProperty('replace') && _params.replace) {
  4926. this.options.data[_params.index] = _params.row;
  4927. } else {
  4928. $.extend(this.options.data[_params.index], _params.row);
  4929. }
  4930. }
  4931. } catch (err) {
  4932. _didIteratorError5 = true;
  4933. _iteratorError5 = err;
  4934. } finally {
  4935. try {
  4936. if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
  4937. _iterator5.return();
  4938. }
  4939. } finally {
  4940. if (_didIteratorError5) {
  4941. throw _iteratorError5;
  4942. }
  4943. }
  4944. }
  4945. this.initSearch();
  4946. this.initPagination();
  4947. this.initSort();
  4948. this.initBody(true);
  4949. }
  4950. }, {
  4951. key: "getRowByUniqueId",
  4952. value: function getRowByUniqueId(_id) {
  4953. var uniqueId = this.options.uniqueId;
  4954. var len = this.options.data.length;
  4955. var id = _id;
  4956. var dataRow = null;
  4957. var i;
  4958. var row;
  4959. var rowUniqueId;
  4960. for (i = len - 1; i >= 0; i--) {
  4961. row = this.options.data[i];
  4962. if (row.hasOwnProperty(uniqueId)) {
  4963. // uniqueId is a column
  4964. rowUniqueId = row[uniqueId];
  4965. } else if (row._data && row._data.hasOwnProperty(uniqueId)) {
  4966. // uniqueId is a row data property
  4967. rowUniqueId = row._data[uniqueId];
  4968. } else {
  4969. continue;
  4970. }
  4971. if (typeof rowUniqueId === 'string') {
  4972. id = id.toString();
  4973. } else if (typeof rowUniqueId === 'number') {
  4974. if (Number(rowUniqueId) === rowUniqueId && rowUniqueId % 1 === 0) {
  4975. id = parseInt(id);
  4976. } else if (rowUniqueId === Number(rowUniqueId) && rowUniqueId !== 0) {
  4977. id = parseFloat(id);
  4978. }
  4979. }
  4980. if (rowUniqueId === id) {
  4981. dataRow = row;
  4982. break;
  4983. }
  4984. }
  4985. return dataRow;
  4986. }
  4987. }, {
  4988. key: "updateByUniqueId",
  4989. value: function updateByUniqueId(params) {
  4990. var allParams = Array.isArray(params) ? params : [params];
  4991. var _iteratorNormalCompletion6 = true;
  4992. var _didIteratorError6 = false;
  4993. var _iteratorError6 = undefined;
  4994. try {
  4995. for (var _iterator6 = allParams[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
  4996. var _params2 = _step6.value;
  4997. if (!_params2.hasOwnProperty('id') || !_params2.hasOwnProperty('row')) {
  4998. continue;
  4999. }
  5000. var rowId = this.options.data.indexOf(this.getRowByUniqueId(_params2.id));
  5001. if (rowId === -1) {
  5002. continue;
  5003. }
  5004. if (_params2.hasOwnProperty('replace') && _params2.replace) {
  5005. this.options.data[rowId] = _params2.row;
  5006. } else {
  5007. $.extend(this.options.data[rowId], _params2.row);
  5008. }
  5009. }
  5010. } catch (err) {
  5011. _didIteratorError6 = true;
  5012. _iteratorError6 = err;
  5013. } finally {
  5014. try {
  5015. if (!_iteratorNormalCompletion6 && _iterator6.return != null) {
  5016. _iterator6.return();
  5017. }
  5018. } finally {
  5019. if (_didIteratorError6) {
  5020. throw _iteratorError6;
  5021. }
  5022. }
  5023. }
  5024. this.initSearch();
  5025. this.initPagination();
  5026. this.initSort();
  5027. this.initBody(true);
  5028. }
  5029. }, {
  5030. key: "removeByUniqueId",
  5031. value: function removeByUniqueId(id) {
  5032. var len = this.options.data.length;
  5033. var row = this.getRowByUniqueId(id);
  5034. if (row) {
  5035. this.options.data.splice(this.options.data.indexOf(row), 1);
  5036. }
  5037. if (len === this.options.data.length) {
  5038. return;
  5039. }
  5040. this.initSearch();
  5041. this.initPagination();
  5042. this.initBody(true);
  5043. }
  5044. }, {
  5045. key: "updateCell",
  5046. value: function updateCell(params) {
  5047. if (!params.hasOwnProperty('index') || !params.hasOwnProperty('field') || !params.hasOwnProperty('value')) {
  5048. return;
  5049. }
  5050. this.data[params.index][params.field] = params.value;
  5051. if (params.reinit === false) {
  5052. return;
  5053. }
  5054. this.initSort();
  5055. this.initBody(true);
  5056. }
  5057. }, {
  5058. key: "updateCellByUniqueId",
  5059. value: function updateCellByUniqueId(params) {
  5060. var _this18 = this;
  5061. if (!params.hasOwnProperty('id') || !params.hasOwnProperty('field') || !params.hasOwnProperty('value')) {
  5062. return;
  5063. }
  5064. var allParams = Array.isArray(params) ? params : [params];
  5065. allParams.forEach(function (_ref7) {
  5066. var id = _ref7.id,
  5067. field = _ref7.field,
  5068. value = _ref7.value;
  5069. var rowId = _this18.options.data.indexOf(_this18.getRowByUniqueId(id));
  5070. if (rowId === -1) {
  5071. return;
  5072. }
  5073. _this18.data[rowId][field] = value;
  5074. });
  5075. if (params.reinit === false) {
  5076. return;
  5077. }
  5078. this.initSort();
  5079. this.initBody(true);
  5080. }
  5081. }, {
  5082. key: "showRow",
  5083. value: function showRow(params) {
  5084. this._toggleRow(params, true);
  5085. }
  5086. }, {
  5087. key: "hideRow",
  5088. value: function hideRow(params) {
  5089. this._toggleRow(params, false);
  5090. }
  5091. }, {
  5092. key: "_toggleRow",
  5093. value: function _toggleRow(params, visible) {
  5094. var row;
  5095. if (params.hasOwnProperty('index')) {
  5096. row = this.getData()[params.index];
  5097. } else if (params.hasOwnProperty('uniqueId')) {
  5098. row = this.getRowByUniqueId(params.uniqueId);
  5099. }
  5100. if (!row) {
  5101. return;
  5102. }
  5103. var index = Utils.findIndex(this.hiddenRows, row);
  5104. if (!visible && index === -1) {
  5105. this.hiddenRows.push(row);
  5106. } else if (visible && index > -1) {
  5107. this.hiddenRows.splice(index, 1);
  5108. }
  5109. if (visible) {
  5110. this.updatePagination();
  5111. } else {
  5112. this.initBody(true);
  5113. this.initPagination();
  5114. }
  5115. }
  5116. }, {
  5117. key: "getHiddenRows",
  5118. value: function getHiddenRows(show) {
  5119. if (show) {
  5120. this.initHiddenRows();
  5121. this.initBody(true);
  5122. return;
  5123. }
  5124. var data = this.getData();
  5125. var rows = [];
  5126. var _iteratorNormalCompletion7 = true;
  5127. var _didIteratorError7 = false;
  5128. var _iteratorError7 = undefined;
  5129. try {
  5130. for (var _iterator7 = data[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
  5131. var row = _step7.value;
  5132. if (this.hiddenRows.includes(row)) {
  5133. rows.push(row);
  5134. }
  5135. }
  5136. } catch (err) {
  5137. _didIteratorError7 = true;
  5138. _iteratorError7 = err;
  5139. } finally {
  5140. try {
  5141. if (!_iteratorNormalCompletion7 && _iterator7.return != null) {
  5142. _iterator7.return();
  5143. }
  5144. } finally {
  5145. if (_didIteratorError7) {
  5146. throw _iteratorError7;
  5147. }
  5148. }
  5149. }
  5150. this.hiddenRows = rows;
  5151. return rows;
  5152. }
  5153. }, {
  5154. key: "showColumn",
  5155. value: function showColumn(field) {
  5156. var _this19 = this;
  5157. var fields = Array.isArray(field) ? field : [field];
  5158. fields.forEach(function (field) {
  5159. _this19._toggleColumn(_this19.fieldsColumnsIndex[field], true, true);
  5160. });
  5161. }
  5162. }, {
  5163. key: "hideColumn",
  5164. value: function hideColumn(field) {
  5165. var _this20 = this;
  5166. var fields = Array.isArray(field) ? field : [field];
  5167. fields.forEach(function (field) {
  5168. _this20._toggleColumn(_this20.fieldsColumnsIndex[field], false, true);
  5169. });
  5170. }
  5171. }, {
  5172. key: "_toggleColumn",
  5173. value: function _toggleColumn(index, checked, needUpdate) {
  5174. if (index === -1 || this.columns[index].visible === checked) {
  5175. return;
  5176. }
  5177. this.columns[index].visible = checked;
  5178. this.initHeader();
  5179. this.initSearch();
  5180. this.initPagination();
  5181. this.initBody();
  5182. if (this.options.showColumns) {
  5183. var $items = this.$toolbar.find('.keep-open input').prop('disabled', false);
  5184. if (needUpdate) {
  5185. $items.filter(Utils.sprintf('[value="%s"]', index)).prop('checked', checked);
  5186. }
  5187. if ($items.filter(':checked').length <= this.options.minimumCountColumns) {
  5188. $items.filter(':checked').prop('disabled', true);
  5189. }
  5190. }
  5191. }
  5192. }, {
  5193. key: "getVisibleColumns",
  5194. value: function getVisibleColumns() {
  5195. return this.columns.filter(function (_ref8) {
  5196. var visible = _ref8.visible;
  5197. return visible;
  5198. });
  5199. }
  5200. }, {
  5201. key: "getHiddenColumns",
  5202. value: function getHiddenColumns() {
  5203. return this.columns.filter(function (_ref9) {
  5204. var visible = _ref9.visible;
  5205. return !visible;
  5206. });
  5207. }
  5208. }, {
  5209. key: "showAllColumns",
  5210. value: function showAllColumns() {
  5211. this._toggleAllColumns(true);
  5212. }
  5213. }, {
  5214. key: "hideAllColumns",
  5215. value: function hideAllColumns() {
  5216. this._toggleAllColumns(false);
  5217. }
  5218. }, {
  5219. key: "_toggleAllColumns",
  5220. value: function _toggleAllColumns(visible) {
  5221. var _this21 = this;
  5222. var _iteratorNormalCompletion8 = true;
  5223. var _didIteratorError8 = false;
  5224. var _iteratorError8 = undefined;
  5225. try {
  5226. for (var _iterator8 = this.columns.slice().reverse()[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
  5227. var column = _step8.value;
  5228. if (column.switchable) {
  5229. if (!visible && this.options.showColumns && this.getVisibleColumns().length === this.options.minimumCountColumns) {
  5230. continue;
  5231. }
  5232. column.visible = visible;
  5233. }
  5234. }
  5235. } catch (err) {
  5236. _didIteratorError8 = true;
  5237. _iteratorError8 = err;
  5238. } finally {
  5239. try {
  5240. if (!_iteratorNormalCompletion8 && _iterator8.return != null) {
  5241. _iterator8.return();
  5242. }
  5243. } finally {
  5244. if (_didIteratorError8) {
  5245. throw _iteratorError8;
  5246. }
  5247. }
  5248. }
  5249. this.initHeader();
  5250. this.initSearch();
  5251. this.initPagination();
  5252. this.initBody();
  5253. if (this.options.showColumns) {
  5254. var $items = this.$toolbar.find('.keep-open input:not(".toggle-all")').prop('disabled', false);
  5255. if (visible) {
  5256. $items.prop('checked', visible);
  5257. } else {
  5258. $items.get().reverse().forEach(function (item) {
  5259. if ($items.filter(':checked').length > _this21.options.minimumCountColumns) {
  5260. $(item).prop('checked', visible);
  5261. }
  5262. });
  5263. }
  5264. if ($items.filter(':checked').length <= this.options.minimumCountColumns) {
  5265. $items.filter(':checked').prop('disabled', true);
  5266. }
  5267. }
  5268. }
  5269. }, {
  5270. key: "mergeCells",
  5271. value: function mergeCells(options) {
  5272. var row = options.index;
  5273. var col = this.getVisibleFields().indexOf(options.field);
  5274. var rowspan = options.rowspan || 1;
  5275. var colspan = options.colspan || 1;
  5276. var i;
  5277. var j;
  5278. var $tr = this.$body.find('>tr');
  5279. if (this.options.detailView && !this.options.cardView) {
  5280. col += 1;
  5281. }
  5282. var $td = $tr.eq(row).find('>td').eq(col);
  5283. if (row < 0 || col < 0 || row >= this.data.length) {
  5284. return;
  5285. }
  5286. for (i = row; i < row + rowspan; i++) {
  5287. for (j = col; j < col + colspan; j++) {
  5288. $tr.eq(i).find('>td').eq(j).hide();
  5289. }
  5290. }
  5291. $td.attr('rowspan', rowspan).attr('colspan', colspan).show();
  5292. }
  5293. }, {
  5294. key: "checkAll",
  5295. value: function checkAll() {
  5296. this._toggleCheckAll(true);
  5297. }
  5298. }, {
  5299. key: "uncheckAll",
  5300. value: function uncheckAll() {
  5301. this._toggleCheckAll(false);
  5302. }
  5303. }, {
  5304. key: "_toggleCheckAll",
  5305. value: function _toggleCheckAll(checked) {
  5306. var rowsBefore = this.getSelections();
  5307. this.$selectAll.add(this.$selectAll_).prop('checked', checked);
  5308. this.$selectItem.filter(':enabled').prop('checked', checked);
  5309. this.updateRows();
  5310. var rowsAfter = this.getSelections();
  5311. if (checked) {
  5312. this.trigger('check-all', rowsAfter, rowsBefore);
  5313. return;
  5314. }
  5315. this.trigger('uncheck-all', rowsAfter, rowsBefore);
  5316. }
  5317. }, {
  5318. key: "checkInvert",
  5319. value: function checkInvert() {
  5320. var $items = this.$selectItem.filter(':enabled');
  5321. var checked = $items.filter(':checked');
  5322. $items.each(function (i, el) {
  5323. $(el).prop('checked', !$(el).prop('checked'));
  5324. });
  5325. this.updateRows();
  5326. this.updateSelected();
  5327. this.trigger('uncheck-some', checked);
  5328. checked = this.getSelections();
  5329. this.trigger('check-some', checked);
  5330. }
  5331. }, {
  5332. key: "check",
  5333. value: function check(index) {
  5334. this._toggleCheck(true, index);
  5335. }
  5336. }, {
  5337. key: "uncheck",
  5338. value: function uncheck(index) {
  5339. this._toggleCheck(false, index);
  5340. }
  5341. }, {
  5342. key: "_toggleCheck",
  5343. value: function _toggleCheck(checked, index) {
  5344. var $el = this.$selectItem.filter("[data-index=\"".concat(index, "\"]"));
  5345. var row = this.data[index];
  5346. if ($el.is(':radio') || this.options.singleSelect || this.options.multipleSelectRow && !this.multipleSelectRowCtrlKey && !this.multipleSelectRowShiftKey) {
  5347. var _iteratorNormalCompletion9 = true;
  5348. var _didIteratorError9 = false;
  5349. var _iteratorError9 = undefined;
  5350. try {
  5351. for (var _iterator9 = this.options.data[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
  5352. var r = _step9.value;
  5353. r[this.header.stateField] = false;
  5354. }
  5355. } catch (err) {
  5356. _didIteratorError9 = true;
  5357. _iteratorError9 = err;
  5358. } finally {
  5359. try {
  5360. if (!_iteratorNormalCompletion9 && _iterator9.return != null) {
  5361. _iterator9.return();
  5362. }
  5363. } finally {
  5364. if (_didIteratorError9) {
  5365. throw _iteratorError9;
  5366. }
  5367. }
  5368. }
  5369. this.$selectItem.filter(':checked').not($el).prop('checked', false);
  5370. }
  5371. row[this.header.stateField] = checked;
  5372. if (this.options.multipleSelectRow) {
  5373. if (this.multipleSelectRowShiftKey && this.multipleSelectRowLastSelectedIndex >= 0) {
  5374. var indexes = [this.multipleSelectRowLastSelectedIndex, index].sort();
  5375. for (var i = indexes[0] + 1; i < indexes[1]; i++) {
  5376. this.data[i][this.header.stateField] = true;
  5377. this.$selectItem.filter("[data-index=\"".concat(i, "\"]")).prop('checked', true);
  5378. }
  5379. }
  5380. this.multipleSelectRowCtrlKey = false;
  5381. this.multipleSelectRowShiftKey = false;
  5382. this.multipleSelectRowLastSelectedIndex = checked ? index : -1;
  5383. }
  5384. $el.prop('checked', checked);
  5385. this.updateSelected();
  5386. this.trigger(checked ? 'check' : 'uncheck', this.data[index], $el);
  5387. }
  5388. }, {
  5389. key: "checkBy",
  5390. value: function checkBy(obj) {
  5391. this._toggleCheckBy(true, obj);
  5392. }
  5393. }, {
  5394. key: "uncheckBy",
  5395. value: function uncheckBy(obj) {
  5396. this._toggleCheckBy(false, obj);
  5397. }
  5398. }, {
  5399. key: "_toggleCheckBy",
  5400. value: function _toggleCheckBy(checked, obj) {
  5401. var _this22 = this;
  5402. if (!obj.hasOwnProperty('field') || !obj.hasOwnProperty('values')) {
  5403. return;
  5404. }
  5405. var rows = [];
  5406. this.data.forEach(function (row, i) {
  5407. if (!row.hasOwnProperty(obj.field)) {
  5408. return false;
  5409. }
  5410. if (obj.values.includes(row[obj.field])) {
  5411. var $el = _this22.$selectItem.filter(':enabled').filter(Utils.sprintf('[data-index="%s"]', i)).prop('checked', checked);
  5412. row[_this22.header.stateField] = checked;
  5413. rows.push(row);
  5414. _this22.trigger(checked ? 'check' : 'uncheck', row, $el);
  5415. }
  5416. });
  5417. this.updateSelected();
  5418. this.trigger(checked ? 'check-some' : 'uncheck-some', rows);
  5419. }
  5420. }, {
  5421. key: "refresh",
  5422. value: function refresh(params) {
  5423. if (params && params.url) {
  5424. this.options.url = params.url;
  5425. }
  5426. if (params && params.pageNumber) {
  5427. this.options.pageNumber = params.pageNumber;
  5428. }
  5429. if (params && params.pageSize) {
  5430. this.options.pageSize = params.pageSize;
  5431. }
  5432. this.trigger('refresh', this.initServer(params && params.silent, params && params.query, params && params.url));
  5433. }
  5434. }, {
  5435. key: "destroy",
  5436. value: function destroy() {
  5437. this.$el.insertBefore(this.$container);
  5438. $(this.options.toolbar).insertBefore(this.$el);
  5439. this.$container.next().remove();
  5440. this.$container.remove();
  5441. this.$el.html(this.$el_.html()).css('margin-top', '0').attr('class', this.$el_.attr('class') || ''); // reset the class
  5442. }
  5443. }, {
  5444. key: "resetView",
  5445. value: function resetView(params) {
  5446. var padding = 0;
  5447. if (params && params.height) {
  5448. this.options.height = params.height;
  5449. }
  5450. this.$selectAll.prop('checked', this.$selectItem.length > 0 && this.$selectItem.length === this.$selectItem.filter(':checked').length);
  5451. this.$tableContainer.toggleClass('has-card-view', this.options.cardView);
  5452. if (!this.options.cardView && this.options.showHeader && this.options.height) {
  5453. this.$tableHeader.show();
  5454. this.resetHeader();
  5455. padding += this.$header.outerHeight(true);
  5456. } else {
  5457. this.$tableHeader.hide();
  5458. this.trigger('post-header');
  5459. }
  5460. if (!this.options.cardView && this.options.showFooter) {
  5461. this.$tableFooter.show();
  5462. this.fitFooter();
  5463. if (this.options.height) {
  5464. padding += this.$tableFooter.outerHeight(true);
  5465. }
  5466. }
  5467. if (this.options.height) {
  5468. var toolbarHeight = this.$toolbar.outerHeight(true);
  5469. var paginationHeight = this.$pagination.outerHeight(true);
  5470. var height = this.options.height - toolbarHeight - paginationHeight;
  5471. var tableHeight = this.$tableBody.find('table').outerHeight(true);
  5472. this.$tableContainer.css('height', "".concat(height, "px"));
  5473. this.$tableBorder && this.$tableBorder.css('height', "".concat(height - tableHeight - padding - 1, "px"));
  5474. }
  5475. if (this.options.cardView) {
  5476. // remove the element css
  5477. this.$el.css('margin-top', '0');
  5478. this.$tableContainer.css('padding-bottom', '0');
  5479. this.$tableFooter.hide();
  5480. } else {
  5481. // Assign the correct sortable arrow
  5482. this.getCaret();
  5483. this.$tableContainer.css('padding-bottom', "".concat(padding, "px"));
  5484. }
  5485. this.trigger('reset-view');
  5486. }
  5487. }, {
  5488. key: "resetWidth",
  5489. value: function resetWidth() {
  5490. if (this.options.showHeader && this.options.height) {
  5491. this.fitHeader();
  5492. }
  5493. if (this.options.showFooter && !this.options.cardView) {
  5494. this.fitFooter();
  5495. }
  5496. }
  5497. }, {
  5498. key: "showLoading",
  5499. value: function showLoading() {
  5500. this.$tableLoading.css('display', 'flex');
  5501. }
  5502. }, {
  5503. key: "hideLoading",
  5504. value: function hideLoading() {
  5505. this.$tableLoading.css('display', 'none');
  5506. }
  5507. }, {
  5508. key: "togglePagination",
  5509. value: function togglePagination() {
  5510. this.options.pagination = !this.options.pagination;
  5511. var icon = this.options.showButtonIcons ? this.options.pagination ? this.options.icons.paginationSwitchDown : this.options.icons.paginationSwitchUp : '';
  5512. var text = this.options.showButtonText ? this.options.pagination ? this.options.formatPaginationSwitchUp() : this.options.formatPaginationSwitchDown() : '';
  5513. this.$toolbar.find('button[name="paginationSwitch"]').html(Utils.sprintf(this.constants.html.icon, this.options.iconsPrefix, icon) + ' ' + text);
  5514. this.updatePagination();
  5515. }
  5516. }, {
  5517. key: "toggleFullscreen",
  5518. value: function toggleFullscreen() {
  5519. this.$el.closest('.bootstrap-table').toggleClass('fullscreen');
  5520. this.resetView();
  5521. }
  5522. }, {
  5523. key: "toggleView",
  5524. value: function toggleView() {
  5525. this.options.cardView = !this.options.cardView;
  5526. this.initHeader();
  5527. var icon = this.options.showButtonIcons ? this.options.cardView ? this.options.icons.toggleOn : this.options.icons.toggleOff : '';
  5528. var text = this.options.showButtonText ? this.options.cardView ? this.options.formatToggleOff() : this.options.formatToggleOn() : '';
  5529. this.$toolbar.find('button[name="toggle"]').html(Utils.sprintf(this.constants.html.icon, this.options.iconsPrefix, icon) + ' ' + text);
  5530. this.initBody();
  5531. this.trigger('toggle', this.options.cardView);
  5532. }
  5533. }, {
  5534. key: "resetSearch",
  5535. value: function resetSearch(text) {
  5536. var $search = this.$toolbar.find('.search input');
  5537. $search.val(text || '');
  5538. this.onSearch({
  5539. currentTarget: $search
  5540. });
  5541. }
  5542. }, {
  5543. key: "filterBy",
  5544. value: function filterBy(columns, options) {
  5545. this.filterOptions = Utils.isEmptyObject(options) ? this.options.filterOptions : $.extend(this.options.filterOptions, options);
  5546. this.filterColumns = Utils.isEmptyObject(columns) ? {} : columns;
  5547. this.options.pageNumber = 1;
  5548. this.initSearch();
  5549. this.updatePagination();
  5550. }
  5551. }, {
  5552. key: "scrollTo",
  5553. value: function scrollTo(params) {
  5554. if (typeof params === 'undefined') {
  5555. return this.$tableBody.scrollTop();
  5556. }
  5557. var options = {
  5558. unit: 'px',
  5559. value: 0
  5560. };
  5561. if (_typeof(params) === 'object') {
  5562. options = Object.assign(options, params);
  5563. } else if (typeof params === 'string' && params === 'bottom') {
  5564. options.value = this.$tableBody[0].scrollHeight;
  5565. } else if (typeof params === 'string') {
  5566. options.value = params;
  5567. }
  5568. var scrollTo = options.value;
  5569. if (options.unit === 'rows') {
  5570. scrollTo = 0;
  5571. this.$body.find("> tr:lt(".concat(options.value, ")")).each(function (i, el) {
  5572. scrollTo += $(el).outerHeight(true);
  5573. });
  5574. }
  5575. this.$tableBody.scrollTop(scrollTo);
  5576. }
  5577. }, {
  5578. key: "getScrollPosition",
  5579. value: function getScrollPosition() {
  5580. return this.scrollTo();
  5581. }
  5582. }, {
  5583. key: "selectPage",
  5584. value: function selectPage(page) {
  5585. if (page > 0 && page <= this.options.totalPages) {
  5586. this.options.pageNumber = page;
  5587. this.updatePagination();
  5588. }
  5589. }
  5590. }, {
  5591. key: "prevPage",
  5592. value: function prevPage() {
  5593. if (this.options.pageNumber > 1) {
  5594. this.options.pageNumber--;
  5595. this.updatePagination();
  5596. }
  5597. }
  5598. }, {
  5599. key: "nextPage",
  5600. value: function nextPage() {
  5601. if (this.options.pageNumber < this.options.totalPages) {
  5602. this.options.pageNumber++;
  5603. this.updatePagination();
  5604. }
  5605. }
  5606. }, {
  5607. key: "toggleDetailView",
  5608. value: function toggleDetailView(index, _columnDetailFormatter) {
  5609. var $tr = this.$body.find(Utils.sprintf('> tr[data-index="%s"]', index));
  5610. if ($tr.next().is('tr.detail-view')) {
  5611. this.collapseRow(index);
  5612. } else {
  5613. this.expandRow(index, _columnDetailFormatter);
  5614. }
  5615. this.resetView();
  5616. }
  5617. }, {
  5618. key: "expandRow",
  5619. value: function expandRow(index, _columnDetailFormatter) {
  5620. var row = this.data[index];
  5621. var $tr = this.$body.find(Utils.sprintf('> tr[data-index="%s"][data-has-detail-view]', index));
  5622. if ($tr.next().is('tr.detail-view')) {
  5623. return;
  5624. }
  5625. if (this.options.detailViewIcon) {
  5626. $tr.find('a.detail-icon').html(Utils.sprintf(this.constants.html.icon, this.options.iconsPrefix, this.options.icons.detailClose));
  5627. }
  5628. $tr.after(Utils.sprintf('<tr class="detail-view"><td colspan="%s"></td></tr>', $tr.children('td').length));
  5629. var $element = $tr.next().find('td');
  5630. var detailFormatter = _columnDetailFormatter || this.options.detailFormatter;
  5631. var content = Utils.calculateObjectValue(this.options, detailFormatter, [index, row, $element], '');
  5632. if ($element.length === 1) {
  5633. $element.append(content);
  5634. }
  5635. this.trigger('expand-row', index, row, $element);
  5636. }
  5637. }, {
  5638. key: "collapseRow",
  5639. value: function collapseRow(index) {
  5640. var row = this.data[index];
  5641. var $tr = this.$body.find(Utils.sprintf('> tr[data-index="%s"][data-has-detail-view]', index));
  5642. if (!$tr.next().is('tr.detail-view')) {
  5643. return;
  5644. }
  5645. if (this.options.detailViewIcon) {
  5646. $tr.find('a.detail-icon').html(Utils.sprintf(this.constants.html.icon, this.options.iconsPrefix, this.options.icons.detailOpen));
  5647. }
  5648. this.trigger('collapse-row', index, row, $tr.next());
  5649. $tr.next().remove();
  5650. }
  5651. }, {
  5652. key: "expandAllRows",
  5653. value: function expandAllRows() {
  5654. var trs = this.$body.find('> tr[data-index][data-has-detail-view]');
  5655. for (var i = 0; i < trs.length; i++) {
  5656. this.expandRow($(trs[i]).data('index'));
  5657. }
  5658. }
  5659. }, {
  5660. key: "collapseAllRows",
  5661. value: function collapseAllRows() {
  5662. var trs = this.$body.find('> tr[data-index][data-has-detail-view]');
  5663. for (var i = 0; i < trs.length; i++) {
  5664. this.collapseRow($(trs[i]).data('index'));
  5665. }
  5666. }
  5667. }, {
  5668. key: "updateColumnTitle",
  5669. value: function updateColumnTitle(params) {
  5670. if (!params.hasOwnProperty('field') || !params.hasOwnProperty('title')) {
  5671. return;
  5672. }
  5673. this.columns[this.fieldsColumnsIndex[params.field]].title = this.options.escape ? Utils.escapeHTML(params.title) : params.title;
  5674. if (this.columns[this.fieldsColumnsIndex[params.field]].visible) {
  5675. var header = this.options.height !== undefined ? this.$tableHeader : this.$header;
  5676. header.find('th[data-field]').each(function (i, el) {
  5677. if ($(el).data('field') === params.field) {
  5678. $($(el).find('.th-inner')[0]).text(params.title);
  5679. return false;
  5680. }
  5681. });
  5682. }
  5683. }
  5684. }, {
  5685. key: "updateFormatText",
  5686. value: function updateFormatText(formatName, text) {
  5687. if (!/^format/.test(formatName) || !this.options[formatName]) {
  5688. return;
  5689. }
  5690. if (typeof text === 'string') {
  5691. this.options[formatName] = function () {
  5692. return text;
  5693. };
  5694. } else if (typeof text === 'function') {
  5695. this.options[formatName] = text;
  5696. }
  5697. this.initToolbar();
  5698. this.initPagination();
  5699. this.initBody();
  5700. }
  5701. }]);
  5702. return BootstrapTable;
  5703. }();
  5704. BootstrapTable.VERSION = Constants.VERSION;
  5705. BootstrapTable.DEFAULTS = Constants.DEFAULTS;
  5706. BootstrapTable.LOCALES = Constants.LOCALES;
  5707. BootstrapTable.COLUMN_DEFAULTS = Constants.COLUMN_DEFAULTS;
  5708. BootstrapTable.METHODS = Constants.METHODS;
  5709. BootstrapTable.EVENTS = Constants.EVENTS; // BOOTSTRAP TABLE PLUGIN DEFINITION
  5710. // =======================
  5711. $.BootstrapTable = BootstrapTable;
  5712. $.fn.bootstrapTable = function (option) {
  5713. for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key3 = 1; _key3 < _len2; _key3++) {
  5714. args[_key3 - 1] = arguments[_key3];
  5715. }
  5716. var value;
  5717. this.each(function (i, el) {
  5718. var data = $(el).data('bootstrap.table');
  5719. var options = $.extend({}, BootstrapTable.DEFAULTS, $(el).data(), _typeof(option) === 'object' && option);
  5720. if (typeof option === 'string') {
  5721. var _data2;
  5722. if (!Constants.METHODS.includes(option)) {
  5723. throw new Error("Unknown method: ".concat(option));
  5724. }
  5725. if (!data) {
  5726. return;
  5727. }
  5728. value = (_data2 = data)[option].apply(_data2, args);
  5729. if (option === 'destroy') {
  5730. $(el).removeData('bootstrap.table');
  5731. }
  5732. }
  5733. if (!data) {
  5734. $(el).data('bootstrap.table', data = new $.BootstrapTable(el, options));
  5735. }
  5736. });
  5737. return typeof value === 'undefined' ? this : value;
  5738. };
  5739. $.fn.bootstrapTable.Constructor = BootstrapTable;
  5740. $.fn.bootstrapTable.theme = Constants.THEME;
  5741. $.fn.bootstrapTable.VERSION = Constants.VERSION;
  5742. $.fn.bootstrapTable.defaults = BootstrapTable.DEFAULTS;
  5743. $.fn.bootstrapTable.columnDefaults = BootstrapTable.COLUMN_DEFAULTS;
  5744. $.fn.bootstrapTable.events = BootstrapTable.EVENTS;
  5745. $.fn.bootstrapTable.locales = BootstrapTable.LOCALES;
  5746. $.fn.bootstrapTable.methods = BootstrapTable.METHODS;
  5747. $.fn.bootstrapTable.utils = Utils; // BOOTSTRAP TABLE INIT
  5748. // =======================
  5749. $(function () {
  5750. $('[data-toggle="table"]').bootstrapTable();
  5751. });
  5752. return BootstrapTable;
  5753. }));