bootstrap-table-filter-control.js 84 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('jquery')) :
  3. typeof define === 'function' && define.amd ? define(['jquery'], factory) :
  4. (global = global || self, factory(global.jQuery));
  5. }(this, function ($) { 'use strict';
  6. $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  7. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  8. function createCommonjsModule(fn, module) {
  9. return module = { exports: {} }, fn(module, module.exports), module.exports;
  10. }
  11. var O = 'object';
  12. var check = function (it) {
  13. return it && it.Math == Math && it;
  14. };
  15. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  16. var global_1 =
  17. // eslint-disable-next-line no-undef
  18. check(typeof globalThis == O && globalThis) ||
  19. check(typeof window == O && window) ||
  20. check(typeof self == O && self) ||
  21. check(typeof commonjsGlobal == O && commonjsGlobal) ||
  22. // eslint-disable-next-line no-new-func
  23. Function('return this')();
  24. var fails = function (exec) {
  25. try {
  26. return !!exec();
  27. } catch (error) {
  28. return true;
  29. }
  30. };
  31. // Thank's IE8 for his funny defineProperty
  32. var descriptors = !fails(function () {
  33. return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
  34. });
  35. var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
  36. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  37. // Nashorn ~ JDK8 bug
  38. var NASHORN_BUG = getOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);
  39. // `Object.prototype.propertyIsEnumerable` method implementation
  40. // https://tc39.github.io/ecma262/#sec-object.prototype.propertyisenumerable
  41. var f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  42. var descriptor = getOwnPropertyDescriptor(this, V);
  43. return !!descriptor && descriptor.enumerable;
  44. } : nativePropertyIsEnumerable;
  45. var objectPropertyIsEnumerable = {
  46. f: f
  47. };
  48. var createPropertyDescriptor = function (bitmap, value) {
  49. return {
  50. enumerable: !(bitmap & 1),
  51. configurable: !(bitmap & 2),
  52. writable: !(bitmap & 4),
  53. value: value
  54. };
  55. };
  56. var toString = {}.toString;
  57. var classofRaw = function (it) {
  58. return toString.call(it).slice(8, -1);
  59. };
  60. var split = ''.split;
  61. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  62. var indexedObject = fails(function () {
  63. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  64. // eslint-disable-next-line no-prototype-builtins
  65. return !Object('z').propertyIsEnumerable(0);
  66. }) ? function (it) {
  67. return classofRaw(it) == 'String' ? split.call(it, '') : Object(it);
  68. } : Object;
  69. // `RequireObjectCoercible` abstract operation
  70. // https://tc39.github.io/ecma262/#sec-requireobjectcoercible
  71. var requireObjectCoercible = function (it) {
  72. if (it == undefined) throw TypeError("Can't call method on " + it);
  73. return it;
  74. };
  75. // toObject with fallback for non-array-like ES3 strings
  76. var toIndexedObject = function (it) {
  77. return indexedObject(requireObjectCoercible(it));
  78. };
  79. var isObject = function (it) {
  80. return typeof it === 'object' ? it !== null : typeof it === 'function';
  81. };
  82. // `ToPrimitive` abstract operation
  83. // https://tc39.github.io/ecma262/#sec-toprimitive
  84. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  85. // and the second argument - flag - preferred type is a string
  86. var toPrimitive = function (input, PREFERRED_STRING) {
  87. if (!isObject(input)) return input;
  88. var fn, val;
  89. if (PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
  90. if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input))) return val;
  91. if (!PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
  92. throw TypeError("Can't convert object to primitive value");
  93. };
  94. var hasOwnProperty = {}.hasOwnProperty;
  95. var has = function (it, key) {
  96. return hasOwnProperty.call(it, key);
  97. };
  98. var document$1 = global_1.document;
  99. // typeof document.createElement is 'object' in old IE
  100. var EXISTS = isObject(document$1) && isObject(document$1.createElement);
  101. var documentCreateElement = function (it) {
  102. return EXISTS ? document$1.createElement(it) : {};
  103. };
  104. // Thank's IE8 for his funny defineProperty
  105. var ie8DomDefine = !descriptors && !fails(function () {
  106. return Object.defineProperty(documentCreateElement('div'), 'a', {
  107. get: function () { return 7; }
  108. }).a != 7;
  109. });
  110. var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  111. // `Object.getOwnPropertyDescriptor` method
  112. // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptor
  113. var f$1 = descriptors ? nativeGetOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  114. O = toIndexedObject(O);
  115. P = toPrimitive(P, true);
  116. if (ie8DomDefine) try {
  117. return nativeGetOwnPropertyDescriptor(O, P);
  118. } catch (error) { /* empty */ }
  119. if (has(O, P)) return createPropertyDescriptor(!objectPropertyIsEnumerable.f.call(O, P), O[P]);
  120. };
  121. var objectGetOwnPropertyDescriptor = {
  122. f: f$1
  123. };
  124. var anObject = function (it) {
  125. if (!isObject(it)) {
  126. throw TypeError(String(it) + ' is not an object');
  127. } return it;
  128. };
  129. var nativeDefineProperty = Object.defineProperty;
  130. // `Object.defineProperty` method
  131. // https://tc39.github.io/ecma262/#sec-object.defineproperty
  132. var f$2 = descriptors ? nativeDefineProperty : function defineProperty(O, P, Attributes) {
  133. anObject(O);
  134. P = toPrimitive(P, true);
  135. anObject(Attributes);
  136. if (ie8DomDefine) try {
  137. return nativeDefineProperty(O, P, Attributes);
  138. } catch (error) { /* empty */ }
  139. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
  140. if ('value' in Attributes) O[P] = Attributes.value;
  141. return O;
  142. };
  143. var objectDefineProperty = {
  144. f: f$2
  145. };
  146. var hide = descriptors ? function (object, key, value) {
  147. return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value));
  148. } : function (object, key, value) {
  149. object[key] = value;
  150. return object;
  151. };
  152. var setGlobal = function (key, value) {
  153. try {
  154. hide(global_1, key, value);
  155. } catch (error) {
  156. global_1[key] = value;
  157. } return value;
  158. };
  159. var shared = createCommonjsModule(function (module) {
  160. var SHARED = '__core-js_shared__';
  161. var store = global_1[SHARED] || setGlobal(SHARED, {});
  162. (module.exports = function (key, value) {
  163. return store[key] || (store[key] = value !== undefined ? value : {});
  164. })('versions', []).push({
  165. version: '3.1.3',
  166. mode: 'global',
  167. copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
  168. });
  169. });
  170. var functionToString = shared('native-function-to-string', Function.toString);
  171. var WeakMap = global_1.WeakMap;
  172. var nativeWeakMap = typeof WeakMap === 'function' && /native code/.test(functionToString.call(WeakMap));
  173. var id = 0;
  174. var postfix = Math.random();
  175. var uid = function (key) {
  176. return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);
  177. };
  178. var keys = shared('keys');
  179. var sharedKey = function (key) {
  180. return keys[key] || (keys[key] = uid(key));
  181. };
  182. var hiddenKeys = {};
  183. var WeakMap$1 = global_1.WeakMap;
  184. var set, get, has$1;
  185. var enforce = function (it) {
  186. return has$1(it) ? get(it) : set(it, {});
  187. };
  188. var getterFor = function (TYPE) {
  189. return function (it) {
  190. var state;
  191. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  192. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  193. } return state;
  194. };
  195. };
  196. if (nativeWeakMap) {
  197. var store = new WeakMap$1();
  198. var wmget = store.get;
  199. var wmhas = store.has;
  200. var wmset = store.set;
  201. set = function (it, metadata) {
  202. wmset.call(store, it, metadata);
  203. return metadata;
  204. };
  205. get = function (it) {
  206. return wmget.call(store, it) || {};
  207. };
  208. has$1 = function (it) {
  209. return wmhas.call(store, it);
  210. };
  211. } else {
  212. var STATE = sharedKey('state');
  213. hiddenKeys[STATE] = true;
  214. set = function (it, metadata) {
  215. hide(it, STATE, metadata);
  216. return metadata;
  217. };
  218. get = function (it) {
  219. return has(it, STATE) ? it[STATE] : {};
  220. };
  221. has$1 = function (it) {
  222. return has(it, STATE);
  223. };
  224. }
  225. var internalState = {
  226. set: set,
  227. get: get,
  228. has: has$1,
  229. enforce: enforce,
  230. getterFor: getterFor
  231. };
  232. var redefine = createCommonjsModule(function (module) {
  233. var getInternalState = internalState.get;
  234. var enforceInternalState = internalState.enforce;
  235. var TEMPLATE = String(functionToString).split('toString');
  236. shared('inspectSource', function (it) {
  237. return functionToString.call(it);
  238. });
  239. (module.exports = function (O, key, value, options) {
  240. var unsafe = options ? !!options.unsafe : false;
  241. var simple = options ? !!options.enumerable : false;
  242. var noTargetGet = options ? !!options.noTargetGet : false;
  243. if (typeof value == 'function') {
  244. if (typeof key == 'string' && !has(value, 'name')) hide(value, 'name', key);
  245. enforceInternalState(value).source = TEMPLATE.join(typeof key == 'string' ? key : '');
  246. }
  247. if (O === global_1) {
  248. if (simple) O[key] = value;
  249. else setGlobal(key, value);
  250. return;
  251. } else if (!unsafe) {
  252. delete O[key];
  253. } else if (!noTargetGet && O[key]) {
  254. simple = true;
  255. }
  256. if (simple) O[key] = value;
  257. else hide(O, key, value);
  258. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  259. })(Function.prototype, 'toString', function toString() {
  260. return typeof this == 'function' && getInternalState(this).source || functionToString.call(this);
  261. });
  262. });
  263. var path = global_1;
  264. var aFunction = function (variable) {
  265. return typeof variable == 'function' ? variable : undefined;
  266. };
  267. var getBuiltIn = function (namespace, method) {
  268. return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global_1[namespace])
  269. : path[namespace] && path[namespace][method] || global_1[namespace] && global_1[namespace][method];
  270. };
  271. var ceil = Math.ceil;
  272. var floor = Math.floor;
  273. // `ToInteger` abstract operation
  274. // https://tc39.github.io/ecma262/#sec-tointeger
  275. var toInteger = function (argument) {
  276. return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);
  277. };
  278. var min = Math.min;
  279. // `ToLength` abstract operation
  280. // https://tc39.github.io/ecma262/#sec-tolength
  281. var toLength = function (argument) {
  282. return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
  283. };
  284. var max = Math.max;
  285. var min$1 = Math.min;
  286. // Helper for a popular repeating case of the spec:
  287. // Let integer be ? ToInteger(index).
  288. // If integer < 0, let result be max((length + integer), 0); else let result be min(length, length).
  289. var toAbsoluteIndex = function (index, length) {
  290. var integer = toInteger(index);
  291. return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
  292. };
  293. // `Array.prototype.{ indexOf, includes }` methods implementation
  294. var createMethod = function (IS_INCLUDES) {
  295. return function ($this, el, fromIndex) {
  296. var O = toIndexedObject($this);
  297. var length = toLength(O.length);
  298. var index = toAbsoluteIndex(fromIndex, length);
  299. var value;
  300. // Array#includes uses SameValueZero equality algorithm
  301. // eslint-disable-next-line no-self-compare
  302. if (IS_INCLUDES && el != el) while (length > index) {
  303. value = O[index++];
  304. // eslint-disable-next-line no-self-compare
  305. if (value != value) return true;
  306. // Array#indexOf ignores holes, Array#includes - not
  307. } else for (;length > index; index++) {
  308. if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
  309. } return !IS_INCLUDES && -1;
  310. };
  311. };
  312. var arrayIncludes = {
  313. // `Array.prototype.includes` method
  314. // https://tc39.github.io/ecma262/#sec-array.prototype.includes
  315. includes: createMethod(true),
  316. // `Array.prototype.indexOf` method
  317. // https://tc39.github.io/ecma262/#sec-array.prototype.indexof
  318. indexOf: createMethod(false)
  319. };
  320. var indexOf = arrayIncludes.indexOf;
  321. var objectKeysInternal = function (object, names) {
  322. var O = toIndexedObject(object);
  323. var i = 0;
  324. var result = [];
  325. var key;
  326. for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key);
  327. // Don't enum bug & hidden keys
  328. while (names.length > i) if (has(O, key = names[i++])) {
  329. ~indexOf(result, key) || result.push(key);
  330. }
  331. return result;
  332. };
  333. // IE8- don't enum bug keys
  334. var enumBugKeys = [
  335. 'constructor',
  336. 'hasOwnProperty',
  337. 'isPrototypeOf',
  338. 'propertyIsEnumerable',
  339. 'toLocaleString',
  340. 'toString',
  341. 'valueOf'
  342. ];
  343. var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype');
  344. // `Object.getOwnPropertyNames` method
  345. // https://tc39.github.io/ecma262/#sec-object.getownpropertynames
  346. var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  347. return objectKeysInternal(O, hiddenKeys$1);
  348. };
  349. var objectGetOwnPropertyNames = {
  350. f: f$3
  351. };
  352. var f$4 = Object.getOwnPropertySymbols;
  353. var objectGetOwnPropertySymbols = {
  354. f: f$4
  355. };
  356. // all object keys, includes non-enumerable and symbols
  357. var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  358. var keys = objectGetOwnPropertyNames.f(anObject(it));
  359. var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
  360. return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
  361. };
  362. var copyConstructorProperties = function (target, source) {
  363. var keys = ownKeys(source);
  364. var defineProperty = objectDefineProperty.f;
  365. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  366. for (var i = 0; i < keys.length; i++) {
  367. var key = keys[i];
  368. if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  369. }
  370. };
  371. var replacement = /#|\.prototype\./;
  372. var isForced = function (feature, detection) {
  373. var value = data[normalize(feature)];
  374. return value == POLYFILL ? true
  375. : value == NATIVE ? false
  376. : typeof detection == 'function' ? fails(detection)
  377. : !!detection;
  378. };
  379. var normalize = isForced.normalize = function (string) {
  380. return String(string).replace(replacement, '.').toLowerCase();
  381. };
  382. var data = isForced.data = {};
  383. var NATIVE = isForced.NATIVE = 'N';
  384. var POLYFILL = isForced.POLYFILL = 'P';
  385. var isForced_1 = isForced;
  386. var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
  387. /*
  388. options.target - name of the target object
  389. options.global - target is the global object
  390. options.stat - export as static methods of target
  391. options.proto - export as prototype methods of target
  392. options.real - real prototype method for the `pure` version
  393. options.forced - export even if the native feature is available
  394. options.bind - bind methods to the target, required for the `pure` version
  395. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  396. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  397. options.sham - add a flag to not completely full polyfills
  398. options.enumerable - export as enumerable property
  399. options.noTargetGet - prevent calling a getter on target
  400. */
  401. var _export = function (options, source) {
  402. var TARGET = options.target;
  403. var GLOBAL = options.global;
  404. var STATIC = options.stat;
  405. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  406. if (GLOBAL) {
  407. target = global_1;
  408. } else if (STATIC) {
  409. target = global_1[TARGET] || setGlobal(TARGET, {});
  410. } else {
  411. target = (global_1[TARGET] || {}).prototype;
  412. }
  413. if (target) for (key in source) {
  414. sourceProperty = source[key];
  415. if (options.noTargetGet) {
  416. descriptor = getOwnPropertyDescriptor$1(target, key);
  417. targetProperty = descriptor && descriptor.value;
  418. } else targetProperty = target[key];
  419. FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  420. // contained in target
  421. if (!FORCED && targetProperty !== undefined) {
  422. if (typeof sourceProperty === typeof targetProperty) continue;
  423. copyConstructorProperties(sourceProperty, targetProperty);
  424. }
  425. // add a flag to not completely full polyfills
  426. if (options.sham || (targetProperty && targetProperty.sham)) {
  427. hide(sourceProperty, 'sham', true);
  428. }
  429. // extend global
  430. redefine(target, key, sourceProperty, options);
  431. }
  432. };
  433. var aFunction$1 = function (it) {
  434. if (typeof it != 'function') {
  435. throw TypeError(String(it) + ' is not a function');
  436. } return it;
  437. };
  438. // optional / simple context binding
  439. var bindContext = function (fn, that, length) {
  440. aFunction$1(fn);
  441. if (that === undefined) return fn;
  442. switch (length) {
  443. case 0: return function () {
  444. return fn.call(that);
  445. };
  446. case 1: return function (a) {
  447. return fn.call(that, a);
  448. };
  449. case 2: return function (a, b) {
  450. return fn.call(that, a, b);
  451. };
  452. case 3: return function (a, b, c) {
  453. return fn.call(that, a, b, c);
  454. };
  455. }
  456. return function (/* ...args */) {
  457. return fn.apply(that, arguments);
  458. };
  459. };
  460. // `ToObject` abstract operation
  461. // https://tc39.github.io/ecma262/#sec-toobject
  462. var toObject = function (argument) {
  463. return Object(requireObjectCoercible(argument));
  464. };
  465. // `IsArray` abstract operation
  466. // https://tc39.github.io/ecma262/#sec-isarray
  467. var isArray = Array.isArray || function isArray(arg) {
  468. return classofRaw(arg) == 'Array';
  469. };
  470. var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () {
  471. // Chrome 38 Symbol has incorrect toString conversion
  472. // eslint-disable-next-line no-undef
  473. return !String(Symbol());
  474. });
  475. var Symbol$1 = global_1.Symbol;
  476. var store$1 = shared('wks');
  477. var wellKnownSymbol = function (name) {
  478. return store$1[name] || (store$1[name] = nativeSymbol && Symbol$1[name]
  479. || (nativeSymbol ? Symbol$1 : uid)('Symbol.' + name));
  480. };
  481. var SPECIES = wellKnownSymbol('species');
  482. // `ArraySpeciesCreate` abstract operation
  483. // https://tc39.github.io/ecma262/#sec-arrayspeciescreate
  484. var arraySpeciesCreate = function (originalArray, length) {
  485. var C;
  486. if (isArray(originalArray)) {
  487. C = originalArray.constructor;
  488. // cross-realm fallback
  489. if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
  490. else if (isObject(C)) {
  491. C = C[SPECIES];
  492. if (C === null) C = undefined;
  493. }
  494. } return new (C === undefined ? Array : C)(length === 0 ? 0 : length);
  495. };
  496. var push = [].push;
  497. // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex }` methods implementation
  498. var createMethod$1 = function (TYPE) {
  499. var IS_MAP = TYPE == 1;
  500. var IS_FILTER = TYPE == 2;
  501. var IS_SOME = TYPE == 3;
  502. var IS_EVERY = TYPE == 4;
  503. var IS_FIND_INDEX = TYPE == 6;
  504. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  505. return function ($this, callbackfn, that, specificCreate) {
  506. var O = toObject($this);
  507. var self = indexedObject(O);
  508. var boundFunction = bindContext(callbackfn, that, 3);
  509. var length = toLength(self.length);
  510. var index = 0;
  511. var create = specificCreate || arraySpeciesCreate;
  512. var target = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  513. var value, result;
  514. for (;length > index; index++) if (NO_HOLES || index in self) {
  515. value = self[index];
  516. result = boundFunction(value, index, O);
  517. if (TYPE) {
  518. if (IS_MAP) target[index] = result; // map
  519. else if (result) switch (TYPE) {
  520. case 3: return true; // some
  521. case 5: return value; // find
  522. case 6: return index; // findIndex
  523. case 2: push.call(target, value); // filter
  524. } else if (IS_EVERY) return false; // every
  525. }
  526. }
  527. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
  528. };
  529. };
  530. var arrayIteration = {
  531. // `Array.prototype.forEach` method
  532. // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
  533. forEach: createMethod$1(0),
  534. // `Array.prototype.map` method
  535. // https://tc39.github.io/ecma262/#sec-array.prototype.map
  536. map: createMethod$1(1),
  537. // `Array.prototype.filter` method
  538. // https://tc39.github.io/ecma262/#sec-array.prototype.filter
  539. filter: createMethod$1(2),
  540. // `Array.prototype.some` method
  541. // https://tc39.github.io/ecma262/#sec-array.prototype.some
  542. some: createMethod$1(3),
  543. // `Array.prototype.every` method
  544. // https://tc39.github.io/ecma262/#sec-array.prototype.every
  545. every: createMethod$1(4),
  546. // `Array.prototype.find` method
  547. // https://tc39.github.io/ecma262/#sec-array.prototype.find
  548. find: createMethod$1(5),
  549. // `Array.prototype.findIndex` method
  550. // https://tc39.github.io/ecma262/#sec-array.prototype.findIndex
  551. findIndex: createMethod$1(6)
  552. };
  553. var SPECIES$1 = wellKnownSymbol('species');
  554. var arrayMethodHasSpeciesSupport = function (METHOD_NAME) {
  555. return !fails(function () {
  556. var array = [];
  557. var constructor = array.constructor = {};
  558. constructor[SPECIES$1] = function () {
  559. return { foo: 1 };
  560. };
  561. return array[METHOD_NAME](Boolean).foo !== 1;
  562. });
  563. };
  564. var $filter = arrayIteration.filter;
  565. // `Array.prototype.filter` method
  566. // https://tc39.github.io/ecma262/#sec-array.prototype.filter
  567. // with adding support of @@species
  568. _export({ target: 'Array', proto: true, forced: !arrayMethodHasSpeciesSupport('filter') }, {
  569. filter: function filter(callbackfn /* , thisArg */) {
  570. return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  571. }
  572. });
  573. // `Object.keys` method
  574. // https://tc39.github.io/ecma262/#sec-object.keys
  575. var objectKeys = Object.keys || function keys(O) {
  576. return objectKeysInternal(O, enumBugKeys);
  577. };
  578. // `Object.defineProperties` method
  579. // https://tc39.github.io/ecma262/#sec-object.defineproperties
  580. var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
  581. anObject(O);
  582. var keys = objectKeys(Properties);
  583. var length = keys.length;
  584. var index = 0;
  585. var key;
  586. while (length > index) objectDefineProperty.f(O, key = keys[index++], Properties[key]);
  587. return O;
  588. };
  589. var html = getBuiltIn('document', 'documentElement');
  590. var IE_PROTO = sharedKey('IE_PROTO');
  591. var PROTOTYPE = 'prototype';
  592. var Empty = function () { /* empty */ };
  593. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  594. var createDict = function () {
  595. // Thrash, waste and sodomy: IE GC bug
  596. var iframe = documentCreateElement('iframe');
  597. var length = enumBugKeys.length;
  598. var lt = '<';
  599. var script = 'script';
  600. var gt = '>';
  601. var js = 'java' + script + ':';
  602. var iframeDocument;
  603. iframe.style.display = 'none';
  604. html.appendChild(iframe);
  605. iframe.src = String(js);
  606. iframeDocument = iframe.contentWindow.document;
  607. iframeDocument.open();
  608. iframeDocument.write(lt + script + gt + 'document.F=Object' + lt + '/' + script + gt);
  609. iframeDocument.close();
  610. createDict = iframeDocument.F;
  611. while (length--) delete createDict[PROTOTYPE][enumBugKeys[length]];
  612. return createDict();
  613. };
  614. // `Object.create` method
  615. // https://tc39.github.io/ecma262/#sec-object.create
  616. var objectCreate = Object.create || function create(O, Properties) {
  617. var result;
  618. if (O !== null) {
  619. Empty[PROTOTYPE] = anObject(O);
  620. result = new Empty();
  621. Empty[PROTOTYPE] = null;
  622. // add "__proto__" for Object.getPrototypeOf polyfill
  623. result[IE_PROTO] = O;
  624. } else result = createDict();
  625. return Properties === undefined ? result : objectDefineProperties(result, Properties);
  626. };
  627. hiddenKeys[IE_PROTO] = true;
  628. var UNSCOPABLES = wellKnownSymbol('unscopables');
  629. var ArrayPrototype = Array.prototype;
  630. // Array.prototype[@@unscopables]
  631. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  632. if (ArrayPrototype[UNSCOPABLES] == undefined) {
  633. hide(ArrayPrototype, UNSCOPABLES, objectCreate(null));
  634. }
  635. // add a key to Array.prototype[@@unscopables]
  636. var addToUnscopables = function (key) {
  637. ArrayPrototype[UNSCOPABLES][key] = true;
  638. };
  639. var $find = arrayIteration.find;
  640. var FIND = 'find';
  641. var SKIPS_HOLES = true;
  642. // Shouldn't skip holes
  643. if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
  644. // `Array.prototype.find` method
  645. // https://tc39.github.io/ecma262/#sec-array.prototype.find
  646. _export({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
  647. find: function find(callbackfn /* , that = undefined */) {
  648. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  649. }
  650. });
  651. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  652. addToUnscopables(FIND);
  653. var $includes = arrayIncludes.includes;
  654. // `Array.prototype.includes` method
  655. // https://tc39.github.io/ecma262/#sec-array.prototype.includes
  656. _export({ target: 'Array', proto: true }, {
  657. includes: function includes(el /* , fromIndex = 0 */) {
  658. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  659. }
  660. });
  661. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  662. addToUnscopables('includes');
  663. var sloppyArrayMethod = function (METHOD_NAME, argument) {
  664. var method = [][METHOD_NAME];
  665. return !method || !fails(function () {
  666. // eslint-disable-next-line no-useless-call,no-throw-literal
  667. method.call(null, argument || function () { throw 1; }, 1);
  668. });
  669. };
  670. var $indexOf = arrayIncludes.indexOf;
  671. var nativeIndexOf = [].indexOf;
  672. var NEGATIVE_ZERO = !!nativeIndexOf && 1 / [1].indexOf(1, -0) < 0;
  673. var SLOPPY_METHOD = sloppyArrayMethod('indexOf');
  674. // `Array.prototype.indexOf` method
  675. // https://tc39.github.io/ecma262/#sec-array.prototype.indexof
  676. _export({ target: 'Array', proto: true, forced: NEGATIVE_ZERO || SLOPPY_METHOD }, {
  677. indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {
  678. return NEGATIVE_ZERO
  679. // convert -0 to +0
  680. ? nativeIndexOf.apply(this, arguments) || 0
  681. : $indexOf(this, searchElement, arguments.length > 1 ? arguments[1] : undefined);
  682. }
  683. });
  684. var nativeJoin = [].join;
  685. var ES3_STRINGS = indexedObject != Object;
  686. var SLOPPY_METHOD$1 = sloppyArrayMethod('join', ',');
  687. // `Array.prototype.join` method
  688. // https://tc39.github.io/ecma262/#sec-array.prototype.join
  689. _export({ target: 'Array', proto: true, forced: ES3_STRINGS || SLOPPY_METHOD$1 }, {
  690. join: function join(separator) {
  691. return nativeJoin.call(toIndexedObject(this), separator === undefined ? ',' : separator);
  692. }
  693. });
  694. var nativeSort = [].sort;
  695. var test = [1, 2, 3];
  696. // IE8-
  697. var FAILS_ON_UNDEFINED = fails(function () {
  698. test.sort(undefined);
  699. });
  700. // V8 bug
  701. var FAILS_ON_NULL = fails(function () {
  702. test.sort(null);
  703. });
  704. // Old WebKit
  705. var SLOPPY_METHOD$2 = sloppyArrayMethod('sort');
  706. var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || SLOPPY_METHOD$2;
  707. // `Array.prototype.sort` method
  708. // https://tc39.github.io/ecma262/#sec-array.prototype.sort
  709. _export({ target: 'Array', proto: true, forced: FORCED }, {
  710. sort: function sort(comparefn) {
  711. return comparefn === undefined
  712. ? nativeSort.call(toObject(this))
  713. : nativeSort.call(toObject(this), aFunction$1(comparefn));
  714. }
  715. });
  716. var FAILS_ON_PRIMITIVES = fails(function () { objectKeys(1); });
  717. // `Object.keys` method
  718. // https://tc39.github.io/ecma262/#sec-object.keys
  719. _export({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {
  720. keys: function keys(it) {
  721. return objectKeys(toObject(it));
  722. }
  723. });
  724. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  725. // ES3 wrong here
  726. var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
  727. // fallback for IE11 Script Access Denied error
  728. var tryGet = function (it, key) {
  729. try {
  730. return it[key];
  731. } catch (error) { /* empty */ }
  732. };
  733. // getting tag from ES6+ `Object.prototype.toString`
  734. var classof = function (it) {
  735. var O, tag, result;
  736. return it === undefined ? 'Undefined' : it === null ? 'Null'
  737. // @@toStringTag case
  738. : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag
  739. // builtinTag case
  740. : CORRECT_ARGUMENTS ? classofRaw(O)
  741. // ES3 arguments fallback
  742. : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;
  743. };
  744. var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag');
  745. var test$1 = {};
  746. test$1[TO_STRING_TAG$1] = 'z';
  747. // `Object.prototype.toString` method implementation
  748. // https://tc39.github.io/ecma262/#sec-object.prototype.tostring
  749. var objectToString = String(test$1) !== '[object z]' ? function toString() {
  750. return '[object ' + classof(this) + ']';
  751. } : test$1.toString;
  752. var ObjectPrototype = Object.prototype;
  753. // `Object.prototype.toString` method
  754. // https://tc39.github.io/ecma262/#sec-object.prototype.tostring
  755. if (objectToString !== ObjectPrototype.toString) {
  756. redefine(ObjectPrototype, 'toString', objectToString, { unsafe: true });
  757. }
  758. // `RegExp.prototype.flags` getter implementation
  759. // https://tc39.github.io/ecma262/#sec-get-regexp.prototype.flags
  760. var regexpFlags = function () {
  761. var that = anObject(this);
  762. var result = '';
  763. if (that.global) result += 'g';
  764. if (that.ignoreCase) result += 'i';
  765. if (that.multiline) result += 'm';
  766. if (that.dotAll) result += 's';
  767. if (that.unicode) result += 'u';
  768. if (that.sticky) result += 'y';
  769. return result;
  770. };
  771. var TO_STRING = 'toString';
  772. var RegExpPrototype = RegExp.prototype;
  773. var nativeToString = RegExpPrototype[TO_STRING];
  774. var NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) != '/a/b'; });
  775. // FF44- RegExp#toString has a wrong name
  776. var INCORRECT_NAME = nativeToString.name != TO_STRING;
  777. // `RegExp.prototype.toString` method
  778. // https://tc39.github.io/ecma262/#sec-regexp.prototype.tostring
  779. if (NOT_GENERIC || INCORRECT_NAME) {
  780. redefine(RegExp.prototype, TO_STRING, function toString() {
  781. var R = anObject(this);
  782. var p = String(R.source);
  783. var rf = R.flags;
  784. var f = String(rf === undefined && R instanceof RegExp && !('flags' in RegExpPrototype) ? regexpFlags.call(R) : rf);
  785. return '/' + p + '/' + f;
  786. }, { unsafe: true });
  787. }
  788. var MATCH = wellKnownSymbol('match');
  789. // `IsRegExp` abstract operation
  790. // https://tc39.github.io/ecma262/#sec-isregexp
  791. var isRegexp = function (it) {
  792. var isRegExp;
  793. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classofRaw(it) == 'RegExp');
  794. };
  795. var notARegexp = function (it) {
  796. if (isRegexp(it)) {
  797. throw TypeError("The method doesn't accept regular expressions");
  798. } return it;
  799. };
  800. var MATCH$1 = wellKnownSymbol('match');
  801. var correctIsRegexpLogic = function (METHOD_NAME) {
  802. var regexp = /./;
  803. try {
  804. '/./'[METHOD_NAME](regexp);
  805. } catch (e) {
  806. try {
  807. regexp[MATCH$1] = false;
  808. return '/./'[METHOD_NAME](regexp);
  809. } catch (f) { /* empty */ }
  810. } return false;
  811. };
  812. // `String.prototype.includes` method
  813. // https://tc39.github.io/ecma262/#sec-string.prototype.includes
  814. _export({ target: 'String', proto: true, forced: !correctIsRegexpLogic('includes') }, {
  815. includes: function includes(searchString /* , position = 0 */) {
  816. return !!~String(requireObjectCoercible(this))
  817. .indexOf(notARegexp(searchString), arguments.length > 1 ? arguments[1] : undefined);
  818. }
  819. });
  820. var nativeExec = RegExp.prototype.exec;
  821. // This always refers to the native implementation, because the
  822. // String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js,
  823. // which loads this file before patching the method.
  824. var nativeReplace = String.prototype.replace;
  825. var patchedExec = nativeExec;
  826. var UPDATES_LAST_INDEX_WRONG = (function () {
  827. var re1 = /a/;
  828. var re2 = /b*/g;
  829. nativeExec.call(re1, 'a');
  830. nativeExec.call(re2, 'a');
  831. return re1.lastIndex !== 0 || re2.lastIndex !== 0;
  832. })();
  833. // nonparticipating capturing group, copied from es5-shim's String#split patch.
  834. var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
  835. var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED;
  836. if (PATCH) {
  837. patchedExec = function exec(str) {
  838. var re = this;
  839. var lastIndex, reCopy, match, i;
  840. if (NPCG_INCLUDED) {
  841. reCopy = new RegExp('^' + re.source + '$(?!\\s)', regexpFlags.call(re));
  842. }
  843. if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;
  844. match = nativeExec.call(re, str);
  845. if (UPDATES_LAST_INDEX_WRONG && match) {
  846. re.lastIndex = re.global ? match.index + match[0].length : lastIndex;
  847. }
  848. if (NPCG_INCLUDED && match && match.length > 1) {
  849. // Fix browsers whose `exec` methods don't consistently return `undefined`
  850. // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
  851. nativeReplace.call(match[0], reCopy, function () {
  852. for (i = 1; i < arguments.length - 2; i++) {
  853. if (arguments[i] === undefined) match[i] = undefined;
  854. }
  855. });
  856. }
  857. return match;
  858. };
  859. }
  860. var regexpExec = patchedExec;
  861. var SPECIES$2 = wellKnownSymbol('species');
  862. var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
  863. // #replace needs built-in support for named groups.
  864. // #match works fine because it just return the exec results, even if it has
  865. // a "grops" property.
  866. var re = /./;
  867. re.exec = function () {
  868. var result = [];
  869. result.groups = { a: '7' };
  870. return result;
  871. };
  872. return ''.replace(re, '$<a>') !== '7';
  873. });
  874. // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
  875. // Weex JS has frozen built-in prototypes, so use try / catch wrapper
  876. var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {
  877. var re = /(?:)/;
  878. var originalExec = re.exec;
  879. re.exec = function () { return originalExec.apply(this, arguments); };
  880. var result = 'ab'.split(re);
  881. return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
  882. });
  883. var fixRegexpWellKnownSymbolLogic = function (KEY, length, exec, sham) {
  884. var SYMBOL = wellKnownSymbol(KEY);
  885. var DELEGATES_TO_SYMBOL = !fails(function () {
  886. // String methods call symbol-named RegEp methods
  887. var O = {};
  888. O[SYMBOL] = function () { return 7; };
  889. return ''[KEY](O) != 7;
  890. });
  891. var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () {
  892. // Symbol-named RegExp methods call .exec
  893. var execCalled = false;
  894. var re = /a/;
  895. re.exec = function () { execCalled = true; return null; };
  896. if (KEY === 'split') {
  897. // RegExp[@@split] doesn't call the regex's exec method, but first creates
  898. // a new one. We need to return the patched regex when creating the new one.
  899. re.constructor = {};
  900. re.constructor[SPECIES$2] = function () { return re; };
  901. }
  902. re[SYMBOL]('');
  903. return !execCalled;
  904. });
  905. if (
  906. !DELEGATES_TO_SYMBOL ||
  907. !DELEGATES_TO_EXEC ||
  908. (KEY === 'replace' && !REPLACE_SUPPORTS_NAMED_GROUPS) ||
  909. (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC)
  910. ) {
  911. var nativeRegExpMethod = /./[SYMBOL];
  912. var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
  913. if (regexp.exec === regexpExec) {
  914. if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
  915. // The native String method already delegates to @@method (this
  916. // polyfilled function), leasing to infinite recursion.
  917. // We avoid it by directly calling the native @@method method.
  918. return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };
  919. }
  920. return { done: true, value: nativeMethod.call(str, regexp, arg2) };
  921. }
  922. return { done: false };
  923. });
  924. var stringMethod = methods[0];
  925. var regexMethod = methods[1];
  926. redefine(String.prototype, KEY, stringMethod);
  927. redefine(RegExp.prototype, SYMBOL, length == 2
  928. // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
  929. // 21.2.5.11 RegExp.prototype[@@split](string, limit)
  930. ? function (string, arg) { return regexMethod.call(string, this, arg); }
  931. // 21.2.5.6 RegExp.prototype[@@match](string)
  932. // 21.2.5.9 RegExp.prototype[@@search](string)
  933. : function (string) { return regexMethod.call(string, this); }
  934. );
  935. if (sham) hide(RegExp.prototype[SYMBOL], 'sham', true);
  936. }
  937. };
  938. // `String.prototype.{ codePointAt, at }` methods implementation
  939. var createMethod$2 = function (CONVERT_TO_STRING) {
  940. return function ($this, pos) {
  941. var S = String(requireObjectCoercible($this));
  942. var position = toInteger(pos);
  943. var size = S.length;
  944. var first, second;
  945. if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
  946. first = S.charCodeAt(position);
  947. return first < 0xD800 || first > 0xDBFF || position + 1 === size
  948. || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF
  949. ? CONVERT_TO_STRING ? S.charAt(position) : first
  950. : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
  951. };
  952. };
  953. var stringMultibyte = {
  954. // `String.prototype.codePointAt` method
  955. // https://tc39.github.io/ecma262/#sec-string.prototype.codepointat
  956. codeAt: createMethod$2(false),
  957. // `String.prototype.at` method
  958. // https://github.com/mathiasbynens/String.prototype.at
  959. charAt: createMethod$2(true)
  960. };
  961. var charAt = stringMultibyte.charAt;
  962. // `AdvanceStringIndex` abstract operation
  963. // https://tc39.github.io/ecma262/#sec-advancestringindex
  964. var advanceStringIndex = function (S, index, unicode) {
  965. return index + (unicode ? charAt(S, index).length : 1);
  966. };
  967. // `RegExpExec` abstract operation
  968. // https://tc39.github.io/ecma262/#sec-regexpexec
  969. var regexpExecAbstract = function (R, S) {
  970. var exec = R.exec;
  971. if (typeof exec === 'function') {
  972. var result = exec.call(R, S);
  973. if (typeof result !== 'object') {
  974. throw TypeError('RegExp exec method returned something other than an Object or null');
  975. }
  976. return result;
  977. }
  978. if (classofRaw(R) !== 'RegExp') {
  979. throw TypeError('RegExp#exec called on incompatible receiver');
  980. }
  981. return regexpExec.call(R, S);
  982. };
  983. // @@match logic
  984. fixRegexpWellKnownSymbolLogic('match', 1, function (MATCH, nativeMatch, maybeCallNative) {
  985. return [
  986. // `String.prototype.match` method
  987. // https://tc39.github.io/ecma262/#sec-string.prototype.match
  988. function match(regexp) {
  989. var O = requireObjectCoercible(this);
  990. var matcher = regexp == undefined ? undefined : regexp[MATCH];
  991. return matcher !== undefined ? matcher.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
  992. },
  993. // `RegExp.prototype[@@match]` method
  994. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match
  995. function (regexp) {
  996. var res = maybeCallNative(nativeMatch, regexp, this);
  997. if (res.done) return res.value;
  998. var rx = anObject(regexp);
  999. var S = String(this);
  1000. if (!rx.global) return regexpExecAbstract(rx, S);
  1001. var fullUnicode = rx.unicode;
  1002. rx.lastIndex = 0;
  1003. var A = [];
  1004. var n = 0;
  1005. var result;
  1006. while ((result = regexpExecAbstract(rx, S)) !== null) {
  1007. var matchStr = String(result[0]);
  1008. A[n] = matchStr;
  1009. if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
  1010. n++;
  1011. }
  1012. return n === 0 ? null : A;
  1013. }
  1014. ];
  1015. });
  1016. var max$1 = Math.max;
  1017. var min$2 = Math.min;
  1018. var floor$1 = Math.floor;
  1019. var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d\d?|<[^>]*>)/g;
  1020. var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d\d?)/g;
  1021. var maybeToString = function (it) {
  1022. return it === undefined ? it : String(it);
  1023. };
  1024. // @@replace logic
  1025. fixRegexpWellKnownSymbolLogic('replace', 2, function (REPLACE, nativeReplace, maybeCallNative) {
  1026. return [
  1027. // `String.prototype.replace` method
  1028. // https://tc39.github.io/ecma262/#sec-string.prototype.replace
  1029. function replace(searchValue, replaceValue) {
  1030. var O = requireObjectCoercible(this);
  1031. var replacer = searchValue == undefined ? undefined : searchValue[REPLACE];
  1032. return replacer !== undefined
  1033. ? replacer.call(searchValue, O, replaceValue)
  1034. : nativeReplace.call(String(O), searchValue, replaceValue);
  1035. },
  1036. // `RegExp.prototype[@@replace]` method
  1037. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace
  1038. function (regexp, replaceValue) {
  1039. var res = maybeCallNative(nativeReplace, regexp, this, replaceValue);
  1040. if (res.done) return res.value;
  1041. var rx = anObject(regexp);
  1042. var S = String(this);
  1043. var functionalReplace = typeof replaceValue === 'function';
  1044. if (!functionalReplace) replaceValue = String(replaceValue);
  1045. var global = rx.global;
  1046. if (global) {
  1047. var fullUnicode = rx.unicode;
  1048. rx.lastIndex = 0;
  1049. }
  1050. var results = [];
  1051. while (true) {
  1052. var result = regexpExecAbstract(rx, S);
  1053. if (result === null) break;
  1054. results.push(result);
  1055. if (!global) break;
  1056. var matchStr = String(result[0]);
  1057. if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
  1058. }
  1059. var accumulatedResult = '';
  1060. var nextSourcePosition = 0;
  1061. for (var i = 0; i < results.length; i++) {
  1062. result = results[i];
  1063. var matched = String(result[0]);
  1064. var position = max$1(min$2(toInteger(result.index), S.length), 0);
  1065. var captures = [];
  1066. // NOTE: This is equivalent to
  1067. // captures = result.slice(1).map(maybeToString)
  1068. // but for some reason `nativeSlice.call(result, 1, result.length)` (called in
  1069. // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and
  1070. // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.
  1071. for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j]));
  1072. var namedCaptures = result.groups;
  1073. if (functionalReplace) {
  1074. var replacerArgs = [matched].concat(captures, position, S);
  1075. if (namedCaptures !== undefined) replacerArgs.push(namedCaptures);
  1076. var replacement = String(replaceValue.apply(undefined, replacerArgs));
  1077. } else {
  1078. replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
  1079. }
  1080. if (position >= nextSourcePosition) {
  1081. accumulatedResult += S.slice(nextSourcePosition, position) + replacement;
  1082. nextSourcePosition = position + matched.length;
  1083. }
  1084. }
  1085. return accumulatedResult + S.slice(nextSourcePosition);
  1086. }
  1087. ];
  1088. // https://tc39.github.io/ecma262/#sec-getsubstitution
  1089. function getSubstitution(matched, str, position, captures, namedCaptures, replacement) {
  1090. var tailPos = position + matched.length;
  1091. var m = captures.length;
  1092. var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
  1093. if (namedCaptures !== undefined) {
  1094. namedCaptures = toObject(namedCaptures);
  1095. symbols = SUBSTITUTION_SYMBOLS;
  1096. }
  1097. return nativeReplace.call(replacement, symbols, function (match, ch) {
  1098. var capture;
  1099. switch (ch.charAt(0)) {
  1100. case '$': return '$';
  1101. case '&': return matched;
  1102. case '`': return str.slice(0, position);
  1103. case "'": return str.slice(tailPos);
  1104. case '<':
  1105. capture = namedCaptures[ch.slice(1, -1)];
  1106. break;
  1107. default: // \d\d?
  1108. var n = +ch;
  1109. if (n === 0) return match;
  1110. if (n > m) {
  1111. var f = floor$1(n / 10);
  1112. if (f === 0) return match;
  1113. if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);
  1114. return match;
  1115. }
  1116. capture = captures[n - 1];
  1117. }
  1118. return capture === undefined ? '' : capture;
  1119. });
  1120. }
  1121. });
  1122. var SPECIES$3 = wellKnownSymbol('species');
  1123. // `SpeciesConstructor` abstract operation
  1124. // https://tc39.github.io/ecma262/#sec-speciesconstructor
  1125. var speciesConstructor = function (O, defaultConstructor) {
  1126. var C = anObject(O).constructor;
  1127. var S;
  1128. return C === undefined || (S = anObject(C)[SPECIES$3]) == undefined ? defaultConstructor : aFunction$1(S);
  1129. };
  1130. var arrayPush = [].push;
  1131. var min$3 = Math.min;
  1132. var MAX_UINT32 = 0xFFFFFFFF;
  1133. // babel-minify transpiles RegExp('x', 'y') -> /x/y and it causes SyntaxError
  1134. var SUPPORTS_Y = !fails(function () { return !RegExp(MAX_UINT32, 'y'); });
  1135. // @@split logic
  1136. fixRegexpWellKnownSymbolLogic('split', 2, function (SPLIT, nativeSplit, maybeCallNative) {
  1137. var internalSplit;
  1138. if (
  1139. 'abbc'.split(/(b)*/)[1] == 'c' ||
  1140. 'test'.split(/(?:)/, -1).length != 4 ||
  1141. 'ab'.split(/(?:ab)*/).length != 2 ||
  1142. '.'.split(/(.?)(.?)/).length != 4 ||
  1143. '.'.split(/()()/).length > 1 ||
  1144. ''.split(/.?/).length
  1145. ) {
  1146. // based on es5-shim implementation, need to rework it
  1147. internalSplit = function (separator, limit) {
  1148. var string = String(requireObjectCoercible(this));
  1149. var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
  1150. if (lim === 0) return [];
  1151. if (separator === undefined) return [string];
  1152. // If `separator` is not a regex, use native split
  1153. if (!isRegexp(separator)) {
  1154. return nativeSplit.call(string, separator, lim);
  1155. }
  1156. var output = [];
  1157. var flags = (separator.ignoreCase ? 'i' : '') +
  1158. (separator.multiline ? 'm' : '') +
  1159. (separator.unicode ? 'u' : '') +
  1160. (separator.sticky ? 'y' : '');
  1161. var lastLastIndex = 0;
  1162. // Make `global` and avoid `lastIndex` issues by working with a copy
  1163. var separatorCopy = new RegExp(separator.source, flags + 'g');
  1164. var match, lastIndex, lastLength;
  1165. while (match = regexpExec.call(separatorCopy, string)) {
  1166. lastIndex = separatorCopy.lastIndex;
  1167. if (lastIndex > lastLastIndex) {
  1168. output.push(string.slice(lastLastIndex, match.index));
  1169. if (match.length > 1 && match.index < string.length) arrayPush.apply(output, match.slice(1));
  1170. lastLength = match[0].length;
  1171. lastLastIndex = lastIndex;
  1172. if (output.length >= lim) break;
  1173. }
  1174. if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++; // Avoid an infinite loop
  1175. }
  1176. if (lastLastIndex === string.length) {
  1177. if (lastLength || !separatorCopy.test('')) output.push('');
  1178. } else output.push(string.slice(lastLastIndex));
  1179. return output.length > lim ? output.slice(0, lim) : output;
  1180. };
  1181. // Chakra, V8
  1182. } else if ('0'.split(undefined, 0).length) {
  1183. internalSplit = function (separator, limit) {
  1184. return separator === undefined && limit === 0 ? [] : nativeSplit.call(this, separator, limit);
  1185. };
  1186. } else internalSplit = nativeSplit;
  1187. return [
  1188. // `String.prototype.split` method
  1189. // https://tc39.github.io/ecma262/#sec-string.prototype.split
  1190. function split(separator, limit) {
  1191. var O = requireObjectCoercible(this);
  1192. var splitter = separator == undefined ? undefined : separator[SPLIT];
  1193. return splitter !== undefined
  1194. ? splitter.call(separator, O, limit)
  1195. : internalSplit.call(String(O), separator, limit);
  1196. },
  1197. // `RegExp.prototype[@@split]` method
  1198. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@split
  1199. //
  1200. // NOTE: This cannot be properly polyfilled in engines that don't support
  1201. // the 'y' flag.
  1202. function (regexp, limit) {
  1203. var res = maybeCallNative(internalSplit, regexp, this, limit, internalSplit !== nativeSplit);
  1204. if (res.done) return res.value;
  1205. var rx = anObject(regexp);
  1206. var S = String(this);
  1207. var C = speciesConstructor(rx, RegExp);
  1208. var unicodeMatching = rx.unicode;
  1209. var flags = (rx.ignoreCase ? 'i' : '') +
  1210. (rx.multiline ? 'm' : '') +
  1211. (rx.unicode ? 'u' : '') +
  1212. (SUPPORTS_Y ? 'y' : 'g');
  1213. // ^(? + rx + ) is needed, in combination with some S slicing, to
  1214. // simulate the 'y' flag.
  1215. var splitter = new C(SUPPORTS_Y ? rx : '^(?:' + rx.source + ')', flags);
  1216. var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
  1217. if (lim === 0) return [];
  1218. if (S.length === 0) return regexpExecAbstract(splitter, S) === null ? [S] : [];
  1219. var p = 0;
  1220. var q = 0;
  1221. var A = [];
  1222. while (q < S.length) {
  1223. splitter.lastIndex = SUPPORTS_Y ? q : 0;
  1224. var z = regexpExecAbstract(splitter, SUPPORTS_Y ? S : S.slice(q));
  1225. var e;
  1226. if (
  1227. z === null ||
  1228. (e = min$3(toLength(splitter.lastIndex + (SUPPORTS_Y ? 0 : q)), S.length)) === p
  1229. ) {
  1230. q = advanceStringIndex(S, q, unicodeMatching);
  1231. } else {
  1232. A.push(S.slice(p, q));
  1233. if (A.length === lim) return A;
  1234. for (var i = 1; i <= z.length - 1; i++) {
  1235. A.push(z[i]);
  1236. if (A.length === lim) return A;
  1237. }
  1238. q = p = e;
  1239. }
  1240. }
  1241. A.push(S.slice(p));
  1242. return A;
  1243. }
  1244. ];
  1245. }, !SUPPORTS_Y);
  1246. // a string of all valid unicode whitespaces
  1247. // eslint-disable-next-line max-len
  1248. var whitespaces = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
  1249. var whitespace = '[' + whitespaces + ']';
  1250. var ltrim = RegExp('^' + whitespace + whitespace + '*');
  1251. var rtrim = RegExp(whitespace + whitespace + '*$');
  1252. // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
  1253. var createMethod$3 = function (TYPE) {
  1254. return function ($this) {
  1255. var string = String(requireObjectCoercible($this));
  1256. if (TYPE & 1) string = string.replace(ltrim, '');
  1257. if (TYPE & 2) string = string.replace(rtrim, '');
  1258. return string;
  1259. };
  1260. };
  1261. var stringTrim = {
  1262. // `String.prototype.{ trimLeft, trimStart }` methods
  1263. // https://tc39.github.io/ecma262/#sec-string.prototype.trimstart
  1264. start: createMethod$3(1),
  1265. // `String.prototype.{ trimRight, trimEnd }` methods
  1266. // https://tc39.github.io/ecma262/#sec-string.prototype.trimend
  1267. end: createMethod$3(2),
  1268. // `String.prototype.trim` method
  1269. // https://tc39.github.io/ecma262/#sec-string.prototype.trim
  1270. trim: createMethod$3(3)
  1271. };
  1272. var non = '\u200B\u0085\u180E';
  1273. // check that a method works with the correct list
  1274. // of whitespaces and has a correct name
  1275. var forcedStringTrimMethod = function (METHOD_NAME) {
  1276. return fails(function () {
  1277. return !!whitespaces[METHOD_NAME]() || non[METHOD_NAME]() != non || whitespaces[METHOD_NAME].name !== METHOD_NAME;
  1278. });
  1279. };
  1280. var $trim = stringTrim.trim;
  1281. // `String.prototype.trim` method
  1282. // https://tc39.github.io/ecma262/#sec-string.prototype.trim
  1283. _export({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, {
  1284. trim: function trim() {
  1285. return $trim(this);
  1286. }
  1287. });
  1288. // iterable DOM collections
  1289. // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
  1290. var domIterables = {
  1291. CSSRuleList: 0,
  1292. CSSStyleDeclaration: 0,
  1293. CSSValueList: 0,
  1294. ClientRectList: 0,
  1295. DOMRectList: 0,
  1296. DOMStringList: 0,
  1297. DOMTokenList: 1,
  1298. DataTransferItemList: 0,
  1299. FileList: 0,
  1300. HTMLAllCollection: 0,
  1301. HTMLCollection: 0,
  1302. HTMLFormElement: 0,
  1303. HTMLSelectElement: 0,
  1304. MediaList: 0,
  1305. MimeTypeArray: 0,
  1306. NamedNodeMap: 0,
  1307. NodeList: 1,
  1308. PaintRequestList: 0,
  1309. Plugin: 0,
  1310. PluginArray: 0,
  1311. SVGLengthList: 0,
  1312. SVGNumberList: 0,
  1313. SVGPathSegList: 0,
  1314. SVGPointList: 0,
  1315. SVGStringList: 0,
  1316. SVGTransformList: 0,
  1317. SourceBufferList: 0,
  1318. StyleSheetList: 0,
  1319. TextTrackCueList: 0,
  1320. TextTrackList: 0,
  1321. TouchList: 0
  1322. };
  1323. var $forEach = arrayIteration.forEach;
  1324. // `Array.prototype.forEach` method implementation
  1325. // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
  1326. var arrayForEach = sloppyArrayMethod('forEach') ? function forEach(callbackfn /* , thisArg */) {
  1327. return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  1328. } : [].forEach;
  1329. for (var COLLECTION_NAME in domIterables) {
  1330. var Collection = global_1[COLLECTION_NAME];
  1331. var CollectionPrototype = Collection && Collection.prototype;
  1332. // some Chrome versions have non-configurable methods on DOMTokenList
  1333. if (CollectionPrototype && CollectionPrototype.forEach !== arrayForEach) try {
  1334. hide(CollectionPrototype, 'forEach', arrayForEach);
  1335. } catch (error) {
  1336. CollectionPrototype.forEach = arrayForEach;
  1337. }
  1338. }
  1339. function _typeof(obj) {
  1340. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  1341. _typeof = function (obj) {
  1342. return typeof obj;
  1343. };
  1344. } else {
  1345. _typeof = function (obj) {
  1346. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  1347. };
  1348. }
  1349. return _typeof(obj);
  1350. }
  1351. function _classCallCheck(instance, Constructor) {
  1352. if (!(instance instanceof Constructor)) {
  1353. throw new TypeError("Cannot call a class as a function");
  1354. }
  1355. }
  1356. function _defineProperties(target, props) {
  1357. for (var i = 0; i < props.length; i++) {
  1358. var descriptor = props[i];
  1359. descriptor.enumerable = descriptor.enumerable || false;
  1360. descriptor.configurable = true;
  1361. if ("value" in descriptor) descriptor.writable = true;
  1362. Object.defineProperty(target, descriptor.key, descriptor);
  1363. }
  1364. }
  1365. function _createClass(Constructor, protoProps, staticProps) {
  1366. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  1367. if (staticProps) _defineProperties(Constructor, staticProps);
  1368. return Constructor;
  1369. }
  1370. function _inherits(subClass, superClass) {
  1371. if (typeof superClass !== "function" && superClass !== null) {
  1372. throw new TypeError("Super expression must either be null or a function");
  1373. }
  1374. subClass.prototype = Object.create(superClass && superClass.prototype, {
  1375. constructor: {
  1376. value: subClass,
  1377. writable: true,
  1378. configurable: true
  1379. }
  1380. });
  1381. if (superClass) _setPrototypeOf(subClass, superClass);
  1382. }
  1383. function _getPrototypeOf(o) {
  1384. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  1385. return o.__proto__ || Object.getPrototypeOf(o);
  1386. };
  1387. return _getPrototypeOf(o);
  1388. }
  1389. function _setPrototypeOf(o, p) {
  1390. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  1391. o.__proto__ = p;
  1392. return o;
  1393. };
  1394. return _setPrototypeOf(o, p);
  1395. }
  1396. function _assertThisInitialized(self) {
  1397. if (self === void 0) {
  1398. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  1399. }
  1400. return self;
  1401. }
  1402. function _possibleConstructorReturn(self, call) {
  1403. if (call && (typeof call === "object" || typeof call === "function")) {
  1404. return call;
  1405. }
  1406. return _assertThisInitialized(self);
  1407. }
  1408. function _superPropBase(object, property) {
  1409. while (!Object.prototype.hasOwnProperty.call(object, property)) {
  1410. object = _getPrototypeOf(object);
  1411. if (object === null) break;
  1412. }
  1413. return object;
  1414. }
  1415. function _get(target, property, receiver) {
  1416. if (typeof Reflect !== "undefined" && Reflect.get) {
  1417. _get = Reflect.get;
  1418. } else {
  1419. _get = function _get(target, property, receiver) {
  1420. var base = _superPropBase(target, property);
  1421. if (!base) return;
  1422. var desc = Object.getOwnPropertyDescriptor(base, property);
  1423. if (desc.get) {
  1424. return desc.get.call(receiver);
  1425. }
  1426. return desc.value;
  1427. };
  1428. }
  1429. return _get(target, property, receiver || target);
  1430. }
  1431. /**
  1432. * @author: Dennis Hernández
  1433. * @webSite: http://djhvscf.github.io/Blog
  1434. * @version: v2.2.0
  1435. */
  1436. var Utils = $.fn.bootstrapTable.utils;
  1437. var UtilsFilterControl = {
  1438. getOptionsFromSelectControl: function getOptionsFromSelectControl(selectControl) {
  1439. return selectControl.get(selectControl.length - 1).options;
  1440. },
  1441. hideUnusedSelectOptions: function hideUnusedSelectOptions(selectControl, uniqueValues) {
  1442. var options = UtilsFilterControl.getOptionsFromSelectControl(selectControl);
  1443. for (var i = 0; i < options.length; i++) {
  1444. if (options[i].value !== '') {
  1445. if (!uniqueValues.hasOwnProperty(options[i].value)) {
  1446. selectControl.find(Utils.sprintf('option[value=\'%s\']', options[i].value)).hide();
  1447. } else {
  1448. selectControl.find(Utils.sprintf('option[value=\'%s\']', options[i].value)).show();
  1449. }
  1450. }
  1451. }
  1452. },
  1453. addOptionToSelectControl: function addOptionToSelectControl(selectControl, _value, text, selected) {
  1454. var value = $.trim(_value);
  1455. var $selectControl = $(selectControl.get(selectControl.length - 1));
  1456. if (!UtilsFilterControl.existOptionInSelectControl(selectControl, value)) {
  1457. var option = $($('<option></option>').attr('value', value).text($('<div />').html(text).text()));
  1458. if (value === selected) {
  1459. option.attr('selected', true);
  1460. }
  1461. $selectControl.append(option);
  1462. }
  1463. },
  1464. sortSelectControl: function sortSelectControl(selectControl, orderBy) {
  1465. var $selectControl = $(selectControl.get(selectControl.length - 1));
  1466. var $opts = $selectControl.find('option:gt(0)');
  1467. $opts.sort(function (a, b) {
  1468. return Utils.sort(a.textContent, b.textContent, orderBy === 'desc' ? -1 : 1);
  1469. });
  1470. $selectControl.find('option:gt(0)').remove();
  1471. $selectControl.append($opts);
  1472. },
  1473. existOptionInSelectControl: function existOptionInSelectControl(selectControl, value) {
  1474. var options = UtilsFilterControl.getOptionsFromSelectControl(selectControl);
  1475. for (var i = 0; i < options.length; i++) {
  1476. if (options[i].value === value.toString()) {
  1477. // The value is not valid to add
  1478. return true;
  1479. }
  1480. } // If we get here, the value is valid to add
  1481. return false;
  1482. },
  1483. fixHeaderCSS: function fixHeaderCSS(_ref) {
  1484. var $tableHeader = _ref.$tableHeader;
  1485. $tableHeader.css('height', '77px');
  1486. },
  1487. getCurrentHeader: function getCurrentHeader(_ref2) {
  1488. var $header = _ref2.$header,
  1489. options = _ref2.options,
  1490. $tableHeader = _ref2.$tableHeader;
  1491. var header = $header;
  1492. if (options.height) {
  1493. header = $tableHeader;
  1494. }
  1495. return header;
  1496. },
  1497. getCurrentSearchControls: function getCurrentSearchControls(_ref3) {
  1498. var options = _ref3.options;
  1499. var searchControls = 'select, input';
  1500. if (options.height) {
  1501. searchControls = 'table select, table input';
  1502. }
  1503. return searchControls;
  1504. },
  1505. getCursorPosition: function getCursorPosition(el) {
  1506. if (Utils.isIEBrowser()) {
  1507. if ($(el).is('input[type=text]')) {
  1508. var pos = 0;
  1509. if ('selectionStart' in el) {
  1510. pos = el.selectionStart;
  1511. } else if ('selection' in document) {
  1512. el.focus();
  1513. var Sel = document.selection.createRange();
  1514. var SelLength = document.selection.createRange().text.length;
  1515. Sel.moveStart('character', -el.value.length);
  1516. pos = Sel.text.length - SelLength;
  1517. }
  1518. return pos;
  1519. }
  1520. return -1;
  1521. }
  1522. return -1;
  1523. },
  1524. setCursorPosition: function setCursorPosition(el) {
  1525. $(el).val(el.value);
  1526. },
  1527. copyValues: function copyValues(that) {
  1528. var header = UtilsFilterControl.getCurrentHeader(that);
  1529. var searchControls = UtilsFilterControl.getCurrentSearchControls(that);
  1530. that.options.valuesFilterControl = [];
  1531. header.find(searchControls).each(function () {
  1532. that.options.valuesFilterControl.push({
  1533. field: $(this).closest('[data-field]').data('field'),
  1534. value: $(this).val(),
  1535. position: UtilsFilterControl.getCursorPosition($(this).get(0)),
  1536. hasFocus: $(this).is(':focus')
  1537. });
  1538. });
  1539. },
  1540. setValues: function setValues(that) {
  1541. var field = null;
  1542. var result = [];
  1543. var header = UtilsFilterControl.getCurrentHeader(that);
  1544. var searchControls = UtilsFilterControl.getCurrentSearchControls(that);
  1545. if (that.options.valuesFilterControl.length > 0) {
  1546. // Callback to apply after settings fields values
  1547. var fieldToFocusCallback = null;
  1548. header.find(searchControls).each(function (index, ele) {
  1549. field = $(this).closest('[data-field]').data('field');
  1550. result = that.options.valuesFilterControl.filter(function (valueObj) {
  1551. return valueObj.field === field;
  1552. });
  1553. if (result.length > 0) {
  1554. $(this).val(result[0].value);
  1555. if (result[0].hasFocus) {
  1556. // set callback if the field had the focus.
  1557. fieldToFocusCallback = function (fieldToFocus, carretPosition) {
  1558. // Closure here to capture the field and cursor position
  1559. var closedCallback = function closedCallback() {
  1560. fieldToFocus.focus();
  1561. UtilsFilterControl.setCursorPosition(fieldToFocus, carretPosition);
  1562. };
  1563. return closedCallback;
  1564. }($(this).get(0), result[0].position);
  1565. }
  1566. }
  1567. }); // Callback call.
  1568. if (fieldToFocusCallback !== null) {
  1569. fieldToFocusCallback();
  1570. }
  1571. }
  1572. },
  1573. collectBootstrapCookies: function collectBootstrapCookies() {
  1574. var cookies = [];
  1575. var foundCookies = document.cookie.match(/(?:bs.table.)(\w*)/g);
  1576. if (foundCookies) {
  1577. $.each(foundCookies, function (i, _cookie) {
  1578. var cookie = _cookie;
  1579. if (/./.test(cookie)) {
  1580. cookie = cookie.split('.').pop();
  1581. }
  1582. if ($.inArray(cookie, cookies) === -1) {
  1583. cookies.push(cookie);
  1584. }
  1585. });
  1586. return cookies;
  1587. }
  1588. },
  1589. escapeID: function escapeID(id) {
  1590. return String(id).replace(/(:|\.|\[|\]|,)/g, '\\$1');
  1591. },
  1592. isColumnSearchableViaSelect: function isColumnSearchableViaSelect(_ref4) {
  1593. var filterControl = _ref4.filterControl,
  1594. searchable = _ref4.searchable;
  1595. return filterControl && filterControl.toLowerCase() === 'select' && searchable;
  1596. },
  1597. isFilterDataNotGiven: function isFilterDataNotGiven(_ref5) {
  1598. var filterData = _ref5.filterData;
  1599. return filterData === undefined || filterData.toLowerCase() === 'column';
  1600. },
  1601. hasSelectControlElement: function hasSelectControlElement(selectControl) {
  1602. return selectControl && selectControl.length > 0;
  1603. },
  1604. initFilterSelectControls: function initFilterSelectControls(that) {
  1605. var data = that.data;
  1606. var itemsPerPage = that.pageTo < that.options.data.length ? that.options.data.length : that.pageTo;
  1607. var z = that.options.pagination ? that.options.sidePagination === 'server' ? that.pageTo : that.options.totalRows : that.pageTo;
  1608. $.each(that.header.fields, function (j, field) {
  1609. var column = that.columns[that.fieldsColumnsIndex[field]];
  1610. var selectControl = $(".bootstrap-table-filter-control-".concat(UtilsFilterControl.escapeID(column.field)));
  1611. if (UtilsFilterControl.isColumnSearchableViaSelect(column) && UtilsFilterControl.isFilterDataNotGiven(column) && UtilsFilterControl.hasSelectControlElement(selectControl)) {
  1612. if (selectControl.get(selectControl.length - 1).options.length === 0) {
  1613. // Added the default option
  1614. UtilsFilterControl.addOptionToSelectControl(selectControl, '', column.filterControlPlaceholder, column.filterDefault);
  1615. }
  1616. var uniqueValues = {};
  1617. for (var i = 0; i < z; i++) {
  1618. // Added a new value
  1619. var fieldValue = data[i][field];
  1620. var formattedValue = Utils.calculateObjectValue(that.header, that.header.formatters[j], [fieldValue, data[i], i], fieldValue);
  1621. if (column.filterDataCollector) {
  1622. formattedValue = Utils.calculateObjectValue(that.header, column.filterDataCollector, [fieldValue, data[i], formattedValue], formattedValue);
  1623. }
  1624. if (_typeof(formattedValue) === 'object') {
  1625. formattedValue.forEach(function (value) {
  1626. UtilsFilterControl.addOptionToSelectControl(selectControl, value, value, column.filterDefault);
  1627. });
  1628. continue;
  1629. }
  1630. UtilsFilterControl.addOptionToSelectControl(selectControl, formattedValue, formattedValue, column.filterDefault);
  1631. }
  1632. UtilsFilterControl.sortSelectControl(selectControl, column.filterOrderBy);
  1633. if (that.options.hideUnusedSelectOptions) {
  1634. UtilsFilterControl.hideUnusedSelectOptions(selectControl, uniqueValues);
  1635. }
  1636. }
  1637. });
  1638. that.trigger('created-controls');
  1639. },
  1640. getFilterDataMethod: function getFilterDataMethod(objFilterDataMethod, searchTerm) {
  1641. var keys = Object.keys(objFilterDataMethod);
  1642. for (var i = 0; i < keys.length; i++) {
  1643. if (keys[i] === searchTerm) {
  1644. return objFilterDataMethod[searchTerm];
  1645. }
  1646. }
  1647. return null;
  1648. },
  1649. createControls: function createControls(that, header) {
  1650. var addedFilterControl = false;
  1651. var isVisible;
  1652. var html;
  1653. $.each(that.columns, function (i, column) {
  1654. isVisible = 'hidden';
  1655. html = [];
  1656. if (!column.visible) {
  1657. return;
  1658. }
  1659. if (!column.filterControl) {
  1660. html.push('<div class="no-filter-control"></div>');
  1661. } else {
  1662. html.push('<div class="filter-control">');
  1663. var nameControl = column.filterControl.toLowerCase();
  1664. if (column.searchable && that.options.filterTemplate[nameControl]) {
  1665. addedFilterControl = true;
  1666. isVisible = 'visible';
  1667. html.push(that.options.filterTemplate[nameControl](that, column.field, isVisible, column.filterControlPlaceholder ? column.filterControlPlaceholder : '', column.filterDefault));
  1668. if ('' !== column.filterDefault && 'undefined' !== typeof column.filterDefault) {
  1669. if ($.isEmptyObject(that.filterColumnsPartial)) {
  1670. that.filterColumnsPartial = {};
  1671. }
  1672. that.filterColumnsPartial[column.field] = column.filterDefault;
  1673. }
  1674. }
  1675. }
  1676. $.each(header.children().children(), function (i, tr) {
  1677. var $tr = $(tr);
  1678. if ($tr.data('field') === column.field) {
  1679. $tr.find('.fht-cell').append(html.join(''));
  1680. return false;
  1681. }
  1682. });
  1683. if (column.filterData !== undefined && column.filterData.toLowerCase() !== 'column') {
  1684. var filterDataType = UtilsFilterControl.getFilterDataMethod(
  1685. /* eslint-disable no-use-before-define */
  1686. filterDataMethods, column.filterData.substring(0, column.filterData.indexOf(':')));
  1687. var filterDataSource;
  1688. var selectControl;
  1689. if (filterDataType !== null) {
  1690. filterDataSource = column.filterData.substring(column.filterData.indexOf(':') + 1, column.filterData.length);
  1691. selectControl = $(".bootstrap-table-filter-control-".concat(UtilsFilterControl.escapeID(column.field)));
  1692. UtilsFilterControl.addOptionToSelectControl(selectControl, '', column.filterControlPlaceholder, column.filterDefault);
  1693. filterDataType(filterDataSource, selectControl, column.filterDefault);
  1694. } else {
  1695. throw new SyntaxError('Error. You should use any of these allowed filter data methods: var, json, url.' + ' Use like this: var: {key: "value"}');
  1696. }
  1697. var variableValues;
  1698. var key; // eslint-disable-next-line default-case
  1699. switch (filterDataType) {
  1700. case 'url':
  1701. $.ajax({
  1702. url: filterDataSource,
  1703. dataType: 'json',
  1704. success: function success(data) {
  1705. // eslint-disable-next-line guard-for-in
  1706. for (var _key in data) {
  1707. UtilsFilterControl.addOptionToSelectControl(selectControl, _key, data[_key], column.filterDefault);
  1708. }
  1709. UtilsFilterControl.sortSelectControl(selectControl, column.filterOrderBy);
  1710. }
  1711. });
  1712. break;
  1713. case 'var':
  1714. variableValues = window[filterDataSource]; // eslint-disable-next-line guard-for-in
  1715. for (key in variableValues) {
  1716. UtilsFilterControl.addOptionToSelectControl(selectControl, key, variableValues[key], column.filterDefault);
  1717. }
  1718. UtilsFilterControl.sortSelectControl(selectControl, column.filterOrderBy);
  1719. break;
  1720. case 'jso':
  1721. variableValues = JSON.parse(filterDataSource); // eslint-disable-next-line guard-for-in
  1722. for (key in variableValues) {
  1723. UtilsFilterControl.addOptionToSelectControl(selectControl, key, variableValues[key], column.filterDefault);
  1724. }
  1725. UtilsFilterControl.sortSelectControl(selectControl, column.filterOrderBy);
  1726. break;
  1727. }
  1728. }
  1729. });
  1730. if (addedFilterControl) {
  1731. header.off('keyup', 'input').on('keyup', 'input', function (event, obj) {
  1732. // Simulate enter key action from clear button
  1733. event.keyCode = obj ? obj.keyCode : event.keyCode;
  1734. if (that.options.searchOnEnterKey && event.keyCode !== 13) {
  1735. return;
  1736. }
  1737. if ($.inArray(event.keyCode, [37, 38, 39, 40]) > -1) {
  1738. return;
  1739. }
  1740. var $currentTarget = $(event.currentTarget);
  1741. if ($currentTarget.is(':checkbox') || $currentTarget.is(':radio')) {
  1742. return;
  1743. }
  1744. clearTimeout(event.currentTarget.timeoutId || 0);
  1745. event.currentTarget.timeoutId = setTimeout(function () {
  1746. that.onColumnSearch(event);
  1747. }, that.options.searchTimeOut);
  1748. });
  1749. header.off('change', 'select').on('change', 'select', function (event) {
  1750. if (that.options.searchOnEnterKey && event.keyCode !== 13) {
  1751. return;
  1752. }
  1753. if ($.inArray(event.keyCode, [37, 38, 39, 40]) > -1) {
  1754. return;
  1755. }
  1756. clearTimeout(event.currentTarget.timeoutId || 0);
  1757. event.currentTarget.timeoutId = setTimeout(function () {
  1758. that.onColumnSearch(event);
  1759. }, that.options.searchTimeOut);
  1760. });
  1761. header.off('mouseup', 'input').on('mouseup', 'input', function (event) {
  1762. var $input = $(this);
  1763. var oldValue = $input.val();
  1764. if (oldValue === '') {
  1765. return;
  1766. }
  1767. setTimeout(function () {
  1768. var newValue = $input.val();
  1769. if (newValue === '') {
  1770. clearTimeout(event.currentTarget.timeoutId || 0);
  1771. event.currentTarget.timeoutId = setTimeout(function () {
  1772. that.onColumnSearch(event);
  1773. }, that.options.searchTimeOut);
  1774. }
  1775. }, 1);
  1776. });
  1777. if (header.find('.date-filter-control').length > 0) {
  1778. $.each(that.columns, function (i, _ref6) {
  1779. var filterControl = _ref6.filterControl,
  1780. field = _ref6.field,
  1781. filterDatepickerOptions = _ref6.filterDatepickerOptions;
  1782. if (filterControl !== undefined && filterControl.toLowerCase() === 'datepicker') {
  1783. header.find(".date-filter-control.bootstrap-table-filter-control-".concat(field)).datepicker(filterDatepickerOptions).on('changeDate', function (event) {
  1784. clearTimeout(event.currentTarget.timeoutId || 0);
  1785. event.currentTarget.timeoutId = setTimeout(function () {
  1786. that.onColumnSearch(event);
  1787. }, that.options.searchTimeOut);
  1788. });
  1789. }
  1790. });
  1791. }
  1792. if (that.options.sidePagination !== 'server') {
  1793. header.find('[class*=\'bootstrap-table-filter-control\']').each(function (k, input) {
  1794. $(input).trigger('change');
  1795. });
  1796. }
  1797. } else {
  1798. header.find('.filterControl').hide();
  1799. }
  1800. },
  1801. getDirectionOfSelectOptions: function getDirectionOfSelectOptions(_alignment) {
  1802. var alignment = _alignment === undefined ? 'left' : _alignment.toLowerCase();
  1803. switch (alignment) {
  1804. case 'left':
  1805. return 'ltr';
  1806. case 'right':
  1807. return 'rtl';
  1808. case 'auto':
  1809. return 'auto';
  1810. default:
  1811. return 'ltr';
  1812. }
  1813. }
  1814. };
  1815. var filterDataMethods = {
  1816. var: function _var(filterDataSource, selectControl, filterOrderBy, selected) {
  1817. var variableValues = window[filterDataSource]; // eslint-disable-next-line guard-for-in
  1818. for (var key in variableValues) {
  1819. UtilsFilterControl.addOptionToSelectControl(selectControl, key, variableValues[key], selected);
  1820. }
  1821. UtilsFilterControl.sortSelectControl(selectControl, filterOrderBy);
  1822. },
  1823. url: function url(filterDataSource, selectControl, filterOrderBy, selected) {
  1824. $.ajax({
  1825. url: filterDataSource,
  1826. dataType: 'json',
  1827. success: function success(data) {
  1828. // eslint-disable-next-line guard-for-in
  1829. for (var key in data) {
  1830. UtilsFilterControl.addOptionToSelectControl(selectControl, key, data[key], selected);
  1831. }
  1832. UtilsFilterControl.sortSelectControl(selectControl, filterOrderBy);
  1833. }
  1834. });
  1835. },
  1836. json: function json(filterDataSource, selectControl, filterOrderBy, selected) {
  1837. var variableValues = JSON.parse(filterDataSource); // eslint-disable-next-line guard-for-in
  1838. for (var key in variableValues) {
  1839. UtilsFilterControl.addOptionToSelectControl(selectControl, key, variableValues[key], selected);
  1840. }
  1841. UtilsFilterControl.sortSelectControl(selectControl, filterOrderBy);
  1842. }
  1843. };
  1844. $.extend($.fn.bootstrapTable.defaults, {
  1845. filterControl: false,
  1846. onColumnSearch: function onColumnSearch(field, text) {
  1847. return false;
  1848. },
  1849. onCreatedControls: function onCreatedControls() {
  1850. return true;
  1851. },
  1852. alignmentSelectControlOptions: undefined,
  1853. filterTemplate: {
  1854. input: function input(that, field, isVisible, placeholder, value) {
  1855. return Utils.sprintf('<input type="text" class="form-control bootstrap-table-filter-control-%s" style="width: 100%; visibility: %s" placeholder="%s" value="%s">', field, isVisible, 'undefined' === typeof placeholder ? '' : placeholder, 'undefined' === typeof value ? '' : value);
  1856. },
  1857. select: function select(_ref7, field, isVisible) {
  1858. var options = _ref7.options;
  1859. return Utils.sprintf('<select class="form-control bootstrap-table-filter-control-%s" style="width: 100%; visibility: %s" dir="%s"></select>', field, isVisible, UtilsFilterControl.getDirectionOfSelectOptions(options.alignmentSelectControlOptions));
  1860. },
  1861. datepicker: function datepicker(that, field, isVisible, value) {
  1862. return Utils.sprintf('<input type="text" class="form-control date-filter-control bootstrap-table-filter-control-%s" style="width: 100%; visibility: %s" value="%s">', field, isVisible, 'undefined' === typeof value ? '' : value);
  1863. }
  1864. },
  1865. disableControlWhenSearch: false,
  1866. searchOnEnterKey: false,
  1867. // internal variables
  1868. valuesFilterControl: []
  1869. });
  1870. $.extend($.fn.bootstrapTable.columnDefaults, {
  1871. filterControl: undefined,
  1872. filterDataCollector: undefined,
  1873. filterData: undefined,
  1874. filterDatepickerOptions: undefined,
  1875. filterStrictSearch: false,
  1876. filterStartsWithSearch: false,
  1877. filterControlPlaceholder: '',
  1878. filterDefault: '',
  1879. filterOrderBy: 'asc' // asc || desc
  1880. });
  1881. $.extend($.fn.bootstrapTable.Constructor.EVENTS, {
  1882. 'column-search.bs.table': 'onColumnSearch',
  1883. 'created-controls.bs.table': 'onCreatedControls'
  1884. });
  1885. $.extend($.fn.bootstrapTable.defaults.icons, {
  1886. clear: {
  1887. bootstrap3: 'glyphicon-trash icon-clear'
  1888. }[$.fn.bootstrapTable.theme] || 'fa-trash'
  1889. });
  1890. $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
  1891. $.extend($.fn.bootstrapTable.defaults, {
  1892. formatClearSearch: function formatClearSearch() {
  1893. return 'Clear filters';
  1894. }
  1895. });
  1896. $.fn.bootstrapTable.methods.push('triggerSearch');
  1897. $.fn.bootstrapTable.methods.push('clearFilterControl');
  1898. $.BootstrapTable =
  1899. /*#__PURE__*/
  1900. function (_$$BootstrapTable) {
  1901. _inherits(_class, _$$BootstrapTable);
  1902. function _class() {
  1903. _classCallCheck(this, _class);
  1904. return _possibleConstructorReturn(this, _getPrototypeOf(_class).apply(this, arguments));
  1905. }
  1906. _createClass(_class, [{
  1907. key: "init",
  1908. value: function init() {
  1909. var _this = this;
  1910. // Make sure that the filterControl option is set
  1911. if (this.options.filterControl) {
  1912. var that = this; // Make sure that the internal variables are set correctly
  1913. this.options.valuesFilterControl = [];
  1914. this.$el.on('reset-view.bs.table', function () {
  1915. // Create controls on $tableHeader if the height is set
  1916. if (!that.options.height) {
  1917. return;
  1918. } // Avoid recreate the controls
  1919. if (that.$tableHeader.find('select').length > 0 || that.$tableHeader.find('input').length > 0) {
  1920. return;
  1921. }
  1922. UtilsFilterControl.createControls(that, that.$tableHeader);
  1923. }).on('post-header.bs.table', function () {
  1924. UtilsFilterControl.setValues(that);
  1925. }).on('post-body.bs.table', function () {
  1926. if (that.options.height) {
  1927. UtilsFilterControl.fixHeaderCSS(that);
  1928. }
  1929. _this.$tableLoading.css('top', _this.$header.outerHeight() + 1);
  1930. }).on('column-switch.bs.table', function () {
  1931. UtilsFilterControl.setValues(that);
  1932. }).on('load-success.bs.table', function () {
  1933. that.EnableControls(true);
  1934. }).on('load-error.bs.table', function () {
  1935. that.EnableControls(true);
  1936. });
  1937. }
  1938. _get(_getPrototypeOf(_class.prototype), "init", this).call(this);
  1939. }
  1940. }, {
  1941. key: "initHeader",
  1942. value: function initHeader() {
  1943. _get(_getPrototypeOf(_class.prototype), "initHeader", this).call(this);
  1944. if (!this.options.filterControl) {
  1945. return;
  1946. }
  1947. UtilsFilterControl.createControls(this, this.$header);
  1948. }
  1949. }, {
  1950. key: "initBody",
  1951. value: function initBody() {
  1952. _get(_getPrototypeOf(_class.prototype), "initBody", this).call(this);
  1953. UtilsFilterControl.initFilterSelectControls(this);
  1954. }
  1955. }, {
  1956. key: "initSearch",
  1957. value: function initSearch() {
  1958. var that = this;
  1959. var fp = $.isEmptyObject(that.filterColumnsPartial) ? null : that.filterColumnsPartial;
  1960. if (fp === null || Object.keys(fp).length <= 1) {
  1961. _get(_getPrototypeOf(_class.prototype), "initSearch", this).call(this);
  1962. }
  1963. if (this.options.sidePagination === 'server') {
  1964. return;
  1965. }
  1966. if (fp === null) {
  1967. return;
  1968. } // Check partial column filter
  1969. that.data = fp ? that.options.data.filter(function (item, i) {
  1970. var itemIsExpected = [];
  1971. Object.keys(item).forEach(function (x, index) {
  1972. var key = that.header.fields[index];
  1973. var thisColumn = that.columns[that.fieldsColumnsIndex[key]];
  1974. var fval = (fp[key] || '').toLowerCase();
  1975. var value = Utils.getItemField(item, key, false);
  1976. if (fval === '') {
  1977. itemIsExpected.push(true);
  1978. } else {
  1979. // Fix #142: search use formated data
  1980. if (thisColumn && thisColumn.searchFormatter) {
  1981. value = $.fn.bootstrapTable.utils.calculateObjectValue(that.header, that.header.formatters[$.inArray(key, that.header.fields)], [value, item, i], value);
  1982. }
  1983. if ($.inArray(key, that.header.fields) !== -1) {
  1984. if (value === undefined || value === null) {
  1985. itemIsExpected.push(false);
  1986. } else if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
  1987. if (thisColumn.filterStrictSearch) {
  1988. itemIsExpected.push(value.toString().toLowerCase() === fval.toString().toLowerCase());
  1989. } else if (thisColumn.filterStartsWithSearch) {
  1990. itemIsExpected.push("".concat(value).toLowerCase().indexOf(fval) === 0);
  1991. } else {
  1992. itemIsExpected.push("".concat(value).toLowerCase().includes(fval));
  1993. }
  1994. }
  1995. }
  1996. }
  1997. });
  1998. return !itemIsExpected.includes(false);
  1999. }) : that.data;
  2000. }
  2001. }, {
  2002. key: "initColumnSearch",
  2003. value: function initColumnSearch(filterColumnsDefaults) {
  2004. UtilsFilterControl.copyValues(this);
  2005. if (filterColumnsDefaults) {
  2006. this.filterColumnsPartial = filterColumnsDefaults;
  2007. this.updatePagination(); // eslint-disable-next-line guard-for-in
  2008. for (var filter in filterColumnsDefaults) {
  2009. this.trigger('column-search', filter, filterColumnsDefaults[filter]);
  2010. }
  2011. }
  2012. }
  2013. }, {
  2014. key: "onColumnSearch",
  2015. value: function onColumnSearch(event) {
  2016. if ($.inArray(event.keyCode, [37, 38, 39, 40]) > -1) {
  2017. return;
  2018. }
  2019. UtilsFilterControl.copyValues(this);
  2020. var text = $.trim($(event.currentTarget).val());
  2021. var $field = $(event.currentTarget).closest('[data-field]').data('field');
  2022. if ($.isEmptyObject(this.filterColumnsPartial)) {
  2023. this.filterColumnsPartial = {};
  2024. }
  2025. if (text) {
  2026. this.filterColumnsPartial[$field] = text;
  2027. } else {
  2028. delete this.filterColumnsPartial[$field];
  2029. }
  2030. this.options.pageNumber = 1;
  2031. this.EnableControls(false);
  2032. this.onSearch(event, false);
  2033. this.trigger('column-search', $field, text);
  2034. }
  2035. }, {
  2036. key: "resetSearch",
  2037. value: function resetSearch() {
  2038. if (this.options.filterControl && this.options.showSearchClearButton) {
  2039. this.clearFilterControl();
  2040. }
  2041. _get(_getPrototypeOf(_class.prototype), "resetSearch", this).call(this);
  2042. }
  2043. }, {
  2044. key: "clearFilterControl",
  2045. value: function clearFilterControl() {
  2046. if (this.options.filterControl) {
  2047. var that = this;
  2048. var cookies = UtilsFilterControl.collectBootstrapCookies();
  2049. var header = UtilsFilterControl.getCurrentHeader(that);
  2050. var table = header.closest('table');
  2051. var controls = header.find(UtilsFilterControl.getCurrentSearchControls(that));
  2052. var search = that.$toolbar.find('.search input');
  2053. var hasValues = false;
  2054. var timeoutId = 0;
  2055. $.each(that.options.valuesFilterControl, function (i, item) {
  2056. hasValues = hasValues ? true : item.value !== '';
  2057. item.value = '';
  2058. });
  2059. $.each(that.options.filterControls, function (i, item) {
  2060. item.text = '';
  2061. });
  2062. UtilsFilterControl.setValues(that); // clear cookies once the filters are clean
  2063. clearTimeout(timeoutId);
  2064. timeoutId = setTimeout(function () {
  2065. if (cookies && cookies.length > 0) {
  2066. $.each(cookies, function (i, item) {
  2067. if (that.deleteCookie !== undefined) {
  2068. that.deleteCookie(item);
  2069. }
  2070. });
  2071. }
  2072. }, that.options.searchTimeOut); // If there is not any value in the controls exit this method
  2073. if (!hasValues) {
  2074. return;
  2075. } // Clear each type of filter if it exists.
  2076. // Requires the body to reload each time a type of filter is found because we never know
  2077. // which ones are going to be present.
  2078. if (controls.length > 0) {
  2079. this.filterColumnsPartial = {};
  2080. $(controls[0]).trigger(controls[0].tagName === 'INPUT' ? 'keyup' : 'change', {
  2081. keyCode: 13
  2082. });
  2083. } else {
  2084. return;
  2085. }
  2086. if (search.length > 0) {
  2087. that.resetSearch();
  2088. } // use the default sort order if it exists. do nothing if it does not
  2089. if (that.options.sortName !== table.data('sortName') || that.options.sortOrder !== table.data('sortOrder')) {
  2090. var sorter = header.find(Utils.sprintf('[data-field="%s"]', $(controls[0]).closest('table').data('sortName')));
  2091. if (sorter.length > 0) {
  2092. that.onSort({
  2093. type: 'keypress',
  2094. currentTarget: sorter
  2095. });
  2096. $(sorter).find('.sortable').trigger('click');
  2097. }
  2098. }
  2099. }
  2100. }
  2101. }, {
  2102. key: "triggerSearch",
  2103. value: function triggerSearch() {
  2104. var header = UtilsFilterControl.getCurrentHeader(this);
  2105. var searchControls = UtilsFilterControl.getCurrentSearchControls(this);
  2106. header.find(searchControls).each(function () {
  2107. var el = $(this);
  2108. if (el.is('select')) {
  2109. el.change();
  2110. } else {
  2111. el.keyup();
  2112. }
  2113. });
  2114. }
  2115. }, {
  2116. key: "EnableControls",
  2117. value: function EnableControls(enable) {
  2118. if (this.options.disableControlWhenSearch && this.options.sidePagination === 'server') {
  2119. var header = UtilsFilterControl.getCurrentHeader(this);
  2120. var searchControls = UtilsFilterControl.getCurrentSearchControls(this);
  2121. if (!enable) {
  2122. header.find(searchControls).prop('disabled', 'disabled');
  2123. } else {
  2124. header.find(searchControls).removeProp('disabled');
  2125. }
  2126. }
  2127. }
  2128. }]);
  2129. return _class;
  2130. }($.BootstrapTable);
  2131. }));