bootstrap-table-filter-control.js 84 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502
  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' && formattedValue !== null) {
  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: "initToolbar",
  2037. value: function initToolbar() {
  2038. this.showSearchClearButton = this.options.filterControl && this.options.showSearchClearButton;
  2039. _get(_getPrototypeOf(_class.prototype), "initToolbar", this).call(this);
  2040. }
  2041. }, {
  2042. key: "resetSearch",
  2043. value: function resetSearch() {
  2044. if (this.options.filterControl && this.options.showSearchClearButton) {
  2045. this.clearFilterControl();
  2046. }
  2047. _get(_getPrototypeOf(_class.prototype), "resetSearch", this).call(this);
  2048. }
  2049. }, {
  2050. key: "clearFilterControl",
  2051. value: function clearFilterControl() {
  2052. if (this.options.filterControl) {
  2053. var that = this;
  2054. var cookies = UtilsFilterControl.collectBootstrapCookies();
  2055. var header = UtilsFilterControl.getCurrentHeader(that);
  2056. var table = header.closest('table');
  2057. var controls = header.find(UtilsFilterControl.getCurrentSearchControls(that));
  2058. var search = that.$toolbar.find('.search input');
  2059. var hasValues = false;
  2060. var timeoutId = 0;
  2061. $.each(that.options.valuesFilterControl, function (i, item) {
  2062. hasValues = hasValues ? true : item.value !== '';
  2063. item.value = '';
  2064. });
  2065. $.each(that.options.filterControls, function (i, item) {
  2066. item.text = '';
  2067. });
  2068. UtilsFilterControl.setValues(that); // clear cookies once the filters are clean
  2069. clearTimeout(timeoutId);
  2070. timeoutId = setTimeout(function () {
  2071. if (cookies && cookies.length > 0) {
  2072. $.each(cookies, function (i, item) {
  2073. if (that.deleteCookie !== undefined) {
  2074. that.deleteCookie(item);
  2075. }
  2076. });
  2077. }
  2078. }, that.options.searchTimeOut); // If there is not any value in the controls exit this method
  2079. if (!hasValues) {
  2080. return;
  2081. } // Clear each type of filter if it exists.
  2082. // Requires the body to reload each time a type of filter is found because we never know
  2083. // which ones are going to be present.
  2084. if (controls.length > 0) {
  2085. this.filterColumnsPartial = {};
  2086. $(controls[0]).trigger(controls[0].tagName === 'INPUT' ? 'keyup' : 'change', {
  2087. keyCode: 13
  2088. });
  2089. } else {
  2090. return;
  2091. }
  2092. if (search.length > 0) {
  2093. that.resetSearch();
  2094. } // use the default sort order if it exists. do nothing if it does not
  2095. if (that.options.sortName !== table.data('sortName') || that.options.sortOrder !== table.data('sortOrder')) {
  2096. var sorter = header.find(Utils.sprintf('[data-field="%s"]', $(controls[0]).closest('table').data('sortName')));
  2097. if (sorter.length > 0) {
  2098. that.onSort({
  2099. type: 'keypress',
  2100. currentTarget: sorter
  2101. });
  2102. $(sorter).find('.sortable').trigger('click');
  2103. }
  2104. }
  2105. }
  2106. }
  2107. }, {
  2108. key: "triggerSearch",
  2109. value: function triggerSearch() {
  2110. var header = UtilsFilterControl.getCurrentHeader(this);
  2111. var searchControls = UtilsFilterControl.getCurrentSearchControls(this);
  2112. header.find(searchControls).each(function () {
  2113. var el = $(this);
  2114. if (el.is('select')) {
  2115. el.change();
  2116. } else {
  2117. el.keyup();
  2118. }
  2119. });
  2120. }
  2121. }, {
  2122. key: "EnableControls",
  2123. value: function EnableControls(enable) {
  2124. if (this.options.disableControlWhenSearch && this.options.sidePagination === 'server') {
  2125. var header = UtilsFilterControl.getCurrentHeader(this);
  2126. var searchControls = UtilsFilterControl.getCurrentSearchControls(this);
  2127. if (!enable) {
  2128. header.find(searchControls).prop('disabled', 'disabled');
  2129. } else {
  2130. header.find(searchControls).removeProp('disabled');
  2131. }
  2132. }
  2133. }
  2134. }]);
  2135. return _class;
  2136. }($.BootstrapTable);
  2137. }));